Search in sources :

Example 1 with BusinessItem

use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.

the class GmfPastCommand method cloneAssignmentForModel.

private void cloneAssignmentForModel(List<BusinessItem> nodes, List pChildren) {
    if (nodes == null || pChildren == null) {
        return;
    }
    int i = nodes.size();
    for (BusinessItem businessItem : getSortedBusinessItems(nodes)) {
        BusinessItem newItem = (BusinessItem) getEObject(businessItem);
        if (!addNew) {
            newItem.setBusinessProcess(businessItem.getBusinessProcess());
        }
        newItem.setHAlignment(businessItem.getHAlignment());
        newItem.setName(businessItem.getName());
        newItem.setVAlignment(businessItem.getVAlignment());
        List assignments = new ArrayList();
        boolean execute = false;
        int n = 0;
        for (Object object : businessItem.getAssignments()) {
            BusinessAssignment older = (BusinessAssignment) object;
            BusinessAssignment newAssignment = (BusinessAssignment) getEObject(older);
            newAssignment.setBusinessItem(newItem);
            newAssignment.setComment(older.getComment());
            if (!addNew) {
                newAssignment.setTalendItem(older.getTalendItem());
            } else {
                TalendItem item = older.getTalendItem();
                String talendId = null;
                if (item != null) {
                    talendId = item.getId();
                } else {
                    List idList = (List) itemIds.get(businessItem);
                    if (n < idList.size()) {
                        talendId = (String) idList.get(n);
                    }
                    n++;
                }
                RepositoryNode node = null;
                if (talendId.split(" - ").length == 1) {
                    //$NON-NLS-1$
                    node = RepositoryNodeUtilities.getRepositoryNode(talendId);
                } else {
                    node = RepositoryNodeUtilities.getMetadataTableFromConnection(talendId);
                    if (node == null) {
                        node = RepositoryNodeUtilities.getQueryFromConnection(talendId);
                    }
                }
                RepositoryHelper repositoryHelper = new RepositoryHelper();
                Repository repository = process.getLocalRepositoryCopy();
                if (repository == null) {
                    repository = repositoryHelper.createLocalRepositoryCopy(process);
                }
                TalendItem talendItem = repositoryHelper.createTalendItem(repository, node);
                newAssignment.setTalendItem(talendItem);
            }
            assignments.add(newAssignment);
        }
        if (assignments.size() > 0) {
            newItem.getAssignments().addAll(assignments);
        }
        if (i <= pChildren.size()) {
            View node = (View) pChildren.get(pChildren.size() - i);
            node.setElement(newItem);
            i--;
        }
        if (addNew) {
            this.process.getBusinessItems().add(newItem);
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) View(org.eclipse.gmf.runtime.notation.View) Repository(org.talend.designer.business.model.business.Repository) ArrayList(java.util.ArrayList) List(java.util.List) EObject(org.eclipse.emf.ecore.EObject) TalendItem(org.talend.designer.business.model.business.TalendItem) InputBusinessItem(org.talend.designer.business.model.business.InputBusinessItem) TerminalBusinessItem(org.talend.designer.business.model.business.TerminalBusinessItem) ActorBusinessItem(org.talend.designer.business.model.business.ActorBusinessItem) DatabaseBusinessItem(org.talend.designer.business.model.business.DatabaseBusinessItem) BusinessItem(org.talend.designer.business.model.business.BusinessItem) GearBusinessItem(org.talend.designer.business.model.business.GearBusinessItem) EllipseBusinessItem(org.talend.designer.business.model.business.EllipseBusinessItem) DataBusinessItem(org.talend.designer.business.model.business.DataBusinessItem) DecisionBusinessItem(org.talend.designer.business.model.business.DecisionBusinessItem) DocumentBusinessItem(org.talend.designer.business.model.business.DocumentBusinessItem) ActionBusinessItem(org.talend.designer.business.model.business.ActionBusinessItem) ListBusinessItem(org.talend.designer.business.model.business.ListBusinessItem) RepositoryHelper(org.talend.designer.business.diagram.custom.util.RepositoryHelper)

Example 2 with BusinessItem

use of org.talend.designer.business.model.business.BusinessItem 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 3 with BusinessItem

use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.

the class DeleteAssignmentAction method doRun.

@Override
protected void doRun() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor editor = (BusinessDiagramEditor) activeEditor;
        ISelection selection2 = editor.getSelection();
        EObject element = null;
        Object firstElement = ((IStructuredSelection) selection2).getFirstElement();
        if (firstElement instanceof BusinessItemShapeEditPart) {
            BusinessItemShapeEditPart editpart = (BusinessItemShapeEditPart) firstElement;
            element = ((Node) editpart.getModel()).getElement();
        } else if (firstElement instanceof BaseBusinessItemRelationShipEditPart) {
            BaseBusinessItemRelationShipEditPart editpart = (BaseBusinessItemRelationShipEditPart) firstElement;
            element = ((EdgeImpl) editpart.getModel()).getElement();
        }
        if (element instanceof BusinessItem) {
            BusinessItem businessItem = (BusinessItem) element;
            DeleteAssignmentCommand command = new DeleteAssignmentCommand(businessItem, selection);
            try {
                command.execute(null, null);
            } catch (ExecutionException e) {
                ExceptionHandler.process(e);
            }
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            for (IEditorReference editors : page.getEditorReferences()) {
                CorePlugin.getDefault().getDiagramModelService().refreshBusinessModel(editors);
            }
        }
    }
}
Also used : BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) EdgeImpl(org.eclipse.gmf.runtime.notation.impl.EdgeImpl) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DeleteAssignmentCommand(org.talend.designer.business.diagram.custom.commands.DeleteAssignmentCommand) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorReference(org.eclipse.ui.IEditorReference) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) EObject(org.eclipse.emf.ecore.EObject) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EObject(org.eclipse.emf.ecore.EObject) ExecutionException(org.eclipse.core.commands.ExecutionException) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 4 with BusinessItem

