Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMélanie Bats2016-09-26 09:43:15 +0000
committerPierre-Charles David2016-09-26 14:07:24 +0000
commite82e19ab7dafa9775a1b11bd0424b8d46cbbfe2c (patch)
treee0783baaf6164d84d882929e418146056e346be6
parentd8dc18acae0a1bdc8f3585841afe8a801303243a (diff)
downloadorg.eclipse.sirius-e82e19ab7dafa9775a1b11bd0424b8d46cbbfe2c.tar.gz
org.eclipse.sirius-e82e19ab7dafa9775a1b11bd0424b8d46cbbfe2c.tar.xz
org.eclipse.sirius-e82e19ab7dafa9775a1b11bd0424b8d46cbbfe2c.zip
[496058] Add preferences to filter the Semantic/Default tabs
Add a preference page for the properties view to let the final user choosing if the Semantic and the Default tabs should be filtered or not. Bug: 496058 Change-Id: If873fa264ee23f8254b0fb31cd1cef185fe3362a Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/plugin.properties8
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/plugin.xml15
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/api/preferences/SiriusPropertiesViewPreferencesKeys.java52
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java62
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/filter/SiriusTabDescriptorFilter.java16
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/Messages.java43
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewGeneralPreferencePage.java78
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewPreferenceInitializer.java37
9 files changed, 308 insertions, 7 deletions
diff --git a/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
index 5ef053e280..4d21847abc 100644
--- a/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF
@@ -37,8 +37,10 @@ Bundle-Activator: org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPl
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.sirius.ui.properties.api;version="4.1.0",
+ org.eclipse.sirius.ui.properties.api.preferences;version="4.1.0",
org.eclipse.sirius.ui.properties.internal;version="4.1.0";x-internal:=true,
org.eclipse.sirius.ui.properties.internal.expressions;version="4.1.0";x-internal:=true,
org.eclipse.sirius.ui.properties.internal.migration;version="4.1.0";x-internal:=true,
org.eclipse.sirius.ui.properties.internal.tabprovider;version="4.1.0";x-internal:=true,
- org.eclipse.sirius.ui.properties.internal.filter;version="4.1.0";x-internal:=true
+ org.eclipse.sirius.ui.properties.internal.filter;version="4.1.0";x-internal:=true,
+ org.eclipse.sirius.ui.properties.internal.preferences;version="4.1.0";x-internal:=true
diff --git a/plugins/org.eclipse.sirius.ui.properties/plugin.properties b/plugins/org.eclipse.sirius.ui.properties/plugin.properties
index 3c4e49275e..8e9d1aea8c 100644
--- a/plugins/org.eclipse.sirius.ui.properties/plugin.properties
+++ b/plugins/org.eclipse.sirius.ui.properties/plugin.properties
@@ -24,4 +24,10 @@ SiriusTabDescriptorProvider_DefaultPropertiesNotFound=The model containing the d
IDescriptionConverter_InvalidDescriptionType=The type of the description is invalid: received {0}, expected {1}
siriusTabDescriptorFilter.Label=Sirius EEF Tab Descriptor Filter
-siriusTabDescriptorFilter.Description=Filters the properties tabs according to a precondition \ No newline at end of file
+siriusTabDescriptorFilter.Description=Filters the properties tabs according to a precondition
+
+# Preferences
+preference.page.title.org.eclipse.sirius.ui.properties.general=Sirius Properties View
+SiriusPropertiesPreferencePage_filterGroup= Legacy Tabs
+SiriusPropertiesPreferencePage_semanticTab= Show Semantic Tab
+SiriusPropertiesPreferencePage_defaultTab= Show Default Tab \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius.ui.properties/plugin.xml b/plugins/org.eclipse.sirius.ui.properties/plugin.xml
index 685348669c..bac5d8561f 100644
--- a/plugins/org.eclipse.sirius.ui.properties/plugin.xml
+++ b/plugins/org.eclipse.sirius.ui.properties/plugin.xml
@@ -92,4 +92,19 @@
label="%siriusTabDescriptorFilter.Label">
</descriptor>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.sirius.ui.page"
+ class="org.eclipse.sirius.ui.properties.internal.preferences.SiriusPropertiesViewGeneralPreferencePage"
+ id="org.eclipse.sirius.ui.properties.general"
+ name="%preference.page.title.org.eclipse.sirius.ui.properties.general">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.sirius.ui.properties.internal.preferences.SiriusPropertiesViewPreferenceInitializer">
+ </initializer>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/api/preferences/SiriusPropertiesViewPreferencesKeys.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/api/preferences/SiriusPropertiesViewPreferencesKeys.java
new file mode 100644
index 0000000000..1e92508aec
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/api/preferences/SiriusPropertiesViewPreferencesKeys.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.api.preferences;
+
+/**
+ * The properties view preference keys.
+ *
+ * @author mbats
+ */
+public enum SiriusPropertiesViewPreferencesKeys {
+
+ /**
+ * Says if the semantic tab should be automatically filtered or not.
+ */
+ PREF_FILTER_PROPERTIES_VIEW_SEMANTIC_TAB(boolean.class),
+
+ /**
+ * Says if the default tab should be automatically filtered or not.
+ */
+ PREF_FILTER_PROPERTIES_VIEW_DEFAULT_TAB(boolean.class);
+
+ /** The type of the preference. */
+ private final Class<?> type;
+
+ /**
+ * Creates a new DesignerPreferencesKeys with the given type.
+ *
+ * @param type
+ * the type of the value of the preference.
+ */
+ private SiriusPropertiesViewPreferencesKeys(final Class<?> type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the type of the value of the preference of this key.
+ *
+ * @return the type of the value of the preference of this key.
+ */
+ public Class<?> getType() {
+ return type;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java
index c99e46babb..18d2c643a2 100644
--- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusUIPropertiesPlugin.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.eef.EefPackage;
import org.eclipse.eef.common.api.AbstractEEFEclipsePlugin;
import org.eclipse.eef.ide.api.extensions.AbstractRegistryEventListener;
@@ -25,6 +26,9 @@ import org.eclipse.eef.ide.api.extensions.impl.ItemRegistry;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.sirius.ui.properties.api.DefaultDescriptionConverter;
import org.eclipse.sirius.ui.properties.api.DefaultDescriptionWithInitialOperationConverter;
import org.eclipse.sirius.ui.properties.api.IDescriptionConverter;
@@ -35,6 +39,7 @@ import org.eclipse.sirius.ui.properties.internal.tabprovider.SemanticValidationR
import org.eclipse.sirius.viewpoint.description.validation.RuleAudit;
import org.eclipse.sirius.viewpoint.description.validation.SemanticValidationRule;
import org.eclipse.sirius.viewpoint.description.validation.ValidationFix;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
/**
@@ -123,11 +128,22 @@ public class SiriusUIPropertiesPlugin extends EMFPlugin {
private AbstractRegistryEventListener descriptionLinkResolverListener;
/**
+ * Storage for preferences.
+ */
+ private ScopedPreferenceStore preferenceStore;
+
+ /**
+ * The property change listener.
+ */
+ private IPropertyChangeListener propertyChangeListener;
+
+ /**
* The constructor.
*/
public Implementation() {
super(PLUGIN_ID);
SiriusUIPropertiesPlugin.plugin = this;
+ startPropertiesPreferencesManagement();
}
@Override
@@ -157,6 +173,8 @@ public class SiriusUIPropertiesPlugin extends EMFPlugin {
this.descriptionLinkResolverListener = null;
this.descriptionLinkResolverRegistry = null;
+ stopPropertiesPreferencesManagement();
+
super.stop(context);
}
@@ -215,6 +233,48 @@ public class SiriusUIPropertiesPlugin extends EMFPlugin {
return linkResolvers;
}
- }
+ /**
+ * Starts the management of the Preferences of the core of Designer.
+ *
+ */
+ private void startPropertiesPreferencesManagement() {
+ propertyChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Object newValue = event.getNewValue();
+ preferenceStore.putValue(event.getProperty(), String.valueOf(newValue));
+ }
+ };
+ getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Stops the management of the Preferences of the core of Designer.
+ *
+ */
+ private void stopPropertiesPreferencesManagement() {
+ getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
+ }
+ /**
+ * Returns the preference store for this UI plug-in. This preference
+ * store is used to hold persistent settings for this plug-in in the
+ * context of a workbench. Some of these settings will be user
+ * controlled.
+ * <p>
+ * If an error occurs reading the preference store, an empty preference
+ * store is quietly created, initialized with defaults, and returned.
+ * </p>
+ *
+ * @return the preference store
+ */
+ public IPreferenceStore getPreferenceStore() {
+ // Create the preference store lazily.
+ if (preferenceStore == null) {
+ preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, INSTANCE.getSymbolicName());
+
+ }
+ return preferenceStore;
+ }
+ }
}
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/filter/SiriusTabDescriptorFilter.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/filter/SiriusTabDescriptorFilter.java
index c0d2d1ba8b..f52cdc4315 100644
--- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/filter/SiriusTabDescriptorFilter.java
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/filter/SiriusTabDescriptorFilter.java
@@ -12,6 +12,8 @@ package org.eclipse.sirius.ui.properties.internal.filter;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;
+import org.eclipse.sirius.ui.properties.api.preferences.SiriusPropertiesViewPreferencesKeys;
+import org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin;
/**
* The {@link IEEFTabDescriptorFilter} for Eclipse Sirius.
@@ -32,11 +34,17 @@ public class SiriusTabDescriptorFilter implements IEEFTabDescriptorFilter {
@Override
public boolean filter(IEEFTabDescriptor tabDescriptor) {
+ boolean result = true;
// Filter the default tab existing in the properties view when an
- // element is selected from the
- // model explorer and the semantic tab when an element is selected from
- // a Sirius editor
- return !DEFAULT_TAB_ID.equals(tabDescriptor.getId()) && !SEMANTIC_TAB_ID.equals(tabDescriptor.getId());
+ // element is selected from the model explorer and the semantic tab when
+ // an element is selected from a Sirius editor
+ if (SEMANTIC_TAB_ID.equals(tabDescriptor.getId())) {
+ result = SiriusUIPropertiesPlugin.getPlugin().getPreferenceStore().getBoolean(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_SEMANTIC_TAB.name());
+ } else if (DEFAULT_TAB_ID.equals(tabDescriptor.getId())) {
+ result = SiriusUIPropertiesPlugin.getPlugin().getPreferenceStore().getBoolean(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_DEFAULT_TAB.name());
+ }
+
+ return result;
}
}
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/Messages.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/Messages.java
new file mode 100644
index 0000000000..c04f81de36
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/Messages.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import org.eclipse.sirius.ext.base.I18N;
+import org.eclipse.sirius.ext.base.I18N.TranslatableMessage;
+import org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin;
+
+/**
+ * Helper class to obtain translated strings.
+ *
+ * @author mbats
+ */
+public final class Messages {
+
+ static {
+ I18N.initializeMessages(Messages.class, SiriusUIPropertiesPlugin.INSTANCE);
+ }
+
+ // CHECKSTYLE:OFF
+ @TranslatableMessage
+ public static String SiriusPropertiesPreferencePage_filterGroup;
+
+ @TranslatableMessage
+ public static String SiriusPropertiesPreferencePage_semanticTab;
+
+ @TranslatableMessage
+ public static String SiriusPropertiesPreferencePage_defaultTab;
+
+ // CHECKSTYLE:ON
+
+ private Messages() {
+ // Prevents instanciation.
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewGeneralPreferencePage.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewGeneralPreferencePage.java
new file mode 100644
index 0000000000..d2ef819a13
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewGeneralPreferencePage.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.sirius.ui.properties.api.preferences.SiriusPropertiesViewPreferencesKeys;
+import org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * The properties view preference page.
+ *
+ * @author mbats
+ */
+public class SiriusPropertiesViewGeneralPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private BooleanFieldEditor filterSemanticTab;
+
+ private BooleanFieldEditor filterDefaultTab;
+
+ @Override
+ protected void createFieldEditors() {
+ setPreferenceStore(SiriusUIPropertiesPlugin.getPlugin().getPreferenceStore());
+
+ Composite parent = getFieldEditorParent();
+ if (parent.getLayout() == null) {
+ GridLayout gridLayout = new GridLayout(1, false);
+ parent.setLayout(gridLayout);
+ }
+
+ addFilterFields(parent);
+
+ }
+
+ private void addFilterFields(Composite parent) {
+ Composite refreshComposite = createGroup(parent, Messages.SiriusPropertiesPreferencePage_filterGroup);
+
+ filterSemanticTab = new BooleanFieldEditor(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_SEMANTIC_TAB.name(), Messages.SiriusPropertiesPreferencePage_semanticTab,
+ new Composite(refreshComposite, SWT.NONE));
+ addField(filterSemanticTab);
+
+ filterDefaultTab = new BooleanFieldEditor(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_DEFAULT_TAB.name(), Messages.SiriusPropertiesPreferencePage_defaultTab,
+ new Composite(refreshComposite, SWT.NONE));
+ addField(filterDefaultTab);
+ }
+
+ private Group createGroup(Composite parent, String text) {
+ Group group = new Group(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(1, false);
+ group.setLayout(gridLayout);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 1;
+ group.setLayoutData(gridData);
+ group.setText(text);
+
+ return group;
+ }
+
+ @Override
+ public void init(final IWorkbench workbench) {
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewPreferenceInitializer.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewPreferenceInitializer.java
new file mode 100644
index 0000000000..2d09e11be0
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/preferences/SiriusPropertiesViewPreferenceInitializer.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.sirius.ui.properties.api.preferences.SiriusPropertiesViewPreferencesKeys;
+import org.eclipse.sirius.ui.properties.internal.SiriusUIPropertiesPlugin;
+
+/**
+ * The properties preference initializer.
+ *
+ * @author mbats
+ */
+public class SiriusPropertiesViewPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ final IPreferenceStore preferenceStore = SiriusUIPropertiesPlugin.getPlugin().getPreferenceStore();
+ // By default the Semantic and Default tabs are visible
+ preferenceStore.setDefault(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_DEFAULT_TAB.name(), true);
+ preferenceStore.setDefault(SiriusPropertiesViewPreferencesKeys.PREF_FILTER_PROPERTIES_VIEW_SEMANTIC_TAB.name(), true);
+ }
+}

Back to the top