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:org.eclipse.debug.internal.ui.actions.breakpoints.RemoveBreakpointAction.java

License:Open Source License

public void run(IAction action) {
    IStructuredSelection selection = getSelection();
    if (selection.isEmpty()) {
        return;/* w w  w.  j a  v a 2s .co  m*/
    }
    final Iterator itr = selection.iterator();
    final CoreException[] exception = new CoreException[1];
    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) {
            ArrayList breakpointsToDelete = new ArrayList();
            ArrayList groupsToDelete = new ArrayList();
            boolean deleteAll = false;
            boolean deleteContainer = false;
            boolean prompted = false;
            while (itr.hasNext()) {
                Object next = itr.next();
                IBreakpoint breakpoint = (IBreakpoint) DebugPlugin.getAdapter(next, IBreakpoint.class);
                if (breakpoint != null) {
                    breakpointsToDelete.add(breakpoint);
                } else if (next instanceof IBreakpointContainer) {
                    //the the container is a workingset, ask if they want to delete it as well
                    IBreakpointContainer bpc = (IBreakpointContainer) next;
                    if (bpc.getCategory() instanceof WorkingSetCategory) {
                        IWorkingSet set = ((WorkingSetCategory) bpc.getCategory()).getWorkingSet();
                        if (!prompted) {
                            prompted = true;
                            DeleteWorkingsetsMessageDialog dialog = new DeleteWorkingsetsMessageDialog(
                                    getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_3,
                                    null, ActionMessages.RemoveBreakpointAction_4, MessageDialog.QUESTION,
                                    new String[] { ActionMessages.RemoveBreakpointAction_5,
                                            ActionMessages.RemoveBreakpointAction_6 },
                                    0);
                            if (dialog.open() == Window.CANCEL) {
                                return;
                            }
                            deleteAll = dialog.deleteAllBreakpoints();
                            deleteContainer = dialog.deleteWorkingset();
                        }
                        if (deleteContainer) {
                            groupsToDelete.add(set);
                        }
                    } else {
                        if (!prompted) {
                            IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
                            prompted = store.getBoolean(
                                    IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER);
                            if (prompted) {
                                MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(
                                        getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_0,
                                        ActionMessages.RemoveBreakpointAction_1,
                                        ActionMessages.RemoveAllBreakpointsAction_3, !prompted, null, null);
                                if (mdwt.getReturnCode() == IDialogConstants.NO_ID) {
                                    deleteAll = false;
                                } else {
                                    store.setValue(
                                            IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER,
                                            !mdwt.getToggleState());
                                    deleteAll = true;
                                }
                            } else {
                                deleteAll = !prompted;
                            }
                        }
                    }
                    if (deleteAll) {
                        IBreakpoint[] breakpoints = bpc.getBreakpoints();
                        for (int i = 0; i < breakpoints.length; i++) {
                            breakpointsToDelete.add(breakpoints[i]);
                        }
                    }
                }
            }
            final IBreakpoint[] breakpoints = (IBreakpoint[]) breakpointsToDelete.toArray(new IBreakpoint[0]);
            final IWorkingSet[] sets = (IWorkingSet[]) groupsToDelete
                    .toArray(new IWorkingSet[groupsToDelete.size()]);
            if (breakpoints.length > 0) {
                ((BreakpointsView) getView()).preserveSelection(getSelection());
            }
            new Job(ActionMessages.RemoveBreakpointAction_2) {
                protected IStatus run(IProgressMonitor pmonitor) {
                    try {
                        Shell shell = getView() != null ? getView().getSite().getShell() : null;
                        DebugUITools.deleteBreakpoints(breakpoints, shell, pmonitor);

                        for (int i = 0; i < sets.length; i++) {
                            PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(sets[i]);
                        }
                        return Status.OK_STATUS;
                    } catch (CoreException e) {
                        DebugUIPlugin.log(e);
                    }
                    return Status.CANCEL_STATUS;
                }
            }.schedule();
        }
    };
    try {
        ResourcesPlugin.getWorkspace().run(runnable, null, 0, null);
    } catch (CoreException ce) {
        exception[0] = ce;
    }
    if (exception[0] != null) {
        IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
        if (window != null) {
            DebugUIPlugin.errorDialog(window.getShell(),
                    ActionMessages.RemoveBreakpointAction_Removing_a_breakpoint_4,
                    ActionMessages.RemoveBreakpointAction_Exceptions_occurred_attempting_to_remove_a_breakpoint__5,
                    exception[0]);
        } else {
            DebugUIPlugin.log(exception[0]);
        }
    }
}

