Search in sources :

Example 16 with EditPart

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

the class AbstractTalendEditor method getCommonKeyHandler.

/**
     * DOC qzhang Comment method "getCommonKeyHandler".
     * 
     * @return
     */
public KeyHandler getCommonKeyHandler() {
    if (sharedKeyHandler == null) {
        sharedKeyHandler = new KeyHandler();
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {

            @Override
            public void run() {
                ISelection selection = getGraphicalViewer().getSelection();
                if (selection != null) {
                    if (selection instanceof IStructuredSelection) {
                        Object input = ((IStructuredSelection) selection).getFirstElement();
                        Node node = null;
                        if (input instanceof NodeTreeEditPart) {
                            NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
                            node = (Node) nTreePart.getModel();
                        } else {
                            if (input instanceof NodePart) {
                                EditPart editPart = (EditPart) input;
                                node = (Node) editPart.getModel();
                            }
                        }
                        if (node != null) {
                            String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
                            String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
                                helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            }
                            PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
                        }
                    }
                }
            }
        });
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    // deactivate the F2 shortcut as it's not used anymore
    // sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
    // getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
    }
    return sharedKeyHandler;
}
Also used : ModifyConnectionOrderAction(org.talend.designer.core.ui.action.ModifyConnectionOrderAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ToggleSubjobsAction(org.talend.designer.core.ui.action.ToggleSubjobsAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) Action(org.eclipse.jface.action.Action) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) ISelection(org.eclipse.jface.viewers.ISelection) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) KeyHandler(org.eclipse.gef.KeyHandler)

Example 17 with EditPart

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

the class AbstractTalendEditor method selectPaletteEntry.

private boolean selectPaletteEntry(String componentName, PaletteViewer paletteViewer, List entries) {
    for (Object entry : entries) {
        if (entry instanceof PaletteContainer) {
            PaletteContainer container = (PaletteContainer) entry;
            if (selectPaletteEntry(componentName, paletteViewer, container.getChildren())) {
                return true;
            }
        } else if (entry instanceof TalendPaletteDrawer) {
            TalendPaletteDrawer drawer = (TalendPaletteDrawer) entry;
            if (selectPaletteEntry(componentName, paletteViewer, drawer.getChildren())) {
                return true;
            }
        } else if (entry instanceof ToolEntry) {
            ToolEntry paletteEntry = (ToolEntry) entry;
            if (paletteEntry.getLabel().equals(componentName)) {
                EditPart part = getToolEntryEditPart(paletteViewer, paletteEntry);
                expandPaletteDrawer(paletteViewer, paletteEntry);
                // paletteViewer.setSelection(new StructuredSelection(part));
                // paletteViewer.setFocus(part);
                paletteViewer.select(part);
                paletteViewer.reveal(part);
                paletteViewer.setActiveTool(paletteEntry);
                return true;
            }
        }
    }
    return false;
}
Also used : TalendPaletteDrawer(org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) ToolEntry(org.eclipse.gef.palette.ToolEntry) PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Example 18 with EditPart

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

the class ShowComponentSettingViewerAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true / false
     */
private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return false;
        }
        NodePart part = (NodePart) o;
        if (!(part.getModel() instanceof INode)) {
            return false;
        }
        node = (Node) part.getModel();
        EditPart parentPart = part.getParent();
        while (!(parentPart instanceof ProcessPart)) {
            parentPart = parentPart.getParent();
        }
        if (!(parentPart instanceof ProcessPart)) {
            return false;
        }
        process = (IProcess) ((ProcessPart) parentPart).getModel();
        //$NON-NLS-1$
        setText(Messages.getString("PropertiesContextAction.Properties"));
    }
    return true;
}
Also used : INode(org.talend.core.model.process.INode) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 19 with EditPart

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

the class TalendConnectionCreationTool method selectAddedObject.

protected void selectAddedObject(EditPartViewer viewer, Collection objects) {
    final List editparts = new ArrayList();
    final EditPart[] primaryEP = new EditPart[1];
    for (Iterator i = objects.iterator(); i.hasNext(); ) {
        Object object = i.next();
        if (object instanceof IAdaptable) {
            Object editPart = viewer.getEditPartRegistry().get(((IAdaptable) object).getAdapter(View.class));
            if (editPart instanceof GraphicalEditPart) {
                editparts.add(editPart);
            }
        }
    }
    if (!editparts.isEmpty()) {
        viewer.setSelection(new StructuredSelection(editparts));
        // automatically put the first shape into edit-mode
        Display.getCurrent().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (primaryEP[0] == null) {
                    primaryEP[0] = (EditPart) editparts.get(0);
                }
                // code is being executed. (see RATLC00527114)
                if (primaryEP[0].isActive()) {
                    primaryEP[0].performRequest(new Request("direct edit"));
                }
            }
        });
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Request(org.eclipse.gef.Request) View(org.eclipse.gmf.runtime.notation.View) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 20 with EditPart

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

the class TalendCreateConnectionTool method handleButtonUp.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.tools.AbstractConnectionCreationTool#handleButtonUp(int)
     */
@Override
protected boolean handleButtonUp(int button) {
    if (button == 1 && stateTransition(STATE_CONNECTION_STARTED, STATE_TERMINAL)) {
        if (getTargetEditPart() == null) {
            EditPart processPart = getProcessPart(this.sourcePart);
            if (processPart != null) {
                this.setTargetEditPart(getProcessPart(this.sourcePart));
                this.getTargetRequest().setType(RequestConstants.REQ_CONNECTION_END);
            }
        }
        return handleConnection();
    }
    super.handleButtonDown(button);
    if (isInState(STATE_CONNECTION_STARTED)) {
        // Fake a drag to cause feedback to be displayed immediately on
        // mouse down.
        handleDrag();
    }
    return true;
}
Also used : EditPart(org.eclipse.gef.EditPart)

Aggregations

EditPart (org.eclipse.gef.EditPart)291 List (java.util.List)58 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)55 ArrayList (java.util.ArrayList)51 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)27 Point (org.eclipse.draw2d.geometry.Point)26 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)26 Test (org.junit.Test)26 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)21 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)21 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 Iterator (java.util.Iterator)18 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)13