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

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

Introduction

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

Prototype

public void setBlockOnOpen(boolean shouldBlock) 

Source Link

Document

Sets whether the open method should block until the window closes.

Usage

From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java

License:Open Source License

/**
 * @param errorMessage/*  ww w.  j  av a2s .  c o  m*/
 * @param shell
 */
private static void error(final String errorMessage, Shell shell) {
    Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell();
    MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.error"), null, errorMessage, //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$
    dialog.setBlockOnOpen(true);
    dialog.open();
}

From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java

License:Open Source License

/**
 * @param warningMessage// ww w  .  j a va  2s. c o  m
 * @param shell
 */
private static void warning(final String warningMessage, Shell shell) {
    Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell();
    MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.warning"), null, //$NON-NLS-1$
            warningMessage, MessageDialog.WARNING, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$
    dialog.setBlockOnOpen(true);
    dialog.open();
}

From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java

License:Open Source License

/**
 * @param infoMessage//from  w  w w .j a va  2  s  .  c om
 * @param shell
 */
private static void info(final String infoMessage, final Shell shell) {
    Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell();
    MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.Info"), null, infoMessage, //$NON-NLS-1$
            MessageDialog.INFORMATION, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$
    dialog.setBlockOnOpen(true);
    dialog.open();
}

From source file:net.sf.eclipsensis.dialogs.NSISTaskTagsPreferencePage.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   w w  w  .j  a  va  2 s . c  o  m*/
public boolean performOk() {
    if (super.performOk()) {
        Collection<NSISTaskTag> taskTags = (Collection<NSISTaskTag>) mTableViewer.getInput();
        boolean caseSensitive = mCaseSensitiveButton.getSelection();
        boolean different = (caseSensitive != NSISPreferences.getInstance().isCaseSensitiveTaskTags());
        if (!different) {
            if (taskTags.size() == mOriginalTags.size()) {
                for (Iterator<NSISTaskTag> iter = taskTags.iterator(); iter.hasNext();) {
                    if (!mOriginalTags.contains(iter.next())) {
                        different = true;
                        break;
                    }
                }
            } else {
                different = true;
            }
        }
        if (different) {
            if (taskTags.size() > 0) {
                boolean defaultFound = false;
                for (Iterator<NSISTaskTag> iter = taskTags.iterator(); iter.hasNext();) {
                    NSISTaskTag element = iter.next();
                    if (element.isDefault()) {
                        defaultFound = true;
                        break;
                    }
                }
                if (!defaultFound) {
                    if (taskTags.size() == 1) {
                        NSISTaskTag taskTag = (NSISTaskTag) taskTags.toArray()[0];
                        taskTag.setDefault(true);
                        mTableViewer.setChecked(taskTag, true);
                    } else {
                        Common.openError(getShell(),
                                EclipseNSISPlugin.getResourceString("task.tag.dialog.missing.default"), //$NON-NLS-1$
                                EclipseNSISPlugin.getShellImage());
                        return false;
                    }
                }
            }
        }
        boolean updateTaskTags = false;
        if (different) {
            NSISPreferences.getInstance().setTaskTags(taskTags);
            NSISPreferences.getInstance().setCaseSensitiveTaskTags(caseSensitive);
            MessageDialog dialog = new MessageDialog(getShell(),
                    EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$
                    EclipseNSISPlugin.getShellImage(),
                    EclipseNSISPlugin.getResourceString("task.tags.settings.changed"), MessageDialog.QUESTION, //$NON-NLS-1$
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL },
                    0);
            dialog.setBlockOnOpen(true);
            int rv = dialog.open();
            if (rv == 2) {
                //Cancel
                return false;
            } else {
                updateTaskTags = (rv == 0);
            }
            NSISPreferences.getInstance().store();
        }
        if (updateTaskTags) {
            new NSISTaskTagUpdater().updateTaskTags();
            NSISEditorUtilities.updatePresentations();
            mOriginalTags.clear();
            mOriginalTags.addAll(taskTags);
        }
        return true;
    }
    return false;
}

From source file:org.ebayopensource.turmeric.eclipse.utils.ui.UIUtil.java

License:Open Source License

/**
 * Open choice dialog.//from w w w. java2  s  . c  o m
 *
 * @param title the title
 * @param message the message
 * @param type the type
 * @param yesLabel the yes label
 * @param noLabel the no label
 * @return true, if successful
 */
public static boolean openChoiceDialog(final String title, final String message, final int type,
        final String yesLabel, final String noLabel) {
    final boolean[] returnValue = new boolean[1];
    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            MessageDialog dialog = new MessageDialog(getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "eBay SOA Plugin: " + title, null, message, type, new String[] { yesLabel, noLabel }, 0);
            dialog.setBlockOnOpen(true);
            returnValue[0] = dialog.open() == Window.OK;
        }
    };
    Display.getCurrent().syncExec(runnable);
    return returnValue[0];
}

