Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMélanie Bats2016-07-21 15:30:59 +0000
committerStéphane Bégaudeau2016-08-22 12:39:54 +0000
commitdf41562b4ae396221c11a64d568d1e7636385a52 (patch)
tree24738e736d40ab9e4b0f518a5015424ed86265f6
parent15268bee93f7397ae72bb6145914152f1eddbaef (diff)
downloadorg.eclipse.eef-df41562b4ae396221c11a64d568d1e7636385a52.tar.gz
org.eclipse.eef-df41562b4ae396221c11a64d568d1e7636385a52.tar.xz
org.eclipse.eef-df41562b4ae396221c11a64d568d1e7636385a52.zip
[489294] Provide a tab descriptor filter
This patch provides a new extension point to allow the users to filter tabs according to a condition. Bug: 489294 Change-Id: I362aaed008dbb67a7b3c2788ca87118b7f4f3bb7 Signed-off-by: Mélanie Bats <melanie.bats@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.properties.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.eef.properties.ui/plugin.xml1
-rw-r--r--plugins/org.eclipse.eef.properties.ui/schema/eefTabDescriptorFilter.exsd171
-rw-r--r--plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/api/IEEFTabDescriptorFilter.java28
-rw-r--r--plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/EEFTabbedPropertyViewPlugin.java42
-rw-r--r--plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFDescriptorRegistryEventListener.java (renamed from plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFTabDescriptorProviderRegistryEventListener.java)4
-rw-r--r--plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/registry/EEFTabbedPropertyRegistry.java22
7 files changed, 262 insertions, 7 deletions
diff --git a/plugins/org.eclipse.eef.properties.ui/plugin.properties b/plugins/org.eclipse.eef.properties.ui/plugin.properties
index 8fb92b10d..945b9d0d5 100644
--- a/plugins/org.eclipse.eef.properties.ui/plugin.properties
+++ b/plugins/org.eclipse.eef.properties.ui/plugin.properties
@@ -8,6 +8,7 @@
pluginName=EEF Properties UI
providerName=Eclipse Modeling Project
eefTabDescriptorProviderExtensionPoint.name = EEF Tab Descriptor Provider
+eefTabDescriptorFilterExtensionPoint.name = EEF Tab Descriptor Filter
DescriptorRegistryEventListener_missingAttribute=The attribute {1} is missing from the configuration element {0}.
DescriptorRegistryEventListener_extensionAlreadyContributed=The extension {0} has already been contributed.
diff --git a/plugins/org.eclipse.eef.properties.ui/plugin.xml b/plugins/org.eclipse.eef.properties.ui/plugin.xml
index bd86ef96c..0fcdc1061 100644
--- a/plugins/org.eclipse.eef.properties.ui/plugin.xml
+++ b/plugins/org.eclipse.eef.properties.ui/plugin.xml
@@ -2,5 +2,6 @@
<?eclipse version="3.4"?>
<plugin>
<extension-point id="eefTabDescriptorProvider" name="%eefTabDescriptorProviderExtensionPoint.name" schema="schema/eefTabDescriptorProvider.exsd"/>
+ <extension-point id="eefTabDescriptorFilter" name="%eefTabDescriptorFilterExtensionPoint.name" schema="schema/eefTabDescriptorFilter.exsd"/>
</plugin>
diff --git a/plugins/org.eclipse.eef.properties.ui/schema/eefTabDescriptorFilter.exsd b/plugins/org.eclipse.eef.properties.ui/schema/eefTabDescriptorFilter.exsd
new file mode 100644
index 000000000..bbe07f680
--- /dev/null
+++ b/plugins/org.eclipse.eef.properties.ui/schema/eefTabDescriptorFilter.exsd
@@ -0,0 +1,171 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.eef.properties.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.eef.properties.ui" id="eefTabDescriptorFilter" name="EEF Tab Descriptor Filter"/>
+ </appinfo>
+ <documentation>
+ This extension point allows to filter tabs contributed to the EEF tabbed property sheet page by implementing &lt;code&gt;org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter&lt;/code&gt;.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="descriptor" 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="descriptor">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The identifier of the contribution.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+ The label of the filter, this information may be used in the user interface and as such it may be visible by the end user. It should be internationalized if possible.
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string" use="required">
+ <annotation>
+ <documentation>
+ The description of the filter, this information may be used in the user interface and as such it may be visible by the end user. It should be internationalized if possible.
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The implementation of the IEEFTabDescriptorFilter.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ This extension point has been available since Eclipse EEF 1.7.0.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+&lt;extension
+ point=&quot;org.eclipse.eef.properties.ui.eefTabDescriptorFilter&quot;&gt;
+ &lt;descriptor
+ class=&quot;org.eclipse.eef.sample.internal.extensions.SampleTabDescriptorFilter&quot;
+ description=&quot;Provides EEF Tab filter&quot;
+ id=&quot;org.eclipse.eef.sample.eefTabDescriptorFilter&quot;
+ label=&quot;EEF Sample Tab Descriptor Filter&quot;&gt;
+ &lt;/descriptor&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+Example of IEEFTabDescriptorFilter contribution. In this example, we are providing a contribution used to filter legacy tabs to the Properties view created by EEF.
+&lt;pre&gt;
+import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
+import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;
+
+public class SampleTabDescriptorFilter implements IEEFTabDescriptorFilter {
+
+ @Override
+ public boolean filter(IEEFTabDescriptor tabDescriptor) {
+ // Write here a useful condition
+ return false;
+ }
+
+}
+&lt;/pre&gt;
+This example requires at least the following dependencies:
+&lt;ul&gt;
+ &lt;li&gt;org.eclipse.eef.common&lt;/li&gt;
+ &lt;li&gt;org.eclipse.eef.properties.ui&lt;/li&gt;
+&lt;/ul&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ The IEEFTabDescriptorProvider allows the contribution of a set of tabs for the EEF-based tabbed property sheet page.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ EEF does not provide any implementation of this API. The Eclipse Sirius project provides a complex implementation of this API. To understand the basic concepts of this API, have a look at the example in this description first.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2016 Obeo&lt;br/&gt;
+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
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/api/IEEFTabDescriptorFilter.java b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/api/IEEFTabDescriptorFilter.java
new file mode 100644
index 000000000..e2431874b
--- /dev/null
+++ b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/api/IEEFTabDescriptorFilter.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.eef.properties.ui.api;
+
+/**
+ * This interface is used to filter {@link IEEFTabDescriptor}.
+ *
+ * @author mbats
+ */
+public interface IEEFTabDescriptorFilter {
+ /**
+ * Returns if a tab descriptor must be filtered or not.
+ *
+ * @param tabDescriptor
+ * The tab descriptor
+ *
+ * @return <code>true</code> if the tab descriptor should be used, <code>false</code> otherwise
+ */
+ boolean filter(IEEFTabDescriptor tabDescriptor);
+}
diff --git a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/EEFTabbedPropertyViewPlugin.java b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/EEFTabbedPropertyViewPlugin.java
index e6a566e43..ceadf0619 100644
--- a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/EEFTabbedPropertyViewPlugin.java
+++ b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/EEFTabbedPropertyViewPlugin.java
@@ -14,10 +14,11 @@ package org.eclipse.eef.properties.ui.internal;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.eef.common.api.AbstractEEFEclipsePlugin;
+import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorProvider;
import org.eclipse.eef.properties.ui.internal.extension.AbstractRegistryEventListener;
import org.eclipse.eef.properties.ui.internal.extension.IItemRegistry;
-import org.eclipse.eef.properties.ui.internal.extension.impl.EEFTabDescriptorProviderRegistryEventListener;
+import org.eclipse.eef.properties.ui.internal.extension.impl.EEFDescriptorRegistryEventListener;
import org.eclipse.eef.properties.ui.internal.extension.impl.ItemRegistry;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
@@ -83,17 +84,33 @@ public class EEFTabbedPropertyViewPlugin extends EMFPlugin {
private static final String EEF_TAB_DESCRIPTOR_PROVIDER_EXTENSION_POINT = "eefTabDescriptorProvider"; //$NON-NLS-1$
/**
+ * The name of the extension point for the tab descriptor filter.
+ */
+ private static final String EEF_TAB_DESCRIPTOR_FILTER_EXTENSION_POINT = "eefTabDescriptorFilter"; //$NON-NLS-1$
+
+ /**
* The {@link IItemRegistry} used to retrieve the tab descriptor provider {@link IEEFTabDescriptorProvider}.
*/
private IItemRegistry<IEEFTabDescriptorProvider> eefTabDescriptorProviderRegistry;
/**
+ * The {@link IItemRegistry} used to retrieve the tab descriptor filter {@link IEEFTabDescriptorFilter}.
+ */
+ private IItemRegistry<IEEFTabDescriptorFilter> eefTabDescriptorFilterRegistry;
+
+ /**
* The extension registry listener used to populate the registry of tab descriptor provider
* {@link IEEFTabDescriptorProvider}.
*/
private AbstractRegistryEventListener eefTabDescriptorProviderListener;
/**
+ * The extension registry listener used to populate the registry of tab descriptor filter
+ * {@link IEEFTabDescriptorFilter}.
+ */
+ private AbstractRegistryEventListener eefTabDescriptorFilterListener;
+
+ /**
* The constructor.
*/
public Implementation() {
@@ -114,10 +131,16 @@ public class EEFTabbedPropertyViewPlugin extends EMFPlugin {
IExtensionRegistry registry = Platform.getExtensionRegistry();
this.eefTabDescriptorProviderRegistry = new ItemRegistry<IEEFTabDescriptorProvider>();
- this.eefTabDescriptorProviderListener = new EEFTabDescriptorProviderRegistryEventListener<IEEFTabDescriptorProvider>(PLUGIN_ID,
+ this.eefTabDescriptorProviderListener = new EEFDescriptorRegistryEventListener<IEEFTabDescriptorProvider>(PLUGIN_ID,
EEF_TAB_DESCRIPTOR_PROVIDER_EXTENSION_POINT, this.eefTabDescriptorProviderRegistry);
registry.addListener(this.eefTabDescriptorProviderListener, PLUGIN_ID + '.' + EEF_TAB_DESCRIPTOR_PROVIDER_EXTENSION_POINT);
this.eefTabDescriptorProviderListener.readRegistry(registry);
+
+ this.eefTabDescriptorFilterRegistry = new ItemRegistry<IEEFTabDescriptorFilter>();
+ this.eefTabDescriptorFilterListener = new EEFDescriptorRegistryEventListener<IEEFTabDescriptorFilter>(PLUGIN_ID,
+ EEF_TAB_DESCRIPTOR_FILTER_EXTENSION_POINT, this.eefTabDescriptorFilterRegistry);
+ registry.addListener(this.eefTabDescriptorFilterListener, PLUGIN_ID + '.' + EEF_TAB_DESCRIPTOR_FILTER_EXTENSION_POINT);
+ this.eefTabDescriptorFilterListener.readRegistry(registry);
}
/**
@@ -132,18 +155,29 @@ public class EEFTabbedPropertyViewPlugin extends EMFPlugin {
IExtensionRegistry registry = Platform.getExtensionRegistry();
registry.removeListener(this.eefTabDescriptorProviderListener);
+ registry.removeListener(this.eefTabDescriptorFilterListener);
this.eefTabDescriptorProviderListener = null;
+ this.eefTabDescriptorFilterListener = null;
this.eefTabDescriptorProviderRegistry = null;
}
/**
- * Return the tabbedPropertyTabsRegistry.
+ * Return the TabDescriptorProviderRegistry.
*
- * @return the tabbedPropertyTabsRegistry
+ * @return the TabDescriptorProviderRegistry
*/
public IItemRegistry<IEEFTabDescriptorProvider> getEEFTabDescriptorProviderRegistry() {
return this.eefTabDescriptorProviderRegistry;
}
+
+ /**
+ * Return the TabDescriptorFilterRegistry.
+ *
+ * @return the TabDescriptorFilterRegistry
+ */
+ public IItemRegistry<IEEFTabDescriptorFilter> getEEFTabDescriptorFilterRegistry() {
+ return this.eefTabDescriptorFilterRegistry;
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFTabDescriptorProviderRegistryEventListener.java b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFDescriptorRegistryEventListener.java
index d23e5e9fa..4ceff3cad 100644
--- a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFTabDescriptorProviderRegistryEventListener.java
+++ b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/extension/impl/EEFDescriptorRegistryEventListener.java
@@ -30,7 +30,7 @@ import org.eclipse.eef.properties.ui.internal.extension.IItemRegistry;
* @param <T>
* The type of the Object described
*/
-public class EEFTabDescriptorProviderRegistryEventListener<T> extends AbstractRegistryEventListener {
+public class EEFDescriptorRegistryEventListener<T> extends AbstractRegistryEventListener {
/** Id attribute of the extension point. */
public static final String ID_DESCRIPTOR_ATTR = "id"; //$NON-NLS-1$
@@ -61,7 +61,7 @@ public class EEFTabDescriptorProviderRegistryEventListener<T> extends AbstractRe
* @param itemRegistry
* The {@link IItemRegistry}
*/
- public EEFTabDescriptorProviderRegistryEventListener(String namespace, String extensionPointID, IItemRegistry<T> itemRegistry) {
+ public EEFDescriptorRegistryEventListener(String namespace, String extensionPointID, IItemRegistry<T> itemRegistry) {
super(namespace, extensionPointID);
this.itemRegistry = itemRegistry;
}
diff --git a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/registry/EEFTabbedPropertyRegistry.java b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/registry/EEFTabbedPropertyRegistry.java
index 4c0682c3a..51ca44479 100644
--- a/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/registry/EEFTabbedPropertyRegistry.java
+++ b/plugins/org.eclipse.eef.properties.ui/src/org/eclipse/eef/properties/ui/internal/registry/EEFTabbedPropertyRegistry.java
@@ -19,6 +19,7 @@ import java.util.Map;
import org.eclipse.eef.properties.ui.api.AbstractEEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFSectionDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
+import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorProvider;
import org.eclipse.eef.properties.ui.internal.EEFTabbedPropertyViewPlugin;
import org.eclipse.eef.properties.ui.internal.Messages;
@@ -69,7 +70,7 @@ public class EEFTabbedPropertyRegistry {
IEEFTabDescriptorProvider eefTabDescriptorProvider = itemDescriptor.getItem();
for (IEEFTabDescriptor eefTabDescriptor : eefTabDescriptorProvider.get(part, input)) {
String eefTabDescriptorId = eefTabDescriptor.getId();
- if (!eefTabDescriptors.containsKey(eefTabDescriptorId)) {
+ if (!eefTabDescriptors.containsKey(eefTabDescriptorId) && filter(eefTabDescriptor)) {
eefTabDescriptors.put(eefTabDescriptorId, eefTabDescriptor);
}
}
@@ -78,6 +79,25 @@ public class EEFTabbedPropertyRegistry {
}
/**
+ * Returns if a tab descriptor must be filtered or not.
+ *
+ * @param eefTabDescriptor
+ * The tab descriptor
+ * @return <code>true</code> if the tab descriptor should be used, <code>false</code> otherwise
+ */
+ private boolean filter(IEEFTabDescriptor eefTabDescriptor) {
+ IItemRegistry<IEEFTabDescriptorFilter> eefTabDescriptorFilterRegistry = EEFTabbedPropertyViewPlugin.getPlugin()
+ .getEEFTabDescriptorFilterRegistry();
+ for (IItemDescriptor<IEEFTabDescriptorFilter> itemDescriptor : eefTabDescriptorFilterRegistry.getItemDescriptors()) {
+ IEEFTabDescriptorFilter eefTabDescriptorFilter = itemDescriptor.getItem();
+ if (!eefTabDescriptorFilter.filter(eefTabDescriptor)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Returns the descriptors.
*
* @param part

Back to the top