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.egit.ui.internal.dialogs.UnmergedBranchDialog.java

License:Open Source License

/**
 * @param parentShell/*  w w w . j av  a2s  . c  o  m*/
 * @param nodes
 */
public UnmergedBranchDialog(Shell parentShell, List<T> nodes) {
    super(parentShell, UIText.UnmergedBranchDialog_Title, null, UIText.UnmergedBranchDialog_Message,
            MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    this.nodes = nodes;
}

From source file:org.eclipse.egit.ui.internal.history.command.AmbiguousBranchDialog.java

License:Open Source License

AmbiguousBranchDialog(Shell parentShell, List<RefNode> nodes, String title, String message) {
    super(parentShell, title, null, message, MessageDialog.QUESTION,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    this.nodes = nodes;
}

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

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    List<RepositoryNode> selectedNodes = getSelectedNodes(event);
    if (selectedNodes.size() != 1)
        return null;

    Repository repository = selectedNodes.get(0).getObject();
    String repositoryName = Activator.getDefault().getRepositoryUtil().getRepositoryName(repository);

    String message = MessageFormat.format(UIText.RemoveOrDeleteRepositoryCommand_DialogMessage, repositoryName);
    String[] buttonLabels = { UIText.RemoveOrDeleteRepositoryCommand_RemoveFromViewButton,
            UIText.RemoveOrDeleteRepositoryCommand_DeleteRepositoryButton, IDialogConstants.CANCEL_LABEL };
    MessageDialog dialog = new MessageDialog(getShell(event),
            UIText.RemoveOrDeleteRepositoryCommand_DialogTitle, null, message, MessageDialog.QUESTION,
            buttonLabels, 0);//from   ww w  . j  a va2  s .  co  m

    int result = dialog.open();
    if (result == 0) // Remove from View
        super.removeRepository(event, false);
    else if (result == 1) // Delete Repository...
        super.removeRepository(event, true);
    return null;
}

From source file:org.eclipse.emf.cdo.dawn.actions.HandleConflictsAction.java

License:Open Source License

public void run(IAction action) {

    if (TRACER.isEnabled()) {
        TRACER.format("Start solving conflicts for {0}", selectedElement); //$NON-NLS-1$
    }/*from ww w . j a  v  a  2s  .  c  om*/

    IEditorPart activeEditor = DawnEditorHelper.getActiveEditor();
    if (activeEditor instanceof IDawnEditor) {
        MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null,
                "There are conflicts in your diagram. Would you like to rollback your current transaction?",
                MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1);

        switch (dialog.open()) {
        case 0: // yes
            // DawnConflictHelper.rollback((DiagramDocumentEditor)activeEditor);
            ((IDawnEditor) activeEditor).getDawnEditorSupport().rollback();
            break;
        case 1: // no
            break;
        default: // cancel
            break;
        }
    }
}

From source file:org.eclipse.emf.cdo.dawn.ui.handlers.SolveConflictHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart activeEditor = DawnEditorHelper.getActiveEditor();

    if (TRACER.isEnabled()) {
        TRACER.format("Start solving conflicts for {0}", activeEditor); //$NON-NLS-1$
    }//www  . ja va2s  . c o  m

    if (activeEditor instanceof IDawnEditor) {
        MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null,
                "There are conflicts in your diagram. Would you like to rollback your current transaction?",
                MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1);

        switch (dialog.open()) {
        case 0: // yes
            ((IDawnEditor) activeEditor).getDawnEditorSupport().rollback();
            break;
        case 1: // no
            break;
        default: // cancel
            break;
        }
    }
    return null;
}

From source file:org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction.java

License:Open Source License

@Override
protected void preRun() throws Exception {
    if (CDOUtil.isSessionDirty(getSession())) {
        MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
                Messages.getString("CloseSessionAction.2"), //$NON-NLS-1$
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                0);//from w w w  .j  ava2s  . com
        if (dialog.open() != MessageDialog.OK) {
            cancel();
        }
    }
}

From source file:org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction.java

License:Open Source License

