Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-02-02 09:01:03 +0000
committerPierre-Charles David2016-02-02 10:05:57 +0000
commita8a12d81f6285dacc5048fcf97612686eae712e3 (patch)
tree83bba3ef4e82c3ff92055e92bfad427f55931cf0
parentcdb9ce32b906f4e956fd364bc8f53d647ac83a1b (diff)
downloadorg.eclipse.sirius-a8a12d81f6285dacc5048fcf97612686eae712e3.tar.gz
org.eclipse.sirius-a8a12d81f6285dacc5048fcf97612686eae712e3.tar.xz
org.eclipse.sirius-a8a12d81f6285dacc5048fcf97612686eae712e3.zip
[482528] Add first version of the default dynamic mappings
1) A model properties.xmi contains the default pages to use if we fail to find any 2) Active checkstyle and fix various warnings and errors 3) Add log Change-Id: I079e55d1a19ea5a40d40152740deb5e5c6534607 Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/.checkstyle13
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/.project6
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF3
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/build.properties10
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/model/properties.xmi39
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/plugin.properties13
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/plugin.xml2
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Activator.java46
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Messages.java42
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SemanticElementFinder.java18
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusInterpreter.java19
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java16
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java174
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/DomainClassTester.java71
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/SiriusTabDescriptorProvider.java (renamed from incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusTabDescriptorProvider.java)55
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/ViewDescriptionConverter.java (renamed from incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ViewDescriptionConverter.java)181
16 files changed, 514 insertions, 194 deletions
diff --git a/incubation/org.eclipse.sirius.ui.properties/.checkstyle b/incubation/org.eclipse.sirius.ui.properties/.checkstyle
new file mode 100644
index 0000000000..3c756ff819
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/.checkstyle
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <local-check-config name="Sirius Checks" location="/org.eclipse.sirius.settings/CheckstyleConfiguration.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="false"/>
+ </local-check-config>
+ <fileset name="all" enabled="true" check-config-name="Sirius Checks" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+ <filter name="FilesFromPackage" enabled="true">
+ <filter-data value="src-gen"/>
+ </filter>
+</fileset-config>
diff --git a/incubation/org.eclipse.sirius.ui.properties/.project b/incubation/org.eclipse.sirius.ui.properties/.project
index b3c84db82d..315429669e 100644
--- a/incubation/org.eclipse.sirius.ui.properties/.project
+++ b/incubation/org.eclipse.sirius.ui.properties/.project
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
diff --git a/incubation/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF b/incubation/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
index 59e3ba44e3..de8ec02db9 100644
--- a/incubation/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
+++ b/incubation/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
@@ -20,5 +20,6 @@ Require-Bundle: org.eclipse.eef;bundle-version="1.6.0",
org.eclipse.eef.properties.ui;bundle-version="1.6.0"
Import-Package: com.ibm.icu.util,
org.eclipse.sirius.ui.tools.api.properties;version="2.1.0"
-Bundle-Activator: org.eclipse.sirius.ui.properties.internal.Activator
+Bundle-Activator: org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin$Implementation
Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
diff --git a/incubation/org.eclipse.sirius.ui.properties/build.properties b/incubation/org.eclipse.sirius.ui.properties/build.properties
index e9863e281e..7817cf26bd 100644
--- a/incubation/org.eclipse.sirius.ui.properties/build.properties
+++ b/incubation/org.eclipse.sirius.ui.properties/build.properties
@@ -1,5 +1,13 @@
+# Copyright (c) 2015, 2016 Obeo.
+# 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.htm
+# Contributors: Obeo - initial API and implementation
+
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ plugin.properties
diff --git a/incubation/org.eclipse.sirius.ui.properties/model/properties.xmi b/incubation/org.eclipse.sirius.ui.properties/model/properties.xmi
new file mode 100644
index 0000000000..ef10bf2302
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/model/properties.xmi
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="ASCII"?>
+<properties:ViewExtensionDescription
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:properties="http://www.eclipse.org/sirius/properties/1.0.0"
+ xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0"
+ xsi:schemaLocation="http://www.eclipse.org/sirius/properties/1.0.0 ../../org.eclipse.sirius.properties/model/properties.ecore http://www.eclipse.org/sirius/description/tool/1.1.0 ../../org.eclipse.sirius/model/viewpoint.ecore#//description/tool"
+ identifier="org.eclipse.sirius.ui.properties"
+ defaultPage="//@pages.0">
+ <pages identifier="org.eclipse.sirius.ui.properties.defaultpage"
+ labelExpression="General"
+ groups="//@groups.0"/>
+ <groups identifier="org.eclipse.sirius.ui.properties.defaultgroup">
+ <container>
+ <dynamicMappings
+ iterator="eStructuralFeature"
+ domainClassExpression="aql:self.eClass().eAllStructuralFeatures">
+ <switch
+ switchExpression="aql:eStructuralFeature.eType.name">
+ <cases
+ caseExpression="EString">
+ <widget
+ xsi:type="properties:TextDescription"
+ identifier=""
+ labelExpression="aql:eStructuralFeature.name"
+ valueExpression="aql:self.eGet(eStructuralFeature).toString()">
+ <initialOperation>
+ <firstModelOperations
+ xsi:type="tool:ChangeContext"
+ browseExpression="aql:self.eSet(eStructuralFeature, newValue)"/>
+ </initialOperation>
+ </widget>
+ </cases>
+ </switch>
+ </dynamicMappings>
+ </container>
+ </groups>
+</properties:ViewExtensionDescription>
diff --git a/incubation/org.eclipse.sirius.ui.properties/plugin.properties b/incubation/org.eclipse.sirius.ui.properties/plugin.properties
new file mode 100644
index 0000000000..924c073a5c
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2016 Obeo.
+# 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.htm
+# Contributors: Obeo - initial API and implementation
+
+pluginName = Sirius UI Properties
+providerName = Eclipse Modeling Project
+
+SiriusTabDescriptorProvider_UnsupportedMultipleSelection=Multiple elements have been selected but only the first one will be used as only element in the selection is currently supported.
+SiriusTabDescriptorProvider_UndefinedSemanticElement=The current selection is not related to any semantic element.
+SiriusTabDescriptorProvider_DefaultPropertiesNotFound=The model containing the default configuration of the Properties page has not been found. \ No newline at end of file
diff --git a/incubation/org.eclipse.sirius.ui.properties/plugin.xml b/incubation/org.eclipse.sirius.ui.properties/plugin.xml
index 36c8669794..cb7e9e3c72 100644
--- a/incubation/org.eclipse.sirius.ui.properties/plugin.xml
+++ b/incubation/org.eclipse.sirius.ui.properties/plugin.xml
@@ -21,7 +21,7 @@
<extension
point="org.eclipse.eef.properties.ui.eefTabDescriptorProvider">
<descriptor
- class="org.eclipse.sirius.ui.properties.internal.SiriusTabDescriptorProvider"
+ class="org.eclipse.sirius.ui.properties.internal.tabprovider.SiriusTabDescriptorProvider"
description="Provides EEF tab descriptors according to what is defined in the view properties extension"
id="org.eclipse.sirius.eefTabDescriptorProvider"
label="Sirius EEF Tab Descriptor Provider">
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Activator.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Activator.java
deleted file mode 100644
index e50d544066..0000000000
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Activator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.ui.properties.internal;
-
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.sirius.viewpoint.DSemanticDecorator;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * Bundle activator for <code>org.eclipse.sirius.ui.properties</code>.
- */
-public class Activator implements BundleActivator {
- static final String PLUGIN_ID = "org.eclipse.sirius.ui.properties";
-
- /**
- * The adapter is stateless, use a single instance that can be easily
- * unregistered when stopped.
- */
- private final SiriusSemanticAdapter adapterFactory = new SiriusSemanticAdapter();
-
- @Override
- public void start(BundleContext context) throws Exception {
- IAdapterManager adapterManager = Platform.getAdapterManager();
- adapterManager.registerAdapters(adapterFactory, DSemanticDecorator.class);
- adapterManager.registerAdapters(adapterFactory, GraphicalEditPart.class);
- adapterManager.registerAdapters(adapterFactory, ConnectionEditPart.class);
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- IAdapterManager adapterManager = Platform.getAdapterManager();
- adapterManager.unregisterAdapters(adapterFactory);
- }
-}
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Messages.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Messages.java
new file mode 100644
index 0000000000..8033752765
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/Messages.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.ui.properties.internal;
+
+import org.eclipse.sirius.ext.base.I18N;
+import org.eclipse.sirius.ext.base.I18N.TranslatableMessage;
+
+/**
+ * Utility class used for the internationalization.
+ *
+ * @author sbegaudeau
+ */
+public final class Messages {
+
+ static {
+ I18N.initializeMessages(Messages.class, SiriusUIPropertiesPlugin.INSTANCE);
+ }
+
+ // CHECKSTYLE:OFF
+ @TranslatableMessage
+ public static String SiriusTabDescriptorProvider_UnsupportedMultipleSelection;
+
+ @TranslatableMessage
+ public static String SiriusTabDescriptorProvider_UndefinedSemanticElement;
+
+ @TranslatableMessage
+ public static String SiriusTabDescriptorProvider_DefaultPropertiesNotFound;
+
+ // CHECKSTYLE:ON
+
+ private Messages() {
+ // Prevents instanciation.
+ }
+}
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SemanticElementFinder.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SemanticElementFinder.java
index 817bf3edce..6445fc22d1 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SemanticElementFinder.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SemanticElementFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -22,7 +22,21 @@ import org.eclipse.sirius.viewpoint.DSemanticDecorator;
*
* @author pcdavid
*/
-public class SemanticElementFinder {
+public final class SemanticElementFinder {
+ /**
+ * The constructor.
+ */
+ private SemanticElementFinder() {
+ // Prevent instantiation
+ }
+
+ /**
+ * Returns the semantic element associated with the given selection.
+ *
+ * @param selection
+ * The selection
+ * @return The semantic element found or <code>null</code> otherwise
+ */
public static EObject getAssociatedSemanticElement(Object selection) {
EObject semanticElement = null;
if (selection instanceof GraphicalEditPart) {
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusInterpreter.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusInterpreter.java
index 49fb3cefd3..fb57c01b7c 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusInterpreter.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusInterpreter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -11,7 +11,6 @@
package org.eclipse.sirius.ui.properties.internal;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -37,10 +36,22 @@ public class SiriusInterpreter implements IInterpreter {
private IInterpreterWithDiagnostic interpreter;
+ /**
+ * The constructor.
+ *
+ * @param session
+ * The Sirius session
+ */
public SiriusInterpreter(Session session) {
this((IInterpreterWithDiagnostic) session.getInterpreter());
}
+ /**
+ * The constructor.
+ *
+ * @param interpreterWithDiagnostic
+ * An interpreter
+ */
public SiriusInterpreter(IInterpreterWithDiagnostic interpreterWithDiagnostic) {
this.interpreter = Preconditions.checkNotNull(interpreterWithDiagnostic);
}
@@ -73,8 +84,8 @@ public class SiriusInterpreter implements IInterpreter {
filesProperty = (Collection<Object>) current;
}
}
- if (!filesProperty.contains(Activator.PLUGIN_ID)) {
- filesProperty.add(Activator.PLUGIN_ID);
+ if (!filesProperty.contains(SiriusUIPropertiesPlugin.PLUGIN_ID)) {
+ filesProperty.add(SiriusUIPropertiesPlugin.PLUGIN_ID);
}
i.setProperty(org.eclipse.sirius.common.tools.api.interpreter.IInterpreter.FILES, filesProperty);
i.addImport(org.eclipse.sirius.ui.properties.internal.SiriusToolServices.class.getName());
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
index 3628d8e48b..2906eb8511 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -26,7 +26,21 @@ import org.eclipse.sirius.viewpoint.description.Viewpoint;
import org.eclipse.sirius.viewpoint.description.tool.InitialOperation;
import org.eclipse.sirius.viewpoint.description.tool.ModelOperation;
+/**
+ * This class contains various services provided by the Sirius UI Properties
+ * bundle to the interpreter.
+ *
+ * @author sbegaudeau
+ */
public class SiriusToolServices {
+ /**
+ * Executes the operation with the given URI.
+ *
+ * @param eObject
+ * The current EObject
+ * @param initialCommandUri
+ * the URI of the operation to execute
+ */
public void executeOperation(EObject eObject, String initialCommandUri) {
Session session = new EObjectQuery(eObject).getSession();
ModelAccessor modelAccessor = session.getModelAccessor();
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java
new file mode 100644
index 0000000000..b9e6378d3e
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.ui.properties.internal;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.EMFPlugin;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.sirius.viewpoint.DSemanticDecorator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The plugin for <code>org.eclipse.sirius.ui.properties</code>.
+ *
+ * @author pcdavid
+ * @author sbegaudeau
+ */
+public class SiriusUIPropertiesPlugin extends EMFPlugin {
+ /**
+ * The identifier of the plugin.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.sirius.ui.properties";
+
+ /**
+ * The sole instance of the plugin.
+ */
+ public static final SiriusUIPropertiesPlugin INSTANCE = new SiriusUIPropertiesPlugin();
+
+ /**
+ * The sole instance of the bundle activator.
+ */
+ private static Implementation plugin;
+
+ /**
+ * The constructor.
+ */
+ public SiriusUIPropertiesPlugin() {
+ super(new ResourceLocator[0]);
+ }
+
+ @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 bundle activator.
+ *
+ * @author sbegaudeau
+ */
+ public static class Implementation extends EclipsePlugin {
+
+ /**
+ * The adapter is stateless, use a single instance that can be easily
+ * unregistered when stopped.
+ */
+ private final SiriusSemanticAdapter adapterFactory = new SiriusSemanticAdapter();
+
+ /**
+ * The constructor.
+ */
+ public Implementation() {
+ super();
+ SiriusUIPropertiesPlugin.plugin = this;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ adapterManager.registerAdapters(adapterFactory, DSemanticDecorator.class);
+ adapterManager.registerAdapters(adapterFactory, GraphicalEditPart.class);
+ adapterManager.registerAdapters(adapterFactory, ConnectionEditPart.class);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ adapterManager.unregisterAdapters(adapterFactory);
+ }
+
+ /**
+ * Logs the status.
+ *
+ * @param severity
+ * The severity of the status
+ * @param message
+ * The message to log or <code>null</code>. If the message is
+ * <code>null</code>, the message of the exception will be
+ * used instead
+ * @param exception
+ * The exception to log
+ */
+ private void doLog(int severity, String message, Exception exception) {
+ String messageToLog = message;
+ if (messageToLog == null && exception != null) {
+ messageToLog = exception.getMessage();
+ }
+ IStatus status = new Status(severity, PLUGIN_ID, messageToLog, exception);
+ this.getLog().log(status);
+ }
+
+ /**
+ * Logs an error with the exception and the given message.
+ *
+ * @param message
+ * The message
+ * @param exception
+ * The exception
+ */
+ public void error(String message, Exception exception) {
+ if (exception instanceof CoreException) {
+ this.getLog().log(((CoreException) exception).getStatus());
+ } else {
+ this.doLog(IStatus.ERROR, message, exception);
+ }
+ }
+
+ /**
+ * Logs a warning with the exception and the given message.
+ *
+ * @param message
+ * The message
+ * @param exception
+ * The exception
+ */
+ public void warning(String message, Exception exception) {
+ if (exception instanceof CoreException) {
+ this.getLog().log(((CoreException) exception).getStatus());
+ } else {
+ this.doLog(IStatus.WARNING, message, exception);
+ }
+ }
+
+ /**
+ * Logs an info with the exception and the given message.
+ *
+ * @param message
+ * The message
+ * @param exception
+ * The exception
+ */
+ public void info(String message, Exception exception) {
+ if (exception instanceof CoreException) {
+ this.getLog().log(((CoreException) exception).getStatus());
+ } else {
+ this.doLog(IStatus.INFO, message, exception);
+ }
+ }
+
+ }
+
+}
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/DomainClassTester.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/DomainClassTester.java
new file mode 100644
index 0000000000..a73baa85ee
--- /dev/null
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/DomainClassTester.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.ui.properties.internal.tabprovider;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.common.base.Predicate;
+
+/**
+ * This class is used to filter EObjects using a domain class.
+ *
+ * @author pcdavid
+ * @author sbegaudeau
+ */
+public class DomainClassTester implements Predicate<EObject> {
+ private static final Pattern SEPARATOR = Pattern.compile("(::?|\\.)");
+
+ private final String packageName;
+
+ private final String className;
+
+ /**
+ * The constructor.
+ *
+ * @param domainClassName
+ * A domain class "packageName::className" or
+ * "packageName.className".
+ */
+ public DomainClassTester(String domainClassName) {
+ if (domainClassName != null) {
+ Matcher m = SEPARATOR.matcher(domainClassName);
+ if (m.find()) {
+ packageName = domainClassName.substring(0, m.start());
+ className = domainClassName.substring(m.end());
+ } else {
+ packageName = null;
+ className = domainClassName;
+ }
+ } else {
+ packageName = null;
+ className = null;
+ }
+
+ }
+
+ @Override
+ public boolean apply(EObject input) {
+ boolean apply = false;
+ if (className == null && packageName == null) {
+ apply = true;
+ } else if (input != null) {
+ EClass klass = input.eClass();
+ boolean packageMatch = packageName == null || packageName.equals(klass.getEPackage().getName());
+ apply = packageMatch && (className == null || className.equals(klass.getName()));
+ }
+ return apply;
+ }
+
+}
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusTabDescriptorProvider.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/SiriusTabDescriptorProvider.java
index cbc842fcba..d76c3a9481 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusTabDescriptorProvider.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/SiriusTabDescriptorProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -8,7 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
-package org.eclipse.sirius.ui.properties.internal;
+package org.eclipse.sirius.ui.properties.internal.tabprovider;
import java.util.ArrayList;
import java.util.Collection;
@@ -22,7 +22,11 @@ import org.eclipse.eef.core.api.EEFViewFactory;
import org.eclipse.eef.ide.ui.api.EEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorProvider;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+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.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.sirius.business.api.query.EObjectQuery;
@@ -32,6 +36,10 @@ import org.eclipse.sirius.common.interpreter.api.VariableManagerFactory;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.properties.PageDescription;
import org.eclipse.sirius.properties.ViewExtensionDescription;
+import org.eclipse.sirius.ui.properties.internal.Messages;
+import org.eclipse.sirius.ui.properties.internal.SemanticElementFinder;
+import org.eclipse.sirius.ui.properties.internal.SiriusInterpreter;
+import org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.eclipse.sirius.viewpoint.description.Group;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
@@ -41,8 +49,20 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+/**
+ * The {@link IEEFTabDescriptorProvider} for Eclipse Sirius.
+ *
+ * @author sbegaudeau
+ * @author pcdavid
+ */
public class SiriusTabDescriptorProvider implements IEEFTabDescriptorProvider {
+ /**
+ * The URI of the model containing the default value of the properties page
+ * to create.
+ */
+ private static final String DEFAULT_PROPERTIES_URI = "platform:/plugin/org.eclipse.sirius.ui.properties/model/properties.xmi";
+
@Override
public Collection<IEEFTabDescriptor> get(IWorkbenchPart part, ISelection selection) {
if (selection instanceof IStructuredSelection) {
@@ -50,16 +70,29 @@ public class SiriusTabDescriptorProvider implements IEEFTabDescriptorProvider {
Object[] objects = structuredSelection.toArray();
// FIXME We take the first one
if (objects.length > 0) {
+ if (objects.length > 1) {
+ SiriusUIPropertiesPlugin.getPlugin().warning(Messages.SiriusTabDescriptorProvider_UnsupportedMultipleSelection, null);
+ }
+
EObject semanticElement = SemanticElementFinder.getAssociatedSemanticElement(objects[0]);
if (semanticElement != null) {
// Let's find out the description of the view
return this.getTabDescriptors(semanticElement);
+ } else {
+ SiriusUIPropertiesPlugin.getPlugin().error(Messages.SiriusTabDescriptorProvider_UndefinedSemanticElement, null);
}
}
}
return new ArrayList<IEEFTabDescriptor>();
}
+ /**
+ * Returns the {@link IEEFTabDescriptor} for the given semantic element.
+ *
+ * @param semanticElement
+ * The semantic element
+ * @return A collection of {@link IEEFTabDescriptor}
+ */
private Collection<IEEFTabDescriptor> getTabDescriptors(EObject semanticElement) {
Session session = new EObjectQuery(semanticElement).getSession();
List<PageDescription> effectivePageDescriptions = computeEffectiveDescription(semanticElement, session);
@@ -67,7 +100,7 @@ public class SiriusTabDescriptorProvider implements IEEFTabDescriptorProvider {
}
private Collection<IEEFTabDescriptor> getTabDescriptors(Session session, EObject semanticElement, List<PageDescription> effectivePageDescriptions) {
- EEFViewDescription viewDescription = new ViewDescriptionConverter(session, semanticElement, effectivePageDescriptions).convert();
+ EEFViewDescription viewDescription = new ViewDescriptionConverter(effectivePageDescriptions).convert();
EEFView eefView = createEEFView(session, semanticElement, viewDescription);
List<IEEFTabDescriptor> descriptors = new ArrayList<IEEFTabDescriptor>();
@@ -108,6 +141,22 @@ public class SiriusTabDescriptorProvider implements IEEFTabDescriptorProvider {
for (ViewExtensionDescription ved : viewDescriptions) {
effectivePages.addAll(ved.getPages());
}
+
+ if (effectivePages.size() == 0) {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ URI uri = URI.createURI(DEFAULT_PROPERTIES_URI, true);
+ Resource resource = resourceSet.getResource(uri, true);
+ if (resource != null) {
+ List<EObject> contents = resource.getContents();
+ if (contents.size() > 0 && contents.get(0) instanceof ViewExtensionDescription) {
+ ViewExtensionDescription viewExtensionDescription = (ViewExtensionDescription) contents.get(0);
+ effectivePages.addAll(viewExtensionDescription.getPages());
+ }
+ } else {
+ SiriusUIPropertiesPlugin.getPlugin().error(Messages.SiriusTabDescriptorProvider_DefaultPropertiesNotFound, null);
+ }
+ }
+
return effectivePages;
}
}
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ViewDescriptionConverter.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/ViewDescriptionConverter.java
index 90c640a138..9cf6e1dc8d 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ViewDescriptionConverter.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/tabprovider/ViewDescriptionConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -8,13 +8,9 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
-package org.eclipse.sirius.ui.properties.internal;
+package org.eclipse.sirius.ui.properties.internal.tabprovider;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.eef.EEFContainerDescription;
import org.eclipse.eef.EEFDynamicMappingCase;
@@ -25,14 +21,9 @@ import org.eclipse.eef.EEFLabelDescription;
import org.eclipse.eef.EEFPageDescription;
import org.eclipse.eef.EEFTextDescription;
import org.eclipse.eef.EEFViewDescription;
+import org.eclipse.eef.EEFWidgetDescription;
import org.eclipse.eef.EefFactory;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.sirius.business.api.session.Session;
-import org.eclipse.sirius.common.interpreter.api.IEvaluationResult;
-import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.properties.DynamicMappingCase;
import org.eclipse.sirius.properties.DynamicMappingFor;
import org.eclipse.sirius.properties.DynamicMappingSwitch;
@@ -43,119 +34,68 @@ import org.eclipse.sirius.properties.TextDescription;
import org.eclipse.sirius.properties.WidgetDescription;
import org.eclipse.sirius.viewpoint.description.tool.InitialOperation;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
/**
* Interprets the high-level property views description defined in a Sirius VSM
* into a lower-level EEFViewDescription suitable for the EEF runtime.
+ *
+ * @author pcdavid
*/
public class ViewDescriptionConverter {
- private static class DomainClassTester implements Predicate<EObject> {
- private static final Pattern SEPARATOR = Pattern.compile("(::?|\\.)");
-
- private final String packageName;
-
- private final String className;
-
- public DomainClassTester(String domainClassName) {
- Matcher m = Pattern.compile("(::?|\\.)").matcher(domainClassName);
- if (m.find()) {
- packageName = domainClassName.substring(0, m.start());
- className = domainClassName.substring(m.end());
- } else {
- packageName = null;
- className = domainClassName;
- }
-
- }
-
- @Override
- public boolean apply(EObject input) {
- if (input != null) {
- EClass klass = input.eClass();
- boolean packageMatch = packageName == null || packageName.equals(klass.getEPackage().getName());
- return packageMatch && (className == null || className.equals(klass.getName()));
- } else {
- return false;
- }
- }
-
- }
-
- private final IInterpreter itp;
-
- private final EObject viewTarget;
-
private final List<PageDescription> pageDescriptions;
- public ViewDescriptionConverter(Session session, EObject viewTarget, List<PageDescription> pageDescriptions) {
- this.itp = new SiriusInterpreter(session);
- this.viewTarget = viewTarget;
+ /**
+ * The contrsuctor.
+ *
+ * @param pageDescriptions
+ * The description of the pages to convert
+ */
+ public ViewDescriptionConverter(List<PageDescription> pageDescriptions) {
this.pageDescriptions = pageDescriptions;
}
+ /**
+ * Use the description of the pages provided in order to create an
+ * {@link EEFViewDescription}.
+ *
+ * @return The {@link EEFViewDescription} computed
+ */
public EEFViewDescription convert() {
- EEFViewDescription wrappingView = EefFactory.eINSTANCE.createEEFViewDescription();
+ EEFViewDescription view = EefFactory.eINSTANCE.createEEFViewDescription();
for (PageDescription pageDescription : pageDescriptions) {
- instantiatePages(pageDescription, wrappingView);
+ createPage(pageDescription, view);
}
- return wrappingView;
- }
-
- /**
- * Instanciates a PageDescription for a concrete semantic target (the
- * top-level input int the page's case), and put the resulting EEF pages &
- * groups in the specified view.
- */
- private void instantiatePages(PageDescription pageDescription, EEFViewDescription view) {
- List<EObject> candidates = computeCandidates(viewTarget, pageDescription.getSemanticCandidateExpression(), pageDescription.getDomainClass());
- for (EObject pageTarget : candidates) {
- createPage(pageDescription, pageTarget, view);
- }
+ return view;
}
/**
* Creates a concrete page instance bound to a specific semantic target.
*/
- private void createPage(PageDescription pageDescription, EObject pageTarget, EEFViewDescription view) {
+ private void createPage(PageDescription pageDescription, EEFViewDescription view) {
EEFPageDescription page = EefFactory.eINSTANCE.createEEFPageDescription();
page.setIdentifier(pageDescription.getIdentifier());
page.setLabelExpression(pageDescription.getLabelExpression());
page.setSemanticCandidateExpression(pageDescription.getSemanticCandidateExpression());
+
for (GroupDescription groupDescription : pageDescription.getGroups()) {
- instantiateGroups(groupDescription, page, pageTarget, view);
+ createGroup(groupDescription, page, view);
}
view.getPages().add(page);
}
/**
- * Instanciates a GroupDescription for a concrete semantic target, and put
- * the resulting EEF pages & groups in the specified view.
- */
- private void instantiateGroups(GroupDescription groupDescription, EEFPageDescription page, EObject pageTarget, EEFViewDescription view) {
- List<EObject> candidates = computeCandidates(pageTarget, groupDescription.getSemanticCandidateExpression(), groupDescription.getDomainClass());
- for (EObject groupTarget : candidates) {
- page.getGroups().add(createGroup(groupDescription, groupTarget, view));
- }
- }
-
- /**
* Creates a concrete group instance bound to a specific semantic target.
*/
- private EEFGroupDescription createGroup(GroupDescription groupDescription, EObject groupTarget, EEFViewDescription view) {
+ private void createGroup(GroupDescription groupDescription, EEFPageDescription page, EEFViewDescription view) {
EEFGroupDescription group = EefFactory.eINSTANCE.createEEFGroupDescription();
group.setIdentifier(groupDescription.getIdentifier());
- // TODO: should be setLabel()
- group.setLabelExpression(computeString(groupTarget, groupDescription.getLabelExpression()));
+ group.setLabelExpression(groupDescription.getLabelExpression());
convertGroupContents(groupDescription, group);
+
+ page.getGroups().add(group);
view.getGroups().add(group);
- return group;
}
private void convertGroupContents(GroupDescription groupDescription, EEFGroupDescription group) {
@@ -167,6 +107,11 @@ public class ViewDescriptionConverter {
} else if (widgetDescription instanceof LabelDescription) {
containerDesc.getWidgets().add(createEEFLabelDescription((LabelDescription) widgetDescription));
}
+
+ EEFWidgetDescription description = this.createEEFWidgetDescription(widgetDescription);
+ if (description != null) {
+ containerDesc.getWidgets().add(description);
+ }
}
for (DynamicMappingFor dynamicMappingFor : groupDescription.getContainer().getDynamicMappings()) {
@@ -183,10 +128,9 @@ public class ViewDescriptionConverter {
EEFDynamicMappingCase eefDynamicMappingCase = EefFactory.eINSTANCE.createEEFDynamicMappingCase();
eefDynamicMappingCase.setCaseExpression(dynamicMappingCase.getCaseExpression());
- if (dynamicMappingCase.getWidget() instanceof TextDescription) {
- eefDynamicMappingCase.setWidget(createEEFTextDescription((TextDescription) dynamicMappingCase.getWidget()));
- } else if (dynamicMappingCase.getWidget() instanceof LabelDescription) {
- eefDynamicMappingCase.setWidget(createEEFLabelDescription((LabelDescription) dynamicMappingCase.getWidget()));
+ EEFWidgetDescription widgetDescription = this.createEEFWidgetDescription(dynamicMappingCase.getWidget());
+ if (widgetDescription != null) {
+ eefDynamicMappingCase.setWidget(widgetDescription);
}
eefDynamicMappingSwitch.getCases().add(eefDynamicMappingCase);
@@ -198,6 +142,16 @@ public class ViewDescriptionConverter {
group.setContainer(containerDesc);
}
+ private EEFWidgetDescription createEEFWidgetDescription(WidgetDescription widgetDescription) {
+ EEFWidgetDescription description = null;
+ if (widgetDescription instanceof TextDescription) {
+ description = createEEFTextDescription((TextDescription) widgetDescription);
+ } else if (widgetDescription instanceof LabelDescription) {
+ description = createEEFLabelDescription((LabelDescription) widgetDescription);
+ }
+ return description;
+ }
+
private EEFTextDescription createEEFTextDescription(TextDescription textDescription) {
EEFTextDescription eefTextDescription = EefFactory.eINSTANCE.createEEFTextDescription();
@@ -218,47 +172,4 @@ public class ViewDescriptionConverter {
return eefLabelDescription;
}
- private static Map<String, Object> singletonEnv(String name, Object value) {
- Map<String, Object> env = Maps.newHashMap();
- env.put(name, value);
- return env;
- }
-
- private String computeString(EObject self, String expression) {
- IEvaluationResult result = itp.evaluateExpression(singletonEnv("self", self), expression);
- if (result.success()) {
- return result.asString();
- } else {
- log(result.getDiagnostic());
- return "";
- }
- }
-
- private List<EObject> computeCandidates(EObject self, String semanticCandidatesExpression, String domainClass) {
- IEvaluationResult result = itp.evaluateExpression(singletonEnv("self", self), isBlank(semanticCandidatesExpression) ? "var:self" : semanticCandidatesExpression);
- if (result.success()) {
- return Lists.newArrayList(Iterables.filter(result.asEObjects(), new DomainClassTester(domainClass)));
- } else {
- log(result.getDiagnostic());
- return Collections.emptyList();
- }
- }
-
- /**
- * Tests if a string is blank (i.e. null, empty, or containing only
- * whitespace).
- *
- * @param s
- * the string to test.
- * @return <code>true</code> iff the string is blank.
- */
- private boolean isBlank(String s) {
- return s == null || s.trim().length() == 0;
- }
-
- private void log(Diagnostic diagnostic) {
- // CHECKSTYLE:OFF
- System.err.println(diagnostic);
- // CHECKSTYLE:ON
- }
}

Back to the top