Example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Prototype

String NO_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Click Source Link

Document

The label for no buttons.

Usage

From source file:org.eclipse.cdt.cpp.ui.internal.actions.CreateConfigureAction.java

License:Open Source License

public void run() {
    boolean execute = true;
    int createUpdate = 0; // 0 == ok do update, 1 == no update , 2 == cancel action
    boolean configfilesExist = false;

    Shell shell = _dataStore.getDomainNotifier().findShell();

    ModelInterface pluginApi = _plugin.getModelInterface();
    project = (IProject) pluginApi.findResource(_subject);

    if (_command.getValue().equals("CREATE_CONFIGURE")) {
        String str1 = new String();
        String message;//from   w w w .  j  a v a  2 s  .c o  m
        String[] extraLabel = new String[] { "Do not show this dialog again" };
        String title = "Creating configure script";
        String[] buttonTitles = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };

        // checking if automatic updating is enabled from the autoconf preferences page
        ArrayList autoUpdateCreate = org.eclipse.cdt.cpp.ui.internal.CppPlugin
                .readProperty(updatePreferenceKey);
        if (!autoUpdateCreate.isEmpty()) {
            String preference = (String) autoUpdateCreate.get(0);
            if (preference.equals("Yes"))
                enableCreateUpdate = true;
            else
                enableCreateUpdate = false;
        }

        if (doesAutoconfSupportExist()) {
            configfilesExist = true;
            if (enableCreateUpdate) {

                if (isProjectImported(project, projectStatusKey)) {
                    str1 = new String(
                            "\nWould you like the system to update and generate missing configuration files?");
                } else {
                    buttonTitles = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
                }
                if (doesFileExist("configure"))
                    message = new String(
                            "\nRegenerating project configuration script - configure is not up to date "
                                    + str1);
                else
                    message = new String("\nGenerating project configuration script." + str1);
                box = new CustomMessageDialog(shell, title, null, message, 3, buttonTitles, 0, extraLabel, this,
                        dialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    if (buttonTitles.length == 2 && result == 1)// has 2 buttons and cancel pressed
                        createUpdate = result + 1;
                    else
                        createUpdate = result;
                else
                    createUpdate = 0;

            } else {
                message = new String("\nUsing existing configuration files to create the configure script");
                buttonTitles = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
                box = new CustomMessageDialog(shell, title, null, message, 2, buttonTitles, 0, extraLabel, this,
                        dialogPrefernceKey, project);
                int result = box.open();
                if (result != -1)
                    createUpdate = result + 1;
                else
                    createUpdate = 1;
                // 0 is equiv to 1 ie run with no update , 
                //and 1 is equiv to 2 which is to cancel the action so we need to increment
            }
        } else {
            configfilesExist = false;
            message = new String("\nCreating configuration files to generate configure script");
            box = new CustomMessageDialog(shell, title, null, message, 2,
                    new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, extraLabel,
                    this, dialogPrefernceKey, project);
            int result = box.open();
            if (result != -1)
                if (result == 1)
                    createUpdate = result + 1;
                else
                    createUpdate = 0;

        }
    }

    if (execute) {
        if (createUpdate == 1 && configfilesExist) {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_CREATE_CONFIGURE_NO_UPDATE");
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        } else if (createUpdate == 0) {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_" + _command.getValue());
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        }
    }
}

From source file:org.eclipse.cdt.cpp.ui.internal.actions.DeleteProjectAction.java

License:Open Source License

