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.azuretools.azureexplorer.forms.createrediscache.CreateRedisCacheForm.java

License:Open Source License

/**
 * Create contents of the button bar./*from   www. j a va 2  s  .  c o  m*/
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    btnOK = getButton(IDialogConstants.OK_ID);
    btnOK.setEnabled(false);
}

From source file:com.microsoft.azuretools.core.ui.SrvPriCreationStatusDialog.java

License:Open Source License

/**
 * Create contents of the button bar./*from w  ww . j  a  v a  2  s.  c  om*/
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button button = createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            onOk();
        }
    });
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.microsoft.azuretools.core.ui.SrvPriSettingsDialog.java

License:Open Source License

/**
 * Create contents of the button bar./* w  w w.ja  v  a2s . co m*/
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button btnOk = createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true);
    btnOk.setEnabled(true);
    btnOk.setText("Start");
    btnOk.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            onOk();
        }
    });
    Button btnCancel = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    btnCancel.setEnabled(true);
    btnCancel.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
        }
    });
}

From source file:com.microsoft.azuretools.docker.ui.dialogs.AzureExportDockerSshKeysDialog.java

License:Open Source License

/**
 * Create contents of the button bar.//from  w  w w .jav a  2s  . c o  m
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, "Save", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.microsoft.azuretools.docker.ui.dialogs.AzureInputDockerLoginCredsDialog.java

License:Open Source License

/**
 * Create contents of the button bar.//ww  w  . j  ava  2  s.  c  o m
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    okButton = createButton(parent, IDialogConstants.OK_ID, resetCredentials ? "Update" : "OK", true);
    okButton.setEnabled(false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.microsoft.tfs.client.common.ui.config.UITransportAuthRunnable.java

License:Open Source License

@Override
public final void run() {
    synchronized (lock) {
        if (complete) {
            return;
        }/*from  w  w  w .  j a va2s.  c  o  m*/
    }

    final CredentialsCompleteDialog credentialsDialog = getCredentialsDialog();

    /*
     * Subclasses may return null, indicating that they cannot handle the
     * given credentials (eg, federated credentials but we can't open a web
     * browser.)
     */
    if (credentialsDialog == null) {
        setComplete(null);
        return;
    }

    credentialsDialog.setBlockOnOpen(false);
    credentialsDialog.addCredentialsCompleteListener(new CredentialsCompleteListener() {
        @Override
        public void credentialsComplete() {
            final Credentials credentials = (credentialsDialog.getReturnCode() == IDialogConstants.OK_ID)
                    ? credentialsDialog.getCredentials()
                    : null;

            setComplete(credentials);
        }
    });

    if (credentialsDialog.open() == IDialogConstants.CANCEL_ID) {
        setComplete(null);
    }
    ;

    /*
     * Store a copy of the display, because the shell may be closed /
     * disposed (below) while processing the UI event loop. (The display
     * itself will never be disposed unless the program has exited.)
     */
    final Display display = credentialsDialog.getShell().getDisplay();

    /* Process the UI thread until the user closes the auth dialog. */
    while (!isComplete()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.UndoPendingChangesAction.java

License:Open Source License

public static void undoPendingChanges(final Shell shell, final TFSRepository repository,
        final ChangeItem[] changeItems) {

    final UndoPendingChangesDialog dialog = new UndoPendingChangesDialog(shell, changeItems);

    if (IDialogConstants.CANCEL_ID == dialog.open()) {
        return;/*from   www . jav  a 2s. c  o  m*/
    }

    PendingChange[] changesToUndo = dialog.getCheckedPendingChanges();
    changesToUndo = UndoHelper.filterChangesToUndo(changesToUndo, shell);
    if (changesToUndo == null || changesToUndo.length == 0) {
        return;
    }

    final ItemSpec[] itemSpecs = new ItemSpec[changesToUndo.length];
    for (int i = 0; i < changesToUndo.length; i++) {
        itemSpecs[i] = new ItemSpec(changesToUndo[i].getServerItem(), RecursionType.NONE);
    }

    final UndoPendingChangesTask undoTask = new UndoPendingChangesTask(shell, repository, itemSpecs);
    undoTask.run();
}

From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.actions.UndoUnchangedPendingChangesAction.java

License:Open Source License

public static void undoUnchangedChanges(final Shell shell, final TFSRepository repository,
        final ChangeItem[] changes) {
    ChangeItem[] changeItems = changes;/*from ww  w.  ja va2s. c  o  m*/

    final FindUnchangedPendingChangesCommand examinePendingChangesCommand = new FindUnchangedPendingChangesCommand(
            changeItems);

    final ICommandExecutor commandExecutor = UICommandExecutorFactory.newUICommandExecutor(shell);

    final IStatus status = commandExecutor.execute(new ResourceChangingCommand(examinePendingChangesCommand));
    if (!status.isOK()) {
        return;
    }

    changeItems = examinePendingChangesCommand.getUnchangedPendingChanges();

    if (changeItems.length == 0) {
        MessageBoxHelpers.messageBox(shell, Messages.getString("UndoUnchangedPendingChangesAction.DialogTitle"), //$NON-NLS-1$
                Messages.getString("UndoUnchangedPendingChangesAction.AllChangesModifiedSinceCheckout")); //$NON-NLS-1$
        return;
    }

    final UndoPendingChangesDialog dialog = new UndoPendingChangesDialog(shell, changeItems);

    dialog.setLabelText(
            Messages.getString("UndoUnchangedPendingChangesAction.NoneChangesModifiedSinceCheckout")); //$NON-NLS-1$

    if (IDialogConstants.CANCEL_ID == dialog.open()) {
        return;
    }

    final PendingChange[] changesToUndo = dialog.getCheckedPendingChanges();

    final ItemSpec[] itemSpecs = new ItemSpec[changesToUndo.length];
    for (int i = 0; i < changesToUndo.length; i++) {
        itemSpecs[i] = new ItemSpec(changesToUndo[i].getServerItem(), RecursionType.NONE);
    }

    final ICommand undoCommand = new ResourceChangingCommand(new UndoCommand(repository, itemSpecs));
    commandExecutor.execute(undoCommand);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.connect.ACSCredentialsDialog.java

License:Open Source License

private void checkCredentials() {
    setReturnCode(ACSConfigurationResult.SUCCESS.equals(configurationResult) ? IDialogConstants.OK_ID
            : IDialogConstants.CANCEL_ID);

    log.debug("Close the browser: " //$NON-NLS-1$
            + (getReturnCode() == IDialogConstants.OK_ID ? "FedAuth* cookies found" //$NON-NLS-1$
                    : "the user has cancelled the browser dialod")); //$NON-NLS-1$

    if (ACSConfigurationResult.FAILURE.equals(configurationResult)) {
        MessageDialog.openError(getShell(), Messages.getString("ACSCredentialsDialog.ACSFailedErrorTitle"), //$NON-NLS-1$
                Messages.getString("ACSCredentialsDialog.ACSFailedErrorMessage")); //$NON-NLS-1$
    }/*  w  w  w  .j a  va2  s.  co  m*/

    browser.stop();
    close();
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.connect.ACSCredentialsDialogD11.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    final GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;/*from  w w w . j a v a2s  .  c o  m*/
    layout.marginHeight = 0;
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing();
    dialogArea.setLayout(layout);

    browser = new FullFeaturedBrowser(dialogArea, SWT.NONE, getBrowserStyle());

    GridDataBuilder.newInstance().grab().fill().wHint((int) (getMinimumMessageAreaWidth() * 1.5))
            .hHint(getMinimumMessageAreaWidth()).applyTo(browser);

    browser.setText(loadInterstitial());

    browser.addLocationListener(new LocationListener() {
        @Override
        public void changing(final LocationEvent event) {
            locationText.setText(event.location);

            /*
             * The browser is trying to navigate to the signin completion
             * page, that means the current page is the page that posts back
             * to TFS (and thus gets cookies set.) Intercept here so that we
             * can get the cookies and configure the profile appropriately.
             *
             * On error, show a dialog but still close the page.
             */

            URI locationURI;

            try {
                locationURI = URIUtils.newURI(event.location);
            } catch (final IllegalArgumentException e) {
                log.warn(MessageFormat.format("Server redirected to an unparseable URL: {0}", event.location), //$NON-NLS-1$
                        e);
                return;
            }

            ACSConfigurationResult configurationResult = ACSConfigurationResult.CONTINUE;

            try {
                configurationResult = configureAuthenticationFromCurrentPage(locationURI);
            } catch (final Exception e) {
                log.error("Could not process ACS authentication", e); //$NON-NLS-1$
                configurationResult = ACSConfigurationResult.FAILURE;
            }

            /* Return to continue processing. */
            if (ACSConfigurationResult.CONTINUE.equals(configurationResult)) {
                return;
            }

            /* Stop the browser, close this dialog and stop processing. */
            setReturnCode(ACSConfigurationResult.SUCCESS.equals(configurationResult) ? IDialogConstants.OK_ID
                    : IDialogConstants.CANCEL_ID);
            browser.stop();
            close();

            if (ACSConfigurationResult.FAILURE.equals(configurationResult)) {
                MessageDialog.openError(getShell(),
                        Messages.getString("ACSCredentialsDialog.ACSFailedErrorTitle"), //$NON-NLS-1$
                        Messages.getString("ACSCredentialsDialog.ACSFailedErrorMessage")); //$NON-NLS-1$
            }

            event.doit = false;
            return;
        }

        @Override
        public void changed(final LocationEvent event) {
            final String message;

            log.debug("The location changed to the URL: " + event.location); //$NON-NLS-1$

            if (event.location.equalsIgnoreCase(serverSigninURL.toString())) {
                if (exception.getCredentials() != null
                        && (exception.getCredentials() instanceof CookieCredentials)) {
                    message = MessageFormat.format(
                            Messages.getString("ACSCredentialsDialog.UnauthorizedErrorMessageFormat"), //$NON-NLS-1$
                            serverURI.toString());
                } else {
                    message = Messages.getString("ACSCredentialsDialog.SignInMessage"); //$NON-NLS-1$
                }

                locationText.setText(message);
            } else {
                message = Messages.getString("ACSCredentialsDialog.DoneMessageText"); //$NON-NLS-1$
            }

            locationText.setText(message);
        }
    });

    final Composite spacerComposite = new Composite(dialogArea, SWT.NONE);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(spacerComposite);

    final GridLayout spacerLayout = new GridLayout(1, false);
    spacerLayout.marginHeight = 0;
    spacerLayout.marginTop = 0;
    spacerLayout.marginBottom = getVerticalMargin() / 2;
    spacerLayout.marginWidth = getHorizontalMargin() / 2;
    spacerComposite.setLayout(spacerLayout);

    locationText = new Text(spacerComposite, SWT.READ_ONLY);
    locationText.setText(serverSigninURL.toString());
    locationText.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(locationText);
}