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

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

Introduction

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

Prototype

public static boolean openQuestion(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:com.minres.scviewer.e4.application.parts.WaveformViewer.java

License:Open Source License

/**
 * Ask if to load./*w w  w.j  a v  a 2 s .  c  om*/
 *
 * @param txFile the tx file
 * @return true, if successful
 */
protected boolean askIfToLoad(File txFile) {
    if (txFile.exists() && MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open",
            "Would you like to open the adjacent database " + txFile.getName() + " as well?")) {
        return true;
    }
    return false;
}

From source file:com.minres.scviewer.ui.TxEditorPart.java

License:Open Source License

protected boolean askIfToLoad(File txFile) {
    if (txFile.exists() && MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open",
            "Would you like to open the adjacent database " + txFile.getName() + " as well?")) {
        return true;
    }/*from   w  ww. java2s  . co m*/
    return false;
}

From source file:com.mobilesorcery.sdk.ui.internal.handlers.FilterProfilesHandler.java

License:Open Source License

private boolean askForConversion(Shell shell, MoSyncProject project) {
    return MessageDialog.openQuestion(shell, "Upgrade profile handling",
            "This project uses device-based profiles. Would you like to convert to platform-based profiles instead?");
}

From source file:com.mobilesorcery.sdk.ui.MosyncUIPlugin.java

License:Open Source License

private void askForUsageStatistics(final IWorkbench wb) {
    final Stats stats = Stats.getStats();
    if (stats.getSendInterval() == Stats.UNASSIGNED_SEND_INTERVAL) {
        Display display = wb.getDisplay();
        display.asyncExec(new Runnable() {
            @Override//from ww w .  j a  v a  2 s.  co m
            public void run() {
                Shell shell = wb.getActiveWorkbenchWindow().getShell();
                boolean ok = MessageDialog.openQuestion(shell, Messages.MosyncUIPlugin_12,
                        Messages.MosyncUIPlugin_13);
                stats.setSendInterval(ok ? Stats.DEFAULT_SEND_INTERVAL : Stats.DISABLE_SEND);
            }
        });
    }
}

From source file:com.mobilesorcery.sdk.update.internal.preferences.ProfileUpdatesPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    BooleanFieldEditor autoUpdate = new BooleanFieldEditor(MoSyncTool.AUTO_UPDATE_PREF,
            Messages.ProfileUpdatesPreferencePage_AutoUpdate, getFieldEditorParent());
    addField(autoUpdate);/*w  w  w.j a  v  a2s.c  o  m*/

    Composite registration = new Composite(getFieldEditorParent(), SWT.NONE);
    registration.setLayout(new GridLayout(2, false));
    registration.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label reg = new Label(registration, SWT.NONE);
    reg.setText(Messages.ProfileUpdatesPreferencePage_RegistrationDescription);
    reg.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    clearSettings = new Button(registration, SWT.PUSH);
    clearSettings.setText(Messages.ProfileUpdatesPreferencePage_ClearRegistrationInfo);
    clearSettings.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));

    hhashText = new Text(registration, SWT.READ_ONLY | SWT.SINGLE);
    GridData emailData = new GridData(GridData.FILL_HORIZONTAL);
    emailData.horizontalSpan = 2;
    hhashText.setLayoutData(emailData);

    updateUI();

    clearSettings.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event event) {
            boolean result = MessageDialog.openQuestion(getShell(),
                    Messages.ProfileUpdatesPreferencePage_AreYouSureTitle,
                    Messages.ProfileUpdatesPreferencePage_AreYouSureMessage);

            if (result) {
                UpdateManager.getDefault().clearRegistrationInfo();
                updateUI();
            }
        }
    });
}

From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Display a yes/no question dialog box/*from  w  w  w  . j av a2s.co m*/
 * 
 * @param title
 *            The title of the dialog box
 * @param message
 *            The error message
 * @param display
 *            the parent display
 * @return true if OK was clicked.
 */
public final static boolean displayPrompt(final Display display, final String title, final String message) {
    /*
     * Sometimes we need to ask the user what he wants to do.
     */
    final boolean[] result = new boolean[1];
    display.syncExec(new Runnable() {

        public void run() {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            result[0] = MessageDialog.openQuestion(shell, title, message);
        }
    });
    return result[0];
}

From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Show a question message using the given title and message
 * /*from w  w  w.  j  ava  2  s.co  m*/
 * @param title
 *            of the dialog
 * @param message
 *            to be displayed in the dialog.
 */
public static boolean showQuestionDialog(final String title, final String message) {
    class BooleanWrapper {
        public boolean bool = false;
    }

    final BooleanWrapper boolWrapper = new BooleanWrapper();
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
            Shell shell = ww.getShell();
            boolWrapper.bool = MessageDialog.openQuestion(shell, title, message);
        }
    });

    return boolWrapper.bool;
}

From source file:com.motorolamobility.studio.android.certmanager.command.DeleteKeyHandler.java

License:Apache License

private boolean showQuestion(List<ITreeNode> nodesToDelete) {

    final Boolean[] reply = new Boolean[1];

    final String entryName = nodesToDelete.size() == 1 ? nodesToDelete.get(0).getName() : null;

    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        @Override/*from   w  ww .ja  v  a2  s.  c  om*/
        public void run() {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow ww = workbench.getActiveWorkbenchWindow();
            Shell shell = ww.getShell();

            reply[0] = MessageDialog.openQuestion(shell,
                    CertificateManagerNLS.DeleteKeyHandler_ConfirmationQuestionDialog_Title,
                    entryName != null ? CertificateManagerNLS.bind(
                            CertificateManagerNLS.DeleteKeyHandler_ConfirmationQuestionDialog_Description,
                            entryName) : CertificateManagerNLS.DeleteKeyHandler_Delete_Selected_Keys);
        }
    });

    return reply[0];
}

From source file:com.motorolamobility.studio.android.certmanager.ui.wizards.CreateKeystorePage.java

License:Apache License

private boolean validateKeyStoreFile(File keystoreFile) {
    boolean result = true;

    if (keystoreFile.exists()) {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

        result = MessageDialog.openQuestion(shell,
                CertificateManagerNLS.CreateKeystorePage_ConfirmFileOverwrite,
                NLS.bind(CertificateManagerNLS.CreateKeystorePage_ConfirmReplaceFile,
                        keystoreFile.getAbsolutePath()));
        if (result) {
            //file will be recreated
            keystoreFile.delete();//from   w ww  .  ja va 2  s  .  com
        }
    }
    return result;
}

From source file:com.netxforge.editing.base.impl.ScreenFormService.java

License:Open Source License

/**
 * Warns if the current screen is dirty, if not saving, flush the command
 * stack. If saving, save depending on the screen type.
 * /*from  www .j a v  a  2 s .  c  om*/
 * @return false if cancelled
 */
public boolean dirtyWarning() {
    // Warn for unsaved changes.
    if (editingService.isDirty()) {
        // For an EMF Editing service, we don't know the exact dirtyness, so
        // we show a regular dialog.

        boolean ok = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Save needed",
                "You have unsaved changes, which will be discarded when not saved, save?");
        if (ok) {
            if (getActiveScreen() instanceof IDataScreenInjection) {
                ((IDataScreenInjection) getActiveScreen()).addData();
            } else {
                editingService.doSave(new NullProgressMonitor());
            }

        } else {
            undoAndFlush();

        }

    } else {
        // Flush the stack anyway.
        editingService.getEditingDomain().getCommandStack().flush();
    }
    return false;
}