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