Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-09-03 08:24:59 +0000
committerPatrick Tessier2019-09-18 13:50:43 +0000
commita39eec0a3c86af8d5fc476dd42c027b35104cb72 (patch)
tree9bff03b6d9ebce8313f7d6fc0121f6ccf4b54bd2 /plugins/infra
parent37eba0da47d6b9a26299f133d69e93223a20dcb6 (diff)
downloadorg.eclipse.papyrus-a39eec0a3c86af8d5fc476dd42c027b35104cb72.tar.gz
org.eclipse.papyrus-a39eec0a3c86af8d5fc476dd42c027b35104cb72.tar.xz
org.eclipse.papyrus-a39eec0a3c86af8d5fc476dd42c027b35104cb72.zip
Bug 550569: [AF] Double-click on diagrams and tables icons of disabled
viewpoint should open a dialog to enable viewpoint - When a diagram/table is needed to be open but his viewpoint is not enable, a dialog is opened to select the viewpoint Change-Id: I052209b91b0e85742af60177e6c733c96c8730c9 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra')
-rwxr-xr-xplugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java26
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml1
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/pom.xml2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/pageAddValidator.exsd129
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/api/IPageAddValidator.java34
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/utils/PageAddValidatorManager.java112
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/pom.xml2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/service/BasicPageManagerImpl.java49
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/META-INF/MANIFEST.MF6
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml6
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/dialogs/ArchitectureContextDialog.java211
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java151
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureViewpointsHandler.java3
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/Messages.java36
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/messages.properties4
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/validators/ArchitecturePageAddValidator.java131
20 files changed, 770 insertions, 143 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
index 87e0f1da698..b28e859078d 100755
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
@@ -11,10 +11,10 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.papyrus.infra.core.sasheditor;bundle-version="[2.1.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.transaction;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="[1.3.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core;bundle-version="[3.0.200,4.0.0)"
Bundle-Vendor: %providerName
-Bundle-Version: 2.0.100.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor.di;singleton:=true
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
index ef4f20c200b..9dfc9952ca9 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 Cedric Dumoulin, CEA, and others.
+ * Copyright (c) 2013-2014, 2019 Cedric Dumoulin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -14,6 +14,8 @@
* Christian W. Damus (CEA) - bug 433371
* Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 415638
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550569
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
@@ -21,6 +23,8 @@ package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
+import org.eclipse.papyrus.infra.core.sasheditor.utils.PageAddValidatorManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
import org.eclipse.papyrus.infra.core.sashwindows.di.service.BasicPageManagerImpl;
@@ -95,6 +99,26 @@ public class PageManagerImpl extends BasicPageManagerImpl {
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.core.sashwindows.di.service.BasicPageManagerImpl#canAddPage(java.lang.Object)
+ */
+ @Override
+ protected boolean canAddPage(final Object pageIdentifier) {
+ return PageAddValidatorManager.getInstance().isValid(pageIdentifier);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.core.sashwindows.di.service.BasicPageManagerImpl#canAddPage(org.eclipse.papyrus.infra.core.sashwindows.di.PageRef)
+ */
+ @Override
+ protected boolean canAddPage(final PageRef page) {
+ return PageAddValidatorManager.getInstance().isValid(page);
+ }
+
+ /**
* @since 2.0
*/
@Override
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
index 5c26d63a24d..1f35c5f3f5f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.core.sasheditor.di</artifactId>
- <version>2.0.100-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
index 4fddb646cfe..18f224501fc 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
@@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)";visibility:=reex
org.eclipse.papyrus.infra.tools;bundle-version="[3.1.0,4.0.0)",
org.eclipse.emf.common.ui;bundle-version="[2.18.0,3.0.0)"
Bundle-Vendor: %providerName
-Bundle-Version: 2.1.100.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.core.sasheditor.Activator
Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor;singleton:=true
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml
index 6c391b80c20..6b0d7a14e13 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml
@@ -6,6 +6,7 @@
id="nestedEditor"
name="NestedEditor"
schema="schema/nestedEditor.exsd"/>
+ <extension-point id="pageAddValidator" name="PageAddValidator" schema="schema/pageAddValidator.exsd"/>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/pom.xml
index 1eda4c3667f..0557c58f898 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/pom.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.core.sasheditor</artifactId>
- <version>2.1.100-SNAPSHOT</version>
+ <version>2.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/pageAddValidator.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/pageAddValidator.exsd
new file mode 100644
index 00000000000..593d08f67e3
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/pageAddValidator.exsd
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.core.sasheditor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.core.sasheditor" id="pageAddValidator" name="PageAddValidator"/>
+ </appInfo>
+ <documentation>
+ Define a validator to manage if a page can be added to the list of opened pages or not.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="validator" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="validator">
+ <annotation>
+ <documentation>
+ The validator to manage the page addition.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class of validator to manage the page addition.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.core.sasheditor.api.IPageAddValidator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Since 2.2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /*****************************************************************************
+ * Copyright (c) 2019 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/api/IPageAddValidator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/api/IPageAddValidator.java
new file mode 100644
index 00000000000..2d8487822a5
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/api/IPageAddValidator.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.api;
+
+/**
+ * This interface allows to define page add validators which allows to define if a page should be opened or not.
+ *
+ * @since 2.2
+ */
+public interface IPageAddValidator {
+
+ /**
+ * Define if a page is valid to be added or not.
+ *
+ * @param pageIdentifier
+ * The page identifier.
+ * @return <code>true</code> if the page can be added, <code>false</code> otherwise.
+ */
+ public boolean isValid(final Object pageIdentifier);
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/utils/PageAddValidatorManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/utils/PageAddValidatorManager.java
new file mode 100644
index 00000000000..2260bebf329
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/utils/PageAddValidatorManager.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.utils;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.core.sasheditor.Activator;
+import org.eclipse.papyrus.infra.core.sasheditor.api.IPageAddValidator;
+import org.osgi.framework.Bundle;
+
+/**
+ * This allows to define a manager for the page add validators.
+ *
+ * @since 2.2
+ */
+public class PageAddValidatorManager {
+
+ /**
+ * The page add validator extension identifier.
+ */
+ private static String PAGEADDVALIDATOR_EXTENSION_ID = "org.eclipse.papyrus.infra.core.sasheditor.pageAddValidator"; //$NON-NLS-1$
+
+ /**
+ * The class attribute of the extension point.
+ */
+ private static String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+
+ /**
+ * The singleton instance.
+ */
+ private static PageAddValidatorManager instance;
+
+ /**
+ * The declared validators in extension points.
+ */
+ private Set<IPageAddValidator> validators;
+
+ /**
+ * Private constructor to avoid external instanciation.
+ */
+ private PageAddValidatorManager() {
+ validators = new HashSet<>();
+ initializeValidators();
+ }
+
+ /**
+ * Get the singleton instance.
+ *
+ * @return The singleton instance.
+ */
+ public static PageAddValidatorManager getInstance() {
+ if (null == instance) {
+ instance = new PageAddValidatorManager();
+ }
+ return instance;
+ }
+
+ /**
+ * This allows to initialize the validators for the extension points.
+ */
+ private void initializeValidators() {
+ // Reading data from extensions
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(PAGEADDVALIDATOR_EXTENSION_ID);
+ for (int i = 0; i < configElements.length; i++) {
+ final IConfigurationElement element = configElements[i];
+ final Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier());
+ final String classAttribute = element.getAttribute(CLASS_ATTRIBUTE);
+ try {
+ // Get the class from the referenced one
+ final Class<?> clazz = extensionBundle.loadClass(classAttribute);
+ final Object obj = clazz.newInstance();
+ validators.add((IPageAddValidator) obj);
+ } catch (Exception e) {
+ Activator.log.error("The class '" + classAttribute + "' cannot be accessible from plug-in '" + extensionBundle.getSymbolicName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+ }
+
+ /**
+ * Determinate if the validators allow to add page or not.
+ *
+ * @param pageIdentifier
+ * The page identifier.
+ * @return <code>true</code> if the page can be added, <code>false</code> otherwise.
+ */
+ public boolean isValid(final Object pageIdentifier) {
+ for (final IPageAddValidator validator : validators) {
+ if (!validator.isValid(pageIdentifier)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/META-INF/MANIFEST.MF
index 3ccd6b938fb..b6577002e40 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/META-INF/MANIFEST.MF
@@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility
org.eclipse.emf.transaction;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: %providerName
-Bundle-Version: 1.3.0.qualifier
+Bundle-Version: 1.4.0.qualifier
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sashwindows.di;singleton:=true
Automatic-Module-Name: org.eclipse.papyrus.infra.core.sashwindows.di
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/pom.xml
index 76f26d72424..5af9d825fe9 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/pom.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/pom.xml
@@ -9,6 +9,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.core.sashwindows.di</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/service/BasicPageManagerImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/service/BasicPageManagerImpl.java
index f2ca28a885c..71848384bfb 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/service/BasicPageManagerImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sashwindows.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/service/BasicPageManagerImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2016 Cedric Dumoulin, CEA, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2016, 2019 Cedric Dumoulin, CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,7 @@
* Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 415638
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754
* Christian W. Damus - bug 485220
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550569
*
*****************************************************************************/
@@ -89,25 +90,31 @@ public class BasicPageManagerImpl implements IPageManager {
@Override
@Deprecated
public void addPage(Object pageIdentifier) {
- if (isLegacyMode()) {
- diSashModel.getPageList().addPage(pageIdentifier);
+ if (canAddPage(pageIdentifier)) {
+ if (isLegacyMode()) {
+ diSashModel.getPageList().addPage(pageIdentifier);
+ }
}
}
@SuppressWarnings("deprecation")
private void doAddPage(Object pageIdentifier) {
- if (isLegacyMode()) {
- diSashModel.getPageList().addPage(pageIdentifier);
+ if (canAddPage(pageIdentifier)) {
+ if (isLegacyMode()) {
+ diSashModel.getPageList().addPage(pageIdentifier);
+ }
+ diSashModel.getSashModel().addPage(getCurrentFolder(), pageIdentifier);
}
- diSashModel.getSashModel().addPage(getCurrentFolder(), pageIdentifier);
}
@SuppressWarnings("deprecation")
private void doAddPage(PageRef page) {
- if (isLegacyMode()) {
- diSashModel.getPageList().addPage(page.getPageIdentifier());
+ if (canAddPage(page)) {
+ if (isLegacyMode()) {
+ diSashModel.getPageList().addPage(page.getPageIdentifier());
+ }
+ diSashModel.getSashModel().addPage(getCurrentFolder(), page);
}
- diSashModel.getSashModel().addPage(getCurrentFolder(), page);
}
/**
@@ -318,6 +325,30 @@ public class BasicPageManagerImpl implements IPageManager {
}
/**
+ * Determinate if the page can be added or not.
+ *
+ * @param pageIdentifier
+ * The page identifier.
+ * @return <code>true</code> if the page can be added, <code>false</code> otherwise.
+ * @since 1.4
+ */
+ protected boolean canAddPage(final Object pageIdentifier) {
+ return true;
+ }
+
+ /**
+ * Determinate if the page can be added or not.
+ *
+ * @param page
+ * The page ref.
+ * @return <code>true</code> if the page can be added, <code>false</code> otherwise.
+ * @since 1.4
+ */
+ protected boolean canAddPage(final PageRef page) {
+ return true;
+ }
+
+ /**
* Obtains the currently active tab folder, whatever that might mean in the
* context of the page manager.
*
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
index 7b6a0fd097f..dc3b3a56493 100644
--- 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
@@ -9,6 +9,9 @@ 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.dialogs,
+ org.eclipse.papyrus.infra.ui.architecture.messages,
+ org.eclipse.papyrus.infra.ui.architecture.validators,
org.eclipse.papyrus.infra.ui.architecture.commands,
org.eclipse.papyrus.infra.ui.architecture.widgets
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.0.0,4.0.0)",
@@ -29,6 +32,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.0.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.nattable.representation;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.nattable.representation;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.editor.welcome;bundle-version="[2.0.0,3.0.0)"
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.papyrus.infra.ui.architecture
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
index 649bbd79960..757513a86f5 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/plugin.xml
@@ -113,5 +113,11 @@
</includes>
</viewerContentBinding>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.sasheditor.pageAddValidator">
+ <validator
+ class="org.eclipse.papyrus.infra.ui.architecture.validators.ArchitecturePageAddValidator">
+ </validator>
+ </extension>
</plugin>
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/dialogs/ArchitectureContextDialog.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/dialogs/ArchitectureContextDialog.java
new file mode 100644
index 00000000000..403868fd29c
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/dialogs/ArchitectureContextDialog.java
@@ -0,0 +1,211 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Maged Elaasar - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550569
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.ui.architecture.dialogs;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+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.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A dialog to allow choosing a new architecture context and viewpoints.
+ *
+ * @since 2.1
+ */
+public class ArchitectureContextDialog extends Dialog {
+
+ /**
+ * The dialog section name.
+ */
+ private final static String DIALOG_SECTION = ArchitectureContextDialog.class.getName();
+
+ /**
+ * The initial context ids.
+ */
+ private String[] originalContextIds;
+
+ /**
+ * The selected context ids.
+ */
+ private String[] selectedContextIds;
+
+ /**
+ * The selected viewpoints ids.
+ */
+ private String[] selectedViewpointIds;
+
+ /**
+ * The shell title.
+ */
+ private String shellTitle;
+
+ /**
+ * The label displayed in the dialog.
+ */
+ private String labelText;
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * The parent shell.
+ * @param shellTitle
+ * The shell title.
+ * @param labelText
+ * The label of text in the dialog.
+ */
+ public ArchitectureContextDialog(final Shell parentShell, final String shellTitle, final String labelText) {
+ super(parentShell);
+ this.shellTitle = shellTitle;
+ this.labelText = labelText;
+ }
+
+ /**
+ * Get the selected context ids.
+ *
+ * @return The selected context ids.
+ */
+ public String[] getSelectedContextIds() {
+ return selectedContextIds;
+ }
+
+ /**
+ * Get the selected viewpoints ids.
+ *
+ * @return The selected viewpoints ids.
+ */
+ public String[] getSelectedViewpointIds() {
+ return selectedViewpointIds;
+ }
+
+ /**
+ * Set the selected context ids.
+ *
+ * @param selectedContextIds
+ * The selected context ids.
+ */
+ public void setSelectedContexts(final String[] selectedContextIds) {
+ this.selectedContextIds = selectedContextIds;
+ this.originalContextIds = selectedContextIds;
+ }
+
+ /**
+ * Set the selected viewpoints ids.
+ *
+ * @param selectedContextIds
+ * The selected viewpoints ids.
+ */
+ public void setSelectedViewpoints(final String[] selectedViewpointIds) {
+ this.selectedViewpointIds = selectedViewpointIds;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ final Composite container = (Composite) super.createDialogArea(parent);
+
+ final Label label = new Label(container, SWT.NONE);
+ label.setText(labelText);
+
+ final ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance();
+
+ final 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;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(final Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(shellTitle);
+ }
+
+ /**
+ * [{@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ */
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ final IDialogSettings globalSettings = ArchitectureUIPlugin.getPlugin().getDialogSettings();
+ IDialogSettings dialogSettings = globalSettings.getSection(DIALOG_SECTION);
+ if (dialogSettings == null) {
+ dialogSettings = globalSettings.addNewSection(DIALOG_SECTION);
+ }
+ return dialogSettings;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ if (!Arrays.equals(getSelectedContextIds(), originalContextIds)) {
+ final 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?"); //$NON-NLS-1$
+ messageBox.setText("Warning"); //$NON-NLS-1$
+ final int response = messageBox.open();
+ if (response != SWT.YES) {
+ return;
+ }
+ }
+ super.okPressed();
+ }
+} \ 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/handlers/ChangeArchitectureContextHandler.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/handlers/ChangeArchitectureContextHandler.java
index 7a2a92dfdfc..7c10c739166 100644
--- 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
@@ -1,17 +1,17 @@
/**
- * Copyright (c) 2017 CEA LIST.
- *
+ * Copyright (c) 2017, 2019 CEA LIST.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
- * Maged Elaasar - Initial API and implementation
- *
- *
+ * Maged Elaasar - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 550569
+ *
*/
package org.eclipse.papyrus.infra.ui.architecture.handlers;
@@ -25,64 +25,59 @@ 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.papyrus.infra.ui.architecture.dialogs.ArchitectureContextDialog;
+import org.eclipse.papyrus.infra.ui.architecture.messages.Messages;
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
}
-
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
@Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
EObject selection = getSelection(event);
- if (selection == null)
+ if (selection == null) {
return new IContributionItem[0];
+ }
ResourceSet resourceSet = selection.eResource().getResourceSet();
- if (!(resourceSet instanceof ModelSet))
+ if (!(resourceSet instanceof ModelSet)) {
return new IContributionItem[0];
- final ArchitectureDescriptionUtils helper = new ArchitectureDescriptionUtils((ModelSet)resourceSet);
- String[] contextIds = new String[] {helper.getArchitectureContextId()};
+ }
+ 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);
+ ArchitectureContextDialog dialog = new ArchitectureContextDialog(shell, Messages.ChangeArchitectureContextHandler_dialogTitle, Messages.ChangeArchitectureContextHandler_dialogLabel);
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");
+ final TransactionalEditingDomain dom = helper.getModelSet().getTransactionalEditingDomain();
+ final CompoundCommand cmd = new CompoundCommand("Change Architecture Context"); //$NON-NLS-1$
if (!Arrays.equals(dialog.getSelectedContextIds(), contextIds)) {
cmd.append(helper.switchArchitectureContextId(dialog.getSelectedContextIds()[0]));
}
@@ -111,96 +106,4 @@ public class ChangeArchitectureContextHandler extends AbstractHandler {
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
index 9bf6d60a8f8..34ef5dbb901 100644
--- 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
@@ -96,9 +96,10 @@ public class ChangeArchitectureViewpointsHandler extends CompoundContributionIte
viewpoints.add(viewpoint);
}
TransactionalEditingDomain ted = helper.getModelSet().getTransactionalEditingDomain();
- cc.append(helper.switchArchitectureViewpointIds(viewpointIds.toArray(new String[0])));
// More than set the architecture viewpoints used, close needed editors
+ // It is needed to be the first action to avoid opened dialog for viewpoints selection
cc.append(new CloseEditorsForViewpointsCommand(viewpoints.stream().filter(viewpoint -> viewpointIds.contains(viewpoint.getId())).collect(Collectors.toList())));
+ cc.append(helper.switchArchitectureViewpointIds(viewpointIds.toArray(new String[0])));
ted.getCommandStack().execute(cc);
}
}));
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/Messages.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/Messages.java
new file mode 100644
index 00000000000..527d82dce86
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/Messages.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.ui.architecture.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages for architecture framework.
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.ui.architecture.messages.messages"; //$NON-NLS-1$
+ public static String ArchitecturePageAddValidator_diagleTitle;
+ public static String ArchitecturePageAddValidator_dialogLabel;
+ public static String ChangeArchitectureContextHandler_dialogLabel;
+ public static String ChangeArchitectureContextHandler_dialogTitle;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/messages.properties b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/messages.properties
new file mode 100644
index 00000000000..2a11d2cbdc8
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/messages/messages.properties
@@ -0,0 +1,4 @@
+ArchitecturePageAddValidator_diagleTitle=Enable viewpoint for diagram(s)/table(s)
+ArchitecturePageAddValidator_dialogLabel=The current diagram(s)/table(s) you want to open is not managed by the current viewpoint(s).\nSwitch the architecture context and/or viewpoints to get the one containing the diagram(s)/table(s) you want to open:
+ChangeArchitectureContextHandler_dialogLabel=Switch the architecture context and/or viewpoints applied to the Papyrus model:
+ChangeArchitectureContextHandler_dialogTitle=Switch Architecture Context
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/validators/ArchitecturePageAddValidator.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/validators/ArchitecturePageAddValidator.java
new file mode 100644
index 00000000000..41bdd7b7668
--- /dev/null
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/validators/ArchitecturePageAddValidator.java
@@ -0,0 +1,131 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.ui.architecture.validators;
+
+import java.util.Arrays;
+
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDescriptionUtils;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sasheditor.api.IPageAddValidator;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.editor.welcome.Welcome;
+import org.eclipse.papyrus.infra.ui.architecture.dialogs.ArchitectureContextDialog;
+import org.eclipse.papyrus.infra.ui.architecture.messages.Messages;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The page add validator for architecture framework.
+ * In our case, this will check if the page to add is contained in the current viewpoint. If not, open a dialog to change the context/viewpoint.
+ */
+public class ArchitecturePageAddValidator implements IPageAddValidator {
+
+ /**
+ * Constructor.
+ */
+ public ArchitecturePageAddValidator() {
+ // No nothing here
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.api.IPageAddValidator#isValid(java.lang.Object)
+ */
+ @Override
+ public boolean isValid(final Object pageIdentifier) {
+ Object currentPageIdentifier = pageIdentifier instanceof PageRef ? ((PageRef) pageIdentifier).getPageIdentifier() : pageIdentifier;
+
+ // We need to check if this is an EObject and not the welcome (for the welcome page)
+ if (currentPageIdentifier instanceof EObject && !(currentPageIdentifier instanceof Welcome)) {
+ final EObject eObject = (EObject) currentPageIdentifier;
+ final ViewPrototype prototype = ViewPrototype.get(eObject);
+
+ // Get the checker
+ PolicyChecker checker = PolicyChecker.getFor(eObject);
+
+ if (null != checker && null != prototype) {
+ // Initialize with window.OK
+ while (!checker.isInViewpoint(prototype.getRepresentationKind())) {
+ // If the dialog result is not OK button value, return false
+ // Otherwise, if the window returns OK, loop on while and re-open the dialog (if viewpoint is not the correct one) or return true
+ if (Window.OK != changeArchitectureContextAndViewPoint(eObject)) {
+ return false;
+ } else {
+ // Reload the policy checker after switch context/viewpoints
+ checker = PolicyChecker.getFor(eObject);
+ }
+ }
+ return true;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * This allows to change the context/viewpoint to manage the viewpoint for the selected diagram/table.
+ *
+ * @param eObject
+ * The diagram or table.
+ * @return The dialog result.
+ */
+ private int changeArchitectureContextAndViewPoint(final EObject eObject) {
+ // Check the resource set as first
+ if (null == eObject.eResource() || !(eObject.eResource().getResourceSet() instanceof ModelSet)) {
+ // The initial result is the cancel fake
+ return Window.CANCEL;
+ }
+
+ // Get the current contexts and viewpoints
+ final ArchitectureDescriptionUtils helper = new ArchitectureDescriptionUtils((ModelSet) eObject.eResource().getResourceSet());
+ final String[] contextIds = new String[] { helper.getArchitectureContextId() };
+ final String[] viewpointIds = helper.getArchitectureViewpointIds().toArray(new String[0]);
+
+ // Prepare the dialog
+ final Shell shell = Display.getCurrent().getActiveShell();
+ final ArchitectureContextDialog dialog = new ArchitectureContextDialog(shell, Messages.ArchitecturePageAddValidator_diagleTitle,
+ Messages.ArchitecturePageAddValidator_dialogLabel);
+ dialog.setSelectedContexts(contextIds);
+ dialog.setSelectedViewpoints(viewpointIds);
+ dialog.create();
+
+ // Open the dialog
+ int result = dialog.open();
+ if (Window.OK == result) {
+ // In this case, activate the context and viewpoints
+ final TransactionalEditingDomain dom = helper.getModelSet().getTransactionalEditingDomain();
+ final CompoundCommand cmd = new CompoundCommand("Change Architecture Viewpoint to open diagrams and tables"); //$NON-NLS-1$
+ 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 result;
+ }
+
+}

Back to the top