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.ltk.internal.ui.refactoring.history.RefactoringDescriptorDeleteQuery.java

License:Open Source License

/**
 * {@inheritDoc}/*from  www.j  av  a2 s . c o  m*/
 */
public RefactoringStatus proceed(final RefactoringDescriptorProxy proxy) {
    final IPreferenceStore store = RefactoringUIPlugin.getDefault().getPreferenceStore();
    if (!fWarned) {
        if (!store.getBoolean(PREFERENCE_DO_NOT_WARN_DELETE)) {
            fShell.getDisplay().syncExec(new Runnable() {

                public final void run() {
                    if (!fShell.isDisposed()) {
                        final String count = new Integer(fCount).toString();
                        String message = null;
                        if (fProject != null) {
                            if (fCount == 1) {
                                message = Messages.format(
                                        RefactoringUIMessages.RefactoringPropertyPage_confirm_delete_pattern_singular,
                                        BasicElementLabels.getResourceName(fProject));
                            } else {
                                message = Messages.format(
                                        RefactoringUIMessages.RefactoringPropertyPage_confirm_delete_pattern_plural,
                                        new String[] { count, BasicElementLabels.getResourceName(fProject) });
                            }
                        } else {
                            if (fCount == 1) {
                                message = RefactoringUIMessages.RefactoringDescriptorDeleteQuery_confirm_deletion_singular;
                            } else {
                                message = Messages.format(
                                        RefactoringUIMessages.RefactoringDescriptorDeleteQuery_confirm_deletion_plural,
                                        count);
                            }
                        }
                        final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(fShell,
                                RefactoringUIMessages.RefactoringPropertyPage_confirm_delete_caption, message,
                                RefactoringUIMessages.RefactoringHistoryWizard_do_not_show_message,
                                store.getBoolean(PREFERENCE_DO_NOT_WARN_DELETE), null, null);
                        store.setValue(PREFERENCE_DO_NOT_WARN_DELETE, dialog.getToggleState());
                        fReturnCode = dialog.getReturnCode();
                    }
                }
            });
        } else
            fReturnCode = IDialogConstants.YES_ID;
    }
    fWarned = true;
    if (fReturnCode == IDialogConstants.YES_ID)
        return new RefactoringStatus();
    return RefactoringStatus.createErrorStatus(IDialogConstants.NO_LABEL);
}

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {

    if (fHasAdditionalPages)
        createPreviousAndNextButtons(parent);
    else//from  www.  j a v a2s. co  m
        createPreviewButton(parent);

    String OK_LABEL = (fHasAdditionalPages) ? IDialogConstants.FINISH_LABEL : IDialogConstants.OK_LABEL;
    String CANCEL_LABEL = IDialogConstants.CANCEL_LABEL;
    if (fWizard.internalIsYesNoStyle(InternalAPI.INSTANCE)) {
        OK_LABEL = IDialogConstants.YES_LABEL;
        CANCEL_LABEL = IDialogConstants.NO_LABEL;
    }
    createButton(parent, IDialogConstants.OK_ID, OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, CANCEL_LABEL, false);
    Button okButton = getButton(IDialogConstants.OK_ID);
    okButton.setFocus();
}

From source file:org.eclipse.m2m.internal.qvt.oml.samples.ui.SampleProjectsCreationOperation.java

License:Open Source License

protected IOverwriteQuery createOverwriteQuery(final Shell shell) {
    return new OverwriteQuery(shell) {
        @Override/* w w w  .j  ava2 s . com*/
        protected String[] getOptions() {
            return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL };
        }

        @Override
        protected String[] getReturnCodes() {
            return new String[] { YES, NO, ALL, CANCEL };
        }
    };
}

From source file:org.eclipse.m2m.internal.qvt.oml.samples.ui.SampleProjectsCreationOperation.java

License:Open Source License

