Example usage for org.eclipse.jface.dialogs IDialogConstants YES_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.

Prototype

String YES_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.

Click Source Link

Document

The label for yes buttons.

Usage

From source file:org.eclipse.rcptt.ui.actions.edit.PasteAction.java

License:Open Source License

/**
 * Check if the user wishes to overwrite the supplied resource or all
 * resources. Copied from//from w  w  w.  ja va2s  .co  m
 * org.eclipse.ui.actions.CopyFilesAndFoldersOperation.
 * 
 * @param source
 *            the source resource
 * @param destination
 *            the resource to be overwritten
 * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID,
 *         IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating
 *         whether the current resource or all resources can be overwritten,
 *         or if the operation should be canceled.
 */
private int checkOverwrite(final IResource source, final IResource destination) {
    final int[] result = new int[1];

    // Dialogs need to be created and opened in the UI thread
    Runnable query = new Runnable() {
        public void run() {
            String message;
            int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID,
                    IDialogConstants.CANCEL_ID };
            String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };

            String[] bindings = new String[] { IDEResourceInfoUtils.getLocationText(destination),
                    IDEResourceInfoUtils.getDateStringValue(destination),
                    IDEResourceInfoUtils.getLocationText(source),
                    IDEResourceInfoUtils.getDateStringValue(source) };
            message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion,
                    bindings);

            MessageDialog dialog = new MessageDialog(shell,
                    IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists, null, message,
                    MessageDialog.QUESTION, labels, 0) {
                protected int getShellStyle() {
                    return super.getShellStyle() | SWT.SHEET;
                }
            };
            dialog.open();
            if (dialog.getReturnCode() == SWT.DEFAULT) {
                // A window close returns SWT.DEFAULT, which has to be
                // mapped to a cancel
                result[0] = IDialogConstants.CANCEL_ID;
            } else {
                result[0] = resultId[dialog.getReturnCode()];
            }
        }
    };
    shell.getDisplay().syncExec(query);
    return result[0];
}

From source file:org.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.java

License:Open Source License

/**
 * Check if the user wishes to overwrite the supplied resource or all
 * resources./*from  w  w w .j  a  v a2s .c  om*/
 * 
 * @param source
 *            the source resource
 * @param destination
 *            the resource to be overwritten
 * @return one of IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID,
 *         IDialogConstants.NO_ID, IDialogConstants.CANCEL_ID indicating
 *         whether the current resource or all resources can be overwritten,
 *         or if the operation should be canceled.
 */
private int checkOverwrite(final IResource source, final IResource destination) {
    final int[] result = new int[1];

    // Dialogs need to be created and opened in the UI thread
    Runnable query = new Runnable() {
        @SuppressWarnings("restriction")
        public void run() {
            String message;
            int resultId[] = { IDialogConstants.YES_ID, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.NO_ID,
                    IDialogConstants.CANCEL_ID };
            String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };

            if (destination.getType() == IResource.FOLDER) {
                if (homogenousResources(source, destination)) {
                    message = NLS.bind(
                            org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteMergeQuestion,
                            destination.getFullPath().makeRelative());
                } else {
                    if (destination.isLinked()) {
                        message = NLS.bind(
                                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeLinkQuestion,
                                destination.getFullPath().makeRelative());
                    } else {
                        message = NLS.bind(
                                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteNoMergeNoLinkQuestion,
                                destination.getFullPath().makeRelative());
                    }
                    resultId = new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID,
                            IDialogConstants.CANCEL_ID };
                    labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL };
                }
            } else {
                String[] bindings = new String[] {
                        org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(destination),
                        org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils
                                .getDateStringValue(destination),
                        org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getLocationText(source),
                        org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils.getDateStringValue(source) };
                message = NLS.bind(
                        org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteWithDetailsQuestion,
                        bindings);
            }
            MessageDialog dialog = new MessageDialog(messageShell,
                    org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceExists,
                    null, message, MessageDialog.QUESTION, labels, 0) {
                protected int getShellStyle() {
                    return super.getShellStyle() | SWT.SHEET;
                }
            };
            dialog.open();
            if (dialog.getReturnCode() == SWT.DEFAULT) {
                // A window close returns SWT.DEFAULT, which has to be
                // mapped to a cancel
                result[0] = IDialogConstants.CANCEL_ID;
            } else {
                result[0] = resultId[dialog.getReturnCode()];
            }
        }
    };
    messageShell.getDisplay().syncExec(query);
    return result[0];
}

