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.scada.sec.ui.ConfirmationDialogFuture.java

License:Open Source License

private Boolean showDialog(final ConfirmationCallback cb, final Display display, final Shell parentShell,
        final String dialogTitle) {
    switch (cb.getConfirmationType()) {
    case CONFIRM:
        return MessageDialog.openConfirm(parentShell, dialogTitle, cb.getLabel()) ? true : null;
    case ERROR:/*  w  ww  .ja v a  2  s.com*/
        MessageDialog.openError(parentShell, dialogTitle, cb.getLabel());
        return true;
    case WARNING:
        MessageDialog.openWarning(parentShell, dialogTitle, cb.getLabel());
        return true;
    case INFORMATION:
        MessageDialog.openInformation(parentShell, dialogTitle, cb.getLabel());
        return true;
    case QUESTION:
        return MessageDialog.openQuestion(parentShell, dialogTitle, cb.getLabel());
    case QUESTION_WITH_CANCEL: {
        final MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, null, cb.getLabel(),
                MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL,
                        IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                0);
        final int result = dialog.open();
        if (result == 2 /*CANCEL*/) {
            return null;
        } else {
            return result == Window.OK;
        }
    }
    default:
        throw new IllegalArgumentException(
                String.format("Unable to process type: %s", cb.getConfirmationType()));
    }
}

From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java

License:Open Source License

/**
 * Attempt to find a standard JFace button id that matches the specified
 * button label. If no match can be found, use the default id provided.
 * /*from   w  w w  .j  a  v  a  2  s.c o  m*/
 * Overridden to investigate the provided buttons.
 * 
 * @param buttonLabel
 *            the button label whose id is sought
 * @param defaultId
 *            the id to use for the button if there is no standard id
 * @return the id for the specified button label
 */
