Search in sources :

Example 1 with AbstractEditPart

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

the class AbstractTalendEditor method setFocus.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.parts.GraphicalEditor#setFocus()
     */
@Override
public void setFocus() {
    IComponentSettingsView viewer = (IComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
    if (viewer != null) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (selection.size() == 1 && (selection.getFirstElement() instanceof NodePart || selection.getFirstElement() instanceof ConnectionPart || selection.getFirstElement() instanceof SubjobContainerPart || selection.getFirstElement() instanceof ConnLabelEditPart)) {
            viewer.setElement((Element) ((AbstractEditPart) selection.getFirstElement()).getModel());
        } else {
            viewer.cleanDisplay();
        }
    }
    JobSettings.switchToCurJobSettingsView();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
        ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
        if (testContainerService != null) {
            testContainerService.switchToCurTestContainerView();
        }
    }
    super.setFocus();
    if (!readOnly) {
        // When gain focus, check read-only to disable read-only mode if process has been restore while opened :
        // 1. Enabled/disabled components :
        // process.checkReadOnly();
        // 2. Set backgroung color :
        List children = getViewer().getRootEditPart().getChildren();
        if (!children.isEmpty()) {
            ProcessPart rep = (ProcessPart) children.get(0);
            rep.ajustReadOnly();
        }
    }
}
Also used : IComponentSettingsView(org.talend.core.views.IComponentSettingsView) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService)

Example 2 with AbstractEditPart

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

the class ClipboardActionHandler method saveCut.