From source file:org.eclipse.rcptt.ui.actions.edit.Q7CopyFilesAndFoldersOperation.java

License:Open Source License

/**
 * Performs an import of the given stores into the provided container.
 * Returns a status indicating if the import was successful.
 * //from   w w w.  j  av a 2  s  .  c  om
 * @param stores
 *            stores that are to be imported
 * @param target
 *            container to which the import will be done
 * @param monitor
 *            a progress monitor for showing progress and for cancelation
 */
private void performFileImport(IFileStore[] stores, IContainer target, IProgressMonitor monitor) {
    IOverwriteQuery query = new IOverwriteQuery() {
        @SuppressWarnings("restriction")
        public String queryOverwrite(String pathString) {
            if (alwaysOverwrite) {
                return ALL;
            }

            final String returnCode[] = { CANCEL };
            final String msg = NLS.bind(
                    org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_overwriteQuestion,
                    pathString);
            final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
            messageShell.getDisplay().syncExec(new Runnable() {
                public void run() {
                    MessageDialog dialog = new MessageDialog(messageShell,
                            org.eclipse.ui.internal.ide.IDEWorkbenchMessages.CopyFilesAndFoldersOperation_question,
                            null, msg, MessageDialog.QUESTION, options, 0) {
                        protected int getShellStyle() {
                            return super.getShellStyle() | SWT.SHEET;
                        }
                    };
                    dialog.open();
                    int returnVal = dialog.getReturnCode();
                    String[] returnCodes = { YES, ALL, NO, CANCEL };
                    returnCode[0] = returnVal == -1 ? CANCEL : returnCodes[returnVal];
                }
            });
            if (returnCode[0] == ALL) {
                alwaysOverwrite = true;
            } else if (returnCode[0] == CANCEL) {
                canceled = true;
            }
            return returnCode[0];
        }
    };

    ImportOperation op = new ImportOperation(target.getFullPath(), stores[0].getParent(),
            FileStoreStructureProvider.INSTANCE, query, Arrays.asList(stores));
    op.setContext(messageShell);
    op.setCreateContainerStructure(false);
    op.setVirtualFolders(createVirtualFoldersAndLinks);
    op.setCreateLinks(createLinks);
    op.setRelativeVariable(relativeVariable);
    try {
        op.run(monitor);
    } catch (InterruptedException e) {
        return;
    } catch (InvocationTargetException e) {
        if (e.getTargetException() instanceof CoreException) {
            displayError(((CoreException) e.getTargetException()).getStatus());
        } else {
            display(e);
        }
        return;
    }
    // Special case since ImportOperation doesn't throw a CoreException on
    // failure.
    IStatus status = op.getStatus();
    if (!status.isOK()) {
        if (errorStatus == null) {
            errorStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.ERROR, getProblemsMessage(), null);
        }
        errorStatus.merge(status);
    }
}

From source file:org.eclipse.rcptt.ui.dialogs.AddProjectReferencesDialog.java

License:Open Source License

private AddProjectReferencesDialog(Shell parentShell, IProject project,
        Map<IProject, Set<IQ7NamedElement>> references) {
    super(parentShell, Messages.AddProjectReferencesDialog_Title, null, null, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
            Messages.AddProjectReferencesDialog_ToggleText, false);
    this.project = project;
    this.references = references;
    this.message = generateMessage(references);
    setShellStyle(SWT.SHEET);/*from   ww w .j  a v a2 s.c o  m*/
}