// CHECKSTYLE:OFF
private int mapButtonLabelToButtonID(String buttonLabel, int defaultId) {
    // CHECKSTYLE:OON
    // Not pretty but does the job...
    if (IDialogConstants.OK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OK_ID;
    }

    if (IDialogConstants.YES_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_ID;
    }

    if (IDialogConstants.NO_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_ID;
    }

    if (IDialogConstants.CANCEL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CANCEL_ID;
    }

    if (IDialogConstants.YES_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_TO_ALL_ID;
    }

    if (IDialogConstants.SKIP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.SKIP_ID;
    }

    if (IDialogConstants.STOP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.STOP_ID;
    }

    if (IDialogConstants.ABORT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.ABORT_ID;
    }

    if (IDialogConstants.RETRY_LABEL.equals(buttonLabel)) {
        return IDialogConstants.RETRY_ID;
    }

    if (IDialogConstants.IGNORE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.IGNORE_ID;
    }

    if (IDialogConstants.PROCEED_LABEL.equals(buttonLabel)) {
        return IDialogConstants.PROCEED_ID;
    }

    if (IDialogConstants.OPEN_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OPEN_ID;
    }

    if (IDialogConstants.CLOSE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CLOSE_ID;
    }

    if (IDialogConstants.BACK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.BACK_ID;
    }

    if (IDialogConstants.NEXT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NEXT_ID;
    }

    if (IDialogConstants.FINISH_LABEL.equals(buttonLabel)) {
        return IDialogConstants.FINISH_ID;
    }

    if (IDialogConstants.HELP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.HELP_ID;
    }

    if (IDialogConstants.NO_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_TO_ALL_ID;
    }

    if (IDialogConstants.SHOW_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    if (IDialogConstants.HIDE_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    for (String providedButton : buttonsMap.keySet()) {
        if (providedButton.equals(buttonLabel)) {
            return buttonsMap.get(providedButton);
        }
    }

    // No XXX_LABEL in IDialogConstants for these. Unlikely
    // they would be used in a message dialog though.
    // public int SELECT_ALL_ID = 18;
    // public int DESELECT_ALL_ID = 19;
    // public int SELECT_TYPES_ID = 20;

    return defaultId;
}

From source file:org.eclipse.sirius.common.ui.tools.api.selection.EMFMessageDialog.java

License:Open Source License

/**
 * Convenience method to open a simple Yes/No question dialog.
 * /*  w  w w  . java 2  s.co m*/
 * @param parent
 *            the parent shell of the dialog, or <code>null</code> if none
 * @param factory
 *            the adapter factory for EMF instances.
 * @param eObjects
 *            the list of EObjects to display.
 * @param title
 *            the dialog's title, or <code>null</code> if none
 * @param message
 *            the message
 * @return <code>true</code> if the user presses the OK button,
 *         <code>false</code> otherwise
 */
public static boolean openQuestionWithEObjects(final Shell parent, final AdapterFactory factory,
        final Collection<EObject> eObjects, final String title, final String message) {
    final MessageDialog dialog = new EMFMessageDialog(parent, factory, eObjects, title, null, // accept
            message, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // yes
    return dialog.open() == 0;
}

From source file:org.eclipse.sirius.common.ui.tools.api.util.SWTUtil.java

License:Open Source License

/**
 * Show a dialog to ask the user to save or not the content of the Session.
 * The window's return codes can be ISaveablePart2.CANCEL,
 * ISaveablePart2.YES or ISaveablePart2.NO.
 * /*from  ww w . j  ava 2s.  co  m*/
 * @param label
 *            the name of the element to save or any other label
 * @param canCancel
 *            <code>true</code> if the save can be cancel,
 *            <code>false</code> otherwise
 * @param stillOpenElsewhere
 *            <code>true</code> the object to save is open elsewhere,
 *            <code>false</code> otherwise
 * @return the return code
 */
private static int showStandardSaveDialog(final String label, final boolean canCancel,
        boolean stillOpenElsewhere) {
    // Step 1: getting the save buttons
    Map<String, Integer> buttons = Maps.newLinkedHashMap();
    buttons.put(IDialogConstants.YES_LABEL, IDialogConstants.YES_ID);
    buttons.put(IDialogConstants.NO_LABEL, IDialogConstants.NO_ID);

    // Step 2 :opening window
    int temporaryResult = openSaveDialog(label, canCancel, buttons, stillOpenElsewhere);

    return temporaryResult;
}

From source file:org.eclipse.sirius.tests.swtbot.RepairTest.java

License:Open Source License

/**
 * Scenario 4 bis : repair with multiple opened sessions (at least one
 * changed), and without backup//from  w  w  w .j  a va2  s .  com
 * <UL>
 * <LI>Close all the opened sessions</LI>
 * <LI>Open a session on a simple aird file, sc4-1.aird</LI>
 * <LI>The session is opened and not dirty (if it's dirty, save it)</LI>
 * <LI>Open a session on another simple aird file, sc4-2.aird</LI>
 * <LI>Modify one of the diagram of the second session to have this one in
 * dirty mode</LI>
 * <LI>Launch the action Repair model on an sc3-1.aird</LI>
 * <LI>A popup warns the user that the session will be close</LI>
 * <LI>Click NO on the popup</LI>
 * <LI>Check that the session are closed</LI>
 * <LI>Check that a backup was done</LI>
 * <LI>Check that the modification done in the diagram of the second session
 * (sc4-2.aird) is still longer here and that the second session is dirty</LI>
 * </UL>
 * 
 * @throws Exception
 *             in case of problem
 */
public void testRepairWithMultipleSessionsOpenedWithOneDirtyAndWithoutSave() throws Exception {
    String nameOfPackageToRename = "pc";
    String newNameOfPackage = "pcNew";
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
    assertEquals("It should be no backup file before repair.", 0,
            getNumberOfBackupFiles(project, SESSION_FILE4_1));
    // Open the session
    final UIResource sessionAirdResource1 = new UIResource(designerProject, SESSION_FILE4_1);
    final UILocalSession localSession1 = designerPerspective.openSessionFromFile(sessionAirdResource1);
    // Open a diagram of this session
    openRepresentation(localSession1.getOpenedSession(), REPRESENTATION_NAME_DIAGRAM,
            REPRESENTATION_INSTANCE_NAME_DIAGRAM4_1, DDiagram.class);
    // Check that the session is not dirty (if dirty, save it)
    if (localSession1.getOpenedSession().getStatus() == SessionStatus.DIRTY) {
        localSession1.save();
    }
    // Open the session
    final UIResource sessionAirdResource2 = new UIResource(designerProject, SESSION_FILE4_2);
    UILocalSession localSession2 = designerPerspective.openSessionFromFile(sessionAirdResource2);
    // Open a diagram of this session
    SWTBotSiriusDiagramEditor editor = (SWTBotSiriusDiagramEditor) openRepresentation(
            localSession2.getOpenedSession(), REPRESENTATION_NAME_DIAGRAM,
            REPRESENTATION_INSTANCE_NAME_DIAGRAM4_2, DDiagram.class);
    changeNameOfPCPackage(editor, nameOfPackageToRename, newNameOfPackage);
    // Check that the session is dirty
    assertTrue("The session \"" + sessionAirdResource2.getName() + "\" must be dirty.",
            localSession2.getOpenedSession().getStatus() == SessionStatus.DIRTY);
    // Launch the repair action
    String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel");
    designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel);
    //
    bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE));
    SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE);
    message.setFocus();
    bot.button(IDialogConstants.NO_LABEL).click();
    // Wait the end of repair
    SWTBotUtils.waitProgressMonitorClose("Progress Information");
    assertNoProblemsLogged();
    // Check that two sessions are open
    assertEquals("No session should be opened.", 0, SessionManager.INSTANCE.getSessions().size());

    // Check that there is a backup
    assertEquals("It should be one backup file after repair.", 1,
            getNumberOfBackupFiles(project, SESSION_FILE4_1));
    localSession2 = designerPerspective.openSessionFromFile(sessionAirdResource2);
    editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession2.getOpenedSession(),
            REPRESENTATION_NAME_DIAGRAM, REPRESENTATION_INSTANCE_NAME_DIAGRAM4_2, DDiagram.class);

    assertNotNull("The modification made in the second editor should be lost.",
            editor.getEditPart(nameOfPackageToRename));
    // Check if there is problem logged during this test
    assertNoProblemsLogged();
}

From source file:org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesRepairValidator.java

