Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfaure2011-05-24 13:35:09 +0000
committertfaure2011-05-24 13:35:09 +0000
commit374a41064dc54c333e525ba24ab3cb316bd87b92 (patch)
treea71823a067263554c65c0a0b129b8af0f35d2981 /incoming
parent774facb7a842ef3dbb81bc9651d41b85e0fedbf3 (diff)
downloadorg.eclipse.papyrus-374a41064dc54c333e525ba24ab3cb316bd87b92.tar.gz
org.eclipse.papyrus-374a41064dc54c333e525ba24ab3cb316bd87b92.tar.xz
org.eclipse.papyrus-374a41064dc54c333e525ba24ab3cb316bd87b92.zip
NEW - bug 346708: Feature for logical view in Project Explorer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=346708 Implement the FR, by default filter Di view is enabled and trigger the content provider.
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.onefile/.classpath7
-rw-r--r--incoming/org.eclipse.papyrus.onefile/.project28
-rw-r--r--incoming/org.eclipse.papyrus.onefile/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--incoming/org.eclipse.papyrus.onefile/META-INF/MANIFEST.MF20
-rw-r--r--incoming/org.eclipse.papyrus.onefile/build.properties5
-rw-r--r--incoming/org.eclipse.papyrus.onefile/icons/papyrus.pngbin0 -> 602 bytes
-rw-r--r--incoming/org.eclipse.papyrus.onefile/plugin.xml211
-rw-r--r--incoming/org.eclipse.papyrus.onefile/schema/modelFactory.exsd111
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/Activator.java67
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java55
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java34
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java55
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java50
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java29
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java111
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java48
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java78
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java77
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java52
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java98
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java35
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java69
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java84
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java71
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java70
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java153
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java67
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java286
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java54
-rw-r--r--incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/utils/Utils.java335
30 files changed, 2368 insertions, 0 deletions
diff --git a/incoming/org.eclipse.papyrus.onefile/.classpath b/incoming/org.eclipse.papyrus.onefile/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/.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/incoming/org.eclipse.papyrus.onefile/.project b/incoming/org.eclipse.papyrus.onefile/.project
new file mode 100644
index 00000000000..cbc0ec4ed8e
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.onefile</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/incoming/org.eclipse.papyrus.onefile/.settings/org.eclipse.jdt.core.prefs b/incoming/org.eclipse.papyrus.onefile/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..12ae8eaacf9
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Apr 06 17:02:48 CEST 2011
+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/incoming/org.eclipse.papyrus.onefile/META-INF/MANIFEST.MF b/incoming/org.eclipse.papyrus.onefile/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..c5af33086e1
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Onefile
+Bundle-SymbolicName: org.eclipse.papyrus.onefile;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.onefile.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.core,
+ org.eclipse.papyrus.core.resourceloading;bundle-version="0.8.0",
+ org.eclipse.core.filesystem,
+ org.eclipse.ui.navigator,
+ org.eclipse.core.expressions,
+ org.eclipse.team.ui,
+ org.eclipse.team.core,
+ org.eclipse.ltk.core.refactoring,
+ org.eclipse.papyrus.navigator;bundle-version="0.8.0",
+ org.eclipse.ui.navigator.resources;bundle-version="3.4.300"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/incoming/org.eclipse.papyrus.onefile/build.properties b/incoming/org.eclipse.papyrus.onefile/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/incoming/org.eclipse.papyrus.onefile/icons/papyrus.png b/incoming/org.eclipse.papyrus.onefile/icons/papyrus.png
new file mode 100644
index 00000000000..0f74e27b483
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/icons/papyrus.png
Binary files differ
diff --git a/incoming/org.eclipse.papyrus.onefile/plugin.xml b/incoming/org.eclipse.papyrus.onefile/plugin.xml
new file mode 100644
index 00000000000..109da15a147
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/plugin.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="modelFactory" name="Model Factory" schema="schema/modelFactory.exsd"/>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.papyrus.onefile.model.IPapyrusFile"
+ class="org.eclipse.papyrus.onefile.model.adapters.ModelAdapterFactory">
+ <adapter type="org.eclipse.core.resources.mapping.ResourceMapping" />
+ <adapter type="org.eclipse.core.resources.IFile" />
+ <adapter type="org.eclipse.core.resources.IResource" />
+ </factory>
+ <factory
+ adaptableType="org.eclipse.papyrus.onefile.model.ISubResourceFile"
+ class="org.eclipse.papyrus.onefile.model.adapters.SubResourceAdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ <adapter
+ type="org.eclipse.core.resources.IFile">
+ </adapter>
+ <adapter
+ type="org.eclipse.core.resources.IResource">
+ </adapter>
+ </factory>
+ </extension>
+ <extension
+ id="modelProvider"
+ name="One File Model Provider"
+ point="org.eclipse.core.resources.modelProviders">
+ <modelProvider
+ class="org.eclipse.papyrus.onefile.providers.OneFileModelProvider"/>
+ <extends-model id="org.eclipse.core.resources.modelProvider"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <commonFilter
+ activeByDefault="true"
+ class="org.eclipse.papyrus.onefile.matcher.OnlyDiFilter"
+ description="All the files related to di files are agregated bellow a common parent"
+ id="org.eclipse.papyrus.onefile.onlyDiFilter"
+ name="Di view"
+ visibleInUI="true">
+ </commonFilter>
+ <navigatorContent
+ activeByDefault="true"
+ contentProvider="org.eclipse.papyrus.onefile.providers.PapyrusContentProvider"
+ id="org.eclipse.papyrus.onefile.DiContent"
+ labelProvider="org.eclipse.papyrus.onefile.providers.PapyrusLabelProvider"
+ name="Papyrus Content"
+ priority="high">
+ <enablement>
+ <or>
+ <instanceof
+ value="org.eclipse.papyrus.onefile.model.IPapyrusFile">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.papyrus.onefile.providers.OneFileModelProvider">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IResource">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.internal.resources.mapping.ResourceModelProvider">
+ </instanceof>
+ </or>
+ </enablement>
+ <actionProvider
+ class="org.eclipse.papyrus.onefile.providers.PapyrusModelActionProvider"
+ id="org.eclipse.papyrus.onefile.DiContent.OpenActions"
+ overrides="org.eclipse.ui.navigator.resources.OpenActions">
+ </actionProvider>
+ <dropAssistant
+ class="org.eclipse.papyrus.onefile.model.adapters.PapyrusCommonDropAdapterAssistant"
+ id="org.eclipse.papyrus.onefile.PapyrusDropAssistantt">
+ <possibleDropTargets>
+ <instanceof
+ value="org.eclipse.core.resources.IContainer">
+ </instanceof></possibleDropTargets>
+ </dropAssistant>
+ <commonSorter
+ class="org.eclipse.papyrus.onefile.providers.PapyrusViewerSorter"
+ id="org.eclipse.papyrus.onefile.sorter">
+ </commonSorter>
+ </navigatorContent>
+ </extension>
+ <extension point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding viewerId="org.eclipse.team.ui.navigatorViewer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent"/>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.jdt.ui.PackageExplorer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.onlyDiFilter">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.oneFileLinkHelper">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.onlyDiFilter">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.oneFileLinkHelper">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.team.ui.navigatorViewer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.onlyDiFilter">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.team.svn.ui.workspaceSynchronization">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.onlyDiFilter">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.team.cvs.ui.workspaceSynchronization">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.onlyDiFilter">
+ </contentExtension>
+ <contentExtension
+ pattern="org.eclipse.papyrus.onefile.DiContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ <viewerContentBinding
+ viewerId="org.eclipse.papyrus.onefile.DiContent">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.jdt.java.ui.javaContent">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.navigator.linkHelper">
+ <linkHelper
+ class="org.eclipse.papyrus.onefile.model.adapters.PapyrusLinkHelper"
+ id="org.eclipse.papyrus.onefile.oneFileLinkHelper">
+ <editorInputEnablement>
+ <and>
+ <instanceof
+ value="org.eclipse.ui.IFileEditorInput">
+ </instanceof>
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <test
+ property="org.eclipse.core.resources.extension"
+ value="di">
+ </test>
+ </adapt>
+ </and>
+ </editorInputEnablement>
+ <selectionEnablement>
+ <or>
+ <instanceof
+ value="org.eclipse.papyrus.onefile.model.IPapyrusFile">
+ </instanceof>
+ <and>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.core.resources.extension"
+ value="di">
+ </test>
+ </and>
+ </or>
+ </selectionEnablement>
+ </linkHelper>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.onefile.modelFactory">
+ <factory
+ instance="org.eclipse.papyrus.onefile.model.impl.PapyrusModelFactory"
+ priority="1">
+ </factory>
+ </extension>
+</plugin>
diff --git a/incoming/org.eclipse.papyrus.onefile/schema/modelFactory.exsd b/incoming/org.eclipse.papyrus.onefile/schema/modelFactory.exsd
new file mode 100644
index 00000000000..1c6e4e0eccb
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/schema/modelFactory.exsd
@@ -0,0 +1,111 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.onefile" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.onefile" id="modelFactory" name="Model Factory"/>
+ </appinfo>
+ <documentation>
+ This extension point allows developer to change implementation of logical navigator model.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="factory" minOccurs="1" maxOccurs="unbounded"/>
+ </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="factory">
+ <complexType>
+ <attribute name="instance" type="string" use="required">
+ <annotation>
+ <documentation>
+ the instance of the factory
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.onefile.model.IPapyrusModelFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="required">
+ <annotation>
+ <documentation>
+ the content provider will use the factory with highest priority. Set a high priority and your factory will be used.
+
+The standard factory has a priority set to 1.
+ </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/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/Activator.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/Activator.java
new file mode 100644
index 00000000000..ecdacc05fbd
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/Activator.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile;
+
+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.onefile"; //$NON-NLS-1$
+
+ // 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/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java
new file mode 100644
index 00000000000..f8d22c08360
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.matcher;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.onefile.utils.Utils;
+
+/**
+ * Filter hiding di files and associated. the filter enables the content
+ * provider
+ *
+ * @author tfaure
+ *
+ */
+public class OnlyDiFilter extends ViewerFilter {
+
+ public static final String FILTER_ID = "org.eclipse.papyrus.onefile.onlyDiFilter";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers
+ * .Viewer, java.lang.Object, java.lang.Object)
+ *
+ * @Override
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return Utils.isVisible(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ViewerFilter#isFilterProperty(java.lang.Object,
+ * java.lang.String)
+ *
+ * @Override
+ */
+ public boolean isFilterProperty(Object element, String property) {
+ return true;
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java
new file mode 100644
index 00000000000..66534e04029
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java
@@ -0,0 +1,34 @@
+package org.eclipse.papyrus.onefile.model;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Basic operations for Papyrus Model Elements
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public interface IPapyrusElement {
+ /**
+ * Return the text displayed for the {@link IPapyrusFile}
+ *
+ * @return
+ */
+ String getText();
+
+ /**
+ * Return the image displayed for the {@link IPapyrusFile}
+ *
+ * @return
+ */
+ Image getImage();
+
+ /**
+ * Return the project containing the {@link IPapyrusFile}
+ *
+ * @return an {@link IProject}
+ */
+ IProject getProject();
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java
new file mode 100644
index 00000000000..fc14c12561a
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Contract for Papyrus Files representation
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public interface IPapyrusFile extends IPapyrusElement {
+
+ /**
+ * Return the resources associated to the DI, the di must be included in the
+ * resutl
+ *
+ * @return
+ */
+ IResource[] getAssociatedResources();
+
+ /**
+ * Return the main file (normally the di)
+ *
+ * @return
+ */
+ IFile getMainFile();
+
+ /**
+ * Return the parent of the current {@link IPapyrusFile}
+ *
+ * @return an IContainer
+ */
+ IContainer getParent();
+
+ /**
+ * Return the text displayed for the {@link IPapyrusFile}
+ *
+ * @return
+ */
+ String getName();
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java
new file mode 100644
index 00000000000..f1b1dd7e27d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Factory able to create instances of model interfaces
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public interface IPapyrusModelFactory {
+
+ /**
+ * Create an instance of {@link IPapyrusFile} with the given file
+ *
+ * @param file
+ * @return
+ */
+ IPapyrusFile createIPapyrusFile(IFile file);
+
+ /**
+ * Create an instanceof {@link IPapyrusFile} with the given file and the
+ * given {@link IPapyrusFile}
+ *
+ * @param papy
+ * @param r
+ * @return
+ */
+ ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r);
+
+ /**
+ * Determines if the file in parameter is a di
+ *
+ * @param file
+ * @return
+ */
+ boolean isDi(IResource file);
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java
new file mode 100644
index 00000000000..3b51302b518
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Contract for elements bellow an {@link IPapyrusFile}
+ *
+ * @author tfaure
+ *
+ */
+public interface ISubResourceFile extends IPapyrusElement {
+ /**
+ * Returns the IFile associted to the {@link ISubResourceFile}
+ *
+ * @return
+ */
+ IFile getFile();
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java
new file mode 100644
index 00000000000..10fc49aa819
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java
@@ -0,0 +1,111 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.onefile.Activator;
+import org.osgi.framework.Bundle;
+
+/**
+ * Helper class able to get the correct {@link IPapyrusModelFactory}
+ *
+ * @author tfaure
+ *
+ */
+public class PapyrusModelHelper {
+
+ private static final String MODEL_FACTORY = "modelFactory";
+ static List<Segment> segments;
+
+ static {
+ IConfigurationElement[] elements = Platform
+ .getExtensionRegistry()
+ .getConfigurationElementsFor(Activator.PLUGIN_ID, MODEL_FACTORY);
+ segments = new ArrayList<PapyrusModelHelper.Segment>(elements.length);
+ for (IConfigurationElement e : elements) {
+ Segment s = new PapyrusModelHelper.Segment();
+ try {
+ s.priority = Integer.parseInt(e.getAttribute("priority"));
+ s.bundle = Platform.getBundle(e.getContributor().getName());
+ s.className = e.getAttribute("instance");
+ segments.add(s);
+ } catch (NumberFormatException ex) {
+ // in case of exception the process continue but the stack is
+ // traced
+ ex.printStackTrace();
+ }
+ }
+ // sort elements according to their priorities
+ Collections.sort(segments, new Comparator<Segment>() {
+ public int compare(Segment o1, Segment o2) {
+ Integer val1 = 0;
+ Integer val2 = 0;
+ if (o1 != null) {
+ val1 = o1.priority;
+ }
+ if (o2 != null) {
+ val2 = o2.priority;
+ }
+ return val1.compareTo(val2);
+ }
+ });
+ }
+
+ /**
+ * get the {@link IPapyrusModelFactory} in the current platform
+ *
+ * @return a {@link IPapyrusModelFactory}
+ */
+ public static IPapyrusModelFactory getPapyrusModelFactory() {
+ if (segments == null || segments.size() == 0) {
+ throw new RuntimeException(
+ "Initialisation error, please register extension to "
+ + Activator.PLUGIN_ID + "." + MODEL_FACTORY);
+ }
+ // segments are sorted by priorities, the highest is at the end of the
+ // list
+ return segments.get(segments.size() - 1).getFactory();
+ }
+
+ /**
+ * Utility class to save extension point information
+ *
+ */
+ private static class Segment {
+ public String className;
+ Bundle bundle;
+ int priority;
+ IPapyrusModelFactory instance = null;
+
+ IPapyrusModelFactory getFactory() {
+ if (instance == null) {
+ try {
+ instance = (IPapyrusModelFactory) bundle.loadClass(
+ className).newInstance();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ return instance;
+ }
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java
new file mode 100644
index 00000000000..db598a2caee
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.adapters;
+
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.mapping.PapyrusResourceMapping;
+
+/**
+ * Adapter factory to adapt {@link IPapyrusFile}
+ *
+ * @author tristan.faure@atosorigin.com
+ */
+@SuppressWarnings("rawtypes")
+public class ModelAdapterFactory implements IAdapterFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+ * java.lang.Class)
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (ResourceMapping.class.equals(adapterType)) {
+ if (adaptableObject instanceof IPapyrusFile) {
+ return new PapyrusResourceMapping(
+ (IPapyrusFile) adaptableObject);
+ }
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] {};
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java
new file mode 100644
index 00000000000..d1b547928ef
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.adapters;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant;
+
+/**
+ * Assistant to manage drag and drop of {@link IPapyrusFile}
+ * {@link IPapyrusFile} are not adapted to {@link IResource} to prevent
+ * misunderstanding so during transfer the selection is changed
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class PapyrusCommonDropAdapterAssistant extends
+ ResourceDropAdapterAssistant {
+
+ @Override
+ public IStatus validateDrop(Object target, int aDropOperation,
+ TransferData transferType) {
+ manageSelection();
+ return super.validateDrop(target, aDropOperation, transferType);
+ }
+
+ @Override
+ public IStatus handleDrop(CommonDropAdapter aDropAdapter,
+ DropTargetEvent aDropTargetEvent, Object aTarget) {
+ manageSelection();
+ return super.handleDrop(aDropAdapter, aDropTargetEvent, aTarget);
+ }
+
+ @Override
+ protected void doInit() {
+ super.doInit();
+ manageSelection();
+ }
+
+ private void manageSelection() {
+ List<Object> elements = new ArrayList<Object>();
+ ISelection selec = LocalSelectionTransfer.getTransfer().getSelection();
+ if (selec instanceof IStructuredSelection) {
+ IStructuredSelection struc = (IStructuredSelection) selec;
+ for (Iterator<Object> i = struc.iterator(); i.hasNext();) {
+ Object o = i.next();
+ if (o instanceof IPapyrusFile) {
+ IPapyrusFile papy = (IPapyrusFile) o;
+ elements.add(papy.getMainFile());
+ }
+ }
+ }
+ LocalSelectionTransfer.getTransfer().setSelection(
+ new StructuredSelection(elements));
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java
new file mode 100644
index 00000000000..8cee453617d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.adapters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.PapyrusModelHelper;
+import org.eclipse.papyrus.onefile.utils.Utils;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.navigator.ILinkHelper;
+
+/**
+ * Link the Papyrus Editor with {@link IPapyrusFile}
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class PapyrusLinkHelper implements ILinkHelper {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui.
+ * IEditorInput)
+ */
+ public IStructuredSelection findSelection(IEditorInput anInput) {
+ List<Object> select = new ArrayList<Object>();
+ if (anInput instanceof IFileEditorInput) {
+ IFileEditorInput input = (IFileEditorInput) anInput;
+ IPapyrusFile papy = PapyrusModelHelper.getPapyrusModelFactory()
+ .createIPapyrusFile(input.getFile());
+ select.add(papy);
+ IResource res = papy.getMainFile();
+ while (res.getParent() != null) {
+ select.add(0, res.getParent());
+ res = res.getParent();
+ }
+ return new StructuredSelection(papy);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.
+ * IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void activateEditor(IWorkbenchPage page,
+ IStructuredSelection selection) {
+ if (selection == null || selection.isEmpty())
+ return;
+ Object element = selection.getFirstElement();
+ IEditorPart part = Utils.isOpenInEditor(element);
+ if (part != null) {
+ page.bringToTop(part);
+ }
+
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java
new file mode 100644
index 00000000000..ef43053bb64
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.adapters;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.papyrus.onefile.model.impl.SubResourceFile;
+import org.eclipse.papyrus.onefile.model.mapping.SubResourceMapping;
+
+/**
+ * Adapter Factory for {@link SubResourceFile}
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class SubResourceAdapterFactory implements IAdapterFactory {
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (ResourceMapping.class.equals(adapterType)) {
+ if (adaptableObject instanceof ISubResourceFile) {
+ return new SubResourceMapping(
+ (ISubResourceFile) adaptableObject);
+ }
+ } else if (IFile.class.equals(adapterType)) {
+ if (adaptableObject instanceof ISubResourceFile) {
+ return ((ISubResourceFile) adaptableObject).getFile();
+ }
+ } else if (IResource.class.equals(adapterType)) {
+ if (adaptableObject instanceof ISubResourceFile) {
+ return ((ISubResourceFile) adaptableObject).getFile();
+ }
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] {};
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java
new file mode 100644
index 00000000000..35b9f7e10de
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.impl;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.papyrus.core.utils.PapyrusImageUtils;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.utils.Utils;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default Implementation of {@link IPapyrusFile}
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class PapyrusFile implements IPapyrusFile {
+
+ private final IFile file;
+ private final List<IFile> files = new LinkedList<IFile>();
+
+ public PapyrusFile(IFile file) {
+ this.file = file;
+ try {
+ for (IResource res : file.getParent().members()) {
+ if (res instanceof IFile
+ && !Utils.isDi((IFile) res)
+ && Utils.withoutFileExtension(file).equals(
+ Utils.withoutFileExtension(res))) {
+ files.add((IFile) res);
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+
+ public IFile getMainFile() {
+ return file;
+ }
+
+ public IResource[] getAssociatedResources() {
+ ArrayList<IResource> list = new ArrayList<IResource>(files.size() + 1);
+ list.add(file);
+ list.addAll(files);
+ return list.toArray(new IResource[] {});
+ }
+
+ public String getLabel() {
+ return file.getName();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PapyrusFile) {
+ PapyrusFile papy = (PapyrusFile) obj;
+ return getMainFile().equals(papy.getMainFile());
+ }
+ return super.equals(obj);
+ }
+
+ public IProject getProject() {
+ return file.getProject();
+ }
+
+ public IContainer getParent() {
+ return file.getParent();
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+
+ public String getText() {
+ return getName().substring(0, getName().lastIndexOf('.'));
+ }
+
+ public Image getImage() {
+ return PapyrusImageUtils.getDefaultIcon();
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java
new file mode 100644
index 00000000000..cb0dea4719f
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.impl;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.IPapyrusModelFactory;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.papyrus.resource.sasheditor.DiModel;
+
+public class PapyrusModelFactory implements IPapyrusModelFactory {
+
+ public IPapyrusFile createIPapyrusFile(IFile file) {
+ return new PapyrusFile(file);
+ }
+
+ public ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r) {
+ return new SubResourceFile(papy, r);
+ }
+
+ public boolean isDi(IResource file) {
+ return DiModel.DI_FILE_EXTENSION.equals(file.getFileExtension());
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java
new file mode 100644
index 00000000000..81e5849767d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.impl;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Default implementation of {@link ISubResourceFile}
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class SubResourceFile implements ISubResourceFile {
+ @SuppressWarnings("unused")
+ private IPapyrusFile parent;
+ private final IFile subResource;
+
+ public SubResourceFile(IPapyrusFile papy, IFile r) {
+ this.parent = papy;
+ this.subResource = r;
+ }
+
+ public IProject getProject() {
+ return subResource.getProject();
+ }
+
+ @Override
+ public String toString() {
+ String fileExtension = subResource.getFileExtension();
+ return fileExtension != null ? fileExtension : subResource.getName();
+ }
+
+ public IFile getFile() {
+ return subResource;
+ }
+
+ public Image getImage() {
+ Image image = JFaceResources.getImage(getFile().getFileExtension());
+ if (image == null) {
+ ImageDescriptor desc = PlatformUI.getWorkbench()
+ .getEditorRegistry()
+ .getImageDescriptor(getFile().getName());
+ JFaceResources.getImageRegistry().put(getFile().getFileExtension(),
+ desc);
+ }
+ return JFaceResources.getImage(getFile().getFileExtension());
+ }
+
+ public String getText() {
+ return toString();
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java
new file mode 100644
index 00000000000..dffb6761d53
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.mapping;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.PapyrusModelHelper;
+import org.eclipse.papyrus.onefile.providers.OneFileModelProvider;
+
+/**
+ * Resource Mapping for Papyrus File
+ *
+ */
+public class PapyrusResourceMapping extends ResourceMapping {
+
+ private final IPapyrusFile papyrusFile;
+
+ public PapyrusResourceMapping(IPapyrusFile adaptableObject) {
+ this.papyrusFile = adaptableObject;
+ }
+
+ public PapyrusResourceMapping(IFile resource) {
+ this.papyrusFile = PapyrusModelHelper.getPapyrusModelFactory()
+ .createIPapyrusFile(resource);
+ }
+
+ @Override
+ public Object getModelObject() {
+ return papyrusFile;
+ }
+
+ @Override
+ public String getModelProviderId() {
+ return OneFileModelProvider.MODEL_PROVIDER_ID;
+ }
+
+ @Override
+ public IProject[] getProjects() {
+ return new IProject[] { papyrusFile.getProject() };
+ }
+
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ // if (ResourceMappingContext.LOCAL_CONTEXT == context)
+ // {
+ // return new ResourceTraversal[]{new ResourceTraversal(new
+ // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE,
+ // IResource.NONE)};
+ // }
+ // else
+ // {
+ return new ResourceTraversal[] { new ResourceTraversal(
+ papyrusFile.getAssociatedResources(), IResource.DEPTH_INFINITE,
+ IResource.NONE) };
+ // }
+
+ }
+
+ @Override
+ public void accept(ResourceMappingContext context,
+ IResourceVisitor visitor, IProgressMonitor monitor)
+ throws CoreException {
+ super.accept(context, visitor, monitor);
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java
new file mode 100644
index 00000000000..5eb0ae7de8a
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.model.mapping;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.papyrus.onefile.providers.OneFileModelProvider;
+
+public class SubResourceMapping extends ResourceMapping {
+ private final ISubResourceFile file;
+
+ public SubResourceMapping(ISubResourceFile adaptableObject) {
+ this.file = adaptableObject;
+ }
+
+ @Override
+ public Object getModelObject() {
+ return file;
+ }
+
+ @Override
+ public String getModelProviderId() {
+ return OneFileModelProvider.MODEL_PROVIDER_ID;
+ }
+
+ @Override
+ public IProject[] getProjects() {
+ return new IProject[] { file.getProject() };
+ }
+
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ // if (ResourceMappingContext.LOCAL_CONTEXT == context)
+ // {
+ // return new ResourceTraversal[]{new ResourceTraversal(new
+ // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE,
+ // IResource.NONE)};
+ // }
+ // else
+ // {
+ return new ResourceTraversal[] { new ResourceTraversal(
+ new IResource[] { file.getFile() }, IResource.DEPTH_INFINITE,
+ IResource.NONE) };
+ // }
+
+ }
+
+ @Override
+ public void accept(ResourceMappingContext context,
+ IResourceVisitor visitor, IProgressMonitor monitor)
+ throws CoreException {
+ super.accept(context, visitor, monitor);
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java
new file mode 100644
index 00000000000..9beba13cb25
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.providers;
+
+import org.eclipse.core.internal.resources.mapping.SimpleResourceMapping;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.papyrus.onefile.model.mapping.PapyrusResourceMapping;
+import org.eclipse.papyrus.onefile.utils.Utils;
+
+@SuppressWarnings("restriction")
+public class OneFileModelProvider extends ModelProvider {
+
+ public static String MODEL_PROVIDER_ID = "org.eclipse.papyrus.onefile.modelProvider";
+
+ public OneFileModelProvider() {
+ }
+
+ public ResourceMapping[] getMappings(IResource resource,
+ ResourceMappingContext context, IProgressMonitor monitor) {
+ if (Utils.isDi(resource)) {
+ return new ResourceMapping[] { new PapyrusResourceMapping(
+ (IFile) resource) };
+ }
+ return new ResourceMapping[] { new SimpleResourceMapping(resource) };
+ }
+
+ @Override
+ public ResourceMapping[] getMappings(IResource[] resources,
+ ResourceMappingContext context, IProgressMonitor monitor)
+ throws CoreException {
+ return super.getMappings(resources, context, monitor);
+ }
+
+ @Override
+ public ResourceTraversal[] getTraversals(ResourceMapping[] mappings,
+ ResourceMappingContext context, IProgressMonitor monitor)
+ throws CoreException {
+ return super.getTraversals(mappings, context, monitor);
+ }
+
+ @Override
+ public ResourceMapping[] getMappings(ResourceTraversal[] traversals,
+ ResourceMappingContext context, IProgressMonitor monitor)
+ throws CoreException {
+ return super.getMappings(traversals, context, monitor);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ return super.getAdapter(adapter);
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java
new file mode 100644
index 00000000000..e7288bc49cb
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java
@@ -0,0 +1,153 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.providers;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.onefile.matcher.OnlyDiFilter;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.PapyrusModelHelper;
+import org.eclipse.papyrus.onefile.utils.Utils;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Content provider able to retrieve Papyrus children from an {@link IContainer}
+ *
+ * @author tfaure
+ *
+ */
+public class PapyrusContentProvider extends SynchronizationContentProvider {
+
+ private ITreeContentProvider provider = null;
+ private CommonViewer common;
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (viewer instanceof CommonViewer) {
+ common = (CommonViewer) viewer;
+ }
+ }
+
+ /**
+ * Determine if the current navigator is filtered or not
+ *
+ * @return true if the viewer is filtered
+ */
+ public boolean isFiltered() {
+ return common != null
+ && common.getNavigatorContentService() != null
+ && common.getNavigatorContentService().getFilterService() != null
+ && common.getNavigatorContentService().getFilterService()
+ .isActive(OnlyDiFilter.FILTER_ID);
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof IWorkspaceRoot) {
+ return null;
+ }
+ List<Object> result = new LinkedList<Object>();
+ try {
+ if (isFiltered()) {
+ if (inputElement instanceof IPapyrusFile) {
+ IPapyrusFile file = (IPapyrusFile) inputElement;
+ for (IResource r : file.getAssociatedResources()) {
+ result.add(PapyrusModelHelper.getPapyrusModelFactory()
+ .createISubResourceFile(file, (IFile) r));
+ }
+ } else {
+ IResource[] members = null;
+ if (inputElement instanceof IContainer) {
+ members = ((IContainer) inputElement).members();
+ }
+ if (members != null) {
+ for (IResource r : members) {
+ if (r instanceof IContainer
+ && !(r instanceof IProject)) {
+ IContainer cont = (IContainer) r;
+ result.add(cont);
+ } else if (r instanceof IFile) {
+ if (Utils.isDi(r)) {
+ result.add(PapyrusModelHelper
+ .getPapyrusModelFactory()
+ .createIPapyrusFile((IFile) r));
+ } else {
+ if (!Utils.diExists(r.getName(),
+ r.getParent())) {
+ result.add(r);
+ }
+ }
+ } else {
+ result.add(r);
+ }
+ }
+ }
+ }
+
+ }
+ } catch (CoreException e) {
+ }
+ return result.isEmpty() ? null : result.toArray();
+ }
+
+ public Object[] getChildren(Object inputElement) {
+ return getElements(inputElement);
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof IPapyrusFile) {
+ IPapyrusFile papyFile = (IPapyrusFile) element;
+ return papyFile.getParent();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return Utils.hasChildren(element);
+ }
+
+ @Override
+ protected ITreeContentProvider getDelegateContentProvider() {
+ if (provider == null) {
+ provider = new WorkbenchContentProvider();
+ }
+ return provider;
+ }
+
+ @Override
+ protected String getModelProviderId() {
+ return OneFileModelProvider.MODEL_PROVIDER_ID;
+ }
+
+ @Override
+ protected Object getModelRoot() {
+ return null;
+ }
+
+ @Override
+ protected ResourceTraversal[] getTraversals(
+ ISynchronizationContext context, Object object) {
+ return null;
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java
new file mode 100644
index 00000000000..d874589462b
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.providers;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Label Provider for Papyrus Model Elements
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class PapyrusLabelProvider implements ILabelProvider {
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ if (element instanceof IPapyrusFile) {
+ IPapyrusFile papyFile = (IPapyrusFile) element;
+ return papyFile.getImage();
+ }
+ if (element instanceof ISubResourceFile) {
+ return ((ISubResourceFile) element).getImage();
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof IPapyrusFile) {
+ IPapyrusFile papyFile = (IPapyrusFile) element;
+ return papyFile.getText();
+ }
+ if (element instanceof ISubResourceFile) {
+ return ((ISubResourceFile) element).getText();
+ }
+ if (element instanceof IResource) {
+ return ((IResource) element).getName();
+ }
+ return null;
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java
new file mode 100644
index 00000000000..0f69f6440bf
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java
@@ -0,0 +1,286 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.providers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.CopyResourceAction;
+import org.eclipse.ui.actions.DeleteResourceAction;
+import org.eclipse.ui.actions.RefreshAction;
+import org.eclipse.ui.actions.RenameResourceAction;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+/**
+ * Actions available through an {@link IPapyrusFile}
+ *
+ * @author tfaure
+ *
+ */
+@SuppressWarnings({"restriction","rawtypes"})
+public class PapyrusModelActionProvider extends CommonActionProvider {
+
+ private boolean fInViewPart = false;
+ private ICommonViewerWorkbenchSite workbenchSite;
+ private Action openAction;
+ private Action deleteAction;
+ private Action copyAction;
+ private Action renameAction;
+ private Action refreshAction;
+
+ public PapyrusModelActionProvider() {
+
+ }
+
+ @Override
+ protected boolean filterAction(IAction action) {
+ return super.filterAction(action);
+ }
+
+ @Override
+ public void fillActionBars(IActionBars actionBars) {
+ if (fInViewPart) {
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN,
+ openAction);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
+ deleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(),
+ renameAction);
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
+ copyAction);
+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(),
+ refreshAction);
+
+ }
+ super.fillActionBars(actionBars);
+ }
+
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ appendToGroup(menu, openAction, ICommonMenuConstants.GROUP_OPEN);
+ appendToGroup(menu, deleteAction, ICommonMenuConstants.GROUP_EDIT);
+ appendToGroup(menu, copyAction, ICommonMenuConstants.GROUP_EDIT);
+ appendToGroup(menu, renameAction, ICommonMenuConstants.GROUP_EDIT);
+ appendToGroup(menu, refreshAction, ICommonMenuConstants.GROUP_EDIT);
+ }
+
+ private void appendToGroup(IMenuManager menu, Action action, String id) {
+ if (action != null && action.isEnabled()) {
+ menu.appendToGroup(id, action);
+ }
+ }
+
+ @Override
+ public void init(ICommonActionExtensionSite site) {
+ if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+ workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
+ }
+ if (workbenchSite != null) {
+ if (workbenchSite.getPart() != null
+ && workbenchSite.getPart() instanceof IViewPart) {
+ fInViewPart = true;
+ }
+ makeActions();
+ }
+ }
+
+ private void makeActions() {
+ final IWorkbenchPartSite provider = workbenchSite.getSite();
+ final ActionHelper helper = new ActionHelper();
+ openAction = new Action() {
+
+ @Override
+ public void run() {
+ if (getIFile() != null) {
+ try {
+ IDE.openEditor(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage(),
+ getIFile(), true);
+ } catch (WorkbenchException e) {
+ }
+ }
+ }
+
+ public IFile getIFile() {
+ return helper.getIFile(getContext());
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return getIFile() != null;
+ }
+
+ @Override
+ public String getText() {
+ return IDEWorkbenchMessages.OpenFileAction_text;
+ }
+ };
+
+ deleteAction = new DeleteResourceAction(provider) {
+
+ @Override
+ public IStructuredSelection getStructuredSelection() {
+ return helper.getOneStructuredSelection(getContext());
+ }
+
+ @Override
+ protected List getSelectedResources() {
+ return helper.getOneSelectedResources(getContext());
+ }
+ };
+
+ copyAction = new CopyResourceAction(provider) {
+ @Override
+ public IStructuredSelection getStructuredSelection() {
+ return helper.getStructuredSelection(getContext());
+ }
+
+ @Override
+ protected List getSelectedResources() {
+ return helper.getSelectedResources(getContext());
+ }
+ };
+
+ renameAction = new RenameResourceAction(provider) {
+
+ @Override
+ public IStructuredSelection getStructuredSelection() {
+ IStructuredSelection selec = helper
+ .getOneStructuredSelection(getContext());
+ return selec != null ? selec : super.getStructuredSelection();
+ }
+
+ @Override
+ protected List getSelectedResources() {
+ return helper.getOneSelectedResources(getContext());
+ }
+
+ };
+
+ refreshAction = new RefreshAction(provider);
+
+ makeAction(openAction, ICommonActionConstants.OPEN,
+ ISharedImages.IMG_TOOL_COPY,
+ ISharedImages.IMG_TOOL_COPY_DISABLED);
+ makeAction(deleteAction, IWorkbenchCommandConstants.EDIT_DELETE,
+ ISharedImages.IMG_TOOL_DELETE,
+ ISharedImages.IMG_TOOL_DELETE_DISABLED);
+ makeAction(copyAction, IWorkbenchCommandConstants.EDIT_COPY,
+ ISharedImages.IMG_TOOL_COPY,
+ ISharedImages.IMG_TOOL_COPY_DISABLED);
+ makeAction(refreshAction, ActionFactory.REFRESH.getCommandId(), null,
+ null);
+ }
+
+ protected void makeAction(Action action, String id, String imgTool,
+ String imgToolDisabled) {
+ if (action != null) {
+ ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+ if (id != null) {
+ action.setId(id);
+ action.setActionDefinitionId(id);
+ }
+ if (imgTool != null) {
+ action.setImageDescriptor(images.getImageDescriptor(imgTool));
+ }
+ if (imgToolDisabled != null) {
+ action.setDisabledImageDescriptor(images
+ .getImageDescriptor(imgToolDisabled));
+ }
+ }
+ }
+
+ public static class ActionHelper {
+
+ public IStructuredSelection getStructuredSelection(ActionContext context) {
+ return new StructuredSelection(getSelectedResources(context));
+ }
+
+ public List getOneSelectedResources(ActionContext context) {
+ List selectedResources = getSelectedResources(context);
+ if (selectedResources.size() > 0) {
+ return Collections.singletonList(selectedResources.get(0));
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ public IStructuredSelection getOneStructuredSelection(
+ ActionContext context) {
+ List selectedResources = getSelectedResources(context);
+ if (selectedResources.size() > 0) {
+ return new StructuredSelection(selectedResources.get(0));
+ }
+ return null;
+ }
+
+ protected List getSelectedResources(ActionContext context) {
+ ISelection selec = context.getSelection();
+ List<IResource> resources = new ArrayList<IResource>();
+ if (selec instanceof IStructuredSelection) {
+ IStructuredSelection struc = (IStructuredSelection) selec;
+ for (Iterator<Object> i = struc.iterator(); i.hasNext();) {
+ Object o = i.next();
+ if (o instanceof IPapyrusFile) {
+ IPapyrusFile papy = (IPapyrusFile) o;
+ resources.addAll(Arrays.asList(papy
+ .getAssociatedResources()));
+ }
+ }
+ }
+ return resources;
+ }
+
+ public IFile getIFile(ActionContext context) {
+ ISelection selec = context.getSelection();
+ if (selec instanceof IStructuredSelection) {
+ IStructuredSelection struc = (IStructuredSelection) selec;
+ Object firstElement = struc.getFirstElement();
+ if (firstElement instanceof IFile) {
+ IFile file = (IFile) firstElement;
+ return file;
+ } else if (firstElement instanceof IPapyrusFile) {
+ return (IFile) ((IPapyrusFile) firstElement).getMainFile();
+ }
+ }
+ return null;
+ }
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java
new file mode 100644
index 00000000000..685a6e41802
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.providers;
+
+import java.text.Collator;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+/**
+ * Sort Papyrus Files according to their Main File
+ *
+ * @author tristan.faure@atosorigin.com
+ */
+public class PapyrusViewerSorter extends ViewerSorter {
+
+ /**
+ * {@link ResourceComparator} for comparison delegation
+ */
+ ResourceComparator comp = new ResourceComparator(ResourceComparator.TYPE);
+
+ public PapyrusViewerSorter() {
+ super();
+ }
+
+ public PapyrusViewerSorter(Collator collator) {
+ super(collator);
+ }
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof IPapyrusFile) {
+ IPapyrusFile papyrusFile = (IPapyrusFile) e1;
+ e1 = papyrusFile.getMainFile();
+ }
+ if (e2 instanceof IPapyrusFile) {
+ IPapyrusFile papyrusFile = (IPapyrusFile) e2;
+ e2 = papyrusFile.getMainFile();
+ }
+ return comp.compare(viewer, e1, e2);
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/utils/Utils.java b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/utils/Utils.java
new file mode 100644
index 00000000000..7ed953d5b1d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.onefile/src/org/eclipse/papyrus/onefile/utils/Utils.java
@@ -0,0 +1,335 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin Integration.
+ *
+ * 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 Integration) tristan.faure@atosorigin.com - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.onefile.utils;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.onefile.Activator;
+import org.eclipse.papyrus.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.onefile.model.ISubResourceFile;
+import org.eclipse.papyrus.onefile.model.PapyrusModelHelper;
+import org.eclipse.papyrus.resource.sasheditor.DiModel;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Utility methods
+ *
+ * @author tristan.faure@atosorigin.com
+ *
+ */
+public class Utils {
+
+ /**
+ * Determines if a di exist in the container from a file name
+ *
+ * @param fileName
+ * @param parent
+ * @return
+ */
+ public static boolean diExists(String fileName, IContainer parent) {
+ if (parent == null || parent.getType() == IResource.ROOT) {
+ return false;
+ }
+ String substring = fileName;
+ if (fileName.indexOf('.') > 0) {
+ substring = fileName.substring(0, fileName.lastIndexOf('.'));
+ }
+ IFile file = parent.getFile(new Path(substring + "."
+ + DiModel.DI_FILE_EXTENSION));
+ return file != null && file.exists();
+ }
+
+ /**
+ * check if the element has children or not
+ *
+ * @param element
+ * @return
+ */
+ public static boolean hasChildren(Object element) {
+ if (element instanceof IContainer) {
+ IContainer container = (IContainer) element;
+ try {
+ return container.members().length > 0;
+ } catch (CoreException e) {
+ }
+ }
+ if (element instanceof IPapyrusFile) {
+ IPapyrusFile iPapyrusFile = (IPapyrusFile) element;
+ return iPapyrusFile.getMainFile() != null
+ && iPapyrusFile.getAssociatedResources().length > 1;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the element in parameter is visible or not
+ *
+ * @param element
+ * @return
+ */
+ public static boolean isVisible(Object element) {
+ boolean typeOk = element instanceof IPapyrusFile
+ || element instanceof IProject || element instanceof IFile
+ || element instanceof IContainer
+ || element instanceof ISubResourceFile;
+ if (typeOk && element instanceof IFile) {
+ IFile file = (IFile) element;
+ typeOk &= !Utils.diExists(file.getName(), file.getParent());
+ }
+ return typeOk;
+ }
+
+ /**
+ * Check if the resource is a Papyrus Di
+ *
+ * @param fileName
+ * @return
+ */
+ public static boolean isDi(IResource fileName) {
+ return PapyrusModelHelper.getPapyrusModelFactory().isDi(fileName);
+ }
+
+ /**
+ * Returns the name without the extension of the file
+ *
+ * @param res
+ * @return
+ */
+ public static String withoutFileExtension(IResource res) {
+ if (res.getFileExtension() != null
+ && res.getFileExtension().length() > 0) {
+ return res.getName().substring(0, res.getName().lastIndexOf('.'));
+ } else {
+ return res.getName();
+ }
+ }
+
+ /**
+ * Check if the resource has a DI inside it
+ *
+ * @param resource
+ * @return
+ */
+ public static boolean containsModelFiles(IResource resource) {
+ if (resource instanceof IContainer) {
+ IContainer container = (IContainer) resource;
+ try {
+ for (IResource m : container.members()) {
+ if (isDi(m)) {
+ return true;
+ }
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if the object is in an already opened editor
+ *
+ * @param inputElement
+ * @return
+ */
+ public static IEditorPart isOpenInEditor(Object inputElement) {
+ IEditorPart editor = findEditor(inputElement, false);
+ if (editor != null) {
+ return editor;
+ }
+ IEditorInput input = getEditorInput(inputElement);
+ if (input != null) {
+
+ IWorkbenchPage p = getActivePage();
+ if (p != null) {
+ return p.findEditor(input);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find an editor opening the input element
+ *
+ * @param inputElement
+ * @param activate
+ * , if activate is true, once the editor is found it is
+ * activated
+ * @return null if no editor is found
+ */
+ private static IEditorPart findEditor(Object inputElement, boolean activate) {
+ if (inputElement instanceof IPapyrusFile) {
+ IPapyrusFile cu = (IPapyrusFile) inputElement;
+ if (cu != null) {
+ IWorkbenchPage page = getActivePage();
+ for (IEditorReference ref : page.getEditorReferences()) {
+ IEditorPart editor = ref.getEditor(false);
+ if (editor != null) {
+ IEditorInput editorInput;
+ editorInput = (IEditorInput) editor.getEditorInput();
+ if (cu.getMainFile().equals(
+ editorInput.getAdapter(IFile.class))) {
+ if (activate && page.getActivePart() != editor) {
+ page.activate(editor);
+ }
+ return editor;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Open the editor corresponding to the inpur element
+ *
+ * @param inputElement
+ * @param activate
+ * @return
+ * @throws PartInitException
+ */
+ public static IEditorPart openInEditor(Object inputElement, boolean activate)
+ throws PartInitException {
+
+ if (inputElement instanceof IFile) {
+ return openInEditor((IFile) inputElement, activate);
+ }
+ IEditorPart editor = findEditor(inputElement, activate);
+ if (editor != null) {
+ return editor;
+ }
+ IEditorInput input = getEditorInput(inputElement);
+ if (input == null) {
+ throw new PartInitException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, "not found"));
+ }
+ return openInEditor(input, getEditorID(input), activate);
+ }
+
+ /**
+ * Get the editor input for the given element
+ *
+ * @param inputElement
+ * @return
+ */
+ private static IEditorInput getEditorInput(Object inputElement) {
+ if (inputElement instanceof IFile) {
+ IFile file = (IFile) inputElement;
+ return new FileEditorInput(file);
+ }
+ return null;
+ }
+
+ /**
+ * Get the editor id for an editor input
+ *
+ * @param input
+ * @return
+ * @throws PartInitException
+ */
+ public static String getEditorID(IEditorInput input)
+ throws PartInitException {
+
+ Assert.isNotNull(input);
+
+ IEditorDescriptor editorDescriptor;
+
+ if (input instanceof IFileEditorInput)
+ editorDescriptor = IDE
+ .getEditorDescriptor(((IFileEditorInput) input).getFile());
+ else {
+ editorDescriptor = IDE.getEditorDescriptor(input.getName());
+ }
+ return editorDescriptor.getId();
+
+ }
+
+ /**
+ * @param file
+ * @param activate
+ * @return
+ * @throws PartInitException
+ */
+ private static IEditorPart openInEditor(IFile file, boolean activate)
+ throws PartInitException {
+
+ if (file == null) {
+ throw new PartInitException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, "not found"));
+ }
+
+ IWorkbenchPage p = getActivePage();
+
+ if (p == null) {
+ throw new PartInitException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, "not found"));
+ }
+
+ IEditorPart editorPart = IDE.openEditor(p, file, activate);
+
+ return editorPart;
+
+ }
+
+ /**
+ * Get the active Page
+ *
+ * @return
+ */
+ public static IWorkbenchPage getActivePage() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench == null) {
+ return null;
+ }
+ IWorkbenchWindow activeWorkbenchWindow = workbench
+ .getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow == null) {
+ return null;
+ }
+ return activeWorkbenchWindow.getActivePage();
+ }
+
+ private static IEditorPart openInEditor(IEditorInput input,
+ String editorID, boolean activate) throws PartInitException {
+ Assert.isNotNull(input);
+ Assert.isNotNull(editorID);
+ IWorkbenchPage p = getActivePage();
+ if (p == null) {
+ throw new PartInitException(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, "not found"));
+ }
+ IEditorPart editorPart = p.openEditor(input, editorID, activate);
+ return editorPart;
+
+ }
+
+}

Back to the top