Example usage for org.eclipse.jface.dialogs MessageDialog QUESTION

List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog QUESTION.

Prototype

int QUESTION

To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.

Click Source Link

Document

Constant for the question image, or a simple dialog with the question image and Yes/No buttons (value 3).

Usage

From source file:com.aptana.ide.ui.ftp.dialogs.FTPConnectionPointPropertyDialog.java

License:Open Source License

@Override
protected void okPressed() {
    if (!isValid()) {
        return;/*from   w ww .  j  av  a  2  s.  c o m*/
    }
    if (DEFAULT_NAME.equals(nameText.getText())) {
        nameText.setText(hostText.getText());
    }
    if (!connectionTested) {
        if (!testConnection()) {
            MessageDialog dlg = new MessageDialog(getShell(),
                    Messages.FTPConnectionPointPropertyDialog_ConfirmTitle, null,
                    Messages.FTPConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            Messages.FTPConnectionPointPropertyDialog_LBL_Edit },
                    2);
            int code = dlg.open();
            switch (code) {
            case 1:
                super.okPressed();
            case 2:
                return;
            default:
            }
        }
    }
    CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(ftpConnectionPoint),
            passwordText.getText().toCharArray(), savePasswordButton.getSelection());

    boolean changed = savePropertiesTo(ftpConnectionPoint);
    if (isNew) {
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint);
    } else if (ftpConnectionPoint != originalFtpConnectionPoint) {
        CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalFtpConnectionPoint);
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint);
    } else if (changed) {
        CoreIOPlugin.getConnectionPointManager().connectionPointChanged(ftpConnectionPoint);
    }
    super.okPressed();
}

From source file:com.aptana.internal.ui.text.spelling.OptionsConfigurationBlock.java

License:Open Source License

protected boolean processChanges(IWorkbenchPreferenceContainer container) {
    final IScopeContext currContext = this.fLookupOrder[0];

    final List /* <Key> */ changedOptions = new ArrayList();
    boolean needsBuild = this.getChanges(currContext, changedOptions);
    if (changedOptions.isEmpty()) {
        return true;
    }/*from  ww  w .  java  2 s .com*/
    if (needsBuild) {
        final int count = this.getRebuildCount();
        if (count > this.fRebuildCount) {
            needsBuild = false; // build already requested
            this.fRebuildCount = count;
        }
    }

    boolean doBuild = false;
    if (needsBuild) {
        final String[] strings = this.getFullBuildDialogStrings(true);
        if (strings != null) {
            final MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1],
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    2);
            final int res = dialog.open();
            if (res == 0) {
                doBuild = true;
            } else if (res != 1) {
                return false; // cancel pressed
            }
        }
    }
    if (container != null) {
        // no need to apply the changes to the original store: will be done
        // by the page container
        if (doBuild) { // post build
            this.incrementRebuildCount();
            //container.registerUpdateJob(CoreUtility.getBuildJob(fProject))
            // ;
        }
    } else {
        // apply changes right away
        try {
            this.fManager.applyChanges();
        } catch (final BackingStoreException e) {
            // JavaPlugin.log(e);
            return false;
        }
        if (doBuild) {
            // CoreUtility.getBuildJob(fProject).schedule();
        }

    }
    return true;
}

From source file:com.aptana.radrails.rcp.IDEWorkbenchAdvisor.java

License:Open Source License

/**
 * Initialize the listener for settings changes.
 *//*from w w w.j  ava 2  s .  c om*/
private void initializeSettingsChangeListener() {
    settingsChangeListener = new Listener() {

        boolean currentHighContrast = Display.getCurrent().getHighContrast();

        public void handleEvent(org.eclipse.swt.widgets.Event event) {
            if (Display.getCurrent().getHighContrast() == currentHighContrast)
                return;

            currentHighContrast = !currentHighContrast;

            // make sure they really want to do this
            if (new MessageDialog(null, IDEWorkbenchMessages.SystemSettingsChange_title, null,
                    IDEWorkbenchMessages.SystemSettingsChange_message, MessageDialog.QUESTION,
                    new String[] { IDEWorkbenchMessages.SystemSettingsChange_yes,
                            IDEWorkbenchMessages.SystemSettingsChange_no },
                    1).open() == Window.OK) {
                PlatformUI.getWorkbench().restart();
            }
        }
    };

}

From source file:com.aptana.rcp.IDEWorkbenchAdvisor.java

License:Open Source License

/**
 * Initialize the listener for settings changes.
 *//*w  ww  . ja  v  a 2 s  .c om*/
