Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.classpath7
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.project28
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.svnignore1
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/META-INF/MANIFEST.MF22
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/about.html28
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/build.properties5
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/plugin.xml6
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/schema/profileDiagram.exsd143
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/Activator.java65
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/controller/ProfileDiagramController.java208
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDragDropEditPolicy.java153
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDropTargetListener.java42
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParser.java152
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParserProvider.java71
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/OCLUtils.java67
-rw-r--r--deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java177
17 files changed, 0 insertions, 1183 deletions
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.classpath b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.classpath
deleted file mode 100644
index 2d1a4302f04..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.project b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.project
deleted file mode 100644
index 4ed4e112799..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.diagramprofile</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>
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.settings/org.eclipse.jdt.core.prefs b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 60cc9b00ecc..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,8 +0,0 @@
-#Tue Sep 22 09:17:03 CEST 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.svnignore b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.svnignore
deleted file mode 100644
index c5e82d74585..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/.svnignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/META-INF/MANIFEST.MF b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/META-INF/MANIFEST.MF
deleted file mode 100644
index 2efc4139643..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,22 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Profile management Plugin
-Bundle-SymbolicName: org.eclipse.papyrus.diagramprofile;singleton:=true
-Bundle-Version: 0.7.0.qualifier
-Bundle-Activator: org.eclipse.papyrus.diagramprofile.Activator
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.uml2.uml,
- org.eclipse.papyrus.core,
- org.eclipse.ocl.ecore,
- org.eclipse.papyrus.resource,
- org.eclipse.gmf.runtime.common.ui.services.dnd;visibility:=reexport,
- org.eclipse.papyrus.diagram.common;visibility:=reexport
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.papyrus.diagramprofile,
- org.eclipse.papyrus.diagramprofile.controller,
- org.eclipse.papyrus.diagramprofile.dnd,
- org.eclipse.papyrus.diagramprofile.parsers,
- org.eclipse.papyrus.diagramprofile.utils
-Bundle-Vendor: Eclipse.org
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/about.html b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/about.html
deleted file mode 100644
index 50d9eae0154..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>December 15, 2009</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/build.properties b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/build.properties
deleted file mode 100644
index 6f20375d6c7..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/plugin.xml b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/plugin.xml
deleted file mode 100644
index edd1cf05707..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/plugin.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension-point id="profileDiagram" name="Profile Diagram" schema="schema/profileDiagram.exsd"/>
-
-</plugin>
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/schema/profileDiagram.exsd b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/schema/profileDiagram.exsd
deleted file mode 100644
index fe9bc8bdbcf..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/schema/profileDiagram.exsd
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.diagramprofile" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.diagramprofile" id="profileDiagram" name="Profile Diagram"/>
- </appinfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="profileDiagram"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="profileDiagram">
- <complexType>
- <attribute name="classeCandidatesForNewDiagram" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.EClass"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="diagramName" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="profileToMatchName" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="creationCommand" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.core.extension.commands.ICreationCommand"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="commandId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/Activator.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/Activator.java
deleted file mode 100644
index b34be6a4054..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/Activator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile;
-
-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 = "org.eclipse.papyrus.diagramprofile";
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * 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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/controller/ProfileDiagramController.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/controller/ProfileDiagramController.java
deleted file mode 100644
index 78afee7152c..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/controller/ProfileDiagramController.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.controller;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.papyrus.core.editor.BackboneException;
-import org.eclipse.papyrus.core.extension.commands.CreationCommandDescriptor;
-import org.eclipse.papyrus.core.extension.commands.ICreationCommand;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageableElement;
-import org.eclipse.uml2.uml.Profile;
-import org.osgi.framework.Bundle;
-
-public class ProfileDiagramController {
-
- private static final String ATTR_ICON = "icon";
-
- private static final String ATTR_DIAGRAM_NAME = "diagramName";
-
- private static final String ATTR_CLASSES_CANDIDATES_FOR_NEW_DIAGRAM = "classeCandidatesForNewDiagram";
-
- private static final String ATTR_PROFILE_AVAILABLE = "profileToMatchName";
-
- private static final String ATTR_CREATION_COMMAND = "creationCommand";
-
- private static final String ATTR_COMMAND_ID = "commandId";
-
- private static String extension_point_diagram_profile = "org.eclipse.papyrus.diagramprofile.profileDiagram";
-
- private Collection<CreationCommandDescriptor> descriptors = null;
-
- public Collection<CreationCommandDescriptor> getDiagramDescriptors(PackageableElement packageableElement) {
- if (descriptors == null) {
- descriptors = initDescriptors();
- }
- Collection<CreationCommandDescriptor> result = new LinkedList<CreationCommandDescriptor>(descriptors);
- filter(result, packageableElement.getClass());
- filterDependingOnProfile(result, packageableElement);
- return result;
- }
-
- private void filterDependingOnProfile(Collection<CreationCommandDescriptor> result, PackageableElement context) {
- for (Iterator<CreationCommandDescriptor> i = result.iterator(); i.hasNext();) {
- CreationCommandDescriptor crea = i.next();
- if (crea instanceof ProfileCreationCommandDescriptor) {
- ProfileCreationCommandDescriptor proCre = (ProfileCreationCommandDescriptor) crea;
- Package aPackage = null;
- if (context instanceof Package) {
- aPackage = (Package) context;
- } else {
- aPackage = context.getNearestPackage();
- }
- List<Profile> allProfiles = aPackage.getAllAppliedProfiles();
- boolean keep = false;
- for (Profile p : allProfiles) {
- keep |= (p.getName() != null && p.getName().equals(proCre.getToMatch()));
- }
- if (!keep) {
- i.remove();
- }
- }
- }
- }
-
- private void filter(Collection<CreationCommandDescriptor> result, Class<? extends PackageableElement> class1) {
- for (Iterator<CreationCommandDescriptor> i = result.iterator(); i.hasNext();) {
- CreationCommandDescriptor crea = i.next();
- if (crea instanceof ProfileCreationCommandDescriptor) {
- ProfileCreationCommandDescriptor proCre = (ProfileCreationCommandDescriptor) crea;
- if (!proCre.getTheClassApplicable().isAssignableFrom(class1)) {
- i.remove();
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private Collection<CreationCommandDescriptor> initDescriptors() {
- Collection<CreationCommandDescriptor> tmpDescriptors = new LinkedList<CreationCommandDescriptor>();
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- extension_point_diagram_profile);
- for (IConfigurationElement e : elements) {
- try {
- Bundle bundle = Platform.getBundle(e.getContributor().getName());
- Class<? extends EClass> classApplicable = bundle.loadClass(e
- .getAttribute(ATTR_CLASSES_CANDIDATES_FOR_NEW_DIAGRAM));
- String profileURi = e.getAttribute(ATTR_PROFILE_AVAILABLE);
- String diagramName = e.getAttribute(ATTR_DIAGRAM_NAME);
- String icon = e.getAttribute(ATTR_ICON);
- ICreationCommand command = (ICreationCommand) e.createExecutableExtension(ATTR_CREATION_COMMAND);
- String commandId = e.getAttribute(ATTR_COMMAND_ID);
- // IContextChecker checker = (IContextChecker) e
- // .createExecutableExtension(ATTR_PROFILE_AVAILABLE);
- ProfileCreationCommandDescriptor desc = new ProfileCreationCommandDescriptor(classApplicable,
- profileURi, command, commandId);
- if (icon != null && icon.length() > 0) {
- try {
- final Image image = new Image(Display.getDefault(), bundle.getResource(icon).openStream());
- ImageDescriptor imageD = new ImageDescriptor() {
-
- @Override
- public ImageData getImageData() {
- return image.getImageData();
- }
- };
- desc.setImageDescriptor(imageD);
- } catch (IOException e1) {
- }
- }
- desc.setLabel(diagramName);
- tmpDescriptors.add(desc);
- } catch (InvalidRegistryObjectException e1) {
- e1.printStackTrace();
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
- }
- return tmpDescriptors;
- }
-
- private class ProfileCreationCommandDescriptor extends CreationCommandDescriptor {
-
- private Class<? extends EClass> theClassApplicable;
-
- private String toMatch;
-
- private ICreationCommand command;
-
- private String commandIdToCreateDiagram;
-
- public ProfileCreationCommandDescriptor(Class<? extends EClass> classApplicable, String profileToMatch,
- ICreationCommand comm, String commandIdToCreateDiagram) {
- theClassApplicable = classApplicable;
- toMatch = profileToMatch;
- this.command = comm;
- this.commandIdToCreateDiagram = commandIdToCreateDiagram;
- }
-
- @SuppressWarnings("unused")
- public void setTheClassApplicable(Class<? extends EClass> theClassApplicable) {
- this.theClassApplicable = theClassApplicable;
- }
-
- public Class<? extends EClass> getTheClassApplicable() {
- return theClassApplicable;
- }
-
- @SuppressWarnings("unused")
- public void setToMatch(String toMatch) {
- this.toMatch = toMatch;
- }
-
- public String getToMatch() {
- return toMatch;
- }
-
- public void setLabel(String lab) {
- label = lab;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setImageDescriptor(ImageDescriptor imageD) {
- icon = imageD;
- }
-
- @Override
- protected ICreationCommand getCommand() throws BackboneException {
- return command;
- }
-
- @Override
- public String getCommandId() {
- return commandIdToCreateDiagram;
- }
-
- }
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDragDropEditPolicy.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDragDropEditPolicy.java
deleted file mode 100644
index dcd3f42b8b6..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDragDropEditPolicy.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.dnd;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy;
-import org.eclipse.papyrus.diagram.common.helper.ILinkMappingHelper;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
-
-public abstract class ProfileDragDropEditPolicy extends CommonDiagramDragDropEditPolicy {
-
- public ProfileDragDropEditPolicy() {
- super(new ILinkMappingHelper() {
-
- public Collection<?> getTarget(Element link) {
- return Collections.EMPTY_LIST;
- }
-
- public Collection<?> getSource(Element link) {
- return Collections.EMPTY_LIST;
- }
- });
- }
-
- public ProfileDragDropEditPolicy(ILinkMappingHelper helper) {
- super(helper);
- }
-
- @Override
- public int getLinkWithClassVisualID(EObject domainElement) {
- return 0;
- }
-
- public EObject getApplication(EObject domainElement) {
- if (getStereotypeAvailable() != null && domainElement instanceof Element) {
- Element element = (Element) domainElement;
- List<EObject> applications = element.getStereotypeApplications();
- for (EObject e : applications) {
- if (getStereotypeAvailable().equals(e.eClass())) {
- return e;
- }
- }
- }
- return null;
- }
-
- @Override
- public int getNodeVisualID(View containerView, EObject domainElement) {
- if (domainElement instanceof Element) {
- EObject e = getApplication(domainElement);
- if (e != null) {
- return getNodeVisualID();
- }
- }
- return -1;
- }
-
- @Override
- public abstract IElementType getUMLElementType(int elementID);
-
- @Override
- public Command getDropObjectsCommand(DropObjectsRequest dropRequest) {
- // Create a view request from the drop request and then forward getting
- // the command for that.
- CompositeCommand cc = new CompositeCommand("Drop");
- List viewDescriptors = new ArrayList();
- Iterator iter = dropRequest.getObjects().iterator();
- if (dropRequest.getObjects().size() > 0 && dropRequest.getObjects().get(0) instanceof String) {
- return getDropFileCommand(dropRequest);
- }
- Point location = dropRequest.getLocation().getCopy();
- ((GraphicalEditPart) getHost()).getContentPane().translateToRelative(location);
- ((GraphicalEditPart) getHost()).getContentPane().translateFromParent(location);
- location.translate(((GraphicalEditPart) getHost()).getContentPane().getClientArea().getLocation().getNegated());
- while (iter.hasNext()) {
- EObject next = (EObject) iter.next();
- EObject droppedObject = getApplication(next);
- int nodeVISUALID = getNodeVisualID(((IGraphicalEditPart) getHost()).getNotationView(), next);
- // int linkVISUALID = getLinkWithClassVisualID(droppedObject);
- // if (specificDrop.contains(nodeVISUALID) || specificDrop.contains(linkVISUALID)) {
- // return getSpecificDropCommand(dropRequest, (Element) droppedObject, nodeVISUALID,
- // linkVISUALID);
- // }
-
- if (nodeVISUALID != -1) {
- // The element to drop is a node
- // Retrieve it's expected graphical parent
- EObject graphicalParent = ((GraphicalEditPart) getHost()).resolveSemanticElement();
-
- // Restrict the default node creation to the following cases:
- // . Take the containment relationship into consideration
- // . Release the constraint when GraphicalParent is a Package (Canvas for most
- // diagrams)
- if (graphicalParent instanceof Package) {
- cc = getDefaultDropNodeCommand(nodeVISUALID, location, droppedObject);
-
- } else if ((graphicalParent instanceof Element)
- && ((Element) graphicalParent).getOwnedElements().contains(droppedObject)) {
- cc = getDefaultDropNodeCommand(nodeVISUALID, location, droppedObject);
-
- } else {
- return UnexecutableCommand.INSTANCE;
- }
-
- }
- // Collection sources = get.getSource((Element) droppedObject);
- // Collection targets = linkmappingHelper.getTarget((Element) droppedObject);
- // if (sources.size() == 0 || targets.size() == 0) {
- // return UnexecutableCommand.INSTANCE;
- // }
- // binary association
- // Element source = (Element) sources.toArray()[0];
- // Element target = (Element) targets.toArray()[0];
- // cc = dropBinaryLink(cc, source, target, linkVISUALID, dropRequest.getLocation(),
- // (Element) droppedObject);
- }
- return new ICommandProxy(cc);
- }
-
- public abstract int getNodeVisualID();
-
- public abstract EClass getStereotypeAvailable();
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDropTargetListener.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDropTargetListener.java
deleted file mode 100644
index 5a7d18f2321..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/dnd/ProfileDropTargetListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.dnd;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.papyrus.diagram.common.listeners.DropTargetListener;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-
-public class ProfileDropTargetListener extends DropTargetListener {
-
- private final TransactionalEditingDomain domain;
-
- public ProfileDropTargetListener(EditPartViewer viewer, Transfer xfer, TransactionalEditingDomain domain) {
- super(viewer, xfer);
- this.domain = domain;
- }
-
- @Override
- protected Object getJavaObject(TransferData data) {
- return LocalSelectionTransfer.getTransfer().nativeToJava(data);
- }
-
- @Override
- protected TransactionalEditingDomain getTransactionalEditingDomain() {
- return domain;
- }
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParser.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParser.java
deleted file mode 100644
index a3b45239129..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParser.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.parsers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.papyrus.diagramprofile.Activator;
-import org.eclipse.papyrus.resource.ResourceEObject;
-
-public class ResourceEObjectParser implements ISemanticParser {
-
- private static final Pattern patternForBaseElement = Pattern.compile("base_.*");
-
- private final EStructuralFeature eStructuralFeature;
-
- private String oclRule = "";
-
- public ResourceEObjectParser(String oclRule, EStructuralFeature eStructuralFeature) {
- this.oclRule = oclRule;
- this.eStructuralFeature = eStructuralFeature;
- }
-
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
- public String getEditString(IAdaptable element, int flags) {
- return getString(element);
- }
-
- public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
- ICommand result = null;
- if (element instanceof EObjectAdapter) {
- EObjectAdapter adapter = (EObjectAdapter) element;
- if (adapter.getRealObject() instanceof EObject) {
- Object runOcl = getEobjectFromOCLRUle(element);
- if (runOcl instanceof EObject) {
- EObject eobject = (EObject) runOcl;
- result = new SetValueCommand(new SetRequest(eobject, eStructuralFeature, newString));
- }
- }
- }
- return result;
- }
-
- public String getPrintString(IAdaptable element, int flags) {
- return getString(element);
- }
-
- private Object getEobjectFromOCLRUle(IAdaptable element) {
- Object result = null;
- if (element instanceof EObjectAdapter) {
- EObjectAdapter adapter = (EObjectAdapter) element;
- if (adapter.getRealObject() instanceof ResourceEObject) {
- ResourceEObject rEobject = (ResourceEObject) adapter.getRealObject();
- result = org.eclipse.papyrus.diagramprofile.utils.OCLUtils.runOclRule(oclRule, rEobject);
- }
- }
- return result;
- }
-
- private String getString(IAdaptable element) {
- Object result = getEobjectFromOCLRUle(element);
- if (result != null && result instanceof EObject) {
- Object object = ((EObject) result).eGet(eStructuralFeature);
- return object == null ? "" : object.toString();
- }
- return "";
- }
-
- private EObject getBaseElement(ResourceEObject rEobject) {
- for (EStructuralFeature f : rEobject.eClass().getEAllStructuralFeatures()) {
- if (patternForBaseElement.matcher(f.getName()).matches()) {
- Object result = rEobject.eGet(f);
- if (result != null && result instanceof EObject) {
- return (EObject) result;
- }
- }
- }
- return null;
- }
-
- public boolean isAffectingEvent(Object event, int flags) {
- return getEStructuralFeature(event).equals(eStructuralFeature);
- }
-
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
- if (element instanceof EObjectAdapter) {
- EObjectAdapter eobjectAdapter = (EObjectAdapter) element;
- if (eobjectAdapter.getRealObject() instanceof ResourceEObject) {
- return new ParserEditStatus(Status.OK, Activator.PLUGIN_ID, ParserEditStatus.EDITABLE, "ok", null);
- }
- }
- return new ParserEditStatus(Status.ERROR, Activator.PLUGIN_ID, ParserEditStatus.EDITABLE, "error", null);
- }
-
- /**
- * Get the EStructuralFeature of the given notification
- *
- * @param notification
- * the notification
- * @return the EStructuralFeature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- return true;
- }
-
- public List getSemanticElementsBeingParsed(EObject element) {
- List result = new ArrayList();
- result.add(element);
- result.add(org.eclipse.papyrus.diagramprofile.utils.OCLUtils.runOclRule(oclRule, element));
- return result;
- }
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParserProvider.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParserProvider.java
deleted file mode 100644
index e655fed420a..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/parsers/ResourceEObjectParserProvider.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.parsers;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.papyrus.resource.ResourcePackage;
-
-public abstract class ResourceEObjectParserProvider extends AbstractProvider implements IParserProvider {
-
- //private IProviderChangeListener myListener;
-
- private ResourceEObjectParser resourceEObjectParser;
-
- /**
- * returns the label from the current eobject to access base element please do self.base_...
- *
- * @return
- */
- public abstract String getOclRule();
-
- /**
- * @return the target type to determine if the operation can be performed
- */
- public abstract String getTargetType();
-
- /**
- * @return the structural feature to display and edit
- */
- public abstract EStructuralFeature getEStructuralFeatureFromOCLResult();
-
- /**
- * @see org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider#getParser(org.eclipse.core.runtime.IAdaptable)
- */
- public IParser getParser(IAdaptable hint) {
- resourceEObjectParser = new ResourceEObjectParser(getOclRule(), getEStructuralFeatureFromOCLResult());
- return resourceEObjectParser;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)
- */
- public boolean provides(IOperation operation) {
- if (operation instanceof GetParserOperation) {
- GetParserOperation pOperation = (GetParserOperation) operation;
- IElementType type = (IElementType) pOperation.getHint().getAdapter(IElementType.class);
- return getTargetType() != null
- && getTargetType().equals((String) pOperation.getHint().getAdapter(String.class))
- && ResourcePackage.Literals.RESOURCE_EOBJECT.isSuperTypeOf(type.getEClass());
- }
- return false;
- }
-
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/OCLUtils.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/OCLUtils.java
deleted file mode 100644
index faa3c08a364..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/OCLUtils.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * 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:
- * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.utils;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.ocl.ParserException;
-import org.eclipse.ocl.ecore.CallOperationAction;
-import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
-import org.eclipse.ocl.ecore.OCL;
-import org.eclipse.ocl.ecore.OCLExpression;
-import org.eclipse.ocl.ecore.SendSignalAction;
-import org.eclipse.ocl.helper.OCLHelper;
-
-public class OCLUtils {
-
- /**
- * variables for ocl
- */
- private static org.eclipse.ocl.OCL<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, org.eclipse.ocl.ecore.Constraint, EClass, EObject> ocl = OCL
- .newInstance(new EcoreEnvironmentFactory());
-
- private static OCLHelper<EClassifier, ?, ?, ?> oclHelper = ocl.createOCLHelper();
-
- /**
- * The Ocl rule is evaluated to the eobject argument this methods returns an object and the type
- * depends of the input rule
- *
- * @param oclRule
- * the ocl rule
- * @param object
- * the object
- *
- * @return the object, result of the query
- */
- public static Object runOclRule(String oclRule, EObject object) {
- if (object != null) {
- oclHelper.setContext(object.eClass());
- }
- OCLExpression exp;
- try {
- exp = (OCLExpression) oclHelper.createQuery(oclRule);
- Object result = ocl.evaluate(object, exp);
- return result;
- } catch (ParserException e) {
- e.printStackTrace();
- }
- return null;
- }
-}
diff --git a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java b/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java
deleted file mode 100644
index 4f0b81b7fcf..00000000000
--- a/deprecated/deprecated-plugins/sysml.deprecated/org.eclipse.papyrus.diagramprofile/src/org/eclipse/papyrus/diagramprofile/utils/StereotypeUtils.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 ATOS ORIGIN.
- *
- *
- * 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:
- * Tristan FAURE (ATOS ORIGIN) tristan.faure@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.diagramprofile.utils;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class StereotypeUtils.
- */
-public class StereotypeUtils {
-
- /** extension point ID to load profile */
- public static final String extensionPointIdForProfile = "org.eclipse.uml2.uml.generated_package";
-
- /** URI for profile */
- public static final String uriExtensionPointIdForProfile = "uri";
-
- /** location for profile */
- public static final String locationExtensionPointIdForProfile = "location";
-
- /** URI for SysML profile */
- public static final String SYSML_URI = "http://www.eclipse.org/papyrus/0.7.0/SysML";
-
- /**
- * Get the base Element from a stereotype application.
- *
- * @param e
- * , the stereotype application
- *
- * @return the base element
- */
- public static EObject getBaseElement(EObject e) {
- if (e != null) {
- for (EStructuralFeature f : e.eClass().getEAllStructuralFeatures()) {
- if (f.getName().startsWith("base_")) {
- Object b = e.eGet(f);
- if (b instanceof EObject && b != null) {
- return (EObject) b;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Checks if is profile applied.
- *
- * @param qualifiedName
- * the qualified name of the profile
- * @param e
- * the element
- *
- * @return true, if the profile is applied
- */
- public static boolean isProfileApplied(String qualifiedName, Element e) {
- if (qualifiedName == null || e == null || qualifiedName.length() == 0) {
- return false;
- }
- Package p = e.getNearestPackage();
- for (Profile pr : p.getAllAppliedProfiles()) {
- if (qualifiedName.equals(pr.getQualifiedName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the is stereotype applied.
- *
- * @param qualifiedName
- * the qualified name of the stereotype
- * @param e
- * the element to check
- *
- * @return true, if the stereotype is applied
- */
- public static boolean isStereotypeApplied(String qualifiedName, Element e) {
- if (qualifiedName == null || e == null || qualifiedName.length() == 0) {
- return false;
- }
- Stereotype s = e.getAppliedStereotype(qualifiedName);
- return s != null;
- }
-
- /**
- * Load a profile from an URI
- *
- * @return the profile
- */
- public static Profile loadProfile(String uri, ResourceSet set) {
- String locationURI = "";
- Profile profile = null;
- IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(
- extensionPointIdForProfile);
- for (IConfigurationElement e : extensions) {
- String extensionURI = e.getAttribute(uriExtensionPointIdForProfile);
- if (extensionURI.equals(uri)) {
- locationURI = e.getAttribute(locationExtensionPointIdForProfile);
- URI profileURI = URI.createURI(locationURI);
- if (set != null) {
- Resource resource = set.getResource(profileURI, true);
- for (EObject obj : resource.getContents()) {
- if (obj instanceof Profile) {
- profile = (Profile) obj;
- return profile;
- }
- }
- }
- }
- }
- return profile;
- }
-
- /**
- * Apply a profile on a package, from an URI
- */
- public static void applyProfile(String uri, Package element) {
- Profile profile = loadProfile(uri, element.eResource().getResourceSet());
- if (profile != null) {
- element.applyProfile(profile);
- }
- }
-
- /**
- * Apply the SysML profile on the specified element
- */
- public static void applySysMLProfile(Package element) {
- Profile profile = loadProfile(SYSML_URI, element.eResource().getResourceSet());
- if (profile != null) {
- element.applyProfile(profile);
- // Apply sub profiles of SysML
- for(Element e : profile.getOwnedElements()){
- if(e instanceof Profile){
- element.applyProfile((Profile)e);
- }
- }
- }
- }
-
- /**
- * Apply stereotype to element.
- *
- * @param element the element
- * @param stereotypeName the stereotype qualified name
- */
- public static void applyStereotypeToElement(Element element, String stereotypeName) {
- for (Stereotype stereotype : element.getApplicableStereotypes()) {
- if (stereotype.getQualifiedName().equals(stereotypeName)) {
- element.applyStereotype(stereotype);
- }
- }
- }
-
-}

Back to the top