use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class EntryContentProposal method getDescription.
@Override
public String getDescription() {
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
String separator = " - ";
if (entry instanceof TreeNode) {
TreeNode inputEntry = (TreeNode) entry;
IMetadataColumn metadataColumn = null;
if (inputEntry.eContainer() instanceof InputXmlTree) {
InputXmlTree tree = (InputXmlTree) inputEntry.eContainer();
List<IODataComponent> inputs = mapperManager.getMapperComponent().getIODataComponents().getInputs();
IMetadataTable table = null;
for (int i = 0; i < inputs.size(); i++) {
IODataComponent ioDataComponent = inputs.get(i);
if (tree.getName() != null && tree.getName().equals(ioDataComponent.getConnection().getName())) {
table = ioDataComponent.getTable();
break;
}
}
if (table != null && table.getListColumns() != null) {
for (IMetadataColumn column : table.getListColumns()) {
if (inputEntry.getName().equals(column.getLabel())) {
metadataColumn = column;
}
}
}
}
//$NON-NLS-1$ //$NON-NLS-2$
sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(inputEntry.getName()).append(//$NON-NLS-1$
"' ");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append(Messages.getString("EntryContentProposal.properties"));
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(inputEntry.getName());
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(inputEntry.isKey());
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(format(inputEntry.getType()));
if (metadataColumn != null) {
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
sb.append(format(metadataColumn.getLength()));
}
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
sb.append(format(metadataColumn.getPrecision()));
}
sb.append(CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
format(metadataColumn.getDefault()));
sb.append(CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
format(metadataColumn.getComment()));
}
sb.append(CARRIAGE_RETURN);
if (inputEntry.eContainer() instanceof TreeNode) {
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.xPath")).append(inputEntry.getXpath());
sb.append(CARRIAGE_RETURN);
}
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
sb.append(CARRIAGE_RETURN);
} else if (entry instanceof VarNode) {
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
}
return sb.toString();
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapFilterConnectionPart method calculateConnOffset.
protected int calculateConnOffset() {
FilterConnection model = (FilterConnection) getModel();
if (model.getSource() == null) {
return 0;
}
TreeNode sourceTreeNode = (TreeNode) model.getSource();
AbstractInOutTree inputTreeNodeRoot = XmlMapUtil.getAbstractInOutTree(sourceTreeNode);
List<IConnection> outConns = new ArrayList<IConnection>();
if (inputTreeNodeRoot instanceof InputXmlTree) {
outConns.addAll(XmlMapUtil.getInputTreeFilterConnections((InputXmlTree) inputTreeNodeRoot));
}
int indexOf = outConns.indexOf(model);
if (indexOf != -1) {
return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET_FILTER;
}
return 0;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class TreeNodeEditPart method setModel.
@Override
public void setModel(Object model) {
super.setModel(model);
entityManger = new TreeNodeEntityManager((TreeNode) model, this);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class TreeNodeEditPart method performRequest.
@Override
public void performRequest(Request req) {
if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
Figure figure = null;
DirectEditRequest drequest = (DirectEditRequest) req;
Point figureLocation = drequest.getLocation();
if (getFigure() instanceof TableTreeEntityFigure) {
XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
ArrayList collection = new ArrayList();
collection.add(treeNodeFigure.getExpressionFigure());
collection.add(treeNodeFigure.getBranchContent());
figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
}
if (figure instanceof IWidgetCell) {
directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
}
if (directEditManager != null) {
TreeNode outputTreeNode = (TreeNode) getModel();
if (figure instanceof ExpressionFigure) {
if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
Point location = drequest.getLocation();
if (figure.containsPoint(location)) {
directEditManager.show();
((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
} else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
// disable for RC2
// directEditManager.show();
// ((XmlMapGraphicViewer)
// getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
}
super.performRequest(req);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class TreeNodeEditPart method getExpressionIndex.
protected int getExpressionIndex(TreeNode treeNode, TreeNode treeRoot, int index, Map<TreeNode, Integer> nodeAndIndex) {
for (int i = 0; i < treeRoot.getChildren().size(); i++) {
index++;
TreeNode treeNode2 = treeRoot.getChildren().get(i);
nodeAndIndex.put(treeNode2, new Integer(index));
if (treeNode == treeNode2) {
return index;
} else if (!treeNode2.getChildren().isEmpty()) {
index = getExpressionIndex(treeNode, treeNode2, index, nodeAndIndex);
if (nodeAndIndex.get(treeNode) != null) {
return index;
}
}
}
return index;
}
Aggregations