Search in sources :

Example 1 with Note

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

the class ComponentSettingsView method getCategories.

/**
     * yzhang Comment method "getCategories".
     * 
     * @param elem
     * @return
     */
private EComponentCategory[] getCategories(Element elem) {
    if (elem instanceof Connection) {
        EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
        if (PluginChecker.isTeamEdition()) {
            Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
            if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
                // if (((Connection) elem).checkTraceShowEnable()) {
                final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                // mrjob and stormjob not add breakpoint
                if (!isStormProcess && !isMRProcess) {
                    list.add(EComponentCategory.BREAKPOINT);
                }
                if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
                    list.add(EComponentCategory.PARALLELIZATION);
                }
                // if it mr group line then add errorRecovery
                if (isMRProcess && isMrGroupLine(elem)) {
                    list.add(EComponentCategory.RESUMING);
                }
                return list.toArray(new EComponentCategory[0]);
            // }
            } else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
                boolean isMRProcess = false;
                IProcess process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
                        isMRProcess = true;
                    }
                }
                boolean isStormProcess = false;
                process = ((Connection) elem).getSource().getProcess();
                if (process instanceof IProcess2) {
                    IProcess2 process2 = (IProcess2) process;
                    if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
                        isStormProcess = true;
                    }
                }
                int length = categories.length;
                EComponentCategory[] newCategories;
                boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
                boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
                if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
                    newCategories = new EComponentCategory[length + 1];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                    EComponentCategory resuming = EComponentCategory.RESUMING;
                    newCategories[length] = resuming;
                } else {
                    newCategories = new EComponentCategory[length];
                    for (int i = 0; i < length; i++) {
                        newCategories[i] = categories[i];
                    }
                }
                return newCategories;
            }
        }
        return categories;
    } else if (elem instanceof Node) {
        // if (isAdvancedType(elem)) {
        if (((Node) elem).isELTComponent()) {
            if (//$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
            !((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
                //$NON-NLS-1$
                return EElementType.ELT_NODE.getCategories();
            }
        }
        EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
        // add for bug TDI-8476
        if (((Node) elem).getComponent() != null) {
            String paletteType = ((Node) elem).getComponent().getPaletteType();
            if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
                categories = EElementType.NODE.getCategories();
            }
        }
        if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
            // show
            EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
            System.arraycopy(categories, 0, newCategories, 0, categories.length);
            newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
            return newCategories;
        }
        return categories;
    } else if (elem instanceof Note) {
        return EElementType.NOTE.getCategories();
    } else if (elem instanceof SubjobContainer) {
        return EElementType.SUBJOB.getCategories();
    } else if (elem instanceof ConnectionLabel) {
        return getCategories(((ConnectionLabel) elem).getConnection());
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ArrayList(java.util.ArrayList) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Note(org.talend.designer.core.ui.editor.notes.Note) IProcess2(org.talend.core.model.process.IProcess2) EConnectionType(org.talend.core.model.process.EConnectionType) IProcess(org.talend.core.model.process.IProcess) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 2 with Note

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

the class NotesPasteCommand method undo.

@SuppressWarnings("unchecked")
@Override
public void undo() {
    // remove the current selection
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    if (!multipleCommand) {
        viewer.deselectAll();
    }
    for (Note note : noteList) {
        process.removeNote(note);
    }
    // set the old selection active
    if (!multipleCommand) {
        StructuredSelection s = new StructuredSelection(oldSelection);
        viewer.setSelection(s);
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Note(org.talend.designer.core.ui.editor.notes.Note) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 3 with Note

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

the class NotesPasteCommand method findLocationForNoteInContainerList.

private Point findLocationForNoteInContainerList(final Point location, Dimension size, int index, int firstIndex) {
    Rectangle copiedRect = new Rectangle(location.x, location.y, size.width, size.height);
    Point newLocation = new Point(location);
    if (!isMultiple) {
        for (Note node : noteList) {
            Rectangle currentRect = new Rectangle(node.getLocation().x, node.getLocation().y, node.getSize().width, node.getSize().height);
            if (currentRect.intersects(copiedRect)) {
                newLocation = computeTheDistance(index, firstIndex, newLocation);
            // return findLocationForNoteInContainerList(newLocation, size, index, firstIndex);
            }
        }
    } else {
        if (getCursorLocation() == null) {
            return newLocation;
        }
        newLocation = computeTheDistance(index, firstIndex, newLocation);
    }
    return newLocation;
}
Also used : Note(org.talend.designer.core.ui.editor.notes.Note) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with Note

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

the class NotesPasteCommand method createNoteList.

@SuppressWarnings("unchecked")
private void createNoteList() {
    int firstIndex = 0;
    int index = 0;
    noteList = new ArrayList<Note>();
    // create the notes
    for (NoteEditPart copiedNodePart : noteParts) {
        Note copiedNote = (Note) copiedNodePart.getModel();
        Note pastedNote = new Note();
        pastedNote.setOpaque(copiedNote.isOpaque());
        pastedNote.setText(copiedNote.getText());
        pastedNote.setSize(copiedNote.getSize());
        // see bug 0005571: Copy/Paste of Note doesn't keep Format
        EParameterName[] params = new EParameterName[] { EParameterName.NOTE_FONT, EParameterName.FONT_SIZE, EParameterName.FONT_BOLD, EParameterName.FONT_ITALIC, EParameterName.NOTE_LINECOLOR, EParameterName.NOTE_COLOR, EParameterName.NOTETXT_COLOR, EParameterName.NOTETXT_LEFT, EParameterName.NOTETXT_RIGHT, EParameterName.NOTETXT_CENTER, EParameterName.NOTELABEL_CENTER, EParameterName.NOTETXT_TOP, EParameterName.NOTETXT_BOTTOM };
        for (EParameterName param : params) {
            Object value = copiedNote.getElementParameter(param.getName()).getValue();
            pastedNote.getElementParameter(param.getName()).setValue(value);
        }
        pastedNote.setOpaque(copiedNote.isOpaque());
        pastedNote.setProcess(process);
        Point location = null;
        if (getCursorLocation() == null) {
            location = copiedNote.getLocation();
        } else {
            location = getCursorLocation();
            index = noteParts.indexOf(copiedNodePart);
        }
        if (process.isGridEnabled()) {
            // replace the component to set it on the grid if it's enabled
            int tempVar = location.x / TalendEditor.GRID_SIZE;
            location.x = tempVar * TalendEditor.GRID_SIZE;
            tempVar = location.y / TalendEditor.GRID_SIZE;
            location.y = tempVar * TalendEditor.GRID_SIZE;
        }
        pastedNote.setLocation(findLocationForNote(location, copiedNote.getSize(), index, firstIndex));
        noteList.add(pastedNote);
    }
}
Also used : Note(org.talend.designer.core.ui.editor.notes.Note) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EParameterName(org.talend.designer.core.model.components.EParameterName) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with Note

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

the class MultiplePasteCommand method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.CompoundCommand#execute()
     */
@Override
public void execute() {
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    oldSelection = new ArrayList<EditPart>();
    for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
        oldSelection.add(editPart);
    }
    // remove the old selection
    viewer.deselectAll();
    super.execute();
    EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
    if (processPart instanceof ProcessPart) {
        // can only be ProcessPart but still test
        List<EditPart> sel = new ArrayList<EditPart>();
        for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
            if (editPart instanceof NodePart) {
                Node currentNode = (Node) editPart.getModel();
                if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof NoteEditPart) {
                Note currentNode = (Note) editPart.getModel();
                if (noteCmd.getNoteList().contains(currentNode)) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof SubjobContainerPart) {
                // add for the bug TDI-7706
                for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                    if (subjobChildsPart instanceof NodeContainerPart) {
                        if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                            NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                            if (nodePart != null) {
                                sel.add(nodePart);
                            }
                        }
                    }
                }
            }
        }
        StructuredSelection s = new StructuredSelection(sel);
        viewer.setSelection(s);
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) Note(org.talend.designer.core.ui.editor.notes.Note) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

Note (org.talend.designer.core.ui.editor.notes.Note)18 Node (org.talend.designer.core.ui.editor.nodes.Node)12 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)6 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)6 ArrayList (java.util.ArrayList)5 Point (org.eclipse.draw2d.geometry.Point)5 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 MoveNodeCommand (org.talend.designer.core.ui.editor.cmd.MoveNodeCommand)5 MoveNoteCommand (org.talend.designer.core.ui.editor.cmd.MoveNoteCommand)5 Connection (org.talend.designer.core.ui.editor.connections.Connection)5 ConnectionLabel (org.talend.designer.core.ui.editor.connections.ConnectionLabel)5 EditPart (org.eclipse.gef.EditPart)4 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)4 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)4 List (java.util.List)3 GraphicalViewer (org.eclipse.gef.GraphicalViewer)3 Command (org.eclipse.gef.commands.Command)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3