use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class MapperManager method getSelectedOutputTreeSchemaModel.
public ExtendedTableModel<TreeSchemaTableEntry> getSelectedOutputTreeSchemaModel(OutputXmlTree outputXmlTree) {
if (outputXmlTree == null && !getExternalData().getOutputTrees().isEmpty()) {
outputXmlTree = getExternalData().getOutputTrees().get(0);
}
List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
ExtendedTableModel<TreeSchemaTableEntry> tableModel = new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys);
if (outputXmlTree != null) {
tableModel.setName(outputXmlTree.getName());
EList<OutputTreeNode> nodes = outputXmlTree.getNodes();
for (TreeNode node : nodes) {
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
addTreeSchemaEnties(tableModel, node.getChildren());
}
}
}
return tableModel;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode 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.OutputTreeNode in project tdi-studio-se by Talend.
the class MapperUI method prepareClosing.
public void prepareClosing(int response) {
List<IMetadataTable> newMetadatas = new ArrayList<IMetadataTable>();
EList<OutputXmlTree> outputTrees = null;
if (response == SWT.OK || response == SWT.APPLICATION_MODAL) {
// fix for bug TDI-18185
mapperManager.fireCurrentDirectEditApply();
// if press ok or apply , use copyOfMapData to check the metadata list
outputTrees = copyOfMapData.getOutputTrees();
} else {
// if press cancel , use the original mapData
outputTrees = ((XmlMapData) mapperComponent.getExternalEmfData()).getOutputTrees();
}
List<IMetadataTable> copyOfMetadata = new ArrayList<IMetadataTable>(mapperComponent.getMetadataList());
for (OutputXmlTree outputTree : outputTrees) {
IMetadataTable found = null;
for (IMetadataTable table : mapperComponent.getMetadataList()) {
if (outputTree.getName().equals(table.getTableName())) {
found = table;
}
}
if (found != null) {
newMetadatas.add(found);
} else {
// create a new metadata if needed
MetadataTable metadataTable = new MetadataTable();
metadataTable.setTableName(outputTree.getName());
mapperComponent.getProcess().addUniqueConnectionName(outputTree.getName());
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (OutputTreeNode treeNode : outputTree.getNodes()) {
MetadataColumn column = new MetadataColumn();
column.setLabel(treeNode.getName());
column.setKey(treeNode.isKey());
column.setTalendType(treeNode.getType());
column.setNullable(treeNode.isNullable());
column.setPattern(treeNode.getPattern());
listColumns.add(column);
}
metadataTable.setListColumns(listColumns);
newMetadatas.add(metadataTable);
}
}
mapperComponent.setMetadataList(newMetadatas);
copyOfMetadata.removeAll(newMetadatas);
List<IODataComponent> outputs = mapperComponent.getIODataComponents().getOuputs();
List<String> connectionNames = new ArrayList<String>();
for (IODataComponent output : outputs) {
connectionNames.add(output.getUniqueName());
}
for (IMetadataTable leftTree : copyOfMetadata) {
if (!connectionNames.contains(leftTree.getTableName())) {
mapperComponent.getProcess().removeUniqueConnectionName(leftTree.getTableName());
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class DragAndDropEditPolicy method showTargetFeedback.
@Override
public void showTargetFeedback(Request request) {
if (request instanceof CreateNodeConnectionRequest) {
CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
// show feedback when insert new column
if (rq.getNewObjectType() != null && targetEditPart != null) {
Object model = targetEditPart.getModel();
switch(rq.getNewObjectType()) {
case DROP_INSERT_OUTPUT:
case DROP_INSERT_VAR:
if (model instanceof OutputTreeNode || model instanceof VarNode) {
IFigure targetFigure = targetEditPart.getFigure();
if (targetFigure != null) {
if (indicator == null) {
indicator = new InsertionIndicator();
}
Rectangle copy = targetFigure.getBounds().getCopy();
Rectangle bounds = new Rectangle();
bounds.x = copy.x - 5;
bounds.y = copy.y - 5;
bounds.width = copy.width + 10;
bounds.height = 10;
indicator.setBounds(bounds);
getFeedbackLayer().add(indicator);
}
} else {
if (indicator != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
getFeedbackLayer().remove(indicator);
}
}
break;
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class SetLoopAction method findUpGroupNode.
private void findUpGroupNode(List<TreeNode> newLoopUpGroups, OutputTreeNode node) {
if (node.eContainer() instanceof OutputTreeNode) {
OutputTreeNode parent = (OutputTreeNode) node.eContainer();
if (parent.isGroup()) {
newLoopUpGroups.add(parent);
}
findUpGroupNode(newLoopUpGroups, parent);
}
}
Aggregations