Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin')
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java9
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java23
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java47
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java563
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java58
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java189
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java506
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java242
8 files changed, 0 insertions, 1637 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java
deleted file mode 100644
index b8f2cedea..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEModuleConstants.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.eclipse.jst.j2ee.internal.plugin;
-
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
-
-public interface IJ2EEModuleConstants extends IModuleConstants {
-
- String J2EE_PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java
deleted file mode 100644
index a0c2f8a3e..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/IJ2EEPreferences.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.internal.plugin;
-
-
-public interface IJ2EEPreferences {
-
- String PREF_J2EEWEBCONTENT = "org.eclipse.jst.j2ee.internal.preference.j2eeWebContentName"; //$NON-NLS-1$
- String PREF_STATICWEBCONTENT = "org.eclipse.jst.j2ee.internal.preference.staticWebContentName"; //$NON-NLS-1$
- String PREF_JAVASOURCE = "org.eclipse.jst.j2ee.internal.preference.javaSourceName"; //$NON-NLS-1$
- String DEFAULT_J2EEWEBCONTENT = "WebContent"; //$NON-NLS-1$
- String DEFAULT_STATICWEBCONTENT = "WebContent"; //$NON-NLS-1$
- String DEFAULT_JAVASOURCE = "JavaSource"; //$NON-NLS-1$
- String SERVER_TARGET_SUPPORT = "org.eclipse.jst.j2ee.internal.preference.servertargetsupport"; //$NON-NLS-1$
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java
deleted file mode 100644
index c7ea0800b..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEGroupInitializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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 Dec 4, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.internal.plugin;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.wst.common.frameworks.internal.enablement.IGroupInitializer;
-
-
-/**
- * @author schacher
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class J2EEGroupInitializer implements IGroupInitializer {
-
- /**
- *
- */
- public J2EEGroupInitializer() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.frameworks.internal.group.IGroupInitializer#isGroupEnabled(org.eclipse.core.resources.IProject)
- */
- public boolean isGroupEnabled(IProject project) {
- return true;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java
deleted file mode 100644
index 1c1572fb8..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.internal.plugin;
-
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Vector;
-
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.ResourceLocator;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.core.JavaModel;
-import org.eclipse.jem.util.UIContextDetermination;
-import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities;
-import org.eclipse.jst.j2ee.application.ApplicationFactory;
-import org.eclipse.jst.j2ee.applicationclient.internal.modulecore.util.AppClientEditAdapterFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit;
-import org.eclipse.jst.j2ee.internal.application.ApplicationPackage;
-import org.eclipse.jst.j2ee.internal.application.impl.ApplicationFactoryImpl;
-import org.eclipse.jst.j2ee.internal.application.impl.ApplicationResourceFactory;
-import org.eclipse.jst.j2ee.internal.client.impl.ApplicationClientResourceFactory;
-import org.eclipse.jst.j2ee.internal.common.impl.J2EEResourceFactoryRegistry;
-import org.eclipse.jst.j2ee.internal.modulecore.util.EarEditAdapterFactory;
-import org.eclipse.jst.j2ee.internal.validation.ResourceUtil;
-import org.eclipse.jst.j2ee.internal.webservices.WSDLServiceExtensionRegistry;
-import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel;
-import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry;
-import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
-import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress;
-import org.eclipse.wst.common.internal.emf.resource.ReferencedXMIFactoryImpl;
-import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel;
-import org.eclipse.wst.validation.internal.operations.ValidatorManager;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * This is a top-level class of the j2ee plugin.
- *
- * @see AbstractUIPlugin for additional information on UI plugins
- */
-
-public class J2EEPlugin extends WTPPlugin implements ResourceLocator {
- // Default instance of the receiver
- private static J2EEPlugin inst;
- public static final String PLUGIN_ID = "org.eclipse.jst.j2ee"; //$NON-NLS-1$
- public static final String UI_PLUGIN_ID = "org.eclipse.jst.j2ee.ui"; //$NON-NLS-1$
- protected final IPath iconsFolder = new Path(Platform.getBundle(PLUGIN_ID).getEntry("icons").getPath()); //$NON-NLS-1$
- // LibDir Change Listener
- public static final String LIBDIRCHANGE_BUILDER_ID = "org.eclipse.jst.j2ee.web.LibDirBuilder"; //$NON-NLS-1$
- // LibCopy builder ID
- public static final String LIBCOPY_BUILDER_ID = PLUGIN_ID + ".LibCopyBuilder"; //$NON-NLS-1$
- // Validation part of the plugin
- public static final String VALIDATION_BUILDER_ID = ValidationPlugin.VALIDATION_BUILDER_ID; // plugin
- private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
- private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
- // id
- // of
- // the
- // validation
- // builder//$NON-NLS-1$
- //Global ResourceSet (somewhat global)
- private static boolean defaultIsWorkspaceRelativeSchema = false;
-
- private List fextendedEditModels;
- private static IPath location;
-
- public static IStatus OK_STATUS = new Status(IStatus.OK, PLUGIN_ID, 0, "OK", null); //$NON-NLS-1$
-
- public static final String[] ICON_DIRS = new String[]{"icons/full/obj16", //$NON-NLS-1$
- "icons/full/cview16", //$NON-NLS-1$
- "icons/full/ctool16", //$NON-NLS-1$
- "icons/full/clcl16", //$NON-NLS-1$
- "icons/full/ovr16", //$NON-NLS-1$
- "icons/full/extra", //$NON-NLS-1$
- "icons/full/wizban", //$NON-NLS-1$
- "icons", //$NON-NLS-1$
- ""}; //$NON-NLS-1$
-
- protected static Boolean EJB_AVAILABLE = null;
- private static Boolean HAS_DEV_ROLE;
-
- private J2EEPreferences preferences = null;
- public static J2EEPlugin INSTANCE = inst;
-
- /**
- * Create the J2EE plugin and cache its default instance
- */
- public J2EEPlugin() {
- super();
- if (inst == null)
- inst = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.jst.j2ee"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (7/16/2001 7:38:56 PM)
- *
- * @return boolean
- */
- public static boolean defaultIsWorkspaceRelativeSchema() {
- return defaultIsWorkspaceRelativeSchema;
- }
-
- /**
- * Get the one application factory.
- */
- public ApplicationFactory getApplicationFactory() {
- return (ApplicationFactory) getApplicationPackage().getEFactoryInstance();
- }
-
- /**
- * Get the one ejb package.
- */
- public ApplicationPackage getApplicationPackage() {
- return ApplicationFactoryImpl.getPackage();
- }
-
- /**
- * Get the plugin singleton.
- */
- static public J2EEPlugin getDefault() {
- return inst;
- }
-
- /*
- * Javadoc copied from interface.
- */
- public URL getBaseURL() {
- return getBundle().getEntry("/");
- }
-
-
- public Object[] getJ2EEWebProjectMigrationExtensions() {
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint pct = registry.getExtensionPoint("J2EEWebProjectMigrationExtension"); //$NON-NLS-1$
- List ret = new Vector();
- if (pct != null) {
- IExtension[] extension = pct.getExtensions();
- for (int l = 0; l < extension.length; ++l) {
- IExtension config = extension[l];
-
- IConfigurationElement[] cElems = config.getConfigurationElements();
- for (int i = 0; i < cElems.length; i++) {
- IConfigurationElement d = cElems[i];
- if (d.getName().equals("migration")) { //$NON-NLS-1$
- try {
- Object me = d.createExecutableExtension("run"); //$NON-NLS-1$
-
- ret.add(me);
- } catch (Exception ex) {
- // ignore this extension, keep going
- }
- }
- }
- }
- }
- return ret.toArray();
- }
-
- public EditModel getExtendedEditModel(String editModelKey) {
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint pct = registry.getExtensionPoint("EditModelExtension"); //$NON-NLS-1$
-
- IExtension[] extension = pct.getExtensions();
- for (int l = 0; l < extension.length; ++l) {
- IExtension config = extension[l];
-
- IConfigurationElement[] cElems = config.getConfigurationElements();
- for (int i = 0; i < cElems.length; i++) {
- IConfigurationElement d = cElems[i];
- if (d.getName().equals("editmodel") && editModelKey.equals(d.getAttribute("key"))) //$NON-NLS-1$ //$NON-NLS-2$
- { // editmodel class
- try {
- return (EditModel) d.createExecutableExtension("run"); //$NON-NLS-1$
-
- } catch (Exception ex) {
- return null;
- }
- }
- }
- }
-
- return null;
- }
-
- public List getExtendedEditModels() {
-
- if (fextendedEditModels != null)
- return fextendedEditModels;
- List editModels = new ArrayList();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint pct = registry.getExtensionPoint("EditModelExtension"); //$NON-NLS-1$
-
- IExtension[] extension = pct.getExtensions();
- for (int l = 0; l < extension.length; ++l) {
- IExtension config = extension[l];
-
- IConfigurationElement[] cElems = config.getConfigurationElements();
- for (int i = 0; i < cElems.length; i++) {
- IConfigurationElement d = cElems[i];
- if (d.getName().equals("editmodel")) //$NON-NLS-1$
- {
- // editmodel class
- try {
- editModels.add(d.createExecutableExtension("run")); //$NON-NLS-1$
-
- } catch (Exception ex) {
- return null;
- }
- }
- }
- }
- fextendedEditModels = editModels;
- return fextendedEditModels;
- }
-
- /**
- * This gets a .gif from the icons folder.
- */
- public static URL getImageURL(String key, Bundle bundle) {
- String gif = "/" + key + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$
- IPath path = null;
- for (int i = 0; i < ICON_DIRS.length; i++) {
- path = new Path(ICON_DIRS[i]).append(gif);
- if (Platform.find(bundle,path) == null)
- continue;
- try {
- return new URL( bundle.getEntry("/"), path.toString());
- } catch (MalformedURLException exception) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(J2EEPluginResourceHandler.getString("Load_Image_Error_", new Object[]{key})); //$NON-NLS-1$
- exception.printStackTrace();
- continue;
- }
- }
- return null;
- }
-
- /**
- * This gets a .gif from the icons folder.
- */
- public Object getImage(String key) {
- return getImageURL(key,this.getBundle());
- }
-
- public static IPath getInstallLocation() {
- if (location == null) {
- URL url = getInstallURL();
- try {
- String installLocation = ((PlatformURLConnection) url.openConnection()).getURLAsLocal().getFile();
- location = new Path(installLocation);
- } catch (IOException e) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(J2EEPluginResourceHandler.getString("Install_Location_Error_", new Object[]{url}) + e); //$NON-NLS-1$
- }
- }
- return location;
- }
-
- public static URL getInstallURL() {
- return getDefault().getBundle().getEntry("/");
- }
-
- protected static JavaModel getJavaModel() {
- return JavaProjectUtilities.getJavaModel();
- }
-
- protected static JavaModel getJavaModel(IProject aProject) {
- if (aProject != null)
- return JavaProjectUtilities.getJavaModel();
- return null;
- }
-
- public static IJavaProject getJavaProject(IProject project) {
- JavaModel model = getJavaModel(project);
- if (model != null)
- return model.getJavaProject(project);
- return null;
- }
-
- /**
- * Retrieves a hashtable of a logger's preferences initially from the
- * com.ibm.etools.logging.util.loggingDefaults extension point if specified in the
- * com.ibm.etools.logging.util plugin.xml file. If specified, the
- * com.ibm.etools.logging.util.loggingOptions extension point preferences in the parameter
- * plugin's plugin.xml file are returned.
- *
- * The logger's preferences are stored in the return hashtable using the static instance
- * variables in LoggerStateHashKeys as keys.
- *
- * @param plugin
- * the Plugin polled for their logger's preferences in the plugin.xml file
- * @return hashtable of a logger's preferences
- */
- /*
- * public java.util.Hashtable getMsgLoggerConfig(org.eclipse.core.runtime.Plugin plugin) {
- * return (new PluginHelperImpl().getMsgLoggerConfig(plugin)); }
- */
- /**
- * Get the singleton instance.
- */
- public static J2EEPlugin getPlugin() {
- return inst;
- }
-
- /**
- * Return the plugin directory location- the directory that all the plugins are located in (i.e.
- * d:\installdir\plugin)
- */
- public static IPath getPluginLocation(String pluginId) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- Bundle bundle = Platform.getBundle(pluginId);
- if (bundle != null) {
- try {
- IPath installPath = new Path(bundle.getEntry("/").toExternalForm()).removeTrailingSeparator();
- String installStr = Platform.asLocalURL(new URL(installPath.toString())).getFile();
- return new Path(installStr);
- } catch (IOException e) {
- };
- }
- return null;
- }
-
- protected void initializeDefaultPluginPreferences() {
- getJ2EEPreferences().initializeDefaultPreferences();
- }
-
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * If this is called from an operation, in response to some other exception that was caught,
- * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException};
- * otherwise this can still be used to signal some other error condition within the operation,
- * or to throw a core exception in a context other than executing an operation
- *
- * Create a new IStatus of type ERROR using the J2EEPlugin ID. aCode is just an internal code.
- */
- public static IStatus newErrorStatus(int aCode, String aMessage, Throwable exception) {
- return newStatus(IStatus.ERROR, aCode, aMessage, exception);
- }
-
- /**
- * If this is called from an operation, in response to some other exception that was caught,
- * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException};
- * otherwise this can still be used to signal some other error condition within the operation,
- * or to throw a core exception in a context other than executing an operation
- *
- * Create a new IStatus of type ERROR, code OPERATION_FAILED, using the J2EEPlugin ID
- */
- public static IStatus newErrorStatus(String aMessage, Throwable exception) {
- return newErrorStatus(0, aMessage, exception);
- }
-
- /**
- * If this is called from an operation, in response to some other exception that was caught,
- * then the client code should throw {@link com.ibm.etools.wft.util.WFTWrappedException};
- * otherwise this can still be used to signal some other error condition within the operation.
- *
- * Create a new IStatus of type ERROR, code OPERATION_FAILED, using the J2EEPlugin ID
- */
- public static IStatus newOperationFailedStatus(String aMessage, Throwable exception) {
- return newStatus(IStatus.ERROR, IResourceStatus.OPERATION_FAILED, aMessage, exception);
- }
-
- /**
- * Create a new IStatus with a severity using the J2EEPlugin ID. aCode is just an internal code.
- */
- public static IStatus newStatus(int severity, int aCode, String aMessage, Throwable exception) {
- return new Status(severity, PLUGIN_ID, aCode, aMessage, exception);
- }
-
- /*
- * Javadoc copied from interface.
- */
- public String getString(String key) {
- try {
- return Platform.getResourceString(getBundle(), key);
- } catch (MissingResourceException ex) {
- //TODO Don't throw error - just show unresolved key
- //Logger.getLogger().logError(ex);
- return '!' + key + '!';
- }
- }
-
- /*
- * Javadoc copied from interface.
- */
- public String getString(String key, Object[] substitutions) {
- return MessageFormat.format(getString(key), substitutions);
- }
-
- /**
- * Insert the method's description here. Creation date: (7/16/2001 7:38:56 PM)
- *
- * @param newDefaultIsWorkspaceRelativeSchema
- * boolean
- */
- public static void setDefaultIsWorkspaceRelativeSchema(boolean newDefaultIsWorkspaceRelativeSchema) {
- defaultIsWorkspaceRelativeSchema = newDefaultIsWorkspaceRelativeSchema;
- }
-
- /**
- * This method should be used to determine if the EJB UI support is currently packaged in the
- * image.
- */
- public static boolean isEJBSupportAvailable() {
- if (EJB_AVAILABLE == null) {
- //TODO We need a better mechanism for the detection of the EJB support.
- //IPluginDescriptor desc =
- // Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.jst.j2ee.internal.internal.ejb.ui");
- // //$NON-NLS-1$
- // EJB_AVAILABLE = new Boolean(desc != null);
- EJB_AVAILABLE = Boolean.TRUE;
- }
- return EJB_AVAILABLE.booleanValue();
- }
-
- /**
- * This method should be used to determine if the workbench is running in UI or Headless
- *
- * @deprecated use {@link org.eclipse.wst.common.frameworks.internal.UIContextDetermination}
- */
- public static boolean isHeadless() {
- return UIContextDetermination.getCurrentContext() == UIContextDetermination.HEADLESS_CONTEXT;
- }
-
- /**
- * Sets the logger's preferences based on values in the parameter hashtable.
- *
- * The logger's preferences are stored in the parameter hashtable using the static instance
- * variables in LoggerStateHashKeys as keys.
- *
- * @param msgLoggerConfig
- * hashtable of the logger's preferences
- */
- /*
- * public void setMsgLoggerConfig(java.util.Hashtable msgLoggerConfig) { MsgLogger ml =
- * getLogger(); ml.setMsgLoggerConfig(msgLoggerConfig);
- * org.eclipse.wst.common.frameworks.internal.logger.proxy.Logger.getLogger(PLUGIN_ID).setTraceMode(
- * ml.getMsgLoggerConfig().get(LoggerStateHashKeys.LEVEL).equals(Level.getLevelName(Level.FINEST))); }
- */
- public void stop(BundleContext bundle) throws Exception {
- super.stop(bundle);
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- //Have to do the next line immediately to fix timing problems with factory registration
- ArchiveInit.init(false);
- //ModuleMaps are the maps from modules in an ear project to the j2ee projects for the
- // modules
- org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapInit.init(false);
- ensureFactoryRegistration();
- ValidatorManager.setResourceUtilClass(ResourceUtil.class);
- IAdapterManager manager = Platform.getAdapterManager();
- manager.registerAdapters(new EarEditAdapterFactory(), ArtifactEditModel.class);
- manager.registerAdapters(new AppClientEditAdapterFactory(), ArtifactEditModel.class);
- ApplicationResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE);
- ApplicationClientResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE);
- WSDLServiceExtensionRegistry.getInstance();
-
- }
-
- /*
- * need to make sure the correct factories get loaded when we are in the UI
- */
- private void ensureFactoryRegistration() {
- //Inside the workbench we do not want the global override defined here.
- ensureDefaultReferencedXMIResourceFactoryRegistration();
- }
-
- /**
- *
- */
- private void ensureDefaultReferencedXMIResourceFactoryRegistration() {
- J2EEResourceFactoryRegistry reg = J2EEResourceFactoryRegistry.INSTANCE;
- ReferencedXMIFactoryImpl factory = new ReferencedXMIFactoryImpl();
- reg.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, factory);
- // add xmi because other plugins are registering it globally
- reg.getExtensionToFactoryMap().put("xmi", factory); //$NON-NLS-1$
- }
-
- /**
- * This is currently just a convenience api for the AAW to turn off unwanted actions. It will
- * currently be initialized based on the existence of the AAW plugin.
- */
- public static boolean hasDevelopmentRole() {
- if (HAS_DEV_ROLE == null) {
- Bundle desc = Platform.getBundle("org.eclipse.jst.j2ee.assembly"); //$NON-NLS-1$
- HAS_DEV_ROLE = desc != null ? Boolean.FALSE : Boolean.TRUE;
- }
- return HAS_DEV_ROLE.booleanValue();
- }
-
- public static IWorkspaceRunnable getWorkspaceRunnable(final IHeadlessRunnableWithProgress op) {
- return new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- op.run(monitor);
- } catch (InvocationTargetException e) {
- throw new CoreException(newErrorStatus(0, e.getMessage(), e));
- } catch (InterruptedException e) {
- throw new CoreException(newErrorStatus(0, e.getMessage(), e));
- }
- }
- };
- }
-
- public String getPluginID() {
- return PLUGIN_ID;
- }
-
- /**
- * @return Returns the preferences.
- */
- public J2EEPreferences getJ2EEPreferences() {
- if (this.preferences == null)
- this.preferences = new J2EEPreferences(this);
- return this.preferences;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java
deleted file mode 100644
index 54eb06053..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPluginResourceHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/***************************************************************************************************
- * 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
- **************************************************************************************************/
-package org.eclipse.jst.j2ee.internal.plugin;
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class J2EEPluginResourceHandler {
-
- private static ResourceBundle fgResourceBundle;
-
- /**
- * Returns the resource bundle used by all classes in this Project
- */
- public static ResourceBundle getResourceBundle() {
- try {
- return ResourceBundle.getBundle("j2eewtpplugin");//$NON-NLS-1$
- } catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String, String) will return the key
- // it was called with
- }
- return null;
- }
-
- public static String getString(String key) {
- if (fgResourceBundle == null) {
- fgResourceBundle = getResourceBundle();
- }
-
- if (fgResourceBundle != null) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- }
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
-
- public static String getString(String key, Object[] args) {
-
- try {
- return MessageFormat.format(getString(key), args);
- } catch (IllegalArgumentException e) {
- return getString(key);
- }
-
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 64b87a3c5..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPreferences.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * 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.j2ee.internal.plugin;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-
-
-/**
- * @author mdelder
- */
-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$
-
-
- }
-
- public interface Values {
- final static String J2EE_VERSION_1_2 = "J2EE_1_2"; //$NON-NLS-1$
- 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$
- }
-
- public interface Defaults {
-
- final static String J2EE_WEB_CONTENT = Values.J2EE_WEB_CONTENT;
- final static String STATIC_WEB_CONTENT = Values.STATIC_WEB_CONTENT;
- 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;
- final static boolean CREATE_EJB_CLIENT_JAR = false;
- final static boolean EJB_CLIENT_JAR_CP_COMPATIBILITY = true;
- final static boolean INCREMENTAL_DEPLOYMENT_SUPPORT = false;
- }
-
- private Plugin owner = null;
- private Preferences preferences = null;
- private boolean persistOnChange = false;
-
- public J2EEPreferences(Plugin owner) {
- this.owner = owner;
- }
-
- 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);
-
- }
-
- public String getJ2EEWebContentFolderName() {
- return getPreferences().getString(Keys.J2EE_WEB_CONTENT);
- }
-
- public String getStaticWebContentFolderName() {
- return getPreferences().getString(Keys.STATIC_WEB_CONTENT);
- }
-
- public String getJavaSourceFolderName() {
- return getPreferences().getString(Keys.JAVA_SOURCE);
- }
-
- public String getHighestJ2EEVersionSetting() {
- return getPreferences().getString(Keys.J2EE_VERSION);
- }
-
- public boolean isServerTargetingEnabled() {
- return getPreferences().getBoolean(Keys.SERVER_TARGET_SUPPORT);
- }
-
- ///
- public void setJ2EEWebContentFolderName(String value) {
- getPreferences().setValue(Keys.J2EE_WEB_CONTENT, value);
- firePreferenceChanged();
- }
-
- public void setStaticWebContentFolderName(String value) {
- getPreferences().setValue(Keys.STATIC_WEB_CONTENT, value);
- firePreferenceChanged();
- }
-
- public void setJavaSourceFolderName(String value) {
- getPreferences().setValue(Keys.JAVA_SOURCE, value);
- firePreferenceChanged();
- }
-
- public void setHighestJ2EEVersionSetting(String value) {
- getPreferences().setValue(Keys.J2EE_VERSION, value);
- firePreferenceChanged();
- }
-
- public void setServerTargetingEnabled(boolean value) {
- getPreferences().setValue(Keys.SERVER_TARGET_SUPPORT, value);
- firePreferenceChanged();
- }
-
- public void setIncrementalDeploymentEnabled(boolean value) {
- getPreferences().setValue(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT, value);
- firePreferenceChanged();
- }
-
- public boolean isIncrementalDeploymentEnabled() {
- return getPreferences().getBoolean(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT);
- }
-
- /**
- * @return one of J2EEVersionConstants.J2EE_VERSION_X_X (@see J2EEVersionConstants)
- */
- public int getHighestJ2EEVersionID() {
- String versionPreference = getHighestJ2EEVersionSetting();
- if (Values.J2EE_VERSION_1_2.equals(versionPreference))
- return J2EEVersionConstants.J2EE_1_2_ID;
- else if (Values.J2EE_VERSION_1_3.equals(versionPreference))
- return J2EEVersionConstants.J2EE_1_3_ID;
- else
- return J2EEVersionConstants.J2EE_1_4_ID;
- }
-
- 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;
- }
-
- private Preferences getPreferences() {
- if (this.preferences == null)
- this.preferences = getOwner().getPluginPreferences();
- return this.preferences;
- }
-
- /**
- * @return Returns the owner.
- */
- private Plugin getOwner() {
- return this.owner;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java
deleted file mode 100644
index 57ad496dc..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/LibCopyBuilder.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.internal.plugin;
-
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-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.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities;
-
-/**
- * An example incremental project builder that copies additional class files from a library package
- * fragment root folder into a Java project's output directory.
- *
- * General parameters:
- * <ul>
- * <li>The project should be a Java project.</li>
- * <li>The class files are in the "imported_classes" folder of the project.</li>
- * <li>This builder should run <b>after </b> the Java builder.</li>
- * <li>Full build should copy class files from a secondary library folder into the output folder
- * maintaining package hierarchy; existing class files must never be overwritten.</li>
- * <li>Only *.class files should be copied (not other resource files).</li>
- * <li>Incremental build and auto-build should will perform the copy when there is an add/change in
- * the "imported_classes" folder.</li>
- * <li>Changing the project's output folder should be handled.</li>
- * </ul>
- * Note: the builder is not currently invoking the Minimize helper, it is relying on the copy to not
- * replace existing class files, and the build path order to ensure that compiled classes override
- * imported ones.
- */
-public class LibCopyBuilder extends IncrementalProjectBuilder {
- /**
- * Internal debug tracing.
- */
- static boolean DEBUG = false;
-
- /**
- * Builder id of this incremental project builder.
- */
- public static final String BUILDER_ID = J2EEPlugin.LIBCOPY_BUILDER_ID;
-
- /**
- * The path where we expect to find the .class files to be copied.
- */
- public static final String IMPORTED_CLASSES_PATH = "imported_classes"; //$NON-NLS-1$
-
- /**
- * The path of the output folder that we last copied class files into, or <code>null</code> if
- * this builder has not built this project before.
- */
- private IPath lastOutputPath = null;
-
- private List sourceContainers;
-
- private boolean needOutputRefresh;
-
- /**
- * Creates a new instance of the library copying builder.
- * <p>
- * All incremental project builders are required to have a public 0-argument constructor.
- * </p>
- */
- public LibCopyBuilder() {
- super();
- }
-
-
- /**
- *
- * The <code>LibCopyBuilder</code> implementation of this
- * <code>IncrementalProjectBuilder</code> method copies additional class files into the output
- * folder.
- * <p>
- * [Issue: the implementation should report progress.]
- * </p>
- * <p>
- * [Issue: the implementation should probably use a workspace runnable.]
- * </p>
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- sourceContainers = null;
- needOutputRefresh = false;
- if (DEBUG) {
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Start_build_project_INFO_") + getProject().getName()); //$NON-NLS-1$
- }
-
- boolean builderOrderOK = checkBuilderOrdering();
-
- if (DEBUG && !builderOrderOK) {
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Bad_builder_order_for_project_INFO_") + getProject().getName()); //$NON-NLS-1$
- }
-
- IFolder[] classFolders = getClassesFolders();
- if (classFolders.length == 0) {
- // no files to copy
- if (DEBUG)
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__No_imported_classes_folder,_quitting_INFO_")); //$NON-NLS-1$
- return null;
- }
-
- IJavaProject jproject = JavaCore.create(getProject());
- if (jproject == null) {
- // not a java project (anymore?)
- return null;
- }
-
- IPath outputPath = jproject.getOutputLocation();
- IFolder outputFolder = getProject().getParent().getFolder(outputPath);
- if (outputPath.equals(lastOutputPath)) {
- if (kind == INCREMENTAL_BUILD || kind == AUTO_BUILD) {
- processDelta(getDelta(getProject()), outputFolder, monitor, classFolders);
- refreshOutputIfNecessary(outputFolder);
- return null;
- }
- }
-
- if (DEBUG) {
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Full/first_build_INFO_")); //$NON-NLS-1$
- }
- copyAllClassFolders(monitor, classFolders, outputFolder);
- lastOutputPath = outputPath;
- refreshOutputIfNecessary(outputFolder);
- return null;
- }
-
- /**
- *
- */
- private void refreshOutputIfNecessary(IFolder outputFolder) throws CoreException {
- if (needOutputRefresh && outputFolder != null && outputFolder.exists())
- outputFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- private void copyAllClassFolders(IProgressMonitor monitor, IFolder[] classFolders, IFolder outputFolder) throws CoreException {
- for (int i = 0; i < classFolders.length; i++) {
- copyClassFiles(classFolders[i], outputFolder, monitor);
- }
-
- }
-
-
- /**
- * Process an incremental build delta.
- *
- * @return <code>true</code> if the delta requires a copy
- * @param dest
- * the destination folder; may or may not exist
- * @param monitor
- * the progress monitor, or <code>null</code> if none
- * @exception CoreException
- * if something goes wrong
- */
- protected void processDelta(IResourceDelta delta, final IFolder outputFolder, final IProgressMonitor monitor, final IFolder[] classesFolders) {
- if (DEBUG) {
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Considering_delta_INFO_") + delta); //$NON-NLS-1$
- }
- IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
- private List copiedClassFolders = new ArrayList(classesFolders.length);
-
- public boolean visit(IResourceDelta subdelta) throws CoreException {
- IResource resource = subdelta.getResource();
- if (resource.getType() == IResource.FILE) {
- IFolder classesFolder = retrieveClassesFolder(resource, classesFolders);
- if (classesFolder != null && !copiedClassFolders.contains(classesFolder)) {
- int kind = subdelta.getKind();
- switch (kind) {
- case IResourceDelta.ADDED :
- case IResourceDelta.CHANGED :
- if (DEBUG) {
- System.out.println(BUILDER_ID + J2EEPluginResourceHandler.getString("__Delta_build_INFO_") + subdelta); //$NON-NLS-1$
- }
- copyClassFiles(classesFolder, outputFolder, monitor);
- break;
- case IResourceDelta.REMOVED :
- deleteCorrespondingFile((IFile) resource, classesFolder, outputFolder, monitor);
- break;
- case IResourceDelta.ADDED_PHANTOM :
- break;
- case IResourceDelta.REMOVED_PHANTOM :
- break;
- }
-
- }
- } else if (resource.getType() == IResource.FOLDER && resource.equals(outputFolder)) {
- copyAllClassFolders(null, classesFolders, outputFolder);
- return false;
- }
- return true;
- }
- };
- if (delta != null) {
- try {
- delta.accept(visitor);
- } catch (CoreException e) {
- // should not happen
- }
- }
- }
-
- /**
- * @param file
- * @param classesFolder
- * @param outputFolder
- * @param monitor
- */
- protected void deleteCorrespondingFile(IFile file, IFolder classesFolder, IFolder outputFolder, IProgressMonitor monitor) throws CoreException {
- IPath path = file.getFullPath();
- int segCount = classesFolder.getFullPath().segmentCount();
- path = path.removeFirstSegments(segCount);
- IFile javaFile = findCorrespondingJavaFile(path);
- if (javaFile != null && javaFile.exists())
- return; //There is nothing to do because the file in the output location is from the
- // java compilation not the copy.
- IFile outFile = outputFolder.getFile(path);
- if (outFile.exists())
- outFile.delete(true, false, monitor);
- }
-
-
- /**
- * Method retrieveClassesFolder.
- *
- * @param resource
- * @return IFolder
- */
- protected IFolder retrieveClassesFolder(IResource resource, IFolder[] classesFolders) {
- for (int i = 0; i < classesFolders.length; i++) {
- if (classesFolders[i].getName().equals(resource.getProjectRelativePath().segment(0)))
- return classesFolders[i];
- }
- return null;
- }
-
-
- /**
- * Checks whether this builder is configured to run <b>after </b> the Java builder.
- *
- * @return <code>true</code> if the builder order is correct, and <code>false</code>
- * otherwise
- * @exception CoreException
- * if something goes wrong
- */
- private boolean checkBuilderOrdering() throws CoreException {
- // determine relative builder position from project's buildspec
- ICommand[] cs = getProject().getDescription().getBuildSpec();
- int myIndex = -1;
- int javaBuilderIndex = -1;
- for (int i = 0; i < cs.length; i++) {
- if (cs[i].getBuilderName().equals(JavaCore.BUILDER_ID)) {
- javaBuilderIndex = i;
- } else if (cs[i].getBuilderName().equals(BUILDER_ID)) {
- myIndex = i;
- }
- }
- return myIndex > javaBuilderIndex;
- }
-
- /**
- * Copies class files from the given source folder to the given destination folder. The
- * destination folder will be created if required, but only if at least one class file is
- * copied.
- *
- * @param source
- * the source folder; must exist
- * @param dest
- * the destination folder; may or may not exist
- * @param monitor
- * the progress monitor, or <code>null</code> if none
- * @exception CoreException
- * if something goes wrong
- */
- private void copyClassFiles(IFolder source, final IFolder dest, final IProgressMonitor monitor) throws CoreException {
- if (DEBUG) {
- System.out.println(BUILDER_ID + ": Begin copying class files from " + source.getFullPath() + " to " + dest.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- final int sourcePathLength = source.getFullPath().segmentCount();
-
- class Visitor implements IResourceVisitor {
- public boolean visit(IResource res) throws CoreException {
- if (res.getType() == IResource.FILE) {
- IFile file = (IFile) res;
-
- // compute relative path from source folder to this file
- IPath filePath = file.getFullPath();
- IPath dpath = filePath.removeFirstSegments(sourcePathLength);
- IFile targetFile = dest.getFile(dpath);
- copyFile(file, targetFile, dpath, monitor);
- }
- return true;
- }
- }
-
- try {
- source.accept(new Visitor());
- } catch (CoreException e) {
- // should not happen
- }
-
- }
-
- /**
- * Copies the given file to the given destination file. Does nothing if the destination file
- * already exists.
- *
- * @param source
- * the source file; must exist
- * @param dest
- * the destination file; may or may not exist; never overwritten
- * @param monitor
- * the progress monitor, or <code>null</code> if none
- * @exception CoreException
- * if something goes wrong
- */
- private void copyFile(IFile source, IFile dest, IPath fileRelativePath, IProgressMonitor monitor) throws CoreException {
- if (pruneForJavaSource(source, fileRelativePath, monitor))
- return; //no copy necessary.
- File sourceFile = null, destFile = null;
- if (source.exists())
- sourceFile = source.getLocation().toFile();
- if (dest.exists())
- destFile = dest.getLocation().toFile();
-
- if (destFile != null && sourceFile != null) {
- if (DEBUG)
- System.out.println(BUILDER_ID + ": " + dest.getFullPath() + " already exists."); //$NON-NLS-1$ //$NON-NLS-2$
- if (destFile.lastModified() == sourceFile.lastModified())
- return;
- dest.setContents(source.getContents(false), true, false, monitor); //we have to force
- // b/c set the mod
- // stamp makes it
- // think it is out of
- // synch.
- synchronizeModificationStamps(sourceFile, destFile);
- return;
- }
- if (DEBUG) {
- System.out.println(BUILDER_ID + ": Creating " + dest.getFullPath()); //$NON-NLS-1$
- }
-
- IContainer parent = dest.getParent();
- if (parent.getType() == IResource.FOLDER) {
- mkdirs((IFolder) parent, monitor);
- }
- dest.create(source.getContents(false), false, monitor);
- destFile = dest.getLocation().toFile();
- synchronizeModificationStamps(sourceFile, destFile);
- dest.setDerived(true);
- }
-
- /**
- * Return true if a corresponding .java file is found. Remove the .class file from the
- * imported_classes folder (i.e., delete the source file).
- *
- * @param source
- * @param monitor
- * @return
- */
- private boolean pruneForJavaSource(IFile classFile, IPath fileRelativePath, IProgressMonitor monitor) throws CoreException {
- if (classFile.exists()) {
- IFile javaFile = findCorrespondingJavaFile(fileRelativePath);
- if (javaFile != null && javaFile.exists()) {
- ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{javaFile}, null);
- classFile.delete(true, false, monitor);
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * @param classFilePath
- * @return
- */
- private IFile findCorrespondingJavaFile(IPath classFilePath) {
- IPath javaPath = convertToJavaPath(classFilePath);
- List sourceFolders = getSourceContainers();
- IContainer cont;
- IFile javaFile;
- for (int i = 0; i < sourceFolders.size(); i++) {
- cont = (IContainer) sourceFolders.get(i);
- javaFile = cont.getFile(javaPath);
- if (javaFile.exists())
- return javaFile;
- }
- return null;
- }
-
-
- private List getSourceContainers() {
- if (sourceContainers == null)
- sourceContainers = JavaProjectUtilities.getSourceContainers(getProject());
- return sourceContainers;
- }
-
-
- /**
- * @param classFile
- * @return
- */
- private IPath convertToJavaPath(IPath classFilePath) {
- IPath javaPath = classFilePath.removeFileExtension();
- //handle inner classes...look for outermost java file
- String fileName = classFilePath.lastSegment();
- int innerIndex = fileName.indexOf('$');
- if (innerIndex > -1) {
- javaPath = javaPath.removeLastSegments(1);
- javaPath = javaPath.append(fileName.substring(0, innerIndex));
- }
- javaPath = javaPath.addFileExtension("java"); //$NON-NLS-1$
- return javaPath;
- }
-
-
- /**
- * @param source
- * @param dest
- */
- private void synchronizeModificationStamps(File sourceFile, File destFile) {
- if (destFile != null && sourceFile != null) {
- destFile.setLastModified(sourceFile.lastModified());
- needOutputRefresh = true;
- }
- }
-
-
- /**
- * Creates the given folder, and its containing folders, if required. Does nothing if the given
- * folder already exists.
- *
- * @param folder
- * the folder to create
- * @param monitor
- * the progress monitor, or <code>null</code> if none
- * @exception CoreException
- * if something goes wrong
- */
- private void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException {
- if (folder.exists()) {
- return;
- }
- IContainer parent = folder.getParent();
- if (!parent.exists() && parent.getType() == IResource.FOLDER) {
- mkdirs((IFolder) parent, monitor);
- }
- folder.create(false, true, monitor);
- }
-
- private IFolder[] getClassesFolders() {
- IProject project = getProject();
- IJavaProject javaProj = JavaProjectUtilities.getJavaProject(project);
- if (javaProj == null)
- return new IFolder[0];
- List result = null;
- IClasspathEntry[] entries;
- try {
- entries = javaProj.getResolvedClasspath(true);
- } catch (JavaModelException e) {
- return new IFolder[0];
- }
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath path = entry.getPath();
- IResource res = project.getWorkspace().getRoot().findMember(path);
- if (res != null && res.isAccessible() && res.getType() == IResource.FOLDER && res.getProject().equals(project)) {
- if (result == null)
- result = new ArrayList(1);
- result.add(res);
- }
- }
- }
- if (result == null)
- return new IFolder[0];
- return (IFolder[]) result.toArray(new IFolder[result.size()]);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java
deleted file mode 100644
index e0f298bc2..000000000
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/MinimizeLib.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.jst.j2ee.internal.plugin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageDeclaration;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.emf.workbench.JavaProjectUtilities;
-import org.eclipse.jst.j2ee.internal.project.J2EENature;
-
-/**
- * Minimize the number of loose class files from an unzipped class library by removing ones
- * corresponding to Java source files.
- */
-public class MinimizeLib {
-
- static boolean DEBUG = true;
-
- /**
- * Helper class for discarding class files for which there is corresponding source. Note: this
- * could be a fairly expensive operation.
- * <p>
- * Assumptions:
- * <ul>
- * <li>The source files are in the source folders of the project.</li>
- * <li>The source folders are source package fragment roots. This allows us to use the Java
- * model to find and access source files.</li>
- * <li>The class files are in the "imported_classes" root folder of the project.</li>
- * <li>We want to delete any class files in the "imported_classes" folder for which there is
- * corresponding source file in any source folder.</li>
- * </ul>
- * </p>
- *
- * @param project
- * the Java project to minimize
- */
- public static void minimize(IJavaProject project) {
-
- if (DEBUG) {
- System.out.println(J2EEPluginResourceHandler.getString("Minimizing_project_UI_") + project.getElementName()); //$NON-NLS-1$
- }
-
- final IFolder classesFolder = project.getProject().getFolder(LibCopyBuilder.IMPORTED_CLASSES_PATH);
-
- if (!classesFolder.exists()) {
- // no classes folder means nothing to prune
- if (DEBUG) {
- System.out.println(J2EEPluginResourceHandler.getString("No_library_folder_UI_") + classesFolder.getFullPath()); //$NON-NLS-1$
- }
- return;
- }
-
- // List of fully qualified type names for which we have source
- // (element type: String)
- final Set sourceTypeNames = new HashSet(1000);
-
- J2EENature nature = J2EENature.getRegisteredRuntime(project.getProject());
- if (nature == null) {
- // not a valid project to build
- if (DEBUG) {
- System.out.println(J2EEPluginResourceHandler.getString("Not_a_J2EE_project_UI_") + project.getProject()); //$NON-NLS-1$
- }
- return;
- }
- List sourceFolders = JavaProjectUtilities.getSourceContainers(project.getProject());
- for (Iterator iter = sourceFolders.iterator(); iter.hasNext();) {
- IFolder srcFolder = (IFolder) iter.next();
- // use Java model to rip through sources to get list of type names
- try {
- IPackageFragmentRoot srcRoot = project.getPackageFragmentRoot(srcFolder);
- IJavaElement[] pkgs = srcRoot.getChildren();
- for (int i = 0; i < pkgs.length; i++) {
- if (pkgs[i] instanceof IPackageFragment) {
- IPackageFragment pkg = (IPackageFragment) pkgs[i];
- ICompilationUnit[] cus = pkg.getCompilationUnits();
- for (int j = 0; j < cus.length; j++) {
- ICompilationUnit cu = cus[j];
- sourceTypeNames.addAll(Arrays.asList(extractTypeNames(cu)));
- }
- }
- }
- } catch (JavaModelException e) {
- // unexpected
- e.printStackTrace();
- }
-
- }
-
- if (sourceTypeNames.isEmpty()) {
- // no source types means no pruning possible
- if (DEBUG) {
- System.out.println(J2EEPluginResourceHandler.getString("No_source_types_UI_")); //$NON-NLS-1$
- }
- return;
- }
-
- // verify that none of the type names are problematic (contain "$")
- // if the name contains '$' we can't pattern match class file names
- for (Iterator it = sourceTypeNames.iterator(); it.hasNext();) {
- String sourceTypeName = (String) it.next();
- if (sourceTypeName.indexOf('$') >= 0) {
- // we're in trouble
- throw new RuntimeException(J2EEPluginResourceHandler.getString("Some_source_types_have___$___in_their_name_ERROR_")); //$NON-NLS-1$
- }
- }
-
- // walk the classes folder deleting class files for which there is source
- class Visitor implements IResourceVisitor {
- public boolean visit(IResource res) throws CoreException {
- if (res.getType() == IResource.FILE) {
- IFile file = (IFile) res;
- String ext = res.getFileExtension();
- if (ext != null && ext.equals("class")) { //$NON-NLS-1$
- IPath pkgPath = file.getFullPath().removeFirstSegments(2).removeLastSegments(1);
- String pkgName = pkgPath.toString().replace('/', '.');
- String baseTypeName = pkgName.length() == 0 ? baseTypeName(file) : pkgName + "." + baseTypeName(file); //$NON-NLS-1$
- if (DEBUG) {
- System.out.println("Have source for " + baseTypeName + "? " + (sourceTypeNames.contains(baseTypeName) ? "Yes" : "No")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- if (sourceTypeNames.contains(baseTypeName)) {
- deleteClassFile(file);
- }
- }
- }
- return true;
- }
- }
-
- try {
- classesFolder.accept(new Visitor());
- } catch (CoreException e) {
- // should not happen
- e.printStackTrace();
- }
- }
-
- /**
- * Deletes the given class file resource. Does nothing if unable to delete it.
- *
- * @param classFile
- * the class file resource to delete
- */
- static void deleteClassFile(IFile classFile) {
- if (DEBUG) {
- System.out.println("Delete " + classFile.getFullPath()); //$NON-NLS-1$
- }
- try {
- classFile.delete(true, false, (IProgressMonitor) null);
- } catch (CoreException e) {
- // unexpected
- e.printStackTrace();
- }
- }
-
- /**
- * Returns the base type name for the given class file, assuming the standard scheme Java
- * compilers use to name generated class files.
- * <p>
- * For example,
- * <ul>
- * <li>file <code>Foo.class</code> returns <code>"Foo"</code></li>
- * <li>file <code>Foo$1.class</code> returns <code>"Foo"</code></li>
- * <li>file <code>Foo$Bar.class</code> returns <code>"Foo"</code></li>
- * <li>file <code>Foo$1$Bar.class</code> returns <code>"Foo"</code></li>
- * </ul>
- *
- * @param classFile
- * the class file
- * @return the name of the corresponding top-level type
- */
- static String baseTypeName(IFile classFile) {
- String fileName = classFile.getName();
- int x = fileName.lastIndexOf(".class"); //$NON-NLS-1$
- if (x < 0) {
- throw new IllegalArgumentException();
- }
- // strip off .class suffix
- String binaryTypeName = fileName.substring(0, x);
- int d = binaryTypeName.indexOf("$"); //$NON-NLS-1$
- if (d < 0)
- return binaryTypeName;
- // the characters before the '$' is the top-level type name
- return binaryTypeName.substring(0, d);
- }
-
- /**
- * Returns a list of fully-qualifed names of top-level types declared in the given compilation
- * unit. Returns the empty list if the compilation unit is empty or could not be parsed.
- *
- * @param cu
- * the Java compilation unit
- * @return the list of fully-qualified names of package-member types
- */
- static String[] extractTypeNames(ICompilationUnit cu) {
- List typeNames = new ArrayList();
- try {
- IPackageDeclaration[] pds = cu.getPackageDeclarations();
- String packageName = pds.length == 0 ? "" : pds[0].getElementName(); //$NON-NLS-1$
- IType[] types = cu.getTypes();
- for (int k = 0; k < types.length; k++) {
- IType type = types[k];
- String name = type.getElementName();
- String fqTypeName = packageName.length() == 0 ? name : packageName + "." + name; //$NON-NLS-1$
- typeNames.add(fqTypeName);
- }
- } catch (JavaModelException e) {
- // unexpected
- e.printStackTrace();
- }
- String[] result = new String[typeNames.size()];
- typeNames.toArray(result);
- return result;
- }
-
-} \ No newline at end of file

Back to the top