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

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

Introduction

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

Prototype

int OK_ID

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

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.amalto.workbench.dialogs.BusinessElementInputDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // Should not really be here but well,....
    parent.getShell().setText(this.title);

    Composite composite = (Composite) super.createDialogArea(parent);

    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 2;/*ww  w  .ja v a  2 s  .c o m*/
    // layout.verticalSpacing = 10;

    Label nameLabel = new Label(composite, SWT.NONE);
    nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    nameLabel.setText(Messages.BusinessElementInputDialog_NameText);

    elementNameText = new Text(composite, SWT.BORDER);
    elementNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    elementNameText.setText(getElementName() == null ? "" : getElementName());//$NON-NLS-1$
    ((GridData) elementNameText.getLayoutData()).widthHint = 200;
    // elementNameText.setSize(100, 22);

    Label refLabel = new Label(composite, SWT.NONE);
    refLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    refLabel.setText(Messages.BusinessElementInputDialog_RefText);

    refCombo = new Combo(composite, SWT.DROP_DOWN | SWT.SIMPLE | SWT.READ_ONLY);
    refCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    refCombo.setItems(elementDeclarations.toArray(new String[elementDeclarations.size()]));
    refCombo.setText(getRefName() == null ? "" : getRefName());//$NON-NLS-1$
    ((GridData) refCombo.getLayoutData()).widthHint = 200;

    if (refCombo.getText().length() > 0) {
        elementNameText.setText("");//$NON-NLS-1$
        elementNameText.setEditable(false);
    } else {
        elementNameText.setEditable(true);
        elementNameText.setText(getElementName() == null ? "" : getElementName());//$NON-NLS-1$
    }

    refCombo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {

        }

        public void widgetSelected(SelectionEvent e) {
            if (refCombo.getText().length() > 0) {
                elementNameText.setText("");//$NON-NLS-1$
                elementNameText.setEditable(false);
            } else {
                elementNameText.setEditable(true);
                elementNameText.setText(getElementName() == null ? "" : getElementName());//$NON-NLS-1$
            }

        }
    });

    Label minLabel = new Label(composite, SWT.NONE);
    minLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    minLabel.setText(Messages.BusinessElementInputDialog_MinText);

    minOccursText = new Text(composite, SWT.NONE);
    minOccursText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    minOccursText.setDoubleClickEnabled(false);
    minOccursText.setText("" + getMinOccurs());//$NON-NLS-1$

    Label maxLabel = new Label(composite, SWT.NONE);
    maxLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    maxLabel.setText(Messages.BusinessElementInputDialog_MaxText);

    maxOccursText = new Text(composite, SWT.NONE);
    maxOccursText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    maxOccursText.setText(getMaxOccurs() == -1 ? "" : "" + getMaxOccurs());//$NON-NLS-1$//$NON-NLS-2$

    if (isNew && exAdapter != null) {
        exAdapter.crateDialogArea(composite);
    }
    // check pk can't edit Maximum/Minimum
    minOccursText.setEditable(!isPK);
    maxOccursText.setEditable(!isPK);
    refCombo.setEnabled(!isPK);

    msgLabel = new Label(composite, SWT.NONE);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(msgLabel);
    msgLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));

    elementNameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String text = elementNameText.getText().trim();
            boolean isValid = XSDUtil.isValidatedXSDName(text);
            isValid = isValid || !refCombo.getText().trim().isEmpty();
            msgLabel.setText(isValid ? "" : Messages.InvalidName_Message); //$NON-NLS-1$
            msgLabel.getParent().layout();
            getButton(IDialogConstants.OK_ID).setEnabled(isValid);
        }
    });
    return composite;
}

From source file:com.amalto.workbench.dialogs.BusinessElementInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).addSelectionListener(this.caller);
    /*/*from  w  ww . ja v  a  2s  . co m*/
     * createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent,
     * IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
     */
}

From source file:com.amalto.workbench.dialogs.ComplexTypeInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).addSelectionListener(this.caller);
}

From source file:com.amalto.workbench.dialogs.ComplexTypeInputDialog.java

License:Open Source License

