use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlmapBranchContent method createContent.
@Override
protected void createContent() {
super.createContent();
statusFigure = new Label();
statusFigure.setForegroundColor(ColorConstants.red);
statusFigure.setText(getStatus());
defaultValue = new Label();
defaultValue.setForegroundColor(ColorConstants.blue);
defaultValue.setText(getDefaultValue());
ImageInfo infor = ImageInfo.SETLOOPFUNCTION_BUTTON;
if (treeNode instanceof OutputTreeNode) {
InputLoopNodesTable inputLoopNodesTable = ((OutputTreeNode) treeNode).getInputLoopNodesTable();
infor = (inputLoopNodesTable == null || inputLoopNodesTable.getInputloopnodes().isEmpty()) ? ImageInfo.SETLOOPFUNCTION_BUTTON_ERROR : ImageInfo.SETLOOPFUNCTION_BUTTON;
}
loopButtonFigure = new ToolBarButtonImageFigure(ImageProviderMapper.getImage(infor));
loopButtonFigure.addMouseListener(new MouseListener.Stub() {
@Override
public void mousePressed(MouseEvent me) {
OutputTreeNode outputTreeNode = (OutputTreeNode) treeNode;
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
if (manager.isMainTableMultiLoop()) {
loopNodes.addAll(XmlMapUtil.getMultiLoopsForXmlTree(manager.getMainInputTree()));
}
InputLoopNodesTable inputLoopNodesTable = null;
if (outputTreeNode.getInputLoopNodesTable() != null) {
inputLoopNodesTable = outputTreeNode.getInputLoopNodesTable();
} else {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(outputTreeNode);
if (abstractInOutTree != null) {
((OutputXmlTree) abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
}
}
SetLoopFunctionDialog nsDialog = new SetLoopFunctionDialog(null, outputTreeNode.getInputLoopNodesTable(), loopNodes);
if (nsDialog.open() == Window.OK) {
manager.getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
manager.getMapperUI().updateStatusBar();
}
}
});
if (treeNode != null && treeNode instanceof OutputTreeNode) {
// display loop setup button only when input main is multiloop
if (treeNode.isLoop() && manager.isMainTableMultiLoop()) {
this.add(loopButtonFigure);
}
}
this.add(statusFigure);
this.add(defaultValue);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlmapTreeNodeFigure method createEntityItems.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.table.entity.TableEntityFigure#createEntityItems()
*/
@Override
protected void createEntityItems(TableEntityElement entityElement) {
this.treeNode = getEntityManager().getModel();
boolean isLookup = false;
if (treeNode instanceof OutputTreeNode) {
isLookup = true;
} else {
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(treeNode);
if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
isLookup = ((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
}
}
if (isLookup) {
expression = new ExpressionFigure();
expression.setText(treeNode.getExpression());
if (!XmlMapUtil.isExpressionEditable(treeNode)) {
expression.setOpaque(true);
expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
} else {
expression.setOpaque(false);
}
entityElement.add(expression);
}
branchContent = new XmlmapBranchContent(getEntityManager());
TreeBranch treeBranch = new TreeBranch(branchContent, !isRoot());
entityElement.add(treeBranch);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class SetSubstitutionAction method run.
@Override
public void run() {
TreeNode treeNode = null;
boolean needWarning = false;
if (input) {
treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
if (!selectedNode.getOutgoingConnections().isEmpty()) {
needWarning = true;
}
} else {
treeNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
EList<Connection> incomingConnections = selectedNode.getIncomingConnections();
if (!incomingConnections.isEmpty()) {
needWarning = true;
}
}
boolean canContinue = true;
// Shell shell = this.part.getSite().getShell();
if (needWarning) {
canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add a choice for the selected element ?");
}
if (canContinue) {
AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
IDialogSettings workbenchSettings = plugin.getDialogSettings();
//$NON-NLS-1$
IDialogSettings section = workbenchSettings.getSection("SetSubstitutionAction.SubsMessageDialog");
if (section == null) {
//$NON-NLS-1$
section = workbenchSettings.addNewSection("SetSubstitutionAction.SubsMessageDialog");
}
boolean popupMessageDialog = !section.getBoolean(HIDE_MESSAGE);
if (popupMessageDialog) {
String message = "This element will be copied as part of the substitution group automatically." + "\n" + "If this element must be abstract and must be extended only, you can delete it.";
SubsMessageDialog dialog = new SubsMessageDialog(null, message);
int open = dialog.open();
if (open == Window.OK) {
boolean hideDialogNextTime = dialog.getResult();
if (hideDialogNextTime) {
section.put(HIDE_MESSAGE, true);
}
}
if (open == Window.CANCEL) {
return;
}
}
XmlMapUtil.detachNodeConnections(selectedNode, mapperManager.getExternalData(), false);
treeNode.setName(selectedNode.getName() + XSDPopulationUtil2.SUBS);
treeNode.setNodeType(NodeType.ELEMENT);
treeNode.setXpath(selectedNode.getXpath() + XmlMapUtil.XPATH_SEPARATOR + treeNode.getName());
treeNode.setSubstitution(true);
TreeNode parentNode = (TreeNode) selectedNode.eContainer();
int index = parentNode.getChildren().indexOf(selectedNode);
parentNode.getChildren().remove(selectedNode);
treeNode.getChildren().add(selectedNode);
parentNode.getChildren().add(index, treeNode);
if (!input) {
OutputTreeNode output = (OutputTreeNode) selectedNode;
if (!XmlMapUtil.isExpressionEditable(output) && output.isAggregate()) {
output.setAggregate(false);
}
}
Object object = graphicViewer.getEditPartRegistry().get(treeNode);
if (object instanceof TreeNodeEditPart) {
graphicViewer.select((TreeNodeEditPart) object);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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.model.emf.xmlmap.OutputTreeNode 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);
}
}
});
}
Aggregations