License:Open Source License

/**
 * @param dirtySessionsName//from w  w  w.  j av  a  2s .c  o  m
 *            The dirty sessions names
 * @return true if the dirty sessions must be saved, false otherwise
 * @throws CoreException
 *             If the user cancel the process
 */
private boolean userValidation(Collection<String> dirtySessionsName) throws CoreException {
    // Get the active shell
    Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    if (shell == null) {
        shell = new Shell();
    }

    boolean saveSessions = false;
    String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel");
    StringBuffer message = new StringBuffer("It's impossible to launch the \"" + repairActionLabel
            + "\" action with opened representations file. So they will be closed before the repair process.");
    if (dirtySessionsName.size() > 0) {
        message.append(" The following representations file");
        if (dirtySessionsName.size() == 1) {
            message.append(" has");
        } else {
            message.append("s have");
        }
        message.append(" been modified : ");
        for (String dirtySessionName : dirtySessionsName) {
            message.append("\n\t- '");
            message.append(dirtySessionName);
            message.append("'");
            message.append(", ");
        }
        message.delete(message.length() - 2, message.length() - 1);
        message.append("\n\nSave changes?");
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        final MessageDialog dialog = new MessageDialog(shell, MESSAGE_TITLE, null, message.toString(),
                MessageDialog.QUESTION, buttons, 0);
        int result = dialog.open();
        if (result == SWT.DEFAULT || buttons[result].equals(IDialogConstants.CANCEL_LABEL)) {
            throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID,
                    RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.",
                    null));
        }
        if (buttons[result].equals(IDialogConstants.YES_LABEL)) {
            saveSessions = true;
        }
    } else {
        message.append("\nDo you want to continue?");
        if (!MessageDialog.openConfirm(shell, MESSAGE_TITLE, message.toString())) {
            throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID,
                    RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.",
                    null));
        }
    }
    return saveSessions;
}

From source file:org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog.java

License:Open Source License

/**
 * Opens a question dialog with YES, NO and CANCEL.
 *
 * @param parentShell//from  w  ww .ja  v a 2s .com
 *            The shell.
 * @param title
 *            The title for the message dialog.
 * @param message
 *            The dialog message text.
 * @param buttonLabel
 *            An string array listing the labels of the message dialog buttons. If <code>null</code>, the default
 *            labeling, typically &quot;OK&quot; for a single button message dialog, will be applied.
 * @param key
 *            The unique key for the stored result value (e.g. "<PluginName>.<ActionOrDialogName>").
 * @param contextHelpId
 *            The optional help context id. If <code>null</code>, no help
 *            button will be shown.
 * @return The stored or selected result.
 */
public static int openYesNoCancelDialog(Shell parentShell, String title, String message, String[] buttonLabel,
        String key, String contextHelpId) {
    if (buttonLabel == null)
        buttonLabel = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
    OptionalMessageDialog dialog = new OptionalMessageDialog(parentShell, title, null, message, QUESTION,
            buttonLabel, 0, key, contextHelpId);
    return dialog.open();
}

From source file:org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog.java

License:Open Source License

/**
 * Opens a question dialog with YES and NO.
 *
 * @param parentShell//from  w w w  .j a  v  a  2s.  c  o m
 *            The shell.
 * @param title
 *            The title for the message dialog.
 * @param message
 *            The dialog message text.
 * @param buttonLabel
 *            An string array listing the labels of the message dialog buttons. If <code>null</code>, the default
 *            labeling, typically &quot;OK&quot; for a single button message dialog, will be applied.
 * @param key
 *            The unique key for the stored result value (e.g. "<PluginName>.<ActionOrDialogName>").
 * @param contextHelpId
 *            The optional help context id. If <code>null</code>, no help
 *            button will be shown.
 * @return The stored or selected result.
 */
public static int openYesNoDialog(Shell parentShell, String title, String message, String[] buttonLabel,
        String key, String contextHelpId) {
    if (buttonLabel == null)
        buttonLabel = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
    OptionalMessageDialog dialog = new OptionalMessageDialog(parentShell, title, null, message, QUESTION,
            buttonLabel, 0, key, contextHelpId);
    return dialog.open();
}

From source file:org.eclipse.team.internal.ccvs.ui.AddToVersionControlDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
    super.createButtonsForButtonBar(parent);
}

From source file:org.eclipse.team.internal.ccvs.ui.CVSProjectSetSerializer.java

License:Open Source License

private int confirmOverwrite(IProject project, boolean yesToAll, Shell shell) {
    if (yesToAll)
        return 2;
    if (!project.exists())
        return 0;
    final MessageDialog dialog = new MessageDialog(shell,
            CVSUIMessages.CVSProjectSetSerializer_Confirm_Overwrite_Project_8, null,
            NLS.bind(// w w  w.j a v a 2 s. c om
                    CVSUIMessages.CVSProjectSetSerializer_The_project__0__already_exists__Do_you_wish_to_overwrite_it__9,
                    new String[] { project.getName() }),
            MessageDialog.QUESTION, // 
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    final int[] result = new int[1];
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            result[0] = dialog.open();
        }
    });
    return result[0];
}