From source file:org.eclipse.debug.internal.ui.importexport.launchconfigurations.ExportLaunchConfigurationsWizardPage.java

License:Open Source License

/**
 * This method performs the work of the page
 * @return if the export job was successful or not
 *///from  w  w w .  j  a  v a 2 s .  c o  m
public boolean finish() {
    final String dpath = fFilePath.getText().trim();
    IDialogSettings settings = getDialogSettings();
    settings.put(OVERWRITE, fOverwrite.getSelection());
    settings.put(OLD_PATH, dpath);
    final Object[] configs = fViewer.getCheckedElements();
    final boolean overwrite = fOverwrite.getSelection();
    UIJob exportjob = new UIJob(getContainer().getShell().getDisplay(),
            WizardMessages.ExportLaunchConfigurationsWizard_0) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
            if (monitor == null) {
                monitor = new NullProgressMonitor();
            }
            IPath destpath = new Path(dpath);
            File destfolder = destpath.toFile();
            if (!destfolder.exists()) {
                destfolder.mkdirs();
            }
            monitor.beginTask(WizardMessages.ExportLaunchConfigurationsWizardPage_10, configs.length);
            try {
                List errors = null;
                IFileStore file = null;
                File newfile = null;
                boolean owall = false, nowall = false;
                MessageDialog dialog = null;
                for (int i = 0; i < configs.length; i++) {
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }
                    if (configs[i] instanceof ILaunchConfiguration) {
                        try {
                            LaunchConfiguration launchConfig = (LaunchConfiguration) configs[i];
                            file = launchConfig.getFileStore();
                            if (file == null) {
                                if (errors == null) {
                                    errors = new ArrayList(configs.length);
                                }
                                errors.add(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(),
                                        MessageFormat.format(
                                                WizardMessages.ExportLaunchConfigurationsWizardPage_19,
                                                new String[] { launchConfig.getName() }),
                                        null));
                            } else {
                                newfile = new File(destpath.append(file.getName()).toOSString());
                                if (newfile.exists() & !overwrite) {
                                    if (nowall) {
                                        continue;
                                    }
                                    dialog = new MessageDialog(DebugUIPlugin.getShell(),
                                            WizardMessages.ExportLaunchConfigurationsWizardPage_11, null,
                                            MessageFormat.format(
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_12,
                                                    new String[] { file.getName() }),
                                            MessageDialog.QUESTION,
                                            new String[] {
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_13,
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_14,
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_15,
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_16,
                                                    WizardMessages.ExportLaunchConfigurationsWizardPage_17 },
                                            0);
                                    if (!owall) {
                                        int ret = dialog.open();
                                        switch (ret) {
                                        case 0: {
                                            copyFile(file, newfile);
                                            break;
                                        }
                                        case 1: {
                                            owall = true;
                                            copyFile(file, newfile);
                                            break;
                                        }
                                        case 3: {
                                            nowall = true;
                                            break;
                                        }
                                        case 4: {
                                            monitor.setCanceled(true);
                                            break;
                                        }
                                        }
                                    } else if (!nowall) {
                                        copyFile(file, newfile);
                                    }
                                } else {
                                    copyFile(file, newfile);
                                }
                            }
                        } catch (IOException e) {
                            if (errors == null) {
                                errors = new ArrayList(configs.length);
                            }
                            errors.add(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(),
                                    e.getMessage(), e));
                        } catch (CoreException e) {
                            if (errors == null) {
                                errors = new ArrayList(configs.length);
                            }
                            errors.add(e.getStatus());
                        }
                    }
                    if (!monitor.isCanceled()) {
                        monitor.worked(1);
                    }
                }
                if (errors == null || errors.isEmpty()) {
                    return Status.OK_STATUS;
                } else {
                    if (errors.size() == 1) {
                        return (IStatus) errors.get(0);
                    } else {
                        return new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), 0,
                                (IStatus[]) errors.toArray(new IStatus[errors.size()]),
                                WizardMessages.ExportLaunchConfigurationsWizardPage_18, null);
                    }
                }
            } finally {
                monitor.done();
            }
        }
    };
    exportjob.schedule();
    return true;
}

From source file:org.eclipse.debug.internal.ui.importexport.launchconfigurations.ImportLaunchConfigurationsWizardPage.java

License:Open Source License

