Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-11-02 10:26:54 +0000
committervlorenzo2011-11-02 10:26:54 +0000
commitfdc516e66ff24418748f79234ebcf2038022cc27 (patch)
treef6f2af6b0abd3bef54daf18f1e511766517c9c13 /plugins/uml/org.eclipse.papyrus.uml.documentation
parent6d65a984bafbd766c4d61f2f06919e3171970f11 (diff)
downloadorg.eclipse.papyrus-fdc516e66ff24418748f79234ebcf2038022cc27.tar.gz
org.eclipse.papyrus-fdc516e66ff24418748f79234ebcf2038022cc27.tar.xz
org.eclipse.papyrus-fdc516e66ff24418748f79234ebcf2038022cc27.zip
362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.documentation')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/.classpath7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/.project28
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/META-INF/MANIFEST.MF15
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/about.html28
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/build.properties7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.properties12
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.xml23
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Activator.java45
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Messages.java32
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLAddOrRemoveAssociatedResourceCommand.java121
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLChangeDocumentationCommand.java192
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLDocumentationManager.java152
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/messages.properties2
13 files changed, 664 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/.classpath b/plugins/uml/org.eclipse.papyrus.uml.documentation/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/.classpath
@@ -0,0 +1,7 @@
+<?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/plugins/uml/org.eclipse.papyrus.uml.documentation/.project b/plugins/uml/org.eclipse.papyrus.uml.documentation/.project
new file mode 100644
index 00000000000..be3524e471e
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.documentation.uml</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/plugins/uml/org.eclipse.papyrus.uml.documentation/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.documentation/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..effb73b29a8
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.papyrus.documentation;bundle-version="0.9.0",
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.uml.profile;bundle-version:="0.9.0"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.documentation.uml.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.documentation.uml;singleton:=
+ true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/about.html b/plugins/uml/org.eclipse.papyrus.uml.documentation/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/about.html
@@ -0,0 +1,28 @@
+<!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>June 5, 2007</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>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/build.properties b/plugins/uml/org.eclipse.papyrus.uml.documentation/build.properties
new file mode 100644
index 00000000000..04a7f082f9f
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:29:51 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,about.html,plugin.properties
+output..=bin/
+src.includes=META-INF/,.,plugin.xml,about.html,plugin.properties
+source..=src/
+bin..=bin/
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.properties b/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.properties
new file mode 100644
index 00000000000..1221470b2bd
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2010 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:
+# Atos Origin - Initial API and Implementation
+##################################################################################
+pluginName=UML implementation of Papyrus Documentation (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.xml
new file mode 100644
index 00000000000..c4c1a6c2967
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.documentation.documentationManager">
+ <documentationManager
+ managerClass="org.eclipse.papyrus.documentation.uml.UMLDocumentationManager"
+ modelNsURI="http://www.eclipse.org/uml2/3.0.0/UML"
+ priority="Lowest">
+ </documentationManager>
+ <documentationManager
+ managerClass="org.eclipse.papyrus.documentation.uml.UMLDocumentationManager"
+ modelNsURI="http://www.eclipse.org/uml2/2.1.0/UML"
+ priority="Lowest">
+ </documentationManager>
+ <documentationManager
+ managerClass="org.eclipse.papyrus.documentation.uml.UMLDocumentationManager"
+ modelNsURI="http://www.eclipse.org/uml2/2.0.0/UML"
+ priority="Lowest">
+ </documentationManager>
+ </extension>
+
+</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Activator.java b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Activator.java
new file mode 100644
index 00000000000..331930f76b7
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Activator.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.documentation.uml;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Messages.java b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Messages.java
new file mode 100644
index 00000000000..ef39a9d4575
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/Messages.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.documentation.uml;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.documentation.uml.messages"; //$NON-NLS-1$
+
+ public static String UMLDocumentationManager_DocOnDocCommentError;
+
+ public static String UMLDocumentationManager_NonUMLElementError;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLAddOrRemoveAssociatedResourceCommand.java b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLAddOrRemoveAssociatedResourceCommand.java
new file mode 100644
index 00000000000..417a0bfcabf
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLAddOrRemoveAssociatedResourceCommand.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.documentation.uml;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.documentation.IDocumentationChangedListener;
+import org.eclipse.papyrus.uml.profile.IUMLDocumentationConstants;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+@SuppressWarnings("unchecked")
+public class UMLAddOrRemoveAssociatedResourceCommand extends AbstractCommand {
+
+ private Element element;
+
+ private Comment documentationComment = null;
+
+ private Stereotype documentationStereotype = null;
+
+ private Set<IDocumentationChangedListener> documentationChangedListeners;
+
+ private boolean remove;
+
+ private String resourceURIString;
+
+ public UMLAddOrRemoveAssociatedResourceCommand(boolean remove, Element element, URI resourceURI, Set<IDocumentationChangedListener> documentationChangedListeners) {
+ super(org.eclipse.papyrus.documentation.Messages.AddOrRemoveAssociatedResourceCommandLabel);
+ this.remove = remove;
+ this.element = element;
+ this.resourceURIString = resourceURI.toString();
+ this.documentationChangedListeners = documentationChangedListeners;
+ }
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+
+ @Override
+ public boolean canUndo() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute() {
+ EList<Comment> ownedComments = element.getOwnedComments();
+
+ for(Comment comment : ownedComments) {
+ documentationStereotype = comment.getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME);
+ if(documentationStereotype != null) {
+ documentationComment = comment;
+ break;
+ }
+ }
+
+ redo();
+ }
+
+ private void notifyListeners() {
+ for(IDocumentationChangedListener listener : documentationChangedListeners) {
+ listener.documentationChanged(element);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void redo() {
+ if (remove) {
+ removeAssociatedResource();
+ } else {
+ addAssociatedResource();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void undo() {
+ if (remove) {
+ addAssociatedResource();
+ } else {
+ removeAssociatedResource();
+ }
+ }
+
+ private void removeAssociatedResource() {
+ if(documentationStereotype != null && documentationComment != null) {
+ List<String> resourceURIs = (List<String>)documentationComment.getValue(documentationStereotype, IUMLDocumentationConstants.RESOURCE_PROPERTY_NAME);
+ resourceURIs.remove(resourceURIString);
+ notifyListeners();
+ }
+ }
+
+ private void addAssociatedResource() {
+ if(documentationStereotype != null && documentationComment != null) {
+ List<String> resourceURIs = (List<String>)documentationComment.getValue(documentationStereotype, IUMLDocumentationConstants.RESOURCE_PROPERTY_NAME);
+ resourceURIs.add(resourceURIString);
+ notifyListeners();
+ }
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLChangeDocumentationCommand.java b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLChangeDocumentationCommand.java
new file mode 100644
index 00000000000..42e87031c92
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLChangeDocumentationCommand.java
@@ -0,0 +1,192 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.documentation.uml;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.documentation.IDocumentationChangedListener;
+import org.eclipse.papyrus.uml.profile.IUMLDocumentationConstants;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * A GEF Command use to update documentation using profiled Comment.
+ *
+ */
+public class UMLChangeDocumentationCommand extends AbstractCommand {
+
+ private Element element;
+
+ private String newComment;
+
+ private String oldComment;
+
+ private Comment documentationComment = null;
+
+ private Stereotype documentationStereotype = null;
+
+ private boolean profileWasAlreadyApplied = false;
+
+ private Set<IDocumentationChangedListener> documentationChangedListeners;
+
+ public UMLChangeDocumentationCommand(Element element, String newDocumentation, Set<IDocumentationChangedListener> documentationChangedListeners) {
+ super(org.eclipse.papyrus.documentation.Messages.ChangeDocCommandLabel);
+ this.element = element;
+ this.newComment = newDocumentation;
+ this.documentationChangedListeners = documentationChangedListeners;
+ }
+
+ @Override
+ public boolean canExecute() {
+ return true;
+ }
+
+ @Override
+ public boolean canUndo() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void execute() {
+
+ profileWasAlreadyApplied = element.getNearestPackage().getAppliedProfile(IUMLDocumentationConstants.PROFILE_NAME, true) != null;
+
+ // stores the previous doc
+ oldComment = null;
+
+ EList<Comment> ownedComments = element.getOwnedComments();
+
+ for(Comment comment : ownedComments) {
+ documentationStereotype = comment.getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME);
+ if(documentationStereotype != null) {
+ documentationComment = comment;
+ break;
+ }
+ }
+
+ if(documentationComment != null) {
+ oldComment = documentationComment.getBody();
+ }
+
+ redo();
+ }
+
+ private void notifyListeners() {
+ for(IDocumentationChangedListener listener : documentationChangedListeners) {
+ listener.documentationChanged(element);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void redo() {
+ changeDocumentation(newComment);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void undo() {
+ changeDocumentation(oldComment);
+ }
+
+ private IStatus changeDocumentation(String newDoc) {
+ if(newDoc != null) {
+ if(documentationComment == null) {
+ documentationComment = UMLFactory.eINSTANCE.createComment();
+ element.getOwnedComments().add(documentationComment);
+ applyDocumentationStereotype(documentationComment);
+ }
+
+ documentationComment.setBody(newDoc);
+ } else {
+ removeDocumentation();
+ }
+ notifyListeners();
+ return Status.OK_STATUS;
+ }
+
+ private void removeDocumentation() {
+ if(documentationComment != null) {
+ Stereotype documentationStereotype = documentationComment.getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME);
+ if(documentationStereotype != null) {
+ documentationComment.unapplyStereotype(documentationStereotype);
+ }
+ element.getOwnedComments().remove(documentationComment);
+ documentationComment = null;
+ }
+
+ // remove profile application if not applied before
+ if(!profileWasAlreadyApplied) {
+ Profile documentationProfile = element.getNearestPackage().getAppliedProfile(IUMLDocumentationConstants.PROFILE_NAME, true);
+ if(documentationProfile != null) {
+ element.getNearestPackage().unapplyProfile(documentationProfile);
+ }
+ }
+ }
+
+ public void applyDocumentationStereotype(Comment comment) {
+
+ Profile documentationProfile = element.getNearestPackage().getAppliedProfile(IUMLDocumentationConstants.PROFILE_NAME, true);
+
+ if(documentationProfile == null) {
+ ResourceSet rs = null;
+ Resource resource = element.eResource();
+ if(resource != null) {
+ rs = resource.getResourceSet();
+ }
+ if (rs == null) {
+ rs = new ResourceSetImpl();
+ }
+
+ Resource papyrusProfileResource = rs.getResource(URI.createURI(IUMLDocumentationConstants.PROFILE_URI), true);
+
+ if(papyrusProfileResource != null && !papyrusProfileResource.getContents().isEmpty() && papyrusProfileResource.getContents().get(0) instanceof Profile) {
+ Profile papyrusProfile = (Profile)papyrusProfileResource.getContents().get(0);
+
+ NamedElement possibleDocumentationProfile = papyrusProfile.getMember(IUMLDocumentationConstants.DOCUMENTATION_SUB_PROFILE_NAME);
+
+ if (possibleDocumentationProfile instanceof Profile) {
+ documentationProfile = (Profile)possibleDocumentationProfile;
+ element.getNearestPackage().applyProfile(documentationProfile);
+ }
+ }
+
+ }
+
+ if (documentationProfile != null) {
+ Stereotype documentationStereotype = documentationProfile.getOwnedStereotype(IUMLDocumentationConstants.STEREOTYPE_NAME);
+
+ if(documentationStereotype != null) {
+ comment.applyStereotype(documentationStereotype);
+ }
+ }
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLDocumentationManager.java b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLDocumentationManager.java
new file mode 100644
index 00000000000..106b5573451
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/UMLDocumentationManager.java
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.documentation.uml;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.documentation.DocumentationUnsupportedException;
+import org.eclipse.papyrus.documentation.IDocumentationChangedListener;
+import org.eclipse.papyrus.documentation.IDocumentationManager;
+import org.eclipse.papyrus.uml.profile.IUMLDocumentationConstants;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+public class UMLDocumentationManager implements IDocumentationManager {
+
+ private static class UMLDocumentationManagerHolder {
+
+ public static final UMLDocumentationManager instance = new UMLDocumentationManager();
+ }
+
+ public static UMLDocumentationManager getInstance() {
+ return UMLDocumentationManagerHolder.instance;
+ }
+
+ private static Set<IDocumentationChangedListener> documentationChangedListeners = new HashSet<IDocumentationChangedListener>();
+
+ /**
+ * {@inheritDoc}
+ */
+ public Command getChangeDocumentationCommand(EObject eObject, String newDocumentation) {
+ if (getUnsupportedErrorMessage(eObject) == null) {
+ return new UMLChangeDocumentationCommand((Element)eObject, newDocumentation, documentationChangedListeners);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDocumentation(EObject eObject) throws DocumentationUnsupportedException {
+ String errorMsg = getUnsupportedErrorMessage(eObject);
+ if (errorMsg == null) {
+ EList<Comment> ownedComments = ((Element)eObject).getOwnedComments();
+
+ for(Comment comment : ownedComments) {
+ if(comment.getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME) != null) {
+ return comment.getBody();
+ }
+ }
+ return null;
+ } else {
+ throw new DocumentationUnsupportedException(errorMsg);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<URI> getAssociatedResources(EObject eObject) throws DocumentationUnsupportedException {
+ String errorMsg = getUnsupportedErrorMessage(eObject);
+ if (errorMsg == null) {
+ List<URI> URIs = new LinkedList<URI>();
+ EList<Comment> ownedComments = ((Element)eObject).getOwnedComments();
+
+ for(Comment comment : ownedComments) {
+ Stereotype docStereotype = comment.getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME);
+ if(docStereotype != null) {
+ List<String> stringURIs = (List<String>)comment.getValue(docStereotype, IUMLDocumentationConstants.RESOURCE_PROPERTY_NAME);
+ for (String stringURI : stringURIs) {
+ URIs.add(URI.createURI(stringURI));
+ }
+ }
+ }
+ return URIs;
+ } else {
+ throw new DocumentationUnsupportedException(errorMsg);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerDocumentationChangedListener(IDocumentationChangedListener listener) {
+ documentationChangedListeners.add(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unregisterDocumentationChangedListener(IDocumentationChangedListener listener) {
+ documentationChangedListeners.remove(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<IDocumentationChangedListener> getRegisteredDocumentationChangedListeners() {
+ return documentationChangedListeners;
+ }
+
+ /**
+ * get an error message if eObject is unsupported by this implementation
+ * @param eObject
+ * @return null if documentation is supported or an error message if not
+ */
+ private static String getUnsupportedErrorMessage(EObject eObject) {
+ // can't have a documentation on a documentation comment
+ if(eObject instanceof Comment && ((Comment)eObject).getAppliedStereotype(IUMLDocumentationConstants.STEREOTYPE_QUALIFIED_NAME) != null) {
+ return Messages.UMLDocumentationManager_DocOnDocCommentError;
+ } else if(eObject instanceof Element) {
+ // OK, return null
+ return null;
+ } else {
+ return Messages.UMLDocumentationManager_NonUMLElementError;
+ }
+ }
+
+ public Command getAddAssociatedResourceCommand(EObject eObject, URI resourceURI) {
+ if (getUnsupportedErrorMessage(eObject) == null) {
+ return new UMLAddOrRemoveAssociatedResourceCommand(false, (Element)eObject, resourceURI, documentationChangedListeners);
+ } else {
+ return null;
+ }
+ }
+
+ public Command getRemoveAssociatedResourceCommand(EObject eObject, URI resourceURI) {
+ if (getUnsupportedErrorMessage(eObject) == null) {
+ return new UMLAddOrRemoveAssociatedResourceCommand(true, (Element)eObject, resourceURI, documentationChangedListeners);
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/messages.properties b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/messages.properties
new file mode 100644
index 00000000000..09c53a6992e
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.documentation/src/org/eclipse/papyrus/documentation/uml/messages.properties
@@ -0,0 +1,2 @@
+UMLDocumentationManager_DocOnDocCommentError=Documentation on documentation comment unsupported
+UMLDocumentationManager_NonUMLElementError=Documentation on non UML element unsupported by this implementation

Back to the top