summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradaussy2013-10-21 06:45:32 (EDT)
committeradaussy2013-10-21 06:46:33 (EDT)
commita60498ac9b35d92ceb0ec9997a4cea2e2be6d54f (patch)
treea9b4901814c0070ae78298c9c0ee31619e6ad805
parent844a7fef4b3e1919b6e4879c7c9dbbf43b97e547 (diff)
downloadorg.eclipse.papyrus-a60498ac9b35d92ceb0ec9997a4cea2e2be6d54f.zip
org.eclipse.papyrus-a60498ac9b35d92ceb0ec9997a4cea2e2be6d54f.tar.gz
org.eclipse.papyrus-a60498ac9b35d92ceb0ec9997a4cea2e2be6d54f.tar.bz2
Bug 419954 - It shall be possible to remove advance property tab from
MDT Papyrus https://bugs.eclipse.org/bugs/show_bug.cgi?id=419954 Signed-off-by: adaussy <arthur.daussy@atos.net>
-rw-r--r--plugins/core/org.eclipse.papyrus.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/core/org.eclipse.papyrus.core/plugin.xml1
-rw-r--r--plugins/core/org.eclipse.papyrus.core/schema/manageTab.exsd127
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java14
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/IPropertyTabProvider.java36
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/PropertyTabProviderService.java128
6 files changed, 305 insertions, 2 deletions
diff --git a/plugins/core/org.eclipse.papyrus.core/META-INF/MANIFEST.MF b/plugins/core/org.eclipse.papyrus.core/META-INF/MANIFEST.MF
index 7db5032..f4d71d5 100644
--- a/plugins/core/org.eclipse.papyrus.core/META-INF/MANIFEST.MF
+++ b/plugins/core/org.eclipse.papyrus.core/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Export-Package: org.eclipse.papyrus.core,
org.eclipse.papyrus.core.extension.diagrameditor,
org.eclipse.papyrus.core.lifecycleevents,
org.eclipse.papyrus.core.listenerservice,
+ org.eclipse.papyrus.core.managetab,
org.eclipse.papyrus.core.modelsetquery,
org.eclipse.papyrus.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.resourceloading.umlprofile",
org.eclipse.papyrus.core.multidiagram.actionbarcontributor,
diff --git a/plugins/core/org.eclipse.papyrus.core/plugin.xml b/plugins/core/org.eclipse.papyrus.core/plugin.xml
index 756b31f..e31bba9 100644
--- a/plugins/core/org.eclipse.papyrus.core/plugin.xml
+++ b/plugins/core/org.eclipse.papyrus.core/plugin.xml
@@ -7,6 +7,7 @@
<extension-point id="service" name="Service" schema="schema/service.exsd"/>
<extension-point id="model" name="plugin.xml.ModelName" schema="schema/model.exsd"/>
<extension-point id="transactionalEditingDomainProvider" name="transactionalEditingDomainProvider" schema="schema/transactionalEditingDomainProvider.exsd"/>
+ <extension-point id="manageTab" name="ManageTab" schema="schema/manageTab.exsd" />
<extension
point="org.eclipse.ui.menus">
<menuContribution
diff --git a/plugins/core/org.eclipse.papyrus.core/schema/manageTab.exsd b/plugins/core/org.eclipse.papyrus.core/schema/manageTab.exsd
new file mode 100644
index 0000000..58df1bd
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/schema/manageTab.exsd
@@ -0,0 +1,127 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.core" id="org.eclipse.papyrus.core.manageTab" name="manageTab"/>
+ </appInfo>
+ <documentation>
+ Specify the content outline to be used by the Papyrus backbone.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="manageTab"/>
+ </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="manageTab">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class implementing the manageTab
+Class must extends org.eclipse.ui.views.properties.IPropertySheetPage.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.core.managetab.IPropertyTabProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="required">
+ <annotation>
+ <documentation>
+ An integer value representing the priority of the contentOutline.
+Only one contentOutline is shown. The one with the highest priority is choosen.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /*******************************************************************************
+ * Copyright (c) 2013 ATOS.
+ * 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
+ * *
+ * Contributors:
+ * EL AYADI Abdellah - ATOS - initial API and implementation
+ *******************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
index 3e4104b..66de0cc 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.core.editor;
import static org.eclipse.papyrus.core.Activator.log;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -49,6 +50,7 @@ import org.eclipse.papyrus.core.contentoutline.ContentOutlineRegistry;
import org.eclipse.papyrus.core.lifecycleevents.DoSaveEvent;
import org.eclipse.papyrus.core.lifecycleevents.IEditorInputChangedListener;
import org.eclipse.papyrus.core.lifecycleevents.ISaveAndDirtyService;
+import org.eclipse.papyrus.core.managetab.PropertyTabProviderService;
import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry;
import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor;
import org.eclipse.papyrus.core.services.ExtensionServicesRegistry;
@@ -182,7 +184,7 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
/**
*
*/
- private TabbedPropertySheetPage tabbedPropertySheetPage = null;
+ private IPropertySheetPage tabbedPropertySheetPage = null;
/**
* My editing domain provider.
@@ -364,6 +366,7 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// Do not test if tabbedPropertySheetPage is null before calling new
// this is managed by Eclipse which only call current method when
// necessary
+
return getPropertySheetPage();
}
@@ -658,7 +661,14 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
*/
public IPropertySheetPage getPropertySheetPage() {
if(this.tabbedPropertySheetPage == null) {
- this.tabbedPropertySheetPage = new TabbedPropertySheetPage(this);
+ IPropertySheetPage psp = PropertyTabProviderService.getInstance().getPropertySheetPageDescriptor(this);
+
+ if(psp != null){
+ this.tabbedPropertySheetPage = psp;
+ }else {
+
+ this.tabbedPropertySheetPage = new TabbedPropertySheetPage(this);
+ }
}
return tabbedPropertySheetPage;
}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/IPropertyTabProvider.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/IPropertyTabProvider.java
new file mode 100644
index 0000000..bb0315e
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/IPropertyTabProvider.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 ATOS.
+ *
+ *
+ * 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:
+ * EL AYADI Abdellah <abdellah.elayadi@atos.net> - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.core.managetab;
+
+import org.eclipse.papyrus.core.editor.IMultiDiagramEditor;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+public interface IPropertyTabProvider {
+
+ /**
+ * Return true if this shall provide return a {@link IPropertySheetPage}
+ * @param input Use this to determine if this provider shall provide something or not
+ * @return
+ */
+ public boolean provider(IMultiDiagramEditor input);
+
+ /**
+ * Return the {@link IPropertySheetPage} of this provider
+ * @param in
+ * @return
+ */
+ public IPropertySheetPage getProvider(ITabbedPropertySheetPageContributor in);
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/PropertyTabProviderService.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/PropertyTabProviderService.java
new file mode 100644
index 0000000..ec6c628
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/managetab/PropertyTabProviderService.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2013 ATOS.
+ *
+ *
+ * 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:
+ * EL AYADI Abdellah <abdellah.elayadi@atos.net> - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.core.managetab;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.core.editor.BackboneException;
+import org.eclipse.papyrus.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.core.extension.NotFoundException;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+public class PropertyTabProviderService {
+
+
+ private static class SingletonHolder {
+ private static final PropertyTabProviderService INSTANCE = new PropertyTabProviderService();
+ }
+
+ public static PropertyTabProviderService getInstance(){
+ return SingletonHolder.INSTANCE;
+ }
+
+
+ /** ID of the editor extension (schema filename) */
+ public static final String EDITOR_EXTENSION_ID = "manageTab";
+
+ private int priority = 0;
+
+
+ /**
+ * Constructor. defaultContext, input and site are explicitly required in
+ * order be sure that they are initialized. The multiEditor should be
+ * initialized. In particular, getEditorSite(), getEditorInput() and
+ * getDefaultContext() should return initialized values.
+ *
+ * @param multiEditor
+ * @param defaultContext
+ * @param input
+ * @param site
+ * @param extensionPointNamespace
+ */
+ protected PropertyTabProviderService() {
+ }
+
+ private List<IPropertyTabProvider> providers = null;
+
+ public List<IPropertyTabProvider> getProviders() {
+ IPropertyTabProvider higherPriority = null;
+ if(providers == null){
+ providers = new ArrayList<IPropertyTabProvider>();
+ //init
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IConfigurationElement[] configElements = extensionRegistry.getConfigurationElementsFor("org.eclipse.papyrus.core", EDITOR_EXTENSION_ID);
+ for(IConfigurationElement ele : configElements) {
+ if(ele.getName().equals(EDITOR_EXTENSION_ID)) {
+ Object newInstance;
+ try {
+ //todo order this by priority
+ newInstance = ele.createExecutableExtension("class");
+ if (newInstance instanceof IPropertyTabProvider) {
+ int newPriority = 0;
+ try {
+ newPriority = Integer.parseInt(ele.getAttribute("priority"));
+ } catch (NumberFormatException e) {
+ newPriority = 0;
+ }
+ if(this.priority < newPriority){
+ this.priority = newPriority;
+ higherPriority = (IPropertyTabProvider) newInstance;
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ if(higherPriority!=null)
+ providers.add(higherPriority);
+ return providers;
+ }
+
+ /**
+ * Return the {@link ContentOutlineDescriptor} with the highest priority.
+ *
+ * @return IPropertySheetPage
+ * @throws BackboneException
+ * @throws ClassNotFoundException
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ * @throws NotFoundException
+ * If no ContentOutline can be found in extensions
+ */
+ public IPropertySheetPage getPropertySheetPageDescriptor(IMultiDiagramEditor multiEditor){
+ for (IPropertyTabProvider p : getProviders()){
+ if(p.provider(multiEditor)){
+ if (multiEditor instanceof ITabbedPropertySheetPageContributor) {
+ IPropertySheetPage propertyPage = p.getProvider((ITabbedPropertySheetPageContributor) multiEditor);
+ return propertyPage;
+ }
+ }
+ }
+ return null;
+ }
+
+}