use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.
the class MapperSelectEditPartTracker method canAppend.
private boolean canAppend() {
if (getSourceEditPart() instanceof TableEntityPart) {
EditPart lastPart = lastSelectedShiftPart;
List selectedEditParts = getCurrentViewer().getSelectedEditParts();
if (lastPart == null && !selectedEditParts.isEmpty()) {
lastPart = (EditPart) selectedEditParts.get(selectedEditParts.size() - 1);
}
if (lastPart == null) {
return true;
} else if (lastPart instanceof TableEntityPart) {
MapperTablePart lastContaier = MapperUtils.getMapperTablePart((TableEntityPart) lastPart);
MapperTablePart toAppendContaier = MapperUtils.getMapperTablePart((TableEntityPart) getSourceEditPart());
if (lastContaier == toAppendContaier) {
return true;
}
}
}
lastSelectedShiftPart = null;
return false;
}
use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.
the class MapperUtils method getFlatChildrenPartList.
public static List<TableEntityPart> getFlatChildrenPartList(MapperTablePart treePart) {
List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
List children = treePart.getChildren();
for (int i = 0; i < children.size(); i++) {
partList.add((TableEntityPart) children.get(i));
partList.addAll(getFlatChildrenPartList((TableEntityPart) children.get(i)));
}
return partList;
}
use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.
the class MapperUtils method getFlatChildrenPartList.
private static List<TableEntityPart> getFlatChildrenPartList(TableEntityPart treeNode) {
List<TableEntityPart> list = new ArrayList<TableEntityPart>();
List children = treeNode.getChildren();
for (int i = 0; i < children.size(); i++) {
if (children.get(i) instanceof TableEntityPart) {
TableEntityPart child = (TableEntityPart) children.get(i);
list.add(child);
if (!child.getChildren().isEmpty()) {
list.addAll(getFlatChildrenPartList(child));
}
}
}
return list;
}
use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.
the class XmlDragSourceListener method getTemplate.
/**
*
* DOC talend Comment method "getTemplate".
*
* @param event
* @return the validate drag able node list
*/
@Override
protected Object getTemplate(DragSourceEvent event) {
final RootEditPart rootEditPart = getViewer().getRootEditPart();
if (rootEditPart instanceof AbstractGraphicalEditPart) {
AbstractGraphicalEditPart graphicPart = (AbstractGraphicalEditPart) rootEditPart;
final IFigure figure = graphicPart.getFigure();
final IFigure findFigureAt = figure.findFigureAt(new Point(event.x, event.y));
if (findFigureAt instanceof ISash) {
return findFigureAt;
}
}
List<EditPart> filtedSelection = new ArrayList<EditPart>();
for (Object part : getViewer().getSelectedEditParts()) {
if (part instanceof TreeNodeEditPart || part instanceof VarNodeEditPart) {
filtedSelection.add((EditPart) part);
}
}
if (filtedSelection == null || filtedSelection.isEmpty()) {
return null;
}
List toTransfer = new ArrayList();
TransferdType type = null;
List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
EditPart lastSelection = filtedSelection.get(filtedSelection.size() - 1);
if (lastSelection instanceof TreeNodeEditPart && !(lastSelection instanceof OutputTreeNodeEditPart)) {
type = TransferdType.INPUT;
} else if (lastSelection instanceof VarNodeEditPart) {
type = TransferdType.VAR;
}
if (type != null) {
if (filtedSelection.size() > 1) {
partList.addAll(lastSelection.getParent().getChildren());
Map<EditPart, Integer> partAndIndex = new HashMap<EditPart, Integer>();
if (type == TransferdType.INPUT) {
for (EditPart treePart : filtedSelection) {
if (!XmlMapUtil.isDragable((TreeNode) treePart.getModel())) {
return null;
}
}
MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
if (abstractInOutTreePart != null) {
partList = MapperUtils.getFlatChildrenPartList(abstractInOutTreePart);
}
} else {
partList.addAll(lastSelection.getParent().getChildren());
}
for (EditPart selected : filtedSelection) {
int indexOf = partList.indexOf(selected);
if (indexOf != -1) {
partAndIndex.put(selected, indexOf);
int index = 0;
for (int i = 0; i < toTransfer.size(); i++) {
if (indexOf > partAndIndex.get(toTransfer.get(i))) {
index = i + 1;
}
}
toTransfer.add(index, selected);
}
}
} else {
if (lastSelection.getModel() instanceof TreeNode && !XmlMapUtil.isDragable((TreeNode) lastSelection.getModel())) {
return null;
}
toTransfer.add(lastSelection);
}
return new TransferedObject(toTransfer, type);
}
return null;
}
use of org.talend.designer.gefabstractmap.part.TableEntityPart in project tdi-studio-se by Talend.
the class FiguresManager method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
mapDataEditPart = (MapperRootEditPart) graphicViewer.getContents();
if (getRootEditPart() == null) {
return;
}
List selectedEditParts = graphicViewer.getSelectedEditParts();
if (selectedEditParts.isEmpty()) {
return;
}
boolean outputRemoveEnable = false;
boolean outputMoveUp = false;
boolean outputMoveDown = false;
boolean inputMoveUp = false;
boolean inputMoveDown = false;
List<MapperTable> outputTrees = getOutputTables();
List<MapperTable> inputTrees = getInputTables();
OutputZoneToolBar outputToolBar = mapDataEditPart.getOutputZoneToolBar();
InputZoneToolBar inputToolBar = mapDataEditPart.getInputZoneToolBar();
boolean selectNode = false;
Object lastSelection = selectedEditParts.get(selectedEditParts.size() - 1);
if (lastSelection instanceof TableEntityPart) {
selectNode = true;
MapperTablePart findTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
if (findTreePart instanceof InputTablePart) {
currentSelectedInputTable = (InputTablePart) findTreePart;
} else if (findTreePart instanceof OutputTablePart) {
currentSelectedOutputTable = (OutputTablePart) findTreePart;
}
// only change connection figures for nodes in the same tree as the lastSelection
List<TableEntityPart> nodes = new ArrayList<TableEntityPart>();
for (int i = 0; i < selectedEditParts.size() - 1; i++) {
Object obj = selectedEditParts.get(i);
if (obj instanceof TableEntityPart) {
MapperTablePart findOtherTreePart = MapperUtils.getMapperTablePart((TableEntityPart) obj);
if (findOtherTreePart == findTreePart) {
nodes.add((TableEntityPart) obj);
}
}
}
nodes.add((TableEntityPart) lastSelection);
onTreeSelected(nodes, findTreePart);
// change color for other unselected node in the tree;
} else if (lastSelection instanceof OutputTablePart) {
currentSelectedOutputTable = (OutputTablePart) lastSelection;
onTreeSelected(currentSelectedOutputTable.getChildren(), currentSelectedOutputTable);
} else if (lastSelection instanceof InputTablePart) {
currentSelectedInputTable = (InputTablePart) lastSelection;
onTreeSelected(currentSelectedInputTable.getChildren(), currentSelectedInputTable);
}
if (currentSelectedOutputTable != null) {
MapperTable model = (MapperTable) currentSelectedOutputTable.getModel();
if (!isErrorRejectTable(model)) {
outputRemoveEnable = true;
}
int index = outputTrees.indexOf(model);
if (index != -1 && index != 0) {
if (index != 1 || !isErrorRejectTable(outputTrees.get(0))) {
outputMoveUp = true;
}
}
if (index != -1 && index != outputTrees.size() - 1) {
if (!isErrorRejectTable(model)) {
outputMoveDown = true;
}
}
}
outputToolBar.setRemoveButtonEnable(outputRemoveEnable);
outputToolBar.setMoveUpEnable(outputMoveUp);
outputToolBar.setMoveDownEnable(outputMoveDown);
if (currentSelectedInputTable != null) {
MapperTable tree = (MapperTable) currentSelectedInputTable.getModel();
if (!isLookup(tree)) {
inputMoveUp = false;
inputMoveDown = false;
} else {
int indexOf = inputTrees.indexOf(tree);
if (indexOf != -1 && indexOf > 1) {
inputMoveUp = true;
}
if (indexOf > 0 && indexOf != inputTrees.size() - 1) {
inputMoveDown = true;
}
}
}
inputToolBar.setMoveDownEnable(inputMoveDown);
inputToolBar.setMoveUpEnable(inputMoveUp);
}
Aggregations