public void run() {
    ModelInterface api = ModelInterface.getInstance();
    IProject project = api.findProjectResource(_subject);
    if (project != null) {
        Shell shell = api.getDummyShell();
        String msg = "About to delete project \'" + project.getName() + "\'.\n";
        msg += "Delete all its contents under " + project.getLocation().toOSString() + " as well?";
        String title = "Delete Project Contents";

        MessageDialog dialog = new MessageDialog(shell, title, null, // accept the default window icon
                msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                        IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                0); // yes is the default
        int code = dialog.open();
        boolean deleteContent = false;
        switch (code) {
        case 0: // Yes
            deleteContent = true;/*from   ww  w. j a v a2s .co m*/
            break;
        case 1: // No
            deleteContent = false;
            break;
        default: // CANCEL
            return;
        }

        DeleteOperation op = new DeleteOperation(project, api, deleteContent);
        ProgressMonitorDialog progressDlg = new ProgressMonitorDialog(shell);
        try {
            progressDlg.run(true, true, op);
        } catch (InterruptedException e) {
            System.out.println(e);
        } catch (InvocationTargetException e) {
            System.out.println(e);
        }
    }
}

From source file:org.eclipse.cdt.cpp.ui.internal.actions.RunConfigureAction.java

License:Open Source License

public void run() {
    boolean execute = true;
    int runUpdate = 0;// 0 == ok, 1 == no, 2 == cancel
    boolean noConfigfilesExist = true;

    Shell shell = _dataStore.getDomainNotifier().findShell();
    ModelInterface pluginApi = _plugin.getModelInterface();
    project = (IProject) pluginApi.findResource(_subject);

    if (_command.getValue().equals("RUN_CONFIGURE")) {
        // checking if automatic updating is enabled from the autoconf preferences page
        ArrayList autoUpdateRun = org.eclipse.cdt.cpp.ui.internal.CppPlugin.readProperty(runUpdateKey);
        if (!autoUpdateRun.isEmpty()) {
            String preference = (String) autoUpdateRun.get(0);
            if (preference.equals("Yes")) {
                enableRunUpdate = true;//from w  w  w  .j av a  2 s  .co  m
            } else {
                enableRunUpdate = false;
                ;
            }
        }
        if (!configureIsUptodate(_subject)) {
            if (enableRunUpdate) {
                String message = new String("\nThe system detects that configure script is not up to date"
                        + "\nWould you like to update and generate missing configuration files before running configure?");
                box = new CustomMessageDialog(
                        shell, title, null, message, 3, new String[] { IDialogConstants.YES_LABEL,
                                IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                        0, extraLabels, this, runDialogKey, project);
                // open   the xbox      
                int result = box.open();
                if (result != -1)
                    runUpdate = result;
                else
                    runUpdate = 0;
            } else {
                String message = new String("\nRunning existing configure script"
                        + "\nAutomatic update is turned off - You can use the preferences page to turn it on");
                box = new CustomMessageDialog(shell, title, null, message, 2,
                        new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
                        extraLabels, this, runDialogKey, project);
                // open   the xbox      
                int result = box.open();
                if (result != -1)
                    runUpdate = ++result;
                else
                    runUpdate = 1;
                // 0 is equiv to 1 ie run with no update , 
                //and 1 is equiv to 2 which is to cancel the action so we need to increment
            }
        } else {
            runUpdate = 1;
        }
    }
    if (execute) {
        if (runUpdate == 1) {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_RUN_CONFIGURE_NO_UPDATE");
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        } else if (runUpdate == 0)//&&enableRunUpdate)
        {
            DataElement configureCmd = _dataStore.localDescriptorQuery(_subject.getDescriptor(),
                    "C_" + _command.getValue());
            DataElement status = _dataStore.command(configureCmd, _subject);
            ModelInterface api = ModelInterface.getInstance();
            api.monitorStatus(status);
            api.showView("org.eclipse.cdt.cpp.ui.CppOutputViewPart", status);
            RunThread thread = new RunThread(_subject, status);
            thread.start();
        }
    }
}

From source file:org.eclipse.cdt.cpp.ui.internal.dialogs.PreventableMessageBox.java

License:Open Source License

public static boolean openQuestion(Shell parent, String title, String message) {
    if (_showAgain) {
        PreventableMessageBox dialog = new PreventableMessageBox(parent, title, null, // accept the default window icon
                message, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default
        boolean result = dialog.open() == 0;
        return result;
    }/*  w w  w  . j  a  v  a 2 s . c om*/
    return true;
}

From source file:org.eclipse.cdt.internal.ui.editor.CEditor.java

License:Open Source License

private void updateScalabilityMode(IEditorInput input) {
    int lines = getDocumentProvider().getDocument(input).getNumberOfLines();
    boolean wasEnabled = fEnableScalablilityMode;
    fEnableScalablilityMode = lines > getPreferenceStore()
            .getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES);
    if (fEnableScalablilityMode && !wasEnabled) {
        // Alert users that scalability mode should be turned on
        if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
            MessageDialogWithToggle dialog = new MessageDialogWithToggle(Display.getCurrent().getActiveShell(),
                    CEditorMessages.Scalability_info, null, CEditorMessages.Scalability_message,
                    MessageDialog.INFORMATION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
                    CEditorMessages.Scalability_reappear, false) {
                {/*  w w w  .ja v a 2s  .c o m*/
                    setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.ON_TOP | getDefaultOrientation());
                }

                @Override
                protected void buttonPressed(int buttonId) {
                    PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT,
                            !getToggleState());
                    super.buttonPressed(buttonId);
                    if (buttonId == IDialogConstants.YES_ID) {
                        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
                                Display.getCurrent().getActiveShell(),
                                "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null); //$NON-NLS-1$
                        dialog.open();
                    }
                }
            };
            dialog.setBlockOnOpen(false);
            dialog.open();
        }
    }
}

