Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] URI for a structural feature in override.


Hi Janak,

The code you shown is how you do it:

InverseMaintenanceAdapter.getFirstReferencedBy(component,
JavaInstantiation.getReference(component,
JFCConstants.SF_CONSTRAINT_COMPONENT))


component is the child (in your case the ULCPanel), and JFCConstants.SF_CONSTRAINT_COMPONENT is the URI for the feature.

Let's take a simpler example. The constraint component is more complicated because it is referencing a feature of a dynamic EMF class instead of a JavaClass. Let's take the example of the java.awt.Container components feature. The URI would be:

URI.createURI("java:/java.awt#Container/components");

Here
  • the "java:/" indicates it is pointing to a java class that we have reflected/introspected.  
  • the "java.awt" is the package name of the class and the "#" is used as a separator.
  • the "Container" is the name of the class within the package and the "/" is used as a separator between the class and the property
  • the "components" is the name of the components feature.

I could go into detail as to the XMI/EMF significance of this format, but I don't think you really care. What I've shown is how you access a feature of a JavaClass and is all you really need to know.

JavaInstantiation.getReference(component, featureURI) is a helper method to get the true EReference of the URI represents. The component used is actually immaterial. It simply needs to be any IJavaInstance in the VE's EMF model. It is used to find the proper EMF ResourceSet for the project that contains the JavaClasses for that project.
 
Rich


"Janak Mulani" <janak.mulani@xxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

01/31/2006 12:46 PM

Please respond to
Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

To
"Discussions people developing code for the Visual Editor project" <ve-dev@xxxxxxxxxxx>
cc
Subject
RE: [ve-dev] URI for a structural feature in override.





Hi Rich,

>I'm not clear on the question. where exactly in the override file do you
want to ref the feature.

I don't want to refer to it in the override file. I want to access it in my
Java code.

For example, if I have a ULCFrame and ULCPanel and
ULCFrame-contentPane-ULCPanel. Then for a ULCPanel I want to find out using
Invers Maint Adapter, that it has a back ref to ULCFrame.

>And I don't understand how that
>relates to inverse maint adapter. Your question about the inv. maint.
basically says return the first guy that has its "constraint >component"
feature set to me.

I just gave that as an example. Sorry to have caused confusion by not
mentioning that.

Thanks and regards,

Janak

--------------------------------------------------------------
In the following override file for a Java class
com.ulcjava.base.application.ULCRootPane, I want to access a structural
feature "contentPane".

How do I specify the URI for it so that I can use to obtain an EReference
using
InverseMaintenanceAdapter.getFirstReferencedBy(component,
JavaInstantiation.getReference(component,
JFCConstants.SF_CONSTRAINT_COMPONENT))

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/int
ernal/cde/decorators.ecore"
  xmlns:org.eclipse.ve.internal.cde.utility="http:///org/eclipse/ve/intern
al/cde/utility.ecore"
xmlns:org.eclipse.ve.internal.jcm="http:///org/eclipse/ve/internal/jcm.ecore
"
  xmlns:codeGenHelpers="platform:/plugin/org.eclipse.ve.java.core/override
s/codegenHelpers.ecore"
  xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:event="event.xmi">

 <event:Add  featureName="eAnnotations">

  <addedEObjects xsi:type="codeGenHelpers:CodeGenHelperClass"
source="codegen.CodeGenHelperClass"
                      expDecoder="com.canoo.ulc.visualeditor/com.canoo.ulc.
visualeditor.co
degen.ULCRootPaneDecoder"
                      modelled="true"/>
</event:Add>


<event:Add  featureName="eStructuralFeatures">
  <addedEObjects xsi:type="ecore:EReference" name="components"
                                                        eType="ecore:EClass
java:/com.ulcjava.base.application#ULCComponent"
                                           upperBound="1"
unsettable="false" changeable="true"
                                           containment="false">
                                 <eAnnotations
xsi:type="org.eclipse.ve.internal.cde.decorators:PropertyDescriptorDecorator
"  hidden="true"/>
      <eAnnotations
xsi:type="org.eclipse.ve.internal.jcm:BeanFeatureDecorator"
linkType="CHILD"/>
  </addedEObjects>
</event:Add>
<event:Add  featureName="eStructuralFeatures">
  <addedEObjects xsi:type="ecore:EReference" name="contentPane"
                                                        eType="ecore:EClass
java:/com.ulcjava.base.application#ULCComponent"
                                           upperBound="1"
unsettable="false" changeable="true"
                                           containment="false">
      <eAnnotations
xsi:type="org.eclipse.ve.internal.jcm:BeanFeatureDecorator"
linkType="CHILD"/>
  </addedEObjects>
</event:Add>
<event:Add  featureName="eStructuralFeatures">
  <addedEObjects xsi:type="ecore:EReference" name="menuBar"
unsettable="true">
    <eAnnotations
xsi:type="org.eclipse.ve.internal.jcm:BeanFeatureDecorator"
linkType="CHILD"/>
  </addedEObjects>
</event:Add>
</xmi:XMI>


_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev

_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top