use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.

the class DiagramModelService method setBusinessItemAlignment.

public void setBusinessItemAlignment(BusinessAlignment alignment, BusinessAlignment alignmentGroup, Object part) {
    if (part instanceof BusinessItemShapeEditPart) {
        BusinessItem item = (BusinessItem) ((Node) ((BusinessItemShapeEditPart) part).getModel()).getElement();
        ChangeBusinessItemAlignmentCommand command = new ChangeBusinessItemAlignmentCommand(item, alignment, alignmentGroup);
        try {
            command.execute(null, null);
        } catch (ExecutionException e) {
        }
        ((BusinessItemShapeEditPart) part).refreshVisuals();
    }
}
Also used : ChangeBusinessItemAlignmentCommand(org.talend.designer.business.diagram.custom.commands.ChangeBusinessItemAlignmentCommand) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ExecutionException(org.eclipse.core.commands.ExecutionException) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 5 with BusinessItem

use of org.talend.designer.business.model.business.BusinessItem in project tdi-studio-se by Talend.

the class BusinessItemDragDropEditPolicy method getDropObjectsCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy#getDropObjectsCommand(org.eclipse.gmf
     * .runtime.diagram.ui.requests.DropObjectsRequest)
     */
@Override
public Command getDropObjectsCommand(DropObjectsRequest dropObjectsRequest) {
    BusinessItem businessItem = new ElementHelper().getElement(getHost());
    if (businessItem != null) {
        CreateAssignmentCommand createAssignmentCommand = new CreateAssignmentCommand(((IGraphicalEditPart) getHost()).getEditingDomain());
        createAssignmentCommand.setBusinessItem(businessItem);
        createAssignmentCommand.setItems(dropObjectsRequest.getObjects());
        return new ICommandProxy(createAssignmentCommand);
    }
    return UnexecutableCommand.INSTANCE;
}
Also used : ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CreateAssignmentCommand(org.talend.designer.business.diagram.custom.commands.CreateAssignmentCommand) BusinessItem(org.talend.designer.business.model.business.BusinessItem) ElementHelper(org.talend.designer.business.diagram.custom.util.ElementHelper)

Aggregations

BusinessItem (org.talend.designer.business.model.business.BusinessItem)14 EObject (org.eclipse.emf.ecore.EObject)9 ArrayList (java.util.ArrayList)7 List (java.util.List)7 BusinessAssignment (org.talend.designer.business.model.business.BusinessAssignment)6 View (org.eclipse.gmf.runtime.notation.View)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Iterator (java.util.Iterator)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 AbstractEditPart (org.eclipse.gef.editparts.AbstractEditPart)3 IEditorPart (org.eclipse.ui.IEditorPart)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)3 TalendItem (org.talend.designer.business.model.business.TalendItem)3 HashMap (java.util.HashMap)2 EditPart (org.eclipse.gef.EditPart)2 DiagramEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart)2 Diagram (org.eclipse.gmf.runtime.notation.Diagram)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 BaseBusinessItemRelationShipEditPart (org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart)2