use of org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart 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);
// }
}
use of org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
if (searchValue.equals("") || searchValue == null) {
return;
}
List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
matcher.setPattern("*" + searchValue.trim() + "*");
int index = -1;
// for the InputTables
for (InputXmlTree inputXmlTree : inputTrees) {
// ExpressionFilter
if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = inputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof InputXmlTreeEditPart) {
InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, inputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// TreeNode
for (TreeNode node : inputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
}
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the VarsTables
for (VarTable varTable : varTables) {
for (VarNode node : varTable.getNodes()) {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the OutputTables
for (OutputXmlTree outputXmlTree : outputTrees) {
// ExpressionFilter
if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = outputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, outputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// OutputTreeNode
for (OutputTreeNode node : outputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
} else {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
}
}
use of org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart in project tdi-studio-se by Talend.
the class XmlMapOutputZoneToolBar method removeTable.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#removeTable()
*/
@Override
protected void removeTable() {
CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
OutputXmlTreeEditPart currentSelectedOutputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedOutputTable();
if (currentSelectedOutputXmlTree != null) {
OutputXmlTree outputTree = (OutputXmlTree) currentSelectedOutputXmlTree.getModel();
int indexOf = externalPart.getModelChildren().indexOf(outputTree);
mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
removeMetadataTableByName(outputTree.getName());
for (OutputTreeNode treeNode : outputTree.getNodes()) {
XmlMapUtil.detachConnectionsSouce(treeNode, externalData);
}
externalData.getOutputTrees().remove(outputTree);
XmlMapUtil.detachFilterSource(outputTree, externalData);
indexOf = indexOf - 1;
if (indexOf > -1 && (EditPart) externalPart.getChildren().get(indexOf) instanceof OutputXmlTreeEditPart) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
} else if (indexOf > -1 && indexOf + 1 < externalPart.getChildren().size() && (EditPart) externalPart.getChildren().get(indexOf + 1) instanceof OutputXmlTreeEditPart) {
graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf + 1));
} else {
mapperManger.getMapperUI().getTabFolderEditors().getOutputMetaEditorView().setMetadataTableEditor(null);
}
mapperManger.getProblemsAnalyser().clearProblemsForTree(outputTree);
mapperManger.getMapperUI().updateStatusBar();
}
if (externalData.getOutputTrees().isEmpty() && min_size.isEnabled()) {
min_size.setEnabled(false);
}
}
});
}
use of org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart in project tdi-studio-se by Talend.
the class CreateNodeAndConnectionCommand method doUpdate.
// private void createInputLoopTable(TreeNode sourceNode, OutputTreeNode targetOutputNode) {
// EditPartViewer viewer = targetEditPart.getViewer();
// if (viewer instanceof XmlMapGraphicViewer) {
// InputLoopTableUtil.addSourceLoopToInputLoopTable(sourceNode, targetOutputNode, ((XmlMapGraphicViewer) viewer)
// .getMapperManager().getMainInputTree());
// }
// }
private void doUpdate(AbstractNode sourceNode) {
if (targetEditPart instanceof OutputTreeNodeEditPart) {
OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) targetEditPart).getModel();
String expression = targetOutputNode.getExpression();
if (sourceNode instanceof TreeNode) {
if (expression == null) {
expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
} else {
expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
}
} else if (sourceNode instanceof VarNode) {
String tableName = "Var";
if (sourceNode.eContainer() instanceof VarTable) {
tableName = ((VarTable) sourceNode.eContainer()).getName();
}
if (expression == null) {
expression = tableName + "." + sourceNode.getName();
} else {
expression = expression + " " + tableName + "." + sourceNode.getName();
}
}
// if (sourceNode instanceof TreeNode) {
// createInputLoopTable((TreeNode) sourceNode, targetOutputNode);
// }
targetOutputNode.setExpression(expression);
Connection conn = XmlmapFactory.eINSTANCE.createConnection();
conn.setSource(sourceNode);
conn.setTarget(targetOutputNode);
targetOutputNode.getIncomingConnections().add(conn);
sourceNode.getOutgoingConnections().add(conn);
if (xmlMapData != null) {
xmlMapData.getConnections().add(conn);
}
} else if (targetEditPart instanceof TreeNodeEditPart) {
/* for lookup connections */
if (sourceNode instanceof TreeNode) {
TreeNode targetTreeNode = (TreeNode) targetEditPart.getModel();
String expression = targetTreeNode.getExpression();
if (expression == null) {
expression = "";
}
expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
targetTreeNode.setExpression(expression);
LookupConnection conn = XmlmapFactory.eINSTANCE.createLookupConnection();
conn.setSource(sourceNode);
conn.setTarget(targetTreeNode);
targetTreeNode.getLookupIncomingConnections().add(conn);
((TreeNode) sourceNode).getLookupOutgoingConnections().add(conn);
if (xmlMapData != null) {
xmlMapData.getConnections().add(conn);
}
}
} else if (targetEditPart instanceof VarNodeEditPart) {
/* for varTable drag drop */
if (sourceNode instanceof TreeNode) {
VarNodeEditPart targetPart = (VarNodeEditPart) targetEditPart;
VarNode targetNode = (VarNode) targetPart.getModel();
String expression = targetNode.getExpression();
if (expression == null) {
expression = "";
}
expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
if (targetNode.getName() == null || "".equals(targetNode.getName())) {
String findUniqueVarColumnName = XmlMapUtil.findUniqueVarColumnName(sourceNode.getName(), xmlMapData.getVarTables().get(0));
targetNode.setName(findUniqueVarColumnName);
}
targetNode.setExpression(expression.trim());
targetNode.setType(sourceNode.getType());
Connection conn = XmlmapFactory.eINSTANCE.createConnection();
conn.setSource(sourceNode);
conn.setTarget(targetNode);
targetNode.getIncomingConnections().add(conn);
sourceNode.getOutgoingConnections().add(conn);
if (xmlMapData != null) {
xmlMapData.getConnections().add(conn);
}
}
} else if (targetEditPart instanceof InputXmlTreeEditPart || targetEditPart instanceof OutputXmlTreeEditPart) {
AbstractInOutTree treeModel = (AbstractInOutTree) targetEditPart.getModel();
String expression = treeModel.getExpressionFilter();
if (sourceNode instanceof TreeNode) {
if (expression == null) {
expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
} else {
expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
}
} else if (sourceNode instanceof VarNode) {
String tableName = "Var";
if (sourceNode.eContainer() instanceof VarTable) {
tableName = ((VarTable) sourceNode.eContainer()).getName();
}
if (expression == null) {
expression = tableName + "." + sourceNode.getName();
} else {
expression = expression + " " + tableName + "." + sourceNode.getName();
}
}
treeModel.setExpressionFilter(expression);
FilterConnection connection = XmlmapFactory.eINSTANCE.createFilterConnection();
connection.setSource(sourceNode);
connection.setTarget(treeModel);
treeModel.getFilterIncomingConnections().add(connection);
sourceNode.getFilterOutGoingConnections().add(connection);
xmlMapData.getConnections().add(connection);
}
}
use of org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method createCellEditorOn.
@Override
protected CellEditor createCellEditorOn(Composite composite) {
Composite parent = (Composite) source.getViewer().getControl();
CellEditor cellEditor = null;
Figure figure = null;
if (this.locator instanceof XmlMapNodeCellEditorLocator) {
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
figure = lo.getFigure();
}
if (figure instanceof IComboCell) {
try {
// tree setting can be edit or not
if (source instanceof InputXmlTreeEditPart) {
InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
return null;
}
}
if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
return null;
}
}
}
if (source instanceof OutputXmlTreeEditPart) {
OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
boolean hasAggregate = false;
for (int i = 0; i < outputTree.getNodes().size(); i++) {
OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
hasAggregate = hasAggreage(outputTreeNode);
if (hasAggregate) {
break;
}
}
if (hasAggregate) {
return null;
}
} else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
}
}
cellEditor = new XmlComboCellEditor();
cellEditor.create(composite);
((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
} catch (Exception e) {
return null;
}
} else if (figure instanceof ITextCell) {
// this one is created for direct doc child name , no use anymore...
cellEditor = new TextCellEditor(composite);
cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
// for the search
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
figure = (VarNodeTextLabel) lo.getFigure();
if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
if (searchZone.getSearchMaps().size() > 0) {
searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
searchZone.getSearchZoneMapper().setHightlightAll(false);
searchZone.getSearchMaps().clear();
searchZone.hightLightAll.setSelected(false);
}
}
}
} else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
} else if (figure instanceof ITextAreaCell) {
TextAreaBehavior behavior = new TextAreaBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
} else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
}
// }
return cellEditor;
}
Aggregations