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.laex.cg2d.screeneditor.handlers.EditShapeIDDialog.java

License:Open Source License

/**
 * Create contents of the button bar.//  w w w  .j av  a 2  s  . com
 * 
 * @param parent
 *          the 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);

    getButton(OK).setEnabled(false);
}

From source file:com.laex.cg2d.screeneditor.handlers.ImportScreenContentsDialog.java

License:Open Source License

/**
 * Create contents of the button bar.// w w w  . j a  v a2 s  . c  om
 * 
 * @param parent
 *          the parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    validateAll();
}

From source file:com.laex.cg2d.screeneditor.views.AddLayerDialog.java

License:Open Source License

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

From source file:com.linghushaoxia.et.translate.view.QueryDialog.java

License:Apache License

@Override
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    if (id == IDialogConstants.CANCEL_ID || id == IDialogConstants.OK_ID) {
        return null;
    }/*from  ww w.  ja v  a  2s. co m*/
    return super.createButton(parent, id, label, defaultButton);
}

From source file:com.maccasoft.composer.InstrumentEditor.java

License:Open Source License

protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout();
    layout.numColumns = 0;// w  ww. j a v a2  s  .  co  m
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    layout.marginTop = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Button button = createButton(composite, -1, "Get Spin Data");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuilder sb = new StringBuilder();
            sb.append("DAT\n\n");

            sb.append(name.getText().replace(' ', '_'));
            sb.append("\n");

            for (Command cmd : list) {
                if (!cmd.isDisabled()) {
                    sb.append("    " + cmd.toSpinString() + "\n");
                }
            }

            TextDialog dlg = new TextDialog(getShell());
            dlg.setString(sb.toString());
            dlg.open();
        }
    });

    button = createButton(composite, -1, "Get C Data");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("uint32_t %s[] = {\n", name.getText().replace(' ', '_')));

            for (Command cmd : list) {
                if (!cmd.isDisabled()) {
                    sb.append("    " + cmd.toCString() + ",\n");
                }
            }

            sb.append("};\n");

            TextDialog dlg = new TextDialog(getShell());
            dlg.setString(sb.toString());
            dlg.open();
        }
    });

    Label label = new Label(composite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    layout.numColumns++;

    button = createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            okPressed();
            setReturnCode(OK);
            close();
        }
    });
    getShell().setDefaultButton(button);

    button = createButton(composite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });

    return composite;
}

From source file:com.mentor.nucleus.bp.core.ui.dialogs.ScrolledTextDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    if (optionalText != null) {
        ((GridLayout) parent.getLayout()).numColumns++;
        optionalButton = new Button(parent, SWT.CHECK);
        optionalButton.setText(optionalText);
        optionalButton.setFont(JFaceResources.getDialogFont());
        optionalButton.setSelection(false);
        setButtonLayoutData(optionalButton);
    }//from   ww  w.  jav  a  2s . c o  m
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    if (allowCancel) {
        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    }
}

From source file:com.mentor.nucleus.bp.model.compare.contentmergeviewer.SynchronizedTreeViewer.java

License:Open Source License

