Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2013-05-27 14:14:17 +0000
committercdumoulin2013-05-27 14:14:17 +0000
commitdd4ed5d91d870151b083d2a5edc2143dcfd7ec36 (patch)
treeaa1c9ab113084ffafc96779aee2f4741a0be0dd7 /extraplugins/java
parentf75d4cff249e3a4d2ccb1ef01f605fda2aa79a90 (diff)
downloadorg.eclipse.papyrus-dd4ed5d91d870151b083d2a5edc2143dcfd7ec36.tar.gz
org.eclipse.papyrus-dd4ed5d91d870151b083d2a5edc2143dcfd7ec36.tar.xz
org.eclipse.papyrus-dd4ed5d91d870151b083d2a5edc2143dcfd7ec36.zip
399058: [Java] Java plugins (reverse, generator, profile) should be available from "Install Papyrus additional Component"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399058 - change providerName (use Eclipe) - add a menu entry allowing to create Association from properties.
Diffstat (limited to 'extraplugins/java')
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java-updatesite/site.xml14
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.generator.jdtsynchronizer/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.edit/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.editor/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.profile.edit/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.profile.editor/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.profile/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse.ui/icons/associationFromProperty.gifbin0 -> 96 bytes
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.xml55
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse.ui/src/org/eclipse/papyrus/java/reverse/ui/handlers/CreateAssociationFromPropertyHandler.java281
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse/plugin.properties2
-rw-r--r--extraplugins/java/org.eclipse.papyrus.java.reverse/src/org/eclipse/papyrus/java/reverse/utils/TypeOperationsEnhanced.java169
15 files changed, 521 insertions, 19 deletions
diff --git a/extraplugins/java/org.eclipse.papyrus.java-updatesite/site.xml b/extraplugins/java/org.eclipse.papyrus.java-updatesite/site.xml
index 04f39ab0937..7ca05aad69a 100644
--- a/extraplugins/java/org.eclipse.papyrus.java-updatesite/site.xml
+++ b/extraplugins/java/org.eclipse.papyrus.java-updatesite/site.xml
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
- <feature url="features/org.eclipse.papyrus.java.reverse.feature_0.10.0.201301311719.jar" id="org.eclipse.papyrus.java.reverse.feature" version="0.10.0.201301311719">
+ <feature url="features/org.eclipse.papyrus.java.generator.feature_0.10.0.201305271555.jar" id="org.eclipse.papyrus.java.generator.feature" version="0.10.0.201305271555">
+ <category name="org.eclipse.papyrus.java.generator"/>
<category name="org.eclipse.papyrus.java"/>
</feature>
- <feature url="features/org.eclipse.papyrus.java.profile.feature_0.10.0.201301311719.jar" id="org.eclipse.papyrus.java.profile.feature" version="0.10.0.201301311719">
+ <feature url="features/org.eclipse.papyrus.java.reverse.feature_0.10.0.201305271555.jar" id="org.eclipse.papyrus.java.reverse.feature" version="0.10.0.201305271555">
<category name="org.eclipse.papyrus.java"/>
- <category name="org.eclipse.papyrus.java.profile"/>
</feature>
- <feature url="features/org.eclipse.papyrus.java.generator.feature_0.10.0.201301311719.jar" id="org.eclipse.papyrus.java.generator.feature" version="0.10.0.201301311719">
+ <feature url="features/org.eclipse.papyrus.java.profile.feature_0.10.0.201305271555.jar" id="org.eclipse.papyrus.java.profile.feature" version="0.10.0.201305271555">
+ <category name="org.eclipse.papyrus.java.profile"/>
<category name="org.eclipse.papyrus.java"/>
- <category name="org.eclipse.papyrus.java.generator"/>
</feature>
<category-def name="org.eclipse.papyrus.java.generator" label="Java Generator">
<description>
@@ -21,9 +21,9 @@
This profile is used by the Java generator and the Java reverse to add additional properties to the UML model. These properties allows to change the names, specify project target, source targets, ...
</description>
</category-def>
- <category-def name="org.eclipse.papyrus.java" label="Java Tools For Ppyrus">
+ <category-def name="org.eclipse.papyrus.java" label="Java Tools For Papyrus">
<description>
- Tools related to the Java language.
+ Tools related to the Java language. This set of plugins allows to reverse java code to a Papyrus model, and to generate Java code from a Papyrus model.
</description>
</category-def>
</site>
diff --git a/extraplugins/java/org.eclipse.papyrus.java.generator.jdtsynchronizer/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.generator.jdtsynchronizer/plugin.properties
index 0dcfd846a4b..41b9da94450 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.generator.jdtsynchronizer/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.generator.jdtsynchronizer/plugin.properties
@@ -15,4 +15,4 @@
pluginName = Jdt Synchronizer (Incubation)
-providerName = Nicolas Deblock and Manuel Giles
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.edit/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.edit/plugin.properties
index 54108df1eab..1e5303e0749 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.edit/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.edit/plugin.properties
@@ -14,7 +14,7 @@
#################################################################################
pluginName = Jdt metamodel edit (Incubation)
-providerName = Nicolas Deblock and Manuel Giles
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.editor/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.editor/plugin.properties
index fe2e8db2acf..6ada7272ef5 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.editor/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt.editor/plugin.properties
@@ -16,7 +16,7 @@
pluginName = Jdt metamodel editor (Incubation)
-providerName = Nicolas Deblock and Manuel Giles
+providerName = Eclipse Modeling Project
_UI_JdtmmEditor_menu = &Jdtmm Editor
diff --git a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt/plugin.properties
index 33d31ed981c..0a19e739f6a 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.generator.metamodel.jdt/plugin.properties
@@ -15,5 +15,5 @@
pluginName = Jdt metamodel (Incubation)
-providerName = Nicolas Deblock and Manuel Giles
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.profile.edit/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.profile.edit/plugin.properties
index 975ea750227..dfb7e79f433 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.profile.edit/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.profile.edit/plugin.properties
@@ -14,7 +14,7 @@
#################################################################################
pluginName = Profile for Java classes generation Edit Support (Incubation)
-providerName = Cedric Dumoulin
+providerName = Eclipse Modeling Project
_UI_CreateChild_text = {0}
_UI_CreateChild_text2 = {1} {0}
diff --git a/extraplugins/java/org.eclipse.papyrus.java.profile.editor/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.profile.editor/plugin.properties
index e512f754485..f21e2f2baf8 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.profile.editor/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.profile.editor/plugin.properties
@@ -13,7 +13,7 @@
#################################################################################
pluginName = Profile for Java classes generation Editor Support (Incubation)
-providerName = Cedric Dumoulin
+providerName = Eclipse Modeling Project
_UI_JavaEditor_menu = &Java Editor
diff --git a/extraplugins/java/org.eclipse.papyrus.java.profile/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.profile/plugin.properties
index 937f8a00a6d..bc49c812cb7 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.profile/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.profile/plugin.properties
@@ -13,4 +13,4 @@
#################################################################################
pluginName = Profile for Java classes generation (Incubation)
-providerName = Cedric Dumoulin
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/icons/associationFromProperty.gif b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/icons/associationFromProperty.gif
new file mode 100644
index 00000000000..b4fbec9c849
--- /dev/null
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/icons/associationFromProperty.gif
Binary files differ
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.properties
index 97c3d969986..fba264cf201 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.properties
@@ -13,4 +13,4 @@
#################################################################################
pluginName = Java Reverse UI (Incubation)
-providerName = Cedric Dumoulin
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.xml b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.xml
index 9d76a3c9bac..8b7f78dc466 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.xml
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/plugin.xml
@@ -7,6 +7,10 @@
class="org.eclipse.papyrus.java.reverse.ui.ReverseCodeHandler"
commandId="org.eclipse.papyrus.java.reverse.ui.reverseCodeCommand">
</handler>
+ <handler
+ class="org.eclipse.papyrus.java.reverse.ui.handlers.CreateAssociationFromPropertyHandler"
+ commandId="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand">
+ </handler>
</extension>
<extension
point="org.eclipse.ui.menus">
@@ -21,30 +25,72 @@
style="push"
tooltip="Reverse Java code into current model">
</command>
+ <command
+ commandId="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand"
+ icon="icons/associationFromProperty.gif"
+ label="Create Association From Property"
+ style="push">
+ </command>
</toolbar>
</menuContribution>
<menuContribution
locationURI="menu:org.eclipse.papyrus.ui.menu">
<menu
id="org.eclipse.papyrus.java.ui.menu"
- label="java">
+ label="Java">
<command
commandId="org.eclipse.papyrus.java.reverse.ui.reverseCodeCommand"
style="push">
</command>
</menu>
+ <menu
+ id="org.eclipse.papyrus.ui.menu.misc"
+ label="Utils">
+ <command
+ commandId="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand"
+ icon="icons/associationFromProperty.gif"
+ label="Create Association From Property"
+ style="push">
+ </command>
+ </menu>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.sash.ui.folder">
<menu
id="org.eclipse.papyrus.java.ui.sash.menu"
- label="java">
+ label="Java">
<command
commandId="org.eclipse.papyrus.java.reverse.ui.reverseCodeCommand"
style="push">
</command>
</menu>
</menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
+ <menu
+ id="org.eclipse.papyrus.ui.popupmenu.modelexplorer.misc"
+ label="Utils">
+ <command
+ commandId="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand"
+ icon="icons/associationFromProperty.gif"
+ label="Create Association From Property"
+ style="push">
+ </command>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
+ <menu
+ id="org.eclipse.papyrus.ui.popupmenu.diagram.misc"
+ label="Utils">
+ <command
+ commandId="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand"
+ icon="icons/associationFromProperty.gif"
+ label="Create Association From Property"
+ style="push">
+ </command>
+ </menu>
+ </menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
@@ -53,6 +99,11 @@
id="org.eclipse.papyrus.java.reverse.ui.reverseCodeCommand"
name="Java Reverse">
</command>
+ <command
+ description="Create a New association from the Property."
+ id="org.eclipse.papyrus.java.reverse.ui.commands.CreateAssociationFromPropertyCommand"
+ name="Create Association From Property">
+ </command>
</extension>
</plugin>
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/src/org/eclipse/papyrus/java/reverse/ui/handlers/CreateAssociationFromPropertyHandler.java b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/src/org/eclipse/papyrus/java/reverse/ui/handlers/CreateAssociationFromPropertyHandler.java
new file mode 100644
index 00000000000..0dbeef8fe12
--- /dev/null
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse.ui/src/org/eclipse/papyrus/java/reverse/ui/handlers/CreateAssociationFromPropertyHandler.java
@@ -0,0 +1,281 @@
+/**
+ *
+ */
+package org.eclipse.papyrus.java.reverse.ui.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.java.reverse.utils.TypeOperationsEnhanced;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.internal.operations.TypeOperations;
+
+
+/**
+ * An handler getting the selected element and reporting them in console.
+ *
+ * @author Cedric dumoulin
+ *
+ */
+public class CreateAssociationFromPropertyHandler extends AbstractHandler implements IHandler {
+
+
+ /**
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ * @param event
+ * @return
+ * @throws ExecutionException
+ *
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ List<Object> objects = lookupSelectedElements();
+ List<Property> selectedProperties = getAllSelectionOfType( event, Property.class );
+ if( objects == null) {
+
+ showErrorDialog(event, "No object selected", "Can't create association. Please select a Property First.");
+ return null;
+ }
+
+ // Try creation
+ try {
+ doExecute( selectedProperties );
+ } catch (ServiceException e) {
+ showErrorDialog(event, "Can't get TransactionalEditingDomain", e.getMessage());
+ e.printStackTrace();
+ }
+ catch (Exception e) {
+ showErrorDialog(event, "Can't Create Association", e.getMessage());
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * Get all selected element of the specified type.
+ *
+ * @param expectedType
+ * @return
+ * @throws ExecutionException
+ */
+ private <T> List<T> getAllSelectionOfType(ExecutionEvent event, Class<T> expectedType) throws ExecutionException {
+
+ ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
+// IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+// ISelection selection = page.getSelection();
+ System.out.println("check " + selection);
+ if(selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ return getAllElementOfType( structuredSelection.toList(), expectedType);
+ }
+ else if( selection instanceof TreeSelection) {
+ TreeSelection treeSelection = (TreeSelection)selection;
+ return getAllElementOfType( treeSelection.toList(), expectedType );
+
+ }
+ return null;
+ }
+
+ /**
+ * Filter the list, and only retain objects that can be adapted to the specified type
+ * @param objects
+ * @param class1
+ * @return
+ */
+ private <T> List<T> getAllElementOfType(List<Object> list, Class<T> expectedClassType) {
+
+ List<T> res = new ArrayList<T>();
+
+ for( Object cur : list) {
+
+ T adapted = adapt( cur, expectedClassType);
+ if( adapted != null)
+ res.add(adapted);
+ }
+ return res;
+ }
+
+ /**
+ * Adapt the specified object to the requested type, if possible.
+ * Return null if the object can't be adapted.
+ *
+ * @param object
+ * @param expectedClassType
+ * @return The adapted object, or null.
+ */
+ private <T> T adapt( Object object, Class<T> expectedClassType) {
+
+ if( object instanceof IAdaptable ) {
+ @SuppressWarnings("unchecked")
+ T ele = (T)((IAdaptable)object).getAdapter(expectedClassType);
+ if(ele != null) {
+ return ele;
+ }
+ // Try as EObject if the expectedClasType is sub-type of EObject.
+ if( EObject.class.isAssignableFrom( expectedClassType) ) {
+ // to EObject
+ EObject eobject = (EObject)((IAdaptable)object).getAdapter(EObject.class);
+
+ if(eobject != null && expectedClassType.isInstance(eobject)) {
+ return (T)eobject;
+ }
+ }
+ }
+
+ // Try global mechanism
+ {
+ @SuppressWarnings("unchecked")
+ T ele = (T)Platform.getAdapterManager().getAdapter(object, expectedClassType);
+ if(ele != null) {
+ return ele;
+ }
+ // Try as EObject if the expectedClasType is sub-type of EObject.
+ if( EObject.class.isAssignableFrom( expectedClassType) ) {
+ // to EObject
+ EObject eobject = (EObject)Platform.getAdapterManager().getAdapter(object, EObject.class);
+
+ if(eobject != null && expectedClassType.isInstance(eobject)) {
+
+ return (T)eobject;
+ }
+ }
+ }
+ // Can't be adapted
+ return null;
+
+ }
+ /**
+ *
+ * @param event
+ * @param errorMessage
+ * @throws ExecutionException
+ */
+ private void showErrorDialog(ExecutionEvent event, String title, String errorMessage) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ MessageDialog.openError(
+ window.getShell(),
+ title,
+ errorMessage);
+ }
+
+
+ /**
+ * Get the name used in the {@link RecordingCommand}. This name will be visible in
+ * undo/redo.
+ *
+ * @return The command name to show.
+ */
+ public String getCommandName() {
+ return "Create Association";
+ }
+
+ /**
+ * Do the execution of the command.
+ *
+ * @param objects List of object to generate Java code from.
+ * @throws ServiceException
+ */
+ protected void doExecute(final List<?> objects) throws ServiceException {
+
+ // Execute the reverse with provided paramters
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(editingDomain, getCommandName()) {
+
+ @Override
+ protected void doExecute() {
+ System.out.println(" Selections:");
+
+ for( Object obj : objects) {
+
+ System.out.println("found '" + obj + "'.");
+ createAssociationFromProperty((Property)obj);
+ }
+ }
+
+ };
+
+ editingDomain.getCommandStack().execute(command);
+
+
+ }
+
+
+ /**
+ * Create an association from the specified Property. The association is created
+ * in the property's nearest package.
+ *
+ * @param p The property to use to create an association.
+ */
+ protected void createAssociationFromProperty( Property p) {
+
+ Element owner = p.getOwner();
+
+ if( owner instanceof Type) {
+
+ Type classOwner = (Type)owner;
+
+ // Compute other end name
+ String name = classOwner.getName();
+ String newname = name.substring(0, 1).toLowerCase() + name.substring(1);
+ // Create
+ TypeOperationsEnhanced.createAssociationFromProperty( p, true, AggregationKind.COMPOSITE_LITERAL,
+ false, AggregationKind.NONE_LITERAL, newname, 0, 1);
+ }
+ }
+
+ /**
+ * Lookup selected objects in UI.
+ * @return
+ */
+ private List<Object> lookupSelectedElements() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ ISelection selection = page.getSelection();
+ System.out.println("check " + selection);
+ if(selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ return structuredSelection.toList();
+ }
+ else if( selection instanceof TreeSelection) {
+ TreeSelection treeSelection = (TreeSelection)selection;
+ return treeSelection.toList();
+
+ }
+ return null;
+ }
+
+ /**
+ * Get the main editing doamin.
+ *
+ * @return
+ * @throws ServiceException
+ */
+ protected TransactionalEditingDomain getEditingDomain() throws ServiceException {
+ return ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ }
+
+}
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse/META-INF/MANIFEST.MF b/extraplugins/java/org.eclipse.papyrus.java.reverse/META-INF/MANIFEST.MF
index c178777f8e1..e9698383384 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.reverse/META-INF/MANIFEST.MF
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse/META-INF/MANIFEST.MF
@@ -8,7 +8,8 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: japa.parser,
japa.parser.ast,
- javagen.umlparser
+ javagen.umlparser,
+ org.eclipse.papyrus.java.reverse.utils
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.uml2.uml;visibility:=reexport
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse/plugin.properties b/extraplugins/java/org.eclipse.papyrus.java.reverse/plugin.properties
index ffcb5701557..4baa6d1eeda 100644
--- a/extraplugins/java/org.eclipse.papyrus.java.reverse/plugin.properties
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse/plugin.properties
@@ -13,4 +13,4 @@
#################################################################################
pluginName=Java Reverse (Incubation)
-providerName=Cedric Dumoulin
+providerName=Eclipse Modeling Project
diff --git a/extraplugins/java/org.eclipse.papyrus.java.reverse/src/org/eclipse/papyrus/java/reverse/utils/TypeOperationsEnhanced.java b/extraplugins/java/org.eclipse.papyrus.java.reverse/src/org/eclipse/papyrus/java/reverse/utils/TypeOperationsEnhanced.java
new file mode 100644
index 00000000000..4103b3d3d6e
--- /dev/null
+++ b/extraplugins/java/org.eclipse.papyrus.java.reverse/src/org/eclipse/papyrus/java/reverse/utils/TypeOperationsEnhanced.java
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Cedric Dumoulin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.java.reverse.utils;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.internal.operations.TypeOperations;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * A static utility class that provides operations related to '<em><b>Type</b></em>' model objects.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following operations are supported:
+ * <ul>
+ * <li>{@link org.eclipse.uml2.uml.Type#createAssociation(boolean, org.eclipse.uml2.uml.AggregationKind, java.lang.String, int, int, org.eclipse.uml2.uml.Type, boolean, org.eclipse.uml2.uml.AggregationKind, java.lang.String, int, int) <em>Create Association</em>}</li>
+ * <li>{@link org.eclipse.uml2.uml.Type#getAssociations() <em>Get Associations</em>}</li>
+ * <li>{@link org.eclipse.uml2.uml.Type#conformsTo(org.eclipse.uml2.uml.Type) <em>Conforms To</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @copyright copied from org.eclipse.uml2.uml.internal.operations.TypeOperations
+ */
+public class TypeOperationsEnhanced extends TypeOperations {
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TypeOperationsEnhanced() {
+ super();
+ }
+
+ protected static Property setAssociationEnd(Property property,
+ Association association, boolean isNavigable,
+ AggregationKind aggregation) {
+
+ Property associationEnd = property;
+
+ associationEnd.setAggregation(aggregation);
+
+ if (isNavigable) {
+ association.getMemberEnds().add(associationEnd);
+ }
+
+ return associationEnd;
+ }
+
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * Creates a(n) (binary) association between this type and the specified other type, with the specified navigabilities, aggregations, names, lower bounds, and upper bounds, and owned by this type's nearest package.
+ * @param type The receiving '<em><b>Type</b></em>' model object.
+ * @param end1IsNavigable The navigability for the first end of the new association.
+ * @param end1Aggregation The aggregation for the first end of the new association.
+ * @param end1Name The name for the first end of the new association.
+ * @param end1Lower The lower bound for the first end of the new association.
+ * @param end1Upper The upper bound for the first end of the new association.
+ * @param end1Type The type for the first end of the new association.
+ * @param end2IsNavigable The navigability for the second end of the new association.
+ * @param end2Aggregation The aggregation for the second end of the new association.
+ * @param end2Name The name for the second end of the new association.
+ * @param end2Lower The lower bound for the second end of the new association.
+ * @param end2Upper The upper bound for the second end of the new association.
+ * <!-- end-model-doc -->
+ * @generated NOT
+ */
+ public static Association createAssociationFromProperty(Property property,
+ boolean end1IsNavigable, AggregationKind end1Aggregation,
+ boolean end2IsNavigable, AggregationKind end2Aggregation,
+ String end2Name, int end2Lower, int end2Upper) {
+ return createAssociationFromProperty(property, end1IsNavigable, end1Aggregation,
+ end2IsNavigable, end2Aggregation,
+ end2Name, end2Lower, end2Upper,
+ UMLPackage.Literals.ASSOCIATION);
+ }
+
+ /**
+ *
+ * @param property
+ * @param end1IsNavigable
+ * @param end1Aggregation
+ * @param end2IsNavigable
+ * @param end2Aggregation
+ * @param end2Name
+ * @param end2Lower
+ * @param end2Upper
+ * @param eClass
+ * @return
+ */
+ protected static Association createAssociationFromProperty(Property property,
+ boolean end1IsNavigable, AggregationKind end1Aggregation,
+ boolean end2IsNavigable, AggregationKind end2Aggregation,
+ String end2Name, int end2Lower, int end2Upper,
+ EClass eClass) {
+
+ // Check if there the property is already part of an association
+ if( property.getAssociation() != null ) {
+ return property.getAssociation();
+ }
+
+ // Get owner (end2Type)
+ Type type;
+ try {
+ type = (Type)property.getOwner();
+ } catch (ClassCastException e) {
+ throw new IllegalArgumentException("Property's owner should be a Type");
+ }
+
+ Type end1Type = property.getType();
+ // Validate end1
+ validateTypeAndBounds(end1Type, end2Lower, end2Upper);
+
+
+ org.eclipse.uml2.uml.Package package_ = type.getNearestPackage();
+
+ if (package_ == null) {
+ throw new IllegalStateException();
+ }
+
+ if (end1Aggregation == null) {
+ throw new IllegalArgumentException(String.valueOf(end1Aggregation));
+ }
+
+ if (end2Aggregation == null) {
+ throw new IllegalArgumentException(String.valueOf(end2Aggregation));
+ }
+
+ Association association = (Association) package_.createOwnedType(null, eClass);
+ association.setName("A_" + property.getName() + "_" + end2Name);
+
+ // Set end1
+// createAssociationEnd(type, association, end1IsNavigable,
+// end1Aggregation, end1Name, end1Lower, end1Upper, end1Type);
+ setAssociationEnd( property, association, end1IsNavigable,
+ end1Aggregation);
+
+ createAssociationEnd(end1Type, association, end2IsNavigable,
+ end2Aggregation, end2Name, end2Lower, end2Upper, type);
+
+
+
+
+
+ return association;
+ }
+
+} // TypeOperations \ No newline at end of file

Back to the top