use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XMLMapperHelper method hasDocumentInMainInput.
private static boolean hasDocumentInMainInput(final INode xmlMapperNode) {
boolean hasDocumentInMainInput = false;
List<? extends IConnection> inConnections = (List<? extends IConnection>) xmlMapperNode.getIncomingConnections();
XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
if (xmlMapData != null && inConnections != null && inConnections.size() > 0) {
List<InputXmlTree> inputTables = xmlMapData.getInputTrees();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : inConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (InputXmlTree inputTable : inputTables) {
String tableName = inputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
if (!(inputTable.isLookup())) {
for (TreeNode node : inputTable.getNodes()) {
if ("id_Document".equals(node.getType())) {
hasDocumentInMainInput = true;
break;
}
}
}
}
}
return hasDocumentInMainInput;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems() {
treeAndProblems.clear();
final XmlMapData copyOfMapData = mapperManager.getExternalData();
if (copyOfMapData != null) {
// check problems for InputLoopTable in output
InputXmlTree mainInputTree = mapperManager.getMainInputTree();
for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
checkInputLoopTablesProblem(outputTree, mainInputTree);
}
for (InputXmlTree inputTree : copyOfMapData.getInputTrees()) {
isMultipleDocType = false;
checkTreeNodesProblem(inputTree, inputTree.getNodes());
}
for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
isMultipleDocType = false;
checkTreeNodesProblem(outputTree, outputTree.getNodes());
}
}
return getProblems();
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree 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.InputXmlTree in project tdi-studio-se by Talend.
the class MapperManager method onEntitySelection.
private void onEntitySelection(IStructuredSelection selection, AbstractInOutTree selectedTree) {
// do selection in metadata schema editor
EList<? extends TreeNode> nodes = null;
if (selectedTree instanceof InputXmlTree) {
nodes = ((InputXmlTree) selectedTree).getNodes();
} else {
nodes = ((OutputXmlTree) selectedTree).getNodes();
}
List<Integer> selectionIndices = new ArrayList<Integer>();
List<TreeNode> selectedDocChild = new ArrayList<TreeNode>();
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof TreeNodeEditPart) {
TreeNode model = (TreeNode) ((TreeNodeEditPart) obj).getModel();
if (model.eContainer() == selectedTree) {
selectionIndices.add(nodes.indexOf(model));
} else {
AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(model);
if (abstractInOutTree == selectedTree) {
selectedDocChild.add(model);
}
}
}
}
int[] selections = new int[selectionIndices.size()];
for (int i = 0; i < selectionIndices.size(); i++) {
selections[i] = selectionIndices.get(i);
}
MetadataTableEditorView metaEditorView = null;
XmlTreeSchemaTableView treeEditorView = null;
if (selectedTree instanceof InputXmlTree) {
metaEditorView = mapperUI.getTabFolderEditors().getInputMetaEditorView();
treeEditorView = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
} else {
metaEditorView = mapperUI.getTabFolderEditors().getOutputMetaEditorView();
treeEditorView = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
}
metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metaEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metaEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
// if no, change page
if (!selectedDocChild.isEmpty()) {
treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
TreeNode firstSelection = null;
if (selectedDocChild.size() > 1) {
selectionIndices = new ArrayList<Integer>();
List<TreeNode> allList = new ArrayList<TreeNode>();
for (TreeNode schemaNodes : nodes) {
if (XmlMapUtil.DOCUMENT.equals(schemaNodes.getType())) {
allList.addAll(SchemaTableUtils.getTreeSchemaEnties(schemaNodes));
}
}
int minIndex = allList.size();
for (TreeNode selected : selectedDocChild) {
int indexOf = allList.indexOf(selected);
if (indexOf != -1 && indexOf < minIndex) {
firstSelection = selected;
}
}
} else {
firstSelection = selectedDocChild.get(0);
}
treeEditorView.getExtendedTableModel().changePageIfNeeded(firstSelection);
// update selection
selectionIndices = new ArrayList<Integer>();
for (TreeNode selected : selectedDocChild) {
int indexOf = treeEditorView.getExtendedTableModel().getBeansList().indexOf(selected);
if (indexOf != -1) {
selectionIndices.add(indexOf);
}
}
selections = new int[selectionIndices.size()];
for (int i = 0; i < selectionIndices.size(); i++) {
selections[i] = selectionIndices.get(i);
}
treeEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
treeEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class MapperManager method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
Iterator iterator = ((IStructuredSelection) event.getSelection()).iterator();
while (iterator.hasNext()) {
Object firstElement = iterator.next();
if (firstElement instanceof TableEntityPart) {
AbstractNode model = (AbstractNode) ((TableEntityPart) firstElement).getModel();
boolean isInputMain = false;
if (model instanceof OutputTreeNode) {
OutputTreeNode outputTreeNodeRoot = (OutputTreeNode) XmlMapUtil.getTreeNodeRoot((OutputTreeNode) model);
if (outputTreeNodeRoot != null && outputTreeNodeRoot.eContainer() instanceof OutputXmlTree) {
selectOutputXmlTree((OutputXmlTree) outputTreeNodeRoot.eContainer());
onEntitySelection((IStructuredSelection) event.getSelection(), selectedOutputTree);
}
} else if (model instanceof TreeNode) {
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot((TreeNode) model);
if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
selectInputXmlTree((InputXmlTree) inputTreeNodeRoot.eContainer());
isInputMain = !((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
onEntitySelection((IStructuredSelection) event.getSelection(), selectedInputTree);
}
}
if (!isInputMain) {
refreshStyledTextEditor((TableEntityPart) firstElement);
} else {
refreshStyledTextEditor(null);
}
selectedFigure = ((TableEntityPart) firstElement).getFigure();
} else if (firstElement instanceof InputXmlTreeEditPart) {
selectInputXmlTree((InputXmlTree) ((InputXmlTreeEditPart) firstElement).getModel());
refreshStyledTextEditor(null);
} else if (firstElement instanceof OutputXmlTreeEditPart) {
selectOutputXmlTree((OutputXmlTree) ((OutputXmlTreeEditPart) firstElement).getModel());
refreshStyledTextEditor(null);
}
}
}
// else {
// ExtendedTableModel<TreeSchemaTableEntry> oldModel = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .getExtendedTableModel();
// if (oldModel != null && oldModel.getBeanCount() != 0) {
// List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .setExtendedControlModel(new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys));
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor().getTableViewerCreator().refresh();
// }
// refreshStyledTextEditor(null);
// }
}
Aggregations