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 105408 Details for
Bug 226882
Support links with childMetaFeature not from container
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed solution
226882.patch (text/plain), 17.36 KB, created by
Artem Tikhomirov
on 2008-06-19 08:37:40 EDT
(
hide
)
Description:
Proposed solution
Filename:
MIME Type:
Creator:
Artem Tikhomirov
Created:
2008-06-19 08:37:40 EDT
Size:
17.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.codegen >Index: templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt,v >retrieving revision 1.31 >diff -u -r1.31 BaseItemSemanticEditPolicy.xpt >--- templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt 20 May 2008 15:45:10 -0000 1.31 >+++ templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt 19 Jun 2008 12:33:47 -0000 >@@ -15,6 +15,7 @@ > «IMPORT "http://www.eclipse.org/emf/2002/GenModel"» > > «EXTENSION xpt::diagram::editpolicies::Utils» >+«EXTENSION xpt::diagram::Utils» > «EXTENSION xpt::GenModelUtils» > «EXTENSION xpt::expressions::ValueExpression» > >@@ -377,20 +378,20 @@ > «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Link constraint evaluation error", e); «EXPAND xpt::Common::nonNLS» > return false; > } >-«ELSE» >+«ELSE-» > return true; > «ENDIF-» > } > «ENDDEFINE» > > «DEFINE canCreateParameters FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE» >-«DEFINE canCreateParameters FOR gmfgen::TypeLinkModelFacet»«IF null != sourceMetaFeature»«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container, «ENDIF»«EXPAND sourceTargetParameters»«ENDDEFINE» >+«DEFINE canCreateParameters FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource()»«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container, «ENDIF»«EXPAND sourceTargetParameters»«ENDDEFINE» > «DEFINE canCreateParameters FOR gmfgen::FeatureLinkModelFacet»«EXPAND sourceTargetParameters»«ENDDEFINE» > > «DEFINE sourceTargetParameters FOR gmfgen::LinkModelFacet»«EXPAND MetaModel::QualifiedClassName FOR getSourceType()» source, «EXPAND MetaModel::QualifiedClassName FOR getTargetType()» target«ENDDEFINE» > > «DEFINE canCreateValues FOR gmfgen::LinkModelFacet»«EXPAND incorrectLinkModelFacet»«ENDDEFINE» >-«DEFINE canCreateValues FOR gmfgen::TypeLinkModelFacet»«IF null != sourceMetaFeature»container, «ENDIF»source, target«ENDDEFINE» >+«DEFINE canCreateValues FOR gmfgen::TypeLinkModelFacet»«IF hasContainerOtherThanSource()»container, «ENDIF»source, target«ENDDEFINE» > «DEFINE canCreateValues FOR gmfgen::FeatureLinkModelFacet»source, target«ENDDEFINE» > > >Index: templates/xpt/diagram/editpolicies/LinkUtils.ext >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/LinkUtils.ext,v >retrieving revision 1.8 >diff -u -r1.8 LinkUtils.ext >--- templates/xpt/diagram/editpolicies/LinkUtils.ext 7 May 2008 13:55:59 -0000 1.8 >+++ templates/xpt/diagram/editpolicies/LinkUtils.ext 19 Jun 2008 12:33:47 -0000 >@@ -39,20 +39,7 @@ > ; > > boolean canBeContainer(gmfgen::GenLink link, genmodel::GenClass metaClass) : >- null != link.modelFacet && canBeLinkEnd(getContainerClass(link.modelFacet), metaClass) >-; >- >-private genmodel::GenClass getContainerClass(gmfgen::LinkModelFacet modelFacet) : >-// Should not be called >- null >-; >- >-private genmodel::GenClass getContainerClass(gmfgen::TypeLinkModelFacet modelFacet) : >- modelFacet.containmentMetaFeature.genClass >-; >- >-private genmodel::GenClass getContainerClass(gmfgen::FeatureLinkModelFacet modelFacet) : >- modelFacet.getSourceType() >+ null != link.modelFacet && canBeLinkEnd(link.modelFacet.getSourceType(), metaClass) > ; > > private boolean canBeLinkEnd(genmodel::GenClass endType, genmodel::GenClass metaClass) : >Index: src/org/eclipse/gmf/codegen/gmfgen/impl/TypeLinkModelFacetImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/TypeLinkModelFacetImpl.java,v >retrieving revision 1.15 >diff -u -r1.15 TypeLinkModelFacetImpl.java >--- src/org/eclipse/gmf/codegen/gmfgen/impl/TypeLinkModelFacetImpl.java 9 May 2007 16:19:09 -0000 1.15 >+++ src/org/eclipse/gmf/codegen/gmfgen/impl/TypeLinkModelFacetImpl.java 19 Jun 2008 12:33:47 -0000 >@@ -155,9 +155,9 @@ > public GenClass getSourceType() { > if (getSourceMetaFeature() != null) { > return getSourceMetaFeature().getTypeGenClass(); >- } else if (getContainmentMetaFeature() != null) { >- return getContainmentMetaFeature().getGenClass(); >- } >+ } else if (getChildMetaFeature() != null) { >+ return getChildMetaFeature().getGenClass(); >+ } // child feature defaults to be equal to containment, so if child == null, no reason to check containment > return null; > } > >Index: templates/xpt/diagram/commands/ReorientLinkUtils.xpt >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt,v >retrieving revision 1.9 >diff -u -r1.9 ReorientLinkUtils.xpt >--- templates/xpt/diagram/commands/ReorientLinkUtils.xpt 7 May 2008 13:56:00 -0000 1.9 >+++ templates/xpt/diagram/commands/ReorientLinkUtils.xpt 19 Jun 2008 12:33:47 -0000 >@@ -184,7 +184,7 @@ > «ENDDEFINE» > > «DEFINE checkLinkConstraint(gmfgen::GenLink link, String sourceVar, String targetVar) FOR gmfgen::TypeLinkModelFacet-» >- «IF sourceMetaFeature != null-» >+ «IF hasContainerOtherThanSource()-» > if (!(«EXPAND MetaModel::IsContainerInstance("getLink()", metaClass) FOR containmentMetaFeature.genClass»)) { > return false; > } >@@ -239,11 +239,11 @@ > Shouldn't we change link container here? > «ENDREM» > «DEFINE reorientSource FOR gmfgen::TypeLinkModelFacet-» >- «IF sourceMetaFeature != null-» >- «EXPAND changeTarget("getLink()", metaClass, "getOldSource()", "getNewSource()") FOR sourceMetaFeature-» >- «ELSE-» >- «EXPAND changeSource("getLink()", "getOldSource()", "getNewSource()", getSourceType()) FOR containmentMetaFeature-» >- «ENDIF-» >+«IF sourceMetaFeature != null-» >+ «EXPAND changeTarget("getLink()", metaClass, "getOldSource()", "getNewSource()") FOR sourceMetaFeature-» >+«ELSE-» >+ «EXPAND changeSource("getLink()", "getOldSource()", "getNewSource()", getSourceType()) FOR hasExplicitChildFeature() ? childMetaFeature : containmentMetaFeature-» >+«ENDIF-» > return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(getLink()); > «ENDDEFINE» > >Index: templates/xpt/diagram/commands/CreateLinkCommand.xpt >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt,v >retrieving revision 1.16 >diff -u -r1.16 CreateLinkCommand.xpt >--- templates/xpt/diagram/commands/CreateLinkCommand.xpt 7 May 2008 13:56:00 -0000 1.16 >+++ templates/xpt/diagram/commands/CreateLinkCommand.xpt 19 Jun 2008 12:33:47 -0000 >@@ -68,7 +68,7 @@ > «EXPAND xpt::Common::generatedMemberComment» > protected org.eclipse.emf.ecore.EObject doDefaultElementCreation() { > «EXPAND MetaModel::NewInstance("newElement") FOR metaClass-» >- «EXPAND CreateLinkUtils::addValue(sourceMetaFeature != null ? "getContainer()" : "getSource()", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-» >+ «EXPAND CreateLinkUtils::addValue(hasContainerOtherThanSource() ? "getContainer()" : "getSource()", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-» > «IF sourceMetaFeature != null-» > «EXPAND CreateLinkUtils::addValue("newElement", metaClass, "getSource()") FOR sourceMetaFeature-» > «ENDIF-» >Index: templates/xpt/diagram/commands/CreateLinkUtils.xpt >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt,v >retrieving revision 1.13 >diff -u -r1.13 CreateLinkUtils.xpt >--- templates/xpt/diagram/commands/CreateLinkUtils.xpt 7 May 2008 13:56:00 -0000 1.13 >+++ templates/xpt/diagram/commands/CreateLinkUtils.xpt 19 Jun 2008 12:33:47 -0000 >@@ -46,42 +46,40 @@ > «ENDDEFINE» > > «DEFINE canCreateElement(gmfgen::GenLink link) FOR gmfgen::TypeLinkModelFacet-» >- «IF sourceMetaFeature != null-» >+ «IF hasContainerOtherThanSource()-» > if (getContainer() == null) { > return false; > } > «ENDIF-» >- return «EXPAND validatorInvocation FOR link»( >- «IF sourceMetaFeature != null»getContainer(), «ENDIF»getSource(), getTarget()); >+ return «EXPAND validatorInvocation FOR link»(«IF hasContainerOtherThanSource()»getContainer(), «ENDIF»getSource(), getTarget()); > «ENDDEFINE» > > «DEFINE validatorInvocation FOR gmfgen::GenLink-» >-«diagram.getBaseItemSemanticEditPolicyQualifiedClassName()». >- «diagram.getLinkCreationConstraintsClassName()».canCreate«getUniqueIdentifier()-» >+«diagram.getBaseItemSemanticEditPolicyQualifiedClassName()».«diagram.getLinkCreationConstraintsClassName()».canCreate«getUniqueIdentifier()-» > «ENDDEFINE» > > «REM» > Fields of command that creates link. > «ENDREM» >-«DEFINE fields FOR gmfgen::LinkModelFacet-» >- >+«DEFINE fields FOR gmfgen::LinkModelFacet» > «EXPAND xpt::Common::generatedMemberComment» > private final org.eclipse.emf.ecore.EObject source; > > «EXPAND xpt::Common::generatedMemberComment» > private final org.eclipse.emf.ecore.EObject target; >- «EXPAND containerField-» > «ENDDEFINE» > >-«DEFINE containerField FOR gmfgen::LinkModelFacet-» >-«ENDDEFINE» >+«DEFINE fields FOR gmfgen::TypeLinkModelFacet» >+ «EXPAND xpt::Common::generatedMemberComment» >+ private final org.eclipse.emf.ecore.EObject source; > >-«DEFINE containerField FOR gmfgen::TypeLinkModelFacet-» >- «IF sourceMetaFeature != null-» >+ «EXPAND xpt::Common::generatedMemberComment» >+ private final org.eclipse.emf.ecore.EObject target; >+«IF hasContainerOtherThanSource()» > > «EXPAND xpt::Common::generatedMemberComment» >- private «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container; >- «ENDIF-» >+ private final «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container; >+«ENDIF-» > «ENDDEFINE» > > «REM» >@@ -101,17 +99,33 @@ > «EXPAND containerAccessor-» > «ENDDEFINE» > >-«DEFINE containerAccessor FOR gmfgen::LinkModelFacet-» >-«ENDDEFINE» >+«DEFINE containerAccessor FOR gmfgen::LinkModelFacet»«ENDDEFINE» > > «DEFINE containerAccessor FOR gmfgen::TypeLinkModelFacet-» >- «IF sourceMetaFeature != null-» >+«IF hasContainerOtherThanSource()-» > > «EXPAND xpt::Common::generatedMemberComment» > public «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» getContainer() { > return container; > } >- «ENDIF-» >+ >+ «EXPAND xpt::Common::generatedMemberComment( >+ "Default approach is to traverse ancestors of the source to find instance of container.\n" + >+ "Modify with appropriate logic." >+ )» >+ private static «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» deduceContainer(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject target) { >+ // Find container element for the new link. >+ // Climb up by containment hierarchy starting from the source >+ // and return the first element that is instance of the container class. >+ for (org.eclipse.emf.ecore.EObject element = source; element != null; element = element.eContainer()) { >+ if («EXPAND MetaModel::IsInstance("element") FOR containmentMetaFeature.genClass») { >+ return «EXPAND MetaModel::CastEObject("element") FOR containmentMetaFeature.genClass»; >+ } >+ } >+ return null; >+ } >+«ENDIF-» >+ > «ENDDEFINE» > > «REM» >@@ -120,40 +134,27 @@ > «DEFINE init FOR gmfgen::LinkModelFacet-» > this.source = source; > this.target = target; >- «EXPAND initContainment-» >-«ENDDEFINE» >- >-«DEFINE initContainment FOR gmfgen::LinkModelFacet-» > «ENDDEFINE» > >-«DEFINE initContainment FOR gmfgen::TypeLinkModelFacet-» >+«DEFINE init FOR gmfgen::TypeLinkModelFacet-» >+ this.source = source; >+ this.target = target; > if (request.getContainmentFeature() == null) { > setContainmentFeature(«EXPAND MetaModel::MetaFeature FOR containmentMetaFeature»); > } > «REM»XXX!!! >- (1) why getContainer() only when sourceMetaFeature is set >- (2) FIXME - do not need to setElementToEdit unless use doDefaultElementCreation (no) and canExecute from [Create|Edit]ElementCommand (no, IMO) >+ FIXME - do not need to setElementToEdit unless use doDefaultElementCreation (no) and canExecute from [Create|Edit]ElementCommand (no, IMO) > «ENDREM» >- «IF sourceMetaFeature != null-» >- // Find container element for the new link. >- // Climb up by containment hierarchy starting from the source >- // and return the first element that is instance of the container class. >- for (org.eclipse.emf.ecore.EObject element = source; element != null; element = element.eContainer()) { >- if («EXPAND MetaModel::IsInstance("element") FOR containmentMetaFeature.genClass») { >- container = «EXPAND MetaModel::CastEObject("element") FOR containmentMetaFeature.genClass»; >- super.«EXPAND setElementToEdit("container") FOR containmentMetaFeature-» >- break; >- } >+ «IF hasContainerOtherThanSource()-» >+ container = deduceContainer(source, target); >+ if (container != null) { >+ super.setElementToEdit(«EXPAND MetaModel::DowncastToEObject("container") FOR containmentMetaFeature.genClass»); > } > «ELSE-» >- super.«EXPAND setElementToEdit("source") FOR containmentMetaFeature-» >+ super.setElementToEdit(«EXPAND MetaModel::DowncastToEObject("source") FOR containmentMetaFeature.genClass»); > «ENDIF-» > «ENDDEFINE» > >-«DEFINE setElementToEdit(String elementVar) FOR genmodel::GenFeature-» >- setElementToEdit(«EXPAND MetaModel::DowncastToEObject(elementVar) FOR genClass»); >-«ENDDEFINE» >- > «DEFINE addValue(String containerVar, genmodel::GenClass containerClass, String valueVar) FOR genmodel::GenFeature-» > «IF isListType()-» > «EXPAND MetaModel::getFeatureValue(containerVar, containerClass)».add(«valueVar»); >Index: templates/xpt/diagram/Utils.ext >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/Utils.ext,v >retrieving revision 1.8 >diff -u -r1.8 Utils.ext >--- templates/xpt/diagram/Utils.ext 7 May 2008 13:56:02 -0000 1.8 >+++ templates/xpt/diagram/Utils.ext 19 Jun 2008 12:33:47 -0000 >@@ -1,5 +1,5 @@ > /* >- * Copyright (c) 2006 Borland Software Corporation >+ * Copyright (c) 2006, 2008 Borland Software Corporation > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -30,6 +30,17 @@ > !isDerived(facet.childMetaFeature) && facet.childMetaFeature != facet.containmentMetaFeature > ; > >+// true when link is contained in an object other than link's source, >+// (1) sourceMetaFeature is specified >+// (2) childMetaFeature is not the same as containment and belongs to a different class than container >+// for (2), consider scenario from bug #226882, container "A", that holds link "L" and link's source and target, >+// "N1" and "N2". "N1" has a reference to "L" which is being used as childMetaFeature. Hence, link's container, "C" >+// is different from link's source, "N1". As nothing can prevent "C" from subclassing "N1", there's no sure way to >+// tell if container is really different from the source or not, and we'd better assume they are different. >+boolean hasContainerOtherThanSource(gmfgen::TypeLinkModelFacet facet) : >+ facet.sourceMetaFeature != null || facet.childMetaFeature != facet.containmentMetaFeature >+; >+ > List[gmfgen::GenLink] getOutgoingLinks(gmfgen::GenNode node) : > node.getDiagram().links.select(link | link.getAssistantSources().contains(node)) > ; >Index: templates/xpt/diagram/updater/DiagramUpdater.xpt >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/updater/DiagramUpdater.xpt,v >retrieving revision 1.31 >diff -u -r1.31 DiagramUpdater.xpt >--- templates/xpt/diagram/updater/DiagramUpdater.xpt 7 May 2008 13:56:02 -0000 1.31 >+++ templates/xpt/diagram/updater/DiagramUpdater.xpt 19 Jun 2008 12:33:47 -0000 >@@ -283,7 +283,7 @@ > «DEFINE getContainedLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-» > > «EXPAND xpt::Common::generatedMemberComment» >-private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink»(«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container) { >+private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink»(«EXPAND MetaModel::QualifiedClassName FOR getSourceType()» container) { > «EXPAND getContainedLinksByTypeMethodBody(genLink, false)-» > } > «ENDDEFINE» >@@ -292,7 +292,7 @@ > java.util.Collection result = new java.util.LinkedList(); > «LET childMetaFeature.isListType() AS inLoop-» > «IF inLoop-» >-for (java.util.Iterator links = «EXPAND MetaModel::getFeatureValue("container", containmentMetaFeature.genClass) FOR childMetaFeature».iterator(); links.hasNext();) { >+for (java.util.Iterator links = «EXPAND MetaModel::getFeatureValue("container", childMetaFeature.genClass) FOR childMetaFeature».iterator(); links.hasNext();) { > org.eclipse.emf.ecore.EObject linkObject = (org.eclipse.emf.ecore.EObject ) links.next(); > if («EXPAND MetaModel::NotInstance("linkObject") FOR metaClass») { > continue;
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 226882
:
95876
|
95877
|
95878
|
104977
|
104978
|
104979
| 105408