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 184197 Details for
Bug 330482
[diagram] Support diagram editing in Sapphire UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
A basic diagram editor based on Graphiti
patch_sapphire_editor2.txt (text/plain), 111.17 KB, created by
Shenxue Zhou
on 2010-11-30 17:49:31 EST
(
hide
)
Description:
A basic diagram editor based on Graphiti
Filename:
MIME Type:
Creator:
Shenxue Zhou
Created:
2010-11-30 17:49:31 EST
Size:
111.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.sapphire.samples >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.samples/META-INF/MANIFEST.MF,v >retrieving revision 1.2 >diff -u -r1.2 MANIFEST.MF >--- META-INF/MANIFEST.MF 16 Nov 2010 04:26:06 -0000 1.2 >+++ META-INF/MANIFEST.MF 30 Nov 2010 22:44:07 -0000 >@@ -12,7 +12,12 @@ > org.eclipse.wst.xml.ui, > org.eclipse.ui, > org.eclipse.ui.views, >- org.eclipse.help >+ org.eclipse.help, >+ org.eclipse.emf.transaction, >+ org.eclipse.ui.views.properties.tabbed, >+ org.eclipse.gef, >+ org.eclipse.graphiti, >+ org.eclipse.graphiti.ui > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Vendor: %providerName >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.samples/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 16 Nov 2010 04:26:05 -0000 1.2 >+++ plugin.xml 30 Nov 2010 22:44:07 -0000 >@@ -146,5 +146,15 @@ > id="org.eclipse.sapphire.samples.ezbug.ui.BugDatabaseEditor" > name="Bug Database Editor (Sapphire Sample)"/> > </extension> >+ >+ <extension point="org.eclipse.ui.editors"> >+ <editor >+ class="org.eclipse.sapphire.samples.map.ui.MapEditor" >+ default="true" >+ filenames="map.xml" >+ id="org.eclipse.sapphire.samples.map.ui.MapEditor" >+ name="Map Editor"/> >+ </extension> >+ > > </plugin> >Index: sdef/MapEditor.sdef >=================================================================== >RCS file: sdef/MapEditor.sdef >diff -N sdef/MapEditor.sdef >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ sdef/MapEditor.sdef 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+<definition> >+ >+ <import> >+ <bundle>org.eclipse.sapphire.samples</bundle> >+ <package>org.eclipse.sapphire.samples.map</package> >+ <package>org.eclipse.sapphire.samples.map.ui</package> >+ </import> >+ >+ <diagram-page> >+ <id>diagram</id> >+ <page-name>Diagram</page-name> >+ <page-header-text>Diagram</page-header-text> >+ <node> >+ <id>destinations</id> >+ <tool-palette-label>Destination</tool-palette-label> >+ <tool-palette-desc>Map Destination</tool-palette-desc> >+ <property>Destinations</property> >+ <label>${ Name == null ? "<Destination>" : Name }</label> >+ </node> >+ <connection> >+ <id>connections</id> >+ <tool-palette-label>Route</tool-palette-label> >+ <tool-palette-desc>Map Route</tool-palette-desc> >+ <property>Routes</property> >+ <label>${ Distance == null ? "<Distance>" : Distance }</label> >+ <endpoint1> >+ <property>FromDestination</property> >+ <value>${Name}</value> >+ <type>NONE</type> >+ </endpoint1> >+ <endpoint2> >+ <property>ToDestination</property> >+ <value>${Name}</value> >+ <type>ARROW</type> >+ </endpoint2> >+ </connection> >+ </diagram-page> >+ >+ <editor-page> >+ <id>overview</id> >+ <page-name>Overview</page-name> >+ <page-header-text>Overview</page-header-text> >+ <root-node> >+ <node> >+ <label>Destinations</label> >+ <section> >+ <description>Destinations in the map</description> >+ <content> >+ <property-editor>Destinations</property-editor> >+ </content> >+ </section> >+ </node> >+ <node> >+ <label>Routes</label> >+ <section> >+ <description>Routes in the map</description> >+ <content> >+ <property-editor>Routes</property-editor> >+ </content> >+ </section> >+ </node> >+ </root-node> >+ </editor-page> >+</definition> >+ >\ No newline at end of file >Index: src/org/eclipse/sapphire/samples/map/IDestination.java >=================================================================== >RCS file: src/org/eclipse/sapphire/samples/map/IDestination.java >diff -N src/org/eclipse/sapphire/samples/map/IDestination.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/samples/map/IDestination.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+package org.eclipse.sapphire.samples.map; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.annotations.NonNullValue; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+ >+@GenerateImpl >+ >+public interface IDestination extends IModelElement >+{ >+ ModelElementType TYPE = new ModelElementType( IDestination.class ); >+ >+ // *** Name *** >+ >+ @XmlBinding( path = "name" ) >+ @Label( standard = "name" ) >+ @NonNullValue >+ //@DefaultValue( text = "Destination" ) >+ >+ ValueProperty PROP_NAME = new ValueProperty( TYPE, "Name" ); >+ >+ Value<String> getName(); >+ void setName( String name ); >+ >+} >Index: src/org/eclipse/sapphire/samples/map/IMap.java >=================================================================== >RCS file: src/org/eclipse/sapphire/samples/map/IMap.java >diff -N src/org/eclipse/sapphire/samples/map/IMap.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/samples/map/IMap.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+package org.eclipse.sapphire.samples.map; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ListProperty; >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Type; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlListBinding; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlRootBinding; >+ >+@GenerateImpl >+@XmlRootBinding( elementName = "map") >+ >+public interface IMap extends IModelElement >+{ >+ ModelElementType TYPE = new ModelElementType( IMap.class ); >+ >+ // *** Destinations *** >+ >+ @Type( base = IDestination.class ) >+ @XmlListBinding( mappings = @XmlListBinding.Mapping( element = "destination", type = IDestination.class ) ) >+ >+ ListProperty PROP_DESTINATIONS = new ListProperty( TYPE, "Destinations" ); >+ >+ ModelElementList<IDestination> getDestinations(); >+ >+ // *** Routes *** >+ >+ @Type( base = IRoute.class ) >+ @XmlListBinding( mappings = @XmlListBinding.Mapping( element = "route", type = IRoute.class ) ) >+ >+ ListProperty PROP_ROUTES = new ListProperty( TYPE, "Routes" ); >+ >+ ModelElementList<IRoute> getRoutes(); >+ >+} >Index: src/org/eclipse/sapphire/samples/map/IRoute.java >=================================================================== >RCS file: src/org/eclipse/sapphire/samples/map/IRoute.java >diff -N src/org/eclipse/sapphire/samples/map/IRoute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/samples/map/IRoute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+package org.eclipse.sapphire.samples.map; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ReferenceValue; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.annotations.NonNullValue; >+import org.eclipse.sapphire.modeling.annotations.Reference; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+import org.eclipse.sapphire.samples.map.internal.DestinationReferenceService; >+ >+@GenerateImpl >+ >+public interface IRoute extends IModelElement >+{ >+ ModelElementType TYPE = new ModelElementType( IRoute.class ); >+ >+ // *** FromDestination *** >+ >+ @Reference( target = IDestination.class, service = DestinationReferenceService.class ) >+ @XmlBinding( path = "from-destination") >+ @NonNullValue >+ @Label(standard = "from destination") >+ >+ ValueProperty PROP_FROM_DESTINATION = new ValueProperty( TYPE, "FromDestination" ); >+ >+ ReferenceValue<IDestination> getFromDestination(); >+ void setFromDestination( String name ); >+ >+ // *** ToDestination *** >+ >+ @Reference( target = IDestination.class, service = DestinationReferenceService.class ) >+ @XmlBinding( path = "to-destination") >+ @NonNullValue >+ @Label(standard = "to destination") >+ >+ ValueProperty PROP_TO_DESTINATION = new ValueProperty( TYPE, "ToDestination" ); >+ >+ ReferenceValue<IDestination> getToDestination(); >+ void setToDestination( String name ); >+ >+ // *** Distance *** >+ >+ @XmlBinding( path = "distance" ) >+ @Label( standard = "distance" ) >+ @NonNullValue >+ >+ ValueProperty PROP_DISTANCE = new ValueProperty( TYPE, "Distance" ); >+ >+ Value<String> getDistance(); >+ void setDistance( String distance ); >+ >+} >Index: src/org/eclipse/sapphire/samples/map/internal/DestinationReferenceService.java >=================================================================== >RCS file: src/org/eclipse/sapphire/samples/map/internal/DestinationReferenceService.java >diff -N src/org/eclipse/sapphire/samples/map/internal/DestinationReferenceService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/samples/map/internal/DestinationReferenceService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+package org.eclipse.sapphire.samples.map.internal; >+ >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.modeling.ReferenceService; >+import org.eclipse.sapphire.samples.map.IDestination; >+import org.eclipse.sapphire.samples.map.IMap; >+ >+public class DestinationReferenceService extends ReferenceService >+{ >+ >+ @Override >+ public Object resolve(String reference) >+ { >+ if (reference != null) >+ { >+ IMap map = element().nearest(IMap.class); >+ ModelElementList<IDestination> dests = map.getDestinations(); >+ for (IDestination dest : dests) >+ { >+ if (reference.equals(dest.getName().getContent())) >+ { >+ return dest; >+ } >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/samples/map/ui/MapEditor.java >=================================================================== >RCS file: src/org/eclipse/sapphire/samples/map/ui/MapEditor.java >diff -N src/org/eclipse/sapphire/samples/map/ui/MapEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/samples/map/ui/MapEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+package org.eclipse.sapphire.samples.map.ui; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.xml.RootXmlResource; >+import org.eclipse.sapphire.samples.map.IMap; >+import org.eclipse.sapphire.ui.SapphireEditor; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPart; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditor; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditorInput; >+import org.eclipse.sapphire.ui.editor.views.masterdetails.MasterDetailsPage; >+import org.eclipse.sapphire.ui.xml.XmlEditorResourceStore; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.part.FileEditorInput; >+import org.eclipse.wst.sse.ui.StructuredTextEditor; >+ >+public class MapEditor extends SapphireEditor >+{ >+ private IMap modelMap; >+ private StructuredTextEditor mapSourceEditor; >+ private SapphireDiagramEditorPart mapDiagramPart; >+ private MasterDetailsPage mapOverviewPage; >+ >+ public MapEditor() >+ { >+ super( "org.eclipse.sapphire.samples" ); >+ } >+ >+ @Override >+ protected void createSourcePages() throws PartInitException >+ { >+ this.mapSourceEditor = new StructuredTextEditor(); >+ this.mapSourceEditor.setEditorPart(this); >+ final FileEditorInput rootEditorInput = (FileEditorInput) getEditorInput(); >+ >+ int index = addPage( this.mapSourceEditor, rootEditorInput ); >+ setPageText( index, "map.xml" ); >+ } >+ >+ @Override >+ protected IModelElement createModel() >+ { >+ this.modelMap = IMap.TYPE.instantiate(new RootXmlResource(new XmlEditorResourceStore(this, this.mapSourceEditor))); >+ return this.modelMap; >+ } >+ >+ @Override >+ protected void createDiagramPages() throws PartInitException >+ { >+ IPath path = new Path( "org.eclipse.sapphire.samples/sdef/MapEditor.sdef/diagram" ); >+ this.mapDiagramPart = new SapphireDiagramEditorPart(this, this.modelMap, path); >+ SapphireDiagramEditor diagramEditor = this.mapDiagramPart.getDiagramEditor(); >+ SapphireDiagramEditorInput diagramEditorInput = this.mapDiagramPart.getDiagramEditorInput(); >+ addPage(0, diagramEditor, diagramEditorInput); >+ setPageText( 0, "Diagram" ); >+ setPageId(this.pages.get(0), "Diagram"); >+ } >+ >+ @Override >+ protected void createFormPages() throws PartInitException >+ { >+ IPath path = new Path( "org.eclipse.sapphire.samples/sdef/MapEditor.sdef/overview" ); >+ this.mapOverviewPage = new MasterDetailsPage(this, this.modelMap, path); >+ addPage(1, this.mapOverviewPage); >+ setPageText(1, "Overview"); >+ setPageId(this.pages.get(1), "Overview"); >+ } >+ >+ public IMap getMap() >+ { >+ return this.modelMap; >+ } >+} >#P org.eclipse.sapphire.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 27 Nov 2010 03:44:29 -0000 1.3 >+++ META-INF/MANIFEST.MF 30 Nov 2010 22:44:08 -0000 >@@ -19,7 +19,9 @@ > org.eclipse.sapphire.ui.swt.renderer, > org.eclipse.sapphire.ui.swt.renderer.actions, > org.eclipse.sapphire.ui.util, >- org.eclipse.sapphire.ui.xml >+ org.eclipse.sapphire.ui.xml, >+ org.eclipse.sapphire.ui.diagram.editor, >+ org.eclipse.sapphire.ui.diagram.graphiti.editor > Require-Bundle: org.eclipse.debug.ui, > org.eclipse.jdt.ui, > org.eclipse.ui.forms;visibility:=reexport, >@@ -37,6 +39,13 @@ > org.eclipse.help, > org.eclipse.ui.views, > org.eclipse.jface.text, >- org.apache.ant >+ org.apache.ant, >+ org.eclipse.gef, >+ org.eclipse.graphiti, >+ org.eclipse.graphiti.mm, >+ org.eclipse.graphiti.pattern, >+ org.eclipse.graphiti.ui, >+ org.eclipse.emf.transaction, >+ org.eclipse.ui.views.properties.tabbed > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.5 >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/plugin.properties,v >retrieving revision 1.2 >diff -u -r1.2 plugin.properties >--- plugin.properties 16 Nov 2010 04:26:07 -0000 1.2 >+++ plugin.properties 30 Nov 2010 22:44:08 -0000 >@@ -15,3 +15,7 @@ > showInSourceCommandName = Show in Source > showInSourceCommandDescription = Shows the location in the source file that corresponds to the selected entity. > builderName = Sapphire UI Builder >+sapphireDiagramTypeDescription = Sapphire Diagram Type >+sapphireDiagramTypeName = Sapphire Diagram Type >+sapphireDiagramTypeProviderDescription = Sapphire Diagram Type Provider >+sapphireDiagramTypeProviderName = Sapphire Diagram Type Provider >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 27 Nov 2010 03:44:29 -0000 1.3 >+++ plugin.xml 30 Nov 2010 22:44:08 -0000 >@@ -24,4 +24,23 @@ > </builder> > </extension> > >+ <extension point="org.eclipse.graphiti.ui.diagramTypes"> >+ <diagramType >+ description="%sapphireDiagramTypeDescription" >+ id="org.eclipse.sapphire.ui.SapphireDiagramType" >+ name="%sapphireDiagramTypeName" >+ type="sapphireDiagram"> >+ </diagramType> >+ </extension> >+ >+ <extension point="org.eclipse.graphiti.ui.diagramTypeProviders"> >+ <diagramTypeProvider >+ class="org.eclipse.sapphire.ui.diagram.graphiti.providers.SapphireDiagramTypeProvider" >+ description="%sapphireDiagramTypeProviderDescription" >+ id="org.eclipse.sapphire.ui.sapphireDiagramTypeProvider" >+ name="%sapphireDiagramTypeProviderName"> >+ <diagramType id="org.eclipse.sapphire.ui.SapphireDiagramType"/> >+ </diagramTypeProvider> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/sapphire/ui/SapphireEditor.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/SapphireEditor.java,v >retrieving revision 1.4 >diff -u -r1.4 SapphireEditor.java >--- src/org/eclipse/sapphire/ui/SapphireEditor.java 23 Nov 2010 20:18:30 -0000 1.4 >+++ src/org/eclipse/sapphire/ui/SapphireEditor.java 30 Nov 2010 22:44:08 -0000 >@@ -18,6 +18,7 @@ > import java.net.URI; > import java.util.Collections; > import java.util.HashMap; >+import java.util.Iterator; > import java.util.Map; > import java.util.Set; > >@@ -285,6 +286,8 @@ > this.model = createModel(); > adaptModel( this.model ); > >+ createDiagramPages(); >+ > createFormPages(); > > createFileChangeListener(); >@@ -330,6 +333,12 @@ > protected abstract void createSourcePages() throws PartInitException; > protected abstract void createFormPages() throws PartInitException; > >+ // default impl does nothing, subclass may override it to add diagram pages >+ protected void createDiagramPages() throws PartInitException >+ { >+ >+ } >+ > protected final void setPageId( final Object page, > final String id ) > { >Index: src/org/eclipse/sapphire/ui/def/ISapphireUiDef.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.sapphire/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/def/ISapphireUiDef.java,v >retrieving revision 1.2 >diff -u -r1.2 ISapphireUiDef.java >--- src/org/eclipse/sapphire/ui/def/ISapphireUiDef.java 16 Nov 2010 04:26:02 -0000 1.2 >+++ src/org/eclipse/sapphire/ui/def/ISapphireUiDef.java 30 Nov 2010 22:44:08 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.sapphire.modeling.xml.annotations.XmlListBinding; > import org.eclipse.sapphire.modeling.xml.annotations.XmlRootBinding; > import org.eclipse.sapphire.ui.def.internal.SapphireUiDefMethods; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramPageDef; > > /** > * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> >@@ -129,6 +130,15 @@ > > ModelElementList<IEditorPageDef> getEditorPageDefs(); > >+ // *** DiagramPageDefs *** >+ >+ @Type( base = IDiagramPageDef.class ) >+ @XmlListBinding( mappings = @XmlListBinding.Mapping( element = "diagram-page", type = IDiagramPageDef.class ) ) >+ >+ ListProperty PROP_DIAGRAM_PAGE_DEFS = new ListProperty( TYPE, "DiagramPageDefs" ); >+ >+ ModelElementList<IDiagramPageDef> getDiagramPageDefs(); >+ > // *** DialogDefs *** > > @Type( base = ISapphireDialogDef.class ) >Index: src/org/eclipse/sapphire/ui/def/SapphireDiagramDefFactory.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/def/SapphireDiagramDefFactory.java >diff -N src/org/eclipse/sapphire/ui/def/SapphireDiagramDefFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/def/SapphireDiagramDefFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+package org.eclipse.sapphire.ui.def; >+ >+import org.eclipse.sapphire.modeling.BundleResourceStore; >+import org.eclipse.sapphire.modeling.ResourceStoreException; >+import org.eclipse.sapphire.modeling.SharedModelsCache; >+import org.eclipse.sapphire.modeling.xml.RootXmlResource; >+import org.eclipse.sapphire.modeling.xml.XmlResourceStore; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramPageDef; >+import org.eclipse.sapphire.ui.internal.SapphireUiFrameworkPlugin; >+ >+public class SapphireDiagramDefFactory >+{ >+ public static IDiagramPageDef load(final String bundleId, final String path) >+ { >+ try >+ { >+ return load( new XmlResourceStore( new BundleResourceStore( bundleId, path ) ), false ); >+ } >+ catch( ResourceStoreException e ) >+ { >+ SapphireUiFrameworkPlugin.log( e ); >+ return null; >+ } >+ } >+ >+ public static IDiagramPageDef load( final XmlResourceStore resourceStore, >+ final boolean writable ) >+ { >+ IDiagramPageDef model; >+ >+ if( writable ) >+ { >+ model = IDiagramPageDef.TYPE.instantiate( new RootXmlResource( resourceStore ) ); >+ } >+ else >+ { >+ final SharedModelsCache.StandardKey key = new SharedModelsCache.StandardKey( resourceStore, IDiagramPageDef.TYPE ); >+ >+ model = (IDiagramPageDef) SharedModelsCache.retrieve( key ); >+ >+ if( model == null ) >+ { >+ model = IDiagramPageDef.TYPE.instantiate( new RootXmlResource( resourceStore ) ); >+ SharedModelsCache.store( key, model ); >+ } >+ } >+ return model; >+ } >+ >+} >+ >Index: src/org/eclipse/sapphire/ui/diagram/def/ConnectionEndpointType.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/def/ConnectionEndpointType.java >diff -N src/org/eclipse/sapphire/ui/diagram/def/ConnectionEndpointType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/def/ConnectionEndpointType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,10 @@ >+package org.eclipse.sapphire.ui.diagram.def; >+ >+ >+public enum ConnectionEndpointType >+{ >+ NONE, >+ ARROW, >+ CIRCLE, >+ ELLIPSE; >+} >Index: src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionDef.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionDef.java >diff -N src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionDef.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionDef.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+package org.eclipse.sapphire.ui.diagram.def; >+ >+import org.eclipse.sapphire.modeling.ElementProperty; >+import org.eclipse.sapphire.modeling.ModelElementHandle; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.annotations.Type; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+import org.eclipse.sapphire.ui.def.ISapphirePartDef; >+ >+@GenerateImpl >+ >+public interface IDiagramConnectionDef >+ >+ extends ISapphirePartDef >+ >+{ >+ ModelElementType TYPE = new ModelElementType( IDiagramConnectionDef.class ); >+ >+ // *** Id *** >+ >+ @Label( standard = "ID" ) >+ @XmlBinding( path = "id" ) >+ >+ ValueProperty PROP_ID = new ValueProperty( TYPE, "Id" ); >+ >+ Value<String> getId(); >+ void setId( String id ); >+ >+ // *** Property *** >+ >+ @Label( standard = "property" ) >+ @XmlBinding( path = "property" ) >+ >+ ValueProperty PROP_PROPERTY = new ValueProperty( TYPE, "Property" ); >+ >+ Value<String> getProperty(); >+ void setProperty( String property ); >+ >+ // *** ToolPaletteLabel *** >+ >+ @Label( standard = "tool palette label" ) >+ @XmlBinding( path = "tool-palette-label" ) >+ >+ ValueProperty PROP_TOOL_PALETTE_LABEL = new ValueProperty( TYPE, "ToolPaletteLabel" ); >+ >+ Value<String> getToolPaletteLabel(); >+ void setToolPaletteLabel( String paletteLabel ); >+ >+ // *** ToolPaletteDesc *** >+ >+ @Label( standard = "tool palette description" ) >+ @XmlBinding( path = "tool-palette-desc" ) >+ >+ ValueProperty PROP_TOOL_PALETTE_DESC = new ValueProperty( TYPE, "ToolPaletteDesc" ); >+ >+ Value<String> getToolPaletteDesc(); >+ void setToolPaletteDesc( String paletteDesc ); >+ >+ // *** Label *** >+ >+ @Label( standard = "label" ) >+ @XmlBinding( path = "label" ) >+ >+ ValueProperty PROP_LABEL = new ValueProperty( TYPE, "Label" ); >+ >+ Value<String> getLabel(); >+ void setLabel( String label ); >+ >+ // *** Endpoint1 *** >+ >+ @Type( base = IDiagramConnectionEndpointDef.class ) >+ @XmlBinding( path = "endpoint1" ) >+ >+ ElementProperty PROP_ENDPOINT_1 = new ElementProperty( TYPE, "Endpoint1" ); >+ >+ ModelElementHandle<IDiagramConnectionEndpointDef> getEndpoint1(); >+ >+ // *** Endpoint2 *** >+ >+ @Type( base = IDiagramConnectionEndpointDef.class ) >+ @XmlBinding( path = "endpoint2" ) >+ >+ ElementProperty PROP_ENDPOINT_2 = new ElementProperty( TYPE, "Endpoint2" ); >+ >+ ModelElementHandle<IDiagramConnectionEndpointDef> getEndpoint2(); >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionEndpointDef.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionEndpointDef.java >diff -N src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionEndpointDef.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/def/IDiagramConnectionEndpointDef.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+package org.eclipse.sapphire.ui.diagram.def; >+ >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.annotations.Type; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+import org.eclipse.sapphire.ui.def.ISapphirePartDef; >+ >+@GenerateImpl >+ >+public interface IDiagramConnectionEndpointDef >+ >+ extends ISapphirePartDef >+ >+{ >+ ModelElementType TYPE = new ModelElementType( IDiagramConnectionEndpointDef.class ); >+ >+ // *** Property *** >+ >+ @Label( standard = "property" ) >+ @XmlBinding( path = "property" ) >+ >+ ValueProperty PROP_PROPERTY = new ValueProperty( TYPE, "Property" ); >+ >+ Value<String> getProperty(); >+ void setProperty( String property ); >+ >+ // *** Value *** >+ >+ @Label( standard = "value" ) >+ @XmlBinding( path = "value" ) >+ >+ ValueProperty PROP_VALUE = new ValueProperty( TYPE, "Value" ); >+ >+ Value<String> getValue(); >+ void setValue( String value ); >+ >+ >+ // *** Type *** >+ >+ @Type( base = ConnectionEndpointType.class ) >+ @XmlBinding( path = "connectionDecoratorType" ) >+ >+ ValueProperty PROP_TYPE = new ValueProperty( TYPE, "Type" ); >+ >+ Value<ConnectionEndpointType> getType(); >+ void setType( String value ); >+ void setType( ConnectionEndpointType value ); >+ >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/def/IDiagramNodeDef.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/def/IDiagramNodeDef.java >diff -N src/org/eclipse/sapphire/ui/diagram/def/IDiagramNodeDef.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/def/IDiagramNodeDef.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+package org.eclipse.sapphire.ui.diagram.def; >+ >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+import org.eclipse.sapphire.ui.def.ISapphirePartDef; >+ >+@GenerateImpl >+ >+public interface IDiagramNodeDef >+ >+ extends ISapphirePartDef >+ >+{ >+ ModelElementType TYPE = new ModelElementType( IDiagramNodeDef.class ); >+ >+ // *** Id *** >+ >+ @Label( standard = "ID" ) >+ @XmlBinding( path = "id" ) >+ >+ ValueProperty PROP_ID = new ValueProperty( TYPE, "Id" ); >+ >+ Value<String> getId(); >+ void setId( String id ); >+ >+ // *** ToolPaletteLabel *** >+ >+ @Label( standard = "tool palette label" ) >+ @XmlBinding( path = "tool-palette-label" ) >+ >+ ValueProperty PROP_TOOL_PALETTE_LABEL = new ValueProperty( TYPE, "ToolPaletteLabel" ); >+ >+ Value<String> getToolPaletteLabel(); >+ void setToolPaletteLabel( String paletteLabel ); >+ >+ // *** ToolPaletteDesc *** >+ >+ @Label( standard = "tool palette description" ) >+ @XmlBinding( path = "tool-palette-desc" ) >+ >+ ValueProperty PROP_TOOL_PALETTE_DESC = new ValueProperty( TYPE, "ToolPaletteDesc" ); >+ >+ Value<String> getToolPaletteDesc(); >+ void setToolPaletteDesc( String paletteDesc ); >+ >+ // *** Property *** >+ >+ @Label( standard = "property" ) >+ @XmlBinding( path = "property" ) >+ >+ ValueProperty PROP_PROPERTY = new ValueProperty( TYPE, "Property" ); >+ >+ Value<String> getProperty(); >+ void setProperty( String property ); >+ >+ // *** Label *** >+ >+ @Label( standard = "label" ) >+ @XmlBinding( path = "label" ) >+ >+ ValueProperty PROP_LABEL = new ValueProperty( TYPE, "Label" ); >+ >+ Value<String> getLabel(); >+ void setLabel( String label ); >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/def/IDiagramPageDef.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/def/IDiagramPageDef.java >diff -N src/org/eclipse/sapphire/ui/diagram/def/IDiagramPageDef.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/def/IDiagramPageDef.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+package org.eclipse.sapphire.ui.diagram.def; >+ >+import org.eclipse.sapphire.modeling.ListProperty; >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.annotations.DefaultValue; >+import org.eclipse.sapphire.modeling.annotations.GenerateImpl; >+import org.eclipse.sapphire.modeling.annotations.Label; >+import org.eclipse.sapphire.modeling.annotations.Type; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlBinding; >+import org.eclipse.sapphire.modeling.xml.annotations.XmlListBinding; >+import org.eclipse.sapphire.ui.def.ISapphirePartDef; >+ >+@GenerateImpl >+ >+public interface IDiagramPageDef >+ >+ extends ISapphirePartDef >+ >+{ >+ ModelElementType TYPE = new ModelElementType( IDiagramPageDef.class); >+ >+ // *** Id *** >+ >+ @Label( standard = "ID" ) >+ @XmlBinding( path = "id" ) >+ >+ ValueProperty PROP_ID = new ValueProperty( TYPE, "Id" ); >+ >+ Value<String> getId(); >+ void setId( String id ); >+ >+ // *** PageName *** >+ >+ @Label( standard = "page name" ) >+ @DefaultValue( text = "Diagram" ) >+ @XmlBinding( path = "page-name" ) >+ >+ ValueProperty PROP_PAGE_NAME = new ValueProperty( TYPE, "PageName" ); >+ >+ Value<String> getPageName(); >+ void setPageName( String pageName ); >+ >+ // *** PageHeaderText *** >+ >+ @Label( standard = "page header text" ) >+ @DefaultValue( text = "Diagram View" ) >+ @XmlBinding( path = "page-header-text" ) >+ >+ ValueProperty PROP_PAGE_HEADER_TEXT = new ValueProperty( TYPE, "PageHeaderText" ); >+ >+ Value<String> getPageHeaderText(); >+ void setPageHeaderText( String pageHeaderText ); >+ >+ // *** DiagramNodeDefs *** >+ >+ @Type( base = IDiagramNodeDef.class ) >+ @XmlListBinding( mappings = @XmlListBinding.Mapping( element = "node", type = IDiagramNodeDef.class ) ) >+ >+ ListProperty PROP_DIAGRAM_NODE_DEFS = new ListProperty( TYPE, "DiagramNodeDefs" ); >+ >+ ModelElementList<IDiagramNodeDef> getDiagramNodeDefs(); >+ >+ // *** DiagramConnectionDefs *** >+ >+ @Type( base = IDiagramConnectionDef.class ) >+ @XmlListBinding( mappings = @XmlListBinding.Mapping( element = "connection", type = IDiagramConnectionDef.class ) ) >+ >+ ListProperty PROP_DIAGRAM_CONNECTION_DEFS = new ListProperty( TYPE, "DiagramConnectionDefs" ); >+ >+ ModelElementList<IDiagramConnectionDef> getDiagramConnectionDefs(); >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionPart.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionPart.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,177 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ModelProperty; >+import org.eclipse.sapphire.modeling.ReferenceValue; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.el.Function; >+import org.eclipse.sapphire.ui.SapphirePart; >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramConnectionDef; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramConnectionEndpointDef; >+ >+public class DiagramConnectionPart extends SapphirePart >+{ >+ private DiagramConnectionTemplate connectionTemplate; >+ private IDiagramConnectionDef definition; >+ private IModelElement modelElement; >+ private String label; >+ private IDiagramConnectionEndpointDef endpoint1Def; >+ private IDiagramConnectionEndpointDef endpoint2Def; >+ private IModelElement endpoint1Model; >+ private IModelElement endpoint2Model; >+ private Function endpoint1Function; >+ private Function endpoint2Function; >+ >+ public DiagramConnectionPart(DiagramConnectionTemplate connectionTemplate) >+ { >+ this.connectionTemplate = connectionTemplate; >+ } >+ >+ @Override >+ protected void init() >+ { >+ super.init(); >+ >+ this.definition = (IDiagramConnectionDef)super.definition; >+ this.modelElement = getModelElement(); >+ Function labelFunction = initExpression >+ ( >+ this.definition.getLabel().getLocalizedText(), >+ new Runnable() >+ { >+ public void run() >+ { >+ } >+ } >+ ); >+ this.label = (String)labelFunction.value(); >+ labelFunction.dispose(); >+ >+ this.endpoint1Def = this.definition.getEndpoint1().element(); >+ this.endpoint2Def = this.definition.getEndpoint2().element(); >+ this.endpoint1Model = processEndpoint(this.endpoint1Def); >+ this.endpoint2Model = processEndpoint(this.endpoint2Def); >+ this.endpoint1Function = initExpression >+ ( >+ this.endpoint1Model, >+ this.endpoint1Def.getValue().getContent(), >+ new Runnable() >+ { >+ public void run() >+ { >+ refreshEndpoint1(); >+ } >+ } >+ ); >+ this.endpoint2Function = initExpression >+ ( >+ this.endpoint2Model, >+ this.endpoint2Def.getValue().getContent(), >+ new Runnable() >+ { >+ public void run() >+ { >+ refreshEndpoint2(); >+ } >+ } >+ ); >+ } >+ >+ public DiagramConnectionTemplate getDiagramConnectionTemplate() >+ { >+ return this.connectionTemplate; >+ } >+ >+ public IModelElement getLocalModelElement() >+ { >+ return this.modelElement; >+ } >+ >+ public IModelElement getEndpoint1() >+ { >+ return this.endpoint1Model; >+ } >+ >+ public IModelElement getEndpoint2() >+ { >+ return this.endpoint2Model; >+ } >+ >+ public String getLabel() >+ { >+ return this.label; >+ } >+ >+ @Override >+ public void render(SapphireRenderingContext context) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ public void refreshEndpoint1() >+ { >+ if (this.endpoint1Function != null) >+ { >+ Object value = this.endpoint1Function.value(); >+ String property = this.endpoint1Def.getProperty().getContent(); >+ setModelProperty(this.modelElement, property, value); >+ } >+ } >+ >+ public void refreshEndpoint2() >+ { >+ if (this.endpoint2Function != null) >+ { >+ Object value = this.endpoint2Function.value(); >+ String property = this.endpoint2Def.getProperty().getContent(); >+ setModelProperty(this.modelElement, property, value); >+ } >+ } >+ >+ private IModelElement processEndpoint(IDiagramConnectionEndpointDef endpointDef) >+ { >+ String propertyName = endpointDef.getProperty().getContent(); >+ ModelProperty modelProperty = resolve(this.modelElement, propertyName); >+ if (!(modelProperty instanceof ValueProperty)) >+ { >+ throw new RuntimeException( "Property " + propertyName + " not a ValueProperty"); >+ } >+ ValueProperty property = (ValueProperty)modelProperty; >+ Value<?> valObj = this.modelElement.read(property); >+ if (!(valObj instanceof ReferenceValue)) >+ { >+ throw new RuntimeException( "Property " + propertyName + " value not a reference"); >+ } >+ ReferenceValue<?> refVal = (ReferenceValue<?>)valObj; >+ Object targetObj = refVal.resolve(); >+ if (!(targetObj instanceof IModelElement)) >+ { >+ throw new RuntimeException( "Target not an IModelElement"); >+ } >+ return (IModelElement)targetObj; >+ } >+ >+ private void setModelProperty(final IModelElement modelElement, >+ String propertyName, Object value) >+ { >+ if (propertyName != null) >+ { >+ final ModelElementType type = modelElement.getModelElementType(); >+ final ModelProperty property = type.getProperty( propertyName ); >+ if( property == null ) >+ { >+ throw new RuntimeException( "Could not find property " + propertyName + " in " + type.getQualifiedName() ); >+ } >+ if (!(property instanceof ValueProperty)) >+ { >+ throw new RuntimeException( "Property " + propertyName + " not a ValueProperty"); >+ } >+ >+ modelElement.write((ValueProperty)property, value); >+ } >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionTemplate.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionTemplate.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionTemplate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/DiagramConnectionTemplate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,186 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.sapphire.modeling.ElementProperty; >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ListProperty; >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ModelProperty; >+import org.eclipse.sapphire.modeling.Value; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.el.Function; >+import org.eclipse.sapphire.modeling.el.FunctionContext; >+import org.eclipse.sapphire.modeling.el.ModelElementFunctionContext; >+import org.eclipse.sapphire.modeling.el.parser.ExpressionLanguageParser; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramConnectionDef; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramConnectionEndpointDef; >+import org.eclipse.sapphire.ui.internal.SapphireUiFrameworkPlugin; >+ >+public class DiagramConnectionTemplate >+{ >+ private SapphireDiagramEditorPart diagramEditor; >+ private IDiagramConnectionDef definition; >+ private IModelElement modelElement; >+ private ModelProperty modelProperty; >+ private String toolPaletteLabel; >+ private String toolPaletteDesc; >+ >+ private List<DiagramConnectionPart> diagramConnections; >+ >+ public DiagramConnectionTemplate(final SapphireDiagramEditorPart diagramEditor, >+ IDiagramConnectionDef definition, IModelElement modelElement) >+ { >+ this.diagramEditor = diagramEditor; >+ this.modelElement = modelElement; >+ this.definition = definition; >+ >+ this.toolPaletteLabel = this.definition.getToolPaletteLabel().getContent(); >+ this.toolPaletteDesc = this.definition.getToolPaletteDesc().getContent(); >+ >+ this.diagramConnections = new ArrayList<DiagramConnectionPart>(); >+ >+ String propertyName = this.definition.getProperty().getContent(); >+ this.modelProperty = resolve(this.modelElement, propertyName); >+ if (this.modelProperty instanceof ListProperty) >+ { >+ ListProperty listProperty = (ListProperty)this.modelProperty; >+ ModelElementList<?> list = this.modelElement.read(listProperty); >+ for( IModelElement listEntryModelElement : list ) >+ { >+ DiagramConnectionPart connection = new DiagramConnectionPart(this); >+ connection.init(this.diagramEditor, listEntryModelElement, definition, >+ Collections.<String,String>emptyMap()); >+ this.diagramConnections.add(connection); >+ } >+ } >+ else if (this.modelProperty instanceof ElementProperty) >+ { >+ ElementProperty elementProperty = (ElementProperty)this.modelProperty; >+ if (this.modelElement.read(elementProperty) != null) >+ { >+ IModelElement localModelElement = this.modelElement.read(elementProperty).element(); >+ DiagramConnectionPart connection = new DiagramConnectionPart(this); >+ connection.init(this.diagramEditor, localModelElement, definition, >+ Collections.<String,String>emptyMap()); >+ >+ this.diagramConnections.add(connection); >+ } >+ } >+ } >+ >+ public List<DiagramConnectionPart> getDiagramConnections() >+ { >+ return this.diagramConnections; >+ } >+ >+ public String getToolPaletteLabel() >+ { >+ return this.toolPaletteLabel; >+ } >+ >+ public String getToolPaletteDesc() >+ { >+ return this.toolPaletteDesc; >+ } >+ >+ public DiagramConnectionPart createNewDiagramConnection(DiagramNodePart srcNode, >+ DiagramNodePart targetNode) >+ { >+ IModelElement newElement = null; >+ if (this.modelProperty instanceof ListProperty) >+ { >+ ListProperty listProperty = (ListProperty)this.modelProperty; >+ ModelElementList<?> list = this.modelElement.read(listProperty); >+ newElement = list.addNewElement(); >+ } >+ else if (this.modelProperty instanceof ElementProperty) >+ { >+ // TODO what if the element property does exist? >+ ElementProperty elementProperty = (ElementProperty)this.modelProperty; >+ newElement = this.modelElement.read(elementProperty).element(true); >+ } >+ >+ IDiagramConnectionEndpointDef srcAnchorDef = this.definition.getEndpoint1().element(); >+ String srcProperty = srcAnchorDef.getProperty().getContent(); >+ String srcExpr = srcAnchorDef.getValue().getContent(); >+ Function srcFunc = getNodeReferenceFunction(srcNode, srcExpr); >+ Object srcValue = srcFunc.value(); >+ srcFunc.dispose(); >+ setModelProperty(newElement, srcProperty, srcValue); >+ >+ IDiagramConnectionEndpointDef targetAnchorDef = this.definition.getEndpoint2().element(); >+ String targetProperty = targetAnchorDef.getProperty().getContent(); >+ String targetExpr = targetAnchorDef.getValue().getContent(); >+ Function targetFunc = getNodeReferenceFunction(targetNode, targetExpr); >+ Object targetValue = targetFunc.value(); >+ targetFunc.dispose(); >+ setModelProperty(newElement, targetProperty, targetValue); >+ >+ DiagramConnectionPart newConn = new DiagramConnectionPart(this); >+ newConn.init(this.diagramEditor, newElement, this.definition, >+ Collections.<String,String>emptyMap()); >+ this.diagramConnections.add(newConn); >+ return newConn; >+ } >+ >+ private ModelProperty resolve(final IModelElement modelElement, >+ String propertyName) >+ { >+ if (propertyName != null) >+ { >+ final ModelElementType type = modelElement.getModelElementType(); >+ final ModelProperty property = type.getProperty( propertyName ); >+ if( property == null ) >+ { >+ throw new RuntimeException( "Could not find property " + propertyName + " in " + type.getQualifiedName() ); >+ } >+ return property; >+ } >+ return null; >+ } >+ >+ private void setModelProperty(final IModelElement modelElement, >+ String propertyName, Object value) >+ { >+ if (propertyName != null) >+ { >+ final ModelElementType type = modelElement.getModelElementType(); >+ final ModelProperty property = type.getProperty( propertyName ); >+ if( property == null ) >+ { >+ throw new RuntimeException( "Could not find property " + propertyName + " in " + type.getQualifiedName() ); >+ } >+ if (!(property instanceof ValueProperty)) >+ { >+ throw new RuntimeException( "Property " + propertyName + " not a ValueProperty"); >+ } >+ >+ modelElement.write((ValueProperty)property, ((Value<?>)value).getContent()); >+ } >+ } >+ >+ private Function getNodeReferenceFunction(final DiagramNodePart nodePart, >+ final String expression) >+ { >+ final FunctionContext context = new ModelElementFunctionContext( nodePart.getLocalModelElement() ); >+ Function result = null; >+ >+ if( expression != null ) >+ { >+ try >+ { >+ result = ExpressionLanguageParser.parse( context, expression ); >+ } >+ catch( Exception e ) >+ { >+ SapphireUiFrameworkPlugin.log( e ); >+ result = null; >+ } >+ } >+ return result; >+ } >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodePart.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodePart.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodePart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodePart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import java.util.List; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ModelProperty; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.el.Function; >+import org.eclipse.sapphire.modeling.el.RootPropertyAccessFunction; >+import org.eclipse.sapphire.ui.SapphirePart; >+import org.eclipse.sapphire.ui.SapphireRenderingContext; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramNodeDef; >+ >+public class DiagramNodePart extends SapphirePart >+{ >+ private DiagramNodeTemplate nodeTemplate; >+ private IDiagramNodeDef definition; >+ private IModelElement modelElement; >+ private String label; >+ private Function labelFunction; >+ private ValueProperty labelProperty; >+ >+ public DiagramNodePart(DiagramNodeTemplate nodeTemplate) >+ { >+ this.nodeTemplate = nodeTemplate; >+ } >+ >+ @Override >+ protected void init() >+ { >+ super.init(); >+ >+ this.definition = (IDiagramNodeDef)super.definition; >+ this.modelElement = getModelElement(); >+ this.labelFunction = initExpression >+ ( >+ this.definition.getLabel().getLocalizedText(), >+ new Runnable() >+ { >+ public void run() >+ { >+ refreshLabel(); >+ } >+ } >+ ); >+ refreshLabel(); >+ this.labelProperty = FunctionUtil.getFunctionProperty(this.modelElement, this.labelFunction); >+ if (this.labelProperty == null) >+ { >+ throw new RuntimeException( "Label function does not contain a property."); >+ } >+ } >+ >+ public DiagramNodeTemplate getDiagramNodeTemplate() >+ { >+ return this.nodeTemplate; >+ } >+ >+ public IModelElement getLocalModelElement() >+ { >+ return this.modelElement; >+ } >+ >+ @Override >+ public void render(SapphireRenderingContext context) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ public String getLabel() >+ { >+ return this.label; >+ } >+ >+ public void setLabel(String newValue) >+ { >+ if (this.labelProperty != null) >+ { >+ this.modelElement.write(this.labelProperty, newValue); >+ refreshLabel(); >+ } >+ } >+ >+ private void refreshLabel() >+ { >+ if( this.labelFunction != null ) >+ { >+ this.label = (String) this.labelFunction.value(); >+ } >+ >+ if( this.label == null ) >+ { >+ this.label = "#null#"; >+ } >+ else >+ { >+ this.label = this.label.trim(); >+ } >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodeTemplate.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodeTemplate.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodeTemplate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/DiagramNodeTemplate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,120 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.sapphire.modeling.ElementProperty; >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ListProperty; >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ModelProperty; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramNodeDef; >+ >+public class DiagramNodeTemplate >+{ >+ private SapphireDiagramEditorPart diagramEditor; >+ private IDiagramNodeDef definition; >+ private IModelElement modelElement; >+ private ModelProperty modelProperty; >+ private String toolPaletteLabel; >+ private String toolPaletteDesc; >+ >+ private List<DiagramNodePart> diagramNodes; >+ >+ public DiagramNodeTemplate(final SapphireDiagramEditorPart diagramEditor, IDiagramNodeDef definition, IModelElement modelElement) >+ { >+ this.diagramEditor = diagramEditor; >+ this.modelElement = modelElement; >+ this.definition = definition; >+ >+ this.toolPaletteLabel = this.definition.getToolPaletteLabel().getContent(); >+ this.toolPaletteDesc = this.definition.getToolPaletteDesc().getContent(); >+ >+ this.diagramNodes = new ArrayList<DiagramNodePart>(); >+ >+ String propertyName = this.definition.getProperty().getContent(); >+ this.modelProperty = resolve(this.modelElement, propertyName); >+ if (this.modelProperty instanceof ListProperty) >+ { >+ ListProperty listProperty = (ListProperty)this.modelProperty; >+ ModelElementList<?> list = this.modelElement.read(listProperty); >+ for( IModelElement listEntryModelElement : list ) >+ { >+ DiagramNodePart node = new DiagramNodePart(this); >+ node.init(this.diagramEditor, listEntryModelElement, definition, >+ Collections.<String,String>emptyMap()); >+ this.diagramNodes.add(node); >+ } >+ } >+ else if (this.modelProperty instanceof ElementProperty) >+ { >+ ElementProperty elementProperty = (ElementProperty)this.modelProperty; >+ if (this.modelElement.read(elementProperty) != null) >+ { >+ IModelElement localModelElement = this.modelElement.read(elementProperty).element(); >+ DiagramNodePart node = new DiagramNodePart(this); >+ node.init(this.diagramEditor, localModelElement, definition, >+ Collections.<String,String>emptyMap()); >+ >+ this.diagramNodes.add(node); >+ } >+ } >+ } >+ >+ public List<DiagramNodePart> getDiagramNodes() >+ { >+ return this.diagramNodes; >+ } >+ >+ public String getToolPaletteLabel() >+ { >+ return this.toolPaletteLabel; >+ } >+ >+ public String getToolPaletteDesc() >+ { >+ return this.toolPaletteDesc; >+ } >+ >+ public DiagramNodePart createNewDiagramNode() >+ { >+ IModelElement newElement = null; >+ if (this.modelProperty instanceof ListProperty) >+ { >+ ListProperty listProperty = (ListProperty)this.modelProperty; >+ ModelElementList<?> list = this.modelElement.read(listProperty); >+ newElement = list.addNewElement(); >+ } >+ else if (this.modelProperty instanceof ElementProperty) >+ { >+ // TODO what if the element property does exist? >+ ElementProperty elementProperty = (ElementProperty)this.modelProperty; >+ newElement = this.modelElement.read(elementProperty).element(true); >+ } >+ DiagramNodePart newNode = new DiagramNodePart(this); >+ newNode.init(this.diagramEditor, newElement, this.definition, >+ Collections.<String,String>emptyMap()); >+ this.diagramNodes.add(newNode); >+ return newNode; >+ } >+ >+ private ModelProperty resolve(final IModelElement modelElement, >+ String propertyName) >+ { >+ if (propertyName != null) >+ { >+ final ModelElementType type = modelElement.getModelElementType(); >+ final ModelProperty property = type.getProperty( propertyName ); >+ >+ if( property == null ) >+ { >+ throw new RuntimeException( "Could not find property " + propertyName + " in " + type.getQualifiedName() ); >+ } >+ return property; >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/FunctionUtil.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/FunctionUtil.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/FunctionUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/FunctionUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import java.util.List; >+ >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementType; >+import org.eclipse.sapphire.modeling.ModelProperty; >+import org.eclipse.sapphire.modeling.ValueProperty; >+import org.eclipse.sapphire.modeling.el.Function; >+import org.eclipse.sapphire.modeling.el.RootPropertyAccessFunction; >+ >+public class FunctionUtil >+{ >+ public static ValueProperty getFunctionProperty(IModelElement modelElement, Function function) >+ { >+ if (function instanceof RootPropertyAccessFunction) >+ { >+ RootPropertyAccessFunction rpaf = (RootPropertyAccessFunction)function; >+ if (rpaf.operand(0).value() instanceof String) >+ { >+ String propName = (String)rpaf.operand(0).value(); >+ final ModelElementType type = modelElement.getModelElementType(); >+ final ModelProperty property = type.getProperty(propName); >+ if (property instanceof ValueProperty) >+ { >+ return (ValueProperty)property; >+ } >+ } >+ } >+ else >+ { >+ List<Function> subFuncs = function.operands(); >+ for (Function subFunc : subFuncs) >+ { >+ ValueProperty property = getFunctionProperty(modelElement, subFunc); >+ if (property != null) >+ { >+ return property; >+ } >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPart.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPart.java >diff -N src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPart.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/editor/SapphireDiagramEditorPart.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,198 @@ >+package org.eclipse.sapphire.ui.diagram.editor; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.help.IContext; >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.modeling.ModelElementList; >+import org.eclipse.sapphire.ui.ISapphirePart; >+import org.eclipse.sapphire.ui.SapphireAction; >+import org.eclipse.sapphire.ui.SapphireActionGroup; >+import org.eclipse.sapphire.ui.SapphireEditor; >+import org.eclipse.sapphire.ui.SapphireImageCache; >+import org.eclipse.sapphire.ui.SapphirePartListener; >+import org.eclipse.sapphire.ui.def.ISapphirePartDef; >+import org.eclipse.sapphire.ui.def.ISapphireUiDef; >+import org.eclipse.sapphire.ui.def.SapphireUiDefFactory; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramConnectionDef; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramNodeDef; >+import org.eclipse.sapphire.ui.diagram.def.IDiagramPageDef; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditor; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditorFactory; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditorInput; >+import org.eclipse.sapphire.ui.internal.SapphireUiFrameworkPlugin; >+ >+public class SapphireDiagramEditorPart >+ implements ISapphirePart >+{ >+ private final SapphireEditor editor; >+ private final IModelElement rootModelElement; >+ private IDiagramPageDef diagramPageDef = null; >+ private List<DiagramNodeTemplate> nodeTemplates; >+ private List<DiagramConnectionTemplate> connectionTemplates; >+ private SapphireDiagramEditorInput diagramInput; >+ private SapphireDiagramEditor diagramEditor; >+ >+ public SapphireDiagramEditorPart(final SapphireEditor editor, >+ final IModelElement rootModelElement, >+ final IPath pageDefinitionLocation ) >+ { >+ this(editor, rootModelElement, pageDefinitionLocation, null); >+ } >+ >+ public SapphireDiagramEditorPart(final SapphireEditor editor, >+ final IModelElement rootModelElement, >+ final IPath pageDefinitionLocation, >+ String pageName ) >+ { >+ this.editor = editor; >+ this.rootModelElement = rootModelElement; >+ >+ final String bundleId = pageDefinitionLocation.segment( 0 ); >+ final String pageId = pageDefinitionLocation.lastSegment(); >+ final String relPath = pageDefinitionLocation.removeFirstSegments( 1 ).removeLastSegments( 1 ).toPortableString(); >+ >+ final ISapphireUiDef def = SapphireUiDefFactory.load( bundleId, relPath ); >+ >+ for( IDiagramPageDef pg : def.getDiagramPageDefs() ) >+ { >+ if( pageId.equals( pg.getId().getText() ) ) >+ { >+ this.diagramPageDef = pg; >+ break; >+ } >+ } >+ >+ this.nodeTemplates = new ArrayList<DiagramNodeTemplate>(); >+ ModelElementList<IDiagramNodeDef> nodeDefs = this.diagramPageDef.getDiagramNodeDefs(); >+ >+ for (IDiagramNodeDef nodeDef : nodeDefs) >+ { >+ DiagramNodeTemplate nodeTemplate = new DiagramNodeTemplate(this, nodeDef, this.rootModelElement); >+ this.nodeTemplates.add(nodeTemplate); >+ } >+ >+ this.connectionTemplates = new ArrayList<DiagramConnectionTemplate>(); >+ ModelElementList<IDiagramConnectionDef> connectionDefs = this.diagramPageDef.getDiagramConnectionDefs(); >+ for (IDiagramConnectionDef connectionDef : connectionDefs) >+ { >+ DiagramConnectionTemplate connectionTemplate = new DiagramConnectionTemplate(this, connectionDef, this.rootModelElement); >+ this.connectionTemplates.add(connectionTemplate); >+ } >+ >+ initializeDiagramEditor(); >+ } >+ >+ private void initializeDiagramEditor() >+ { >+ try >+ { >+ this.diagramInput = SapphireDiagramEditorFactory.createEditorInput(this.editor.getEditorInput()); >+ } >+ catch( CoreException e ) >+ { >+ SapphireUiFrameworkPlugin.log( e ); >+ } >+ this.diagramEditor = new SapphireDiagramEditor(this); >+ } >+ >+ public SapphireDiagramEditorInput getDiagramEditorInput() >+ { >+ return this.diagramInput; >+ } >+ >+ public SapphireDiagramEditor getDiagramEditor() >+ { >+ return this.diagramEditor; >+ } >+ >+ public List<DiagramNodeTemplate> getNodeTemplates() >+ { >+ return this.nodeTemplates; >+ } >+ >+ public List<DiagramConnectionTemplate> getConnectionTemplates() >+ { >+ return this.connectionTemplates; >+ } >+ >+ public ISapphirePart getParentPart() >+ { >+ return this.editor; >+ } >+ >+ public <T> T getNearestPart(Class<T> partType) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public IModelElement getModelElement() >+ { >+ return this.rootModelElement; >+ } >+ >+ public IStatus getValidationState() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public IContext getDocumentationContext() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public SapphireImageCache getImageCache() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public void addListener(SapphirePartListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void removeListener(SapphirePartListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public ISapphirePartDef getDefinition() >+ { >+ return this.diagramPageDef; >+ } >+ >+ public Set<String> getActionContexts() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getMainActionContext() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public SapphireActionGroup getActions() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public SapphireActionGroup getActions(String context) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public SapphireAction getAction(String id) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/GraphitiFileService.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/GraphitiFileService.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/GraphitiFileService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/GraphitiFileService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,172 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti; >+ >+import java.io.IOException; >+import java.io.PrintWriter; >+import java.io.StringWriter; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Map; >+import java.util.Map.Entry; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRunnable; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.emf.common.command.CommandStack; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.common.util.WrappedException; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.transaction.RecordingCommand; >+import org.eclipse.emf.transaction.Transaction; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.graphiti.ui.editor.DiagramEditorFactory; >+ >+public class GraphitiFileService >+{ >+ public static TransactionalEditingDomain createEmfFileForDiagram(URI diagramResourceUri, final Diagram diagram) { >+ >+ // Create a resource set and EditingDomain >+ final TransactionalEditingDomain editingDomain = DiagramEditorFactory.createResourceSetAndEditingDomain(); >+ final ResourceSet resourceSet = editingDomain.getResourceSet(); >+ // Create a resource for this file. >+ final Resource resource = resourceSet.createResource(diagramResourceUri); >+ final CommandStack commandStack = editingDomain.getCommandStack(); >+ commandStack.execute(new RecordingCommand(editingDomain) { >+ >+ @Override >+ protected void doExecute() { >+ resource.setTrackingModification(true); >+ resource.getContents().add(diagram); >+ >+ } >+ }); >+ >+ save(editingDomain, Collections.<Resource, Map<?, ?>> emptyMap()); >+ return editingDomain; >+ } >+ >+ private static void save(TransactionalEditingDomain editingDomain, Map<Resource, Map<?, ?>> options) { >+ saveInWorkspaceRunnable(editingDomain, options); >+ } >+ >+ private static void saveInWorkspaceRunnable(final TransactionalEditingDomain editingDomain, final Map<Resource, Map<?, ?>> options) { >+ >+ final Map<URI, Throwable> failedSaves = new HashMap<URI, Throwable>(); >+ final IWorkspaceRunnable wsRunnable = new IWorkspaceRunnable() { >+ public void run(final IProgressMonitor monitor) throws CoreException { >+ >+ final Runnable runnable = new Runnable() { >+ >+ public void run() { >+ Transaction parentTx; >+ if (editingDomain != null >+ && (parentTx = ((TransactionalEditingDomainImpl) editingDomain).getActiveTransaction()) != null) { >+ do { >+ if (!parentTx.isReadOnly()) { >+ throw new IllegalStateException( >+ "FileService.save() called from within a command (likely produces a deadlock)"); >+ } >+ } while ((parentTx = ((TransactionalEditingDomainImpl) editingDomain).getActiveTransaction().getParent()) != null); >+ } >+ >+ final EList<Resource> resources = editingDomain.getResourceSet().getResources(); >+ // Copy list to an array to prevent >+ // ConcurrentModificationExceptions >+ // during the saving of the dirty resources >+ Resource[] resourcesArray = new Resource[resources.size()]; >+ resourcesArray = resources.toArray(resourcesArray); >+ final Set<Resource> savedResources = new HashSet<Resource>(); >+ for (int i = 0; i < resourcesArray.length; i++) { >+ // In case resource modification tracking is >+ // switched on, we can check if a resource >+ // has been modified, so that we only need to same >+ // really changed resources; otherwise >+ // we need to save all resources in the set >+ final Resource resource = resourcesArray[i]; >+ if (resource.isModified()) { >+ try { >+ resource.save(options.get(resource)); >+ savedResources.add(resource); >+ } catch (final Throwable t) { >+ failedSaves.put(resource.getURI(), t); >+ } >+ } >+ } >+ } >+ }; >+ >+ try { >+ editingDomain.runExclusive(runnable); >+ } catch (final InterruptedException e) { >+ throw new RuntimeException(e); >+ } >+ editingDomain.getCommandStack().flush(); >+ } >+ }; >+ try { >+ ResourcesPlugin.getWorkspace().run(wsRunnable, null); >+ if (!failedSaves.isEmpty()) { >+ throw new WrappedException(createMessage(failedSaves), new RuntimeException()); >+ } >+ } catch (final CoreException e) { >+ final Throwable cause = e.getStatus().getException(); >+ if (cause instanceof RuntimeException) { >+ throw (RuntimeException) cause; >+ } >+ throw new RuntimeException(e); >+ } >+ } >+ >+ private static String createMessage(Map<URI, Throwable> failedSaves) { >+ final StringBuilder buf = new StringBuilder("The following resources could not be saved:"); >+ for (final Entry<URI, Throwable> entry : failedSaves.entrySet()) { >+ buf.append("\nURI: ").append(entry.getKey().toString()).append(", cause: \n").append(getExceptionAsString(entry.getValue())); >+ } >+ return buf.toString(); >+ } >+ >+ private static String getExceptionAsString(Throwable t) { >+ final StringWriter stringWriter = new StringWriter(); >+ final PrintWriter printWriter = new PrintWriter(stringWriter); >+ t.printStackTrace(printWriter); >+ final String result = stringWriter.toString(); >+ try { >+ stringWriter.close(); >+ } catch (final IOException e) { >+ // $JL-EXC$ ignore >+ } >+ printWriter.close(); >+ return result; >+ } >+ >+ public static IFile EmfResourceToIFile(Resource resource) >+ { >+ IFile ifile = null; >+ >+ URI uri = resource.getURI(); >+ uri = resource.getResourceSet().getURIConverter().normalize(uri); >+ >+ String scheme = uri.scheme(); >+ if ("platform".equals(scheme) && uri.segmentCount() > 1 && >+ "resource".equals(uri.segment(0))) >+ { >+ StringBuffer platformResourcePath = new StringBuffer(); >+ for (int j = 1, size = uri.segmentCount(); j < size; ++j) >+ { >+ platformResourcePath.append('/'); >+ platformResourcePath.append(uri.segment(j)); >+ } >+ return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourcePath.toString())); >+ } >+ return ifile; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditor.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditor.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.editor; >+ >+import org.eclipse.gef.DefaultEditDomain; >+import org.eclipse.graphiti.ui.editor.DiagramEditor; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPart; >+ >+public class SapphireDiagramEditor extends DiagramEditor >+{ >+ private SapphireDiagramEditorPart diagramPart; >+ >+ public SapphireDiagramEditor(SapphireDiagramEditorPart diagramPart) >+ { >+ this.diagramPart = diagramPart; >+ DefaultEditDomain ded = new DefaultEditDomain( this ); >+ } >+ >+ public SapphireDiagramEditorPart getDiagramEditorPart() >+ { >+ return this.diagramPart; >+ } >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorFactory.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorFactory.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.editor; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.util.Iterator; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.graphiti.services.Graphiti; >+import org.eclipse.graphiti.ui.editor.DiagramEditorFactory; >+import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal; >+import org.eclipse.graphiti.ui.services.GraphitiUi; >+import org.eclipse.sapphire.modeling.util.internal.FileUtil; >+import org.eclipse.sapphire.ui.diagram.graphiti.GraphitiFileService; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IFileEditorInput; >+ >+public class SapphireDiagramEditorFactory >+{ >+ public static final String SAPPHIRE_DIAGRAM_TYPE = "sapphireDiagram"; >+ >+ public static SapphireDiagramEditorInput createEditorInput(IEditorInput otherInput) >+ throws CoreException >+ { >+ if (otherInput instanceof SapphireDiagramEditorInput) >+ { >+ return (SapphireDiagramEditorInput)otherInput; >+ } >+ else if (otherInput instanceof IFileEditorInput) >+ { >+ final IFileEditorInput fileInput = (IFileEditorInput) otherInput; >+ final IFile file = fileInput.getFile(); >+ final IProject project = file.getProject(); >+ >+ final IFolder diagramFolder = project.getFolder(".settings/diagrams/"); >+ String fileName = file.getName(); >+ if (fileName.endsWith(".xml")) >+ { >+ fileName = fileName.substring(0, fileName.indexOf(".xml")); >+ } >+ >+ TransactionalEditingDomain domain = null; >+ ResourceSet resourceSet = null; >+ Diagram diagram = null; >+ URI diagramFileUri = null; >+ >+ // create diagram file if it doesn't exist >+ final IFile diagramFile = diagramFolder.getFile(fileName + ".xmi"); >+ if (!diagramFile.exists()) >+ { >+ FileUtil.mkdirs( diagramFile.getParent().getLocation().toFile() ); >+ diagramFile.create( new ByteArrayInputStream(new byte[0]), true, null ); >+ >+ // Create Diagram Obj >+ diagram = Graphiti.getPeCreateService().createDiagram( >+ SAPPHIRE_DIAGRAM_TYPE, fileName, 10, false); >+ diagramFileUri = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true); >+ domain = GraphitiFileService.createEmfFileForDiagram(diagramFileUri, diagram); >+ } >+ else >+ { >+ domain = DiagramEditorFactory.createResourceSetAndEditingDomain(); >+ resourceSet = domain.getResourceSet(); >+ >+ diagramFileUri = GraphitiUiInternal.getEmfService().getFileURI(diagramFile, resourceSet); >+ if (diagramFileUri != null) >+ { >+ final Resource resource = resourceSet.createResource(diagramFileUri); >+ try >+ { >+ resource.load(null); >+ } >+ catch (IOException ie) >+ { >+ ie.printStackTrace(); >+ } >+ EList<EObject> objs = resource.getContents(); >+ Iterator<EObject> it = objs.iterator(); >+ while (it.hasNext()) >+ { >+ EObject obj = it.next(); >+ if ((obj == null) && !Diagram.class.isInstance(obj)) >+ continue; >+ diagram = (Diagram)obj; >+ break; >+ } >+ } >+ } >+ // create diagram node position file if it doesn't exist >+ IFile nodePosFile = diagramFile.getParent().getFile(new Path(fileName + ".np")); >+ if (!nodePosFile.exists()) >+ { >+ nodePosFile.create( new ByteArrayInputStream(new byte[0]), true, null ); >+ } >+ >+ // create sapphire diagram editor input >+ if (diagram != null) >+ { >+ String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId()); >+ final SapphireDiagramEditorInput diagramEditorInput = >+ SapphireDiagramEditorInput.createEditorInput(diagram, domain, providerId, false); >+ diagramEditorInput.setNodePositionFile(nodePosFile); >+ return diagramEditorInput; >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorInput.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorInput.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorInput.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/editor/SapphireDiagramEditorInput.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.editor; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.graphiti.ui.editor.DiagramEditorInput; >+ >+public class SapphireDiagramEditorInput extends DiagramEditorInput >+{ >+ private Diagram diagram; >+ private IFile nodePositionFile; >+ >+ public SapphireDiagramEditorInput(Diagram diagram, String diagramUriString, >+ TransactionalEditingDomain domain, String providerId, >+ boolean disposeEditingDomain) >+ { >+ super(diagramUriString, domain, providerId, disposeEditingDomain); >+ this.diagram = diagram; >+ } >+ >+ public SapphireDiagramEditorInput(Diagram diagram, URI diagramUri, >+ TransactionalEditingDomain domain, String providerId, >+ boolean disposeEditingDomain) >+ { >+ super(diagramUri, domain, providerId, disposeEditingDomain); >+ this.diagram = diagram; >+ } >+ >+ public Diagram getDiagram() >+ { >+ return this.diagram; >+ } >+ >+ public TransactionalEditingDomain getEditingDomain() >+ { >+ return this.editingDomain; >+ } >+ >+ @SuppressWarnings("rawtypes") >+ public Object getAdapter(Class adapter) >+ { >+ if (EObject.class.isAssignableFrom(adapter)) >+ { >+ return getDiagram(); >+ } >+ else if (Diagram.class.isAssignableFrom(adapter)) >+ { >+ return getDiagram(); >+ } >+ else if (TransactionalEditingDomain.class.isAssignableFrom(adapter)) >+ { >+ return getEditingDomain(); >+ } >+ else if (ResourceSet.class.isAssignableFrom(adapter)) >+ { >+ return getEditingDomain().getResourceSet(); >+ } >+ return null; >+ } >+ >+ public IFile getNodePositionFile() >+ { >+ return this.nodePositionFile; >+ } >+ >+ public void setNodePositionFile(IFile file) >+ { >+ this.nodePositionFile = file; >+ } >+ >+ >+ public static SapphireDiagramEditorInput createEditorInput(Diagram diagram, >+ TransactionalEditingDomain domain, String providerId, boolean disposeEditingDomain) >+ { >+ final Resource resource = diagram.eResource(); >+ if (resource == null) { >+ throw new IllegalArgumentException(); >+ } >+ final String fragment = resource.getURIFragment(diagram); >+ final URI fragmentUri = resource.getURI().appendFragment(fragment); >+ SapphireDiagramEditorInput diagramEditorInput; >+ diagramEditorInput = new SapphireDiagramEditorInput(diagram, fragmentUri, >+ domain, providerId, disposeEditingDomain); >+ return diagramEditorInput; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddConnectionFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddConnectionFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddConnectionFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddConnectionFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,97 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import org.eclipse.graphiti.features.IDirectEditingInfo; >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.context.IAddConnectionContext; >+import org.eclipse.graphiti.features.context.IAddContext; >+import org.eclipse.graphiti.features.impl.AbstractAddFeature; >+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer; >+import org.eclipse.graphiti.mm.algorithms.Polygon; >+import org.eclipse.graphiti.mm.algorithms.Polyline; >+import org.eclipse.graphiti.mm.algorithms.Text; >+import org.eclipse.graphiti.mm.pictograms.Connection; >+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator; >+import org.eclipse.graphiti.mm.pictograms.PictogramElement; >+import org.eclipse.graphiti.services.Graphiti; >+import org.eclipse.graphiti.services.IGaService; >+import org.eclipse.graphiti.services.IPeCreateService; >+import org.eclipse.graphiti.util.IColorConstant; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionPart; >+ >+public class SapphireAddConnectionFeature extends AbstractAddFeature >+{ >+ public SapphireAddConnectionFeature(IFeatureProvider fp) >+ { >+ super(fp); >+ } >+ >+ public boolean canAdd(IAddContext context) >+ { >+ // return true if given business object is an DiagramConnectionPart >+ // note, that the context must be an instance of IAddConnectionContext >+ if (context instanceof IAddConnectionContext && >+ context.getNewObject() instanceof DiagramConnectionPart) >+ { >+ return true; >+ } >+ return false; >+ } >+ >+ public PictogramElement add(IAddContext context) >+ { >+ IAddConnectionContext addConContext = (IAddConnectionContext) context; >+ DiagramConnectionPart connectionPart = (DiagramConnectionPart) context.getNewObject(); >+ >+ IPeCreateService peCreateService = Graphiti.getPeCreateService(); >+ // CONNECTION WITH POLYLINE >+ Connection connection = peCreateService.createFreeFormConnection(getDiagram()); >+ connection.setStart(addConContext.getSourceAnchor()); >+ connection.setEnd(addConContext.getTargetAnchor()); >+ >+ IGaService gaService = Graphiti.getGaService(); >+ Polyline polyline = gaService.createPolyline(connection); >+ polyline.setForeground(manageColor(IColorConstant.BLACK)); >+ polyline.setLineWidth(1); >+ >+ // create link and wire it >+ link(connection, connectionPart); >+ >+ // add dynamic text decorator for the reference name >+ ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true); >+ Text text = gaService.createDefaultText(textDecorator); >+ text.setForeground(manageColor(IColorConstant.BLACK)); >+ gaService.setLocation(text, 10, 0); >+ >+ text.setValue(connectionPart.getLabel()); >+ >+ // add static graphical decorators (composition and navigable) >+ ConnectionDecorator cd; >+ cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true); >+ createArrow(cd); >+ >+ // provide information to support direct-editing directly >+ >+ // after object creation (must be activated additionally) >+ IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo(); >+ >+ // set container shape for direct editing after object creation >+ directEditingInfo.setMainPictogramElement(connection); >+ >+ // set shape and graphics algorithm where the editor for >+ // direct editing shall be opened after object creation >+ directEditingInfo.setPictogramElement(textDecorator); >+ directEditingInfo.setGraphicsAlgorithm(text); >+ >+ return connection; >+ } >+ >+ private Polygon createArrow(GraphicsAlgorithmContainer gaContainer) >+ { >+ Polygon polygon = Graphiti.getGaCreateService().createPolygon(gaContainer, new int[] { -8, 4, 0, 0, -8, -4, -5, 0 }); >+ polygon.setBackground(manageColor(IColorConstant.BLACK)); >+ //polygon.setStyle(StyleUtil.getStyleForADFView(getDiagram())); >+ polygon.setFilled(true); >+ return polygon; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddNodeFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddNodeFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddNodeFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireAddNodeFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import org.eclipse.graphiti.features.IDirectEditingInfo; >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.context.IAddContext; >+import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature; >+import org.eclipse.graphiti.mm.algorithms.Polyline; >+import org.eclipse.graphiti.mm.algorithms.Rectangle; >+import org.eclipse.graphiti.mm.algorithms.Text; >+import org.eclipse.graphiti.mm.algorithms.styles.Orientation; >+import org.eclipse.graphiti.mm.pictograms.ContainerShape; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.graphiti.mm.pictograms.PictogramElement; >+import org.eclipse.graphiti.mm.pictograms.Shape; >+import org.eclipse.graphiti.services.Graphiti; >+import org.eclipse.graphiti.services.IGaService; >+import org.eclipse.graphiti.services.IPeCreateService; >+import org.eclipse.graphiti.util.ColorConstant; >+import org.eclipse.graphiti.util.IColorConstant; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+ >+public class SapphireAddNodeFeature extends AbstractAddShapeFeature >+{ >+ private static final IColorConstant CLASS_TEXT_FOREGROUND = new ColorConstant(51, 51, 153); >+ private static final IColorConstant CLASS_FOREGROUND = new ColorConstant(255, 102, 0); >+ private static final IColorConstant CLASS_BACKGROUND = new ColorConstant(255, 204, 153); >+ >+ public SapphireAddNodeFeature(IFeatureProvider fp) >+ { >+ super(fp); >+ } >+ >+ public boolean canAdd(IAddContext context) >+ { >+ Object newObj = context.getNewObject(); >+ if (newObj instanceof DiagramNodePart && context.getTargetContainer() instanceof Diagram) >+ { >+ return true; >+ } >+ return false; >+ } >+ >+ public PictogramElement add(IAddContext context) >+ { >+ DiagramNodePart nodePart = (DiagramNodePart)context.getNewObject(); >+ final Diagram targetDiagram = (Diagram) context.getTargetContainer(); >+ >+ // CONTAINER SHAPE WITH RECTANGLE >+ IPeCreateService peCreateService = Graphiti.getPeCreateService(); >+ ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true); >+ >+ // define a default size for the shape >+ int width = 100; >+ int height = 50; >+ IGaService gaService = Graphiti.getGaService(); >+ { >+ // create and set graphics algorithm >+ Rectangle rectangle = gaService.createRectangle(containerShape); >+ rectangle.setForeground(manageColor(CLASS_FOREGROUND)); >+ rectangle.setBackground(manageColor(CLASS_BACKGROUND)); >+ rectangle.setLineWidth(2); >+ gaService.setLocationAndSize(rectangle, >+ context.getX(), context.getY(), width, height); >+ >+ // create link and wire it >+ link(containerShape, nodePart); >+ } >+ >+ // SHAPE WITH LINE >+ { >+ // create shape for line >+ Shape shape = peCreateService.createShape(containerShape, false); >+ >+ // create and set graphics algorithm >+ Polyline polyline = >+ gaService.createPolyline(shape, new int[] { 0, 20, width, 20 }); >+ polyline.setForeground(manageColor(CLASS_FOREGROUND)); >+ polyline.setLineWidth(2); >+ } >+ >+ // SHAPE WITH TEXT >+ { >+ // create shape for text >+ Shape shape = peCreateService.createShape(containerShape, false); >+ >+ // create and set text graphics algorithm >+ Text text = gaService.createDefaultText(shape, nodePart.getLabel()); >+ text.setForeground(manageColor(CLASS_TEXT_FOREGROUND)); >+ text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER); >+ text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER); >+ //text.getFont().setBold(true); >+ gaService.setLocationAndSize(text, 0, 0, width, 20); >+ >+ // create link and wire it >+ link(shape, nodePart); >+ >+ // provide information to support direct-editing directly >+ // after object creation (must be activated additionally) >+ final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo(); >+ // set container shape for direct editing after object creation >+ directEditingInfo.setMainPictogramElement(containerShape); >+ // set shape and graphics algorithm where the editor for >+ // direct editing shall be opened after object creation >+ directEditingInfo.setPictogramElement(shape); >+ directEditingInfo.setGraphicsAlgorithm(text); >+ } >+ >+ // add a chopbox anchor to the shape >+ peCreateService.createChopboxAnchor(containerShape); >+ >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateConnectionFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateConnectionFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateConnectionFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateConnectionFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.context.ICreateConnectionContext; >+import org.eclipse.graphiti.features.context.impl.AddConnectionContext; >+import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature; >+import org.eclipse.graphiti.mm.pictograms.Anchor; >+import org.eclipse.graphiti.mm.pictograms.Connection; >+import org.eclipse.sapphire.ui.SapphirePart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionPart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionTemplate; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+ >+public class SapphireCreateConnectionFeature extends AbstractCreateConnectionFeature >+{ >+ private DiagramConnectionTemplate connectionTemplate; >+ >+ public SapphireCreateConnectionFeature(IFeatureProvider fp, DiagramConnectionTemplate connectionTemplate) >+ { >+ super(fp, connectionTemplate.getToolPaletteLabel(), connectionTemplate.getToolPaletteDesc()); >+ this.connectionTemplate = connectionTemplate; >+ } >+ >+ public boolean canCreate(ICreateConnectionContext context) >+ { >+ // return true if both anchors belong to an IModelElement >+ // and those model elements are not identical >+ SapphirePart source = getEndpoint(context.getSourceAnchor()); >+ SapphirePart target = getEndpoint(context.getTargetAnchor()); >+ if (source instanceof DiagramNodePart && >+ source instanceof DiagramNodePart && source != target) >+ { >+ return true; >+ } >+ return false; >+ } >+ >+ public Connection create(ICreateConnectionContext context) >+ { >+ Connection newConnection = null; >+ >+ // get model elements which should be connected >+ SapphirePart source = getEndpoint(context.getSourceAnchor()); >+ SapphirePart target = getEndpoint(context.getTargetAnchor()); >+ >+ if (source instanceof DiagramNodePart && target instanceof DiagramNodePart) >+ { >+ DiagramNodePart sourceNode = (DiagramNodePart)source; >+ DiagramNodePart targetNode = (DiagramNodePart)target; >+ // create new business object >+ DiagramConnectionPart connectionPart = >+ this.connectionTemplate.createNewDiagramConnection(sourceNode, targetNode); >+ >+ // add connection for business object >+ AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor()); >+ addContext.setNewObject(connectionPart); >+ newConnection = (Connection) getFeatureProvider().addIfPossible(addContext); >+ >+ // activate direct editing after object creation >+ getFeatureProvider().getDirectEditingInfo().setActive(true); >+ } >+ >+ return newConnection; >+ } >+ >+ public boolean canStartConnection(ICreateConnectionContext context) >+ { >+ // return true if start anchor belongs to an IModelElement >+ if (getEndpoint(context.getSourceAnchor()) instanceof DiagramNodePart) >+ { >+ return true; >+ } >+ return false; >+ } >+ >+ /** >+ * Returns the EClass belonging to the anchor, or null if not available. >+ */ >+ private SapphirePart getEndpoint(Anchor anchor) >+ { >+ if (anchor != null) >+ { >+ Object obj = getBusinessObjectForPictogramElement(anchor.getParent()); >+ if (obj instanceof SapphirePart) >+ { >+ return (SapphirePart) obj; >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateNodeFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateNodeFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateNodeFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireCreateNodeFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.context.ICreateContext; >+import org.eclipse.graphiti.features.impl.AbstractCreateFeature; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodeTemplate; >+ >+public class SapphireCreateNodeFeature extends AbstractCreateFeature >+{ >+ private DiagramNodeTemplate nodeTemplate; >+ >+ public SapphireCreateNodeFeature(IFeatureProvider fp, DiagramNodeTemplate nodeTemplate) >+ { >+ super(fp, nodeTemplate.getToolPaletteLabel(), nodeTemplate.getToolPaletteDesc()); >+ this.nodeTemplate = nodeTemplate; >+ } >+ >+ public boolean canCreate(ICreateContext context) >+ { >+ return context.getTargetContainer() instanceof Diagram; >+ } >+ >+ public Object[] create(ICreateContext context) >+ { >+ DiagramNodePart nodePart = this.nodeTemplate.createNewDiagramNode(); >+ >+ addGraphicalRepresentation(context, nodePart); >+ return new Object[] { nodePart }; >+ } >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireDirectEditNodeFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireDirectEditNodeFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireDirectEditNodeFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireDirectEditNodeFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import java.util.Iterator; >+ >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.context.IDirectEditingContext; >+import org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature; >+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; >+import org.eclipse.graphiti.mm.algorithms.Text; >+import org.eclipse.graphiti.mm.pictograms.Anchor; >+import org.eclipse.graphiti.mm.pictograms.Connection; >+import org.eclipse.graphiti.mm.pictograms.PictogramElement; >+import org.eclipse.graphiti.mm.pictograms.Shape; >+import org.eclipse.graphiti.services.Graphiti; >+import org.eclipse.sapphire.modeling.IModelElement; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionPart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+ >+public class SapphireDirectEditNodeFeature extends AbstractDirectEditingFeature >+{ >+ public SapphireDirectEditNodeFeature(IFeatureProvider fp) >+ { >+ super(fp); >+ } >+ >+ public int getEditingType() >+ { >+ return TYPE_TEXT; >+ } >+ >+ @Override >+ public boolean canDirectEdit(IDirectEditingContext context) >+ { >+ PictogramElement pe = context.getPictogramElement(); >+ Object bo = getBusinessObjectForPictogramElement(pe); >+ GraphicsAlgorithm ga = context.getGraphicsAlgorithm(); >+ // support direct editing, if it is a IADFView, and the user clicked >+ // directly on the text and not somewhere else in the rectangle >+ if (bo instanceof DiagramNodePart && ga instanceof Text) >+ { >+ return true; >+ } >+ // direct editing not supported in all other cases >+ return false; >+ } >+ >+ public String getInitialValue(IDirectEditingContext context) >+ { >+ // return the current name of the EClass >+ PictogramElement pe = context.getPictogramElement(); >+ DiagramNodePart nodePart = (DiagramNodePart)getBusinessObjectForPictogramElement(pe); >+ return nodePart.getLabel(); >+ } >+ >+ public void setValue(String value, IDirectEditingContext context) >+ { >+ // set the new id for the adf view >+ PictogramElement pe = context.getPictogramElement(); >+ >+ if (pe.eContainer() instanceof Shape) >+ { >+ DiagramNodePart nodePart = (DiagramNodePart)getBusinessObjectForPictogramElement(pe); >+ String oldValue = nodePart.getLabel(); >+ nodePart.setLabel(value); >+ IModelElement nodeElement = nodePart.getLocalModelElement(); >+ Shape nodeShape = (Shape)pe.eContainer(); >+ >+ // go through all the connections associated with this bo and update them >+ for (Iterator<Anchor> iter = nodeShape.getAnchors().iterator(); iter.hasNext();) >+ { >+ Anchor anchor = iter.next(); >+ for (Iterator<Connection> iterator = Graphiti.getPeService().getAllConnections(anchor).iterator(); iterator.hasNext();) >+ { >+ Connection connection = iterator.next(); >+ Object bo = getBusinessObjectForPictogramElement(connection); >+ if (bo instanceof DiagramConnectionPart) >+ { >+ DiagramConnectionPart connectionPart = (DiagramConnectionPart)bo; >+ IModelElement endpoint1 = connectionPart.getEndpoint1(); >+ IModelElement endpoint2 = connectionPart.getEndpoint2(); >+ if (endpoint1 == nodeElement) >+ { >+ connectionPart.refreshEndpoint1(); >+ } >+ else if (endpoint2 == nodeElement) >+ { >+ connectionPart.refreshEndpoint2(); >+ } >+ } >+ } >+ } >+ >+ } >+ >+ // Explicitly update the shape to display the new value in the diagram >+ // Note, that this might not be necessary in future versions of Graphiti >+ // (currently in discussion) >+ >+ // we know, that pe is the Shape of the Text, so its container is the >+ // main shape of the adf view >+ updatePictogramElement(((Shape)pe).getContainer()); >+ >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireUpdateNodeFeature.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireUpdateNodeFeature.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireUpdateNodeFeature.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/features/SapphireUpdateNodeFeature.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.features; >+ >+import org.eclipse.graphiti.features.IFeatureProvider; >+import org.eclipse.graphiti.features.IReason; >+import org.eclipse.graphiti.features.context.IUpdateContext; >+import org.eclipse.graphiti.features.impl.AbstractUpdateFeature; >+import org.eclipse.graphiti.features.impl.Reason; >+import org.eclipse.graphiti.mm.algorithms.Text; >+import org.eclipse.graphiti.mm.pictograms.ContainerShape; >+import org.eclipse.graphiti.mm.pictograms.PictogramElement; >+import org.eclipse.graphiti.mm.pictograms.Shape; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+ >+public class SapphireUpdateNodeFeature extends AbstractUpdateFeature >+{ >+ public SapphireUpdateNodeFeature(IFeatureProvider fp) >+ { >+ super(fp); >+ } >+ >+ public boolean canUpdate(IUpdateContext context) >+ { >+ Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement()); >+ return bo instanceof DiagramNodePart; >+ } >+ >+ public IReason updateNeeded(IUpdateContext context) >+ { >+ // retrieve name from pictogram model >+ String pictogramName = null; >+ PictogramElement pictogramElement = context.getPictogramElement(); >+ if (pictogramElement instanceof ContainerShape) >+ { >+ ContainerShape cs = (ContainerShape) pictogramElement; >+ for (Shape shape : cs.getChildren()) >+ { >+ if (shape.getGraphicsAlgorithm() instanceof Text) { >+ Text text = (Text) shape.getGraphicsAlgorithm(); >+ pictogramName = text.getValue(); >+ } >+ } >+ } >+ // retrieve name from business model >+ String businessName = null; >+ Object bo = getBusinessObjectForPictogramElement(pictogramElement); >+ if (bo instanceof DiagramNodePart) >+ { >+ DiagramNodePart nodePart = (DiagramNodePart) bo; >+ businessName = nodePart.getLabel(); >+ } >+ // update needed, if names are different >+ boolean updateNameNeeded = >+ ((pictogramName == null && businessName != null) || >+ (pictogramName != null && !pictogramName.equals(businessName))); >+ if (updateNameNeeded) >+ { >+ return Reason.createTrueReason("Name is out of date"); //$NON-NLS-1$ >+ } >+ else >+ { >+ return Reason.createFalseReason(); >+ } >+ } >+ >+ public boolean update(IUpdateContext context) >+ { >+ // retrieve name from business model >+ String businessName = null; >+ PictogramElement pictogramElement = context.getPictogramElement(); >+ Object bo = getBusinessObjectForPictogramElement(pictogramElement); >+ if (bo instanceof DiagramNodePart) { >+ DiagramNodePart nodePart = (DiagramNodePart) bo; >+ businessName = nodePart.getLabel(); >+ } >+ >+ // Set name in pictogram model >+ if (pictogramElement instanceof ContainerShape) >+ { >+ ContainerShape cs = (ContainerShape) pictogramElement; >+ for (Shape shape : cs.getChildren()) >+ { >+ if (shape.getGraphicsAlgorithm() instanceof Text) >+ { >+ Text text = (Text) shape.getGraphicsAlgorithm(); >+ text.setValue(businessName); >+ return true; >+ } >+ } >+ } >+ >+ return false; >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramFeatureProvider.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramFeatureProvider.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramFeatureProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramFeatureProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.providers; >+ >+import java.util.List; >+ >+import org.eclipse.graphiti.dt.IDiagramTypeProvider; >+import org.eclipse.graphiti.features.IAddFeature; >+import org.eclipse.graphiti.features.ICreateConnectionFeature; >+import org.eclipse.graphiti.features.ICreateFeature; >+import org.eclipse.graphiti.features.IDirectEditingFeature; >+import org.eclipse.graphiti.features.IUpdateFeature; >+import org.eclipse.graphiti.features.context.IAddContext; >+import org.eclipse.graphiti.features.context.IDirectEditingContext; >+import org.eclipse.graphiti.features.context.IUpdateContext; >+import org.eclipse.graphiti.features.impl.IIndependenceSolver; >+import org.eclipse.graphiti.mm.pictograms.ContainerShape; >+import org.eclipse.graphiti.mm.pictograms.PictogramElement; >+import org.eclipse.graphiti.ui.features.DefaultFeatureProvider; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionPart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramConnectionTemplate; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart; >+import org.eclipse.sapphire.ui.diagram.editor.DiagramNodeTemplate; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPart; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireAddConnectionFeature; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireAddNodeFeature; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireCreateConnectionFeature; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireCreateNodeFeature; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireDirectEditNodeFeature; >+import org.eclipse.sapphire.ui.diagram.graphiti.features.SapphireUpdateNodeFeature; >+ >+public class SapphireDiagramFeatureProvider extends DefaultFeatureProvider >+{ >+ private SapphireDiagramEditorPart diagramPart; >+ >+ public SapphireDiagramFeatureProvider(IDiagramTypeProvider dtp, IIndependenceSolver solver) >+ { >+ super(dtp); >+ this.setIndependenceSolver(solver); >+ } >+ >+ public void setDiagramPart(SapphireDiagramEditorPart diagramPart) >+ { >+ this.diagramPart = diagramPart; >+ >+ } >+ >+ public SapphireDiagramEditorPart getDiagramPart() >+ { >+ return this.diagramPart; >+ } >+ >+ @Override >+ public IAddFeature getAddFeature(IAddContext context) >+ { >+ Object obj = context.getNewObject(); >+ if (obj instanceof DiagramNodePart) >+ { >+ return new SapphireAddNodeFeature(this); >+ } >+ else if (obj instanceof DiagramConnectionPart) >+ { >+ return new SapphireAddConnectionFeature(this); >+ } >+ >+ return super.getAddFeature(context); >+ } >+ >+ @Override >+ public ICreateFeature[] getCreateFeatures() >+ { >+ List<DiagramNodeTemplate> nodeTemplates = this.diagramPart.getNodeTemplates(); >+ ICreateFeature[] features = new ICreateFeature[nodeTemplates.size()]; >+ int i = 0; >+ for (DiagramNodeTemplate nodeTemplate : nodeTemplates) >+ { >+ SapphireCreateNodeFeature createNodeFeature = >+ new SapphireCreateNodeFeature(this, nodeTemplate); >+ features[i++] = createNodeFeature; >+ } >+ return features; >+ } >+ >+ @Override >+ public ICreateConnectionFeature[] getCreateConnectionFeatures() >+ { >+ List<DiagramConnectionTemplate> connectionTemplates = this.diagramPart.getConnectionTemplates(); >+ ICreateConnectionFeature[] features = new ICreateConnectionFeature[connectionTemplates.size()]; >+ int i = 0; >+ for (DiagramConnectionTemplate connectionTemplate : connectionTemplates) >+ { >+ SapphireCreateConnectionFeature createConnectionFeature = >+ new SapphireCreateConnectionFeature(this, connectionTemplate); >+ features[i++] = createConnectionFeature; >+ } >+ return features; >+ } >+ >+ @Override >+ public IDirectEditingFeature getDirectEditingFeature(IDirectEditingContext context) >+ { >+ PictogramElement pe = context.getPictogramElement(); >+ Object bo = getBusinessObjectForPictogramElement((PictogramElement) pe.eContainer()); >+ if (bo instanceof DiagramNodePart) >+ { >+ return new SapphireDirectEditNodeFeature(this); >+ } >+ >+ return super.getDirectEditingFeature(context); >+ } >+ >+ @Override >+ public IUpdateFeature getUpdateFeature(IUpdateContext context) >+ { >+ PictogramElement pictogramElement = context.getPictogramElement(); >+ if (pictogramElement instanceof ContainerShape) >+ { >+ Object bo = getBusinessObjectForPictogramElement(pictogramElement); >+ if (bo instanceof DiagramNodePart) >+ { >+ return new SapphireUpdateNodeFeature(this); >+ } >+ } >+ return super.getUpdateFeature(context); >+ } >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramSolver.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramSolver.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramSolver.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramSolver.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.providers; >+ >+import java.util.HashMap; >+ >+import org.eclipse.graphiti.features.impl.IIndependenceSolver; >+import org.eclipse.sapphire.ui.SapphirePart; >+ >+public class SapphireDiagramSolver implements IIndependenceSolver >+{ >+ private HashMap<String, SapphirePart> keyToBOMap; >+ private HashMap<SapphirePart, String> bOToKeyMap; >+ private int counter = 0; >+ >+ public SapphireDiagramSolver() >+ { >+ this.keyToBOMap = new HashMap<String, SapphirePart>(); >+ this.bOToKeyMap = new HashMap<SapphirePart, String>(); >+ } >+ >+ public String getKeyForBusinessObject(Object bo) >+ { >+ if (bo instanceof SapphirePart) >+ { >+ SapphirePart part = (SapphirePart)bo; >+ if (this.bOToKeyMap.containsKey(bo)) >+ { >+ return this.bOToKeyMap.get(bo); >+ } >+ String key = Integer.toString(this.counter++); >+ this.keyToBOMap.put(key, part); >+ this.bOToKeyMap.put(part, key); >+ >+ return key; >+ } >+ return null; >+ } >+ >+ public Object getBusinessObjectForKey(String key) >+ { >+ if (key == null) >+ return null; >+ return this.keyToBOMap.get(key); >+ } >+ >+} >Index: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramTypeProvider.java >=================================================================== >RCS file: src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramTypeProvider.java >diff -N src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramTypeProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/sapphire/ui/diagram/graphiti/providers/SapphireDiagramTypeProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+package org.eclipse.sapphire.ui.diagram.graphiti.providers; >+ >+import org.eclipse.graphiti.dt.AbstractDiagramTypeProvider; >+import org.eclipse.graphiti.mm.pictograms.Diagram; >+import org.eclipse.graphiti.platform.IDiagramEditor; >+import org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPart; >+import org.eclipse.sapphire.ui.diagram.graphiti.editor.SapphireDiagramEditor; >+ >+public class SapphireDiagramTypeProvider extends AbstractDiagramTypeProvider >+{ >+ private SapphireDiagramEditorPart diagramPart; >+ private SapphireDiagramFeatureProvider featureProvider; >+ >+ public SapphireDiagramTypeProvider() >+ { >+ this.featureProvider = >+ new SapphireDiagramFeatureProvider(this, new SapphireDiagramSolver()); >+ setFeatureProvider(this.featureProvider); >+ } >+ >+ public void setDiagramPart(SapphireDiagramEditorPart diagramPart) >+ { >+ this.diagramPart = diagramPart; >+ this.featureProvider.setDiagramPart(diagramPart); >+ } >+ >+ public SapphireDiagramEditorPart getDiagramPart() >+ { >+ return this.diagramPart; >+ } >+ >+ @Override >+ public void init(Diagram diagram, IDiagramEditor diagramEditor) >+ { >+ super.init(diagram, diagramEditor); >+ setDiagramPart(((SapphireDiagramEditor)diagramEditor).getDiagramEditorPart()); >+ } >+}
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 330482
:
183320
|
183327
|
183361
|
183403
|
184197
|
184669
|
185156
|
185573
|
185574
|
185576
|
185679
|
186532
|
186776
|
186777