protected IOverwriteQuery createProjectOverwriteQuery(final Shell shell) {
    return new OverwriteQuery(shell) {
        @Override//  ww w.  j ava  2s.c  o  m
        protected String[] getOptions() {
            return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL };
        }

        @Override
        protected String[] getReturnCodes() {
            return new String[] { YES, NO, CANCEL };
        }
    };
}

From source file:org.eclipse.mdht.uml.ui.navigator.internal.actions.CloseModelAction.java

License:Open Source License

protected static void closeModel(Resource resource) {
    try {/*from   www.j  av a 2 s  . c o m*/
        ModelDocument saveable = ModelManager.getManager().getModelDocument(resource);
        if (saveable != null) {
            if (saveable.isDirty()) {
                String fileName = resource.getURI().lastSegment();
                String message = NLS.bind(Messages.CloseModelAction_dialogMessage, fileName);
                // Yes, No, Cancel
                MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(),
                        Messages.CloseModelAction_dialogTitle, null, // accept
                        message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                                IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                        0); // yes is the default

                int result = dialog.open();
                if (2 == result) {
                    // Cancel
                    return;
                }
                if (0 == result) {
                    // Yes
                    saveable.doSave(new NullProgressMonitor());
                }
            }

            // if not canceled, the resource is closed
            saveable.doClose(new NullProgressMonitor());

            return;
        }

        // if saveable not found, the resource is unloaded
        resource.unload();

    } catch (Exception e) {
        String message = NLS.bind(Messages.CloseModelAction_errorMessage,
                new String[] { e.getLocalizedMessage() });
        Logger.logException(message, e);
        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.CloseModelAction_errorTitle,
                message);
    }
}

From source file:org.eclipse.mylyn.internal.tasks.ui.actions.DeleteAction.java

License:Open Source License

protected void doDelete(final List<?> toDelete) {

    boolean allLocalTasks = true;
    boolean allSupportRepositoryDeletion = true;
    boolean allElementsAreTasks = true;

    // determine what repository elements are to be deleted so that we can present the correct message to the user
    for (Object object : toDelete) {
        if (object instanceof ITask) {
            ITask task = (ITask) object;
            AbstractRepositoryConnector repositoryConnector = TasksUi
                    .getRepositoryConnector(task.getConnectorKind());
            TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
                    task.getRepositoryUrl());
            if (repository != null && repositoryConnector != null) {
                allSupportRepositoryDeletion &= repositoryConnector.canDeleteTask(repository, task);
            } else {
                allSupportRepositoryDeletion = false;
            }/* w  w w.j ava  2  s  .  c o  m*/
            allLocalTasks &= task instanceof LocalTask;
        } else {
            allElementsAreTasks = false;
        }
    }

    String elements = buildElementListString(toDelete);
    String message = buildMessage(toDelete, elements, allElementsAreTasks);

    if (toDelete.isEmpty()) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.DeleteAction_Delete_failed, Messages.DeleteAction_Nothing_selected);
    } else {
        boolean deleteConfirmed = false;
        boolean deleteOnServer = false;

        final boolean allTasksDeletable = allSupportRepositoryDeletion;

        if (allLocalTasks || !allElementsAreTasks) {
            deleteConfirmed = MessageDialog.openQuestion(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.DeleteAction_Delete_Tasks, message);
        } else {
            String toggleMessage = Messages.DeleteAction_Also_delete_from_repository_X;
            if (allTasksDeletable) {
                toggleMessage = NLS.bind(toggleMessage, ""); //$NON-NLS-1$
            } else {
                toggleMessage = NLS.bind(toggleMessage, Messages.DeleteAction_Not_supported);
            }
            final MessageDialogWithToggle dialog = new MessageDialogWithToggle(WorkbenchUtil.getShell(),
                    Messages.DeleteAction_Delete_Tasks, null, message, MessageDialog.QUESTION,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, toggleMessage,
                    false) {
                @Override
                protected Control createContents(Composite parent) {
                    Control createdControl = super.createContents(parent);
                    getToggleButton().setEnabled(allTasksDeletable);
                    return createdControl;
                }
            };

            deleteConfirmed = dialog.open() == IDialogConstants.YES_ID;
            deleteOnServer = dialog.getToggleState() && allTasksDeletable;
        }

        if (deleteConfirmed) {
            deleteElements(toDelete, deleteOnServer);
        }
    }
}

