Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaged Elaasar2017-02-21 08:19:48 +0000
committerFlorian Noyrit2017-03-13 16:19:06 +0000
commit7a1e61e4203fcf468a2635b80dd94182a95b588b (patch)
tree804451f2f230c2cb1a4b07815f4ccd2dc1edcf52 /plugins/infra/ui
parentcb10068854ce727bc5004e997663ae0a3ae2ffd6 (diff)
downloadorg.eclipse.papyrus-7a1e61e4203fcf468a2635b80dd94182a95b588b.tar.gz
org.eclipse.papyrus-7a1e61e4203fcf468a2635b80dd94182a95b588b.tar.xz
org.eclipse.papyrus-7a1e61e4203fcf468a2635b80dd94182a95b588b.zip
Bug 510451 - Reimplement the ISO42010 specification to properly support
architectural contexts and viewpoints Replaced the viewpoint configuration framework by a new architectural context/viewpoint framework. This involves defining architecture contexts and viewpoints in models and contributing them via extension points or via the preferences. Models reference an architecture context and a set of viewpoints at creation time, but can be switched later. Architecture contexts double as client contexts for which elementtypesetconfigurations can be registered. They also define viewpoints, which reference representation kinds (diagrams or tables). This contribution defines three architecture contexts: UML, Profile, and SysML corresponding to what Papyrus used to call diagram categories. Change-Id: I203b58d9e97afdffc45c2674683c0281eb8a7c5b Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/infra/ui')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.classpath7
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.project28
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF26
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/about.html28
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/build.properties20
-rwxr-xr-xplugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureContext.gifbin0 -> 602 bytes
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureModelFile.gifbin0 -> 346 bytes
-rwxr-xr-xplugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureViewpoint.gifbin0 -> 602 bytes
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/wizban/NewArchitecture.gifbin0 -> 2462 bytes
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.properties65
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml132
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/pom.xml13
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/ArchitectureUIPlugin.java85
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureActionBarContributor.java373
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java1534
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureModelWizard.java518
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java204
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureViewpointsHandler.java118
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/navigator/ViewpointFilter.java49
-rwxr-xr-xplugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java433
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureModelSelectDialog.java234
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/widgets/ArchitectureContextComposite.java374
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/schema/papyrusDiagram.exsd61
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/extension/commands/IModelCreationCommand.java33
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/internal/commands/SashLayoutCommandFactory.java12
-rw-r--r--plugins/infra/ui/pom.xml1
26 files changed, 4248 insertions, 100 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.classpath b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.classpath
new file mode 100644
index 00000000000..22f30643cba
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.project b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.project
new file mode 100644
index 00000000000..4a60469d860
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.ui.architecture</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.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..dba7daad09d
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.infra.ui.architecture;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin$Implementation
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: org.eclipse.papyrus.infra.ui.architecture,
+ org.eclipse.papyrus.infra.ui.architecture.widgets
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.eclipse.emf.edit.ui;visibility:=reexport,
+ org.eclipse.ui.ide;visibility:=reexport,
+ org.eclipse.papyrus.infra.types.edit;visibility:=reexport,
+ org.eclipse.papyrus.infra.architecture;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.core.architecture.edit;visibility:=reexport,
+ org.eclipse.papyrus.infra.architecture.representation.edit;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="2.2.0",
+ org.eclipse.papyrus.infra.ui;bundle-version="2.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="3.0.0",
+ org.eclipse.papyrus.infra.nattable.common;bundle-version="3.0.0"
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/about.html b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/about.html
new file mode 100644
index 00000000000..bbf2bd6aac7
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/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>January 30, 2017</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/build.properties b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/build.properties
new file mode 100644
index 00000000000..d9800df7f61
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/build.properties
@@ -0,0 +1,20 @@
+# Copyright (c) 2016 CEA LIST.
+#
+# 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:
+# Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+#
+#
+
+bin.includes = .,\
+ icons/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
+source.. = src/
+output.. = bin
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureContext.gif b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureContext.gif
new file mode 100755
index 00000000000..1c1f316b177
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureContext.gif
Binary files differ
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureModelFile.gif b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureModelFile.gif
new file mode 100644
index 00000000000..1ae5c0695d9
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureModelFile.gif
Binary files differ
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureViewpoint.gif b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureViewpoint.gif
new file mode 100755
index 00000000000..1c1f316b177
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/obj16/ArchitectureViewpoint.gif
Binary files differ
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/wizban/NewArchitecture.gif b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/wizban/NewArchitecture.gif
new file mode 100644
index 00000000000..36775a51305
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/icons/full/wizban/NewArchitecture.gif
Binary files differ
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.properties b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.properties
new file mode 100644
index 00000000000..80ebaecd936
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.properties
@@ -0,0 +1,65 @@
+# Copyright (c) 2016 CEA LIST.
+#
+# 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:
+# Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+#
+#
+
+pluginName = Architecture UI
+providerName = Eclipse Modeling Project
+
+_UI_ArchitectureEditor_menu = &Architecture Editor
+
+_UI_CreateChild_menu_item = &New Child
+_UI_CreateSibling_menu_item = N&ew Sibling
+
+_UI_ShowPropertiesView_menu_item = Show &Properties View
+_UI_RefreshViewer_menu_item = &Refresh
+
+_UI_SelectionPage_label = Selection
+_UI_ParentPage_label = Parent
+_UI_ListPage_label = List
+_UI_TreePage_label = Tree
+_UI_TablePage_label = Table
+_UI_TreeWithColumnsPage_label = Tree with Columns
+_UI_ObjectColumn_label = Object
+_UI_SelfColumn_label = Self
+
+_UI_NoObjectSelected = Selected Nothing
+_UI_SingleObjectSelected = Selected Object: {0}
+_UI_MultiObjectSelected = Selected {0} Objects
+
+_UI_OpenEditorError_label = Open Editor
+
+_UI_Wizard_category = Example EMF Model Creation Wizards
+
+_UI_CreateModelError_message = Problems encountered in file "{0}"
+
+_UI_ArchitectureModelWizard_label = Architecture Model
+_UI_ArchitectureModelWizard_description = Create a new Architecture model
+
+_UI_ArchitectureEditor_label = Architecture Model Editor
+
+_UI_ArchitectureEditorFilenameDefaultBase = My
+_UI_ArchitectureEditorFilenameExtensions = architecture
+
+_UI_Wizard_label = New
+
+_WARN_FilenameExtension = The file name must end in ''.{0}''
+_WARN_FilenameExtensions = The file name must have one of the following extensions: {0}
+
+_UI_ModelObject = &Model Object
+_UI_XMLEncoding = &XML Encoding
+_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1
+_UI_Wizard_initial_object_description = Select a model object to create
+
+_UI_FileConflict_label = File Conflict
+_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?
+
+Switch_Architecture_Context = Switch Architecture Context...
+Switch_Architecture_Viewpoints = Switch Architecture Viewpoints \ No newline at end of file
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml
new file mode 100644
index 00000000000..b054f1d1de6
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2016 CEA LIST.
+
+ 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:
+ Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+
+
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.ui.newWizards">
+ <!-- @generated Architecture -->
+ <category
+ id="org.eclipse.emf.ecore.Wizard.category.ID"
+ name="%_UI_Wizard_category"/>
+ <wizard
+ id="org.eclipse.papyrus.infra.ui.architecture.ArchitectureModelWizardID"
+ name="%_UI_ArchitectureModelWizard_label"
+ class="org.eclipse.papyrus.infra.ui.architecture.editor.ArchitectureModelWizard"
+ category="org.eclipse.papyrus.wizards.category"
+ icon="icons/full/obj16/ArchitectureModelFile.gif">
+ <description>%_UI_ArchitectureModelWizard_description</description>
+ <selection class="org.eclipse.core.resources.IResource"/>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors">
+ <!-- @generated Architecture -->
+ <editor
+ id="org.eclipse.papyrus.infra.ui.architecture.ArchitectureEditorID"
+ name="%_UI_ArchitectureEditor_label"
+ icon="icons/full/obj16/ArchitectureModelFile.gif"
+ extensions="architecture"
+ class="org.eclipse.papyrus.infra.ui.architecture.editor.ArchitectureEditor"
+ contributorClass="org.eclipse.papyrus.infra.ui.architecture.editor.ArchitectureActionBarContributor">
+ </editor>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
+ class="org.eclipse.papyrus.infra.ui.architecture.preferences.ArchitectureContextPreferencePage"
+ id="org.eclipse.papyrus.infra.ui.architecture.preferences.ArchitecturesPreferencePage"
+ name="Architecture Contexts">
+ </page>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.infra.ui.architecture.handlers.ChangeArchitectureContextHandler"
+ id="org.eclipse.papyrus.infra.ui.architecture.commands.ChangeArchitectureContext"
+ name="Change Architecture Context">
+ </command>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=newelements">
+ <separator
+ name="architecture"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.papyrus.infra.ui.architecture.commands.ChangeArchitectureContext"
+ icon="icons/full/obj16/ArchitectureContext.gif"
+ id="org.eclipse.papyrus.infra.ui.architecture.commands.ChangeArchitectureContext"
+ label="%Switch_Architecture_Context"
+ mnemonic="C"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <adapt
+ type="org.eclipse.emf.ecore.EObject">
+ </adapt>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <menu
+ icon="icons/full/obj16/ArchitectureViewpoint.gif"
+ id="org.eclipse.papyrus.infra.ui.architecture.menus.ChangeArchitectureViewpoints"
+ label="%Switch_Architecture_Viewpoints">
+ <dynamic
+ class="org.eclipse.papyrus.infra.ui.architecture.handlers.ChangeArchitectureViewpointsHandler"
+ id="org.eclipse.papyrus.infra.ui.architecture.menus.ChangeArchitectureViewpoints">
+ </dynamic>
+ </menu>
+ </menuContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.navigatorContent">
+ <commonFilter
+ activeByDefault="true"
+ description="Filters diagrams/tables that are unsupported by the selected viewpoints in the Papyrus model"
+ class="org.eclipse.papyrus.infra.ui.architecture.navigator.ViewpointFilter"
+ id="org.eclipse.papyrus.infra.ui.architecture.viewpointFilter"
+ name="Unsupported Diagrams/Tables"
+ visibleInUI="true">
+ </commonFilter>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding
+ viewerId="org.eclipse.papyrus.views.modelexplorer.modelexplorer">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.papyrus.infra.ui.architecture.*">
+ </contentExtension>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/pom.xml b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/pom.xml
new file mode 100644
index 00000000000..06fa013a04e
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-ui</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.ui.architecture</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/ArchitectureUIPlugin.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/ArchitectureUIPlugin.java
new file mode 100644
index 00000000000..669fd4990b6
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/ArchitectureUIPlugin.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture;
+
+import org.eclipse.emf.common.EMFPlugin;
+
+import org.eclipse.emf.common.ui.EclipseUIPlugin;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.papyrus.infra.types.provider.TypesConfigurationsEditPlugin;
+
+/**
+ * This is the central singleton for the Architecture UI plugin.
+ */
+public final class ArchitectureUIPlugin extends EMFPlugin {
+ /**
+ * Keep track of the singleton.
+ */
+ public static final ArchitectureUIPlugin INSTANCE = new ArchitectureUIPlugin();
+
+ /**
+ * Keep track of the singleton.
+ */
+ private static Implementation plugin;
+
+ /** Logging helper */
+ public static LogHelper log;
+
+ /**
+ * Create the instance.
+ */
+ public ArchitectureUIPlugin() {
+ super
+ (new ResourceLocator [] {
+ TypesConfigurationsEditPlugin.INSTANCE,
+ });
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * @return the singleton instance.
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * @return the singleton instance.
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ */
+ public static class Implementation extends EclipseUIPlugin {
+ /**
+ * Creates an instance.
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ log = new LogHelper(this);
+ }
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureActionBarContributor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureActionBarContributor.java
new file mode 100644
index 00000000000..9d756bac45f
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureActionBarContributor.java
@@ -0,0 +1,373 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.editor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+
+import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.SubContributionItem;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Architecture model editor.
+ *
+ * @since 1.0
+ */
+public class ArchitectureActionBarContributor
+ extends EditingDomainActionBarContributor
+ implements ISelectionChangedListener {
+ /**
+ * This keeps track of the active editor.
+ */
+ protected IEditorPart activeEditorPart;
+
+ /**
+ * This keeps track of the current selection provider.
+ */
+ protected ISelectionProvider selectionProvider;
+
+ /**
+ * This action opens the Properties view.
+ */
+ protected IAction showPropertiesViewAction =
+ new Action(ArchitectureUIPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet");
+ }
+ catch (PartInitException exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ */
+ protected IAction refreshViewerAction =
+ new Action(ArchitectureUIPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
+
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.refresh();
+ }
+ }
+ }
+ };
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ */
+ protected Collection<IAction> createChildActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateChild actions.
+ */
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ */
+ protected Collection<IAction> createSiblingActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
+ */
+ protected IMenuManager createSiblingMenuManager;
+
+ /**
+ * This creates an instance of the contributor.
+ */
+ public ArchitectureActionBarContributor() {
+ super(ADDITIONS_LAST_STYLE);
+ loadResourceAction = new LoadResourceAction();
+ validateAction = new ValidateAction();
+ controlAction = new ControlAction();
+ }
+
+ /**
+ * This adds Separators for editor additions to the tool bar.
+ */
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(new Separator("architecture-settings"));
+ toolBarManager.add(new Separator("architecture-additions"));
+ }
+
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ */
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ IMenuManager submenuManager = new MenuManager(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureEditor_menu"), "org.eclipse.papyrus.infra.ui.architecture.menuID");
+ menuManager.insertAfter("additions", submenuManager);
+ submenuManager.add(new Separator("settings"));
+ submenuManager.add(new Separator("actions"));
+ submenuManager.add(new Separator("additions"));
+ submenuManager.add(new Separator("additions-end"));
+
+ // Prepare for CreateChild item addition or removal.
+ //
+ createChildMenuManager = new MenuManager(ArchitectureUIPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ submenuManager.insertBefore("additions", createChildMenuManager);
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(ArchitectureUIPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+ submenuManager.insertBefore("additions", createSiblingMenuManager);
+
+ // Force an update because Eclipse hides empty menus now.
+ //
+ submenuManager.addMenuListener
+ (new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
+
+ addGlobalActions(submenuManager);
+ }
+
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection provider.
+ */
+ @Override
+ public void setActiveEditor(IEditorPart part) {
+ super.setActiveEditor(part);
+ activeEditorPart = part;
+
+ // Switch to the new selection provider.
+ //
+ if (selectionProvider != null) {
+ selectionProvider.removeSelectionChangedListener(this);
+ }
+ if (part == null) {
+ selectionProvider = null;
+ }
+ else {
+ selectionProvider = part.getSite().getSelectionProvider();
+ selectionProvider.addSelectionChangedListener(this);
+
+ // Fake a selection changed event to update the menus.
+ //
+ if (selectionProvider.getSelection() != null) {
+ selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
+ }
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null) {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null) {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null) {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null) {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ */
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ */
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ */
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) {
+ if (actions != null) {
+ for (IAction action : actions) {
+ if (contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ }
+ else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
+ */
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
+ if (actions != null) {
+ IContributionItem[] items = manager.getItems();
+ for (int i = 0; i < items.length; i++) {
+ // Look into SubContributionItems
+ //
+ IContributionItem contributionItem = items[i];
+ while (contributionItem instanceof SubContributionItem) {
+ contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+ }
+
+ // Delete the ActionContributionItems with matching action.
+ //
+ if (contributionItem instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem)contributionItem).getAction();
+ if (actions.contains(action)) {
+ manager.remove(contributionItem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This populates the pop-up menu before it appears.
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ MenuManager submenuManager = null;
+
+ submenuManager = new MenuManager(ArchitectureUIPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager);
+
+ submenuManager = new MenuManager(ArchitectureUIPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+ populateManager(submenuManager, createSiblingActions, null);
+ menuManager.insertBefore("edit", submenuManager);
+ }
+
+ /**
+ * This inserts global actions before the "additions-end" separator.
+ */
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ menuManager.insertAfter("additions-end", new Separator("ui-actions"));
+ menuManager.insertAfter("ui-actions", showPropertiesViewAction);
+
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ menuManager.insertAfter("ui-actions", refreshViewerAction);
+
+ super.addGlobalActions(menuManager);
+ }
+
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects.
+ */
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
+ return true;
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java
new file mode 100644
index 00000000000..48bbd71b8b7
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java
@@ -0,0 +1,1534 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.editor;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.ViewerPane;
+import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+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.util.EContentAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
+import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
+import org.eclipse.emf.edit.ui.util.EditUIUtil;
+import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.core.architecture.provider.ArchitectureItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.architecture.representation.provider.RepresentationItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.types.provider.ElementTypesConfigurationsItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+
+/**
+ * This is the Architecture model editor.
+ *
+ * @since 1.0
+ */
+public class ArchitectureEditor
+ extends MultiPageEditorPart
+ implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
+ /**
+ * This keeps track of the editing domain that is used to track all changes to the model.
+ */
+ protected AdapterFactoryEditingDomain editingDomain;
+
+ /**
+ * This is the one adapter factory used for providing views of the model.
+ */
+ protected ComposedAdapterFactory adapterFactory;
+
+ /**
+ * This is the content outline page.
+ */
+ protected IContentOutlinePage contentOutlinePage;
+
+ /**
+ * This is a kludge...
+ */
+ protected IStatusLineManager contentOutlineStatusLineManager;
+
+ /**
+ * This is the content outline page's viewer.
+ */
+ protected TreeViewer contentOutlineViewer;
+
+ /**
+ * This is the property sheet page.
+ */
+ protected List<PropertySheetPage> propertySheetPages = new ArrayList<PropertySheetPage>();
+
+ /**
+ * This is the viewer that shadows the selection in the content outline.
+ * The parent relation must be correctly defined for this to work.
+ */
+ protected TreeViewer selectionViewer;
+
+ /**
+ * This inverts the roll of parent and child in the content provider and show parents as a tree.
+ */
+ protected TreeViewer parentViewer;
+
+ /**
+ * This shows how a tree view works.
+ */
+ protected TreeViewer treeViewer;
+
+ /**
+ * This shows how a list view works.
+ * A list viewer doesn't support icons.
+ */
+ protected ListViewer listViewer;
+
+ /**
+ * This shows how a table view works.
+ * A table can be used as a list with icons.
+ */
+ protected TableViewer tableViewer;
+
+ /**
+ * This shows how a tree view with columns works.
+ */
+ protected TreeViewer treeViewerWithColumns;
+
+ /**
+ * This keeps track of the active viewer pane, in the book.
+ */
+ protected ViewerPane currentViewerPane;
+
+ /**
+ * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
+ */
+ protected Viewer currentViewer;
+
+ /**
+ * This listens to which ever viewer is active.
+ */
+ protected ISelectionChangedListener selectionChangedListener;
+
+ /**
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ */
+ protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+
+ /**
+ * This keeps track of the selection of the editor as a whole.
+ */
+ protected ISelection editorSelection = StructuredSelection.EMPTY;
+
+ /**
+ * The MarkerHelper is responsible for creating workspace resource markers presented
+ * in Eclipse's Problems View.
+ */
+ protected MarkerHelper markerHelper = new EditUIMarkerHelper();
+
+ /**
+ * This listens for when the outline becomes active
+ */
+ protected IPartListener partListener =
+ new IPartListener() {
+ public void partActivated(IWorkbenchPart p) {
+ if (p instanceof ContentOutline) {
+ if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
+ getActionBarContributor().setActiveEditor(ArchitectureEditor.this);
+
+ setCurrentViewer(contentOutlineViewer);
+ }
+ }
+ else if (p instanceof PropertySheet) {
+ if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) {
+ getActionBarContributor().setActiveEditor(ArchitectureEditor.this);
+ handleActivate();
+ }
+ }
+ else if (p == ArchitectureEditor.this) {
+ handleActivate();
+ }
+ }
+ public void partBroughtToTop(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partClosed(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partDeactivated(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partOpened(IWorkbenchPart p) {
+ // Ignore.
+ }
+ };
+
+ /**
+ * Resources that have been removed since last activation.
+ */
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been changed since last activation.
+ */
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been saved.
+ */
+ protected Collection<Resource> savedResources = new ArrayList<Resource>();
+
+ /**
+ * Map to store the diagnostic associated with a resource.
+ */
+ protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
+
+ /**
+ * Controls whether the problem indication should be updated.
+ */
+ protected boolean updateProblemIndication = true;
+
+ /**
+ * Adapter used to update the problem indication when resources are demanded loaded.
+ */
+ protected EContentAdapter problemIndicationAdapter =
+ new EContentAdapter() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (notification.getNotifier() instanceof Resource) {
+ switch (notification.getFeatureID(Resource.class)) {
+ case Resource.RESOURCE__IS_LOADED:
+ case Resource.RESOURCE__ERRORS:
+ case Resource.RESOURCE__WARNINGS: {
+ Resource resource = (Resource)notification.getNotifier();
+ Diagnostic diagnostic = analyzeResourceProblems(resource, null);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, diagnostic);
+ }
+ else {
+ resourceToDiagnosticMap.remove(resource);
+ }
+
+ if (updateProblemIndication) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+ break;
+ }
+ }
+ }
+ else {
+ super.notifyChanged(notification);
+ }
+ }
+
+ @Override
+ protected void setTarget(Resource target) {
+ basicSetTarget(target);
+ }
+
+ @Override
+ protected void unsetTarget(Resource target) {
+ basicUnsetTarget(target);
+ resourceToDiagnosticMap.remove(target);
+ if (updateProblemIndication) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+ }
+ };
+
+ /**
+ * This listens for workspace changes.
+ */
+ protected IResourceChangeListener resourceChangeListener =
+ new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ protected ResourceSet resourceSet = editingDomain.getResourceSet();
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ public boolean visit(IResourceDelta delta) {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if (delta.getKind() == IResourceDelta.REMOVED ||
+ delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {
+ Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false);
+ if (resource != null) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ removedResources.add(resource);
+ }
+ else if (!savedResources.remove(resource)) {
+ changedResources.add(resource);
+ }
+ }
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
+
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
+ }
+ }
+
+ final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getPage().closeEditor(ArchitectureEditor.this, false);
+ }
+ }
+ });
+ }
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == ArchitectureEditor.this) {
+ handleActivate();
+ }
+ }
+ });
+ }
+ }
+ catch (CoreException exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * Handles activation of the editor or it's associated views.
+ */
+ protected void handleActivate() {
+ // Recompute the read only state.
+ //
+ if (editingDomain.getResourceToReadOnlyMap() != null) {
+ editingDomain.getResourceToReadOnlyMap().clear();
+
+ // Refresh any actions that may become enabled or disabled.
+ //
+ setSelection(getSelection());
+ }
+
+ if (!removedResources.isEmpty()) {
+ if (handleDirtyConflict()) {
+ getSite().getPage().closeEditor(ArchitectureEditor.this, false);
+ }
+ else {
+ removedResources.clear();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+ else if (!changedResources.isEmpty()) {
+ changedResources.removeAll(savedResources);
+ handleChangedResources();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+
+ /**
+ * Handles what to do with changed resources on activation.
+ */
+ protected void handleChangedResources() {
+ if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
+ editingDomain.getCommandStack().flush();
+
+ updateProblemIndication = false;
+ for (Resource resource : changedResources) {
+ if (resource.isLoaded()) {
+ resource.unload();
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ }
+ catch (IOException exception) {
+ if (!resourceToDiagnosticMap.containsKey(resource)) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ }
+ }
+ }
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+ }
+
+ /**
+ * Updates the problems indication with the information described in the specified diagnostic.
+ */
+ protected void updateProblemIndication() {
+ if (updateProblemIndication) {
+ BasicDiagnostic diagnostic =
+ new BasicDiagnostic
+ (Diagnostic.OK,
+ "org.eclipse.papyrus.infra.core.architecture.editor",
+ 0,
+ null,
+ new Object [] { editingDomain.getResourceSet() });
+ for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
+ if (childDiagnostic.getSeverity() != Diagnostic.OK) {
+ diagnostic.add(childDiagnostic);
+ }
+ }
+
+ int lastEditorPage = getPageCount() - 1;
+ if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
+ ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ setActivePage(lastEditorPage);
+ }
+ }
+ else if (diagnostic.getSeverity() != Diagnostic.OK) {
+ ProblemEditorPart problemEditorPart = new ProblemEditorPart();
+ problemEditorPart.setDiagnostic(diagnostic);
+ problemEditorPart.setMarkerHelper(markerHelper);
+ try {
+ addPage(++lastEditorPage, problemEditorPart, getEditorInput());
+ setPageText(lastEditorPage, problemEditorPart.getPartName());
+ setActivePage(lastEditorPage);
+ showTabs();
+ }
+ catch (PartInitException exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ }
+
+ if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
+ markerHelper.deleteMarkers(editingDomain.getResourceSet());
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ try {
+ markerHelper.createMarkers(diagnostic);
+ }
+ catch (CoreException exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Shows a dialog that asks if conflicting changes should be discarded.
+ */
+ protected boolean handleDirtyConflict() {
+ return
+ MessageDialog.openQuestion
+ (getSite().getShell(),
+ getString("_UI_FileConflict_label"),
+ getString("_WARN_FileConflict"));
+ }
+
+ /**
+ * This creates a model editor.
+ */
+ public ArchitectureEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * This sets up the editing domain for the model editor.
+ */
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ArchitectureItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new RepresentationItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ElementTypesConfigurationsItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener
+ (new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
+ PropertySheetPage propertySheetPage = i.next();
+ if (propertySheetPage.getControl().isDisposed()) {
+ i.remove();
+ }
+ else {
+ propertySheetPage.refresh();
+ }
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+ }
+
+ /**
+ * This is here for the listener to be able to call it.
+ */
+ @Override
+ protected void firePropertyChange(int action) {
+ super.firePropertyChange(action);
+ }
+
+ /**
+ * This sets the selection into whichever viewer is active.
+ */
+ public void setSelectionToViewer(Collection<?> collection) {
+ final Collection<?> theSelection = collection;
+ // Make sure it's okay.
+ //
+ if (theSelection != null && !theSelection.isEmpty()) {
+ Runnable runnable =
+ new Runnable() {
+ public void run() {
+ // Try to select the items in the current content viewer of the editor.
+ //
+ if (currentViewer != null) {
+ currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
+ }
+ }
+ };
+ getSite().getShell().getDisplay().asyncExec(runnable);
+ }
+ }
+
+ /**
+ * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
+ * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
+ * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
+ */
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
+ public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ @Override
+ public Object [] getElements(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ @Override
+ public Object [] getChildren(Object object) {
+ Object parent = super.getParent(object);
+ return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
+ }
+
+ @Override
+ public boolean hasChildren(Object object) {
+ Object parent = super.getParent(object);
+ return parent != null;
+ }
+
+ @Override
+ public Object getParent(Object object) {
+ return null;
+ }
+ }
+
+ public void setCurrentViewerPane(ViewerPane viewerPane) {
+ if (currentViewerPane != viewerPane) {
+ if (currentViewerPane != null) {
+ currentViewerPane.showFocus(false);
+ }
+ currentViewerPane = viewerPane;
+ }
+ setCurrentViewer(currentViewerPane.getViewer());
+ }
+
+ /**
+ * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
+ * is the current one.
+ */
+ public void setCurrentViewer(Viewer viewer) {
+ // If it is changing...
+ //
+ if (currentViewer != viewer) {
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener =
+ new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+
+ // Stop listening to the old one.
+ //
+ if (currentViewer != null) {
+ currentViewer.removeSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Start listening to the new one.
+ //
+ if (viewer != null) {
+ viewer.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ // Remember it.
+ //
+ currentViewer = viewer;
+
+ // Set the editors selection based on the current viewer's selection.
+ //
+ setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
+ }
+ }
+
+ /**
+ * This returns the viewer as required by the {@link IViewerProvider} interface.
+ */
+ public Viewer getViewer() {
+ return currentViewer;
+ }
+
+ /**
+ * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
+ */
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp");
+ contextMenu.add(new Separator("additions"));
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu= contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
+ }
+
+ /**
+ * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
+ */
+ public void createModel() {
+ URI resourceURI = EditUIUtil.getURI(getEditorInput(), editingDomain.getResourceSet().getURIConverter());
+ Exception exception = null;
+ Resource resource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ resource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ }
+ catch (Exception e) {
+ exception = e;
+ resource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+
+ Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
+ }
+
+ /**
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ */
+ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
+ boolean hasErrors = !resource.getErrors().isEmpty();
+ if (hasErrors || !resource.getWarnings().isEmpty()) {
+ BasicDiagnostic basicDiagnostic =
+ new BasicDiagnostic
+ (hasErrors ? Diagnostic.ERROR : Diagnostic.WARNING,
+ "org.eclipse.papyrus.infra.core.architecture.editor",
+ 0,
+ getString("_UI_CreateModelError_message", resource.getURI()),
+ new Object [] { exception == null ? (Object)resource : exception });
+ basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
+ return basicDiagnostic;
+ }
+ else if (exception != null) {
+ return
+ new BasicDiagnostic
+ (Diagnostic.ERROR,
+ "org.eclipse.papyrus.infra.core.architecture.editor",
+ 0,
+ getString("_UI_CreateModelError_message", resource.getURI()),
+ new Object[] { exception });
+ }
+ else {
+ return Diagnostic.OK_INSTANCE;
+ }
+ }
+
+ /**
+ * This is the method used by the framework to install your own controls.
+ */
+ @Override
+ public void createPages() {
+ // Creates the model from the editor input
+ //
+ createModel();
+
+ // Only creates the other pages if there is something that can be edited
+ //
+ if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
+ // Create a page for the selection tree view.
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ selectionViewer = (TreeViewer)viewerPane.getViewer();
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
+ viewerPane.setTitle(editingDomain.getResourceSet());
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_SelectionPage_label"));
+ }
+
+ // Create a page for the parent tree view.
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ parentViewer = (TreeViewer)viewerPane.getViewer();
+ parentViewer.setAutoExpandLevel(30);
+ parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
+ parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(parentViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ParentPage_label"));
+ }
+
+ // This is the page for the list viewer
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new ListViewer(composite);
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ listViewer = (ListViewer)viewerPane.getViewer();
+ listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(listViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_ListPage_label"));
+ }
+
+ // This is the page for the tree viewer
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ treeViewer = (TreeViewer)viewerPane.getViewer();
+ treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(treeViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreePage_label"));
+ }
+
+ // This is the page for the table viewer.
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TableViewer(composite);
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+ tableViewer = (TableViewer)viewerPane.getViewer();
+
+ Table table = tableViewer.getTable();
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn objectColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(3, 100, true));
+ objectColumn.setText(getString("_UI_ObjectColumn_label"));
+ objectColumn.setResizable(true);
+
+ TableColumn selfColumn = new TableColumn(table, SWT.NONE);
+ layout.addColumnData(new ColumnWeightData(2, 100, true));
+ selfColumn.setText(getString("_UI_SelfColumn_label"));
+ selfColumn.setResizable(true);
+
+ tableViewer.setColumnProperties(new String [] {"a", "b"});
+ tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(tableViewer);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TablePage_label"));
+ }
+
+ // This is the page for the table tree viewer.
+ //
+ {
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), ArchitectureEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ return new TreeViewer(composite);
+ }
+ @Override
+ public void requestActivation() {
+ super.requestActivation();
+ setCurrentViewerPane(this);
+ }
+ };
+ viewerPane.createControl(getContainer());
+
+ treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
+
+ Tree tree = treeViewerWithColumns.getTree();
+ tree.setLayoutData(new FillLayout());
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
+ objectColumn.setText(getString("_UI_ObjectColumn_label"));
+ objectColumn.setResizable(true);
+ objectColumn.setWidth(250);
+
+ TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
+ selfColumn.setText(getString("_UI_SelfColumn_label"));
+ selfColumn.setResizable(true);
+ selfColumn.setWidth(200);
+
+ treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"});
+ treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+
+ createContextMenuFor(treeViewerWithColumns);
+ int pageIndex = addPage(viewerPane.getControl());
+ setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
+ }
+
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ setActivePage(0);
+ }
+ });
+ }
+
+ // Ensures that this editor will only display the page's tab
+ // area if there are more than one page
+ //
+ getContainer().addControlListener
+ (new ControlAdapter() {
+ boolean guard = false;
+ @Override
+ public void controlResized(ControlEvent event) {
+ if (!guard) {
+ guard = true;
+ hideTabs();
+ guard = false;
+ }
+ }
+ });
+
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ updateProblemIndication();
+ }
+ });
+ }
+
+ /**
+ * If there is just one page in the multi-page editor part,
+ * this hides the single tab at the bottom.
+ */
+ protected void hideTabs() {
+ if (getPageCount() <= 1) {
+ setPageText(0, "");
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(1);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y + 6);
+ }
+ }
+ }
+
+ /**
+ * If there is more than one page in the multi-page editor part,
+ * this shows the tabs at the bottom.
+ */
+ protected void showTabs() {
+ if (getPageCount() > 1) {
+ setPageText(0, getString("_UI_SelectionPage_label"));
+ if (getContainer() instanceof CTabFolder) {
+ ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
+ Point point = getContainer().getSize();
+ getContainer().setSize(point.x, point.y - 6);
+ }
+ }
+ }
+
+ /**
+ * This is used to track the active viewer.
+ */
+ @Override
+ protected void pageChange(int pageIndex) {
+ super.pageChange(pageIndex);
+
+ if (contentOutlinePage != null) {
+ handleContentOutlineSelection(contentOutlinePage.getSelection());
+ }
+ }
+
+ /**
+ * This is how the framework determines which interfaces we implement.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public Object getAdapter(Class key) {
+ if (key.equals(IContentOutlinePage.class)) {
+ return showOutlineView() ? getContentOutlinePage() : null;
+ }
+ else if (key.equals(IPropertySheetPage.class)) {
+ return getPropertySheetPage();
+ }
+ else if (key.equals(IGotoMarker.class)) {
+ return this;
+ }
+ else {
+ return super.getAdapter(key);
+ }
+ }
+
+ /**
+ * This accesses a cached version of the content outliner.
+ */
+ public IContentOutlinePage getContentOutlinePage() {
+ if (contentOutlinePage == null) {
+ // The content outline is just a tree.
+ //
+ class MyContentOutlinePage extends ContentOutlinePage {
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ contentOutlineViewer.setInput(editingDomain.getResourceSet());
+
+ // Make sure our popups work.
+ //
+ createContextMenuFor(contentOutlineViewer);
+
+ if (!editingDomain.getResourceSet().getResources().isEmpty()) {
+ // Select the root object in the view.
+ //
+ contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
+ }
+ }
+
+ @Override
+ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
+ super.makeContributions(menuManager, toolBarManager, statusLineManager);
+ contentOutlineStatusLineManager = statusLineManager;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ }
+
+ contentOutlinePage = new MyContentOutlinePage();
+
+ // Listen to selection so that we can handle it is a special way.
+ //
+ contentOutlinePage.addSelectionChangedListener
+ (new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ }
+
+ return contentOutlinePage;
+ }
+
+ /**
+ * This accesses a cached version of the property sheet.
+ */
+ public IPropertySheetPage getPropertySheetPage() {
+ PropertySheetPage propertySheetPage =
+ new ExtendedPropertySheetPage(editingDomain) {
+ @Override
+ public void setSelectionToViewer(List<?> selection) {
+ ArchitectureEditor.this.setSelectionToViewer(selection);
+ ArchitectureEditor.this.setFocus();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ };
+ propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+ propertySheetPages.add(propertySheetPage);
+
+ return propertySheetPage;
+ }
+
+ /**
+ * This deals with how we want selection in the outliner to affect the other views.
+ */
+ public void handleContentOutlineSelection(ISelection selection) {
+ if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
+ if (selectedElements.hasNext()) {
+ // Get the first selected element.
+ //
+ Object selectedElement = selectedElements.next();
+
+ // If it's the selection viewer, then we want it to select the same selection as this selection.
+ //
+ if (currentViewerPane.getViewer() == selectionViewer) {
+ ArrayList<Object> selectionList = new ArrayList<Object>();
+ selectionList.add(selectedElement);
+ while (selectedElements.hasNext()) {
+ selectionList.add(selectedElements.next());
+ }
+
+ // Set the selection to the widget.
+ //
+ selectionViewer.setSelection(new StructuredSelection(selectionList));
+ }
+ else {
+ // Set the input to the widget.
+ //
+ if (currentViewerPane.getViewer().getInput() != selectedElement) {
+ currentViewerPane.getViewer().setInput(selectedElement);
+ currentViewerPane.setTitle(selectedElement);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply tests the command stack.
+ */
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
+
+ // Do the work within an operation because this is a long running activity that modifies the workbench.
+ //
+ WorkspaceModifyOperation operation =
+ new WorkspaceModifyOperation() {
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for (Resource resource : editingDomain.getResourceSet().getResources()) {
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ }
+ catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+
+ /**
+ * This returns whether something has been persisted to the URI of the specified resource.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ */
+ protected boolean isPersisted(Resource resource) {
+ boolean result = false;
+ try {
+ InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
+ if (stream != null) {
+ result = true;
+ stream.close();
+ }
+ }
+ catch (IOException e) {
+ // Ignore
+ }
+ return result;
+ }
+
+ /**
+ * This always returns true because it is not currently supported.
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * This also changes the editor's input.
+ */
+ @Override
+ public void doSaveAs() {
+ SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
+ saveAsDialog.open();
+ IPath path = saveAsDialog.getResult();
+ if (path != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
+ }
+ }
+ }
+
+ protected void doSaveAs(URI uri, IEditorInput editorInput) {
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ IProgressMonitor progressMonitor =
+ getActionBars().getStatusLineManager() != null ?
+ getActionBars().getStatusLineManager().getProgressMonitor() :
+ new NullProgressMonitor();
+ doSave(progressMonitor);
+ }
+
+ public void gotoMarker(IMarker marker) {
+ List<?> targetObjects = markerHelper.getTargetObjects(editingDomain, marker);
+ if (!targetObjects.isEmpty()) {
+ setSelectionToViewer(targetObjects);
+ }
+ }
+
+ /**
+ * This is called during startup.
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) {
+ setSite(site);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ site.setSelectionProvider(this);
+ site.getPage().addPartListener(partListener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+ }
+
+ @Override
+ public void setFocus() {
+ if (currentViewerPane != null) {
+ currentViewerPane.setFocus();
+ }
+ else {
+ getControl(getActivePage()).setFocus();
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
+ */
+ public ISelection getSelection() {
+ return editorSelection;
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
+ * Calling this result will notify the listeners.
+ */
+ public void setSelection(ISelection selection) {
+ editorSelection = selection;
+
+ for (ISelectionChangedListener listener : selectionChangedListeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ setStatusLineManager(selection);
+ }
+
+ public void setStatusLineManager(ISelection selection) {
+ IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ?
+ contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
+
+ if (statusLineManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> collection = ((IStructuredSelection)selection).toList();
+ switch (collection.size()) {
+ case 0: {
+ statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
+ break;
+ }
+ case 1: {
+ String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
+ statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
+ break;
+ }
+ default: {
+ statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
+ break;
+ }
+ }
+ }
+ else {
+ statusLineManager.setMessage("");
+ }
+ }
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ */
+ private static String getString(String key) {
+ return ArchitectureUIPlugin.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ */
+ private static String getString(String key, Object s1) {
+ return ArchitectureUIPlugin.INSTANCE.getString(key, new Object [] { s1 });
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ */
+ public void menuAboutToShow(IMenuManager menuManager) {
+ ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ }
+
+ public EditingDomainActionBarContributor getActionBarContributor() {
+ return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
+ }
+
+ public IActionBars getActionBars() {
+ return getActionBarContributor().getActionBars();
+ }
+
+ public AdapterFactory getAdapterFactory() {
+ return adapterFactory;
+ }
+
+ @Override
+ public void dispose() {
+ updateProblemIndication = false;
+
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ getSite().getPage().removePartListener(partListener);
+
+ adapterFactory.dispose();
+
+ if (getActionBarContributor().getActiveEditor() == this) {
+ getActionBarContributor().setActiveEditor(null);
+ }
+
+ for (PropertySheetPage propertySheetPage : propertySheetPages) {
+ propertySheetPage.dispose();
+ }
+
+ if (contentOutlinePage != null) {
+ contentOutlinePage.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * Returns whether the outline view should be presented to the user.
+ */
+ protected boolean showOutlineView() {
+ return true;
+ }
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureModelWizard.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureModelWizard.java
new file mode 100644
index 00000000000..2159daf94b0
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureModelWizard.java
@@ -0,0 +1,518 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.editor;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.CommonPlugin;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+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.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.papyrus.infra.core.architecture.ArchitectureFactory;
+import org.eclipse.papyrus.infra.core.architecture.ArchitecturePackage;
+import org.eclipse.papyrus.infra.core.architecture.provider.ArchitectureEditPlugin;
+import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+
+/**
+ * This is the wizard for creating a new architecture model file.
+ *
+ * @since 1.0
+*/
+public class ArchitectureModelWizard extends Wizard implements INewWizard {
+ /**
+ * The supported extensions for created files.
+ */
+ public static final List<String> FILE_EXTENSIONS =
+ Collections.unmodifiableList(Arrays.asList(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureEditorFilenameExtensions").split("\\s*,\\s*")));
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS =
+ ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
+
+ /**
+ * This caches an instance of the model package.
+ */
+ protected ArchitecturePackage architecturePackage = ArchitecturePackage.eINSTANCE;
+
+ /**
+ * This caches an instance of the model factory.
+ */
+ protected ArchitectureFactory architectureFactory = architecturePackage.getArchitectureFactory();
+
+ /**
+ * This is the file creation page.
+ */
+ protected ArchitectureModelWizardNewFileCreationPage newFileCreationPage;
+
+ /**
+ * This is the initial object creation page.
+ */
+ protected ArchitectureModelWizardInitialObjectCreationPage initialObjectCreationPage;
+
+ /**
+ * Remember the selection during initialization for populating the default container.
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * Remember the workbench during initialization.
+ */
+ protected IWorkbench workbench;
+
+ /**
+ * Caches the names of the types that can be created as the root object.
+ */
+ protected List<String> initialObjectNames;
+
+ /**
+ * This just records the information.
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(ArchitectureUIPlugin.INSTANCE.getString("_UI_Wizard_label"));
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ArchitectureUIPlugin.INSTANCE.getImage("full/wizban/NewArchitecture")));
+ }
+
+ /**
+ * Returns the names of the types that can be created as the root object.
+ */
+ protected Collection<String> getInitialObjectNames() {
+ if (initialObjectNames == null) {
+ initialObjectNames = new ArrayList<String>();
+ for (EClassifier eClassifier : architecturePackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract()) {
+ initialObjectNames.add(eClass.getName());
+ }
+ }
+ }
+ Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
+ }
+ return initialObjectNames;
+ }
+
+ /**
+ * Create a new model.
+ */
+ protected EObject createInitialModel() {
+ EClass eClass = (EClass)architecturePackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
+ EObject rootObject = architectureFactory.create(eClass);
+ return rootObject;
+ }
+
+ /**
+ * Do the work after everything is specified.
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation =
+ new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ resource.save(options);
+ }
+ catch (Exception exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ }
+ finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor
+ (new FileEditorInput(modelFile),
+ workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
+ }
+ catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), ArchitectureUIPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+ catch (Exception exception) {
+ ArchitectureUIPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ /**
+ * This is the one page of the wizard.
+ */
+ public class ArchitectureModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Pass in the selection.
+ */
+ public ArchitectureModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ */
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
+ setErrorMessage(ArchitectureUIPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
+ }
+ }
+
+ /**
+ * This is the page where the type of object to create is selected.
+ */
+ public class ArchitectureModelWizardInitialObjectCreationPage extends WizardPage {
+ protected Combo initialObjectField;
+
+ protected List<String> encodings;
+
+ protected Combo encodingField;
+
+ /**
+ * Pass in the selection.
+ */
+ public ArchitectureModelWizardInitialObjectCreationPage(String pageId) {
+ super(pageId);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 12;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ }
+
+ Label containerLabel = new Label(composite, SWT.LEFT);
+ {
+ containerLabel.setText(ArchitectureUIPlugin.INSTANCE.getString("_UI_ModelObject"));
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ containerLabel.setLayoutData(data);
+ }
+
+ initialObjectField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ initialObjectField.setLayoutData(data);
+ }
+
+ for (String objectName : getInitialObjectNames()) {
+ initialObjectField.add(getLabel(objectName));
+ }
+
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.select(0);
+ }
+ initialObjectField.addModifyListener(validator);
+
+ Label encodingLabel = new Label(composite, SWT.LEFT);
+ {
+ encodingLabel.setText(ArchitectureUIPlugin.INSTANCE.getString("_UI_XMLEncoding"));
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ encodingLabel.setLayoutData(data);
+ }
+ encodingField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ encodingField.setLayoutData(data);
+ }
+
+ for (String encoding : getEncodings()) {
+ encodingField.add(encoding);
+ }
+
+ encodingField.select(0);
+ encodingField.addModifyListener(validator);
+
+ setPageComplete(validatePage());
+ setControl(composite);
+ }
+
+ protected ModifyListener validator =
+ new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ };
+
+ protected boolean validatePage() {
+ return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.clearSelection();
+ encodingField.setFocus();
+ }
+ else {
+ encodingField.clearSelection();
+ initialObjectField.setFocus();
+ }
+ }
+ }
+
+ public String getInitialObjectName() {
+ String label = initialObjectField.getText();
+
+ for (String name : getInitialObjectNames()) {
+ if (getLabel(name).equals(label)) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ public String getEncoding() {
+ return encodingField.getText();
+ }
+
+ /**
+ * Returns the label for the specified type name.
+ */
+ protected String getLabel(String typeName) {
+ try {
+ return ArchitectureEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
+ }
+ catch(MissingResourceException mre) {
+ ArchitectureUIPlugin.INSTANCE.log(mre);
+ }
+ return typeName;
+ }
+
+ protected Collection<String> getEncodings() {
+ if (encodings == null) {
+ encodings = new ArrayList<String>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(ArchitectureUIPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
+ encodings.add(stringTokenizer.nextToken());
+ }
+ }
+ return encodings;
+ }
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ */
+ @Override
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ newFileCreationPage = new ArchitectureModelWizardNewFileCreationPage("Whatever", selection);
+ newFileCreationPage.setTitle(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureModelWizard_label"));
+ newFileCreationPage.setDescription(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureModelWizard_description"));
+ newFileCreationPage.setFileName(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
+ addPage(newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureEditorFilenameDefaultBase");
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
+ }
+ newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ initialObjectCreationPage = new ArchitectureModelWizardInitialObjectCreationPage("Whatever2");
+ initialObjectCreationPage.setTitle(ArchitectureUIPlugin.INSTANCE.getString("_UI_ArchitectureModelWizard_label"));
+ initialObjectCreationPage.setDescription(ArchitectureUIPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
+ addPage(initialObjectCreationPage);
+ }
+
+ /**
+ * Get the file from the page.
+ */
+ public IFile getModelFile() {
+ return newFileCreationPage.getModelFile();
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java
new file mode 100644
index 00000000000..a9c42d6db76
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java
@@ -0,0 +1,204 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.handlers;
+
+import java.util.Arrays;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDescriptionUtils;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin;
+import org.eclipse.papyrus.infra.ui.architecture.widgets.ArchitectureContextComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * A command handler for changing architecture context in a model set
+ *
+ * @since 1.0
+ */
+public class ChangeArchitectureContextHandler extends AbstractHandler {
+
+ private final static String DIALOG_SECTION = ChangeArchitectureContextHandler.class.getName();
+
+ /**
+ * Constructor.
+ */
+ public ChangeArchitectureContextHandler() {
+ // nothing by default
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ EObject selection = getSelection(event);
+ if (selection == null)
+ return new IContributionItem[0];
+ ResourceSet resourceSet = selection.eResource().getResourceSet();
+ if (!(resourceSet instanceof ModelSet))
+ return new IContributionItem[0];
+ final ArchitectureDescriptionUtils helper = new ArchitectureDescriptionUtils((ModelSet)resourceSet);
+ String[] contextIds = new String[] {helper.getArchitectureContextId()};
+ String[] viewpointIds = helper.getArchitectureViewpointIds().toArray(new String[0]);
+
+ final Shell shell = Display.getCurrent().getActiveShell();
+ ArchitectureContextDialog dialog = new ArchitectureContextDialog(shell);
+ dialog.setSelectedContexts(contextIds);
+ dialog.setSelectedViewpoints(viewpointIds);
+ dialog.create();
+
+ if (dialog.open() == Window.OK) {
+ TransactionalEditingDomain dom = helper.getModelSet().getTransactionalEditingDomain();
+ CompoundCommand cmd = new CompoundCommand("Change Architecture Context");
+ if (!Arrays.equals(dialog.getSelectedContextIds(), contextIds)) {
+ cmd.append(helper.switchArchitectureContextId(dialog.getSelectedContextIds()[0]));
+ }
+ if (!Arrays.equals(dialog.getSelectedViewpointIds(), viewpointIds)) {
+ cmd.append(helper.switchArchitectureViewpointIds(dialog.getSelectedViewpointIds()));
+ }
+ if (!cmd.isEmpty()) {
+ dom.getCommandStack().execute(cmd);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets the current selection as an EObject
+ *
+ * @return The current selection, or <code>null</code> if it is not an EObject
+ */
+ protected EObject getSelection(ExecutionEvent event) {
+ Object selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection struct = (IStructuredSelection) selection;
+ Object obj = struct.getFirstElement();
+ return EMFHelper.getEObject(obj);
+ }
+ return null;
+ }
+
+ /**
+ * A dialog to allow choosing a new architecture context and viewpoints
+ */
+ private class ArchitectureContextDialog extends Dialog {
+
+ private String[] originalContextIds;
+
+ private String[] selectedContextIds;
+
+ private String[] selectedViewpointIds;
+
+ protected ArchitectureContextDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public String[] getSelectedContextIds() {
+ return selectedContextIds;
+ }
+
+ public String[] getSelectedViewpointIds() {
+ return selectedViewpointIds;
+ }
+
+ public void setSelectedContexts(String[] selectedContextIds) {
+ this.selectedContextIds = selectedContextIds;
+ this.originalContextIds = selectedContextIds;
+ }
+
+ public void setSelectedViewpoints(String[] selectedViewpointIds) {
+ this.selectedViewpointIds = selectedViewpointIds;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Label label = new Label(container, SWT.NONE);
+ label.setText("Switch the architecture context and/or viewpoints applied to the Papyrus model:");
+
+ ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance();
+
+ ArchitectureContextComposite acc = new ArchitectureContextComposite(container, 1, 1, GridData.FILL_BOTH, 0, 0);
+ acc.setAllowSeveralContexts(false);
+ acc.setSelectedContexts(selectedContextIds);
+ acc.setSelectedViewpoints(selectedViewpointIds);
+ acc.setInput(manager.getVisibleArchitectureContexts().toArray(new MergedArchitectureContext[0]));
+ acc.setUpdater(new ArchitectureContextComposite.Updater() {
+ @Override
+ public void update() {
+ selectedContextIds = acc.getSelectedContexts();
+ selectedViewpointIds = acc.getSelectedViewpoints();
+ }
+ });
+
+ return container;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Switch Architecture Context");
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ IDialogSettings globalSettings = ArchitectureUIPlugin.getPlugin().getDialogSettings();
+ IDialogSettings dialogSettings = globalSettings.getSection(DIALOG_SECTION);
+ if (dialogSettings == null) {
+ dialogSettings = globalSettings.addNewSection(DIALOG_SECTION);
+ }
+ return dialogSettings;
+ }
+
+ @Override
+ protected void okPressed() {
+ if (!Arrays.equals(getSelectedContextIds(), originalContextIds)) {
+ MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
+ messageBox.setMessage("Changing the architecture context may cause significant changes to the model.\nDo you like to proceed?");
+ messageBox.setText("Warning");
+ int response = messageBox.open();
+ if (response != SWT.YES)
+ return;
+ }
+ super.okPressed();
+ }
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureViewpointsHandler.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureViewpointsHandler.java
new file mode 100644
index 00000000000..00affdd915b
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureViewpointsHandler.java
@@ -0,0 +1,118 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.handlers;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureViewpoint;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDescriptionUtils;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+/**
+ * A command handler for changing architecture viewpoints in a model set
+ *
+ * @since 1.0
+ */
+public class ChangeArchitectureViewpointsHandler extends CompoundContributionItem {
+
+ // the label provider for architecture viewpoints
+ private ILabelProvider provider;
+
+ public ChangeArchitectureViewpointsHandler() {
+ ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ provider = new AdapterFactoryLabelProvider(composedAdapterFactory);
+ }
+
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ final EObject selection = getSelection();
+ if (selection == null)
+ return new IContributionItem[0];
+ ResourceSet resourceSet = selection.eResource().getResourceSet();
+ if (!(resourceSet instanceof ModelSet))
+ return new IContributionItem[0];
+ final ArchitectureDescriptionUtils helper = new ArchitectureDescriptionUtils((ModelSet)resourceSet);
+ MergedArchitectureContext context = helper.getArchitectureContext();
+ final Set<String> viewpointIds = new HashSet<String>(helper.getArchitectureViewpointIds());
+
+ List<IContributionItem> items = new ArrayList<IContributionItem>();
+ for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) {
+ Object imageObject = viewpoint.getImageObject();
+ ImageDescriptor desc = ExtendedImageRegistry.getInstance().getImageDescriptor(provider.getImage(imageObject));
+ items.add(new ActionContributionItem(new Action(viewpoint.getName(), desc) {
+ {
+ setChecked(viewpointIds.contains(viewpoint.getId()));
+ }
+ @Override
+ public void run() {
+ if (!isChecked())
+ viewpointIds.remove(viewpoint.getId());
+ else
+ viewpointIds.add(viewpoint.getId());
+ TransactionalEditingDomain ted = helper.getModelSet().getTransactionalEditingDomain();
+ Command cmd = helper.switchArchitectureViewpointIds(viewpointIds.toArray(new String[0]));
+ ted.getCommandStack().execute(cmd);
+ }
+ }));
+ }
+ return items.toArray(new IContributionItem[0]);
+ }
+
+ /**
+ * Gets the current selection as an EObject
+ *
+ * @return The current selection, or <code>null</code> if it is not an EObject
+ */
+ protected EObject getSelection() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection == null) {
+ return null;
+ }
+ if (selection.isEmpty()) {
+ return null;
+ }
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection struct = (IStructuredSelection) selection;
+ Object obj = struct.getFirstElement();
+ return EMFHelper.getEObject(obj);
+ }
+ return null;
+ }
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/navigator/ViewpointFilter.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/navigator/ViewpointFilter.java
new file mode 100644
index 00000000000..f7aa52d6320
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/navigator/ViewpointFilter.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.navigator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractTreeFilter;
+
+/**
+ * A tree filter for representations (diagrams, tables) based on active viewpoints in a model set
+ *
+ * @since 1.0
+ */
+public class ViewpointFilter extends AbstractTreeFilter {
+
+ public ViewpointFilter() {
+ super();
+ useCache = false;//don't cache
+ }
+
+ /**
+ * hide a representation when it's not supported by the active viewpoints
+ */
+ @Override
+ public boolean isVisible(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof EObjectTreeElement) {
+ EObject eObj = ((EObjectTreeElement)element).getEObject();
+ if (eObj instanceof Diagram || eObj instanceof Table) {
+ return ViewPrototype.get(eObj) != ViewPrototype.UNAVAILABLE_VIEW;
+ }
+ }
+ return true;
+ }
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java
new file mode 100755
index 00000000000..13e5d6f60b2
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureContextPreferencePage.java
@@ -0,0 +1,433 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.preferences;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedADElement;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureDomain;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainPreferences;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainMerger;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.TextStyle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+
+/**
+ * Represents the preference page for the architecture contexts
+ *
+ * @since 1.0
+ */
+public class ArchitectureContextPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ // The ID of this preference page used to contribute via extension
+ public static final String PAGE_ID = ArchitectureContextPreferencePage.class.getName();
+
+ //A bold style
+ private static final Styler BOLD_FONT_STYLER = new Styler() {
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ FontDescriptor boldDescriptor = FontDescriptor.createFrom(new FontData()).setStyle(SWT.BOLD);
+ Font boldFont = boldDescriptor.createFont(Display.getCurrent());
+ textStyle.font = boldFont;
+ }
+ };
+
+ // Contexts viewer
+ private CheckboxTreeViewer fContextsViewer;
+ // Text displaying additional information
+ private ListViewer fDescription;
+ // Adapter Factory
+ private ComposedAdapterFactory fComposedAdapterFactory;
+
+ // Buttons
+ private Button fOtherButton;
+ private Button fDefaultButton;
+
+ // the architecture domain model merger
+ ArchitectureDomainMerger fMerger;
+
+ //Preferences
+ ArchitectureDomainPreferences fPreferences;
+
+ /**
+ * Constructor.
+ */
+ public ArchitectureContextPreferencePage() {
+ fComposedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ fMerger = ArchitectureDomainManager.getInstance().getMerger().clone();
+ fPreferences = ArchitectureDomainManager.getInstance().getPreferences().clone();
+ }
+
+ @Override
+ public Control createContents(Composite parent) {
+ Composite container = createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
+ createArchitectureContextsGroup(container);
+ Dialog.applyDialogFont(container);
+ return container;
+ }
+
+ /**
+ * Creates the Architecture Context group in the page
+ */
+ private void createArchitectureContextsGroup(Composite container) {
+ Composite comp = createComposite(container, 1, 1, GridData.FILL_BOTH, 0, 0);
+ ((GridData) comp.getLayoutData()).widthHint = 350;
+ createWrapLabel(comp, "Select the architecture contexts that can be applied to Papyrus models:", 2);
+ createVerticalSpacer(comp, 1);
+
+ Composite tableComposite = createComposite(comp, 2, 1, GridData.FILL_BOTH, 0, 0);
+ createLabel(tableComposite, "Architecture Contexts:", 2);
+
+ fContextsViewer = new ContainerCheckedTreeViewer(tableComposite, SWT.MULTI | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 250;
+ fContextsViewer.getControl().setLayoutData(gd);
+
+ final IStyledLabelProvider labelProvider = new AdapterFactoryLabelProvider.StyledLabelProvider(fComposedAdapterFactory, fContextsViewer) {
+ @Override
+ public StyledString getStyledText(Object object) {
+ MergedADElement element = (MergedADElement) object;
+ if (element instanceof MergedArchitectureContext) {
+ MergedArchitectureContext context = (MergedArchitectureContext)element;
+ if (context.getId() != null && context.getId().equals(fPreferences.getDefaultContextId()))
+ return new StyledString(element.getName(), BOLD_FONT_STYLER);
+ }
+ return new StyledString(element.getName());
+ }
+ @Override
+ public Image getImage(Object object) {
+ MergedADElement element = (MergedADElement) object;
+ return super.getImage(element.getImageObject());
+ }
+ };
+
+ fContextsViewer.setContentProvider(new ITreeContentProvider() {
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof MergedArchitectureDomain) {
+ return !((MergedArchitectureDomain)element).getContexts().isEmpty();
+ }
+ return false;
+ }
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+ @Override
+ public Object[] getElements(Object inputElement) {
+ Collection<MergedArchitectureDomain> domains = ((ArchitectureDomainMerger)inputElement).getDomains();
+ return domains.toArray();
+ }
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof MergedArchitectureDomain) {
+ Collection<MergedArchitectureContext> contexts = ((MergedArchitectureDomain)parentElement).getContexts();
+ return contexts.toArray();
+ }
+ return null;
+ }
+ });
+ fContextsViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider));
+ fContextsViewer.setComparator(new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ String name1 = labelProvider.getStyledText(e1).getString();
+ String name2 = labelProvider.getStyledText(e2).getString();
+ return getComparator().compare(name1, name2);
+ }
+ });
+ fContextsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateButtons();
+ updateDetails();
+ }
+ });
+ fContextsViewer.setCheckStateProvider(new ICheckStateProvider() {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ @Override
+ public boolean isChecked(Object element) {
+ if (element instanceof MergedArchitectureContext)
+ return !fPreferences.getExcludedContextIds().contains(((MergedArchitectureContext)element).getId());
+ else
+ return fContextsViewer.getChecked(element);
+ }
+ });
+ fContextsViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Collection<MergedArchitectureContext> contexts = null;
+ if (event.getElement() instanceof MergedArchitectureContext)
+ contexts = Collections.singletonList((MergedArchitectureContext) event.getElement());
+ else
+ contexts = ((MergedArchitectureDomain)event.getElement()).getContexts();
+ for (MergedArchitectureContext context : contexts) {
+ if (event.getChecked() == false)
+ fPreferences.getExcludedContextIds().add(context.getId());
+ else
+ fPreferences.getExcludedContextIds().remove(context.getId());
+ }
+ }
+ });
+ fContextsViewer.setInput(fMerger);
+ fContextsViewer.expandAll();
+
+ ColumnViewerToolTipSupport.enableFor(fContextsViewer, ToolTip.NO_RECREATE);
+
+ Composite buttonComposite = createComposite(tableComposite, 1, 1, GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING, 0, 0);
+ createVerticalSpacer(buttonComposite, 1);
+
+ fOtherButton = createPushButton(buttonComposite, "Other Architecture Models...", null, SWT.PUSH);
+ fOtherButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleOther();
+ }
+ });
+
+ fDefaultButton = createPushButton(buttonComposite, "Make Default", null, SWT.PUSH);
+ fDefaultButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleDefault();
+ }
+ });
+
+ updateButtons();
+
+ Composite descriptionComposite = createComposite(comp, 1, 1, GridData.FILL_HORIZONTAL, 0, 0);
+
+ createLabel(descriptionComposite, "Description:", 1);
+
+ fDescription = new ListViewer(descriptionComposite);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 50;
+ fDescription.getControl().setLayoutData(gd);
+ fDescription.setContentProvider(new IStructuredContentProvider() {
+ private Object input;
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.input = newInput;
+ }
+ public void dispose() {
+ }
+ public Object[] getElements(Object inputElement) {
+ return new Object[] {input};
+ }
+ });
+ fDescription.setLabelProvider(new LabelProvider() {
+ public String getText(Object element) {
+ return ((MergedADElement)element).getDesciption();
+ }
+ });
+ }
+
+ /**
+ * Handles the selection of other models by merging them
+ */
+ private void handleOther() {
+ ArchitectureModelSelectDialog dialog = new ArchitectureModelSelectDialog(getShell(), "File Selection", fPreferences.getAddedModelURIs().toArray(new String[0]));
+ dialog.open();
+ List<URI> files = dialog.getURIs();
+ fPreferences.getAddedModelURIs().clear();
+ for (URI file : files) {
+ fPreferences.getAddedModelURIs().add(file.toString());
+ }
+ fMerger.setPreferenceModels(files);
+ fContextsViewer.refresh();
+ fContextsViewer.expandAll();
+ }
+
+ /**
+ * Handles the default button by setting the selected context as default
+ */
+ protected void handleDefault() {
+ IStructuredSelection selection = (IStructuredSelection) fContextsViewer.getSelection();
+ MergedArchitectureContext selected = (MergedArchitectureContext) selection.getFirstElement();
+ fPreferences.setDefaultContextId(selected.getId());
+ fContextsViewer.refresh();
+ }
+
+ /**
+ * Update the enabled state of the buttons
+ */
+ protected void updateButtons() {
+ IStructuredSelection selection = (IStructuredSelection) fContextsViewer.getSelection();
+ if (selection.size() == 1) {
+ MergedADElement selected = (MergedADElement) selection.getFirstElement();
+ if (selected instanceof MergedArchitectureContext) {
+ fDefaultButton.setEnabled(true);
+ //ArchitectureContext context = (ArchitectureContext)selected;
+ //fDefaultButton.setSelection(context.getId().equals(fPreferences.getDefaultContextId()));
+ return;
+ }
+ }
+ fDefaultButton.setEnabled(false);
+ fDefaultButton.setSelection(false);
+ }
+
+ /**
+ * Updates the details text box with information about the currently selected target
+ */
+ protected void updateDetails() {
+ IStructuredSelection selection = (IStructuredSelection) fContextsViewer.getSelection();
+ if (selection.size() == 1) {
+ MergedADElement selected = (MergedADElement) selection.getFirstElement();
+ fDescription.setInput(selected);
+ } else {
+ fDescription.setInput(null);
+ }
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ public void performDefaults() {
+ fPreferences.reset();
+ fContextsViewer.refresh();
+ }
+
+ @Override
+ public boolean performOk() {
+ fPreferences.write();
+ return true;
+ }
+
+ private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth, int marginheight) {
+ Composite g = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(columns, false);
+ layout.marginWidth = marginwidth;
+ layout.marginHeight = marginheight;
+ g.setLayout(layout);
+ g.setFont(parent.getFont());
+ GridData gd = new GridData(fill);
+ gd.horizontalSpan = hspan;
+ g.setLayoutData(gd);
+ return g;
+ }
+
+ private static Label createLabel(Composite parent, String text, int hspan) {
+ Label l = new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ gd.grabExcessHorizontalSpace = false;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+ private static Label createWrapLabel(Composite parent, String text, int hspan) {
+ Label l = new Label(parent, SWT.NONE | SWT.WRAP);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+ private static void createVerticalSpacer(Composite parent, int numlines) {
+ Label lbl = new Label(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ Layout layout = parent.getLayout();
+ if (layout instanceof GridLayout) {
+ gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
+ }
+ gd.heightHint = numlines;
+ lbl.setLayoutData(gd);
+ }
+
+ private static Button createPushButton(Composite parent, String label, Image image, int style) {
+ Button button = new Button(parent, style);
+ button.setFont(parent.getFont());
+ if (image != null) {
+ button.setImage(image);
+ }
+ if (label != null) {
+ button.setText(label);
+ }
+ GridData gd = new GridData();
+ button.setLayoutData(gd);
+ setButtonDimensionHint(button);
+ return button;
+ }
+
+ private static void setButtonDimensionHint(Button button) {
+ Assert.isNotNull(button);
+ Object gd = button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData) gd).widthHint = getButtonWidthHint(button);
+ ((GridData) gd).horizontalAlignment = GridData.FILL;
+ }
+ }
+
+ private static int getButtonWidthHint(Button button) {
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter = new PixelConverter(button);
+ int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureModelSelectDialog.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureModelSelectDialog.java
new file mode 100644
index 00000000000..4cfa56fed22
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/preferences/ArchitectureModelSelectDialog.java
@@ -0,0 +1,234 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.common.EMFPlugin;
+import org.eclipse.emf.common.ui.CommonUIPlugin;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A dialog to select architecture models from the file system or workspace by URIs
+ *
+ * @since 1.0
+ */
+public class ArchitectureModelSelectDialog extends Dialog {
+ protected static final int CONTROL_OFFSET = 10;
+ protected String title;
+ protected int style;
+ protected Text uriField;
+ protected String uriText;
+ protected String[] initialSelection;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * @param title
+ * @param initialSelection
+ */
+ public ArchitectureModelSelectDialog(Shell parent, String title, String[] initialSelection) {
+ super(parent);
+ this.title = title != null ? title : CommonUIPlugin.INSTANCE.getString("_UI_ResourceDialog_title");
+ this.style = SWT.MULTI | SWT.OPEN;
+
+ setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
+ this.initialSelection = initialSelection;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(title);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ {
+ FormLayout layout = new FormLayout();
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ if (!EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) {
+ data.widthHint = 330;
+ }
+ composite.setLayoutData(data);
+ }
+
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+
+ Label resourceURILabel = new Label(composite, SWT.LEFT);
+ {
+ resourceURILabel.setText(
+ CommonUIPlugin.INSTANCE.getString("_UI_ResourceURIs_label"));
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, CONTROL_OFFSET);
+ data.top = new FormAttachment(0, CONTROL_OFFSET);
+ resourceURILabel.setLayoutData(data);
+ }
+
+ {
+ FormData data = new FormData();
+ data.top = new FormAttachment(resourceURILabel, CONTROL_OFFSET, SWT.CENTER);
+ data.left = new FormAttachment(resourceURILabel, CONTROL_OFFSET);
+ data.right = new FormAttachment(100, -CONTROL_OFFSET);
+ buttonComposite.setLayoutData(data);
+
+ buttonComposite.setLayout(new FormLayout());
+ }
+
+ uriField = new Text(composite, SWT.BORDER);
+ {
+ FormData data = new FormData();
+ data.top = new FormAttachment(buttonComposite, CONTROL_OFFSET);
+ data.left = new FormAttachment(0, CONTROL_OFFSET);
+ data.right = new FormAttachment(100, -CONTROL_OFFSET);
+ uriField.setLayoutData(data);
+ uriField.setText(String.join(" ", initialSelection));
+ }
+
+ Button browseFileSystemButton = new Button(buttonComposite, SWT.PUSH);
+ browseFileSystemButton.setText(CommonUIPlugin.INSTANCE.getString("_UI_BrowseFileSystem_label"));
+ prepareBrowseFileSystemButton(browseFileSystemButton);
+
+ if (EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) {
+ Button browseWorkspaceButton = new Button(buttonComposite, SWT.PUSH);
+ {
+ FormData data = new FormData();
+ data.right = new FormAttachment(100);
+ browseWorkspaceButton.setLayoutData(data);
+ }
+ {
+ FormData data = new FormData();
+ data.right = new FormAttachment(browseWorkspaceButton, -CONTROL_OFFSET);
+ browseFileSystemButton.setLayoutData(data);
+ }
+ browseWorkspaceButton.setText(CommonUIPlugin.INSTANCE.getString("_UI_BrowseWorkspace_label"));
+ prepareBrowseWorkspaceButton(browseWorkspaceButton);
+ } else {
+ FormData data = new FormData();
+ data.right = new FormAttachment(100);
+ browseFileSystemButton.setLayoutData(data);
+ }
+
+ Label separatorLabel = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ {
+ FormData data = new FormData();
+ data.top = new FormAttachment(uriField, (int) (1.5 * CONTROL_OFFSET));
+ data.left = new FormAttachment(0, -CONTROL_OFFSET);
+ data.right = new FormAttachment(100, CONTROL_OFFSET);
+ separatorLabel.setLayoutData(data);
+ }
+
+ composite.setTabList(new Control[] { uriField, buttonComposite });
+ return composite;
+ }
+
+ /**
+ * Configures the Browse File System button
+ * @param browseFileSystemButton
+ */
+ protected void prepareBrowseFileSystemButton(Button browseFileSystemButton) {
+ browseFileSystemButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ FileDialog fileDialog = new FileDialog(getShell(), style);
+ fileDialog.open();
+
+ String filterPath = fileDialog.getFilterPath();
+ String[] fileNames = fileDialog.getFileNames();
+ StringBuffer uris = new StringBuffer();
+
+ for (int i = 0, len = fileNames.length; i < len; i++) {
+ uris.append(URI.createFileURI(filterPath + File.separator + fileNames[i]).toString());
+ uris.append(" ");
+ }
+ uriField.setText((uriField.getText() + " " + uris.toString()).trim());
+ }
+ });
+ }
+
+ /**
+ * Prepares the Browse Workspace button
+ * @param browseWorkspaceButton
+ */
+ protected void prepareBrowseWorkspaceButton(Button browseWorkspaceButton) {
+ browseWorkspaceButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ StringBuffer uris = new StringBuffer();
+
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(), null, null, true,
+ null, null);
+ for (int i = 0, len = files.length; i < len; i++) {
+ uris.append(URI.createPlatformResourceURI(files[i].getFullPath().toString(), true));
+ uris.append(" ");
+ }
+ uriField.setText((uriField.getText() + " " + uris.toString()).trim());
+ }
+ });
+ }
+
+ @Override
+ protected void okPressed() {
+ uriText = getURIText();
+ super.okPressed();
+ }
+
+ /**
+ * @return the value of the model URIs as a string
+ */
+ public String getURIText() {
+ return uriField != null && !uriField.isDisposed() ? uriField.getText() : uriText;
+ }
+
+ /**
+ * @return the value of the model URIs as a list
+ */
+ public List<URI> getURIs() {
+ List<URI> uris = new ArrayList<URI>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(getURIText()); stringTokenizer.hasMoreTokens();) {
+ String uri = stringTokenizer.nextToken();
+ uris.add(URI.createURI(uri));
+ }
+ return uris;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/widgets/ArchitectureContextComposite.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/widgets/ArchitectureContextComposite.java
new file mode 100644
index 00000000000..7b26a867ce6
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/widgets/ArchitectureContextComposite.java
@@ -0,0 +1,374 @@
+/**
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * Maged Elaasar - Initial API and implementation
+ *
+ *
+ */
+package org.eclipse.papyrus.infra.ui.architecture.widgets;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedADElement;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureDomain;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureViewpoint;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+
+/**
+ * A composite widget that shows the visible architecture contexts and their viewpoints
+ * and allows for changing their selection
+ *
+ * @since 1.0
+ */
+public class ArchitectureContextComposite extends Composite {
+
+ /**
+ * An interface for doing updates upon selection changes
+ */
+ public static interface Updater {
+ void update();
+ }
+
+ // allow selection of multiple contexts
+ private boolean allowSeveralContexts;
+
+ // the set of selected contexts
+ private Set<String> selectedContexts;
+
+ // the set of selected viewpoints
+ private Set<String> selectedViewpoints;
+
+ // the viewer for architecture contexts
+ private CheckboxTreeViewer contextsViewer;
+
+ // the viewer for architecture viewpoints
+ private CheckboxTableViewer viewpointViewer;
+
+ // the adapter factory of the architecture metadata
+ private ComposedAdapterFactory composedAdapterFactory;
+
+ // an updater to call upon selection changes
+ private Updater updater;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * @param columns
+ * @param hspan
+ * @param fill
+ * @param marginwidth
+ * @param marginheight
+ */
+ public ArchitectureContextComposite(Composite parent, int columns, int hspan, int fill, int marginwidth, int marginheight) {
+ super(parent, SWT.NONE);
+ layoutComposite(this, parent, columns, hspan, fill, marginwidth, marginheight);
+
+ composedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ Composite tableComposite = createComposite(this, 1, 1, GridData.FILL_BOTH, 0, 0);
+ createLabel(tableComposite, "Architecture Contexts:", 2);
+
+ contextsViewer = new ContainerCheckedTreeViewer(tableComposite, SWT.MULTI | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 250;
+ contextsViewer.getControl().setLayoutData(gd);
+
+ contextsViewer.setContentProvider(new ITreeContentProvider() {
+ private Collection<MergedArchitectureContext> allContexts;
+ @Override
+ public boolean hasChildren(Object element) {
+ return element instanceof MergedArchitectureDomain;
+ }
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+ @Override
+ public Object[] getElements(Object inputElement) {
+ Set<MergedArchitectureDomain> allDomains = new LinkedHashSet<MergedArchitectureDomain>();
+ allContexts = new LinkedHashSet<MergedArchitectureContext>();
+ for (Object obj : ((Object[])inputElement)) {
+ MergedArchitectureContext context = (MergedArchitectureContext)obj;
+ allContexts.add(context);
+ allDomains.add(context.getDomain());
+ }
+ return allDomains.toArray();
+ }
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof MergedArchitectureDomain) {
+ MergedArchitectureDomain domain = (MergedArchitectureDomain)parentElement;
+ List<MergedArchitectureContext> possibleContexts = new ArrayList<MergedArchitectureContext>(domain.getContexts());
+ possibleContexts.retainAll(allContexts);
+ return possibleContexts.toArray();
+ }
+ return null;
+ }
+ });
+ contextsViewer.setLabelProvider(new AdapterFactoryLabelProvider(composedAdapterFactory) {
+ @Override
+ public Image getImage(Object object) {
+ if (object instanceof MergedADElement) {
+ MergedADElement element = (MergedADElement) object;
+ return super.getImage(element.getImageObject());
+ }
+ return super.getImage(object);
+ }
+ @Override
+ public String getText(Object object) {
+ return ((MergedADElement)object).getName();
+ }
+ });
+ contextsViewer.setComparator(new ViewerComparator());
+ contextsViewer.setCheckStateProvider(new ICheckStateProvider() {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ @Override
+ public boolean isChecked(Object element) {
+ if (element instanceof MergedArchitectureContext)
+ return selectedContexts.contains(((MergedArchitectureContext)element).getId());
+ else
+ return contextsViewer.getChecked(element);
+ }
+ });
+ contextsViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance();
+
+ if (!allowSeveralContexts) {
+ if (event.getChecked() || contextsViewer.getCheckedElements().length == 0) {
+ if (event.getElement() instanceof MergedArchitectureContext) {
+ contextsViewer.setCheckedElements(new Object[] {event.getElement()});
+ } else {
+ for (TreeItem item : contextsViewer.getTree().getItems()) {
+ if (item.getData() == event.getElement()) {
+ contextsViewer.setCheckedElements(new Object[] {item.getItem(0).getData()});
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ selectedContexts.clear();
+ for (Object element : contextsViewer.getCheckedElements()) {
+ if (element instanceof MergedArchitectureContext)
+ selectedContexts.add(((MergedArchitectureContext)element).getId());
+ }
+
+ selectedViewpoints.clear();
+ for (String contextId : selectedContexts) {
+ MergedArchitectureContext context = manager.getArchitectureContextById(contextId);
+ for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) {
+ selectedViewpoints.add(viewpoint.getId());
+ }
+ }
+
+ updateViewpoints();
+ if (updater != null)
+ updater.update();
+ }
+ });
+
+ ColumnViewerToolTipSupport.enableFor(contextsViewer, ToolTip.NO_RECREATE);
+
+ Composite viewpointComposite = createComposite(this, 1, 1, GridData.FILL_HORIZONTAL, 0, 0);
+
+ createLabel(viewpointComposite, "Architecture Viewpoints:", 1);
+
+ viewpointViewer = CheckboxTableViewer.newCheckList(viewpointComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 100;
+ viewpointViewer.getControl().setLayoutData(gd);
+ viewpointViewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ Set<MergedADElement> viewpoints = new TreeSet<MergedADElement>(new Comparator<MergedADElement>() {
+ @Override
+ public int compare(MergedADElement o1, MergedADElement o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ for (Object obj : ((Object[])inputElement)) {
+ if (obj instanceof MergedArchitectureContext)
+ viewpoints.addAll(((MergedArchitectureContext)obj).getViewpoints());
+ }
+ return viewpoints.toArray();
+ }
+ });
+ viewpointViewer.setLabelProvider(new LabelProvider() {
+ private ILabelProvider provider = new AdapterFactoryLabelProvider(composedAdapterFactory);
+ @Override
+ public Image getImage(Object object) {
+ MergedADElement element = (MergedADElement) object;
+ return provider.getImage(element.getImageObject());
+ }
+ @Override
+ public String getText(Object object) {
+ return ((MergedADElement)object).getName();
+ }
+ });
+ viewpointViewer.setCheckStateProvider(new ICheckStateProvider() {
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ @Override
+ public boolean isChecked(Object element) {
+ return selectedViewpoints.contains(((MergedArchitectureViewpoint)element).getId());
+ }
+ });
+ viewpointViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ MergedArchitectureViewpoint viewpoint = (MergedArchitectureViewpoint) event.getElement();
+ if (event.getChecked())
+ selectedViewpoints.add(viewpoint.getId());
+ else
+ selectedViewpoints.remove(viewpoint.getId());
+ updateViewpoints();
+ if (updater != null)
+ updater.update();
+ }
+ });
+ updateViewpoints();
+ }
+
+ /**
+ * Sets the input object of the composite that initializes its viewers
+ *
+ * @param input the input object
+ */
+ public void setInput(Object input) {
+ contextsViewer.setInput(input);
+ contextsViewer.expandAll();
+ updateViewpoints();
+ }
+
+ /**
+ * Sets whether to show several context
+ *
+ * @param allowSeveralContexts boolean value
+ */
+ public void setAllowSeveralContexts(boolean allowSeveralContexts) {
+ this.allowSeveralContexts = allowSeveralContexts;
+ }
+
+ /**
+ * @return an array of selected contexts
+ */
+ public String[] getSelectedContexts() {
+ return selectedContexts.toArray(new String[0]);
+ }
+
+ /**
+ * Sets the selected contexts
+ *
+ * @param selectedContexts
+ */
+ public void setSelectedContexts(String[] selectedContexts) {
+ this.selectedContexts = new HashSet<String>(Arrays.asList(selectedContexts));
+ }
+
+ /**
+ * @return an array of selected viewpoints
+ */
+ public String[] getSelectedViewpoints() {
+ return selectedViewpoints.toArray(new String[0]);
+ }
+
+ /**
+ * Sets the selected viewpoints
+ *
+ * @param selectedViewpoints
+ */
+ public void setSelectedViewpoints(String[] selectedViewpoints) {
+ this.selectedViewpoints = new HashSet<String>(Arrays.asList(selectedViewpoints));
+ }
+
+ /**
+ * Sets the updater instance
+ *
+ * @param updater
+ */
+ public void setUpdater(Updater updater) {
+ this.updater = updater;
+ }
+
+ /*
+ * update the viewpoint viewer based on changes to context viewer
+ */
+ private void updateViewpoints() {
+ viewpointViewer.setInput(contextsViewer.getCheckedElements());
+ }
+
+ private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth, int marginheight) {
+ Composite g = new Composite(parent, SWT.NONE);
+ layoutComposite(g, parent, columns, hspan, fill, marginwidth, marginheight);
+ return g;
+ }
+
+ private static Composite layoutComposite(Composite g, Composite parent, int columns, int hspan, int fill, int marginwidth, int marginheight) {
+ GridLayout layout = new GridLayout(columns, false);
+ layout.marginWidth = marginwidth;
+ layout.marginHeight = marginheight;
+ g.setLayout(layout);
+ g.setFont(parent.getFont());
+ GridData gd = new GridData(fill);
+ gd.horizontalSpan = hspan;
+ g.setLayoutData(gd);
+ return g;
+ }
+
+ private static Label createLabel(Composite parent, String text, int hspan) {
+ Label l = new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ gd.grabExcessHorizontalSpace = false;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/schema/papyrusDiagram.exsd b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/schema/papyrusDiagram.exsd
index 241fe0c27f1..54ba81578bc 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/schema/papyrusDiagram.exsd
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/schema/papyrusDiagram.exsd
@@ -32,7 +32,6 @@ The &lt;code&gt;org.eclipse.papyrus.infra.ui.papyrusDiagram&lt;/code&gt; extensi
<element ref="editorDiagram" minOccurs="0" maxOccurs="unbounded"/>
<element ref="creationCommand" minOccurs="0" maxOccurs="unbounded"/>
<element ref="actionBarContributor" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="diagramCategory" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -199,64 +198,6 @@ The &lt;code&gt;org.eclipse.papyrus.infra.ui.papyrusDiagram&lt;/code&gt; extensi
</complexType>
</element>
- <element name="diagramCategory">
- <annotation>
- <documentation>
- The category of a domain model. The registered category is available in New papyrus Model Wizard and it customizes creation of a domain model. It is also used to filter diagram kinds and model templates.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- a unique identifier used as a reference for this diagram category. It is used to filter model templates and diagram kinds.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- a name of the fully qualified class that implements &lt;samp&gt;org.eclipse.papyrus.infra.ui.extension.commands.IModelCreationCommand&lt;/samp&gt;.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.ui.extension.commands.IModelCreationCommand"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensionPrefix" type="string">
- <annotation>
- <documentation>
- the file extension.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="label" type="string" use="required">
- <annotation>
- <documentation>
- a translatable name of the diagram category, it is displayed in the New Papyrus Model Wizard to select a Diagram Category.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="description" type="string">
- <annotation>
- <documentation>
- a description of the diagram category is to be displayed as a tooltip next ti its label.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- a relative path of an icon used to visually represent the diagram category. The path is relative to the location of the plugin.xml file of the contributing plug-in.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
<annotation>
<appInfo>
<meta.section type="since"/>
@@ -307,7 +248,7 @@ As Requirement diagram belongs to SysML category it will be created with a SysML
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
- &lt;p&gt;The value of the &lt;code&gt;class&lt;/code&gt; attribute of &lt;code&gt;diagramCategory&lt;/code&gt; must represent a class that implements the &lt;code&gt;org.eclipse.papyrus.infra.ui.extension.commands.IModelCreationCommand&lt;/code&gt; interface. There are a few default implementations of &lt;code&gt;IModelCreationCommand&lt;/code&gt; that may be useful to users of this extension point:
+ &lt;p&gt;The value of the &lt;code&gt;class&lt;/code&gt; attribute of &lt;code&gt;diagramCategory&lt;/code&gt; must represent a class that implements the &lt;code&gt;org.eclipse.papyrus.infra.architecture.commands.IModelCreationCommand&lt;/code&gt; interface. There are a few default implementations of &lt;code&gt;IModelCreationCommand&lt;/code&gt; that may be useful to users of this extension point:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;org.eclipse.papyrus.commands.ModelCreationCommandBase&lt;/code&gt; - an abstract implementation of a basic &lt;code&gt;IModelCreationCommand&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand&lt;/code&gt;&lt;/li&gt; - implementation of IModelCreationCommand that creates a UML model.
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/extension/commands/IModelCreationCommand.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/extension/commands/IModelCreationCommand.java
deleted file mode 100644
index 838908b38c2..00000000000
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/extension/commands/IModelCreationCommand.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * 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:
- * Tatiana Fesenko (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.ui.extension.commands;
-
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-
-/**
- * The Interface IModelCreationCommand.
- *
- * @since 1.2
- */
-public interface IModelCreationCommand {
-
- /**
- * Creates the model.
- *
- * @param modelSet
- * the modelSet set
- */
- void createModel(final ModelSet modelSet);
-
-}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/internal/commands/SashLayoutCommandFactory.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/internal/commands/SashLayoutCommandFactory.java
index 61c931b1ec4..b72840bec46 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/internal/commands/SashLayoutCommandFactory.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/internal/commands/SashLayoutCommandFactory.java
@@ -131,15 +131,13 @@ public class SashLayoutCommandFactory {
void moveContents(Resource fromResource, Resource toResource) {
// Safe copy to allow concurrent modifications
for (EObject root : new ArrayList<>(fromResource.getContents())) {
- EObject toReplace = (EObject) EcoreUtil.getObjectByType(toResource.getContents(), root.eClass());
- if (toReplace != null) {
- EcoreUtil.replace(toReplace, root);
- } else {
- if (root instanceof SashWindowsMngr) {
+ if (root instanceof SashWindowsMngr) {
+ EObject toReplace = (EObject) EcoreUtil.getObjectByType(toResource.getContents(), root.eClass());
+ if (toReplace != null) {
+ EcoreUtil.replace(toReplace, root);
+ } else {
// This one is expected always to be first
toResource.getContents().add(0, root);
- } else {
- toResource.getContents().add(root);
}
}
}
diff --git a/plugins/infra/ui/pom.xml b/plugins/infra/ui/pom.xml
index f9cec6ab2b3..2774d80b1e2 100644
--- a/plugins/infra/ui/pom.xml
+++ b/plugins/infra/ui/pom.xml
@@ -13,6 +13,7 @@
<modules>
<module>org.eclipse.papyrus.infra.ui</module>
+ <module>org.eclipse.papyrus.infra.ui.architecture</module>
<module>org.eclipse.papyrus.infra.ui.resources</module>
<module>org.eclipse.papyrus.infra.onefile.ui</module>
<module>org.eclipse.papyrus.infra.widgets</module>

Back to the top