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.ui.internal.tweaklets.TabBehaviourMRU.java

License:Open Source License

public IEditorReference findReusableEditor(WorkbenchPage page) {
    boolean reuse = WorkbenchPlugin.getDefault().getPreferenceStore()
            .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN);
    if (!reuse) {
        return null;
    }//  w  ww.j a  v a2  s .c  om

    IEditorReference editors[] = page.getSortedEditors();
    int length = editors.length;
    if (length < page.getEditorReuseThreshold()) {
        return null;
    } else if (length > page.getEditorReuseThreshold()) {
        List<IEditorReference> refs = new ArrayList<IEditorReference>();
        List<IEditorReference> keep = new ArrayList<IEditorReference>(Arrays.asList(editors));
        int extra = length - page.getEditorReuseThreshold();
        // look for extra editors that should be closed
        for (int i = 0; i < editors.length; i++) {
            if (extra == 0) {
                break;
            }

            if (editors[i].isPinned() || editors[i].isDirty()) {
                continue;
            }

            refs.add(editors[i]);
            extra--;
        }

        for (IEditorReference ref : refs) {
            page.closeEditor(ref, false);
            keep.remove(ref);
        }

        editors = keep.toArray(new IEditorReference[keep.size()]);
    }

    IEditorReference dirtyEditor = null;

    // find an editor to reuse, go in reverse due to activation order
    for (int i = editors.length - 1; i > -1; i--) {
        IEditorReference editor = editors[i];
        if (editor.isPinned()) {
            // skip pinned editors
            continue;
        }
        if (editor.isDirty()) {
            // record dirty editors
            if (dirtyEditor == null) {
                dirtyEditor = editor;
            }
            continue;
        }
        // an editor is neither pinned nor dirty, use this one
        return editor;
    }
    // can't find anything, return null
    if (dirtyEditor == null) {
        return null;
    }

    /* fix for 11122 */
    boolean reuseDirty = WorkbenchPlugin.getDefault().getPreferenceStore()
            .getBoolean(IPreferenceConstants.REUSE_DIRTY_EDITORS);
    if (!reuseDirty) {
        return null;
    }

    MessageDialog dialog = new MessageDialog(page.getWorkbenchWindow().getShell(),
            WorkbenchMessages.EditorManager_reuseEditorDialogTitle, null, // accept the default window icon
            NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, dirtyEditor.getName()),
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    WorkbenchMessages.EditorManager_openNewEditorLabel },
            0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    int result = dialog.open();
    if (result == 0) { // YES
        IEditorPart editor = dirtyEditor.getEditor(true);
        if (!page.saveEditor(editor, false)) {
            return null;
        }
    } else if ((result == 2) || (result == -1)) {
        return null;
    }
    return dirtyEditor;
}

From source file:org.eclipse.ui.internal.views.markers.DeleteHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) {

    final MarkerSupportView view = getView(event);
    if (view == null)
        return this;

    final IMarker[] selected = getSelectedMarkers(event);

    // Verify./*from   ww w.  jav  a  2  s.  c  o m*/
    MessageDialog dialog = new MessageDialog(view.getSite().getShell(), MarkerMessages.deleteActionConfirmTitle,
            null, // icon
            MarkerMessages.deleteActionConfirmMessage, MessageDialog.WARNING,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);

    if (dialog.open() != 0) {
        return view;
    }

    WorkspaceJob deleteJob = new WorkspaceJob(IDEWorkbenchMessages.MarkerDeleteHandler_JobTitle) { //See Bug#250807
        public IStatus runInWorkspace(IProgressMonitor monitor) {
            monitor.beginTask(IDEWorkbenchMessages.MarkerDeleteHandler_JobMessageLabel, 10 * selected.length);
            try {
                IUndoableOperation op = new DeleteMarkersOperation(selected,
                        view.getDeleteOperationName(selected));
                op.addContext(view.getUndoContext());
                execute(op, MarkerMessages.deleteMarkers_errorMessage, monitor,
                        WorkspaceUndoUtil.getUIInfoAdapter(view.getSite().getShell()));
            } finally {
                monitor.done();
            }
            return Status.OK_STATUS;
        }
    };
    deleteJob.setUser(true);
    deleteJob.schedule();

    return this;
}

