Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-04-26 09:29:01 +0000
committercletavernie2012-04-26 09:29:01 +0000
commit8522ae7a0ca0b7ccc03ecd8c548d3dc1750c63d0 (patch)
treef6e03ed460ef02663d678c2c7e7f6e814946929a /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common
parent53feba205450c47e68abcf6648999e9dc09786cd (diff)
downloadorg.eclipse.papyrus-8522ae7a0ca0b7ccc03ecd8c548d3dc1750c63d0.tar.gz
org.eclipse.papyrus-8522ae7a0ca0b7ccc03ecd8c548d3dc1750c63d0.tar.xz
org.eclipse.papyrus-8522ae7a0ca0b7ccc03ecd8c548d3dc1750c63d0.zip
370575: [Papyrus] Avoid using fragments for Papyrus plug-ins
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370575
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/schema/paletteCustomization.exsd102
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/PapyrusPaletteViewer.java49
4 files changed, 130 insertions, 24 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
index 326909cd8a7..251291354db 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
@@ -85,4 +85,4 @@ Bundle-Version: 0.9.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.Activator
Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.common;singleton:=true
-
+Eclipse-BuddyPolicy: dependent
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
index 9247435d415..a018242f11c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
@@ -21,6 +21,7 @@
<extension-point id="moskittEditorFactory" name="moskittEditorFactory" schema="schema/moskittEditorFactory.exsd"/>
<extension-point id="paletteDefinition" name="PaletteDefinition" schema="schema/paletteDefinition.exsd"/>
<extension-point id="aspectToolProvider" name="aspectToolProvider" schema="schema/aspectToolProvider.exsd"/>
+ <extension-point id="paletteCustomization" name="Palette customization" schema="schema/paletteCustomization.exsd"/>
<extension point="org.eclipse.ui.views">
<category
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/schema/paletteCustomization.exsd b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/schema/paletteCustomization.exsd
new file mode 100644
index 00000000000..863d3f3bcf3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/schema/paletteCustomization.exsd
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.uml.diagram.common" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.uml.diagram.common" id="paletteCustomization" name="Palette customization"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <choice>
+ <element ref="customizer"/>
+ </choice>
+ <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="customizer">
+ <complexType>
+ <attribute name="customizerDialog" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </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>
+
+
+</schema>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/PapyrusPaletteViewer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/PapyrusPaletteViewer.java
index a8de011a48b..e3d2976f911 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/PapyrusPaletteViewer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/PapyrusPaletteViewer.java
@@ -14,8 +14,9 @@
package org.eclipse.papyrus.uml.diagram.common.part;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.palette.PaletteCustomizer;
import org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog;
@@ -29,6 +30,10 @@ import org.eclipse.swt.widgets.Shell;
*/
public class PapyrusPaletteViewer extends PaletteViewerEx {
+ public static final String EXTENSION_ID = Activator.ID + ".paletteCustomization"; //$NON-NLS-1$
+
+ public static final String CUSTOMIZER_ATTRIBUTE = "customizerDialog"; //$NON-NLS-1$
+
/** cached dialog for the customization */
private PaletteCustomizerDialog customizerDialog = null;
@@ -38,30 +43,28 @@ public class PapyrusPaletteViewer extends PaletteViewerEx {
@Override
public PaletteCustomizerDialog getCustomizerDialog() {
if(customizerDialog == null) {
- try {
- @SuppressWarnings("unchecked")
- Class<PaletteCustomizerDialog> advancedCustomizerDialogClass = (Class<PaletteCustomizerDialog>)Activator.getDefault().getBundle().loadClass("org.eclipse.papyrus.customization.palette.dialog.PapyrusPaletteCustomizerDialog");
- Constructor<PaletteCustomizerDialog> constructor = advancedCustomizerDialogClass.getConstructor(Shell.class, PaletteCustomizer.class, PaletteRoot.class);
- if(constructor != null) {
- customizerDialog = constructor.newInstance(getControl().getShell(), getCustomizer(), getPaletteRoot());
- if(customizerDialog == null) {
- // be sure it is not null
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
+ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ //Load from extension point
+ for(IConfigurationElement e : config) {
+ String customizerClassName = e.getAttribute("customizerDialog"); //$NON-NLS-1$
+ try {
+ Class<? extends PaletteCustomizerDialog> advancedCustomizerDialogClass = Activator.getDefault().getBundle().loadClass(customizerClassName).asSubclass(PaletteCustomizerDialog.class);
+ if(advancedCustomizerDialogClass != null) {
+ Constructor<? extends PaletteCustomizerDialog> constructor = advancedCustomizerDialogClass.getConstructor(Shell.class, PaletteCustomizer.class, PaletteRoot.class);
+ if(constructor != null) {
+ customizerDialog = constructor.newInstance(getControl().getShell(), getCustomizer(), getPaletteRoot());
+ break;
+ }
}
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ continue;
}
- } catch (ClassNotFoundException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (IllegalArgumentException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (InstantiationException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (IllegalAccessException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (InvocationTargetException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (SecurityException e) {
- customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
- } catch (NoSuchMethodException e) {
+ }
+
+ if(customizerDialog == null) {
+ // be sure it is not null
customizerDialog = new PaletteCustomizerDialogEx(getControl().getShell(), getCustomizer(), getPaletteRoot());
}
}

Back to the top