private void initializeSettingsChangeListener() {
    settingsChangeListener = new Listener() {

        boolean currentHighContrast = Display.getCurrent().getHighContrast();

        public void handleEvent(org.eclipse.swt.widgets.Event event) {
            if (Display.getCurrent().getHighContrast() == currentHighContrast) {
                return;
            }

            currentHighContrast = !currentHighContrast;

            // make sure they really want to do this
            if (new MessageDialog(null, IDEWorkbenchMessages.SystemSettingsChange_title, null,
                    IDEWorkbenchMessages.SystemSettingsChange_message, MessageDialog.QUESTION,
                    new String[] { IDEWorkbenchMessages.SystemSettingsChange_yes,
                            IDEWorkbenchMessages.SystemSettingsChange_no },
                    1).open() == Window.OK) {
                PlatformUI.getWorkbench().restart();
            }
        }
    };
}

From source file:com.aptana.terminal.internal.TerminalCloseHelper.java

License:Open Source License

public static boolean canCloseTerminal(IShellProvider shellProvider, LocalTerminalConnector terminalConnector) {
    List<String> processes = terminalConnector.getRunningProcesses();
    if (processes.size() < 2) {
        return true;
    }//  ww w .  j a va2s.  c  o  m

    int closeId = 1;
    MessageDialog dialog = new MessageDialog(shellProvider.getShell(), Messages.TerminalCloseHelper_DialogTitle,
            null, Messages.TerminalCloseHelper_DialogMessage + processes.toString(), MessageDialog.QUESTION,
            new String[] { IDialogConstants.CANCEL_LABEL, IDialogConstants.CLOSE_LABEL }, closeId);
    return dialog.open() == closeId;
}

From source file:com.aptana.ui.ftp.internal.FTPConnectionPropertyComposite.java

License:Open Source License

public boolean completeConnection() {
    if (DEFAULT_NAME.equals(nameText.getText())) {
        nameText.setText(hostText.getText());
    }/*from  w ww  .j av  a 2  s . c  o m*/
    if (!connectionTested) {
        if (!testConnection()) {
            MessageDialog dlg = new MessageDialog(getShell(),
                    Messages.FTPConnectionPointPropertyDialog_ConfirmTitle, null,
                    Messages.FTPConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            Messages.FTPConnectionPointPropertyDialog_LBL_Edit },
                    2);
            int code = dlg.open();
            switch (code) {
            case 1:
                return true;
            case 2:
                return false;
            default:
            }
        }
    }
    CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(ftpConnectionPoint),
            passwordText.getText().toCharArray(), savePasswordButton.getSelection());

    boolean changed = savePropertiesTo(ftpConnectionPoint);
    if (isNew) {
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint);
    } else if (ftpConnectionPoint != originalFtpConnectionPoint) // $codepro.audit.disable useEquals
    {
        ftpConnectionPoint.setId(originalFtpConnectionPoint.getId());
        CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalFtpConnectionPoint);
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(ftpConnectionPoint);
    } else if (changed) {
        CoreIOPlugin.getConnectionPointManager().connectionPointChanged(ftpConnectionPoint);
    }
    return true;
}

From source file:com.aptana.ui.s3.internal.S3ConnectionPropertyComposite.java

License:Open Source License

public boolean completeConnection() {
    if (DEFAULT_NAME.equals(nameText.getText())) {
        nameText.setText(hostText.getText());
    }//w  w  w  . j a  v  a  2  s .  c o  m
    if (!connectionTested) {
        if (!testConnection()) {
            MessageDialog dlg = new MessageDialog(getShell(),
                    Messages.S3ConnectionPointPropertyDialog_ConfirmTitle, null,
                    Messages.S3ConnectionPointPropertyDialog_ConfirmMessage, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            Messages.S3ConnectionPointPropertyDialog_LBL_Edit },
                    2);
            int code = dlg.open();
            switch (code) {
            case 1:
                return true;
            case 2:
                return false;
            default:
            }
        }
    }
    CoreIOPlugin.getAuthenticationManager().setPassword(getAuthId(s3ConnectionPoint),
            passwordText.getText().toCharArray(), savePasswordButton.getSelection());

    boolean changed = savePropertiesTo(s3ConnectionPoint);
    if (isNew) {
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(s3ConnectionPoint);
    } else if (s3ConnectionPoint != originalS3ConnectionPoint) {
        s3ConnectionPoint.setId(originalS3ConnectionPoint.getId());
        CoreIOPlugin.getConnectionPointManager().removeConnectionPoint(originalS3ConnectionPoint);
        CoreIOPlugin.getConnectionPointManager().addConnectionPoint(s3ConnectionPoint);
    } else if (changed) {
        CoreIOPlugin.getConnectionPointManager().connectionPointChanged(s3ConnectionPoint);
    }
    return true;
}

From source file:com.archimatetool.editor.model.impl.EditorModelManager.java

License:Open Source License

/**
 * Show dialog to save modified model/*w w w  .  ja  v  a 2  s  .c  o  m*/
 * @param model
 * @return true if the user chose to save the model or chose not to save the model, false if cancelled
 * @throws IOException 
 */