/**
 * Performs the actual work of the wizard page and return is the work was successful
 * @return true if the import completed normally, false otherwise
 *//*from  ww w .j av a 2  s . c o m*/
public boolean finish() {
    IDialogSettings settings = getDialogSettings();
    settings.put(OVERWRITE, fOverwrite.getSelection());
    settings.put(OLD_PATH, fFromDirectory.getText().trim());
    boolean overwrite = fOverwrite.getSelection();
    List items = getSelectedResources();
    File config, newconfig = null;
    boolean owall = false, nowall = false;
    MessageDialog dialog = null;
    final List filesToImport = new ArrayList();
    for (Iterator iter = items.iterator(); iter.hasNext();) {
        config = (File) ((DebugFileSystemElement) iter.next()).getFileSystemObject();
        newconfig = new File(new Path(LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.toOSString())
                .append(config.getName()).toOSString());
        if (newconfig.exists() & !overwrite) {
            if (nowall) {
                continue;
            }
            if (!owall) {
                dialog = new MessageDialog(DebugUIPlugin.getShell(),
                        WizardMessages.ExportLaunchConfigurationsWizardPage_11, null,
                        MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_12,
                                new String[] { config.getName() }),
                        MessageDialog.QUESTION,
                        new String[] { WizardMessages.ExportLaunchConfigurationsWizardPage_13,
                                WizardMessages.ExportLaunchConfigurationsWizardPage_14,
                                WizardMessages.ExportLaunchConfigurationsWizardPage_15,
                                WizardMessages.ExportLaunchConfigurationsWizardPage_16,
                                WizardMessages.ExportLaunchConfigurationsWizardPage_17 },
                        0);
                int ret = dialog.open();
                switch (ret) {
                case 0: {
                    filesToImport.add(config);
                    break;
                }
                case 1: {
                    owall = true;
                    filesToImport.add(config);
                    break;
                }
                case 3: {
                    nowall = true;
                    break;
                }
                case 4: {
                    return true;
                }
                }
            } else if (!nowall) {
                filesToImport.add(config);
            }
        } else {
            filesToImport.add(config);
        }
    }

    if (!filesToImport.isEmpty()) {
        Job job = new Job(WizardMessages.ExportLaunchConfigurationsWizard_0) {
            public IStatus run(IProgressMonitor monitor) {
                LaunchManager launchManager = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
                try {
                    launchManager.importConfigurations(
                            (File[]) filesToImport.toArray(new File[filesToImport.size()]), monitor);
                } catch (CoreException e) {
                    return e.getStatus();
                }
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
    return true;
}

From source file:org.eclipse.debug.internal.ui.launchConfigurations.CompileErrorProjectPromptStatusHandler.java

License:Open Source License

public Object handleStatus(IStatus status, Object source) throws CoreException {
    ILaunchConfiguration config = null;/*from   w  w  w  .  ja  v a  2s. c o m*/
    List projects = new ArrayList();

    if (source instanceof List) {
        List args = (List) source;
        Iterator iterator = args.iterator();
        while (iterator.hasNext()) {
            Object arg = iterator.next();
            if (arg instanceof ILaunchConfiguration) {
                config = (ILaunchConfiguration) arg;
                if (DebugUITools.isPrivate(config)) {
                    return Boolean.TRUE;
                }
            } else if (arg instanceof IProject) {
                projects.add(arg);
            }
        }
    }
    Shell shell = DebugUIPlugin.getShell();
    StringBuffer projectList = new StringBuffer();
    //we need to limit this
    int size = Math.min(20, projects.size());
    for (int i = 0; i < size; i++) {
        if (i > 0) {
            projectList.append(", "); //$NON-NLS-1$
        }
        projectList.append(((IProject) projects.get(i)).getName());
    }
    String projectMessage = null;
    if (projects.size() > 20) {
        projectMessage = MessageFormat.format(
                LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_0,
                new Object[] { projectList.toString() });
    } else {
        projectMessage = projectList.toString();
    }
    String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0;
    String message = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_2,
            new String[] { projectMessage });
    IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return Boolean.TRUE;
        }
    }
    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message,
            MessageDialog.QUESTION,
            new String[] { IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
            LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_1, false);
    int open = dialog.open();
    if (open == IDialogConstants.PROCEED_ID) {
        if (dialog.getToggleState()) {
            store.setValue(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR,
                    MessageDialogWithToggle.ALWAYS);
        }
        return Boolean.TRUE;
    } else {
        return Boolean.FALSE;
    }
}