From source file:org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock.java

License:Open Source License

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

    List<Key> changedOptions = new ArrayList<Key>();
    boolean needsBuild = getChanges(currContext, changedOptions);
    if (changedOptions.isEmpty()) {
        return true;
    }/*  w  w w. jav a  2  s.  c  om*/
    if (needsBuild) {
        int count = getRebuildCount();
        if (count > fRebuildCount) {
            needsBuild = false; // build already requested
            fRebuildCount = count;
        }
    }

    boolean doBuild = false;
    if (needsBuild) {
        String[] strings = getFullBuildDialogStrings(fProject == null);
        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);
            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
            incrementRebuildCount();
            // do a re-index?
            //            container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
        }
    } else {
        // apply changes right away
        try {
            fManager.applyChanges();
        } catch (BackingStoreException e) {
            CUIPlugin.log(e);
            return false;
        }
        if (doBuild) {
            // do a re-index?
            //            CoreUtility.getBuildJob(fProject).schedule();
        }

    }
    return true;
}

From source file:org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationBlock.java

License:Open Source License

/**
 * Builds the projects that were reconfigured by the dialog, if any. The user is prompted (if prompting is
 * not disabled via the preference) before building. The user has the options to build, not build, or
 * cancel. The result indicates cancellation.
 * //from  w  ww  .j  ava 2 s . c  o m
 * @return <code>true</code> if the user opted to save changes and exit the dialog (with or without
 *         build); <code>false</code> if the user cancelled and the dialog should remain open and unsaved
 */
public boolean build() {
    boolean result = true;
    Collection<IProject> projects = workspace.getProjectsToBuild();

    if (!projects.isEmpty()) {
        int defaultButton = OptionalMessageDialog.getDialogDetail(BUILD_PROMPT_DIALOG_ID);
        if (defaultButton == OptionalMessageDialog.NO_DETAIL) {
            defaultButton = BUILD_PROMPT_DIALOG_YES; // yes button is the default-default
        }

        int button = OptionalMessageDialog.open(BUILD_PROMPT_DIALOG_ID, contents.getShell(),
                WorkingSetMessages.WSConfigDialog_buildPrompt_title, null,
                WorkingSetMessages.WSConfigDialog_buildPrompt_message, MessageDialog.QUESTION, new String[] {
                        IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL },
                defaultButton);

        if (button == OptionalMessageDialog.NOT_SHOWN) {
            // handle the case where the dialog was suppressed. Get the current default
            button = defaultButton;
        } else if (button != BUILD_PROMPT_DIALOG_CANCEL) {
            // store non-cancel selection as the new default answer
            OptionalMessageDialog.setDialogDetail(BUILD_PROMPT_DIALOG_ID, button);
        }

        switch (button) {
        case BUILD_PROMPT_DIALOG_YES:
            // do the build
            new BuildJob(projects).schedule();
            break;
        case BUILD_PROMPT_DIALOG_NO:
            // just don't build
            break;
        default: // BUILD_PROMPT_DIALOG_CANCEL
            result = false;
            break;
        }
    }

    return result;
}