private void saveCut(ISelection object) {
    cutItemIds = new HashMap();
    if (object instanceof IStructuredSelection) {
        for (Object obj : ((IStructuredSelection) object).toList()) {
            if (obj instanceof AbstractEditPart) {
                AbstractEditPart editPart = (AbstractEditPart) obj;
                EObject element = ((View) editPart.getModel()).getElement();
                if (element instanceof BusinessItem) {
                    BusinessItem businessItem = (BusinessItem) element;
                    List assignments = new ArrayList();
                    for (Object assignment : businessItem.getAssignments()) {
                        BusinessAssignment ba = (BusinessAssignment) assignment;
                        TalendItem item = ba.getTalendItem();
                        if (item != null) {
                            assignments.add(item.getId());
                        }
                    }
                    cutItemIds.put(businessItem, assignments);
                }
            }
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) HashMap(java.util.HashMap) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendItem(org.talend.designer.business.model.business.TalendItem) View(org.eclipse.gmf.runtime.notation.View) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 3 with AbstractEditPart

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

the class ClipboardActionHandler method transfer.

private void transfer(ISelection object) {
    if (object instanceof IStructuredSelection) {
        List<BusinessItem> selections = new ArrayList();
        for (Object obj : ((IStructuredSelection) object).toList()) {
            if (obj instanceof AbstractEditPart) {
                AbstractEditPart editPart = (AbstractEditPart) obj;
                EObject element = ((View) editPart.getModel()).getElement();
                if (element instanceof BusinessItem) {
                    selections.add((BusinessItem) element);
                }
            }
        }
        TemplateTransfer.getInstance().setObject(selections);
    }
}
Also used : AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) View(org.eclipse.gmf.runtime.notation.View) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 4 with AbstractEditPart

use of org.eclipse.gef.editparts.AbstractEditPart in project knime-core by knime.

the class NewWorkflowContainerEditPolicy method handleNodeDrop.

/**
 * @param manager the workflow manager
 * @param factory the ndoe factory
 * @param request the drop request
 */
private Command handleNodeDrop(final WorkflowManager manager, final NodeFactory<? extends NodeModel> factory, final CreateDropRequest request) {
    RequestType requestType = request.getRequestType();
    Point location = request.getLocation();
    boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
    if (requestType.equals(RequestType.CREATE)) {
        // create a new node
        return new CreateNodeCommand(manager, factory, location, snapToGrid);
    } else {
        AbstractEditPart editPart = request.getEditPart();
        if (requestType.equals(RequestType.INSERT)) {
            // insert new node into connection
            InsertNodeCommand insertCommand = new InsertNodeCommand(manager, factory, location, snapToGrid, (ConnectionContainerEditPart) editPart);
            if (request.createSpace()) {
                CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
                return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
            } else {
                return insertCommand;
            }
        } else if (requestType.equals(RequestType.REPLACE)) {
            // replace node with a node
            return new ReplaceNodeCommand(manager, factory, location, snapToGrid, (NodeContainerEditPart) editPart);
        } else {
            return null;
        }
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) ReplaceNodeCommand(org.knime.workbench.editor2.commands.ReplaceNodeCommand) Point(org.eclipse.draw2d.geometry.Point) CreateNodeCommand(org.knime.workbench.editor2.commands.CreateNodeCommand) InsertNodeCommand(org.knime.workbench.editor2.commands.InsertNodeCommand) CreateSpaceAction(org.knime.workbench.editor2.actions.CreateSpaceAction) RequestType(org.knime.workbench.editor2.CreateDropRequest.RequestType)

Example 5 with AbstractEditPart

use of org.eclipse.gef.editparts.AbstractEditPart in project knime-core by knime.

the class NewWorkflowContainerEditPolicy method handleMetaNodeTemplateDrop.

/**
 * @param manager the workflow manager
 * @param request the drop request
 * @param filestore the location of the metanode template
 */
private Command handleMetaNodeTemplateDrop(final WorkflowManager manager, final CreateDropRequest request, final AbstractExplorerFileStore filestore) {
    RequestType requestType = request.getRequestType();
    Point location = request.getLocation();
    boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
    if (requestType.equals(RequestType.CREATE)) {
        // create metanode from template
        return new CreateMetaNodeTemplateCommand(manager, filestore, location, snapToGrid);
    } else {
        AbstractEditPart editPart = request.getEditPart();
        if (requestType.equals(RequestType.INSERT)) {
            // insert metanode from template into connection
            InsertMetaNodeTempalteCommand insertCommand = new InsertMetaNodeTempalteCommand(manager, filestore, location, snapToGrid, (ConnectionContainerEditPart) editPart);
            if (request.createSpace()) {
                CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
                return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
            } else {
                return insertCommand;
            }
        } else if (requestType.equals(RequestType.REPLACE)) {
            // replace node with metanode from template
            return new ReplaceMetaNodeTemplateCommand(manager, filestore, location, snapToGrid, (NodeContainerEditPart) editPart);
        } else {
            return null;
        }
    }
}
Also used : ReplaceMetaNodeTemplateCommand(org.knime.workbench.editor2.commands.ReplaceMetaNodeTemplateCommand) CreateMetaNodeTemplateCommand(org.knime.workbench.editor2.commands.CreateMetaNodeTemplateCommand) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) Point(org.eclipse.draw2d.geometry.Point) InsertMetaNodeTempalteCommand(org.knime.workbench.editor2.commands.InsertMetaNodeTempalteCommand) CreateSpaceAction(org.knime.workbench.editor2.actions.CreateSpaceAction) RequestType(org.knime.workbench.editor2.CreateDropRequest.RequestType)

Aggregations

AbstractEditPart (org.eclipse.gef.editparts.AbstractEditPart)6 ArrayList (java.util.ArrayList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 List (java.util.List)2 Point (org.eclipse.draw2d.geometry.Point)2 EObject (org.eclipse.emf.ecore.EObject)2 View (org.eclipse.gmf.runtime.notation.View)2 RequestType (org.knime.workbench.editor2.CreateDropRequest.RequestType)2 CreateSpaceAction (org.knime.workbench.editor2.actions.CreateSpaceAction)2 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)2 BusinessItem (org.talend.designer.business.model.business.BusinessItem)2 HashMap (java.util.HashMap)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 CreateMetaNodeTemplateCommand (org.knime.workbench.editor2.commands.CreateMetaNodeTemplateCommand)1 CreateNodeCommand (org.knime.workbench.editor2.commands.CreateNodeCommand)1 InsertMetaNodeTempalteCommand (org.knime.workbench.editor2.commands.InsertMetaNodeTempalteCommand)1 InsertNodeCommand (org.knime.workbench.editor2.commands.InsertNodeCommand)1 ReplaceMetaNodeTemplateCommand (org.knime.workbench.editor2.commands.ReplaceMetaNodeTemplateCommand)1 ReplaceNodeCommand (org.knime.workbench.editor2.commands.ReplaceNodeCommand)1