From source file:org.eclipse.rcptt.ui.dialogs.RemoveAllProjectReferencesDialog.java

License:Open Source License

private RemoveAllProjectReferencesDialog(Shell parentShell, IQ7Project project,
        List<IQ7NamedElement> references) {
    super(parentShell, "Project Context and Verification References", null, null, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
            "Always remove default project context and verification references automatically.", false);
    this.project = project;
    this.references = references;
    this.message = generateMessage(references);
    setShellStyle(SWT.SHEET);//  w w w . ja v  a2 s .  c  o  m
}

From source file:org.eclipse.rcptt.ui.dialogs.RemoveProjectReferencesDialog.java

License:Open Source License

private RemoveProjectReferencesDialog(Shell parentShell, IQ7NamedElement element, List<String> references) {
    super(parentShell, "Project Context and Verification References", null, null, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0,
            "Always remove default project context and verification references automatically.", false);
    this.element = element;
    this.references = references;
    this.message = generateMessage(references);
    setShellStyle(SWT.SHEET);//from  w w w  .j a v a 2s .c o  m
}

From source file:org.eclipse.rcptt.ui.launching.aut.AUTConnectionErrorDialog.java

License:Open Source License

private static String[] getDialogButtonsLabels(boolean showLogFile) {
    if (showLogFile) {
        return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
    }//from w  ww.j a v a  2s  . co m
    return new String[] { IDialogConstants.OK_LABEL };
}

From source file:org.eclipse.rcptt.ui.panels.main.ControlPanelWindow.java

License:Open Source License

private void save() {
    try {/*from   w  ww.ja  va  2s  . c o m*/
        ITestCase model = getModel();
        NullProgressMonitor monitor = new NullProgressMonitor();
        if (model.exists()) {
            model = (ITestCase) model.getWorkingCopy(monitor);
            copyContent(scenario, (Scenario) model.getNamedElement());
            WriteAccessChecker writeAccessChecker = new WriteAccessChecker(getShell());

            try {
                if (!writeAccessChecker.makeResourceWritable(model)) {
                    return;
                }
                model.commitWorkingCopy(true, monitor);
            } catch (CoreException e) {
                Q7UIPlugin.log(e);
            } finally {
                model.discardWorkingCopy();
            }
            contextsTable.setProject(getSavedProject());
            verificationsTable.setProject(getSavedProject());
            copyContent((Scenario) model.getNamedElement(), this.scenario);
        } else {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.ControlPanelWindow_SaveDialogTitle,
                    null, "Failed to save testcase because underlying resources is not exist.",
                    MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL },
                    0);
            int value = dialog.open(); // Number of pressed button
            if (value == 0) {
                saveAs();
            }
        }
    } catch (ModelException e) {
        Q7UIPlugin.log(e);
    }
}

From source file:org.eclipse.rcptt.ui.panels.main.ControlPanelWindow.java

License:Open Source License

private boolean openSaveDialog() {
    if (getModel() != null && !getModel().exists()) {
        return true;
    }/*  www  .j av  a 2  s  . co m*/
    MessageDialog dialog = new MessageDialog(getShell(), Messages.ControlPanelWindow_SaveDialogTitle, null,
            Messages.ControlPanelWindow_SaveDialogMsg, MessageDialog.QUESTION_WITH_CANCEL, new String[] {
                    IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            0);
    int returnCode = dialog.open(); // Number of pressed button
    if (returnCode == 0) {
        if (getModel() != null) {
            save();
        } else {
            if (!saveAs()) {
                return false;
            }
        }
    }
    switch (returnCode) {
    case 2:
        return false; // User clicked Cancel button
    default:
        return true;
    }
}

From source file:org.eclipse.rcptt.ui.resources.wizards.WizardFileSystemResourceImportPage1.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. jav a  2 s  . c om
 * @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(
                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
    } else {
        messageString = NLS.bind(
                org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
                path.lastSegment(), path.removeLastSegments(1).toOSString());
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            org.eclipse.ui.internal.ide.IDEWorkbenchMessages.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()];
}