/** @generated */ protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) { if (isShortcut(view)) { return edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.isShortcutOrphaned(view); } return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement()); }
/** @generated */ @SuppressWarnings("rawtypes") protected List getSemanticChildrenList() { View viewObject = (View) getHost().getModel(); LinkedList<EObject> result = new LinkedList<EObject>(); List< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVONodeDescriptor> childDescriptors = edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getClassDiagram_1000SemanticChildren(viewObject); for (edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVONodeDescriptor d : childDescriptors) { result.add(d.getModelElement()); } return result; }
/** @generated */ private Collection< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOLinkDescriptor> collectAllLinks(View view, Domain2Notation domain2NotationMap) { if (!edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.ClassDiagramEditPart .MODEL_ID.equals( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOVisualIDRegistry.getModelID(view))) { return Collections.emptyList(); } LinkedList< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOLinkDescriptor> result = new LinkedList< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOLinkDescriptor>(); switch (edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOVisualIDRegistry.getVisualID(view)) { case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.ClassDiagramEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getClassDiagram_1000ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.ClassEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getClass_2001ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.AttributeEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getAttribute_3001ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.OperationEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getOperation_3002ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.AssociationEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getAssociation_4001ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts .NestedInReferenceEditPart.VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getNestedInReference_4002ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts .SuperclassReferenceEditPart.VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getSuperclassReference_4003ContainedLinks( view)); } domain2NotationMap.putView(view.getElement(), view); break; } case edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.edit.parts.DependencyEditPart .VISUAL_ID: { if (!domain2NotationMap.containsKey(view.getElement())) { result.addAll( edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getDependency_4004ContainedLinks(view)); } domain2NotationMap.putView(view.getElement(), view); break; } } for (Iterator children = view.getChildren().iterator(); children.hasNext(); ) { result.addAll(collectAllLinks((View) children.next(), domain2NotationMap)); } for (Iterator edges = view.getSourceEdges().iterator(); edges.hasNext(); ) { result.addAll(collectAllLinks((View) edges.next(), domain2NotationMap)); } return result; }
/** @generated */ protected void refreshSemantic() { if (resolveSemanticElement() == null) { return; } LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>(); List< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVONodeDescriptor> childDescriptors = edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.getClassDiagram_1000SemanticChildren( (View) getHost().getModel()); LinkedList<View> orphaned = new LinkedList<View>(); // we care to check only views we recognize as ours and not shortcuts LinkedList<View> knownViewChildren = new LinkedList<View>(); for (View v : getViewChildren()) { if (isShortcut(v)) { if (edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVODiagramUpdater.isShortcutOrphaned(v)) { orphaned.add(v); } continue; } if (isMyDiagramElement(v)) { knownViewChildren.add(v); } } // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren) // // iteration happens over list of desired semantic elements, trying to find best matching View, // while original CEP // iterates views, potentially losing view (size/bounds) information - i.e. if there are few // views to reference same EObject, only last one // to answer isOrphaned == true will be used for the domain element representation, see // #cleanCanonicalSemanticChildren() for (Iterator< edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVONodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext(); ) { edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.ClassDiagram_MAVONodeDescriptor next = descriptorsIterator.next(); String hint = edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOVisualIDRegistry.getType(next.getVisualID()); LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor for (View childView : getViewChildren()) { EObject semanticElement = childView.getElement(); if (next.getModelElement().equals(semanticElement)) { if (hint.equals(childView.getType())) { perfectMatch.add(childView); // actually, can stop iteration over view children here, but // may want to use not the first view but last one as a 'real' match (the way original // CEP does // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren } } } if (perfectMatch.size() > 0) { descriptorsIterator .remove(); // precise match found no need to create anything for the NodeDescriptor // use only one view (first or last?), keep rest as orphaned for further consideration knownViewChildren.remove(perfectMatch.getFirst()); } } // those left in knownViewChildren are subject to removal - they are our diagram elements we // didn't find match to, // or those we have potential matches to, and thus need to be recreated, preserving // size/location information. orphaned.addAll(knownViewChildren); // ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size()); for (edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVONodeDescriptor next : childDescriptors) { String hint = edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part .ClassDiagram_MAVOVisualIDRegistry.getType(next.getVisualID()); IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint); CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor( elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint()); viewDescriptors.add(descriptor); } boolean changed = deleteViews(orphaned.iterator()); // CreateViewRequest request = getCreateViewRequest(viewDescriptors); Command cmd = getCreateViewCommand(request); if (cmd != null && cmd.canExecute()) { SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute(); executeCommand(cmd); @SuppressWarnings("unchecked") List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject(); createdViews.addAll(nl); } if (changed || createdViews.size() > 0) { postProcessRefreshSemantic(createdViews); } Collection<IAdaptable> createdConnectionViews = refreshConnections(); if (createdViews.size() > 1) { // perform a layout of the container DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host()); executeCommand(new ICommandProxy(layoutCmd)); } createdViews.addAll(createdConnectionViews); makeViewsImmutable(createdViews); }