public void modifyText(ModifyEvent e) {
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    conceptPanel.setMessage("");//$NON-NLS-1$

    String type = conceptPanel.getText();

    if (Pattern.compile("^\\s+\\w+\\s*").matcher(type).matches()//$NON-NLS-1$
            || type.trim().replaceAll("\\s", "").length() != type.trim().length()) {//$NON-NLS-1$//$NON-NLS-2$
        conceptPanel.setMessage(Messages._NameWithEmptyCharacters);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;/*from www . java2 s .c  o  m*/
    }
    type = type.trim();
    if (!XSDUtil.isValidatedXSDName(type)) {
        conceptPanel.setMessage(Messages.InvalidName_Message);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }

    for (XSDTypeDefinition specType : xsdSchema.getTypeDefinitions()) {
        String typeToCompare = specType.getName();
        int delimiter = type.indexOf(" : ");//$NON-NLS-1$
        if (delimiter != -1) {
            type = type.substring(0, delimiter);
        }
        if (typeToCompare.equals(type)) {
            if (caller instanceof XSDNewComplexTypeDefinition) {
                conceptPanel.setMessage(Messages._SameTypeNameExists);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            } else if (caller instanceof XSDChangeToComplexTypeAction
                    && specType instanceof XSDSimpleTypeDefinition) {
                conceptPanel.setMessage(Messages._SameTypeNameExists);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
            break;
        }
    }
}

From source file:com.amalto.workbench.dialogs.datacontainer.UpdateAutoIncrementDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    resetBtn = createButton(parent, resetBtnId, Messages.UpdateAutoIncrementDialog_Reset, false);
    resetBtn.setEnabled(false);//from ww  w . j av a 2s . c o  m
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(resetBtn);

    Button resetAllBtn = createButton(parent, resetAllBtnId, Messages.UpdateAutoIncrementDialog_resetAll,
            false);
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(resetAllBtn);

    Composite rightArea = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(0).equalWidth(true).applyTo(rightArea);
    GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).grab(true, false).applyTo(rightArea);

    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:com.amalto.workbench.dialogs.DataModelFilterDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(composite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    return composite;
}

From source file:com.amalto.workbench.dialogs.DataModelSelectDialog.java

License:Open Source License

private void changeToResource() {
    TreeParent parent = null;/* ww  w . j  a  v  a  2s .  com*/
    // Modified by hbhong,to fix bug 21784
    TreeObject[] children = treeParent.getChildren();
    for (TreeObject element : children) {
        parent = (TreeParent) element;
        if (parent.getType() == TreeObject.DATA_MODEL) {
            break;
        }
    }
    // The ending| bug:21784
    contentProvider = new ServerTreeContentProvider(site, parent);
    setTreeContentProvider(contentProvider);
    domViewer.setLabelProvider(new ServerTreeLabelProvider());
    domViewer.setSorter(new ViewerSorter() {

        @Override
        public int category(Object element) {
            if (element instanceof TreeParent) {
                TreeParent category = (TreeParent) element;
                if (category.getType() == TreeObject.CATEGORY_FOLDER) {
                    return -1;
                }
            }
            return 0;
        }
    });

    domViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent e) {
            StructuredSelection sel = (StructuredSelection) e.getSelection();

            List<String> xpathList = new ArrayList<String>();
            Object[] selections = sel.toArray();
            for (Object obj : selections) {
                TreeObject treeObj = (TreeObject) obj;
                if (treeObj != null && treeObj.getType() == TreeObject.DATA_MODEL) {
                    xpathList.add(treeObj.getDisplayName());
                }
            }

            xpaths = xpathList.toArray(new String[0]);

            if (getButton(IDialogConstants.OK_ID) != null) {
                getButton(IDialogConstants.OK_ID).setEnabled(xpathList.size() > 0);
            }
        }
    });

    domViewer.setInput(site);
}

From source file:com.amalto.workbench.dialogs.DataModelSelectDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Control btnBar = super.createButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setText(Messages.DataModelSelectDialog_Ok);
    return btnBar;
}

From source file:com.amalto.workbench.dialogs.ErrorExceptionDialog.java

License:Open Source License

protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1) // this is incremented
            // by createButton
            .equalWidth(true).applyTo(composite);

    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).span(2, 1).applyTo(composite);
    composite.setFont(parent.getFont());
    createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    return composite;
}

From source file:com.amalto.workbench.dialogs.FacetsListInputDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    getButton(IDialogConstants.OK_ID).addSelectionListener(this.caller);

}