Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 47815 Details for
Bug 141789
[Layout] Arrange All should be called in generation code to initialize the diagram
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
possible fix #2
fix_141789.txt (text/plain), 14.31 KB, created by
Alex Boyko
on 2006-08-12 14:22:59 EDT
(
hide
)
Description:
possible fix #2
Filename:
MIME Type:
Creator:
Alex Boyko
Created:
2006-08-12 14:22:59 EDT
Size:
14.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.ecore.editor >Index: src/org/eclipse/gmf/ecore/edit/policies/EPackageCanonicalEditPolicy.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/examples/org.eclipse.gmf.ecore.editor/src/org/eclipse/gmf/ecore/edit/policies/EPackageCanonicalEditPolicy.java,v >retrieving revision 1.20 >diff -u -r1.20 EPackageCanonicalEditPolicy.java >--- src/org/eclipse/gmf/ecore/edit/policies/EPackageCanonicalEditPolicy.java 27 Jun 2006 13:43:47 -0000 1.20 >+++ src/org/eclipse/gmf/ecore/edit/policies/EPackageCanonicalEditPolicy.java 12 Aug 2006 18:15:43 -0000 >@@ -10,69 +10,24 @@ > */ > package org.eclipse.gmf.ecore.edit.policies; > >-import java.util.List; >-import java.util.Collection; >-import org.eclipse.gmf.runtime.notation.Edge; >-import org.eclipse.emf.ecore.EObject; >-import java.util.Collections; >-import java.util.HashMap; > import java.util.Iterator; > import java.util.LinkedList; >-import java.util.Map; >- >-import org.eclipse.core.runtime.IAdaptable; >+import java.util.List; > >-import org.eclipse.emf.ecore.EAnnotation; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EModelElement; >+import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EPackage; > import org.eclipse.emf.ecore.ETypedElement; >-import org.eclipse.emf.ecore.EcorePackage; >- >-import org.eclipse.gef.EditPart; >- >-import org.eclipse.gef.commands.Command; >- > import org.eclipse.gmf.ecore.edit.parts.EAnnotation2EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EAnnotationEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EAnnotationReferencesEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EAttributeEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EClass2EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EClassESuperTypesEditPart; > import org.eclipse.gmf.ecore.edit.parts.EClassEditPart; > import org.eclipse.gmf.ecore.edit.parts.EDataType2EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EDataTypeEditPart; > import org.eclipse.gmf.ecore.edit.parts.EEnum2EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EEnumEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EEnumLiteralEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EOperationEditPart; > import org.eclipse.gmf.ecore.edit.parts.EPackage2EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EPackage3EditPart; >-import org.eclipse.gmf.ecore.edit.parts.EPackageEditPart; > import org.eclipse.gmf.ecore.edit.parts.EReference2EditPart; > import org.eclipse.gmf.ecore.edit.parts.EReferenceEditPart; >-import org.eclipse.gmf.ecore.edit.parts.EStringToStringMapEntryEditPart; >- > import org.eclipse.gmf.ecore.part.EcoreVisualIDRegistry; >- >-import org.eclipse.gmf.ecore.providers.EcoreElementTypes; >- >-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; >- >-import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand; >- >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >- > import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalConnectionEditPolicy; >- >-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; >-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; >- >-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; >- >-import org.eclipse.gmf.runtime.emf.type.core.IElementType; >- >-import org.eclipse.gmf.runtime.notation.Diagram; > import org.eclipse.gmf.runtime.notation.View; > > /** >@@ -137,331 +92,50 @@ > protected String getDefaultFactoryHint() { > return null; > } >- >+ > /** > * @generated > */ > protected List getSemanticConnectionsList() { >- return Collections.EMPTY_LIST; >- } >- >- /** >- * @generated >- */ >- protected EObject getSourceElement(EObject relationship) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected EObject getTargetElement(EObject relationship) { >- return null; >- } >- >- /** >- * @generated >- */ >- protected boolean shouldIncludeConnection(Edge connector, Collection children) { >- return false; >- } >- >- /** >- * @generated >- */ >- protected void refreshSemantic() { >- super.refreshSemantic(); >- refreshConnections(); >- } >- >- /** >- * @generated >- */ >- private Collection myLinkDescriptors = new LinkedList(); >- >- /** >- * @generated >- */ >- private Map myEObject2ViewMap = new HashMap(); >- >- /** >- * @generated >- */ >- private void refreshConnections() { >- try { >- collectAllLinks(getDiagram()); >- Collection existingLinks = new LinkedList(getDiagram().getEdges()); >- for (Iterator diagramLinks = existingLinks.iterator(); diagramLinks.hasNext();) { >- Edge nextDiagramLink = (Edge) diagramLinks.next(); >- EObject diagramLinkObject = nextDiagramLink.getElement(); >- EObject diagramLinkSrc = nextDiagramLink.getSource().getElement(); >- EObject diagramLinkDst = nextDiagramLink.getTarget().getElement(); >- int diagramLinkVisualID = EcoreVisualIDRegistry.getVisualID(nextDiagramLink); >- for (Iterator modelLinkDescriptors = myLinkDescriptors.iterator(); modelLinkDescriptors.hasNext();) { >- LinkDescriptor nextLinkDescriptor = (LinkDescriptor) modelLinkDescriptors.next(); >- if (diagramLinkObject == nextLinkDescriptor.getLinkElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() >- && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) { >- diagramLinks.remove(); >- modelLinkDescriptors.remove(); >- } >- } >- } >- deleteViews(existingLinks.iterator()); >- createConnections(myLinkDescriptors); >- } finally { >- myLinkDescriptors.clear(); >- myEObject2ViewMap.clear(); >- } >- } >- >- /** >- * @generated >- */ >- private void collectAllLinks(View view) { >- EObject modelElement = view.getElement(); >- int diagramElementVisualID = EcoreVisualIDRegistry.getVisualID(view); >- switch (diagramElementVisualID) { >- case EClassEditPart.VISUAL_ID: >- case EPackage2EditPart.VISUAL_ID: >- case EAnnotation2EditPart.VISUAL_ID: >- case EDataType2EditPart.VISUAL_ID: >- case EEnum2EditPart.VISUAL_ID: >- case EAttributeEditPart.VISUAL_ID: >- case EOperationEditPart.VISUAL_ID: >- case EAnnotationEditPart.VISUAL_ID: >- case EClass2EditPart.VISUAL_ID: >- case EPackage3EditPart.VISUAL_ID: >- case EDataTypeEditPart.VISUAL_ID: >- case EEnumEditPart.VISUAL_ID: >- case EStringToStringMapEntryEditPart.VISUAL_ID: >- case EEnumLiteralEditPart.VISUAL_ID: >- case EPackageEditPart.VISUAL_ID: { >- myEObject2ViewMap.put(modelElement, view); >- storeLinks(modelElement, getDiagram()); >- } >- default: { >- } >- for (Iterator children = view.getChildren().iterator(); children.hasNext();) { >- View childView = (View) children.next(); >- collectAllLinks(childView); >- } >- } >- } >- >- /** >- * @generated >- */ >- private void createConnections(Collection linkDescriptors) { >- if (linkDescriptors.isEmpty()) { >- return; >- } >- for (Iterator linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) { >- final LinkDescriptor nextLinkDescriptor = (LinkDescriptor) linkDescriptorsIterator.next(); >- EditPart sourceEditPart = getEditPartFor(nextLinkDescriptor.getSource()); >- EditPart targetEditPart = getEditPartFor(nextLinkDescriptor.getDestination()); >- if (sourceEditPart == null || targetEditPart == null) { >+ List result = new LinkedList(); >+ EObject nextValue; >+ int linkVID; >+ for (Iterator iter = getSemanticChildrenList().iterator(); iter.hasNext();) >+ { >+ Object obj = iter.next(); >+ if (!(obj instanceof EClass)) > continue; >- } >- CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(), null, ViewUtil.APPEND, >- false, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint()); >- CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor); >- ccr.setType(RequestConstants.REQ_CONNECTION_START); >- ccr.setSourceEditPart(sourceEditPart); >- sourceEditPart.getCommand(ccr); >- ccr.setTargetEditPart(targetEditPart); >- ccr.setType(RequestConstants.REQ_CONNECTION_END); >- Command cmd = targetEditPart.getCommand(ccr); >- if (cmd != null && cmd.canExecute()) { >- executeCommand(cmd); >- IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject(); >- SetViewMutabilityCommand.makeImmutable(viewAdapter).execute(); >+ >+ EClass modelObject = (EClass) obj; >+ for (Iterator values = modelObject.getEStructuralFeatures().iterator(); values.hasNext();) { >+ nextValue = (EObject) values.next(); >+ linkVID = EcoreVisualIDRegistry.getLinkWithClassVisualID(nextValue); >+ if (linkVID == EReferenceEditPart.VISUAL_ID || EReference2EditPart.VISUAL_ID == linkVID) >+ result.add(nextValue); > } > } >+ return result; > } > > /** > * @generated > */ >- private EditPart getEditPartFor(EObject modelElement) { >- View view = (View) myEObject2ViewMap.get(modelElement); >- if (view != null) { >- return (EditPart) getHost().getViewer().getEditPartRegistry().get(view); >- } >- return null; >- } >- >- /** >- *@generated >- */ >- private void storeLinks(EObject container, Diagram diagram) { >- EClass containerMetaclass = container.eClass(); >- storeFeatureModelFacetLinks(container, containerMetaclass, diagram); >- storeTypeModelFacetLinks(container, containerMetaclass); >+ protected EObject getSourceElement(EObject relationship) { >+ return relationship.eContainer(); > } > > /** > * @generated > */ >- private void storeTypeModelFacetLinks(EObject container, EClass containerMetaclass) { >- if (EcorePackage.eINSTANCE.getEClass().isSuperTypeOf(containerMetaclass)) { >- for (Iterator values = ((EClass) container).getEStructuralFeatures().iterator(); values.hasNext();) { >- EObject nextValue = ((EObject) values.next()); >- int linkVID = EcoreVisualIDRegistry.getLinkWithClassVisualID(nextValue); >- if (EReferenceEditPart.VISUAL_ID == linkVID) { >- Object structuralFeatureResult = ((ETypedElement) nextValue).getEType(); >- if (structuralFeatureResult instanceof EObject) { >- EObject dst = (EObject) structuralFeatureResult; >- EObject src = container; >- myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); >- } >- } >- } >- } >- if (EcorePackage.eINSTANCE.getEClass().isSuperTypeOf(containerMetaclass)) { >- for (Iterator values = ((EClass) container).getEStructuralFeatures().iterator(); values.hasNext();) { >- EObject nextValue = ((EObject) values.next()); >- int linkVID = EcoreVisualIDRegistry.getLinkWithClassVisualID(nextValue); >- if (EReference2EditPart.VISUAL_ID == linkVID) { >- Object structuralFeatureResult = ((ETypedElement) nextValue).getEType(); >- if (structuralFeatureResult instanceof EObject) { >- EObject dst = (EObject) structuralFeatureResult; >- EObject src = container; >- myLinkDescriptors.add(new LinkDescriptor(src, dst, nextValue, linkVID)); >- } >- } >- } >- } >- } >- >- /** >- *@generated >- */ >- private void storeFeatureModelFacetLinks(EObject container, EClass containerMetaclass, Diagram diagram) { >- >- if (EcorePackage.eINSTANCE.getEAnnotation().isSuperTypeOf(containerMetaclass)) { >- for (Iterator destinations = ((EAnnotation) container).getReferences().iterator(); destinations.hasNext();) { >- EObject nextDestination = (EObject) destinations.next(); >- myLinkDescriptors.add(new LinkDescriptor(container, nextDestination, EcoreElementTypes.EAnnotationReferences_4001, EAnnotationReferencesEditPart.VISUAL_ID)); >- >- } >- } >- >- if (EcorePackage.eINSTANCE.getEClass().isSuperTypeOf(containerMetaclass)) { >- for (Iterator destinations = ((EClass) container).getESuperTypes().iterator(); destinations.hasNext();) { >- EObject nextDestination = (EObject) destinations.next(); >- myLinkDescriptors.add(new LinkDescriptor(container, nextDestination, EcoreElementTypes.EClassESuperTypes_4004, EClassESuperTypesEditPart.VISUAL_ID)); >- >+ protected EObject getTargetElement(EObject relationship) { >+ if (relationship instanceof ETypedElement) >+ { >+ Object structuralFeatureResult = ((ETypedElement) relationship).getEType(); >+ if (structuralFeatureResult instanceof EObject) { >+ return (EObject) structuralFeatureResult; > } > } >- } >- >- /** >- * @generated >- */ >- private Diagram getDiagram() { >- return ((View) getHost().getModel()).getDiagram(); >- } >- >- /** >- * @generated >- */ >- private class LinkDescriptor { >- >- /** >- * @generated >- */ >- private EObject mySource; >- >- /** >- * @generated >- */ >- private EObject myDestination; >- >- /** >- * @generated >- */ >- private EObject myLinkElement; >- >- /** >- * @generated >- */ >- private int myVisualID; >- >- /** >- * @generated >- */ >- private IAdaptable mySemanticAdapter; >- >- /** >- * @generated >- */ >- protected LinkDescriptor(EObject source, EObject destination, EObject linkElement, int linkVID) { >- this(source, destination, linkVID); >- myLinkElement = linkElement; >- mySemanticAdapter = new EObjectAdapter(linkElement); >- } >- >- /** >- * @generated >- */ >- protected LinkDescriptor(EObject source, EObject destination, IElementType elementType, int linkVID) { >- this(source, destination, linkVID); >- myLinkElement = null; >- final IElementType elementTypeCopy = elementType; >- mySemanticAdapter = new IAdaptable() { >- >- public Object getAdapter(Class adapter) { >- if (IElementType.class.equals(adapter)) { >- return elementTypeCopy; >- } >- return null; >- } >- }; >- } >- >- /** >- * @generated >- */ >- private LinkDescriptor(EObject source, EObject destination, int linkVID) { >- mySource = source; >- myDestination = destination; >- myVisualID = linkVID; >- } >- >- /** >- * @generated >- */ >- protected EObject getSource() { >- return mySource; >- } >- >- /** >- * @generated >- */ >- protected EObject getDestination() { >- return myDestination; >- } >- >- /** >- * @generated >- */ >- protected EObject getLinkElement() { >- return myLinkElement; >- } >- >- /** >- * @generated >- */ >- protected int getVisualID() { >- return myVisualID; >- } >- >- /** >- * @generated >- */ >- protected IAdaptable getSemanticAdapter() { >- return mySemanticAdapter; >- } >+ return null; > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 141789
: 47815 |
47910