use of org.talend.designer.xmlmap.model.emf.xmlmap.VarNode in project tdi-studio-se by Talend.
the class XmlMapConnectionBuilder method rebuildLink.
private void rebuildLink(int inputTreeIndex, List<TreeNode> children, XmlMapData mapData) {
for (TreeNode treeNode : children) {
if (XmlMapUtil.isDragable(treeNode)) {
String expression = XmlMapUtil.convertToExpression(treeNode.getXpath());
XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
TableEntryLocation sourceLocation = expressionManager.parseTableEntryLocation(expression).get(0);
// LOOKUP ,FILTER
for (int i = inputTreeIndex; i < mapData.getInputTrees().size(); i++) {
InputXmlTree treeTarget = mapData.getInputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, treeTarget, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, treeTarget, mapData);
}
checkTargetChildren(expressionManager, treeTarget.getNodes(), treeNode, sourceLocation, mapData);
}
// VAR
for (VarNode varNode : mapData.getVarTables().get(0).getNodes()) {
if (hasMaptchedLocation(expressionManager, sourceLocation, varNode, ExpressionType.EXPRESSION)) {
createConnection(treeNode, varNode, mapData);
}
}
// OUTPUT,FILTER
for (int i = 0; i < mapData.getOutputTrees().size(); i++) {
OutputXmlTree outputTree = mapData.getOutputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, outputTree, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, outputTree, mapData);
}
checkTargetChildren(expressionManager, outputTree.getNodes(), treeNode, sourceLocation, mapData);
}
}
if (!treeNode.getChildren().isEmpty()) {
rebuildLink(inputTreeIndex, treeNode.getChildren(), mapData);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.VarNode in project tdi-studio-se by Talend.
the class XmlMapUtil method checkValidColumnName.
private static boolean checkValidColumnName(String newName, VarTable parentTable) {
for (VarNode entry : parentTable.getNodes()) {
if (entry.getName().equals(newName)) {
return false;
}
}
//$NON-NLS-1$
Pattern regex = Pattern.compile("^[A-Za-z_][A-Za-z0-9_]*$", Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE);
Matcher regexMatcher = regex.matcher(newName);
return regexMatcher.matches();
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.VarNode in project tdi-studio-se by Talend.
the class XmlMapVarTablePart method activate.
@Override
public void activate() {
super.activate();
selectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
List selectedEditParts = getViewer().getSelectedEditParts();
boolean remove = false;
boolean moveUp = false;
boolean moveDown = false;
boolean disableMoveUp = false;
boolean disableMoveDown = false;
for (Object obj : selectedEditParts) {
if (obj instanceof VarNodeEditPart) {
remove = true;
VarNode selectedNode = (VarNode) ((VarNodeEditPart) obj).getModel();
EList<VarNode> nodes = ((VarTable) getModel()).getNodes();
int indexOf = nodes.indexOf(selectedNode);
if (!disableMoveUp) {
if (indexOf != -1 && indexOf > 0) {
moveUp = true;
} else {
moveUp = false;
disableMoveUp = true;
}
}
if (!disableMoveDown) {
if (indexOf != -1 && indexOf < nodes.size() - 1) {
moveDown = true;
} else {
moveDown = false;
disableMoveDown = true;
}
}
}
}
VarToolBarFigure toolBarFigure = ((VarTableContainer) getFigure()).getToolBarFigure();
toolBarFigure.setRemoveEnable(remove);
toolBarFigure.setMoveUpEnable(moveUp);
toolBarFigure.setMoveDownEnable(moveDown);
}
};
getViewer().addSelectionChangedListener(selectionListener);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.VarNode 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.VarNode in project tdi-studio-se by Talend.
the class VarToolBarFigure method removeVar.
@Override
protected void removeVar() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
final List<VarNode> toRemove = new ArrayList<VarNode>();
int minIndex = parentTable.getNodes().size() - 1;
for (Object obj : selectedEditParts) {
if (obj instanceof VarNodeEditPart) {
VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
toRemove.add(model);
XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
int index = parentTable.getNodes().indexOf(model);
if (index < minIndex) {
minIndex = index;
}
}
}
parentTable.getNodes().removeAll(toRemove);
if (!tablePart.getChildren().isEmpty()) {
if (minIndex > tablePart.getChildren().size() - 1) {
minIndex = tablePart.getChildren().size() - 1;
}
tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
} else {
remove.setEnabled(false);
}
}
});
}
Aggregations