@Override
protected void preRun() throws Exception {
    if (getView().isDirty()) {
        MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
                Messages.getString("CloseViewAction.2"), //$NON-NLS-1$
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                0);/*w  ww. j  a  va 2 s.com*/
        if (dialog.open() != MessageDialog.OK) {
            cancel();
        }
    }
}

From source file:org.eclipse.emf.compare.ide.ui.internal.handler.SelectAncestorDialog.java

License:Open Source License

public SelectAncestorDialog(Shell parentShell, AdapterFactory adapterFactory, T[] theResources) {
    super(parentShell, CompareMessages.SelectAncestorDialog_title, null,
            CompareMessages.SelectAncestorDialog_message, MessageDialog.QUESTION,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    this.adapterFactory = adapterFactory;
    this.elements = new ArrayList<T>(Arrays.asList(theResources));
}

From source file:org.eclipse.emf.compare.mpatch.emfdiff2mpatch.actions.CompareAndTransformAction.java

License:Open Source License

/**
 * Call EMF Compare to create an emfdiff for the given models.
 * /*ww w .j  a  v  a 2  s .c om*/
 * @param oldFile
 *            The unchanged version of a model.
 * @param newFile
 *            The changed version of the same model.
 * @param shell
 *            The shell for showing dialogs.
 * @return The emfdiff in case of successful differencing or <code>null</code> otherwise.
 */
private static ComparisonSnapshot createComparisonSnapshot(final IFile oldFile, final IFile newFile,
        Shell shell) {
    ComparisonResourceSnapshot emfdiff = null;
    try {
        // get resources
        final ResourceSet resourceSet = new ResourceSetImpl();
        final Resource oldResource = resourceSet
                .getResource(URI.createFileURI(oldFile.getFullPath().toString()), true);
        final Resource newResource = resourceSet
                .getResource(URI.createFileURI(newFile.getFullPath().toString()), true);
        if (oldResource.getContents().size() != 1)
            throw new IllegalArgumentException(
                    oldFile.getFullPath() + " is expected to contain exactly one root model element, but "
                            + oldResource.getContents().size() + " elements found!");
        if (newResource.getContents().size() != 1)
            throw new IllegalArgumentException(
                    newFile.getFullPath() + " is expected to contain exactly one root model element, but "
                            + newResource.getContents().size() + " elements found!");

        // ask user which is the modified version of the model
        @SuppressWarnings("deprecation")
        final MessageDialog dialog = new MessageDialog(shell, "Please select the modified model",
                MessageDialog.getImage(Dialog.DLG_IMG_QUESTION),
                "Please select the file which contains the MODIFIED version:", MessageDialog.QUESTION,
                new String[] { newFile.getName(), oldFile.getName() }, 0);
        final int dialogResult = dialog.open();
        if (dialogResult == SWT.DEFAULT)
            return null;

        // use emf compare to compute differences
        final EObject oldModel = (dialogResult == 0 ? oldResource : newResource).getContents().get(0);
        final EObject newModel = (dialogResult == 0 ? newResource : oldResource).getContents().get(0);
        emfdiff = CommonUtils.createEmfdiff(newModel, oldModel);
        if (emfdiff != null)
            return emfdiff;
        throw new IllegalArgumentException("EMF Compare failed to compute differences.");

    } catch (Exception e) {
        final String message = "Could not create differences with EMF Compare.";
        Emfdiff2mpatchActivator.getDefault().logError(message, e);
        MessageDialog.openError(shell, "Could not create differences with EMF Compare!",
                message + " See error log for details.\n" + "Error message: " + e.getMessage());
        return null;
    }
}

From source file:org.eclipse.emf.compare.ui2.input.SelectAncestorDialog.java

License:Open Source License

/**
 * A message dialog that permit the user to select the Ancestor.
 * //from  w w  w. ja va  2 s .co m
 * @param parentShell
 *            Workbench window's shell.
 * @param theResources
 *            list of the selected resources
 */

@SuppressWarnings("restriction")
public SelectAncestorDialog(Shell parentShell, IResource[] theResources) {
    super(parentShell, "Select Common Ancestor", null,
            "Which resource would you like to use as the common ancestor in the three-way compare?",
            MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL, },
            0);
    this.theResources = theResources;
}