use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method initCellEditor.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
*/
@Override
protected void initCellEditor() {
DirectEditType directEditType = cellAndType.get(getCellEditor());
if (model instanceof AbstractNode) {
final AbstractNode abstractNode = (AbstractNode) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION:
String expression = abstractNode.getExpression() == null ? "" : abstractNode.getExpression();
getCellEditor().setValue(expression);
Text text = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
text.selectAll();
break;
case NODE_NAME:
String variable = abstractNode.getName();
if (variable == null) {
variable = "";
}
getCellEditor().setValue(variable);
final Text nametext = (Text) ((TextCellEditor) getCellEditor()).getControl();
nametext.selectAll();
if (model instanceof VarNode) {
nametext.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
List<VarNode> children = new ArrayList<VarNode>();
children.addAll(((VarTable) abstractNode.eContainer()).getNodes());
children.remove(model);
String message = XmlMapUtil.isValidColumnName(children, ((Text) e.widget).getText());
if (message != null) {
nametext.setBackground(ColorConstants.red);
} else {
nametext.setBackground(ColorConstants.white);
}
}
});
}
break;
case VAR_NODE_TYPE:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getTypeDisplayValue((VarNode) abstractNode));
}
break;
}
}
} else if (model instanceof InputXmlTree) {
InputXmlTree inputxmlTree = (InputXmlTree) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION_FILTER:
String expressionFilter = inputxmlTree.getExpressionFilter();
if (expressionFilter == null) {
expressionFilter = "";
}
getCellEditor().setValue(expressionFilter);
Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
textarea.selectAll();
break;
case LOOKUP_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getLookupDisplayName(inputxmlTree.getLookupMode()));
}
break;
case MATCH_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(getMatchModelDisplayName(inputxmlTree.getMatchingMode()));
}
break;
case JOIN_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
String join = "";
if (inputxmlTree.isInnerJoin()) {
join = joinModel[0];
} else {
join = joinModel[1];
}
combo.setText(join);
}
break;
case PERSISTENT_MODEL:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(inputxmlTree.isPersistent()));
}
break;
}
}
} else if (model instanceof OutputXmlTree) {
OutputXmlTree outputTree = (OutputXmlTree) model;
if (directEditType != null) {
switch(directEditType) {
case EXPRESSION_FILTER:
String expressionFilter = outputTree.getExpressionFilter();
if (expressionFilter == null) {
expressionFilter = "";
}
getCellEditor().setValue(expressionFilter);
Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
textarea.selectAll();
break;
case OUTPUT_REJECT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isReject()));
}
break;
case LOOK_UP_INNER_JOIN_REJECT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isRejectInnerJoin()));
}
break;
case ALL_IN_ONE:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isAllInOne()));
}
break;
case ENABLE_EMPTY_ELEMENT:
if (getCellEditor() instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) getCellEditor().getControl();
combo.setText(String.valueOf(outputTree.isEnableEmptyElement()));
}
}
}
} else if (model instanceof XmlMapData) {
XmlMapData xmlMapData = (XmlMapData) model;
if (directEditType != null) {
switch(directEditType) {
case SERACH:
Text text = (Text) getCellEditor().getControl();
text.selectAll();
break;
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class OutputXmlTreeEditPart method setModel.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#setModel(java.lang.Object)
*/
@Override
public void setModel(Object model) {
super.setModel(model);
OutputXmlTree outputTree = (OutputXmlTree) getModel();
manager = new XmlMapTableManager(outputTree, this);
for (InputLoopNodesTable sourceLoopTable : outputTree.getInputLoopNodesTables()) {
addListenerForInputLoopNodeTable(sourceLoopTable);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapComponent method renameOutputConnection.
@Override
public void renameOutputConnection(String oldName, String newName) {
XmlMapData externalEmfData = (XmlMapData) getExternalEmfData();
for (OutputXmlTree outputTree : externalEmfData.getOutputTrees()) {
if (outputTree.getName() != null && outputTree.getName().equals(oldName) && !oldName.equals(newName)) {
outputTree.setName(newName);
XmlMapUtil.updateXPathAndExpression(externalEmfData, expressionManager, outputTree.getNodes(), outputTree.getName(), 1);
}
}
// name here
if (getOriginalNode() == null) {
return;
}
for (IMetadataTable table : getOriginalNode().getMetadataList()) {
boolean changeLabel = oldName.equals(table.getLabel()) || (table.getLabel() != null && !table.getLabel().equals(table.getTableName()) && oldName.equals(table.getTableName()));
if (changeLabel) {
table.setLabel(newName);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapComponent method checkNeededRoutines.
@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
List<String> routinesToAdd = new ArrayList<String>();
XmlMapData xmlMapData = (XmlMapData) getExternalEmfData();
for (String routine : possibleRoutines) {
List<OutputXmlTree> listOutput = xmlMapData.getOutputTrees();
for (OutputXmlTree outTable : listOutput) {
List<OutputTreeNode> listOutEntry = outTable.getNodes();
if (listOutEntry != null && !listOutEntry.isEmpty()) {
for (OutputTreeNode outEntry : listOutEntry) {
String expression = outEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
String filter = outTable.getExpressionFilter();
if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
List<InputXmlTree> listInput = xmlMapData.getInputTrees();
for (InputXmlTree inputTable : listInput) {
List<TreeNode> listInEntry = inputTable.getNodes();
if (listInEntry != null && !listInEntry.isEmpty()) {
for (TreeNode inEntry : listInEntry) {
String expression = inEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
String filter = inputTable.getExpressionFilter();
if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
List<VarTable> listVar = xmlMapData.getVarTables();
for (VarTable varTable : listVar) {
List<VarNode> listVarEntry = varTable.getNodes();
if (listVarEntry != null && !listVarEntry.isEmpty()) {
for (VarNode varEntry : listVarEntry) {
String expression = varEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
return routinesToAdd;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapService method cloneTreeNode.
private EObject cloneTreeNode(EObject node) {
if (node instanceof AbstractInOutTree) {
AbstractInOutTree source = null;
AbstractInOutTree oriSource = null;
if (node instanceof InputXmlTree) {
oriSource = (InputXmlTree) node;
source = XmlmapFactory.eINSTANCE.createInputXmlTree();
((InputXmlTree) source).setActivateGlobalMap(((InputXmlTree) oriSource).isActivateGlobalMap());
((InputXmlTree) source).setInnerJoin(((InputXmlTree) oriSource).isInnerJoin());
((InputXmlTree) source).setLookup(((InputXmlTree) oriSource).isLookup());
((InputXmlTree) source).setLookupMode(((InputXmlTree) oriSource).getLookupMode());
((InputXmlTree) source).setMatchingMode(((InputXmlTree) oriSource).getMatchingMode());
((InputXmlTree) source).setPersistent(((InputXmlTree) oriSource).isPersistent());
} else if (node instanceof OutputXmlTree) {
oriSource = (OutputXmlTree) node;
source = XmlmapFactory.eINSTANCE.createOutputXmlTree();
((OutputXmlTree) source).setAllInOne(((OutputXmlTree) oriSource).isAllInOne());
((OutputXmlTree) source).setEnableEmptyElement(((OutputXmlTree) oriSource).isEnableEmptyElement());
((OutputXmlTree) source).setErrorReject(((OutputXmlTree) oriSource).isErrorReject());
((OutputXmlTree) source).setReject(((OutputXmlTree) oriSource).isReject());
((OutputXmlTree) source).setRejectInnerJoin(((OutputXmlTree) oriSource).isRejectInnerJoin());
}
source.setActivateCondensedTool(oriSource.isActivateCondensedTool());
source.setActivateExpressionFilter(oriSource.isActivateExpressionFilter());
source.setExpressionFilter(oriSource.getExpressionFilter());
source.setMinimized(oriSource.isMinimized());
source.setMultiLoops(oriSource.isMultiLoops());
source.setName(oriSource.getName());
return source;
} else if (node instanceof VarNode) {
VarNode oriSource = (VarNode) node;
VarNode source = XmlmapFactory.eINSTANCE.createVarNode();
source.setExpression(oriSource.getExpression());
source.setName(oriSource.getName());
source.setNullable(oriSource.isNullable());
source.setType(oriSource.getType());
return source;
} else if (node instanceof TreeNode) {
TreeNode source = null;
TreeNode oriSource = null;
if (node instanceof OutputTreeNode) {
oriSource = (OutputTreeNode) node;
source = XmlmapFactory.eINSTANCE.createOutputTreeNode();
((OutputTreeNode) source).setAggregate(((OutputTreeNode) oriSource).isAggregate());
((OutputTreeNode) source).setInputLoopNodesTable(((OutputTreeNode) oriSource).getInputLoopNodesTable());
} else if (node instanceof GlobalMapNode) {
oriSource = (GlobalMapNode) node;
source = XmlmapFactory.eINSTANCE.createGlobalMapNode();
return source;
} else {
oriSource = (TreeNode) node;
source = XmlmapFactory.eINSTANCE.createTreeNode();
}
source.setChoice(oriSource.isChoice());
source.setDefaultValue(oriSource.getDefaultValue());
source.setExpression(oriSource.getExpression());
source.setGroup(oriSource.isGroup());
source.setKey(oriSource.isKey());
source.setLoop(oriSource.isLoop());
source.setMain(oriSource.isMain());
source.setName(oriSource.getName());
source.setNodeType(oriSource.getNodeType());
source.setNullable(oriSource.isNullable());
source.setOptional(oriSource.isOptional());
source.setPattern(oriSource.getPattern());
source.setSubstitution(oriSource.isSubstitution());
source.setType(oriSource.getType());
source.setXpath(oriSource.getXpath());
return source;
}
return null;
}
Aggregations