From source file:org.ebayopensource.turmeric.eclipse.utils.ui.UIUtil.java

License:Open Source License

/**
 * Open choice dialog.//from   ww  w.  ja  va  2s  .c  o  m
 *
 * @param title the title
 * @param message the message
 * @param type the type
 * @return true, if successful
 */
public static boolean openChoiceDialog(final String title, final String message, final int type) {
    final boolean[] returnValue = new boolean[1];
    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            MessageDialog dialog = new MessageDialog(getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "eBay SOA Plugin: " + title, null, message, type,
                    new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
            dialog.setBlockOnOpen(true);
            returnValue[0] = dialog.open() == Window.OK;
        }
    };
    Display.getCurrent().syncExec(runnable);
    return returnValue[0];
}

From source file:org.eclipse.acute.AcutePlugin.java

License:Open Source License

public static void showError(String title, String message) {
    Display.getDefault().asyncExec(() -> {
        MessageDialog dialog = new MessageDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, message,
                MessageDialog.ERROR, 0, IDialogConstants.OK_LABEL);
        dialog.setBlockOnOpen(false);
        dialog.open();//from   w ww  .  j  ava2  s.  c  o  m
    });
}

From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java

License:Open Source License

@SuppressWarnings("deprecation")
public boolean performOk() {
    if (isProjectPreferencePage()) {
        return projectPerformOK();
    } else {//from   w w  w. j  a  va 2s . c om
        IPreferenceStore store = getPreferenceStore();
        Preferences ajCorePreferences = getAspectJCorePLuginPreferences();

        boolean lintChanges = false;
        for (int i = fComboBoxes.size() - 1; i >= 0; i--) {
            Combo curr = (Combo) fComboBoxes.get(i);
            ControlData data = (ControlData) curr.getData();
            String currValue = data.getValue(curr.getSelectionIndex());
            String storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getString(data.getKey())
                    : store.getString(data.getKey());
            if (!currValue.equals(storedValue)) {
                lintChanges = true;

                if (usesAspectJCorePreferences(curr)) {
                    ajCorePreferences.setValue(data.getKey(), currValue);
                } else {
                    store.setValue(data.getKey(), currValue);
                }
            }
        }

        boolean advancedOrOtherChanges = false;
        for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {
            Button curr = (Button) fCheckBoxes.get(i);

            // has the data changed?
            ControlData data = (ControlData) curr.getData();
            boolean currValue = curr.getSelection();
            boolean storedValue = usesAspectJCorePreferences(curr) ? ajCorePreferences.getBoolean(data.getKey())
                    : store.getBoolean(data.getKey());
            if (currValue != storedValue) {
                // check to see if we should ignore the change in the checkbox
                // change should be ignored if the NO_BUILD_ON_CHANGE flag exists
                if (curr.getData(NO_BUILD_ON_CHANGE) == null) {
                    advancedOrOtherChanges = true;
                }

                // determine where this preference is stored
                if (usesAspectJCorePreferences(curr)) {
                    ajCorePreferences.setValue(data.getKey(), currValue);
                } else {
                    store.setValue(data.getKey(), currValue);
                }
            }
        }

        boolean compilerChanges = false;
        String value = nonStandardOptionsEditor.getStringValue();
        if (!value.equals(store.getString(AspectJPreferences.COMPILER_OPTIONS))) {
            store.setValue(AspectJPreferences.COMPILER_OPTIONS, nonStandardOptionsEditor.getStringValue());
            AJLog.log("Non Standard Compiler properties changed: " //$NON-NLS-1$
                    + store.getString(AspectJPreferences.COMPILER_OPTIONS));
            compilerChanges = true;
        }

        AspectJUIPlugin.getDefault().savePluginPreferences();
        AspectJPlugin.getDefault().savePluginPreferences();

        if (lintChanges || advancedOrOtherChanges || compilerChanges) {
            String[] strings = getFullBuildDialogStrings();
            if (strings != null) {
                MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1],
                        MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                                IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                        2);
                if (isTesting) {
                    dialog.setBlockOnOpen(false);
                }
                int res = dialog.open();
                // simulate user input if we're testing
                if (isTesting) {
                    // choices are "Yes", "No" or "Cancel"
                    dialog.close();
                    if (buildNow) {
                        res = Window.OK;
                    } else {
                        res = Window.CANCEL; // simulating cancel or no being pressed.
                    }
                }
                if (res == 0) {
                    projects = (ResourcesPlugin.getWorkspace().getRoot().getProjects());
                } else if (res != 1) {
                    return false; // cancel pressed
                }
            }
            // PreferencePageBuilder handles building so
            // don't need to do it here
            //            if (doBuild) {
            //               doFullBuild();
            //            }
        }

        return true;
    }
}

From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java

License:Open Source License