From source file:org.eclipse.net4j.util.ui.confirmation.ConfirmationDialog.java

License:Open Source License

private static String getLabel(Confirmation confirmation) {
    switch (confirmation) {
    case OK:/*from  w  w  w.  j  a v  a 2s.c o m*/
        return IDialogConstants.OK_LABEL;
    case CANCEL:
        return IDialogConstants.CANCEL_LABEL;
    case YES:
        return IDialogConstants.YES_LABEL;
    case NO:
        return IDialogConstants.NO_LABEL;
    }

    throw new IllegalArgumentException(confirmation.name());
}

From source file:org.eclipse.oomph.setup.internal.installer.SimpleVariablePage.java

License:Open Source License

public boolean promptLaunchProduct(String currentAction) {
    if (installButton != null && installButton.getCurrentState() == State.LAUNCH) {
        MessageDialog prompt = new MessageDialog(dialog, "Launch Product", null,
                currentAction//w  w  w.  j a v a 2  s. co  m
                        + " without having launched the installed product.\n\nDo you want to launch it now?",
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                0);

        int result = prompt.open();
        if (result == 0) {
            // Yes: Do launch; then continue.
            launchProduct(false);
            return true;
        }

        if (result == 1) {
            // No: Do not launch; but continue.
            return true;
        }

        // Cancel: Do not launch; and do not continue.
        return false;
    }

    // Nothing to launch; just continue.
    return true;
}

From source file:org.eclipse.oomph.setup.ui.synchronizer.SynchronizerWelcomeDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.NO_LABEL, false);
}

From source file:org.eclipse.osee.framework.ui.skynet.commandHandlers.branch.GeneralBranchHandler.java

License:Open Source License

@Override
public Object executeWithException(ExecutionEvent arg0, IStructuredSelection selection)
        throws OseeCoreException {
    List<Branch> selectedBranches = Handlers.getBranchesFromStructuredSelection(selection);

    Iterator<Branch> iterator = selectedBranches.iterator();
    List<Branch> hasChildren = new LinkedList<Branch>();
    while (iterator.hasNext()) {
        Branch branch = iterator.next();
        Collection<Branch> childBranches = branch.getChildBranches();
        if (!childBranches.isEmpty()) {
            iterator.remove();/*  w  w w. ja v  a2s.co m*/
            hasChildren.add(branch);
        }
    }

    if (!hasChildren.isEmpty()) {
        StringBuilder children = new StringBuilder();
        children.append(
                String.format("The following branches have children and cannot be %sd:\n", type.dialogType));
        for (Branch b : hasChildren) {
            List<Branch> branches = new LinkedList<Branch>(b.getChildBranches(true));
            children.append(String.format("Branch %s has children: %s\n", b.getName(),
                    Strings.buildStatment(branches)));
        }
        MessageDialog.openError(Displays.getActiveShell(), type.dialogTitle, children.toString());
    }

    if (!selectedBranches.isEmpty()) {
        StringBuilder branchesStatement = new StringBuilder();
        branchesStatement.append(String.format("Are you sure you want to %s branch(es): ", type.dialogType));
        branchesStatement.append(Strings.buildStatment(selectedBranches));
        branchesStatement.append(" \u003F");

        MessageDialog dialog = new MessageDialog(Displays.getActiveShell(), type.dialogTitle, null,
                branchesStatement.toString(), MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);

        if (dialog.open() == 0) {
            performOperation(selectedBranches);
        }
    }

    return null;
}