protected Object handleOpen() {
    if (mergeViewer.getAncestorTree() == this) {
        return null;
    }//from   ww w . j a v a  2 s .co m
    IStructuredSelection sel = (IStructuredSelection) getSelection();
    if (sel.isEmpty()) {
        return null;
    }
    Object current = sel.iterator().next();
    // if the current selection has an Action_Semantics field
    // the grab the necessary object element to open that, failing
    // that look for a description attribute
    if (current instanceof NonRootModelElementComparable) {
        NonRootModelElement nrme = (NonRootModelElement) ((NonRootModelElementComparable) current)
                .getRealElement();
        if (nrme instanceof StateMachineState_c || nrme instanceof Transition_c) {
            // we need to navigate to the Action element
            // for the activity and description attributes
            Object[] children = ((ITreeContentProvider) getContentProvider()).getChildren(current);
            for (Object child : children) {
                if (child instanceof NonRootModelElementComparable) {
                    current = child;
                    break;
                }
            }
        }
        ObjectElement actionObjEle = null;
        ObjectElement descripObjEle = null;
        Object[] children = ((ITreeContentProvider) getContentProvider()).getChildren(current);
        for (Object child : children) {
            if (child instanceof ObjectElementComparable) {
                ObjectElementComparable comparable = (ObjectElementComparable) child;
                ObjectElement objElement = (ObjectElement) comparable.getRealElement();
                if (objElement.getName().equals("Action_Semantics")) {
                    actionObjEle = objElement;
                } else {
                    if (objElement.getName().equals("Descrip")) {
                        descripObjEle = objElement;
                    }
                }
            }
        }
        if (actionObjEle != null) {
            current = ComparableProvider.getComparableTreeObject(actionObjEle);
        } else {
            if (descripObjEle != null) {
                current = ComparableProvider.getComparableTreeObject(descripObjEle);
            }
        }
    }
    if (current instanceof ObjectElementComparable) {
        ObjectElementComparable comparable = (ObjectElementComparable) current;
        ObjectElement objElement = (ObjectElement) comparable.getRealElement();
        if (objElement.getName().equals("Descrip") || objElement.getName().equals("Action_Semantics")) {
            Object leftInput = getMergeViewer().getLeftViewer().getInput();
            Object rightInput = getMergeViewer().getRightViewer().getInput();
            TreeItem rightMatch = getMatchingItem(comparable, synchronizedViewers.get(0));
            TreeItem ancestorMatch = null;
            if (synchronizedViewers.size() == 2) {
                ancestorMatch = getMatchingItem(comparable, synchronizedViewers.get(1));
            }
            Object leftElement = comparable.getRealElement();
            Object rightElement = null;
            Object ancestor = null;
            if (ancestorMatch != null) {
                ancestor = ((ComparableTreeObject) ancestorMatch.getData()).getRealElement();
            }
            if (rightMatch != null) {
                rightElement = ((ComparableTreeObject) rightMatch.getData()).getRealElement();
            }
            if (mergeViewer.getLeftViewer() != this) {
                if (rightMatch == null) {
                    leftElement = null;
                } else {
                    leftElement = rightMatch.getData();
                    leftElement = ((ComparableTreeObject) leftElement).getRealElement();
                }
                rightElement = comparable.getRealElement();
            }
            // create a compare dialog, using the text compare
            final CompareConfiguration compareConfiguration = new CompareConfiguration();
            boolean leftEditable = leftInput instanceof IEditableContent
                    && ((IEditableContent) leftInput).isEditable();
            boolean rightEditable = rightInput instanceof IEditableContent
                    && ((IEditableContent) rightInput).isEditable();
            // if this is a single file compare, do not allow editing
            // at this time as there is no easy way to place the content
            // changes back into the file
            if (ComparePlugin.getDefault().getModelCacheManager()
                    .isInputReadonly(ModelCacheManager.getLeftKey(mergeViewer.getInput()))) {
                compareConfiguration.setLeftEditable(false);
                compareConfiguration.setRightEditable(false);
            } else {
                compareConfiguration.setLeftEditable(leftEditable);
                compareConfiguration.setRightEditable(rightEditable);
            }
            final TextualAttributeCompareEditorInput compareInput = new TextualAttributeCompareEditorInput(
                    compareConfiguration, (ObjectElement) leftElement, (ObjectElement) rightElement,
                    (ObjectElement) ancestor, SynchronizedTreeViewer.this);
            if (CompareUIPlugin.getDefault().compareResultOK(compareInput, null)) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        CompareDialog dialog = new CompareDialog(
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), compareInput) {

                            @Override
                            protected Button createButton(Composite parent, int id, String label,
                                    boolean defaultButton) {
                                if (id == IDialogConstants.CANCEL_ID) {
                                    return null;
                                } else {
                                    return super.createButton(parent, id, label, defaultButton);
                                }
                            }

                        };
                        dialog.open();
                    }
                };
                if (Display.getCurrent() == null) {
                    Display.getDefault().syncExec(runnable);
                } else {
                    runnable.run();
                }
            }
            return null;
        }
    }

    return null;

}

From source file:com.microsoft.applicationinsights.preference.ApplicationInsightsDetailsDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Control ctrl = super.createButtonBar(parent);
    Button okButton = getButton(IDialogConstants.OK_ID);
    okButton.setVisible(false);/*from  www . j  a v a  2s. c om*/

    Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
    cancelButton.setText("Close");
    return ctrl;
}

From source file:com.microsoft.azureexplorer.forms.CreateStorageAccountForm.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    GridData gridData = new GridData();
    gridData.verticalAlignment = SWT.FILL;
    gridData.horizontalAlignment = SWT.FILL;
    parent.setLayoutData(gridData);//w  w w.ja v a  2 s  . co m
    Control ctrl = super.createButtonBar(parent);
    buttonOK = getButton(IDialogConstants.OK_ID);
    buttonOK.setEnabled(false);
    buttonOK.setText("Create");
    buttonCancel = getButton(IDialogConstants.CANCEL_ID);
    buttonCancel.setText("Close");
    return ctrl;
}

From source file:com.microsoft.azureexplorer.forms.ViewMessageForm.java

License:Open Source License

@Override
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    if (id == IDialogConstants.CANCEL_ID) {
        return null;
    }//w  w  w.  ja v a  2s .co m
    return super.createButton(parent, id, label, defaultButton);
}