[268179] Java EE preference page needs to be extensible
diff --git a/plugins/org.eclipse.jst.j2ee.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.j2ee.ui/META-INF/MANIFEST.MF
index d3ff9b1..f37e342 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.j2ee.ui/META-INF/MANIFEST.MF
@@ -27,7 +27,8 @@
org.eclipse.jst.j2ee.ui.archive,
org.eclipse.jst.j2ee.ui.archive.internal,
org.eclipse.jst.j2ee.ui.project.facet,
- org.eclipse.jst.j2ee.ui.project.facet.appclient
+ org.eclipse.jst.j2ee.ui.project.facet.appclient,
+ org.eclipse.jst.j2ee.internal.ui.preferences
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/IJavaEEPreferencePageExtender.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/IJavaEEPreferencePageExtender.java
new file mode 100644
index 0000000..925a54b
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/IJavaEEPreferencePageExtender.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.j2ee.internal.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+
+public abstract interface IJavaEEPreferencePageExtender {
+
+ Composite extendPage(Composite parent);
+ void performDefaults();
+ boolean performOk();
+ void dispose();
+}
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java
index 768e346..027a1f3 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java
@@ -1,5 +1,8 @@
package org.eclipse.jst.j2ee.internal.ui.preferences;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.PreferencePage;
@@ -17,6 +20,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+
public class JavaEEPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
@@ -24,6 +28,7 @@
private String name = J2EEPlugin.DYNAMIC_TRANSLATION_OF_JET_TEMPLATES_PREF_KEY;
private Button showReferences;
private boolean dynamicTranslation;
+ private ArrayList<IJavaEEPreferencePageExtender> extenders = new ArrayList();
public JavaEEPreferencePage() {
setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_NAME));
@@ -35,6 +40,10 @@
J2EEPlugin.getDefault().savePluginPreferences();
dynamicTranslation = preferences.getBoolean(name);
showReferences.setSelection(dynamicTranslation);
+ for(IJavaEEPreferencePageExtender extender : extenders ){
+ extender.performDefaults();
+ }
+
super.performDefaults();
}
@@ -60,6 +69,8 @@
dynamicTranslation = showReferences.getSelection();
}
});
+ invokeExtensions(result);
+
return result;
}
@@ -72,6 +83,27 @@
public boolean performOk() {
preferences.setValue(name, showReferences.getSelection());
J2EEPlugin.getDefault().savePluginPreferences();
- return super.performOk();
+ boolean result = false;
+ for(IJavaEEPreferencePageExtender extender : extenders ){
+ result = extender.performOk();
+ }
+ result = super.performOk();
+ return result;
}
+
+
+ protected void invokeExtensions(Composite parent){
+ List<JavaEEPreferencePageExtension> list = JavaEEPreferencePageExtensionReader.getInstance().getJavaEEPageExtenders();
+ for(JavaEEPreferencePageExtension pageExtension : list ){
+ IJavaEEPreferencePageExtender extender = pageExtension.getInstance();
+ extenders.add(extender);
+ extender.extendPage(parent);
+ }
+ }
+
+ public void dispose(){
+ for(IJavaEEPreferencePageExtender extender : extenders ){
+ extender.dispose();
+ }
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtension.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtension.java
new file mode 100644
index 0000000..a20e338
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtension.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jst.j2ee.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.wst.common.internal.emf.utilities.Assert;
+
+
+
+
+
+public class JavaEEPreferencePageExtension {
+
+ public static final String ATT_ID = "id"; //$NON-NLS-1$
+ public static final String ATT_CLASS = "class"; //$NON-NLS-1$
+ public static final String JAVAEE_PAGE_EXTENSION = "javaeepageextender"; //$NON-NLS-1$
+
+ private String id = null;
+ private IConfigurationElement element;
+ private IJavaEEPreferencePageExtender instance;
+ private boolean errorCondition = false;
+
+ public JavaEEPreferencePageExtension(){
+ super();
+ }
+
+ private void init() {
+ id = element.getAttribute(ATT_ID);
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * The id to set.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public JavaEEPreferencePageExtension(IConfigurationElement element) {
+ Assert.isLegal(JAVAEE_PAGE_EXTENSION.equals(element.getName()), "Extensions must be of the type \"" + JAVAEE_PAGE_EXTENSION + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
+ this.element = element;
+ init();
+ }
+
+ public IJavaEEPreferencePageExtender getInstance() {
+ try {
+ if (instance == null && !errorCondition)
+ instance = (IJavaEEPreferencePageExtender) element.createExecutableExtension("className"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ errorCondition = true;
+ }
+ return instance;
+ }
+}
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtensionReader.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtensionReader.java
new file mode 100644
index 0000000..b2eee93
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePageExtensionReader.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jst.j2ee.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jem.util.RegistryReader;
+
+
+
+public class JavaEEPreferencePageExtensionReader extends RegistryReader {
+
+ private static JavaEEPreferencePageExtensionReader instance = null;
+ private List<JavaEEPreferencePageExtension> pageExtenders = null;
+
+ public JavaEEPreferencePageExtensionReader(){
+ super("org.eclipse.jst.j2ee.ui", "JavaEEPreferencePageExtender"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ public static JavaEEPreferencePageExtensionReader getInstance() {
+ if (instance == null) {
+ instance = new JavaEEPreferencePageExtensionReader();
+ instance.readRegistry();
+ }
+ return instance;
+ }
+
+ public boolean readElement(IConfigurationElement element) {
+ if (JavaEEPreferencePageExtension.JAVAEE_PAGE_EXTENSION.equals(element.getName())) {
+ addExtension(element);
+ return true;
+ }
+ return false;
+ }
+
+ protected void addExtension(IConfigurationElement newExtension) {
+ getJavaEEPageExtenders().add(new JavaEEPreferencePageExtension(newExtension));
+ }
+
+ public List<JavaEEPreferencePageExtension> getJavaEEPageExtenders() {
+ if (pageExtenders == null)
+ pageExtenders = new ArrayList();
+ return pageExtenders;
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.j2ee.ui/plugin.xml b/plugins/org.eclipse.jst.j2ee.ui/plugin.xml
index bf35d28..020346e 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/plugin.xml
+++ b/plugins/org.eclipse.jst.j2ee.ui/plugin.xml
@@ -7,6 +7,10 @@
name="Archive Export Participant Panels Extension Point"
schema="schema/archiveExportParticipantPanels.exsd"/>
+ <extension-point id="JavaEEPreferencePageExtender"
+ name="JavaEEPreferencePage"
+ schema="schema/JavaEEPreferencePageExtender.exsd"/>
+
<!--================================-->
<!-- Project Wizard Contributions -->
<!--================================-->
@@ -797,7 +801,7 @@
<page
class="org.eclipse.jst.j2ee.internal.ui.preferences.JavaEEPreferencePage"
id="org.eclipse.jst.j2ee.ui.preferencePages.JavaEE"
- name="Java EE">
+ name="%j2ee">
</page>
</extension>
diff --git a/plugins/org.eclipse.jst.j2ee.ui/schema/JavaEEPreferencePageExtender.exsd b/plugins/org.eclipse.jst.j2ee.ui/schema/JavaEEPreferencePageExtender.exsd
new file mode 100644
index 0000000..deb3487
--- /dev/null
+++ b/plugins/org.eclipse.jst.j2ee.ui/schema/JavaEEPreferencePageExtender.exsd
@@ -0,0 +1,83 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jst.j2ee.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jst.j2ee.ui" id="JavaEEPreferencePageExtender" name="JavaEEPreferencePageExtender"/>
+ </appInfo>
+ <documentation>
+ Defines extension point for extending Java EE preference page.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="javaeepageextender"/>
+ </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>
+ Optional name for the extension point
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="javaeepageextender">
+ <complexType>
+ <attribute name="className" type="string" use="required">
+ <annotation>
+ <documentation>
+ The className is an implementation of interface IJavaEEPreferencePageExtender
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2009 IBM Corporation and others.
+ 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:
+ IBM Corporation - initial API and implementation
+
+ </documentation>
+ </annotation>
+
+</schema>