Search in sources :

Example 1 with BusinessItemShapeFigure

use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.

the class FindAssignmentAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
    IEditorPart activeEditor = getActiveEditor();
    // remove frames draw last time
    for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
        shapFigure.setDrawFrame(false);
        shapFigure.revalidate();
        shapFigure.repaint();
    }
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
        Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
        BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
        // PTODO mhelleboid use OCL or using a visitor
        List list = new ArrayList();
        for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
                BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
                TalendItem talendItem = businessAssignment.getTalendItem();
                IRepositoryViewObject obj = repositoryNode.getObject();
                if (talendItem.getId().equals(repositoryNode.getId())) {
                    list.add(businessItem);
                } else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
                    if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
                        list.add(businessItem);
                    }
                }
            }
        }
        IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
        List editParts = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
        }
        diagramGraphicalViewer.deselectAll();
        // add a frame when use findAassignment
        for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
            EditPart editPart = (EditPart) iter.next();
            if (editPart instanceof BusinessItemShapeEditPart) {
                BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
                IFigure figure = shapEditPart.getFigure();
                for (Object child : figure.getChildren()) {
                    if (child instanceof BusinessItemShapeFigure) {
                        BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                        shapFigure.setDrawFrame(true);
                        shapFigure.revalidate();
                        shapFigure.repaint();
                        repaintedFigures.add(shapFigure);
                    }
                }
            }
            diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
        }
        ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
        zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
    }
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) SapFunctionMetadata(org.talend.designer.business.model.business.SapFunctionMetadata) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) IFigure(org.eclipse.draw2d.IFigure) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorPart(org.eclipse.ui.IEditorPart) Routine(org.talend.designer.business.model.business.Routine) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 2 with BusinessItemShapeFigure

use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.

the class BusinessItemShapeEditPart method unregisterVisuals.

@Override
protected void unregisterVisuals() {
    IFigure figure2 = getFigure();
    if (figure2 instanceof BusinessItemShapeFigure) {
        ((BusinessItemShapeFigure) figure2).disposeColors();
    }
    super.unregisterVisuals();
}
Also used : BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with BusinessItemShapeFigure

use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.

the class BusinessItemShapeEditPart method refreshVisuals.

@Override
public void refreshVisuals() {
    super.refreshVisuals();
    NodeFigure nodeFigure = getNodeFigure();
    for (Object obj : nodeFigure.getChildren()) {
        if (obj instanceof BusinessItemShapeFigure) {
            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
            for (Object figure : shapFigure.getChildren()) {
                if (figure instanceof BusinessItemNameFigure) {
                    BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
                    nameFigure.addMouseMotionListener(new MouseMotionListener() {

                        @Override
                        public void mouseMoved(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseHover(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseExited(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseEntered(MouseEvent me) {
                            elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
                        }

                        @Override
                        public void mouseDragged(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }
                    });
                    EObject object = ((Node) getModel()).getElement();
                    if (object instanceof BusinessItem) {
                        BusinessItem item = (BusinessItem) object;
                        String hAlignment = item.getHAlignment();
                        if (hAlignment == null) {
                            hAlignment = BusinessAlignment.LEFT.toString();
                        }
                        String vAlignment = item.getVAlignment();
                        if (vAlignment == null) {
                            vAlignment = BusinessAlignment.TOP.toString();
                        }
                        if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
                            if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.TOP);
                            } else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.BOTTOM);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
                            if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.LEFT);
                            } else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.RIGHT);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else {
                            nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
                        }
                    }
                }
            }
        }
    }
    elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) NodeFigure(org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) BusinessItemNameFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemNameFigure) EObject(org.eclipse.emf.ecore.EObject) Node(org.eclipse.gmf.runtime.notation.Node) EObject(org.eclipse.emf.ecore.EObject) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 4 with BusinessItemShapeFigure

use of org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    super.selectionChanged(part, selection);
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    JobSettingsView view = (JobSettingsView) page.findView(JobSettingsView.ID);
    getDiagramEditorInput().getItem().getProperty().eAdapters().remove(dirtyListener);
    if (view == null) {
        return;
    }
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    Object firstElement = ((IStructuredSelection) selection).getFirstElement();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    } else if (firstElement instanceof RepositoryNode) {
        return;
    }
    // for Find Assignment
    if (((IStructuredSelection) selection).size() > 0) {
        DiagramEditPart diagramEditPart = getDiagramEditPart();
        if (diagramEditPart instanceof BusinessProcessEditPart) {
            BusinessProcessEditPart processPart = (BusinessProcessEditPart) diagramEditPart;
            for (Object object : processPart.getChildren()) {
                if (object instanceof BusinessItemShapeEditPart) {
                    BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) object;
                    IFigure figure = shapEditPart.getFigure();
                    for (Object child : figure.getChildren()) {
                        if (child instanceof BusinessItemShapeFigure) {
                            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                            Border border = shapFigure.getBorder();
                            if (border != null) {
                                shapFigure.setDrawFrame(false);
                                shapFigure.revalidate();
                                shapFigure.repaint();
                            }
                        }
                    }
                }
            }
        }
    }
    // to refresh the jobsettings view
    if (((IStructuredSelection) selection).size() > 1) {
        view.cleanDisplay();
    } else {
        if (firstElement instanceof BusinessItemShapeEditPart || firstElement instanceof BaseBusinessItemRelationShipEditPart || firstElement instanceof NoteEditPart || firstElement instanceof NoteAttachmentEditPart) {
            view.refresh(false, firstElement);
        } else if (firstElement instanceof BusinessProcessEditPart || firstElement instanceof CompartmentEditPart) {
            view.refresh(true, this);
        }
    }
    getDiagramEditorInput().getItem().getProperty().eAdapters().add(dirtyListener);
}
Also used : JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) CompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart) NoteEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) NoteAttachmentEditPart(org.eclipse.gmf.runtime.diagram.ui.internal.editparts.NoteAttachmentEditPart) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Border(org.eclipse.draw2d.Border) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

BusinessItemShapeFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure)4 IFigure (org.eclipse.draw2d.IFigure)3 DiagramEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 BaseBusinessItemRelationShipEditPart (org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart)2 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)2 BusinessItem (org.talend.designer.business.model.business.BusinessItem)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Border (org.eclipse.draw2d.Border)1 MouseEvent (org.eclipse.draw2d.MouseEvent)1 MouseMotionListener (org.eclipse.draw2d.MouseMotionListener)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 CompartmentEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart)1 NoteEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart)1