Search in sources :

Example 16 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class GEFCopyAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    List objects = GEFDeleteAction.filterSameObject(getSelectedObjects());
    if (!objects.isEmpty()) {
        Clipboard clipboard = Clipboard.getDefault();
        org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
        boolean noteTextActived = false;
        boolean connectionTextActived = false;
        boolean nodeLabelActived = false;
        Text text = null;
        if (objects.size() == 1) {
            if (objects.get(0) instanceof NoteEditPart) {
                NoteDirectEditManager directEditManager = ((NoteEditPart) objects.get(0)).getDirectEditManager();
                if (directEditManager != null && directEditManager.getCellEditor() != null) {
                    noteTextActived = true;
                }
            } else if (objects.get(0) instanceof ConnLabelEditPart) {
                ConnLabelEditPart connLabelEditPart = (ConnLabelEditPart) objects.get(0);
                if (connLabelEditPart.getDirectEditManager() != null && connLabelEditPart.getDirectEditManager().getTextControl() != null) {
                    connectionTextActived = true;
                }
            } else if (objects.get(0) instanceof NodeLabelEditPart) {
                NodeLabelEditPart nodeLabelEditPart = (NodeLabelEditPart) objects.get(0);
                if (nodeLabelEditPart.getDirectEditManager() != null && nodeLabelEditPart.getDirectEditManager().getCellEditor() != null) {
                    nodeLabelActived = true;
                }
            }
        }
        if (noteTextActived) {
            text = ((NoteEditPart) objects.get(0)).getDirectEditManager().getTextControl();
            clipboard.setContents(text.getSelectionText());
        } else if (connectionTextActived) {
            text = ((ConnLabelEditPart) objects.get(0)).getDirectEditManager().getTextControl();
            clipboard.setContents(text.getSelectionText());
        } else if (nodeLabelActived) {
            text = (Text) ((NodeLabelEditPart) objects.get(0)).getDirectEditManager().getCellEditor().getControl();
            clipboard.setContents(text.getSelectionText());
        } else {
            clipboard.setContents(objects);
        }
        if (text != null && !("").equals(text.getSelectionText())) {
            TextTransfer textTransfer = TextTransfer.getInstance();
            Transfer[] transfers = new Transfer[] { textTransfer };
            Object[] data = new Object[] { text.getSelectionText() };
            systemClipboard.setContents(data, transfers);
        }
    }
    // Refreshes the pasteAction's enable status.
    IWorkbenchPart part = getWorkbenchPart();
    if (part instanceof AbstractTalendEditor) {
        AbstractTalendEditor talendEditor = (AbstractTalendEditor) part;
        IAction action = talendEditor.getActionRegistry().getAction(ActionFactory.PASTE.getId());
        action.setEnabled(true);
    }
}
Also used : NoteDirectEditManager(org.talend.designer.core.ui.editor.notes.NoteDirectEditManager) IAction(org.eclipse.jface.action.IAction) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Text(org.eclipse.swt.widgets.Text) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) List(java.util.List) Clipboard(org.eclipse.gef.ui.actions.Clipboard) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 17 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class NodePartKeyHander method navigateTo.

@Override
protected void navigateTo(EditPart part, KeyEvent event) {
    // PTODO need be removed
    SubjobContainerPart subPart = null;
    NoteEditPart noPart = null;
    boolean displayVa = true;
    if (part instanceof SubjobContainerPart) {
        // NodeContainerPart
        SubjobContainerPart focusPart = (SubjobContainerPart) part;
        List subList = focusPart.getParent().getChildren();
        for (int j = 0; j < subList.size(); j++) {
            if (subList.get(j) instanceof SubjobContainerPart) {
                subPart = (SubjobContainerPart) subList.get(j);
                SubjobContainer subContainer = (SubjobContainer) subPart.getModel();
                if (subContainer.isDisplayed() == false) {
                    displayVa = false;
                }
            } else if (subList.get(j) instanceof NoteEditPart) {
                displayVa = false;
            }
        }
        if (displayVa == false) {
            part = (EditPart) part.getChildren().get(0);
            if (part != null) {
                // NodePart
                part = (EditPart) part.getChildren().get(0);
            }
            if (part == null) {
                return;
            }
        }
    }
    super.navigateTo(part, event);
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) List(java.util.List) ArrayList(java.util.ArrayList) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 18 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class PartFactory method createEditPart.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
     */
