use of org.talend.designer.xmlmap.figures.treetools.VarToolBarFigure 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);
}
Aggregations