Search in sources :

Example 1 with EditPartViewer

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

the class TalendConnectionCreationTool method handleConnection.

protected boolean handleConnection() {
    setAvoidDeactivation(true);
    EditPartViewer viewer = getCurrentViewer();
    Command endCommand = getCommand();
    if (endCommand == null) {
        if (isInState(STATE_TERMINAL)) {
            // Fake a drag to cause feedback to be displayed immediately on mouse down.
            setState(STATE_CONNECTION_STARTED);
            handleDrag();
        }
        return true;
    }
    sourcePart.getViewer().getSelectionManager().deselect(sourcePart);
    setCurrentCommand(endCommand);
    executeCurrentCommand();
    selectAddedObject(viewer, getReturnValues(endCommand));
    setAvoidDeactivation(false);
    getSourceRequest().setType(RequestConstants.REQ_CONNECTION_END);
    eraseSourceFeedback();
    deactivate();
    return true;
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) EditPartViewer(org.eclipse.gef.EditPartViewer)

Example 2 with EditPartViewer

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

the class MapperSelectEditPartTracker method performSelection.

@Override
protected void performSelection() {
    if (hasSelectionOccurred()) {
        return;
    }
    setFlag(FLAG_SELECTION_PERFORMED, true);
    EditPartViewer viewer = getCurrentViewer();
    List selectedObjects = viewer.getSelectedEditParts();
    if (getCurrentInput().isModKeyDown(SWT.MOD1)) {
        lastSelectedShiftPart = null;
        if (selectedObjects.contains(getSourceEditPart())) {
            viewer.deselect(getSourceEditPart());
        } else if (canAppend()) {
            viewer.appendSelection(getSourceEditPart());
        } else {
            viewer.select(getSourceEditPart());
        }
    } else if (getCurrentInput().isShiftKeyDown()) {
        if (lastSelectedShiftPart == null) {
            if (!selectedObjects.isEmpty()) {
                Object object = selectedObjects.get(selectedObjects.size() - 1);
                if (object instanceof TableEntityPart) {
                    lastSelectedShiftPart = (EditPart) object;
                }
            } else {
                lastSelectedShiftPart = getSourceEditPart();
            }
        }
        if (canAppend()) {
            List<EditPart> toselect = new ArrayList<EditPart>();
            List<EditPart> deSelect = new ArrayList<EditPart>();
            getShiftAffactedEditPart(toselect, deSelect);
            for (EditPart part : deSelect) {
                viewer.deselect(part);
            }
            for (EditPart part : toselect) {
                if (!viewer.getSelectedEditParts().contains(part)) {
                    viewer.appendSelection(part);
                }
            }
        } else {
            viewer.select(getSourceEditPart());
        }
    } else {
        lastSelectedShiftPart = null;
        viewer.select(getSourceEditPart());
    }
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) EditPart(org.eclipse.gef.EditPart) EditPartViewer(org.eclipse.gef.EditPartViewer) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with EditPartViewer

use of org.eclipse.gef.EditPartViewer in project cubrid-manager by CUBRID.

the class SchemaContextMenuProvider method buildContextMenu.

@Override
public void buildContextMenu(IMenuManager menu) {
    if (!(menu instanceof SchemaContextMenuProvider)) {
        return;
    }
    SchemaContextMenuProvider menuProvider = (SchemaContextMenuProvider) menu;
    EditPartViewer viewer = menuProvider.getViewer();
    if (viewer == null) {
        return;
    }
    buildPublicMenuItems(menu);
    List selectParts = viewer.getSelectedEditParts();
    // blank right-click
    if (selectParts == null || selectParts.size() == 0) {
        return;
    }
    // multi-objects right-click
    if (selectParts.size() > 1) {
        buildMultiFiguresMenuItems(menu);
        return;
    }
    // one object right-click
    Object object = selectParts.get(0);
    if (object instanceof TablePart) {
        buildTableMenuItems(menu);
    } else if (object instanceof ColumnPart) {
        buildColumnMenuItems(menu);
    } else if (object instanceof RelationshipPart) {
        buildRelationshipLineMenuItems(menu);
    }
}
Also used : RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) TablePart(com.cubrid.common.ui.er.part.TablePart) EditPartViewer(org.eclipse.gef.EditPartViewer) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) List(java.util.List)

Example 4 with EditPartViewer

use of org.eclipse.gef.EditPartViewer in project cubrid-manager by CUBRID.

the class SchemaDiagramPart method getEditor.

public ERSchemaEditor getEditor() {
    EditPart parentP = getParent();
    if (parentP instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart parentEditor = (ScalableFreeformRootEditPart) parentP;
        EditPartViewer viewer = parentEditor.getViewer();
        if (viewer instanceof ValidationGraphicalViewer) {
            ValidationGraphicalViewer gViewer = (ValidationGraphicalViewer) viewer;
            EditDomain domain = gViewer.getEditDomain();
            if (domain instanceof ERSchemaEditDomain) {
                ERSchemaEditDomain erEditorDomain = (ERSchemaEditDomain) domain;
                return (ERSchemaEditor) erEditorDomain.getEditorPart();
            }
        }
    }
    return null;
}
Also used : ValidationGraphicalViewer(com.cubrid.common.ui.er.ValidationGraphicalViewer) EditDomain(org.eclipse.gef.EditDomain) ERSchemaEditDomain(com.cubrid.common.ui.er.editor.ERSchemaEditDomain) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ERSchemaEditor(com.cubrid.common.ui.er.editor.ERSchemaEditor) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) EditPart(org.eclipse.gef.EditPart) ERSchemaEditDomain(com.cubrid.common.ui.er.editor.ERSchemaEditDomain) EditPartViewer(org.eclipse.gef.EditPartViewer)

Example 5 with EditPartViewer

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

the class XmlDropTargetListener method selectAddedObject.

private void selectAddedObject() {
    boolean added = false;
    List newObjects = getCreateRequest().getNewObjects();
    for (int i = 0; i < newObjects.size(); i++) {
        Object model = newObjects.get(i);
        EditPartViewer viewer = getViewer();
        viewer.getControl().forceFocus();
        Object editpart = viewer.getEditPartRegistry().get(model);
        if (editpart instanceof EditPart) {
            if (!added) {
                // Force a layout first.
                getViewer().flush();
                viewer.select((EditPart) editpart);
                added = true;
            } else {
                viewer.appendSelection((EditPart) editpart);
            }
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart) EditPartViewer(org.eclipse.gef.EditPartViewer) List(java.util.List) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

EditPartViewer (org.eclipse.gef.EditPartViewer)5 List (java.util.List)3 EditPart (org.eclipse.gef.EditPart)3 ValidationGraphicalViewer (com.cubrid.common.ui.er.ValidationGraphicalViewer)1 ERSchemaEditDomain (com.cubrid.common.ui.er.editor.ERSchemaEditDomain)1 ERSchemaEditor (com.cubrid.common.ui.er.editor.ERSchemaEditor)1 ColumnPart (com.cubrid.common.ui.er.part.ColumnPart)1 RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)1 TablePart (com.cubrid.common.ui.er.part.TablePart)1 ArrayList (java.util.ArrayList)1 Point (org.eclipse.draw2d.geometry.Point)1 EditDomain (org.eclipse.gef.EditDomain)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)1 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)1 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)1