From source file:org.eclipse.ui.internal.wizards.preferences.WizardPreferencesPage.java

License:Open Source License

/**
 * Displays a Yes/No question to the user with the specified message and
 * returns the user's response./*from   w w  w .  j  av a 2s  .c  om*/
 * 
 * @param message
 *            the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
protected boolean queryYesNoQuestion(String message) {
    MessageDialog dialog = new MessageDialog(getContainer().getShell(), PreferencesMessages.Question,
            (Image) null, message, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    // ensure yes is the default

    return dialog.open() == 0;
}

From source file:org.eclipse.ui.internal.wizards.preferences.WizardPreferencesPage.java

License:Open Source License

/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * //  w  w w  .  j  av a  2s.  c  o  m
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 *         <code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {

    Path path = new Path(pathString);

    String messageString;
    // Break the message up if there is a file name and a directory
    // and there are at least 2 segments.
    if (path.getFileExtension() == null || path.segmentCount() < 2) {
        messageString = NLS.bind(PreferencesMessages.WizardDataTransfer_existsQuestion, pathString);
    } else {
        messageString = NLS.bind(PreferencesMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
                path.lastSegment(), path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(), PreferencesMessages.Question,
            null, messageString, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
    // run in syncExec because callback is from an operation,
    // which is probably not running in the UI thread.
    getControl().getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}

From source file:org.eclipse.ui.tests.dialogs.TextMessageDialogs.java

License:Open Source License

private MessageDialog getQuestionDialog(String title, String message) {
    return new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
}

From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java

License:Open Source License

public void testDeleteProject() {
    String title = "Delete Project";
    String msg = NLS.bind("Delete", (new Object[] { DUMMY_PROJECT, DUMMY_ABSOLUTE_PATH }));
    Dialog dialog = new MessageDialog(getShell(), title, null, // accept the default window icon
            msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);/*ww  w  .  j a va  2 s .  co m*/
    DialogCheck.assertDialog(dialog, this);
}

From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java

License:Open Source License

public void testDeleteReadOnlyCheck() {
    Dialog dialog = new MessageDialog(getShell(), "Delete?", null, "This?", MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);//from  w w w  .  j  a  v  a 2  s.co  m
    DialogCheck.assertDialog(dialog, this);
}

From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java

License:Open Source License

public void testDropOverwrite() {
    Dialog dialog = new MessageDialog(getShell(), ResourceNavigatorMessages.DropAdapter_question, null,
            MessageFormat.format(ResourceNavigatorMessages.DropAdapter_overwriteQuery,
                    new Object[] { DUMMY_RELATIVE_PATH }),
            MessageDialog.QUESTION,//from   w  ww  .j  a v  a 2s  . c  o m
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    DialogCheck.assertDialog(dialog, this);
}

From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java

License:Open Source License

public void testMoveReadOnlyCheck() {
    Dialog dialog = new MessageDialog(getShell(), "Move", null, "OK to move", MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);// w  w w  . j av  a 2  s  .  c  o  m
    DialogCheck.assertDialog(dialog, this);
}

From source file:org.eclipse.ui.tests.dialogs.UIMessageDialogs.java

License:Open Source License

public void testOverwritePerspective() {
    Dialog dialog = new MessageDialog(getShell(), WorkbenchMessages.SavePerspective_overwriteTitle, null,
            NLS.bind(WorkbenchMessages.SavePerspective_overwriteQuestion,
                    (new Object[] { "Dummy Perspective" })),
            MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);/*  www. j  a  v  a 2s  . c om*/
    DialogCheck.assertDialog(dialog, this);
}