Search in sources :

Example 11 with InputDialog

use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.

the class CreateAttributeAction method run.

@Override
public void run() {
    TreeNode treeNode = null;
    if (input) {
        treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
    } else {
        treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
    }
    // IInputValidator validataor = new IInputValidator() {
    //
    // public String isValid(String newText) {
    // String xpath = XmlMapUtil.getXPath(parent.getXpath(), newText, NodeType.ATTRIBUT);
    // EList<TreeNode> children = parent.getChildren();
    // boolean exist = false;
    // for (TreeNode child : children) {
    // if (child.getXpath() != null && child.getXpath().equals(xpath)) {
    // exist = true;
    // break;
    // }
    // }
    //
    // if (exist) {
    // return "Atribute '" + newText + "' already exist !";
    // } else {
    // return null;
    // }
    // }
    //
    // };
    String label = "";
    InputDialog dialog = new InputDialog(null, "Create New Attribute", "Input the new attribute's valid label", "", null);
    int open = -1;
    while (!StringUtil.validateLabelForXML(label)) {
        open = dialog.open();
        if (open == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (open == InputDialog.CANCEL) {
            return;
        }
    }
    if (open == Window.OK) {
        treeNode.setName(label);
        treeNode.setNodeType(NodeType.ATTRIBUT);
        String parentXpath = parent.getXpath();
        if (parent.isChoice() || parent.isSubstitution()) {
            TreeNode realPrant = XmlMapUtil.getRealParentNode(parent);
            if (realPrant != null) {
                parentXpath = realPrant.getXpath();
            }
        }
        treeNode.setXpath(XmlMapUtil.getXPath(parentXpath, treeNode.getName(), treeNode.getNodeType()));
        treeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
        final EList<TreeNode> children = parent.getChildren();
        int index = 0;
        for (int i = 0; i < children.size(); i++) {
            final TreeNode child = children.get(i);
            if (child.getNodeType() == NodeType.NAME_SPACE || child.getNodeType() == NodeType.ATTRIBUT) {
                if (i == children.size() - 1) {
                    index = children.size();
                }
                continue;
            } else {
                index = i;
                break;
            }
        }
        children.add(index, treeNode);
    }
    if (open == Window.OK && mapperManager != null) {
        // if (input) {
        // mapperManager.inputTreeSchemaBeanListModified();
        // } else {
        // mapperManager.outputTreeSchemaBeanListModified();
        // }
        Object object = graphicViewer.getEditPartRegistry().get(treeNode);
        if (object instanceof TreeNodeEditPart) {
            graphicViewer.select((TreeNodeEditPart) object);
        }
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart)

Example 12 with InputDialog

use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.

the class HL7FixValueAction method setFixValue.

private void setFixValue(HL7TreeNode node) {
    //$NON-NLS-1$
    String label = null;
    while (!StringUtil.validateLabelForFixedValue(label)) {
        InputDialog dialog = new InputDialog(null, "Input a fix value", "Input the default value' valid label", "", null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
            if (label != null && label.length() == 0) {
                break;
            }
        }
        if (status == InputDialog.CANCEL) {
            return;
        }
    }
    node.setDefaultValue(label);
    this.xmlViewer.refresh();
    xmlViewer.expandAll();
    if (hl7ui != null) {
        hl7ui.redrawLinkers();
    } else if (form != null) {
        form.refreshLinks();
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog)

Example 13 with InputDialog

use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.

the class FixValueAction method setFixValue.

private void setFixValue(FOXTreeNode node) {
    String label = null;
    while (!StringUtil.validateLabelForFixedValue(label)) {
        InputDialog dialog = new InputDialog(null, "Input a fix value", "Input the default value' valid label", "", null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
            if (label != null && label.length() == 0) {
                break;
            }
        }
        if (status == InputDialog.CANCEL) {
            return;
        }
    }
    node.setDefaultValue(label);
    this.jsonViewer.refresh();
    jsonViewer.expandAll();
    form.redrawLinkers();
    form.updateConnection();
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog)

Example 14 with InputDialog

use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.

the class CreateJSONAttributeAction method createChildNode.

private void createChildNode(FOXTreeNode node) {
    String label = "";
    while (!JSONUtil.validateLabelForJSON(label)) {
        InputDialog dialog = new InputDialog(null, "Input attribute's label", "Input the new attribute's valid label", "", null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (status == InputDialog.CANCEL) {
            return;
        }
    }
    FOXTreeNode child = new Attribute(label);
    // child.setRow(node.getRow());
    node.addChild(child);
    this.jsonViewer.refresh();
    jsonViewer.expandAll();
    form.redrawLinkers();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) InputDialog(org.eclipse.jface.dialogs.InputDialog) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute)

Example 15 with InputDialog

use of org.eclipse.jface.dialogs.InputDialog in project tdi-studio-se by Talend.

the class ConnectionCreateAction method askForConnectionName.

private String askForConnectionName(String nodeLabel, String oldName) {
    final Node node = (Node) nodePart.getModel();
    InputDialog id = new InputDialog(getWorkbenchPart().getSite().getShell(), nodeLabel + //$NON-NLS-1$
    Messages.getString("ConnectionCreateAction.dialogTitle"), Messages.getString("ConnectionCreateAction.dialogMessage"), oldName, new //$NON-NLS-1$
    IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText != null) {
                if (!node.getProcess().checkValidConnectionName(newText, isListenerAttached()) || KeywordsValidator.isKeyword(newText) || KeywordsValidator.isSqlKeyword(newText)) {
                    //$NON-NLS-1$
                    return "Input is invalid.";
                }
                return null;
            } else {
                return null;
            }
        }
    });
    id.open();
    if (id.getReturnCode() == InputDialog.CANCEL) {
        //$NON-NLS-1$
        return "";
    }
    //$NON-NLS-1$
    IElementParameter elementParam = node.getElementParameter("ELT_TABLE_NAME");
    if (elementParam != null) {
        String paraValue = TalendTextUtils.addQuotes(id.getValue());
        elementParam.setValue(paraValue);
    }
    return id.getValue();
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) Node(org.talend.designer.core.ui.editor.nodes.Node) IElementParameter(org.talend.core.model.process.IElementParameter)

Aggregations

InputDialog (org.eclipse.jface.dialogs.InputDialog)31 IInputValidator (org.eclipse.jface.dialogs.IInputValidator)12 Composite (org.eclipse.swt.widgets.Composite)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 FillLayout (org.eclipse.swt.layout.FillLayout)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Button (org.eclipse.swt.widgets.Button)5 Group (org.eclipse.swt.widgets.Group)5 Label (org.eclipse.swt.widgets.Label)5 IStatus (org.eclipse.core.runtime.IStatus)4 Control (org.eclipse.swt.widgets.Control)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 ArrayList (java.util.ArrayList)3 Status (org.eclipse.core.runtime.Status)3 ErrorDialog (org.eclipse.jface.dialogs.ErrorDialog)3 SashForm (org.eclipse.swt.custom.SashForm)3 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)3