Search in sources :

Example 11 with BusinessItem

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

the class BusinessBaseEditHelper method getDestroyElementCommand.

/**
     * @generated NOT
     */
protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
    if (req.getElementToDestroy() != null) {
        if (req.getElementToDestroy() instanceof BusinessItem) {
            BusinessItem businessItem = (BusinessItem) req.getElementToDestroy();
            if (businessItem.getAssignments().size() > 0) {
                UnassignTalendItemsFromBusinessAssignmentCommand command = new UnassignTalendItemsFromBusinessAssignmentCommand(req.getEditingDomain(), false);
                for (Iterator iter = businessItem.getAssignments().iterator(); iter.hasNext(); ) {
                    BusinessAssignment businessAssignment = (BusinessAssignment) iter.next();
                    command.addBusinessAssignment(businessAssignment);
                }
                return command;
            }
        }
    }
    return null;
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) UnassignTalendItemsFromBusinessAssignmentCommand(org.talend.designer.business.diagram.custom.commands.UnassignTalendItemsFromBusinessAssignmentCommand) Iterator(java.util.Iterator) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 12 with BusinessItem

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

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

the class DuplicateAnythingCommand method doExecuteWithResult.

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
    // Remove elements whose container is getting copied.
    ClipboardSupportUtil.getCopyElements(getObjectsToBeDuplicated());
    // Perform the copy and update the references.
    EcoreUtil.Copier copier = new EcoreUtil.Copier();
    copier.copyAll(getObjectsToBeDuplicated());
    copier.copyReferences();
    // Update the map with all elements duplicated.
    getAllDuplicatedObjectsMap().putAll(copier);
    Map targetAndSource = new HashMap();
    // Add the duplicates to the original's container.
    for (Iterator i = getObjectsToBeDuplicated().iterator(); i.hasNext(); ) {
        EObject original = (EObject) i.next();
        EObject duplicate = (EObject) copier.get(original);
        targetAndSource.put(duplicate, original);
        EReference reference = original.eContainmentFeature();
        if (reference != null && FeatureMapUtil.isMany(original.eContainer(), reference) && ClipboardSupportUtil.isOkToAppendEObjectAt(original.eContainer(), reference, duplicate)) {
            ClipboardSupportUtil.appendEObjectAt(original.eContainer(), reference, duplicate);
        }
    }
    for (Object obj : targetAndSource.keySet()) {
        if (obj instanceof BusinessItem) {
            BusinessItem item = (BusinessItem) obj;
            Object sourceObject = targetAndSource.get(item);
            if (sourceObject instanceof BusinessItem) {
                BusinessItem sourceItem = (BusinessItem) sourceObject;
                List targetAssignments = item.getAssignments();
                List sourceAssignments = sourceItem.getAssignments();
                for (int i = 0; i < targetAssignments.size() && i < sourceAssignments.size(); i++) {
                    BusinessAssignment targetAssign = (BusinessAssignment) targetAssignments.get(i);
                    targetAssign.setComment(((BusinessAssignment) sourceAssignments.get(i)).getComment());
                    targetAssign.setTalendItem(((BusinessAssignment) sourceAssignments.get(i)).getTalendItem());
                }
            }
        }
    }
    return null;
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) HashMap(java.util.HashMap) Map(java.util.Map) EReference(org.eclipse.emf.ecore.EReference) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 14 with BusinessItem

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

the class GmfPastCommand method getSortedBusinessItems.

private Collection<BusinessItem> getSortedBusinessItems(List<BusinessItem> items) {
    List allBusinessItems = getClonedSourceProcessItemsList();
    SortedMap<Integer, BusinessItem> sortedMap = new TreeMap<Integer, BusinessItem>();
    if (allBusinessItems != null) {
        for (BusinessItem item : items) {
            int indexOf = allBusinessItems.indexOf(item);
            if (indexOf != -1) {
                sortedMap.put(indexOf, item);
            }
        }
    }
    return sortedMap.values();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) 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)

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