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

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

Introduction

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

Prototype

int CANCEL_ID

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

Click Source Link

Document

Button id for a "Cancel" button (value 1).

Usage

From source file:com.microsoft.tfs.client.common.ui.dialogs.generic.MacMountBusyDialog.java

License:Open Source License

public MacMountBusyDialog(final Shell parent, final String serverName) {
    super(parent);

    setOptionResizable(false);/*from w w  w  .  j  a v  a2  s. com*/
    setOptionPersistGeometry(false);
    setOptionIncludeDefaultButtons(false);
    setReturnCode(IDialogConstants.CANCEL_ID);

    this.serverName = serverName;
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ApplyLabelDialog.java

License:Open Source License

private void createCancelButton(final Composite parent) {
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.BranchBranchDialog.java

License:Open Source License

public BranchBranchDialog(final Shell parentShell, final TFSRepository repository, final String branchFromPath,
        String proposedBranchToPath) {
    super(parentShell);
    Check.notNull(repository, "repository"); //$NON-NLS-1$
    Check.notNull(branchFromPath, "branchFromPath"); //$NON-NLS-1$

    this.repository = repository;
    this.branchFromPath = branchFromPath;

    if (proposedBranchToPath == null) {
        proposedBranchToPath = ""; //$NON-NLS-1$
    }/*www  .j  a  v  a2  s.c o m*/

    branchToPath = proposedBranchToPath;
    setOptionIncludeDefaultButtons(false);
    addButtonDescription(IDialogConstants.OK_ID, Messages.getString("BranchBranchDialog.BranchButtonText"), //$NON-NLS-1$
            true);
    addButtonDescription(IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ConflictDialog.java

License:Open Source License

@Override
protected void hookAfterButtonsCreated() {
    getButton(IDialogConstants.CANCEL_ID).setText(Messages.getString("ConflictDialog.CloseButtonTExt")); //$NON-NLS-1$
    getButton(IDialogConstants.OK_ID).setText(Messages.getString("ConflictDialog.ResolveButtonText")); //$NON-NLS-1$

    refreshLabels();// w  ww .  ja va  2  s  .  c  o m
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ConflictDialog.java

License:Open Source License

@Override
protected void buttonPressed(final int buttonId) {
    // TODO; should this really be *auto merge all*? this seems non-
    // intuitive with the selection? maybe it should be "auto merge
    // selected" unless there's none selected, in which case it should
    // be "auto merge all"?
    if (buttonId == AUTOMERGE) {
        automergeAll();/*from w w  w. jav a 2 s .  c o m*/
    } else if (buttonId == IDialogConstants.OK_ID) {
        resolveSelection();
    } else if (buttonId == IDialogConstants.CANCEL_ID && cancelResolution()) {
        super.cancelPressed();

        /* Refresh pending changes */
        final RefreshPendingChangesCommand pendingChangesCommand = new RefreshPendingChangesCommand(repository);
        UICommandExecutorFactory.newUICommandExecutor(parentShell).execute(pendingChangesCommand);
    }
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ConvertFolderToBranchDialog.java

License:Open Source License

public ConvertFolderToBranchDialog(final Shell parentShell, final TFSItem item, final String user,
        final TFSRepository repository) {
    super(parentShell);
    this.item = item;
    this.user = user;
    setOptionIncludeDefaultButtons(false);
    addButtonDescription(IDialogConstants.OK_ID,
            Messages.getString("ConvertFolderToBranchDialog.ConvertButtonText"), //$NON-NLS-1$
            true);//  w w w .  j a  va2  s .  c  o  m
    addButtonDescription(IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.DetectLocalChangesDialog.java

License:Open Source License

/**
 * Override to set text on OK button. Simply setting the text,
 * unfortunately, does not size the button properly on OS X.
 *//*from   ww w  . j av  a2s  .  c  o m*/
@Override
protected void createButtonsForButtonBar(final Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, Messages.getString("ReturnOnlineDialog.PendChangesButtonText"), //$NON-NLS-1$
            true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.EditLabelDialog.java

License:Open Source License

@Override
protected void okPressed() {
    if (!labelModified) {
        editLabelResults = new EditLabelResults(null, null, null);
        setReturnCode(IDialogConstants.CANCEL_ID);
        close();/*w w w.  j a v a 2s. com*/
        return;
    }

    if (initialLabel == null) {
        final String labelName = nameText.getText().trim();

        if (labelName.length() == 0) {
            final String title = Messages.getString("EditLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$
            final String message = Messages.getString("EditLabelDialog.InvalidNameDialogText"); //$NON-NLS-1$

            MessageDialog.openError(getShell(), title, message);
            return;
        }

        if (labelName.length() >= ApplyLabelDialog.NAME_MAX_LENGTH) {
            final String title = Messages.getString("EditLabelDialog.NametooLongDialogTitle"); //$NON-NLS-1$
            final String messageFormat = Messages.getString("EditLabelDialog.NameTooLongFormat"); //$NON-NLS-1$
            final String message = MessageFormat.format(messageFormat, (ApplyLabelDialog.NAME_MAX_LENGTH + 1));

            MessageDialog.openError(getShell(), title, message);
            return;
        }

        for (int i = 0; i < ApplyLabelDialog.INVALID_NAME_CHARS.length; i++) {
            if (labelName.indexOf(ApplyLabelDialog.INVALID_NAME_CHARS[i]) >= 0) {
                final String title = Messages.getString("EditLabelDialog.InvalidNameDialogTitle"); //$NON-NLS-1$
                final String messageFormat = Messages.getString("EditLabelDialog.InvalidCharInLabelFormat"); //$NON-NLS-1$
                final String message = MessageFormat.format(messageFormat,
                        ApplyLabelDialog.INVALID_NAME_CHARS[i]);

                MessageDialog.openError(getShell(), title, message);
                return;
            }
        }
    }

    if (commentText.getText().trim().length() > ApplyLabelDialog.COMMENT_MAX_LENGTH) {
        final String title = Messages.getString("EditLabelDialog.CommentTooLongDialogTitle"); //$NON-NLS-1$
        final String messageFormat = Messages.getString("EditLabelDialog.CommentTooLongFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, ApplyLabelDialog.COMMENT_MAX_LENGTH);

        MessageDialog.openError(getShell(), title, message);
        return;
    }

    getButton(BUTTON_ADD_ID).setEnabled(false);
    getButton(BUTTON_REMOVE_ID).setEnabled(false);
    nameText.setEnabled(false);
    commentText.setEnabled(false);
    labelItemsTable.setEnabled(false);
    getButton(IDialogConstants.OK_ID).setEnabled(false);

    final IProgressMonitor progressMonitor = progressMonitorControl.getProgressMonitor();
    progressMonitor.beginTask(Messages.getString("EditLabelDialog.ProgressAnalyzingLabel"), //$NON-NLS-1$
            IProgressMonitor.UNKNOWN);

    new Thread(new Runnable() {
        @Override
        public void run() {
            final boolean isDelete;
            final ItemSpec[] deletes;
            final LabelItemSpec[] adds;

            synchronized (labelContentsTree) {
                final LabelContentsTreeDelta delta = labelContentsTree.getDelta();

                isDelete = (initialLabel != null && delta.getExistsCount() == 0 && delta.getAdds().length == 0);
                deletes = delta.getDeletes();
                adds = delta.getAdds();
            }

            final Shell shell = getShell();

            if (shell == null) {
                return;
            }

            shell.getDisplay().syncExec(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (isDelete && !MessageDialog.openQuestion(getShell(),
                                Messages.getString("EditLabelDialog.RemoveLabelDialogTitle"), //$NON-NLS-1$
                                Messages.getString("EditLabelDialog.RemoveLabelDialogText"))) //$NON-NLS-1$
                        {
                            progressMonitor.done();

                            nameText.setEnabled(initialLabel == null);
                            commentText.setEnabled(true);
                            labelItemsTable.setEnabled(true);
                            getButton(BUTTON_ADD_ID).setEnabled(true);
                            getButton(BUTTON_REMOVE_ID).setEnabled(!labelItemsTable.getSelection().isEmpty());
                            getButton(IDialogConstants.OK_ID).setEnabled(nameText.getText().length() > 0);

                            return;
                        }

                        VersionControlLabel newLabel;

                        if (isDelete) {
                            newLabel = null;
                        } else {
                            final String name = initialLabel != null ? initialLabel.getName()
                                    : nameText.getText().trim();
                            final String owner = initialLabel != null ? initialLabel.getOwner()
                                    : VersionControlConstants.AUTHENTICATED_USER;
                            final String ownerDisplayName = initialLabel != null
                                    ? initialLabel.getOwnerDisplayName()
                                    : null;
                            final String scope = initialLabel != null ? initialLabel.getScope() : null;
                            final String comment = commentText.getText().trim();

                            newLabel = new VersionControlLabel(name, owner, ownerDisplayName, scope, comment);
                        }

                        editLabelResults = new EditLabelResults(newLabel, deletes, adds);

                        EditLabelDialog.super.okPressed();
                    } catch (final Throwable e) {
                        progressMonitor.done();

                        MessageDialog.openError(getShell(),
                                Messages.getString("EditLabelDialog.LabelErrorDialogTitle"), //$NON-NLS-1$
                                e.getMessage());

                        nameText.setEnabled(initialLabel == null);
                        commentText.setEnabled(true);
                        labelItemsTable.setEnabled(true);
                        getButton(BUTTON_ADD_ID).setEnabled(true);
                        getButton(BUTTON_REMOVE_ID).setEnabled(!labelItemsTable.getSelection().isEmpty());
                        getButton(IDialogConstants.OK_ID).setEnabled(nameText.getText().length() > 0);

                        return;
                    }
                }
            });
        }
    }).start();
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.FindChangesetDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(final Composite parent) {
    if (closeOnlyMode) {
        addButtonDescription(IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true);
    } else {//from w  w  w .ja v  a 2  s.c o m
        addButtonDescription(IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
        addButtonDescription(IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    }

    super.createButtonsForButtonBar(parent);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.GatedCheckinDialog.java

License:Open Source License

/**
 * This dialog warns the user of a denied check-in due to changes that
 * affect a build definition marked as a gated check-in. The user chooses
 * the target build definition (if there are multiple) and chooses to
 * re-issue the check-in operation after successfully building the chagnes.
 * An option to override the gated check-in is offered if the user has
 * permissions./*  w w  w .  jav  a2  s.c o  m*/
 *
 * @param parentShell
 *        The parent for this dialog.
 * @param shelvesetName
 *        The shelveset name created by the server for the denied check-in.
 * @param buildDefinitionNames
 *        The build definition names that are affected by the attempted
 *        check-in.
 * @param buildDefinitionUris
 *        The build uris that are affected by the attempted check-in.
 * @param allowBypassBuild
 *        True if the user is allowed to override the gated check-in.
 * @param allowKeepCheckedOut
 *        <code>true</code> if the user is allowed to keep the files checked
 *        out.
 */
public GatedCheckinDialog(final Shell parentShell, final String shelvesetName,
        final String[] buildDefinitionNames, final String[] buildDefinitionUris, final boolean allowBypassBuild,
        final boolean allowKeepCheckedOut) {
    super(parentShell);

    Check.notNull(shelvesetName, "shelvesetName"); //$NON-NLS-1$
    Check.notNull(buildDefinitionNames, "buildDefinitions"); //$NON-NLS-1$

    this.shelvesetName = shelvesetName;
    this.buildDefinitionNames = buildDefinitionNames;
    this.buildDefinitionUris = buildDefinitionUris;
    this.allowBypassBuild = allowBypassBuild;
    this.allowKeepCheckedOut = allowKeepCheckedOut;

    final ImageHelper imageHelper = new ImageHelper(TFSCommonUIClientPlugin.PLUGIN_ID);
    image = imageHelper.getImage("images/vc/gated.gif"); //$NON-NLS-1$ );

    setOptionIncludeDefaultButtons(false);
    addButtonDescription(IDialogConstants.OK_ID,
            Messages.getString("GatedCheckinDialog.BuildChangesButtonText"), //$NON-NLS-1$
            true);
    addButtonDescription(IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}