private boolean askSaveModel(IArchimateModel model) throws IOException {
    MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(),
            Messages.EditorModelManager_6, null, NLS.bind(Messages.EditorModelManager_7, model.getName()),
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);

    int result = dialog.open();

    // Yes
    if (result == 0) {
        return saveModel(model);
    }
    // No
    if (result == 1) {
        return true;
    }
    // Cancel
    return false;
}

From source file:com.arm.cmsis.pack.installer.jobs.CpPackUnpackJob.java

License:Open Source License

private boolean myRun(IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, 100);

    File sourceFile = new File(fSourceFilePath);
    monitor.setTaskName(Messages.CpPackUnpackJob_Unpacking + sourceFile.toString());

    if (fDestPath.toFile().exists()) {
        final String messageString = NLS.bind(Messages.CpPackUnpackJob_PathAlreadyExists,
                fDestPath.toOSString());
        Display.getDefault().syncExec(new Runnable() {
            @Override//from   www .ja  va 2  s  .com
            public void run() {
                final MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(),
                        Messages.CpPackUnpackJob_OverwriteQuery, null, messageString, MessageDialog.QUESTION,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                IDialogConstants.CANCEL_LABEL },
                        0);
                returnCode = dialog.open();
            }
        });

        if (returnCode == IDialogConstants.OK_ID) {
            Utils.deleteFolderRecursive(fDestPath.toFile());
        } else {
            fResult.setSuccess(false);
            fResult.setErrorString(Messages.CpPackJob_CancelledByUser);
            return false;
        }
    }

    if (!sourceFile.exists()) {
        fResult.setSuccess(false);
        fResult.setErrorString(sourceFile.toString() + Messages.CpPackUnpackJob_SourceFileCannotBeFound);
        return true;
    }

    try {
        if (!fPackInstaller.unzip(sourceFile, fDestPath, progress.newChild(95))) {
            fResult.setSuccess(false);
            fResult.setErrorString(Messages.CpPackJob_CancelledByUser);
            Utils.deleteFolderRecursive(fDestPath.toFile());
            return false;
        }
        if (fPack != null) { // unpack job
            fPack.setPackState(PackState.INSTALLED);
            fPack.setFileName(fDestPath.append(fPack.getPackFamilyId() + CmsisConstants.EXT_PDSC).toString());
            fResult.setPack(fPack);
            fResult.setSuccess(true);
            return true;
        }
        Collection<String> files = new LinkedList<>();
        Utils.findPdscFiles(fDestPath.toFile(), files, 1);
        if (files.isEmpty()) {
            Utils.deleteFolderRecursive(fDestPath.toFile());
            fResult.setSuccess(false);
            fResult.setErrorString(Messages.CpPackUnpackJob_PdscFileNotFoundInFolder + fDestPath.toOSString());
            return true;
        }

        String file = files.iterator().next();
        ICpXmlParser parser = CpPlugIn.getPackManager().getParser();
        fPack = (ICpPack) parser.parseFile(file);
        if (fPack != null) {
            ICpItem urlItem = fPack.getFirstChild(CmsisConstants.URL);
            if (urlItem == null || !Utils.isValidURL(urlItem.getText())) {
                fPack.setPackState(PackState.GENERATED);
            } else {
                fPack.setPackState(PackState.INSTALLED);
            }
            fResult.setPack(fPack);
            fResult.setSuccess(true);
            return true;
        }
        Utils.deleteFolderRecursive(fDestPath.toFile());
        StringBuilder sb = new StringBuilder(Messages.CpPackUnpackJob_FailToParsePdscFile + file);
        for (String es : parser.getErrorStrings()) {
            sb.append(System.lineSeparator());
            sb.append(es);
        }
        fResult.setErrorString(sb.toString());
        fResult.setSuccess(false);
        return true;
    } catch (IOException e) {
        fResult.setSuccess(false);
        fResult.setErrorString(Messages.CpPackUnpackJob_FailedToUnzipFile + sourceFile.toString());
        Utils.deleteFolderRecursive(fDestPath.toFile());
        return true;
    }
}

From source file:com.arm.cmsis.pack.installer.OverwriteQuery.java

License:Open Source License

@Override
public String queryOverwrite(String pathString) {
    Path path = new Path(pathString);

    String messageString;//from   w  ww .  ja v a 2  s. com
    //Break the message up if there is a file name and a directory
    //and there are at least 2 segments.
    if (path.getFileExtension() == null || path.segmentCount() < 2) {
        messageString = NLS.bind(Messages.OverwriteQuery_ExistsQuestion, pathString);
    } else {
        messageString = NLS.bind(Messages.OverwriteQuery_OverwriteNameAndPathQuestion, path.lastSegment(),
                path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(shell, Messages.OverwriteQuery_Question, null, messageString,
            MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0) {
        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
    //run in syncExec because callback is from an operation,
    //which is probably not running in the UI thread.
    shell.getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}