@Override
public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof SubjobContainer) {
        part = new SubjobContainerPart();
    } else if (model instanceof Process) {
        part = new ProcessPart();
    } else if (model instanceof Node) {
        part = new NodePart();
    } else if (model instanceof Connection) {
        part = new ConnectionPart();
    } else if (model instanceof ConnectionLabel) {
        part = new ConnLabelEditPart();
    } else if (model instanceof MonitorConnectionLabel) {
        part = new MonitorConnectionLabelPart();
    } else if (model instanceof ConnectionPerformance) {
        part = new ConnectionPerformanceEditPart();
    } else if (model instanceof ConnectionTrace) {
        part = new ConnectionTraceEditPart();
    } else if (model instanceof ConnectionResuming) {
        part = new ConnectionResumingEditPart();
    } else if (model instanceof NodeLabel) {
        part = new NodeLabelEditPart();
    } else if (model instanceof NodeContainer) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
            ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
            if (testContainerService != null) {
                part = testContainerService.createEditorPart(model);
                if (part != null) {
                    part.setModel(model);
                    return part;
                }
            }
        }
        if (((NodeContainer) model).getNode().isSparkJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
                ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
                ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isStandardJoblet()) {
            part = new JobletContainerPart();
        } else if (((NodeContainer) model).getNode().isMapReduce()) {
            part = new JobletContainerPart();
        } else {
            part = new NodeContainerPart();
        }
    } else if (model instanceof Note) {
        part = new NoteEditPart();
    } else if (model instanceof NodeError) {
        part = new NodeErrorEditPart();
    } else if (model instanceof NodeProgressBar) {
        part = new NodeProgressBarPart();
    } else {
        return null;
    }
    // tell the newly created part about the model object
    part.setModel(model);
    return part;
}
Also used : NodeError(org.talend.designer.core.ui.editor.nodes.NodeError) NodeProgressBar(org.talend.designer.core.ui.editor.nodes.NodeProgressBar) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeProgressBarPart(org.talend.designer.core.ui.editor.nodes.NodeProgressBarPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ConnectionResuming(org.talend.designer.core.ui.editor.connections.ConnectionResuming) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) ITestContainerGEFService(org.talend.designer.core.ITestContainerGEFService) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ISparkJobletProviderService(org.talend.core.ui.ISparkJobletProviderService) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnectionPerformance(org.talend.designer.core.ui.editor.connections.ConnectionPerformance) ConnectionTrace(org.talend.designer.core.ui.editor.connections.ConnectionTrace) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) ISparkStreamingJobletProviderService(org.talend.core.ui.ISparkStreamingJobletProviderService) Note(org.talend.designer.core.ui.editor.notes.Note) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) MonitorConnectionLabelPart(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabelPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 19 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class TalendSelectionManager method filterSelection.

private StructuredSelection filterSelection(StructuredSelection selection) {
    List newSelection = new ArrayList(selection.toList());
    for (Object element : selection.toArray()) {
        if (element instanceof SubjobContainerPart) {
            // childrens are NodeContainer part
            newSelection.remove(element);
            List<NodeContainerPart> nodeContainerParts = ((SubjobContainerPart) element).getChildren();
            for (NodeContainerPart nodeContainerPart : nodeContainerParts) {
                for (Object object : nodeContainerPart.getChildren()) {
                    if (object instanceof NodePart) {
                        if (!newSelection.contains(object)) {
                            newSelection.add(object);
                        }
                    }
                }
            }
        } else if (element instanceof NoteEditPart) {
            if (!newSelection.contains(element)) {
                newSelection.add(element);
            }
        } else if (!(element instanceof NodePart)) {
            newSelection.remove(element);
        }
    }
    StructuredSelection newList = new StructuredSelection(newSelection);
    return newList;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) ArrayList(java.util.ArrayList) List(java.util.List) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 20 with NoteEditPart

use of org.talend.designer.core.ui.editor.notes.NoteEditPart in project tdi-studio-se by Talend.

the class NotesPasteCommand method orderNoteParts.

private void orderNoteParts(List<NoteEditPart> noteParts) {
    this.noteParts = new ArrayList<NoteEditPart>();
    Point curLocation;
    NoteEditPart toAdd = null;
    List<NoteEditPart> restToOrder = new ArrayList<NoteEditPart>();
    restToOrder.addAll(noteParts);
    for (NoteEditPart copiedNodePart : noteParts) {
        curLocation = null;
        for (NoteEditPart partToOrder : restToOrder) {
            Note copiedNote = (Note) partToOrder.getModel();
            if (curLocation == null) {
                curLocation = copiedNote.getLocation();
                toAdd = partToOrder;
            } else {
                if (curLocation.y >= copiedNote.getLocation().y) {
                    if (curLocation.x >= copiedNote.getLocation().x) {
                        curLocation = copiedNote.getLocation();
                        toAdd = partToOrder;
                    }
                }
            }
        }
        if (toAdd != null) {
            this.noteParts.add(toAdd);
            restToOrder.remove(toAdd);
        }
    }
}
Also used : Note(org.talend.designer.core.ui.editor.notes.Note) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)21 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)14 List (java.util.List)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 ArrayList (java.util.ArrayList)11 Node (org.talend.designer.core.ui.editor.nodes.Node)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)9 Note (org.talend.designer.core.ui.editor.notes.Note)9 EditPart (org.eclipse.gef.EditPart)8 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)6 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)5 Clipboard (org.eclipse.gef.ui.actions.Clipboard)4 JobletContainerPart (org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart)4 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)4 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)4 Point (org.eclipse.draw2d.geometry.Point)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3