[188737] JEE Preference consolidation
diff --git a/plugins/org.eclipse.jst.common.frameworks/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.common.frameworks/META-INF/MANIFEST.MF index d71dc6a..02075e0 100644 --- a/plugins/org.eclipse.jst.common.frameworks/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.common.frameworks/META-INF/MANIFEST.MF
@@ -27,3 +27,5 @@ org.eclipse.jst.common.project.facet.core;bundle-version="[1.1.0,1.2.0)", org.eclipse.jem.workbench;bundle-version="[2.0.0,3.0.0)", org.eclipse.wst.web;bundle-version="[1.1.0,1.2.0)" +Bundle-Activator: org.eclipse.jst.common.frameworks.CommonFrameworksPlugin +Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.jst.common.frameworks/plugin.xml b/plugins/org.eclipse.jst.common.frameworks/plugin.xml index 0ca7e71..b03f353 100644 --- a/plugins/org.eclipse.jst.common.frameworks/plugin.xml +++ b/plugins/org.eclipse.jst.common.frameworks/plugin.xml
@@ -120,5 +120,10 @@ <attribute name="compilerLevel"/> <persistent value="true"/> </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.eclipse.jst.common.frameworks.CommonFrameworksPreferenceInitializer" /> + </extension> </plugin>
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java index f28eeb8..60823e3 100644 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java +++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.wst.common.frameworks.internal.WTPPlugin; +import org.eclipse.wst.project.facet.IProductConstants; public final class CommonFrameworksPlugin @@ -22,9 +23,10 @@ { public static final String PLUGIN_ID = "org.eclipse.jst.common.frameworks"; //$NON-NLS-1$ - - private static final CommonFrameworksPlugin inst - = new CommonFrameworksPlugin(); + public static final String DEFAULT_SOURCE_FOLDER = IProductConstants.DEFAULT_SOURCE_FOLDER; + public static final String OUTPUT_FOLDER = IProductConstants.OUTPUT_FOLDER; + + private static CommonFrameworksPlugin inst; /** * Get the plugin singleton. @@ -35,6 +37,11 @@ return inst; } + public CommonFrameworksPlugin() { + super(); + if (inst == null) + inst = this; + } public String getPluginID() { return PLUGIN_ID;
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java new file mode 100644 index 0000000..65386b1 --- /dev/null +++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java
@@ -0,0 +1,26 @@ +package org.eclipse.jst.common.frameworks; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.wst.project.facet.IProductConstants; +import org.eclipse.wst.project.facet.ProductManager; + + + +public class CommonFrameworksPreferenceInitializer extends + AbstractPreferenceInitializer { + + public CommonFrameworksPreferenceInitializer() { + // TODO Auto-generated constructor stub + } + + public void initializeDefaultPreferences() { + IEclipsePreferences node = new DefaultScope().getNode(CommonFrameworksPlugin.getDefault().getBundle().getSymbolicName()); + + // migration preferences + node.put(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER, ProductManager.getProperty(IProductConstants.DEFAULT_SOURCE_FOLDER)); + node.put(CommonFrameworksPlugin.OUTPUT_FOLDER, ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER)); + } + +}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java index 7ae6f53..07366bb 100644 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java +++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java
@@ -14,10 +14,9 @@ import java.util.Set; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; public class JavaFacetInstallDataModelProvider extends FacetInstallDataModelProvider implements IJavaFacetInstallDataModelProperties { @@ -49,9 +48,9 @@ return JavaFacetUtils.JAVA_50; } else if (SOURCE_FOLDER_NAME.equals(propertyName)) { - return ProductManager.getProperty(IProductConstants.DEFAULT_SOURCE_FOLDER); + return CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER); } else if (DEFAULT_OUTPUT_FOLDER_NAME.equals(propertyName)) { - return ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER); + return CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.OUTPUT_FOLDER); } return super.getDefaultProperty(propertyName);
diff --git a/plugins/org.eclipse.jst.j2ee.core/jee-models/org/eclipse/jst/javaee/web/internal/metadata/WebPackage.java b/plugins/org.eclipse.jst.j2ee.core/jee-models/org/eclipse/jst/javaee/web/internal/metadata/WebPackage.java index fb8e1e5..29256dc 100644 --- a/plugins/org.eclipse.jst.j2ee.core/jee-models/org/eclipse/jst/javaee/web/internal/metadata/WebPackage.java +++ b/plugins/org.eclipse.jst.j2ee.core/jee-models/org/eclipse/jst/javaee/web/internal/metadata/WebPackage.java
@@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: WebPackage.java,v 1.1 2007/05/16 06:42:40 cbridgha Exp $ + * $Id: WebPackage.java,v 1.2 2007/05/30 21:06:23 cbridgha Exp $ */ package org.eclipse.jst.javaee.web.internal.metadata; @@ -368,7 +368,7 @@ * <!-- begin-user-doc --> * <!-- end-user-doc --> */ - String eNS_URI = "http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"; //$NON-NLS-1$ + String eNS_URI = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; //$NON-NLS-1$ /** * The package namespace name.
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java index a50055a..53fa6a8 100644 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java +++ b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDataModelProvider.java
@@ -18,13 +18,13 @@ import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.IProductConstants; import org.eclipse.wst.project.facet.ProductManager; import com.ibm.icu.util.StringTokenizer; @@ -40,7 +40,7 @@ public Object getDefaultProperty(String propertyName) { if (propertyName.equals(CONFIG_FOLDER)) { - return ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER); + return J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.WEB_CONTENT_FOLDER); } else if (propertyName.equals(SOURCE_FOLDER)) { return "src"; //$NON-NLS-1$ } else if (propertyName.equals(CONTEXT_ROOT)) { @@ -51,8 +51,7 @@ String projectName = model.getStringProperty(FACET_PROJECT_NAME).replace(' ', '_'); return projectName + IJ2EEModuleConstants.WAR_EXT; } else if (propertyName.equals(GENERATE_DD)) { - // for ee5 jee web projects default it to true so that we can create servlets, otherwise false - return Boolean.TRUE; + return Boolean.valueOf(J2EEPlugin.getDefault().getJ2EEPreferences().getBoolean(J2EEPreferences.Keys.DYNAMIC_WEB_GENERATE_DD)); } return super.getDefaultProperty(propertyName); } @@ -98,7 +97,10 @@ public IStatus validate(String name) { if (name.equals(CONTEXT_ROOT)) { return validateContextRoot(getStringProperty(CONTEXT_ROOT)); + } else if (name.equals(SOURCE_FOLDER)) { + return validateFolderName(getStringProperty(SOURCE_FOLDER)); } + // the superclass validates the content directory which is actually a "CONFIG_FOLDER" return super.validate(name); }
diff --git a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java index 4faaba7..ed95802 100644 --- a/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java +++ b/plugins/org.eclipse.jst.j2ee.web/webproject/org/eclipse/jst/j2ee/web/project/facet/WebFacetInstallDelegate.java
@@ -27,6 +27,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jem.util.logger.proxy.Logger; +import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; import org.eclipse.jst.common.project.facet.WtpUtils; import org.eclipse.jst.common.project.facet.core.ClasspathHelper; import org.eclipse.jst.j2ee.internal.J2EEConstants; @@ -44,7 +45,6 @@ import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; import org.eclipse.wst.common.project.facet.core.IDelegate; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.IProductConstants; import org.eclipse.wst.project.facet.ProductManager; public final class WebFacetInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { @@ -173,7 +173,8 @@ outputFolder = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)+"/"+J2EEConstants.WEB_INF_CLASSES; // Otherwise set the output folder to the product setting default else - outputFolder = ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER); + outputFolder = CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.OUTPUT_FOLDER); + component.setMetaProperty("java-output-path", outputFolder ); //$NON-NLS-1$ }
diff --git a/plugins/org.eclipse.jst.j2ee/appclientcreation/org/eclipse/jst/j2ee/project/facet/AppClientFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/appclientcreation/org/eclipse/jst/j2ee/project/facet/AppClientFacetInstallDataModelProvider.java index ede3a55..d3711de 100644 --- a/plugins/org.eclipse.jst.j2ee/appclientcreation/org/eclipse/jst/j2ee/project/facet/AppClientFacetInstallDataModelProvider.java +++ b/plugins/org.eclipse.jst.j2ee/appclientcreation/org/eclipse/jst/j2ee/project/facet/AppClientFacetInstallDataModelProvider.java
@@ -15,6 +15,8 @@ import org.eclipse.jst.j2ee.internal.common.CreationConstants; import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; public class AppClientFacetInstallDataModelProvider extends J2EEModuleFacetInstallDataModelProvider implements IAppClientFacetInstallDataModelProperties { @@ -39,6 +41,8 @@ else if (propertyName.equals(MODULE_URI)) { String projectName = model.getStringProperty(FACET_PROJECT_NAME).replace(' ','_'); return projectName + IJ2EEModuleConstants.JAR_EXT; + } else if (propertyName.equals(IJ2EEFacetInstallDataModelProperties.GENERATE_DD)) { + return Boolean.valueOf(J2EEPlugin.getDefault().getJ2EEPreferences().getBoolean(J2EEPreferences.Keys.APP_CLIENT_GENERATE_DD)); } return super.getDefaultProperty(propertyName); }
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java index ef9ecf1..758511e 100644 --- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java +++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java
@@ -10,15 +10,15 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.common; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; public interface CreationConstants { String DEFAULT_WEB_SOURCE_FOLDER = "src"; //$NON-NLS-1$ - String DEFAULT_EJB_SOURCE_FOLDER = ProductManager.getProperty(IProductConstants.EJB_CONTENT_FOLDER); - String DEFAULT_CONNECTOR_SOURCE_FOLDER = ProductManager.getProperty(IProductConstants.JCA_CONTENT_FOLDER); - String DEFAULT_APPCLIENT_SOURCE_FOLDER = ProductManager.getProperty(IProductConstants.APP_CLIENT_CONTENT_FOLDER); + String DEFAULT_EJB_SOURCE_FOLDER = J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.EJB_CONTENT_FOLDER); + String DEFAULT_CONNECTOR_SOURCE_FOLDER = J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.JCA_CONTENT_FOLDER); + String DEFAULT_APPCLIENT_SOURCE_FOLDER = J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.APP_CLIENT_CONTENT_FOLDER); String EJB_CLIENT_NAME ="ClientProject";//$NON-NLS-1$ String CLIENT_JAR_URI="ClientJARURI";//$NON-NLS-1$ }
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java index 862ecb2..2883a65 100644 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java +++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/componentcore/util/EARVirtualComponent.java
@@ -28,6 +28,7 @@ import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; import org.eclipse.wst.common.componentcore.internal.StructureEdit; import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; +import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager; import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent; import org.eclipse.wst.common.componentcore.internal.util.IComponentImplFactory; @@ -39,6 +40,8 @@ public class EARVirtualComponent extends VirtualComponent implements IComponentImplFactory { + private IVirtualReference[] cachedReferences; + private long depGraphModStamp; public EARVirtualComponent() { super(); } @@ -177,13 +180,29 @@ } public IVirtualReference[] getReferences() { + + IVirtualReference[] cached = getCachedReferences(); + if (cached != null) + return cached; List hardReferences = getHardReferences(this); List dynamicReferences = getLooseArchiveReferences(this, hardReferences); if (dynamicReferences != null) { hardReferences.addAll(dynamicReferences); } + cachedReferences = (IVirtualReference[]) hardReferences.toArray(new IVirtualReference[hardReferences.size()]); + return cachedReferences; + } + // Returns cache if still valid or null + public IVirtualReference[] getCachedReferences() { + if (cachedReferences != null && checkIfStillValid()) + return cachedReferences; + else + depGraphModStamp = DependencyGraphManager.getInstance().getModStamp(); + return null; + } - return (IVirtualReference[]) hardReferences.toArray(new IVirtualReference[hardReferences.size()]); + private boolean checkIfStillValid() { + return (DependencyGraphManager.getInstance().getModStamp() == depGraphModStamp); } }
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java index a3ef838..1487ac7 100644 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java +++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/internal/earcreation/EarFacetInstallDataModelProvider.java
@@ -19,12 +19,11 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; import org.eclipse.jst.j2ee.project.facet.J2EEFacetInstallDataModelProvider; import org.eclipse.wst.common.componentcore.ComponentCore; import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; public class EarFacetInstallDataModelProvider extends J2EEFacetInstallDataModelProvider implements IEarFacetInstallDataModelProperties { @@ -40,11 +39,11 @@ if (propertyName.equals(FACET_ID)) { return ENTERPRISE_APPLICATION; } else if (propertyName.equals(CONTENT_DIR)) { - return ProductManager.getProperty(IProductConstants.APPLICATION_CONTENT_FOLDER); + return J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.APPLICATION_CONTENT_FOLDER); } else if (propertyName.equals(J2EE_PROJECTS_LIST) || propertyName.equals(JAVA_PROJECT_LIST)) { return Collections.EMPTY_LIST; } else if(propertyName.equals(GENERATE_DD)){ - return Boolean.FALSE; + return Boolean.valueOf(J2EEPlugin.getDefault().getJ2EEPreferences().getBoolean(J2EEPreferences.Keys.APPLICATION_GENERATE_DD)); } return super.getDefaultProperty(propertyName); } @@ -52,6 +51,8 @@ public IStatus validate(String name) { if (name.equals(J2EE_PROJECTS_LIST)) { return validateTargetComponentVersion((List) model.getProperty(J2EE_PROJECTS_LIST)); + } else if (name.equals(CONTENT_DIR)) { + return validateFolderName(getStringProperty(CONTENT_DIR)); } return super.validate(name); }
diff --git a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/project/facet/J2EEModuleFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/project/facet/J2EEModuleFacetInstallDataModelProvider.java index 35fbcba..695a9d7 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/project/facet/J2EEModuleFacetInstallDataModelProvider.java +++ b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/project/facet/J2EEModuleFacetInstallDataModelProvider.java
@@ -21,6 +21,8 @@ import org.eclipse.jem.util.logger.proxy.Logger; import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties; import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; +import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; import org.eclipse.wst.common.componentcore.ComponentCore; import org.eclipse.wst.common.componentcore.ModuleCoreNature; @@ -63,7 +65,7 @@ if (propertyName.equals(PROHIBIT_ADD_TO_EAR)) { return Boolean.FALSE; } else if (propertyName.equals(ADD_TO_EAR)) { - return new Boolean( ProductManager.shouldAddToEARByDefault() && isEARSupportedByRuntime()); + return new Boolean( J2EEPlugin.getDefault().getJ2EEPreferences().getBoolean(J2EEPreferences.Keys.ADD_TO_EAR_BY_DEFAULT) && isEARSupportedByRuntime()); } else if (propertyName.equals(EAR_PROJECT_NAME)) { if (model.isPropertySet(LAST_EAR_NAME)) { IProject project = ProjectUtilities.getProject(getStringProperty(LAST_EAR_NAME)); @@ -82,8 +84,6 @@ } else { return getDataModel().getStringProperty(FACET_PROJECT_NAME) + "EAR"; //$NON-NLS-1$ } - } else if (propertyName.equals(IJ2EEFacetInstallDataModelProperties.GENERATE_DD)) { - return Boolean.FALSE; } return super.getDefaultProperty(propertyName); } @@ -210,8 +210,11 @@ } else if (name.equals(CONFIG_FOLDER)) { String folderName = model.getStringProperty(CONFIG_FOLDER); if (folderName == null || folderName.length() == 0) { + // all folders which meet the criteria of "CONFIG_FOLDER" are required String errorMessage = WTPCommonPlugin.getResourceString(WTPCommonMessages.SOURCEFOLDER_EMPTY); return WTPCommonPlugin.createErrorStatus(errorMessage); + } else { + return validateFolderName(folderName); } } else if (name.equals(ADD_TO_EAR)) { if (!isEARSupportedByRuntime()) {
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java index d381d03..c2f4268 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java
@@ -18,7 +18,10 @@ import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Preferences; +import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; +import org.eclipse.wst.project.facet.IProductConstants; +import org.eclipse.wst.project.facet.ProductManager; /** @@ -27,15 +30,74 @@ public class J2EEPreferences { public interface Keys { - final static String J2EE_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.j2eeWebContentName"; //$NON-NLS-1$ - final static String STATIC_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName"; //$NON-NLS-1$ - final static String JAVA_SOURCE = "org.eclipse.jst.j2ee.preference.javaSourceName"; //$NON-NLS-1$ - final static String SERVER_TARGET_SUPPORT = "org.eclipse.jst.j2ee.preference.servertargetsupport"; //$NON-NLS-1$ - final static String CREATE_EJB_CLIENT_JAR = "org.eclipse.jst.j2ee.preference.createClientJar"; //$NON-NLS-1$ - final static String J2EE_VERSION = "org.eclipse.jst.j2ee.ui.preference.j2eeVersion"; //$NON-NLS-1$ - final static String EJB_CLIENT_JAR_CP_COMPATIBILITY = "org.eclipse.jst.j2ee.preference.clientjar.cp.compatibility"; //$NON-NLS-1$ - final static String INCREMENTAL_DEPLOYMENT_SUPPORT = "org.eclipse.jst.j2ee.ui.preference.incrementalDeployment"; //$NON-NLS-1$ + + + /** + * @deprecated, use CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER or use + * getJavaSourceFolderName() + * do not call J2EEPlugin.getJ2EEPreferences.getString(JAVA_SOURCE) + * @since 2.0 + */ + static final String JAVA_SOURCE = "org.eclipse.jst.j2ee.preference.javaSourceName"; //$NON-NLS-1$ + static final String SERVER_TARGET_SUPPORT = "org.eclipse.jst.j2ee.preference.servertargetsupport"; //$NON-NLS-1$ + static final String CREATE_EJB_CLIENT_JAR = "org.eclipse.jst.j2ee.preference.createClientJar"; //$NON-NLS-1$ + static final String J2EE_VERSION = "org.eclipse.jst.j2ee.ui.preference.j2eeVersion"; //$NON-NLS-1$ + static final String EJB_CLIENT_JAR_CP_COMPATIBILITY = "org.eclipse.jst.j2ee.preference.clientjar.cp.compatibility"; //$NON-NLS-1$ + static final String INCREMENTAL_DEPLOYMENT_SUPPORT = "org.eclipse.jst.j2ee.ui.preference.incrementalDeployment"; //$NON-NLS-1$ + + /** + * @deprecated, + * but should it be deprecated ? is j2ee_web_content a better name than web_content_folder ? + * @since 2.0 + */ + static final String J2EE_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.j2eeWebContentName"; //$NON-NLS-1$ + /** + * @deprecated, static web content is got from ProductManager + * @since 2.0 + */ + static final String STATIC_WEB_CONTENT = "org.eclipse.jst.j2ee.preference.staticWebContentName"; //$NON-NLS-1$ + /** + * @since 2.0 + */ + static final String APPLICATION_CONTENT_FOLDER = IProductConstants.APPLICATION_CONTENT_FOLDER; + /** + * @since 2.0 + */ + static final String WEB_CONTENT_FOLDER = IProductConstants.WEB_CONTENT_FOLDER; + /** + * @since 2.0 + */ + static final String EJB_CONTENT_FOLDER = IProductConstants.EJB_CONTENT_FOLDER; + /** + * @since 2.0 + */ + static final String APP_CLIENT_CONTENT_FOLDER = IProductConstants.APP_CLIENT_CONTENT_FOLDER; + /** + * @since 2.0 + */ + static final String JCA_CONTENT_FOLDER = IProductConstants.JCA_CONTENT_FOLDER; + + /** + * @since 2.0 + */ + static final String ADD_TO_EAR_BY_DEFAULT = IProductConstants.ADD_TO_EAR_BY_DEFAULT; + /** + * @since 2.0 + */ + static final String APPLICATION_GENERATE_DD = "application_generate_dd"; //$NON-NLS-1$ + /** + * @since 2.0 + */ + static final String DYNAMIC_WEB_GENERATE_DD = "dynamic_web_generate_dd"; //$NON-NLS-1$ + /** + * @since 2.0 + */ + static final String EJB_GENERATE_DD = "ejb_generate_dd"; //$NON-NLS-1$ + /** + * @since 2.0 + */ + static final String APP_CLIENT_GENERATE_DD = "app_client_generate_dd"; //$NON-NLS-1$ } @@ -44,15 +106,33 @@ final static String J2EE_VERSION_1_3 = "J2EE_1_3"; //$NON-NLS-1$ final static String J2EE_VERSION_1_4 = "J2EE_1_4"; //$NON-NLS-1$ - final static String J2EE_WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - final static String STATIC_WEB_CONTENT = "WebContent"; //$NON-NLS-1$ - final static String JAVA_SOURCE = "JavaSource"; //$NON-NLS-1$ + /** + * @deprecated, see initializeDefaultPreferences() it uses ProductManager + */ + final static String J2EE_WEB_CONTENT = ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER); + /** + * @deprecated, see initializeDefaultPreferences() it uses ProductManager + */ + final static String STATIC_WEB_CONTENT = ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER); + /** + * @deprecated, use CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER + */ + final static String JAVA_SOURCE = CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER); } public interface Defaults { + /** + * @deprecated, see initializeDefaultPreferences() it uses ProductManager + */ final static String J2EE_WEB_CONTENT = Values.J2EE_WEB_CONTENT; + /** + * @deprecated, see initializeDefaultPreferences() it uses ProductManager + */ final static String STATIC_WEB_CONTENT = Values.STATIC_WEB_CONTENT; + /** + * @deprecated, see DEFAULT_SOURCE_FOLDER + */ final static String JAVA_SOURCE = Values.JAVA_SOURCE; final static String J2EE_VERSION = Values.J2EE_VERSION_1_4; final static int J2EE_VERSION_ID = J2EEVersionConstants.J2EE_1_4_ID; @@ -70,27 +150,57 @@ } protected void initializeDefaultPreferences() { - getPreferences().setDefault(Keys.J2EE_WEB_CONTENT, Defaults.J2EE_WEB_CONTENT); - getPreferences().setDefault(Keys.STATIC_WEB_CONTENT, Defaults.STATIC_WEB_CONTENT); - getPreferences().setDefault(Keys.JAVA_SOURCE, Defaults.JAVA_SOURCE); getPreferences().setDefault(Keys.J2EE_VERSION, Defaults.J2EE_VERSION); getPreferences().setDefault(Keys.CREATE_EJB_CLIENT_JAR, Defaults.CREATE_EJB_CLIENT_JAR); getPreferences().setDefault(Keys.EJB_CLIENT_JAR_CP_COMPATIBILITY, Defaults.EJB_CLIENT_JAR_CP_COMPATIBILITY); getPreferences().setDefault(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT, Defaults.INCREMENTAL_DEPLOYMENT_SUPPORT); - + + // since 2.0 + getPreferences().setDefault(Keys.J2EE_WEB_CONTENT, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.STATIC_WEB_CONTENT, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER)); + // since 2.0 + getPreferences().setDefault(Keys.JAVA_SOURCE, CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER)); + // done in CommonFrameworksPref..Initializer + //getPreferences().setDefault(Keys.DEFAULT_SOURCE_FOLDER, ProductManager.getProperty(IProductConstants.DEFAULT_SOURCE_FOLDER)); + getPreferences().setDefault(Keys.APPLICATION_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.APPLICATION_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.WEB_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.APP_CLIENT_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.APP_CLIENT_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.EJB_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.EJB_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.JCA_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.JCA_CONTENT_FOLDER)); + getPreferences().setDefault(Keys.ADD_TO_EAR_BY_DEFAULT, ProductManager.getProperty(IProductConstants.ADD_TO_EAR_BY_DEFAULT)); + // done in CommonFrameworksPref..Initializer + //getPreferences().setDefault(Keys.OUTPUT_FOLDER, ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER)); + + // since 2.0, for java ee projects + getPreferences().setDefault(Keys.APPLICATION_GENERATE_DD, false); + // for ee5 jee web projects default it to true so that we can create servlets, otherwise false + getPreferences().setDefault(Keys.DYNAMIC_WEB_GENERATE_DD, true); + getPreferences().setDefault(Keys.EJB_GENERATE_DD, false); + getPreferences().setDefault(Keys.APP_CLIENT_GENERATE_DD, false); + + } public String getJ2EEWebContentFolderName() { - return getPreferences().getString(Keys.J2EE_WEB_CONTENT); + //return getPreferences().getString(Keys.J2EE_WEB_CONTENT); + //but should it be deprecated ? is j2ee_web_content a better name than web_content_folder ? + return getPreferences().getString(Keys.WEB_CONTENT_FOLDER); + } + /** + * @return + * @deprecated + */ public String getStaticWebContentFolderName() { return getPreferences().getString(Keys.STATIC_WEB_CONTENT); } public String getJavaSourceFolderName() { - return getPreferences().getString(Keys.JAVA_SOURCE); + //return getPreferences().getString(Keys.JAVA_SOURCE); + // TODO is JAVA_SOURCE a better name or is DEFAULT_SOURCE... + return CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER); } public String getHighestJ2EEVersionSetting() { @@ -103,17 +213,26 @@ /// public void setJ2EEWebContentFolderName(String value) { - getPreferences().setValue(Keys.J2EE_WEB_CONTENT, value); + //getPreferences().setValue(Keys.J2EE_WEB_CONTENT, value); + // TODO but should it be deprecated ? is j2ee_web_content a better name than web_content_folder ? + getPreferences().setValue(Keys.WEB_CONTENT_FOLDER, value); firePreferenceChanged(); } + /** + * @param value + * @deprecated + */ public void setStaticWebContentFolderName(String value) { getPreferences().setValue(Keys.STATIC_WEB_CONTENT, value); firePreferenceChanged(); } public void setJavaSourceFolderName(String value) { - getPreferences().setValue(Keys.JAVA_SOURCE, value); + //getPreferences().setValue(Keys.JAVA_SOURCE, value); + // TODO is JAVA_SOURCE a better name or is DEFAULT_SOURCE... + CommonFrameworksPlugin.getDefault().getPluginPreferences().setValue(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER, value); + CommonFrameworksPlugin.getDefault().savePluginPreferences(); firePreferenceChanged(); } @@ -186,4 +305,81 @@ return this.owner; } + /** + * Returns the default value for the boolean-valued property + * with the given name. + * Returns the default-default value (<code>false</code>) if there + * is no default property with the given name, or if the default + * value cannot be treated as a boolean. + * The given name must not be <code>null</code>. + * + * @param name the name of the property + * @return the default value of the named property + */ + public boolean getDefaultBoolean(String name) { + return getPreferences().getDefaultBoolean(name); + } + /** + * Returns the current value of the boolean-valued property with the + * given name. + * The given name must not be <code>null</code>. + * + * @param name the name of the property + * @return the boolean-valued property + */ + public boolean getBoolean(String name) { + return getPreferences().getBoolean(name); + } + + /** + * Sets the current value of the boolean-valued property with the + * given name. The given name must not be <code>null</code>. + * @param name the name of the property + * @param value the new current value of the property + */ + public void setValue(String name, boolean value) { + getPreferences().setValue(name, value); + firePreferenceChanged(); + } + + /** + * Returns the default value for the string-valued property + * with the given name. + * Returns the default-default value (the empty string <code>""</code>) + * is no default property with the given name, or if the default + * value cannot be treated as a string. + * The given name must not be <code>null</code>. + * + * @param name the name of the property + * @return the default value of the named property + */ + public String getDefaultString(String name) { + return getPreferences().getDefaultString(name); + } + + /** + * Returns the current value of the string-valued property with the + * given name. + * Returns the default-default value (the empty string <code>""</code>) + * if there is no property with the given name. + * The given name must not be <code>null</code>. + * + * @param name the name of the property + * @return the string-valued property + */ + public String getString(String name) { + return getPreferences().getString(name); + } + + /** + * Sets the current value of the string-valued property with the + * given name. The given name must not be <code>null</code>. + * @param name the name of the property + * @param value the new current value of the property + */ + public void setValue(String name, String value) { + getPreferences().setValue(name, value); + firePreferenceChanged(); + } + } \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/deployables/WebDeployableArtifactUtil.java b/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/deployables/WebDeployableArtifactUtil.java index ab49a31..c7600ce 100644 --- a/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/deployables/WebDeployableArtifactUtil.java +++ b/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/deployables/WebDeployableArtifactUtil.java
@@ -29,6 +29,8 @@ import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; +import org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURL; +import org.eclipse.jst.j2ee.internal.web.jfaces.extension.FileURLExtensionReader; import org.eclipse.jst.j2ee.model.IModelProvider; import org.eclipse.jst.j2ee.model.ModelProviderManager; import org.eclipse.wst.common.componentcore.ComponentCore; @@ -152,16 +154,17 @@ // } } resourcePath = resources[0].getRuntimePath(); -//TODO JSFFileURL should not refer to WebArtifactEdit for JEE Web 2.5 modules, see bug 182012 -// // Extension read to get the correct URL for Java Server Faces file if -// // the jsp is of type jsfaces. -// FileURL jspURL = FileURLExtensionReader.getInstance().getFilesURL(); -// if (jspURL != null) { -// IPath correctJSPPath = jspURL.getFileURL(resource, resourcePath); -// if (correctJSPPath != null && correctJSPPath.toString().length() > 0) -// return new WebResource(getModule(resource.getProject(), component), correctJSPPath); -// } - // return Web resource type + + try {//adding try/catch to avoid future issues that would require commenting this out. + // Extension read to get the correct URL for Java Server Faces file if + // the jsp is of type jsfaces. + FileURL jspURL = FileURLExtensionReader.getInstance().getFilesURL(); + if (jspURL != null) { + IPath correctJSPPath = jspURL.getFileURL(resource, resourcePath); + if (correctJSPPath != null && correctJSPPath.toString().length() > 0) + return new WebResource(getModule(resource.getProject(), component), correctJSPPath); + } + }catch (Exception e) {} return new WebResource(getModule(resource.getProject(), component), resourcePath); }
diff --git a/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/web/project/facet/WebFacetInstallDelegate.java b/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/web/project/facet/WebFacetInstallDelegate.java index b2d5609..f87a3ef 100644 --- a/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/web/project/facet/WebFacetInstallDelegate.java +++ b/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/web/project/facet/WebFacetInstallDelegate.java
@@ -29,6 +29,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jem.util.logger.proxy.Logger; +import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; import org.eclipse.jst.common.project.facet.WtpUtils; import org.eclipse.jst.common.project.facet.core.ClasspathHelper; import org.eclipse.jst.j2ee.internal.J2EEConstants; @@ -46,7 +47,6 @@ import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; import org.eclipse.wst.common.project.facet.core.IDelegate; import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.project.facet.IProductConstants; import org.eclipse.wst.project.facet.ProductManager; public final class WebFacetInstallDelegate extends JEEFacetInstallDelegate implements IDelegate { @@ -183,7 +183,7 @@ outputFolder = model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER)+"/"+J2EEConstants.WEB_INF_CLASSES; //$NON-NLS-1$ // Otherwise set the output folder to the product setting default else - outputFolder = ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER); + outputFolder = CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.OUTPUT_FOLDER); component.setMetaProperty("java-output-path", outputFolder ); //$NON-NLS-1$ }
diff --git a/plugins/org.eclipse.jst.jee/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.jee/META-INF/MANIFEST.MF index 14c3c0b..af5723e 100644 --- a/plugins/org.eclipse.jst.jee/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.jee/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.jst.jee;singleton:=true Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.jst.jee.Activator +Bundle-Activator: org.eclipse.jst.jee.JEEPlugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.wst.common.project.facet.core;bundle-version="[1.2.0,1.3.0)", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
diff --git a/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/Activator.java b/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPlugin.java similarity index 67% rename from plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/Activator.java rename to plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPlugin.java index c690923..43f9789 100644 --- a/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/Activator.java +++ b/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPlugin.java
@@ -6,18 +6,20 @@ /** * The activator class controls the plug-in life cycle */ -public class Activator extends WTPPlugin { +public class JEEPlugin extends WTPPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.jst.jee"; // The shared instance - private static Activator plugin; + private static JEEPlugin plugin; + + private JEEPreferences preferences = null; /** * The constructor */ - public Activator() { + public JEEPlugin() { } /* @@ -43,7 +45,7 @@ * * @return the shared instance */ - public static Activator getDefault() { + public static JEEPlugin getDefault() { return plugin; } @@ -56,4 +58,17 @@ return PLUGIN_ID; } + /** + * @return Returns the preferences. + */ + public JEEPreferences getJEEPreferences() { + if (this.preferences == null) + this.preferences = new JEEPreferences(this); + return this.preferences; + } + + protected void initializeDefaultPluginPreferences() { + getJEEPreferences().initializeDefaultPreferences(); + } + }
diff --git a/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPreferences.java b/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPreferences.java new file mode 100644 index 0000000..55a0b63 --- /dev/null +++ b/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/JEEPreferences.java
@@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +/* + * Created on Jan 26, 2004 + * + * To change the template for this generated file go to Window - Preferences - Java - Code + * Generation - Code and Comments + */ +package org.eclipse.jst.jee; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Preferences; + + +/** + * @author mdelder + */ +public class JEEPreferences { + + public interface Keys { + + + + } + + + + + + private Plugin owner = null; + private Preferences preferences = null; + private boolean persistOnChange = false; + + public JEEPreferences(Plugin owner) { + this.owner = owner; + } + + protected void initializeDefaultPreferences() { + + // placeholder + // we had to move generate_dd to jst.j2ee as jst.jee is not in the pre-req of many plug-ins + } + + + + + + + public void firePreferenceChanged() { + if (isPersistOnChange()) + persist(); + } + + public void persist() { + getOwner().savePluginPreferences(); + } + + /** + * @return Returns the persistOnChange. + */ + public boolean isPersistOnChange() { + return this.persistOnChange; + } + + /** + * @param persistOnChange + * The persistOnChange to set. + */ + public void setPersistOnChange(boolean persistOnChange) { + this.persistOnChange = persistOnChange; + } + + public Preferences getPreferences() { + if (this.preferences == null) + this.preferences = getOwner().getPluginPreferences(); + return this.preferences; + } + + /** + * @return Returns the owner. + */ + private Plugin getOwner() { + return this.owner; + } + + /** + * Returns the current value of the boolean-valued property with the + * given name. + * The given name must not be <code>null</code>. + * + * @param name the name of the property + * @return the boolean-valued property + */ + public boolean getBoolean(String name) { + return getPreferences().getBoolean(name); + } + + /** + * Sets the current value of the boolean-valued property with the + * given name. The given name must not be <code>null</code>. + * @param name the name of the property + * @param value the new current value of the property + */ + public void setValue(String name, boolean value) { + getPreferences().setValue(name, value); + firePreferenceChanged(); + } + +}