Skip to content
Snippets Groups Projects
Commit 9991926e authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Diagram editor example

parent 6508b91a
Branches
No related tags found
No related merge requests found
Showing with 639 additions and 10 deletions
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tdt4250.ra.diagram.examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>org.eclipse.sirius.nature.modelingproject</nature>
</natures>
</projectDescription>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ra:Department xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ra="platform:/plugin/tdt4250.ra/model/ra.ecore" name="Dept. of CS" shortName="IDI">
<staff name="Hallvard" allocations="//@resourceAllocations.0 //@resourceAllocations.1"/>
<staff name="Adrian" allocations="//@resourceAllocations.2"/>
<staff name="Børge" allocations="//@resourceAllocations.3"/>
<courses code="TDT4250" name="AdvSoft" allocations="//@resourceAllocations.0"/>
<courses code="IT1901" name="InfProj" allocations="//@resourceAllocations.1 //@resourceAllocations.2"/>
<courses code="TDT4100" allocations="//@resourceAllocations.3"/>
<resourceAllocations person="//@staff.0" course="//@courses.0" factor="1.5"/>
<resourceAllocations person="//@staff.0" course="//@courses.1" factor="0.3"/>
<resourceAllocations person="//@staff.1" course="//@courses.1" factor="0.7"/>
<resourceAllocations person="//@staff.2" course="//@courses.2"/>
</ra:Department>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tdt4250.ra.diagram</name>
<comment></comment>
<projects></projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments></arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: tdt4250.ra.diagram;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: tdt4250.ra.diagram.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.sirius,
org.eclipse.sirius.common.acceleo.aql
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: %providerName
Automatic-Module-Name: tdt4250.ra.diagram
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
description/,\
plugin.properties,\
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="ra" version="12.0.0.2017041100">
<ownedViewpoints name="RaViewpoint" label="Ra Viewpoint" modelFileExtension="ra">
<ownedRepresentations xsi:type="description_1:DiagramDescription" name="RaDiagram" label="Ra Diagram" domainClass="ra::Department" enablePopupBars="true">
<defaultLayer name="Default">
<nodeMappings name="PersonNode" label="Person Node" semanticCandidatesExpression="aql:self.staff" domainClass="ra::Person">
<style xsi:type="style:BundledImageDescription" labelSize="12" showIcon="false" resizeKind="NSEW">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_blue']"/>
</style>
</nodeMappings>
<nodeMappings name="CourseNode" label="Course Node" semanticCandidatesExpression="aql:self.courses" domainClass="ra::Course">
<style xsi:type="style:BundledImageDescription" labelSize="12" showIcon="false" labelExpression="feature:code" resizeKind="NSEW" shape="dot">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_green']"/>
</style>
</nodeMappings>
<edgeMappings name="ResourceAllocationEdge" label="ResourceAllocation Edge" semanticCandidatesExpression="aql:self.resourceAllocations" sourceMapping="//@ownedViewpoints[name='RaViewpoint']/@ownedRepresentations[name='RaDiagram']/@defaultLayer/@nodeMappings[name='PersonNode']" targetMapping="//@ownedViewpoints[name='RaViewpoint']/@ownedRepresentations[name='RaDiagram']/@defaultLayer/@nodeMappings[name='CourseNode']" targetFinderExpression="aql:self.course" sourceFinderExpression="aql:self.person" domainClass="ra::ResourceAllocation" useDomainElement="true">
<style sizeComputationExpression="2">
<strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='gray']"/>
<centerLabelStyleDescription labelSize="12" showIcon="false" labelExpression="feature:factor">
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
</centerLabelStyleDescription>
</style>
</edgeMappings>
<toolSections name="CreationTools" label="Creation Tools">
<ownedTools xsi:type="tool:NodeCreationDescription" name="CreateCourse" label="Create Course" nodeMappings="//@ownedViewpoints[name='RaViewpoint']/@ownedRepresentations[name='RaDiagram']/@defaultLayer/@nodeMappings[name='CourseNode']">
<variable name="container"/>
<viewVariable name="containerView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:CreateInstance" typeName="ra::Course" referenceName="courses">
<subModelOperations xsi:type="tool_1:SetValue" featureName="code" valueExpression="TDT"/>
</firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool:NodeCreationDescription" name="CreatePerson" label="Create Person" nodeMappings="//@ownedViewpoints[name='RaViewpoint']/@ownedRepresentations[name='RaDiagram']/@defaultLayer/@nodeMappings[name='PersonNode']">
<variable name="container"/>
<viewVariable name="containerView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:CreateInstance" typeName="ra::Person" referenceName="staff">
<subModelOperations xsi:type="tool_1:SetValue" featureName="name" valueExpression="no-name"/>
</firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool:EdgeCreationDescription" name="CreateResourceAllocation" label="Create ResourceAllocation" edgeMappings="//@ownedViewpoints[name='RaViewpoint']/@ownedRepresentations[name='RaDiagram']/@defaultLayer/@edgeMappings[name='ResourceAllocationEdge']">
<sourceVariable name="source"/>
<targetVariable name="target"/>
<sourceViewVariable name="sourceView"/>
<targetViewVariable name="targetView"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="aql:source.employer">
<subModelOperations xsi:type="tool_1:CreateInstance" typeName="ra::ResourceAllocation" referenceName="resourceAllocations">
<subModelOperations xsi:type="tool_1:SetValue" featureName="person" valueExpression="var:source"/>
<subModelOperations xsi:type="tool_1:SetValue" featureName="course" valueExpression="var:target"/>
</subModelOperations>
</firstModelOperations>
</initialOperation>
</ownedTools>
</toolSections>
</defaultLayer>
</ownedRepresentations>
<ownedJavaExtensions qualifiedClassName="tdt4250.ra.diagram.Services"/>
</ownedViewpoints>
</description:Group>
pluginName = tdt4250.ra.diagram
providerName = Eclipse Modeling Project
viewpointName = MyViewpoint
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension point="org.eclipse.sirius.componentization">
<component class="tdt4250.ra.diagram.Activator"
id="tdt4250.ra.diagram"
name="ra">
</component>
</extension>
</plugin>
package tdt4250.ra.diagram;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.sirius.business.api.componentization.ViewpointRegistry;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "tdt4250.ra.diagram";
// The shared instance
private static Activator plugin;
private static Set<Viewpoint> viewpoints;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
viewpoints = new HashSet<Viewpoint>();
viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(PLUGIN_ID + "/description/ra.odesign"));
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
if (viewpoints != null) {
for (final Viewpoint viewpoint: viewpoints) {
ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
}
viewpoints.clear();
viewpoints = null;
}
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
package tdt4250.ra.diagram;
import org.eclipse.emf.ecore.EObject;
/**
* The services class used by VSM.
*/
public class Services {
/**
* See http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.sirius.doc%2Fdoc%2Findex.html&cp=24 for documentation on how to write service methods.
*/
public EObject myService(EObject self, String arg) {
// TODO Auto-generated code
return self;
}
}
...@@ -2,19 +2,29 @@ ...@@ -2,19 +2,29 @@
<ra:Department <ra:Department
xmi:version="2.0" xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ra="platform:/plugin/tdt4250.ra/model/ra.ecore" xmlns:ra="platform:/plugin/tdt4250.ra/model/ra.ecore"
xsi:schemaLocation="platform:/plugin/tdt4250.ra/model/ra.ecore ra.ecore"
name="Dept. of CS" name="Dept. of CS"
shortName="IDI"> shortName="IDI">
<staff name="Hallvard"
allocations="//@resourceAllocations.0 //@resourceAllocations.1"/>
<staff name="Adrian"
allocations="//@resourceAllocations.2"/>
<courses code="TDT4250"
name="AdvSoft"
allocations="//@resourceAllocations.0"/>
<courses code="IT1901"
name="InfProj"
allocations="//@resourceAllocations.1 //@resourceAllocations.2"/>
<resourceAllocations <resourceAllocations
factor="0.5"> person="//@staff.0"
<person course="//@courses.0"
href="idi.xmi#//@staff.0"/> factor="1.0"/>
</resourceAllocations>
<resourceAllocations <resourceAllocations
factor="1.0"> person="//@staff.0"
<person course="//@courses.1"
href="idi.xmi#//@staff.0"/> factor="0.3"/>
</resourceAllocations> <resourceAllocations
person="//@staff.1"
course="//@courses.1"
factor="0.7"/>
</ra:Department> </ra:Department>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment