use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData in project tdi-studio-se by Talend.
the class ExpressionProposalProvider method init.
public void init(Object source) {
XmlMapData mapData = mapperManager.getExternalData();
int index = 0;
boolean needVar = false;
if (source instanceof OutputTreeNode || source instanceof OutputXmlTree) {
needVar = true;
index = mapData.getInputTrees().size();
} else if (source instanceof TreeNode) {
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree((TreeNode) source);
index = mapData.getInputTrees().indexOf(abstractTree);
if (index == -1) {
index = 0;
}
} else if (source instanceof VarNode) {
index = mapData.getInputTrees().size();
} else if (source instanceof InputXmlTree) {
index = mapData.getInputTrees().indexOf(source) + 1;
}
for (int i = 0; i < index; i++) {
InputXmlTree inputTree = mapData.getInputTrees().get(i);
getProposalsInside(inputTree.getNodes(), proposalsInside);
}
if (needVar) {
getProposalsInside(mapData.getVarTables().get(0).getNodes(), proposalsInside);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData 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.XmlMapData 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.XmlMapData in project tdi-studio-se by Talend.
the class XmlMapComponent method getHashConfiguration.
@Override
public IHashConfiguration getHashConfiguration(String connectionName) {
IHashConfiguration hashConfigurationForMapper = null;
XmlMapData externalData = (XmlMapData) getExternalEmfData();
List<InputXmlTree> inputTables = externalData.getInputTrees();
List<IHashableColumn> hashableColumns = new ArrayList<IHashableColumn>();
for (InputXmlTree inputTable : inputTables) {
if (inputTable.getName().equals(connectionName)) {
List<TreeNode> metadataTableEntries = inputTable.getNodes();
if (metadataTableEntries != null) {
int metadataTableEntriesListSize = metadataTableEntries.size();
for (int i = 0; i < metadataTableEntriesListSize; i++) {
TreeNode entry = metadataTableEntries.get(i);
if (entry.getExpression() != null && !entry.getExpression().trim().equals("")) {
//$NON-NLS-1$
hashableColumns.add(new HashableColumn(entry.getName(), i));
}
}
}
IMatchingMode matchingMode = MATCHING_MODE.parse(inputTable.getMatchingMode());
if (matchingMode == null) {
matchingMode = MATCHING_MODE.UNIQUE_MATCH;
}
ILookupMode lookupMode = org.talend.designer.xmlmap.model.tree.LOOKUP_MODE.parse(inputTable.getLookupMode());
if (lookupMode == null) {
lookupMode = org.talend.designer.xmlmap.model.tree.LOOKUP_MODE.LOAD_ONCE;
}
//$NON-NLS-1$
IElementParameter tempFolderElem = getElementParameter("TEMPORARY_DATA_DIRECTORY");
String tempFolder = null;
if (tempFolderElem != null) {
tempFolder = (String) tempFolderElem.getValue();
}
if (("").equals(tempFolder)) {
//$NON-NLS-1$ //$NON-NLS-2$
tempFolder = (String) this.getProcess().getElementParameter("COMP_DEFAULT_FILE_DIR").getValue() + "/temp";
tempFolder = TalendTextUtils.addQuotes(tempFolder);
}
//$NON-NLS-1$
IElementParameter rowsBufferSizeElem = getElementParameter("ROWS_BUFFER_SIZE");
String rowsBufferSize = null;
if (rowsBufferSizeElem != null) {
rowsBufferSize = (String) rowsBufferSizeElem.getValue();
}
hashConfigurationForMapper = new HashConfiguration(hashableColumns, matchingMode, inputTable.isPersistent(), tempFolder, rowsBufferSize);
break;
}
}
return hashConfigurationForMapper;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData in project tdi-studio-se by Talend.
the class XmlMapComponent method removeInput.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.AbstractNode#removeInput(org.talend.core.model.process.IConnection)
*/
@Override
public void removeInput(IConnection connection) {
XmlMapData externalEmfData = (XmlMapData) getExternalEmfData();
InputXmlTree toRemove = null;
for (InputXmlTree inputTree : externalEmfData.getInputTrees()) {
if (inputTree.getName() != null && inputTree.getName().equals(connection.getUniqueName())) {
toRemove = inputTree;
break;
}
}
if (toRemove != null) {
if (!toRemove.isLookup() && toRemove.isMultiLoops()) {
// clean InputLoopTable in putput tree
XmlMapUtil.removeloopInOutputTree(externalEmfData, null, null);
}
for (TreeNode treeNode : toRemove.getNodes()) {
XmlMapUtil.detachNodeConnections(treeNode, externalEmfData, true);
}
XmlMapUtil.detachFilterSource(toRemove, externalEmfData);
externalEmfData.getInputTrees().remove(toRemove);
}
}
Aggregations