From source file:org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.java

License:Open Source License

/**
 * Create and return a dialog that asks the user whether they want to discard
 * unsaved changes.//from   w  w  w. j  a va  2  s.  c  om
 * 
 * @return the return code based on the button selected.
 * The value will be one of <code>YES_ID</code> or <code>NO_ID</code> from
 * <code>IDialogConstants</code>.
 */
private int showDiscardChangesDialog() {
    StringBuffer buffer = new StringBuffer(
            MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___35,
                    new String[] { fTabViewer.getWorkingCopy().getName() }));
    buffer.append(fTabViewer.getErrorMesssage());
    buffer.append(LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_discard_changes_37);
    MessageDialog dialog = new MessageDialog(getShell(),
            LaunchConfigurationsMessages.LaunchConfigurationDialog_Discard_changes__38, null, buffer.toString(),
            MessageDialog.QUESTION,
            new String[] { LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32,
                    LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33 },
            1);
    int val = IDialogConstants.NO_ID;
    if (dialog.open() == 0) {
        if (fLaunchConfigurationView != null) {
            fLaunchConfigurationView.setAutoSelect(false);
        }
        fTabViewer.handleRevertPressed();
        val = IDialogConstants.YES_ID;
        if (fLaunchConfigurationView != null) {
            fLaunchConfigurationView.setAutoSelect(true);
        }
    }
    if (val == IDialogConstants.NO_ID) {
        val = ID_DISCARD_BUTTON;
    }
    return val;
}

From source file:org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.java

License:Open Source License

/**
 * Create and return a dialog that asks the user whether they want to save
 * unsaved changes./*from  w  ww.  j  a v  a  2 s . com*/
 * 
 * @return the return code based on the button selected.
 * The value will be one of <code>YES_ID</code>, <code>NO_ID</code>, or <code>CANCEL_ID</code>, from
 * <code>IDialogConstants</code>.
 */
private int showSaveChangesDialog() {
    String message = MessageFormat.format(
            LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___29,
            new String[] { fTabViewer.getWorkingCopy().getName() });
    MessageDialog dialog = new MessageDialog(getShell(),
            LaunchConfigurationsMessages.LaunchConfigurationFilteredTree_save_changes, null, message,
            MessageDialog.QUESTION,
            new String[] { LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32,
                    LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33,
                    LaunchConfigurationsMessages.LaunchConfigurationsDialog_c_ancel },
            0);
    int ret = dialog.open();
    int val = IDialogConstants.CANCEL_ID;
    if (ret == 0 || ret == 1) {
        if (ret == 0) {
            val = IDialogConstants.YES_ID;
        } else {
            val = IDialogConstants.NO_ID;
        }
    }
    return val;
}

From source file:org.eclipse.debug.internal.ui.preferences.StringVariablePreferencePage.java

License:Open Source License

/**
 * Attempts to create and add a new variable with the given properties.  Returns
 * whether the operation completed successfully (either the variable was added
 * successfully, or the user cancelled the operation).  Returns false if the name
 * is null or the user chooses not to overwrite an existing variable.
 *  /*from w ww  . j av a 2 s.  com*/
 * @param name name of the variable, cannot be <code>null</code> or empty.
 * @param description description of the variable or <code>null</code> 
 * @param value value of the variable or <code>null</code>
 * @return whether the operation completed successfully
 */
private boolean addVariable(String name, String description, String value) {
    if (name == null || name.length() == 0) {
        MessageDialog.openError(getShell(), DebugPreferencesMessages.StringVariablePreferencePage_21,
                DebugPreferencesMessages.StringVariablePreferencePage_20);
        return false;
    }
    List editedVariables = variableContentProvider.getWorkingSetVariables();
    Iterator iter = editedVariables.iterator();
    while (iter.hasNext()) {
        VariableWrapper currentVariable = (VariableWrapper) iter.next();
        if (!currentVariable.isRemoved()) {
            String currentName = currentVariable.getName();
            if (currentName.equals(name)) {
                if (currentVariable.isReadOnly()) {
                    MessageDialog.openError(getShell(),
                            DebugPreferencesMessages.StringVariablePreferencePage_23,
                            MessageFormat.format(DebugPreferencesMessages.StringVariablePreferencePage_22,
                                    new String[] { name }));
                    return false;
                } else {
                    MessageDialog dialog = new MessageDialog(getShell(),
                            DebugPreferencesMessages.SimpleVariablePreferencePage_15, null,
                            MessageFormat.format(DebugPreferencesMessages.SimpleVariablePreferencePage_16,
                                    new String[] { name }),
                            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                            0);
                    int overWrite = dialog.open();
                    if (overWrite == 0) {
                        currentVariable.setValue(value);
                        currentVariable.setDescription(description);
                        variableTable.update(currentVariable, null);
                        return true;
                    } else if (overWrite == 1) {
                        return false;
                    } else {
                        return true; // Cancel was pressed, return true so operation is ended
                    }
                }
            }
        }
    }
    VariableWrapper newVariable = new VariableWrapper(name, description, value);
    variableContentProvider.addVariable(newVariable);
    variableTable.refresh();
    return true;
}

