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.team.internal.ccvs.ui.DateTagDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        dateEntered = privateGetDate();/*from   w  w  w. j  a va 2 s.  c o  m*/
        if (dateEntered.after(Calendar.getInstance().getTime())) {
            MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.DateTagDialog_6, null,
                    CVSUIMessages.DateTagDialog_7, MessageDialog.WARNING,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, }, 1);
            if (dialog.open() == 1)
                return;
        }
    }
    super.buttonPressed(buttonId);
}

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

License:Open Source License

protected boolean shouldRun() {
    if (super.shouldRun() == false) {
        return false;
    }/*from  ww  w . j av  a 2s. c  om*/
    Job[] jobs = Job.getJobManager().find(destination);
    if (jobs.length != 0) {
        MessageDialog question = new MessageDialog(getShell(),
                CVSUIMessages.DiffOperation_CreatePatchConflictTitle, null,
                NLS.bind(CVSUIMessages.DiffOperation_CreatePatchConflictMessage, destination.toString()),
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL },
                1);
        if (question.open() == 0) {
            Job.getJobManager().cancel(destination);
        } else {
            return false;
        }
    }
    return true;
}

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

License:Open Source License

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

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

License:Open Source License

/**
 * Prompts the user to determine how conflicting changes should be handled.
 * Note: This method is designed to be overridden by test cases.
 * @return 0 to sync conflicts, 1 to sync all non-conflicts, 2 to cancel
 *//*from   w  w  w .  j av a2  s . c  o  m*/
protected int promptForConflicts(SyncInfoSet syncSet) {
    String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
            IDialogConstants.CANCEL_LABEL };
    String question = CVSUIMessages.CommitSyncAction_questionRelease;
    String title = CVSUIMessages.CommitSyncAction_titleRelease;
    String[] tips = new String[] { CVSUIMessages.CommitSyncAction_releaseAll,
            CVSUIMessages.CommitSyncAction_releasePart, CVSUIMessages.CommitSyncAction_cancelRelease };
    Shell shell = getShell();
    final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question,
            MessageDialog.QUESTION, buttons, tips, 0);
    shell.getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode();
}

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

License:Open Source License

private int promptToIncludeBinary(IFile file) {
    MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.GenerateDiffFileWizard_11, null, // accept
            // the default window icon
            NLS.bind(CVSUIMessages.GenerateDiffFileWizard_12, file.getFullPath()), MessageDialog.WARNING,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            1); // no is the default
    return dialog.open();
}

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

License:Open Source License

public int prompt(final ICVSRepositoryLocation location, final int promptType, final String title,
        final String message, final int[] promptResponses, final int defaultResponse) {
    final Display display = CVSUIPlugin.getStandardDisplay();
    final int[] retval = new int[1];
    final String[] buttons = new String[promptResponses.length];
    for (int i = 0; i < promptResponses.length; i++) {
        int prompt = promptResponses[i];
        switch (prompt) {
        case IUserAuthenticator.OK_ID:
            buttons[i] = IDialogConstants.OK_LABEL;
            break;
        case IUserAuthenticator.CANCEL_ID:
            buttons[i] = IDialogConstants.CANCEL_LABEL;
            break;
        case IUserAuthenticator.NO_ID:
            buttons[i] = IDialogConstants.NO_LABEL;
            break;
        case IUserAuthenticator.YES_ID:
            buttons[i] = IDialogConstants.YES_LABEL;
            break;
        }/* w  w  w . j a va2  s. c o  m*/
    }

    display.syncExec(new Runnable() {
        public void run() {
            final MessageDialog dialog = new MessageDialog(new Shell(display), title, null /* title image */,
                    NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_0, message, location.getLocation(true)),
                    promptType, buttons, 1);
            retval[0] = dialog.open();
        }
    });
    return retval[0];
}

From source file:org.eclipse.team.internal.ui.dialogs.MultipleYesNoPrompter.java

License:Open Source License

/**
 * Prompt for the given resources using the specific condition. The prompt dialog will
 * have the title specified./*  w ww . j av  a2 s. co  m*/
 */
public MultipleYesNoPrompter(IShellProvider provider, String title, boolean hasMultiple, boolean allOrNothing) {
    this.title = title;
    this.shellProvider = provider;
    this.hasMultiple = hasMultiple;
    this.allOrNothing = allOrNothing;
    if (hasMultiple) {
        if (allOrNothing) {
            buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL };
        } else {
            buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL };
        }
    } else {
        buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
    }
}

From source file:org.eclipse.team.internal.ui.mapping.MergeAllOperation.java

License:Open Source License

