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.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.
 *  /* w  ww  .  j a  v a2  s.  c o  m*/
 * @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.
 * //from  ww  w  . ja va 2 s . co  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  ww.  j  a  v a  2  s.  c o  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.wizards.BuildpathsBlock.java

License:Open Source License

public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) {
    return new IRemoveOldBinariesQuery() {
        public boolean doQuery(final IPath oldOutputLocation) throws OperationCanceledException {
            final int[] res = new int[] { 1 };
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    Shell sh = shell != null ? shell : DLTKUIPlugin.getActiveWorkbenchShell();
                    String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title;
                    String message = Messages.format(
                            NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description,
                            oldOutputLocation.toString());
                    MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION,
                            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                                    IDialogConstants.CANCEL_LABEL },
                            0);//from  w  ww . j  ava  2 s  . c o m
                    res[0] = dialog.open();
                }
            });
            if (res[0] == 0) {
                return true;
            } else if (res[0] == 1) {
                return false;
            }
            throw new OperationCanceledException();
        }
    };
}

From source file:org.eclipse.e4.demio.views.nav.NavigatorDropAdapter.java

License:Open Source License

public String queryOverwrite(String pathString) {
    if (alwaysOverwrite) {
        return ALL;
    }/* w w  w .j ava 2s  .  c om*/

    final String returnCode[] = { CANCEL };
    final String msg = NLS.bind(ResourceNavigatorMessages.DropAdapter_overwriteQuery, pathString);
    final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
    getDisplay().syncExec(new Runnable() {
        public void run() {
            MessageDialog dialog = new MessageDialog(getShell(), ResourceNavigatorMessages.DropAdapter_question,
                    null, msg, MessageDialog.QUESTION, options, 0);
            dialog.open();
            int returnVal = dialog.getReturnCode();
            String[] returnCodes = { YES, ALL, NO, CANCEL };
            returnCode[0] = returnVal < 0 ? CANCEL : returnCodes[returnVal];
        }
    });
    if (returnCode[0] == ALL) {
        alwaysOverwrite = true;
    }
    return returnCode[0];
}

From source file:org.eclipse.e4.demo.contacts.views.DetailsView.java

License:Open Source License

@Inject
public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) {
    if (contact != null) {
        if (dirtyable.isDirty()) {
            MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null,
                    "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
            dialog.create();//from w  w  w . j a v a  2s.co m
            ThemeUtil.applyDialogStyles(engine, dialog.getShell());
            if (dialog.open() == Window.OK) {
                ParameterizedCommand saveCommand = commandService.createCommand("contacts.save",
                        Collections.EMPTY_MAP);
                handlerService.executeHandler(saveCommand);
            }
        }

        updatePartTitle(contact);
    } else {
        uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    if (!detailComposite.isDisposed()) {
        detailComposite.update(contact);
    }
}

From source file:org.eclipse.edt.ide.ui.internal.property.pages.VariableBlock.java

License:Open Source License

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

    // remove all unchanged
    List changedElements = fVariablesList.getElements();
    for (int i = changedElements.size() - 1; i >= 0; i--) {
        CPVariableElement curr = (CPVariableElement) changedElements.get(i);
        if (curr.isReadOnly()) {
            changedElements.remove(curr);
        } else {/*from  w  w  w. ja v  a 2s.  c om*/
            IPath path = curr.getPath();
            IPath prevPath = JavaCore.getClasspathVariable(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.edt.ide.ui.preferences.CompilerPropertyAndPreferencePage.java

License:Open Source License

protected void promptForNewCompiler(String errorCompilerId) {
    String message = MessageFormat.format(UINlsStrings.CompilerPreferencePage_compilerNoLongerAvailable,
            new Object[] { errorCompilerId });
    MessageDialog dialog = new MessageDialog(getShell(),
            UINlsStrings.CompilerPreferencePage_compilerNoLongerAvailable_title, null, message,
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 2) {
        protected int getMinimumMessageWidth() {
            return convertHorizontalDLUsToPixels((int) (IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH * 1.5));
        }//from ww w .jav a  2  s .  co  m

        protected Control createCustomArea(Composite parent) {
            Composite composite = new Composite(parent, SWT.NONE);
            GridLayout layout = new GridLayout();
            composite.setLayout(layout);
            GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            composite.setLayoutData(gridData);
            return composite;
        }
    };
    int res = dialog.open();
    if (res == IDialogConstants.CANCEL_ID) { // cancel pressed
        latestStatus.setWarning(MessageFormat.format(UINlsStrings.CompilerPreferencePage_cannotDisplayCompiler,
                new Object[] { errorCompilerId }));
        statusChangeListener.statusChanged(latestStatus);
    }
}

From source file:org.eclipse.egit.ui.internal.repository.tree.command.RemoveCommand.java

License:Open Source License

@SuppressWarnings("boxing")
private boolean confirmProjectDeletion(List<IProject> projectsToDelete, ExecutionEvent event)
        throws OperationCanceledException {

    String message = NLS.bind(UIText.RepositoriesView_ConfirmProjectDeletion_Question, projectsToDelete.size());
    MessageDialog dlg = new MessageDialog(getShell(event),
            UIText.RepositoriesView_ConfirmProjectDeletion_WindowTitle, null, message,
            MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);/*from www.  j  a  v a  2 s  . c  o m*/
    int index = dlg.open();
    if (index == 2)
        throw new OperationCanceledException();

    return index == 0;
}

From source file:org.eclipse.egit.ui.test.team.actions.CommitNonWSChangesTest.java

License:Open Source License

@Test
public void testCommitDeletedProject() throws Exception {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
    project.delete(true, false, null);/*w ww. j  a  v  a  2  s .c  o m*/
    clickOnCommit();

    SWTBotShell commitDialog = bot.shell(UIText.CommitDialog_CommitChanges);
    SWTBotTable table = commitDialog.bot().table();
    assertEquals("Wrong row count", 4, table.rowCount());
    assertTableLineContent(table, 0, "Rem., not staged", "GeneralProject/.project");
    assertTableLineContent(table, 1, "Rem., not staged", "GeneralProject/folder/test.txt");
    assertTableLineContent(table, 2, "Rem., not staged", "GeneralProject/folder/test2.txt");
    assertTableLineContent(table, 3, "Untracked", "ProjectWithoutDotProject/.project");

    commitDialog.bot().textWithLabel(UIText.CommitDialog_Author).setText(TestUtil.TESTAUTHOR);
    commitDialog.bot().textWithLabel(UIText.CommitDialog_Committer).setText(TestUtil.TESTCOMMITTER);
    commitDialog.bot().styledTextWithLabel(UIText.CommitDialog_CommitMessage)
            .setText("Delete Project GeneralProject");
    selectAllCheckboxes(table);
    commitDialog.bot().button(UIText.CommitDialog_Commit).click();
    // wait until commit is completed
    Job.getJobManager().join(JobFamilies.COMMIT, null);
    String[] paths = { "ProjectWithoutDotProject/.project", "ProjectWithoutDotProject/folder/test.txt",
            "ProjectWithoutDotProject/folder/test2.txt" };
    TestUtil.assertRepositoryContainsFiles(repository, paths);
    // check there is nothing to commit
    clickOnCommit();
    bot.shell(UIText.CommitAction_noFilesToCommit).bot().button(IDialogConstants.NO_LABEL).click();
}