Search in sources :

Example 91 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class MapperGraphicalEditor method makeDefaultSelection.

public void makeDefaultSelection() {
    EditPart contents = getGraphicalViewer().getContents();
    if (contents instanceof MapperRootEditPart) {
        MapperRootEditPart mapdataPart = (MapperRootEditPart) contents;
        List children = mapdataPart.getChildren();
        InputTablePart firstInputPart = null;
        OutputTablePart firstOutputPart = null;
        if (children != null) {
            for (int i = 0; i < children.size(); i++) {
                Object object = children.get(i);
                if (object instanceof InputTablePart && firstInputPart == null) {
                    firstInputPart = (InputTablePart) object;
                }
                if (object instanceof OutputTablePart && firstOutputPart == null) {
                    firstOutputPart = (OutputTablePart) object;
                }
                if (firstInputPart != null && firstOutputPart != null) {
                    break;
                }
            }
            if (firstInputPart != null) {
                getGraphicalViewer().appendSelection(firstInputPart);
            }
            if (firstOutputPart != null) {
                getGraphicalViewer().appendSelection(firstOutputPart);
            }
        }
    }
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) EventObject(java.util.EventObject) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart)

Example 92 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class MapperGraphicalViewer method primDeselectAll.

/*
     * if partToAppend is inputTree , don't clean all outputTree in selection list , leave the first one by default . if
     * partToAppend is outputTree , do the same for inputTree selections
     */
private void primDeselectAll(EditPart eidtPart) {
    EditPart partToAppend = eidtPart;
    List list = primGetSelectedEditParts();
    if (partToAppend instanceof TableEntityPart) {
        partToAppend = MapperUtils.getMapperTablePart((TableEntityPart) partToAppend);
    }
    EditPart part;
    MapperTablePart abstractTreePart = null;
    for (int i = 0; i < list.size(); i++) {
        part = (EditPart) list.get(i);
        if (partToAppend instanceof InputTablePart) {
            if (abstractTreePart == null && part instanceof OutputTablePart) {
                abstractTreePart = (MapperTablePart) part;
                continue;
            }
        } else if (partToAppend instanceof OutputTablePart) {
            if (abstractTreePart == null && part instanceof InputTablePart) {
                abstractTreePart = (MapperTablePart) part;
                continue;
            }
        }
        part.setSelected(EditPart.SELECTED_NONE);
    }
    list.clear();
    if (abstractTreePart != null) {
        list.add(abstractTreePart);
    }
}
Also used : OutputTablePart(org.talend.designer.gefabstractmap.part.OutputTablePart) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart)

Example 93 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class MapperGraphicalViewer method findFigureAt.

public IFigure findFigureAt(int x, int y, Collection exclude, final Conditional condition) {
    class ConditionalTreeSearch extends ExclusionSearch {

        ConditionalTreeSearch(Collection coll) {
            super(coll);
        }

        @Override
        public boolean accept(IFigure figure) {
            EditPart editpart = null;
            while (editpart == null && figure != null) {
                editpart = (EditPart) getVisualPartMap().get(figure);
                figure = figure.getParent();
            }
            return editpart != null && (condition == null || condition.evaluate(editpart));
        }
    }
    return getLightweightSystem().getRootFigure().findFigureAt(x, y, new ConditionalTreeSearch(exclude));
}
Also used : MapperRootEditPart(org.talend.designer.gefabstractmap.part.MapperRootEditPart) EditPart(org.eclipse.gef.EditPart) Collection(java.util.Collection) ExclusionSearch(org.eclipse.draw2d.ExclusionSearch) IFigure(org.eclipse.draw2d.IFigure)

Example 94 with EditPart

use of org.eclipse.gef.EditPart 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;
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ArrayList(java.util.ArrayList) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart)

Example 95 with EditPart

use of org.eclipse.gef.EditPart in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
@SuppressWarnings("unchecked")
public void selectNode(String nodeName) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        // ProcessPart < SubjobContainerPart < NodeContainerPart < NodePart
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof SubjobContainerPart) {
                SubjobContainerPart subjobPart = (SubjobContainerPart) editPart;
                for (EditPart part : (List<EditPart>) subjobPart.getChildren()) {
                    if (part instanceof NodeContainerPart) {
                        EditPart nodePart = (EditPart) part.getChildren().get(0);
                        if (nodePart instanceof NodePart) {
                            if (((Node) ((NodePart) nodePart).getModel()).getLabel().equals(nodeName)) {
                                viewer.select(nodePart);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

EditPart (org.eclipse.gef.EditPart)132 List (java.util.List)50 ArrayList (java.util.ArrayList)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)26 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 Point (org.eclipse.draw2d.geometry.Point)17 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 Command (org.eclipse.gef.commands.Command)16 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)15 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 RootEditPart (org.eclipse.gef.RootEditPart)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)10 INode (org.talend.core.model.process.INode)10