Permalink
Browse files

399104 : optional JavaEE configurators preferences

Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information...
1 parent d8d043f commit 4e59f7d690b143fcd68c3919d56ab6b072c4dc3f @fbricon fbricon committed Jan 25, 2013
@@ -2,4 +2,6 @@ Bundle-Vendor = eclipse.org
Bundle-Name = Maven JAX-RS Configurator
JAXRS_Project_configurator=JAX-RS
Maven_Configuration_Problem=Maven Java EE Configuration Problem
-Maven_Configuration_Problems=Maven Java EE Configuration Problem
+Maven_Configuration_Problems=Maven Java EE Configuration Problem
+jaxrs_enabler_label=JAX-RS Configurator
+jaxrs_enabler_description=The JAX-RS Configurator adds the JAX-RS Facet to Dynamic Web projects if JAX-RS classpath dependencies are found.
@@ -29,4 +29,14 @@
<super type="org.eclipse.m2e.core.maven2Problem"/>
<persistent value="true"/>
</extension>
+
+ <extension
+ point="org.eclipse.m2e.wtp.javaeeConfiguratorEnabler">
+ <javaeeConfiguratorEnabler
+ id="org.eclipse.m2e.wtp.jaxrs.enabler"
+ label="%jaxrs_enabler_label"
+ description="%jaxrs_enabler_description"
+ configuratorIds="org.eclipse.m2e.wtp.jaxrs.configurator"
+ />
+ </extension>
</plugin>
@@ -37,6 +37,7 @@
import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+import org.eclipse.m2e.wtp.MavenWtpPlugin;
import org.eclipse.m2e.wtp.ProjectUtils;
import org.eclipse.m2e.wtp.WTPProjectsUtil;
import org.eclipse.m2e.wtp.WarPluginConfiguration;
@@ -79,13 +80,10 @@ private void configureInternal(MavenProject mavenProject,IProject project,
return;
}
- /* FIX_POST_MIGRATION (dis/en)able configurators in prefs
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- boolean configureJaxRs = store.getBoolean(Activator.CONFIGURE_JAXRS);
- if (!configureJaxRs) {
+ boolean enabled = MavenWtpPlugin.getDefault().getMavenWtpPreferencesManager().isEnabled(getId());
+ if (!enabled) {
return;
}
- */
final IFacetedProject fproj = ProjectFacetsManager.create(project);
if (fproj == null) {
@@ -1,5 +1,7 @@
-Bundle-Vendor =eclipse.org
-Bundle-Name =Maven JSF Configurator
-JSF_Project_configurator =JSF configurator
+Bundle-Vendor=eclipse.org
+Bundle-Name=Maven JSF Configurator
+JSF_Project_configurator=JSF configurator
Maven_Configuration_Problem=Maven Java EE Configuration Problem
Maven_Configuration_Problems=Maven Java EE Configuration Problems
+jsf_enabler_label=JSF Configurator
+jsf_enabler_description=The JSF Configurator adds the JSF Facet to Dynamic Web projects if JSF classpath dependencies are found.
@@ -28,5 +28,14 @@
<super type="org.eclipse.m2e.core.maven2Problem"/>
<persistent value="true"/>
</extension>
+ <extension
+ point="org.eclipse.m2e.wtp.javaeeConfiguratorEnabler">
+ <javaeeConfiguratorEnabler
+ id="org.eclipse.m2e.wtp.jsf.enabler"
+ label="%jsf_enabler_label"
+ description="%jsf_enabler_description"
+ configuratorIds="org.eclipse.m2e.wtp.jsf.configurator"
+ />
+ </extension>
</plugin>
@@ -42,6 +42,7 @@
import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+import org.eclipse.m2e.wtp.MavenWtpPlugin;
import org.eclipse.m2e.wtp.ProjectUtils;
import org.eclipse.m2e.wtp.ResourceCleaner;
import org.eclipse.m2e.wtp.WarPluginConfiguration;
@@ -78,14 +79,10 @@ private void configureInternal(MavenProject mavenProject,IProject project,
return;
}
- /*
- //FIX_POST_MIGRATION
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- boolean configureJSF = store.getBoolean(Activator.CONFIGURE_JSF);
- if (!configureJSF) {
+ boolean enabled = MavenWtpPlugin.getDefault().getMavenWtpPreferencesManager().isEnabled(getId());
+ if (!enabled) {
return;
}
- */
final IFacetedProject fproj = ProjectFacetsManager.create(project);
if (fproj != null) {
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
+
+ <extension-point id="javaeeConfiguratorEnabler" name="Java EE Configurator Enablers" schema="schema/javaeeConfiguratorEnablers.exsd"/>
+
<extension
point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
</extension>
@@ -214,7 +217,6 @@
<keywordReference id="org.eclipse.m2e.core.maven"/>
</page>
</extension>
-
<extension
point="org.eclipse.ui.propertyPages">
@@ -0,0 +1,136 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.m2e.wtp" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.m2e.wtp" id="javaeeConfiguratorEnabler" name="Java EE Configurator Enablers"/>
+ </appinfo>
+ <documentation>
+ Java EE Configurator Enablers
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="javaeeConfiguratorEnabler"/>
+ </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="javaeeConfiguratorEnabler">
+ <annotation>
+ <documentation>
+ Java EE Configurator Enabler
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique project configurator enabler id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+ Label of the Configurator.
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="description" type="string">
+ <annotation>
+ <documentation>
+ Description of the Java EE configurator this enabler targets, used as tooltip in the preference page.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="configuratorIds" type="string" use="required">
+ <annotation>
+ <documentation>
+ Comma-separated list of projectConfigurator ids this enabler targets.
+ </documentation>
+ </annotation>
+ </attribute>
+
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.17.0
+ </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 Red Hat, Inc.
+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
+ </documentation>
+ </annotation>
+
+</schema>
@@ -19,8 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -41,8 +41,6 @@
import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Configures Connector (RAR) projects based on their mavenè-rar-plugin configuration.
@@ -28,10 +28,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
/**
* Utility class around {@link IProject}
@@ -26,14 +26,11 @@
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * 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:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.wtp.internal.preferences;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.m2e.wtp.preferences.ConfiguratorEnabler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * Composite displaying a checkbox {@link Control} based on a {@link ConfiguratorEnabler}
+ *
+ * @author Fred Bricon
+ * @since 0.17.0
+ */
+public class ConfiguratorEnablerComposite extends Composite {
+
+ private Button enableConfigurator;
+
+ private ConfiguratorEnabler enabler;
+
+ public ConfiguratorEnablerComposite(Composite parent, ConfiguratorEnabler enabler, int style) {
+ super(parent, style);
+ Assert.isNotNull(enabler);
+ this.enabler = enabler;
+ enableConfigurator = new Button(parent, SWT.CHECK);
+ enableConfigurator.setSelection(enabler.isEnabled());
+ enableConfigurator.setText(enabler.getConfiguratorLabel());
+ enableConfigurator.setToolTipText(enabler.getDescription());
+ }
+
+ public void setDefaultValue() {
+ enableConfigurator.setSelection(true);
+ }
+
+ public void savePreferences() {
+ if (enabler != null) {
+ enabler.setEnabled(enableConfigurator.getSelection());
+ }
+ }
+
+ public void dispose() {
+ enabler = null;
+ enableConfigurator.dispose();
+ super.dispose();
+ }
+}
Oops, something went wrong. Retry.

0 comments on commit 4e59f7d

Please sign in to comment.