private boolean projectPerformOK() {
    boolean projectSettingsChanged = updateProjectSettings();

    boolean projectWorkspaceChanges = false;
    if (AspectJPreferences.isUsingProjectSettings(getProject()) != useProjectSettings()) {
        projectWorkspaceChanges = true;/*w  ww  .j a va2 s .c  o m*/
        // don't want to overwrite existing project settings
        // because have just set them in the above call to
        // updateProjectSettings();
        AspectJPreferences.setUsingProjectSettings(getProject(), useProjectSettings(), false);
    }

    AspectJUIPlugin.getDefault().savePluginPreferences();

    if (projectWorkspaceChanges || (projectSettingsChanged && useProjectSettings())) {
        String[] strings = getProjectBuildDialogStrings();
        if (strings != null) {
            MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1],
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    2);
            // if we're testing then we don't want to block
            // the dialog on open otherwise we require real user input
            // rather than being able to simulate it
            if (isTesting) {
                dialog.setBlockOnOpen(false);
            }
            int res = dialog.open();
            // simulate user input if we're testing
            if (isTesting) {
                // choices are "Yes", "No" or "Cancel"
                dialog.close();
                if (buildNow) {
                    res = Window.OK;
                } else {
                    res = Window.CANCEL; // simulating cancel or no being pressed.
                }
            }
            if ((res == 0)) {
                // by only setting compilerSettingsUpdated to be true here,
                // means that
                // the user wont select "don't want to build" here and then
                // get a build
                // from other pages.
            } else if (res != 1) {
                return false; // cancel pressed
            }
        }
    }
    return true;
}

From source file:org.eclipse.ecf.internal.provider.skype.ui.hyperlink.SkypeHyperlink.java

License:Open Source License

/**
 * @param adapters//ww  w .j ava 2 s  .  c om
 */
private void chooseAccountAndOpen(final IContainer[] containers) {
    // If there's only one choice then use it
    if (containers.length == 1) {
        // ask to the user if the talk is by IM or Call
        final MessageDialog dialog = new MessageDialog(null, Messages.SkypeHyperlink_DIALOG_CALLIM_TITLE, null,
                NLS.bind(Messages.SkypeHyperlink_DIALOG_CALLIM_MESSAGE, getURI().getAuthority()),
                MessageDialog.QUESTION, new String[] { Messages.SkypeHyperlink_BUTTON_CALL,
                        Messages.SkypeHyperlink_BUTTON_IM, Messages.SkypeHyperlink_BUTTON_CANCEL },
                2);
        final int answer = dialog.open();
        switch (answer) {
        case 0:
            final IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) containers[0]
                    .getAdapter(IPresenceContainerAdapter.class);
            final ID localID = presenceContainerAdapter.getRosterManager().getRoster().getUser().getID();
            final ID targetUser = new SkypeUserID(localID.getNamespace(), getURI().getAuthority());
            call(containers[0], targetUser);
            break;
        case 1:
            openMessagesView(
                    (IPresenceContainerAdapter) containers[0].getAdapter(IPresenceContainerAdapter.class));
            break;
        }

        return;
    } else {
        final IPresenceContainerAdapter[] adapters = new IPresenceContainerAdapter[containers.length];
        for (int i = 0; i < containers.length; i++)
            adapters[i] = (IPresenceContainerAdapter) containers[i].getAdapter(IPresenceContainerAdapter.class);
        final ListDialog dialog = new ListDialog(null);
        dialog.setContentProvider(new IStructuredContentProvider() {

            public Object[] getElements(Object inputElement) {
                return adapters;
            }

            public void dispose() {
            }

            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            }
        });
        dialog.setInput(adapters);
        dialog.setAddCancelButton(true);
        dialog.setBlockOnOpen(true);
        dialog.setTitle(Messages.SkypeHyperlink_DIALOG_SELECT_ACCOUNT_TITLE);
        dialog.setMessage(Messages.SkypeHyperlink_DIALOG_SELECT_ACCOUNT_MESSAGE);
        dialog.setHeightInChars(adapters.length > 4 ? adapters.length : 4);
        dialog.setInitialSelections(new IPresenceContainerAdapter[] { adapters[0] });
        dialog.setLabelProvider(new ILabelProvider() {
            public Image getImage(Object element) {
                return null;
            }

            public String getText(Object element) {
                final IRosterManager manager = ((IPresenceContainerAdapter) element).getRosterManager();
                if (manager == null)
                    return null;
                return manager.getRoster().getUser().getID().getName();
            }

            public void addListener(ILabelProviderListener listener) {
            }

            public void dispose() {
            }

            public boolean isLabelProperty(Object element, String property) {
                return false;
            }

            public void removeListener(ILabelProviderListener listener) {
            }
        });
        final int result = dialog.open();
        if (result == ListDialog.OK) {
            final Object[] res = dialog.getResult();
            if (res.length > 0)
                openMessagesView((IPresenceContainerAdapter) res[0]);
        }
    }
}