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);
}
}
}
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();
}
}
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();
}
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();
}
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();
}
Aggregations