From source file:org.eclipse.dltk.internal.ui.wizards.buildpath.newsourcepage.RemoveLinkedFolderDialog.java

License:Open Source License

/**
 * Creates a new remove linked folder dialog.
 * /*w w w.jav  a  2 s .c  o  m*/
 * @param shell the parent shell to use
 * @param folder the linked folder to remove
 */
RemoveLinkedFolderDialog(final Shell shell, final IFolder folder) {
    super(shell, NewWizardMessages.BuildpathModifierQueries_confirm_remove_linked_folder_label, null,
            Messages.format(NewWizardMessages.BuildpathModifierQueries_confirm_remove_linked_folder_message,
                    new Object[] { folder.getFullPath() }),
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default
    Assert.isTrue(folder.isLinked());
}

From source file:org.eclipse.dltk.internal.ui.wizards.buildpath.VariableBlock.java

License:Open Source License

public boolean performOk() {
    ArrayList removedVariables = new ArrayList();
    ArrayList changedVariables = new ArrayList();
    removedVariables.addAll(Arrays.asList(DLTKCore.getBuildpathVariableNames()));

    // remove all unchanged
    List changedElements = fVariablesList.getElements();
    for (int i = changedElements.size() - 1; i >= 0; i--) {
        BPVariableElement curr = (BPVariableElement) changedElements.get(i);
        if (curr.isReadOnly()) {
            changedElements.remove(curr);
        } else {/*from   w  w w . ja va 2 s  . co m*/
            IPath path = curr.getPath();
            IPath prevPath = DLTKCore.getBuildpathVariable(curr.getName());
            if (prevPath != null && prevPath.equals(path)) {
                changedElements.remove(curr);
            } else {
                changedVariables.add(curr.getName());
            }
        }
        removedVariables.remove(curr.getName());
    }
    int steps = changedElements.size() + removedVariables.size();
    if (steps > 0) {

        boolean needsBuild = false;
        if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) {
            String title = NewWizardMessages.VariableBlock_needsbuild_title;
            String message = NewWizardMessages.VariableBlock_needsbuild_message;

            MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message,
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    2);
            int res = buildDialog.open();
            if (res != 0 && res != 1) {
                return false;
            }
            needsBuild = (res == 0);
        }

        final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements);
        final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        try {
            dialog.run(true, true, runnable);
        } catch (InvocationTargetException e) {
            ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(),
                    NewWizardMessages.VariableBlock_variableSettingError_titel,
                    NewWizardMessages.VariableBlock_variableSettingError_message);
            return false;
        } catch (InterruptedException e) {
            return false;
        }

        if (needsBuild) {
            CoreUtility.getBuildJob(null).schedule();
        }
    }
    return true;
}

From source file:org.eclipse.dltk.mod.ui.preferences.BuildPathsPropertyPage.java

License:Open Source License

public void setVisible(boolean visible) {
    if (fBuildPathsBlock != null) {
        if (!visible) {
            if (fBuildPathsBlock.hasChangesInDialog()) {
                String title = PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title;
                String message = PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message;
                String[] buttonLabels = new String[] {
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save,
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard,
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore };
                MessageDialog dialog = new MessageDialog(getShell(), title, null, message,
                        MessageDialog.QUESTION, buttonLabels, 0);
                int res = dialog.open();
                if (res == 0) {
                    performOk();/*from  w w  w.  j  a v  a  2  s  .c  om*/
                } else if (res == 1) {
                    fBuildPathsBlock.init(DLTKCore.create(getProject()), null);
                } else {
                    // keep unsaved
                }
            }
        } else {
            if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInBuildpathFile()) {
                fBuildPathsBlock.init(DLTKCore.create(getProject()), null);
            }
        }
    }
    super.setVisible(visible);
}