use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree 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;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method getMatchModel.
private IUIMatchingMode[] getMatchModel() {
IUIMatchingMode[] allMatchingModel = XML_MAP_MATCHING_MODE.values();
List<IUIMatchingMode> avilable = new ArrayList<IUIMatchingMode>();
if (model instanceof InputXmlTree) {
InputXmlTree inputTree = (InputXmlTree) model;
for (int i = 0; i < allMatchingModel.length; ++i) {
IUIMatchingMode matchingMode = allMatchingModel[i];
final String text = matchingMode.getLabel();
if (text.length() != 0) {
if (inputTree.getMatchingMode().equals(XML_MAP_MATCHING_MODE.ALL_ROWS.toString())) {
if (matchingMode.equals(XML_MAP_MATCHING_MODE.ALL_ROWS)) {
avilable.add(matchingMode);
}
} else {
if (!matchingMode.equals(XML_MAP_MATCHING_MODE.ALL_ROWS)) {
avilable.add(matchingMode);
}
}
}
}
}
return avilable.toArray(new IUIMatchingMode[avilable.size()]);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class ImportTreeFromXml method run.
@Override
public void run() {
List<FOXTreeNode> list = new ArrayList<FOXTreeNode>();
FileDialog f = new FileDialog(shell);
String file = f.open();
if (file != null) {
boolean clickOk = false;
TreeNode treeNodeRoot = null;
String detailedMessage = "";
try {
clickOk = TreeUtil.getFoxTreeNodesForXmlMap(file, shell, list);
if (!clickOk) {
return;
}
treeNodeRoot = XmlMapUtil.getTreeNodeRoot(parentNode);
XmlMapUtil.detachNodeConnections(treeNodeRoot, mapperManager.getExternalData(), true);
parentNode.getChildren().clear();
prepareEmfTreeNode(list, parentNode);
} catch (Exception e) {
ExceptionHandler.process(e);
StringBuffer sb = new StringBuffer();
sb.append(e.toString());
sb.append("\n");
if (e.getStackTrace() != null) {
for (StackTraceElement trace : e.getStackTrace()) {
sb.append(trace.toString());
sb.append("\n");
}
}
detailedMessage = sb.toString();
}
boolean childrenEmpty = false;
if (parentNode.getChildren().isEmpty()) {
childrenEmpty = true;
TreeNode rootNode = null;
if (input) {
rootNode = XmlmapFactory.eINSTANCE.createTreeNode();
} else {
rootNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
}
rootNode.setName("root");
rootNode.setNodeType(NodeType.ELEMENT);
rootNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
rootNode.setXpath(XmlMapUtil.getXPath(parentNode.getXpath(), "root", NodeType.ELEMENT));
parentNode.getChildren().add(rootNode);
}
// set a default loop
parentNode.getChildren().get(0).setLoop(true);
parentNode.getChildren().get(0).setMain(true);
if (childrenEmpty || (detailedMessage != null && !"".equals(detailedMessage))) {
showError(detailedMessage);
}
if (parentNode.eContainer() instanceof InputXmlTree) {
XmlMapConnectionBuilder connectionBuilder = new XmlMapConnectionBuilder();
connectionBuilder.setCheckRootNodePrefix(true);
connectionBuilder.rebuildLinks(parentNode, mapperManager.getExternalData());
mapperManager.refreshTreeSchemaEditor((InputXmlTree) parentNode.eContainer());
// mapperManager.inputTreeSchemaBeanListModified();
} else if (parentNode.eContainer() instanceof OutputXmlTree) {
mapperManager.refreshTreeSchemaEditor((OutputXmlTree) parentNode.eContainer());
// mapperManager.outputTreeSchemaBeanListModified();
}
if (treeNodeRoot != null && treeNodeRoot.eContainer() instanceof AbstractInOutTree) {
mapperManager.getProblemsAnalyser().checkProblems((AbstractInOutTree) treeNodeRoot.eContainer());
mapperManager.getMapperUI().updateStatusBar();
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XmlMapTableManager method setActivateGlobalMap.
/*
* (non-Javadoc)
*
* @see org.talend.designer.gefabstractmap.figures.manager.TableManager#setActivateGlobalMap(boolean)
*/
@Override
public void setActivateGlobalMap(boolean active) {
if (getModel() instanceof InputXmlTree) {
InputXmlTree inputXmlTree = (InputXmlTree) getModel();
inputXmlTree.setActivateGlobalMap(active);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XmlMapInputZoneToolBar method moveDown.
/*
* (non-Javadoc)
*
* @see org.talend.designer.xmlmap.figures.treetools.zone.ZoneToolBar#moveDown()
*/
@Override
public void moveDown() {
List<InputXmlTree> inputTrees = externalData.getInputTrees();
InputXmlTreeEditPart currentSelectedInputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedInputTable();
if (currentSelectedInputXmlTree != null) {
InputXmlTree selectedTree = (InputXmlTree) currentSelectedInputXmlTree.getModel();
int index = inputTrees.indexOf(selectedTree);
if (index != -1 && index + 1 < inputTrees.size()) {
inputTrees.remove(selectedTree);
inputTrees.add(index + 1, selectedTree);
// index of modelchildren is different from index of tree
int indexOf = externalPart.getModelChildren().indexOf(selectedTree);
if (indexOf != -1) {
graphicViewer.appendSelection((EditPart) externalPart.getChildren().get(indexOf));
}
}
}
}
Aggregations