public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    new ModelMergeOperation(getPart(), ((SynchronizationContext) context).getScopeManager()) {
        public boolean isPreviewRequested() {
            return false;
        }//from  w  w  w. j ava  2s.co  m

        protected void initializeContext(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask(null, 10);
            monitor.done();
        }

        protected ISynchronizationContext getContext() {
            return context;
        }

        protected void executeMerge(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask(null, 100);
            if (!hasChangesOfInterest()) {
                handleNoChanges();
            } else if (isPreviewRequested()) {
                handlePreviewRequest();
            } else {
                IStatus status = ModelMergeOperation.validateMerge(getMergeContext(),
                        Policy.subMonitorFor(monitor, 10));
                if (!status.isOK()) {
                    if (!promptToContinue(status))
                        return;
                }
                status = performMerge(Policy.subMonitorFor(monitor, 90));
                if (!status.isOK()) {
                    handleMergeFailure(status);
                }
            }
            monitor.done();
        }

        private IMergeContext getMergeContext() {
            return (IMergeContext) getContext();
        }

        private boolean promptToContinue(final IStatus status) {
            final boolean[] result = new boolean[] { false };
            Runnable runnable = new Runnable() {
                public void run() {
                    ErrorDialog dialog = new ErrorDialog(getShell(), TeamUIMessages.ModelMergeOperation_0,
                            TeamUIMessages.ModelMergeOperation_1, status,
                            IStatus.ERROR | IStatus.WARNING | IStatus.INFO) {
                        protected void createButtonsForButtonBar(Composite parent) {
                            createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
                            createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
                            createDetailsButton(parent);
                        }

                        /* (non-Javadoc)
                         * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int)
                         */
                        protected void buttonPressed(int id) {
                            if (id == IDialogConstants.YES_ID)
                                super.buttonPressed(IDialogConstants.OK_ID);
                            else if (id == IDialogConstants.NO_ID)
                                super.buttonPressed(IDialogConstants.CANCEL_ID);
                            super.buttonPressed(id);
                        }
                    };
                    int code = dialog.open();
                    result[0] = code == 0;
                }
            };
            getShell().getDisplay().syncExec(runnable);
            return (result[0]);
        }
    }.run(monitor);
}

From source file:org.eclipse.team.internal.ui.synchronize.actions.RemoveSynchronizeParticipantAction.java

License:Open Source License

private boolean promptToSave(List dirtyModels) {
    if (dirtyModels.size() == 1) {
        Saveable model = (Saveable) dirtyModels.get(0);
        String message = NLS.bind(TeamUIMessages.RemoveSynchronizeParticipantAction_2, model.getName());
        // Show a dialog.
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        MessageDialog d = new MessageDialog(view.getSite().getShell(),
                TeamUIMessages.RemoveSynchronizeParticipantAction_3, null, message, MessageDialog.QUESTION,
                buttons, 0);/*from w  w  w . jav  a  2  s  .co m*/

        int choice = d.open();

        // Branch on the user choice.
        // The choice id is based on the order of button labels
        // above.
        switch (choice) {
        case 0: // yes
            break;
        case 1: // no
            return true;
        default:
        case 2: // cancel
            return false;
        }
    } else {
        ListSelectionDialog dlg = new ListSelectionDialog(view.getSite().getShell(), dirtyModels,
                new ArrayContentProvider(), new WorkbenchPartLabelProvider(),
                TeamUIMessages.RemoveSynchronizeParticipantAction_4);
        dlg.setInitialSelections(dirtyModels.toArray());
        dlg.setTitle(TeamUIMessages.RemoveSynchronizeParticipantAction_5);

        int result = dlg.open();
        //Just return false to prevent the operation continuing
        if (result == IDialogConstants.CANCEL_ID)
            return false;

        dirtyModels = Arrays.asList(dlg.getResult());
    }

    // If the editor list is empty return.
    if (dirtyModels.isEmpty())
        return true;

    // Create save block.
    final List finalModels = dirtyModels;
    IRunnableWithProgress progressOp = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
            monitor.beginTask(null, finalModels.size());
            for (Iterator i = finalModels.iterator(); i.hasNext();) {
                Saveable model = (Saveable) i.next();
                if (model.isDirty()) {
                    try {
                        model.doSave(new SubProgressMonitor(monitor, 1));
                    } catch (CoreException e) {
                        ErrorDialog.openError(view.getSite().getShell(), null, e.getMessage(), e.getStatus());
                    }
                }
                if (monitor.isCanceled())
                    break;
            }
            monitor.done();
        }
    };
    try {
        PlatformUI.getWorkbench().getProgressService().run(true, true, progressOp);
    } catch (InvocationTargetException e) {
        Utils.handleError(view.getSite().getShell(), e, null, null);
        return false;
    } catch (InterruptedException e) {
        // Ignore
    }
    // TODO: How do we handle a cancel during save?
    return true;
}

From source file:org.eclipse.team.svn.revision.graph.operation.CheckRepositoryConnectionOperation.java

License:Open Source License

protected void runImpl(IProgressMonitor monitor) throws Exception {
    this.isServerSupportsMergeInfo = this.canIncludeMergeInfo;

    IRepositoryRoot root = this.resource.getRepositoryLocation().getRepositoryRoot();
    try {/*  w ww  .ja  v  a  2  s . co m*/
        this.lastRepositoryRevision = root.getRevision();
        this.hasConnection = this.lastRepositoryRevision != SVNRevision.INVALID_REVISION_NUMBER;
    } catch (SVNConnectorException e) {
        if (e instanceof SVNConnectorCancelException) {
            throw e;
        } else {
            this.hasConnection = false;
        }
    }

    if (!this.hasConnection) {
        final boolean[] isProceedWithoutConnection = new boolean[] { false };
        //ask if there's no connection
        UIMonitorUtility.getDisplay().syncExec(new Runnable() {
            public void run() {
                MessageDialog dlg = new MessageDialog(UIMonitorUtility.getShell(),
                        SVNRevisionGraphMessages.Dialog_GraphTitle, null,
                        SVNRevisionGraphMessages.CheckRepositoryConnectionOperation_DialogMessage,
                        MessageDialog.QUESTION,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);

                isProceedWithoutConnection[0] = dlg.open() == 0;
            }
        });

        if (!isProceedWithoutConnection[0]) {
            throw new ActivityCancelledException();
        }
    } else if (this.isValidateMergeInfo && this.canIncludeMergeInfo) {
        this.checkMergeInfo(monitor);
    }
}