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.apicloud.navigator.dialogs.CreateParamDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    setErrorMessage(null);/*from  w w w.j  ava  2 s.  c om*/
    if (buttonId == IDialogConstants.OK_ID) {
        if ("".equals(this.paramNameText.getText())) { //$NON-NLS-1$
            setErrorMessage("param\u540D\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
            return;
        }
        if ("".equals(this.paramValueText.getText())) { //$NON-NLS-1$
            setErrorMessage("param\u503C\u4E0D\u80FD\u4E3A\u7A7A"); //$NON-NLS-1$
            return;
        }
        StructuredSelection ss = (StructuredSelection) list.getSelection();
        Feature feature = (Feature) ss.getFirstElement();

        for (Param param : feature.getParams()) {
            if (param.getName().equals(this.paramNameText.getText())) {
                setErrorMessage(Messages.PARAMNAMEREPEAT); //$NON-NLS-1$
                return;
            }
        }
        Param p = new Param();
        p.setName(this.paramNameText.getText());
        p.setValue(this.paramValueText.getText());

        feature.addParams(p);
        TreeNode node = new TreeNode(p);
        node.setParent(new TreeNode(feature));
        treeViewer.setInput(config.createTreeNode());
        treeViewer.collapseAll();
        StructuredSelection selection = new StructuredSelection(node);
        treeViewer.setSelection(selection, true);
        treeViewer.refresh();
        editor.setDirty(true);
        editor.change();
    }
    super.buttonPressed(buttonId);
}

From source file:com.apicloud.navigator.dialogs.SyncApplicationDialog.java

License:Open Source License

/**
 * Create contents of the button bar./*from www.  j  a  va2s.  co m*/
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    okButton = createButton(parent, IDialogConstants.OK_ID, Messages.PackageAppItemDialog_SUCESS, true);
    okButton.setEnabled(false);
}

From source file:com.appnativa.studio.composite.BaseEditorComposite.java

License:Open Source License

public String getBackgroundColor(Shell shell, String color) {
    UIColor c = ((color == null) || (color.length() == 0)) ? null : ColorUtils.getBackgroundColor(color);
    BackgroundColorDialog d = new BackgroundColorDialog(getShell(), c);

    if (d.open() != IDialogConstants.OK_ID) {
        return null;
    }/*from w ww  .  j  av  a 2s  .co m*/

    c = d.getSelectedColor();

    if (c == null) {
        return "";
    }

    return c.toString();
}

From source file:com.appnativa.studio.composite.BaseEditorComposite.java

License:Open Source License

public String getBorder(Shell shell, String border) {
    SPOTSet borders = new SPOTSet("border", new CBorder(null, null, CBorder.standard, "standard", true), -1, -1,
            true);/*from w w w . j a va 2  s.  c  o m*/

    if ((border != null) && (border.length() > 0)) {
        try {
            iWidget context = Studio.getSelectedDocument().getContextWidget();
            Reader r;

            if (!border.startsWith("{") && !border.startsWith("borders")) {
                r = new CharArray(border.length() + 2).set('{').append(border).append('}');
            } else {
                r = new StringReader(border);
            }

            SDFNode node = SDFNode.parse(r, context.getURLResolver(), null, false);

            node = node.getFirstNode();
            borders.fromSDF(node);
        } catch (Exception e) {
            System.err.println(ApplicationException.getMessageEx(e));
        }
    }

    BordersDialog d = new BordersDialog(shell, borders);

    if (d.open() != IDialogConstants.OK_ID) {
        return null;
    }

    borders = d.getSelectedBorders();

    if (borders == null) {
        return "";
    }

    return Utilities.toString(borders);
}

From source file:com.appnativa.studio.composite.BaseEditorComposite.java

License:Open Source License

public String getIcon(Shell shell, String icon, boolean imageChooser) {
    SPOTPrintableString ps = new SPOTPrintableString();

    if ((icon != null) && (icon.length() > 0)) {
        try {//from www . jav  a  2s . co  m
            aSPOTElement.spot_populatePrimitaveElementFromString(ps, icon);
        } catch (Exception e) {
            System.err.println(ApplicationException.getMessageEx(e));
        }
    }

    IconOrImageChooserDialog d = new IconOrImageChooserDialog(getShell(), ps, imageChooser);

    if (d.open() == IDialogConstants.OK_ID) {
        return null;
    }

    ps = d.getIconElement();

    return (ps == null) ? "" : Utilities.toStringEx(ps).toString();
}

From source file:com.appnativa.studio.composite.BaseEditorComposite.java

License:Open Source License

public String getInsets(Shell shell, String insets) {
    InsetsDialog d = new InsetsDialog(getShell(), insets);

    if (d.open() == IDialogConstants.OK_ID) {
        return null;
    }/*ww  w  .j a  va 2  s  . c  o m*/

    insets = d.getSelectedInsets();

    return (insets == null) ? "" : insets;
}

From source file:com.appnativa.studio.composite.BaseEditorComposite.java

License:Open Source License

protected void editAttributes() {
    SequenceProperty sp = EditorHelper.getAttributesSequenceProperty(element, null);
    SPOTSequence seq = sp.getSequence();
    seq.spot_setLinkedData(sp);/* w  w w. j  a  v  a  2s . c om*/
    SequenceArrayEditor editor = new SequenceArrayEditor(getShell(), seq, null, false);
    int ret = editor.open();
    if (ret == IDialogConstants.OK_ID) {
        element.spot_cleanAttributes();
        int len = seq.spot_getCount();
        for (int i = 0; i < len; i++) {
            iSPOTElement e = seq.spot_elementAt(i);
            String name = e.spot_getName();
            String value = e.spot_stringValue();
            if (value != null && value.length() == 0) {
                value = null;
            }
            if (value != null) {
                element.spot_setAttribute(name, value);
            }
        }
        notifyPropertyChangeListener(element);
    }
}

From source file:com.appnativa.studio.composite.FontFieldComposite.java

License:Open Source License

protected void showDialog() {
    FontChooserDialog d = new FontChooserDialog(getShell());

    d.setFont(baseFont, (Font) rareFont.clone());

    int ret = d.open();

    switch (ret) {
    case IDialogConstants.OK_ID:
        Font f = d.getSelectedFont();

        if (f != null) {
            rareFont = f;/*w  w  w.j  a  v a  2  s.  co m*/
            updateField(true);
        }

        break;

    case IDialogConstants.CLIENT_ID:
        rareFont.spot_clear();
        updateField(true);

        break;

    default:
        break;
    }
}

From source file:com.appnativa.studio.composite.SequenceArrayEditorComposite.java

License:Open Source License

protected void showsequenceEditor(boolean addNew) {
    final SequenceArrayEditor se = new SequenceArrayEditor(getShell(), element, null, false);

    if (addNew) {
        Display.getDefault().asyncExec(new Runnable() {
            @Override//  w  ww.  j  ava  2 s.co  m
            public void run() {
                se.addElement();
            }
        });
    }

    int ret = se.open();

    if ((ret == IDialogConstants.OK_ID) || (ret == IDialogConstants.CLIENT_ID)) {
        this.element = se.getSPOTElement();
        textWidget.setText(element.toString());

        int y = textWidget.getSize().y;

        if (y != calculatePreferredTextHeight()) {
            this.getParent().getParent().layout();
        }

        if (propertyChangeListener != null) {
            notifyPropertyChangeListener(element);
        }
    }
}

From source file:com.appnativa.studio.dialogs.BackgroundColorDialog.java

License:Open Source License

/**
 * Create contents of the button bar./*from  w  w w.j a v  a  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);
}