From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java

License:Open Source License

/**
 * Overwrite Make Target dialog./*w  w w .  java 2 s.  c o m*/
 *
 * @param name - name of make target to display to a user.
 * @param shell - shell where to display the dialog.
 *
 * @return user's answer.
 */
private static int overwriteMakeTargetDialog(String name, Shell shell) {

    if (lastUserAnswer == IDialogConstants.YES_TO_ALL_ID || lastUserAnswer == IDialogConstants.NO_TO_ALL_ID
            || lastUserAnswer == RENAME_TO_ALL_ID) {

        return lastUserAnswer;
    }

    String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
            MakeUIPlugin.getResourceString("MakeTargetDnD.button.rename"), //$NON-NLS-1$
            IDialogConstants.CANCEL_LABEL, };

    String title = MakeUIPlugin.getResourceString("MakeTargetDnD.title.overwriteTargetConfirm"); //$NON-NLS-1$
    String question = MessageFormat.format(
            MakeUIPlugin.getResourceString("MakeTargetDnD.message.overwriteTargetConfirm"), //$NON-NLS-1$
            new Object[] { name });
    String toggleApplyToAll = MakeUIPlugin.getResourceString("MakeTargetDnD.toggle.applyToAll"); //$NON-NLS-1$

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, question,
            MessageDialog.QUESTION, labels, 0, toggleApplyToAll, false);

    try {
        dialog.open();
        lastUserAnswer = dialog.getReturnCode();
        boolean toAll = dialog.getToggleState();
        if (toAll && lastUserAnswer == IDialogConstants.YES_ID) {
            lastUserAnswer = IDialogConstants.YES_TO_ALL_ID;
        } else if (toAll && lastUserAnswer == IDialogConstants.NO_ID) {
            lastUserAnswer = IDialogConstants.NO_TO_ALL_ID;
        } else if (toAll && lastUserAnswer == RENAME_ID) {
            lastUserAnswer = RENAME_TO_ALL_ID;
        }
    } catch (SWTException e) {
        MakeUIPlugin.log(e);
        lastUserAnswer = IDialogConstants.CANCEL_ID;
    }

    if (lastUserAnswer == SWT.DEFAULT) {
        // A window close returns SWT.DEFAULT, which has to be
        // mapped to a cancel
        lastUserAnswer = IDialogConstants.CANCEL_ID;
    }
    return lastUserAnswer;
}

From source file:org.eclipse.cdt.ui.newui.AbstractPage.java

License:Open Source License

private void rebuildIndex() {
    final Shell shell = getShell();
    final String title = getTitle();
    final String msg = Messages.AbstractPage_rebuildIndex_question;
    int result = OptionalMessageDialog.open(PREF_ASK_REINDEX, shell, title, null /* default image */, msg,
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    if (result == OptionalMessageDialog.NOT_SHOWN) {
        result = OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX);
    } else if (result != SWT.DEFAULT) {
        OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result);
    }//  w ww  .  j a va 2s.co  m
    if (result == 0) { // first button
        final IProject project = getProject();
        CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project));
    }
}

From source file:org.eclipse.cdt.ui.testplugin.util.VerifyDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    _yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    _noButton = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}