Search in sources :

Example 6 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 //$NON-NLS-1$
        InputDialog(//$NON-NLS-1$
        null, //$NON-NLS-1$
        Messages.getString("FixValueAction.1"), Messages.getString("FixValueAction.2"), "", //$NON-NLS-1$ //$NON-NLS-2$
        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(node);
    this.xmlViewer.expandToLevel(node, 1);
    foxui.redrawLinkers();
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog)

Example 7 with InputDialog

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

the class CreateAttributeAction method createChildNode.

/**
     * Create the child node of the input node
     * 
     * @param node
     */
private void createChildNode(FOXTreeNode node) {
    //$NON-NLS-1$
    String label = "";
    while (!org.talend.metadata.managment.ui.wizard.metadata.xml.utils.StringUtil.validateLabelForXML(label)) {
        InputDialog dialog = new //$NON-NLS-1$
        InputDialog(//$NON-NLS-1$
        null, //$NON-NLS-1$
        Messages.getString("CreateAttributeAction.1"), Messages.getString("CreateAttributeAction.2"), "", //$NON-NLS-1$ //$NON-NLS-2$
        null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (status == InputDialog.CANCEL) {
            return;
        }
    }
    FOXTreeNode child = new Attribute(label);
    // add by wzhang. set the row name
    child.setRow(node.getRow());
    node.addChild(child);
    this.xmlViewer.refresh();
    this.xmlViewer.expandToLevel(node, 1);
    foxui.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 8 with InputDialog

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

the class CreateElementAction method createChildNode.

/**
     * Create the child node of the input node
     * 
     * @param node
     */
private boolean createChildNode(FOXTreeNode node) {
    if (node.getColumn() != null) {
        if (!//$NON-NLS-1$
        MessageDialog.openConfirm(//$NON-NLS-1$
        xmlViewer.getControl().getShell(), //$NON-NLS-1$
        Messages.getString("CreateElementAction.0"), //$NON-NLS-1$
        Messages.getString("CreateElementAction.1") + node.getLabel() + "\"?")) {
            //$NON-NLS-1$
            return false;
        }
        node.setColumn(null);
    }
    //$NON-NLS-1$
    String label = "";
    while (!StringUtil.validateLabelForXML(label)) {
        InputDialog dialog = new InputDialog(null, //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("CreateElementAction.4"), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("CreateElementAction.5"), "", //$NON-NLS-1$
        null);
        int status = dialog.open();
        if (status == InputDialog.OK) {
            label = dialog.getValue().trim();
        }
        if (status == InputDialog.CANCEL) {
            return false;
        }
    }
    FOXTreeNode child = new Element(label);
    // add by wzhang. set the row name
    child.setRow(node.getRow());
    node.addChild(child);
    this.xmlViewer.refresh();
    this.xmlViewer.expandToLevel(node, 1);
    return true;
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) InputDialog(org.eclipse.jface.dialogs.InputDialog) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element)

Example 9 with InputDialog

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

the class RenameTreeNodeAction method run.

@Override
public void run() {
    if (selectedNode != null) {
        // validataor
        IInputValidator validataor = new IInputValidator() {

            public String isValid(String newText) {
                String xpath = XmlMapUtil.getXPath(((TreeNode) selectedNode.eContainer()).getXpath(), newText, selectedNode.getNodeType());
                EList<TreeNode> children = ((TreeNode) selectedNode.eContainer()).getChildren();
                boolean exist = false;
                for (TreeNode child : children) {
                    if (child.getNodeType().equals(selectedNode.getNodeType())) {
                        if (child.getXpath() != null && child.getXpath().equals(xpath) && !child.equals(selectedNode)) {
                            exist = true;
                            break;
                        }
                    }
                }
                if (exist) {
                    if (selectedNode.getNodeType().equals(NodeType.ATTRIBUT)) {
                        return "Atribute '" + newText + "' already exist !";
                    } else if (selectedNode.getNodeType().equals(NodeType.ELEMENT)) {
                        return "Element '" + newText + "' already exist !";
                    }
                }
                return null;
            }
        };
        String name = selectedNode.getName();
        if (selectedNode.isSubstitution()) {
            name = name.substring(0, name.lastIndexOf(XSDPopulationUtil2.SUBS));
        }
        InputDialog dialog = new InputDialog(null, "Rename Tree Node", "", name, validataor);
        if (dialog.open() == Window.OK) {
            if (selectedNode.isSubstitution()) {
                selectedNode.setName(dialog.getValue() + XSDPopulationUtil2.SUBS);
            } else {
                selectedNode.setName(dialog.getValue());
            }
            // refresh
            if (selectedNode.isSubstitution()) {
                TreeNode realParent = XmlMapUtil.getRealParentNode(selectedNode);
                if (realParent != null) {
                    selectedNode.setXpath(XmlMapUtil.getXPath(realParent.getXpath(), selectedNode.getName(), selectedNode.getNodeType()));
                }
            } else {
                XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
                XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, dialog.getValue(), XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
            }
            TabFolderEditors tabFolderEditors = mapperManager.getMapperUI().getTabFolderEditors();
            if (tabFolderEditors != null) {
                if (selectedNode instanceof OutputTreeNode) {
                    tabFolderEditors.getOutputTreeSchemaEditor().refresh();
                } else if (selectedNode instanceof TreeNode) {
                    tabFolderEditors.getInputTreeSchemaEditor().refresh();
                }
            }
        }
    }
}
Also used : TabFolderEditors(org.talend.designer.xmlmap.ui.tabs.TabFolderEditors) InputDialog(org.eclipse.jface.dialogs.InputDialog) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 10 with InputDialog

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

the class InsertNewColumnCommand method validSourceNodeName.

private String validSourceNodeName(final List<? extends AbstractNode> validationList, TreeNode sourceNode) {
    String sourceName = sourceNode.getName();
    boolean isValidate = MetadataToolHelper.isValidColumnName(sourceName);
    boolean fixing = false;
    if (!isValidate) {
        if (sourceName.contains(":")) {
            //$NON-NLS-1$
            if (sourceNode.eContainer() instanceof TreeNode) {
                TreeNode parent = (TreeNode) sourceNode.eContainer();
                for (TreeNode child : parent.getChildren()) {
                    if (child.getNodeType() == NodeType.NAME_SPACE) {
                        if (sourceName.startsWith(child.getName() + ":")) {
                            //$NON-NLS-1$
                            sourceName = sourceName.substring(child.getName().length() + 1, sourceName.length());
                            fixing = true;
                        }
                    }
                }
                if (!fixing) {
                    //$NON-NLS-1$
                    sourceName = sourceName.substring(sourceName.indexOf(":"), sourceName.length());
                    fixing = true;
                }
            }
        }
        if (!fixing || !MetadataToolHelper.isValidColumnName(sourceName)) {
            IInputValidator validataor = new IInputValidator() {

                @Override
                public String isValid(String newText) {
                    return XmlMapUtil.isValidColumnName(validationList, newText);
                }
            };
            InputDialog dialog = new InputDialog(null, Messages.getString("InsertNewColumnCommand_createNew"), Messages.getString("InsertNewColumnCommand_message"), sourceName, //$NON-NLS-1$ //$NON-NLS-2$
            validataor);
            int open = dialog.open();
            if (open == Window.CANCEL) {
                return null;
            } else {
                sourceName = dialog.getValue();
            }
        }
    }
    return sourceName;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

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