From 455f4aad0b34872dca6ba98c6e46f94558c917c3 Mon Sep 17 00:00:00 2001 From: jeremie.tatibouet Date: Tue, 26 May 2015 15:24:29 +0200 Subject: Provide a preference page for the Papyrus Alf integration. The nominal behavior is that Alf tooling is disabled. The user can next enabled it through the preference page and additionnaly activate the automated synchronization. Answers to bug 468312. Change-Id: I8c3102b0bb450818e42b921007a2ad49bba89803 Signed-off-by: jeremie.tatibouet Reviewed-on: https://git.eclipse.org/r/48638 Tested-by: Hudson CI Reviewed-by: Arnaud Cuccuru Tested-by: Arnaud Cuccuru --- .../META-INF/MANIFEST.MF | 3 +- .../observation/listener/FUMLElementListener.java | 5 ++ .../.classpath | 7 +++ .../.project | 28 +++++++++ .../.settings/org.eclipse.jdt.core.prefs | 7 +++ .../META-INF/MANIFEST.MF | 13 +++++ .../about.html | 28 +++++++++ .../build.properties | 8 +++ .../plugin.xml | 14 +++++ .../pom.xml | 14 +++++ .../papyrus/uml/alf/preferences/Activator.java | 50 ++++++++++++++++ .../alf/preferences/AlfIntegrationPreferences.java | 66 ++++++++++++++++++++++ .../AlfIntegrationPreferencesConstants.java | 25 ++++++++ .../preferences/AlfIntegrationPreferencesUtil.java | 35 ++++++++++++ .../META-INF/MANIFEST.MF | 3 +- .../sheet/AlfEditorPropertySectionFilter.java | 4 +- 16 files changed, 307 insertions(+), 3 deletions(-) create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.classpath create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.project create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.settings/org.eclipse.jdt.core.prefs create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/META-INF/MANIFEST.MF create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/about.html create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/build.properties create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/plugin.xml create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/pom.xml create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/Activator.java create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferences.java create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesConstants.java create mode 100644 extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesUtil.java (limited to 'extraplugins/alf') diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF index 64d3a5a0f93..166fe48fd00 100644 --- a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF +++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF @@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.uml.alf;bundle-version="1.1.0", org.eclipse.papyrus.uml.alf.text;bundle-version="0.7.0", org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0", - org.eclipse.compare + org.eclipse.compare, + org.eclipse.papyrus.uml.alf.preferences Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.papyrus.uml.alf.transaction, diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java index 1c2c9402bde..6476489f4a8 100644 --- a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java +++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java @@ -26,6 +26,7 @@ import org.eclipse.emf.transaction.ResourceSetChangeEvent; import org.eclipse.emf.transaction.ResourceSetListenerImpl; import org.eclipse.emf.transaction.RollbackException; import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.uml.alf.preferences.AlfIntegrationPreferencesUtil; import org.eclipse.papyrus.uml.alf.transaction.commit.ISyncScenario; import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory; import org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter.FUMLFilter; @@ -53,6 +54,10 @@ public class FUMLElementListener extends ResourceSetListenerImpl { * Note this is not always possible (e.g. the user has ongoing changes in the text) */ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException { + /* 0. If the user disabled the synchronization then we do not exploit notifications*/ + if(!AlfIntegrationPreferencesUtil.isAlfAutoSyncEnabled()){ + return null; + } /* 1. Initialization */ CompoundCommand subCommands = new CompoundCommand("Synchronization"); HashMap> modifications = new HashMap>(); diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.classpath b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.classpath new file mode 100644 index 00000000000..b1dabee3829 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.project b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.project new file mode 100644 index 00000000000..80913d0f4e5 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.project @@ -0,0 +1,28 @@ + + + org.eclipse.papyrus.uml.alf.preferences + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.settings/org.eclipse.jdt.core.prefs b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..11f6e462df7 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/META-INF/MANIFEST.MF b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..b67aa16ce5f --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ALF Preferences (Incubation) +Bundle-SymbolicName: org.eclipse.papyrus.uml.alf.preferences;singleton:=true +Bundle-Version: 0.7.0.qualifier +Bundle-Activator: org.eclipse.papyrus.uml.alf.preferences.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.gmf.runtime.common.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Eclipse Modeling Project +Export-Package: org.eclipse.papyrus.uml.alf.preferences diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/about.html b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/build.properties b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/build.properties new file mode 100644 index 00000000000..0545496cbde --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + about.html,\ + build.properties +src.includes = about.html diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/plugin.xml b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/plugin.xml new file mode 100644 index 00000000000..325969567a2 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/plugin.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/pom.xml b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/pom.xml new file mode 100644 index 00000000000..3afbcfcd668 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + org.eclipse.papyrus + org.eclipse.papyrus + 1.1.0-SNAPSHOT + ../../../../releng/top-pom-extras.xml + + org.eclipse.papyrus.uml.alf.preferences + org.eclipse.papyrus + 0.7.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/Activator.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/Activator.java new file mode 100644 index 00000000000..dd58e2cb882 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.papyrus.uml.alf.preferences; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.alf.preferences"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferences.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferences.java new file mode 100644 index 00000000000..781d9d0862e --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferences.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jeremie Tatibouet (CEA LIST) + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.alf.preferences; + +import org.eclipse.gmf.runtime.common.ui.preferences.CheckBoxFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class AlfIntegrationPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private final static String preferencePageTitle = "Configure Alf support in Papyrus Model"; + + public AlfIntegrationPreferences() { + super(GRID); + } + + @Override + protected void createFieldEditors() { + final CheckBoxFieldEditor enableAlfSupport = new CheckBoxFieldEditor( + AlfIntegrationPreferencesConstants.ALF_SUPPORT, + AlfIntegrationPreferencesConstants.ALF_SUPPORT_LABEL, + this.getFieldEditorParent()); + + final CheckBoxFieldEditor enableSynchronization = new CheckBoxFieldEditor( + AlfIntegrationPreferencesConstants.ALF_AUTOMATIC_SYNCHRONIZATION, + AlfIntegrationPreferencesConstants.ALF_AUTOMATIC_SYNCHRONIZATION_LABEL, + this.getFieldEditorParent()); + enableSynchronization.setEnabled( + AlfIntegrationPreferencesUtil.isAlfSupportEnabled(), + this.getFieldEditorParent()); + + enableAlfSupport.getCheckbox().addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (enableAlfSupport.getBooleanValue()) { + enableSynchronization.setEnabled(true, AlfIntegrationPreferences.this.getFieldEditorParent()); + } else { + enableSynchronization.setEnabled(false, AlfIntegrationPreferences.this.getFieldEditorParent()); + } + } + }); + + this.addField(enableAlfSupport); + this.addField(enableSynchronization); + } + + @Override + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription(preferencePageTitle); + } +} diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesConstants.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesConstants.java new file mode 100644 index 00000000000..33a24007b47 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesConstants.java @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jeremie Tatibouet (CEA LIST) + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.alf.preferences; + +public class AlfIntegrationPreferencesConstants { + + public final static String ALF_SUPPORT = "ALF_SUPPORT_ENABLED"; + + public final static String ALF_SUPPORT_LABEL = "Enable Alf support (Class, Package, Signal, DataType, Enumeration, Association and Activity can be edited through text)"; + + public final static String ALF_AUTOMATIC_SYNCHRONIZATION = "ALF_AUTOMATIC_SYNCHRONIZATION"; + + public final static String ALF_AUTOMATIC_SYNCHRONIZATION_LABEL = "Enable synchronization (Model and text are automatically synchronized) - [EXPERIMENTAL]"; +} diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesUtil.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesUtil.java new file mode 100644 index 00000000000..998c2ff5303 --- /dev/null +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.preferences/src/org/eclipse/papyrus/uml/alf/preferences/AlfIntegrationPreferencesUtil.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jeremie Tatibouet (CEA LIST) + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.alf.preferences; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IPreferencesService; + +public class AlfIntegrationPreferencesUtil { + + private final static String qualifier = "org.eclipse.papyrus.uml.alf.preferences"; + + public static boolean isAlfSupportEnabled() { + IPreferencesService preferencesService = Platform.getPreferencesService(); + return preferencesService.getBoolean(qualifier, + AlfIntegrationPreferencesConstants.ALF_SUPPORT, false, null); + } + + public static boolean isAlfAutoSyncEnabled() { + IPreferencesService preferencesService = Platform.getPreferencesService(); + boolean syncEnabled = preferencesService.getBoolean(qualifier, + AlfIntegrationPreferencesConstants.ALF_AUTOMATIC_SYNCHRONIZATION, false, null); + return syncEnabled && isAlfSupportEnabled(); + } +} diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF index 357c97ee8a6..3c62be446a9 100644 --- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF @@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0", org.eclipse.papyrus.uml.alf.libraries;bundle-version="1.1.0", org.eclipse.papyrus.uml.alf.transaction;bundle-version="0.7.0", org.eclipse.papyrus.uml.alf.text;bundle-version="0.7.0", - org.eclipse.compare + org.eclipse.compare, + org.eclipse.papyrus.uml.alf.preferences;bundle-version="0.7.0" Bundle-Vendor: Eclipse Modeling Project Bundle-ActivationPolicy: lazy Bundle-Version: 0.7.0.qualifier diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java index 6a0432bc2c1..2d26942bbfa 100644 --- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java +++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java @@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.IFilter; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter.FUMLScopeUtil; import org.eclipse.uml2.uml.Element; +import org.eclipse.papyrus.uml.alf.preferences.AlfIntegrationPreferencesUtil; /** * This class constrains the availability of the embedded ALF editor. @@ -45,7 +46,8 @@ public class AlfEditorPropertySectionFilter implements IFilter { public boolean select(Object toTest) { Element element = this.resolveSemanticElement(toTest); boolean accepted = false; - if(element!=null){ + if(element!=null && + AlfIntegrationPreferencesUtil.isAlfSupportEnabled()){ accepted = this.isValidInput(element); } return accepted; -- cgit v1.2.3