Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee/common')
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CMPJavaChangeSynchronizationAdapter.java361
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java722
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelEvent.java42
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelListener.java14
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java21
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EECommonMessages.java74
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EEVersionUtil.java271
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/UpdateProjectClasspath.java162
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/VirtualArchiveComponentAdapterFactory.java34
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java174
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathInitializer.java24
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java262
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentReferenceUpdater.java110
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/INewJavaClassDataModelProperties.java100
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/J2EEModifierHelperCreator.java195
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProperties.java59
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProvider.java82
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyOperation.java178
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JavaModelUtil.java773
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassDataModelProvider.java510
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassOperation.java821
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/UpdateJavaBuildPathOperation.java273
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/DefaultWSDLServiceHelper.java147
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtManager.java32
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtensionRegistry.java71
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceHelper.java51
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServiceClientGenerator.java56
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataHelper.java78
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataRegistry.java86
29 files changed, 0 insertions, 5783 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CMPJavaChangeSynchronizationAdapter.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CMPJavaChangeSynchronizationAdapter.java
deleted file mode 100644
index 4e3fa5e23..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CMPJavaChangeSynchronizationAdapter.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory;
-import org.eclipse.jem.internal.java.adapters.ReadAdaptor;
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaVisibilityKind;
-import org.eclipse.jem.java.util.NotificationUtil;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl;
-
-/**
- * This adapter is used to listen for changes to the ejb class or the primary key class in order to
- * reflect the proper CMP field types and the proper key attributes.
- */
-public class CMPJavaChangeSynchronizationAdapter extends AdapterImpl {
-
- private static final String J2EE_PROJ_MIGRATION_ADAPTER = "J2EEProjectMigration"; //$NON-NLS-1$
-
- protected static EjbPackage EJB_PACK = EjbFactoryImpl.getPackage();
-
- private static HashMap enablementMap = new HashMap();
-
- public static void disable(ContainerManagedEntity cmp) {
- enablementMap.put(cmp, Boolean.FALSE);
- }
-
- public static void enable(ContainerManagedEntity cmp) {
- enablementMap.put(cmp, Boolean.TRUE);
- }
-
- public static boolean isEnabled(ContainerManagedEntity cmp) {
- if (!enablementMap.containsKey(cmp))
- return true;
- return ((Boolean) enablementMap.get(cmp)).booleanValue();
- }
-
- protected Resource cmpResource;
-
- private List foundKeys = new ArrayList();
-
- public CMPJavaChangeSynchronizationAdapter() {
- super();
- } // EJBKeyShapeMaintenanceAdapter
-
- /**
- * Notifies if there is change in the key shape.
- *
- * @param Notification
- * msg - Message indicates what has changed.
- */
- public void notifyChanged(Notification msg) {
- if (!isEnabled(getCMP())) {
- enable(getCMP());
- return;
- }
- switch (msg.getEventType()) {
- case Notification.SET :
- setNotification(msg);
- break;
- case Notification.UNSET :
- unsetNotification(msg);
- break;
- // case Notification.TOUCH :
- // touchNotification(msg);
- // break;
- case Notification.REMOVING_ADAPTER :
- removeAdapterNotification(msg);
- break;
- } // switch
- } // notifyChanged
-
- /**
- * Use if the there was an set notification.
- *
- * @param Notification
- * msg - Message indicates what has changed.
- */
- protected void setNotification(Notification msg) {
- EStructuralFeature sf = (EStructuralFeature) msg.getFeature();
- if (sf == EJB_PACK.getEnterpriseBean_EjbClass() || sf == EJB_PACK.getEntity_PrimaryKey()) {
- if (!isMigrating()) {
- removeAttributeMaintenanceAdapter((Notifier) msg.getOldValue());
- addAttributeMaintenanceAdapter((Notifier) msg.getNewValue());
- touchKeyShapeAdapter(msg);
- }
- } else if (sf == EJB_PACK.getEntity_PrimaryKey()) {
- removeAttributeMaintenanceAdapter((Notifier) msg.getOldValue());
- if (shouldAddToPrimaryKeyClass((ContainerManagedEntity) getTarget()))
- addAttributeMaintenanceAdapter((Notifier) msg.getNewValue());
- } else {
- touchNotification(msg); //In EMF a TOUCH is a SET.
- }
- } // setNotification
-
- /**
- * @return
- */
- private boolean isMigrating() {
- EJBJar jar = ((ContainerManagedEntity) getTarget()).getEjbJar();
- if (jar != null)
- return EcoreUtil.getExistingAdapter(jar, J2EE_PROJ_MIGRATION_ADAPTER) != null;
- return false;
- }
-
- // setNotification
- /**
- * Use if the there was an unset notification.
- *
- * @param Notification
- * msg - Message indicates what has changed.
- */
- protected void unsetNotification(Notification msg) {
- EStructuralFeature sf = (EStructuralFeature) msg.getFeature();
- if ((sf == EJB_PACK.getEnterpriseBean_EjbClass() || sf == EJB_PACK.getEntity_PrimaryKey()) && !isMigrating()) {
- removeAttributeMaintenanceAdapter((Notifier) msg.getOldValue());
- }
- } // unsetNotification
-
- /**
- * Use if the there was an touch notification.
- *
- * @param Notification
- * msg - Message indicates what has changed.
- */
- protected void touchNotification(Notification msg) {
- if ((NotificationUtil.isFlushNewEvent(msg) || NotificationUtil.isFlushEvent(msg)) && !isMigrating()) {
- if (msg.getNotifier() == ((ContainerManagedEntity) getTarget()).getEjbClass()) {
- touchBeanAdapter(msg);
- } else if (msg.getNotifier() == ((ContainerManagedEntity) getTarget()).getPrimaryKey()) {
- touchKeyShapeAdapter(msg);
- } // if
- //if the notifier is eq the primary key
- //else ejb bean class flush
- } // if
- } // touchNotification
-
- protected void removeAdapterNotification(Notification msg) {
- if (msg.getOldValue() == this && msg.getNotifier() instanceof ContainerManagedEntity) {
- ContainerManagedEntity cmp = (ContainerManagedEntity) msg.getNotifier();
- if (cmp.getEjbClass() != null)
- cmp.getEjbClass().eAdapters().remove(this);
- if (cmp.getPrimaryKey() != null)
- cmp.getPrimaryKey().eAdapters().remove(this);
- }
- }
-
- /**
- * Adds the key shape adapter
- *
- * @param Notifier
- * notifier - The current notifier.
- */
- protected void addAttributeMaintenanceAdapter(Notifier notifier) {
- if (notifier != null && !notifier.eAdapters().contains(this))
- notifier.eAdapters().add(this);
- }
-
- /**
- * Remove the key shape adapter
- */
- protected void removeAttributeMaintenanceAdapter(Notifier notifier) {
- if (notifier != null)
- notifier.eAdapters().remove(this);
- }
-
- /**
- * The key has been touched.
- *
- * @param Notification
- * msg - The notification message.
- */
- protected void touchKeyShapeAdapter(Notification msg) {
- if (msg == null)
- return;
- ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget();
- JavaClass primaryKeyClass = cmp.getPrimaryKey();
- //Synch the two lists.
- synchCMPandKeyAttributes(cmp, primaryKeyClass);
- } // touchKeyShapeAdapter
-
- /**
- * The ejb class has been flushed.
- *
- * @param Notification
- * msg - The notification message.
- */
- protected void touchBeanAdapter(Notification msg) {
- if (msg == null)
- return;
- ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget();
- List cmpAttributes = cmp.getPersistentAttributes();
- if (cmpAttributes != null || !cmpAttributes.isEmpty()) {
- boolean modFlag = getCurrentModificationFlag();
- try {
- for (int i = 0; i < cmpAttributes.size(); i++) {
- CMPAttribute cmpAttr = (CMPAttribute) cmpAttributes.get(i);
- if (cmpAttr != null && !cmpAttr.isDerived()) {
- cmpAttr.setEType(null);
- }
- }
- } finally {
- setModificationFlag(modFlag);
- }
- }
- synchCMPandKeyAttributes(cmp, cmp.getPrimaryKey());
- }
-
- /**
- * Synchronzies the cmp and primary key class attributes.
- *
- * @param ContainerManagedEntity
- * cmp - The cmp.
- * @param JavaClass
- * primaryKeyClass
- */
- protected void synchCMPandKeyAttributes(ContainerManagedEntity cmp, JavaClass primaryKeyClass) {
- if (cmp == null || primaryKeyClass == null || cmp.getPrimKeyField() != null || primaryKeyClass.getQualifiedName().startsWith("java.lang")) //$NON-NLS-1$
- return;
-
- // make sure we flush the primary key to get latest updates if no save
- // took place
- flushPrimaryKeyClass(primaryKeyClass);
-
- List cmpAttributes = cmp.getPersistentAttributes();
- if (cmpAttributes != null || !cmpAttributes.isEmpty()) {
- foundKeys.clear();
- List keyAttributesList = cmp.getKeyAttributes();
- foundKeys.addAll(keyAttributesList);
- boolean modFlag = getCurrentModificationFlag();
- try {
- List keyFields = primaryKeyClass.getFieldsExtended();
- for (int i = 0; i < keyFields.size(); i++) {
- Field field = (Field) keyFields.get(i);
- if (field.getJavaVisibility() != JavaVisibilityKind.PUBLIC_LITERAL)
- continue;
- String fieldName = field.getName();
- if (fieldName != null) {
- CMPAttribute keyAttr = cmp.getKeyAttribute(fieldName);
- if (keyAttr == null)
- cmp.addKeyAttributeName(fieldName);
- else
- foundKeys.remove(keyAttr);
- }
- }
- if (!foundKeys.isEmpty())
- keyAttributesList.removeAll(foundKeys);
- } finally {
- setModificationFlag(modFlag);
- }
- }
- }
-
- public void setTarget(Notifier newTarget) {
- boolean isChanged = getTarget() != newTarget;
- if (newTarget == null) {
- super.setTarget(newTarget);
- cmpResource = null;
- } else if (newTarget instanceof ContainerManagedEntity) {
- //TODO - uncomment when compile errors are gone
- if (false)/* (EJBCommandCopier.isCodegenCopy(newTarget)) */
- newTarget.eAdapters().remove(this);
- else {
- Resource res = ((ContainerManagedEntity) newTarget).eResource();
- if (res != null && res.getResourceSet() != null) {
- super.setTarget(newTarget);
- if (isChanged)
- initializeTarget();
- }
- }
- }
- }
-
- /**
- *
- */
- private void initializeTarget() {
- ContainerManagedEntity cmp = (ContainerManagedEntity) getTarget();
- addAttributeMaintenanceAdapter(cmp.getEjbClass());
- if (shouldAddToPrimaryKeyClass(cmp))
- addAttributeMaintenanceAdapter(cmp.getPrimaryKey());
- }
-
- private boolean shouldAddToPrimaryKeyClass(ContainerManagedEntity cmp) {
- return cmp.getPrimKeyField() == null && cmp.getPrimaryKey() != null && !cmp.getPrimaryKey().getQualifiedName().startsWith("java.lang"); //$NON-NLS-1$
- }
-
- protected Resource getCMPResource() {
- if (cmpResource == null && getTarget() != null)
- cmpResource = ((EObject) getTarget()).eResource();
- return cmpResource;
- }
-
- protected boolean getCurrentModificationFlag() {
- return getCMPResource() != null && cmpResource.getContents() != null ? cmpResource.isModified() : false;
- }
-
- protected void setModificationFlag(boolean aBoolean) {
- if (getCMPResource() != null)
- getCMPResource().setModified(aBoolean);
- }
-
- public ContainerManagedEntity getCMP() {
- if (getTarget() instanceof ContainerManagedEntity)
- return (ContainerManagedEntity) getTarget();
- return null;
- }
-
- protected boolean flushPrimaryKeyClass(JavaClass primaryKeyClass) {
- // ensure the primary key class is flushed and reloaded to get latest
- // content
- IProject p = ProjectUtilities.getProject(primaryKeyClass);
- try {
- List natures = EMFNature.getRegisteredRuntimes(p);
- EMFNature nature = null;
- for (int i = 0; i < natures.size(); i++) {
- if (natures.get(i) instanceof EMFNature)
- nature = (EMFNature) natures.get(i);
- }
- List adapterFactories = nature.getResourceSet().getAdapterFactories();
- AdapterFactory factory = EcoreUtil.getAdapterFactory(adapterFactories, ReadAdaptor.TYPE_KEY);
- if (factory instanceof JavaJDOMAdapterFactory) {
- JavaJDOMAdapterFactory javaFactory = (JavaJDOMAdapterFactory) factory;
- javaFactory.flushReflectionNoNotification(primaryKeyClass.getQualifiedName());
- return true;
- }
- } catch (Exception e) {
- // We don't really care what the exception was, we'll just bail out
- // and return false;
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
deleted file mode 100644
index ac3a2ecd0..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
+++ /dev/null
@@ -1,722 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection;
-import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ManifestException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.UnresolveableURIException;
-import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
-import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateInputProvider;
-import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidator;
-import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorImpl;
-import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter;
-
-public class ClasspathModel implements ResourceStateInputProvider, ResourceStateValidator {
-
- protected IProject project;
- protected IVirtualComponent selectedEARComponent;
- protected EARFile earFile;
- protected IVirtualComponent component;
- protected Archive archive;
- public EARArtifactEdit earArtifactEdit;
- /** The EAR nature runtimes for all the open EAR projects in the workspace */
- protected IVirtualComponent[] availableEARComponents = null;
- protected ClassPathSelection classPathSelection;
- protected List listeners;
- protected List nonResourceFiles;
- protected ResourceStateValidator stateValidator;
- protected ArchiveManifest manifest;
- public static String NO_EAR_MESSAGE = CommonEditResourceHandler.getString("NO_EAR_JARDEP_FOR_MOD_UI_"); //$NON-NLS-1$
- protected List targetWLPRefComponentList;
- protected boolean isWLPModel = false;
- protected ClassPathSelection classPathWLPSelection;
-
- protected Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- IVirtualComponent e1 = (IVirtualComponent) o1;
- IVirtualComponent e2 = (IVirtualComponent) o2;
- return e1.getProject().getName().compareTo(e2.getProject().getName());
- }
- };
-
-
- public ClasspathModel(ArchiveManifest initialManifest) {
- super();
- manifest = initialManifest;
- }
-
- public IProject getProject() {
- return project;
- }
-
- public void setProject(IProject project) {
- this.project = project;
- initializeComponent();
- getAvailableEARComponents();
- }
-
- private void initializeComponent() {
- setComponent(ComponentCore.createComponent(getProject()));
- }
-
- protected IVirtualComponent[] refreshAvailableEARs() {
- if (component != null) {
- IProject[] earProjects = J2EEProjectUtilities.getReferencingEARProjects(getComponent().getProject());
- availableEARComponents = ComponentUtilities.getComponents(earProjects);
- if (availableEARComponents != null && availableEARComponents.length > 0) {
- Arrays.sort(availableEARComponents, comparator);
- if (selectedEARComponent == null || !Arrays.asList(availableEARComponents).contains(selectedEARComponent)) {
- if (availableEARComponents.length > 0)
- selectedEARComponent = availableEARComponents[0];
- else
- selectedEARComponent = null;
- }
- }
- }
- return availableEARComponents;
- }
-
- public IVirtualComponent[] getAvailableEARComponents() {
- if (availableEARComponents == null)
- refreshAvailableEARs();
- return availableEARComponents;
- }
-
- /**
- * Gets the selectedEARComponent.
- *
- * @return Returns a EARNatureRuntime
- */
- public IVirtualComponent getSelectedEARComponent() {
- return selectedEARComponent;
- }
-
- public void setSelectedEARComponent(IVirtualComponent component) {
- selectedEARComponent = component;
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.EAR_PROJECT_CHANGED));
- }
-
- public String getArchiveURI() {
- if (selectedEARComponent != null) {
- return getEARArtifactEdit().getModuleURI(getComponent());
- }
- return null;
- }
-
- public EARArtifactEdit getEARArtifactEdit() {
- if (earArtifactEdit == null || selectedEARComponentChanged())
- earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(selectedEARComponent);
- return earArtifactEdit;
- }
-
- private boolean selectedEARComponentChanged() {
- if (earArtifactEdit != null && !earArtifactEdit.getComponent().getName().equals(selectedEARComponent.getName())) {
- earArtifactEdit.dispose();
- earArtifactEdit = null;
- return true;
- }
- return false;
- }
-
- protected void initializeEARFile() {
- if (selectedEARComponent == null || !isDDInEAR(selectedEARComponent)) {
- earFile = null;
- return;
- }
- try {
- earFile = (EARFile) getEARArtifactEdit().asArchive(false);
- } catch (OpenFailureException ex) {
- handleOpenFailureException(ex);
- }
- }
-
- /**
- * initializeSelection method comment.
- */
- protected void initializeSelection(ArchiveManifest existing) {
- try {
- initializeEARFile();
- initializeArchive();
- if (!J2EEProjectUtilities.isEARProject(getProject())) {
- if (archive != null) {
- if (existing == null) {
- if (manifest != null)
- archive.setManifest(manifest);
- else
- // Load it now because we're going to close the EAR;
- // this might be a binary project
- archive.getManifest();
- } else
- archive.setManifest(existing);
- List archiveFiles = earFile.getArchiveFiles();
- for (int i = 0; i < archiveFiles.size(); i++) {
- Archive anArchive = (Archive) archiveFiles.get(i);
- try {
- if (anArchive.isEJBJarFile())
- ((EJBJarFile) anArchive).getDeploymentDescriptor();
- anArchive.getManifest();
- } catch (ManifestException mfEx) {
- Logger.getLogger().logError(mfEx);
- anArchive.setManifest((ArchiveManifest) new ArchiveManifestImpl());
- } catch (DeploymentDescriptorLoadException ddException) {
- Logger.getLogger().logError(ddException);
- }
- }
- }
- createClassPathSelection();
- }
- } finally {
- if (earFile != null)
- earFile.close();
- }
- }
-
- protected void initializeArchive() {
- if (!J2EEProjectUtilities.isEARProject(getProject())) {
- if (earFile == null) {
- archive = null;
- return;
- }
- String uri = getArchiveURI();
- if (uri != null) {
- try {
- archive = (Archive) earFile.getFile(uri);
- } catch (java.io.FileNotFoundException ex) {
- archive = null;
- }
- }
- } else {
- EARArtifactEdit edit = null;
- try {
- edit = EARArtifactEdit.getEARArtifactEditForRead(getProject());
- archive = edit.asArchive(true);
- } catch (OpenFailureException oe) {
- Logger.getLogger().log(oe);
- } finally {
- if (edit != null)
- edit.dispose();
- }
- }
- }
-
- protected void createClassPathSelection() {
- if (archive != null)
- classPathSelection = new ClassPathSelection(archive, earFile);
- else
- classPathSelection = null;
- }
-
- protected boolean isDDInEAR(IVirtualComponent aComponent) {
- IContainer mofRoot = aComponent.getProject();
- if (mofRoot == null || !mofRoot.exists())
- return false;
-
- return mofRoot.exists(new Path(aComponent.getRootFolder().getProjectRelativePath().toString() + "//" + J2EEConstants.APPLICATION_DD_URI)); //$NON-NLS-1$
- }
-
- protected void handleOpenFailureException(OpenFailureException ex) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex);
- }
-
- public void dispose() {
- if (earArtifactEdit != null) {
- earArtifactEdit.dispose();
- earArtifactEdit = null;
- }
- }
-
- public ClassPathSelection getClassPathSelection() {
- if (classPathSelection == null)
- initializeSelection(null);
- return classPathSelection;
- }
-
- public void resetClassPathSelection(ArchiveManifest mf) {
- initializeSelection(mf);
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.CLASS_PATH_RESET));
- }
-
- public void resetClassPathSelection() {
- resetClassPathSelection(null);
- }
-
- public void addListener(ClasspathModelListener listener) {
- if (listeners == null)
- listeners = new ArrayList();
-
- listeners.add(listener);
- }
-
- public void removeListener(ClasspathModelListener listener) {
- if (listeners != null)
- listeners.remove(listener);
- }
-
- public void fireNotification(ClasspathModelEvent evt) {
- if (listeners == null)
- return;
-
- for (int i = 0; i < listeners.size(); i++) {
- ClasspathModelListener listener = (ClasspathModelListener) listeners.get(i);
- listener.modelChanged(evt);
- }
- }
-
- /**
- * Sets the isSelected for the classpath element and sends out a notification of type
- * {@link ClasspathModelEvent#CLASS_PATH_CHANGED}
- */
- public void setSelection(ClasspathElement element, boolean selected) {
- element.setSelected(selected);
- if (!isWLPModel()) {
- updateManifestClasspath();
- } else {
- // at least fire the change event
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.CLASS_PATH_CHANGED));
- }
- }
-
- /**
- * Select or deselect all and notify
- */
- public void setAllClasspathElementsSelected(boolean selected) {
- ClassPathSelection s = getClassPathSelection();
- if (s != null) {
- s.setAllSelected(selected);
- updateManifestClasspath();
- }
- }
-
- /**
- * Select or deselect all and notify
- */
- public void setAllClasspathElementsSelected(List elements, boolean selected) {
- ClassPathSelection s = getClassPathSelection();
- if (s != null) {
- s.setAllSelected(elements, selected);
- updateManifestClasspath();
- }
- }
-
- /**
- * Gets the archive.
- *
- * @return Returns a Archive
- */
- public Archive getArchive() {
- return archive;
- }
-
- /**
- * Updates the manifest Class-Path:, and sends out a notification of type
- * {@link ClasspathModelEvent#CLASS_PATH_CHANGED}
- */
- public void updateManifestClasspath() {
- if (classPathSelection != null && classPathSelection.isModified()) {
- archive.getManifest().setClassPath(classPathSelection.toString());
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.CLASS_PATH_CHANGED));
- }
- }
-
- /**
- * Updates the manifest Main-Class:, and sends out a notification of type
- * {@link ClasspathModelEvent#MAIN_CLASS_CHANGED}
- */
- public void updateMainClass(String mainClass) {
- archive.getManifest().setMainClass(mainClass);
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.MAIN_CLASS_CHANGED));
- }
-
- /**
- * Updates the manifest Main-Class:, and sends out a notification of type
- * {@link ClasspathModelEvent#MAIN_CLASS_CHANGED}
- */
- public void updateImplVersion(String implVersion) {
- archive.getManifest().setImplemenationVersion(implVersion);
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.IMPL_VERSION_CHANGED));
- }
-
- public void fireSavedEvent() {
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.MODEL_SAVED));
- }
-
- /**
- * Sets the manifest without touching the archive, or notifying
- */
- public void primSetManifest(ArchiveManifest mf) {
- manifest = mf;
- }
-
- /**
- * Sets the manfest on the archive, updates the classpath selection, and notifies
- */
- public void setManifest(ArchiveManifest manifest) {
- archive.setManifest(manifest);
- getClassPathSelection(); // Ensure the selection is initialized.
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.MANIFEST_CHANGED));
- }
-
- public void selectEAR(int index) {
- ArchiveManifest mf = new ArchiveManifestImpl((ArchiveManifestImpl) getArchive().getManifest());
- earFile.close();
- selectedEARComponent = availableEARComponents[index];
- initializeSelection(mf);
- fireNotification(new ClasspathModelEvent(ClasspathModelEvent.EAR_PROJECT_CHANGED));
- }
-
- public void moveUp(List toMoveUp) {
- getClassPathSelection().moveUp(toMoveUp);
- updateManifestClasspath();
- }
-
- public void moveDown(List toMoveDown) {
- getClassPathSelection().moveDown(toMoveDown);
- updateManifestClasspath();
- }
-
- public void refresh() {
- ArchiveManifest mf = null;
- if (archive != null)
- mf = new ArchiveManifestImpl((ArchiveManifestImpl) getArchive().getManifest());
- refreshAvailableEARs();
- resetClassPathSelection(mf);
- }
-
-
- /**
- * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#cacheNonResourceValidateState(List)
- */
- public void cacheNonResourceValidateState(List roNonResourceFiles) {
- }
-
-
- /**
- * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#getNonResourceFiles()
- */
- public List getNonResourceFiles() {
- if (nonResourceFiles == null)
- initNonResourceFiles();
- return nonResourceFiles;
- }
-
- protected void initNonResourceFiles() {
- // Might be opened from a JAR
- if (getComponent() == null)
- return;
- nonResourceFiles = new ArrayList(3);
- nonResourceFiles.add(getComponent().getProject().getFile(ProjectUtilities.DOT_PROJECT));
- nonResourceFiles.add(getComponent().getProject().getFile(ProjectUtilities.DOT_CLASSPATH));
- IFile mf = J2EEProjectUtilities.getManifestFile(getComponent().getProject());
- if (mf != null)
- nonResourceFiles.add(mf);
- }
-
-
- /**
- * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#getNonResourceInconsistentFiles()
- */
- public List getNonResourceInconsistentFiles() {
- return null;
- }
-
- /**
- * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#isDirty()
- */
- public boolean isDirty() {
- ClassPathSelection selection = getClassPathSelection();
- if (selection == null)
- return false;
- return selection.isModified();
- }
-
-
- /**
- * Return a list of all the files that will get modified as a result of running this operation;
- * used for validateEdit
- */
- public Set getAffectedFiles() {
- Set result = new HashSet();
- IFile aFile = J2EEProjectUtilities.getManifestFile(getComponent().getProject());
- if (aFile != null && aFile.exists())
- result.add(aFile);
- result.addAll(ProjectUtilities.getFilesAffectedByClasspathChange(getComponent().getProject()));
- return result;
- }
-
- /**
- * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#getResources()
- */
- public List getResources() {
- return Collections.EMPTY_LIST;
- }
-
- public boolean selectDependencyIfNecessary(IProject referencedProject) {
- getClassPathSelection();
- if (classPathSelection == null || classPathSelection.hasDirectOrIndirectDependencyTo(referencedProject))
- return false;
-
- ClasspathElement element = classPathSelection.getClasspathElement(referencedProject);
- if (element != null) {
- setSelection(element, true);
- return true;
- }
- return false;
- }
-
- public boolean selectDependencyIfNecessary(String jarName) {
- getClassPathSelection();
- if (classPathSelection == null || classPathSelection.hasDirectOrIndirectDependencyTo(jarName))
- return false;
-
- ClasspathElement element = classPathSelection.getClasspathElement(jarName);
- if (element != null) {
- setSelection(element, true);
- return true;
- }
- return false;
- }
-
- public void removeDependency(String jarName) {
- getClassPathSelection();
- if (classPathSelection == null)
- return;
-
- ClasspathElement element = classPathSelection.getClasspathElement(jarName);
- if (element != null && element.isValid())
- setSelection(element, false);
- }
-
- public void removeDependency(IProject referencedProject) {
- getClassPathSelection();
- if (classPathSelection == null)
- return;
-
- ClasspathElement element = classPathSelection.getClasspathElement(referencedProject);
- if (element != null && element.isValid())
- setSelection(element, false);
- }
-
- public void selectFilterLevel(int filterLevel) {
- getClassPathSelection();
- if (classPathSelection != null)
- classPathSelection.selectFilterLevel(filterLevel);
- updateManifestClasspath();
- }
-
- /**
- * Gets the stateValidator.
- *
- * @return Returns a ResourceStateValidator
- */
- public ResourceStateValidator getStateValidator() {
- if (stateValidator == null)
- stateValidator = createStateValidator();
- return stateValidator;
- }
-
- /**
- * Method createStateValidator.
- *
- * @return ResourceStateValidator
- */
- private ResourceStateValidator createStateValidator() {
- return new ResourceStateValidatorImpl(this);
- }
-
- /**
- * @see ResourceStateValidator#checkActivation(ResourceStateValidatorPresenter)
- */
- public void checkActivation(ResourceStateValidatorPresenter presenter) throws CoreException {
- getStateValidator().checkActivation(presenter);
- }
-
- /**
- * @see ResourceStateValidator#lostActivation(ResourceStateValidatorPresenter)
- */
- public void lostActivation(ResourceStateValidatorPresenter presenter) throws CoreException {
- getStateValidator().lostActivation(presenter);
- }
-
- /**
- * @see ResourceStateValidator#validateState(ResourceStateValidatorPresenter)
- */
- public IStatus validateState(ResourceStateValidatorPresenter presenter) throws CoreException {
- return getStateValidator().validateState(presenter);
- }
-
- /**
- * @see ResourceStateValidator#checkSave(ResourceStateValidatorPresenter)
- */
- public boolean checkSave(ResourceStateValidatorPresenter presenter) throws CoreException {
- return getStateValidator().checkSave(presenter);
- }
-
- /**
- * @see ResourceStateValidator#checkReadOnly()
- */
- public boolean checkReadOnly() {
- return getStateValidator().checkReadOnly();
- }
-
- public IVirtualComponent getComponent() {
- return component;
- }
-
- public void setComponent(IVirtualComponent component) {
- this.component = component;
- }
-
- public ClassPathSelection getClassPathSelectionForWLPs() {
- if (classPathWLPSelection == null)
- initializeSelectionForWLPs();
- return classPathWLPSelection;
- }
-
- private void initializeSelectionForWLPs() {
- classPathWLPSelection = new ClassPathSelection();
- try {
- IClasspathContainer container = J2EEComponentClasspathUpdater.getInstance().getWebAppLibrariesContainer(component.getProject());
- IClasspathEntry[] containerEntries = null != container ? container.getClasspathEntries() : null;
- IPath libPath = new Path("/WEB-INF/lib"); //$NON-NLS-1$
-
- HashSet hs = new HashSet();
- hs.addAll(J2EEProjectUtilities.getAllJavaNonFlexProjects());
- IProject[] utilityProjects = J2EEProjectUtilities.getAllProjectsInWorkspaceOfType(J2EEProjectUtilities.UTILITY);
- hs.addAll(Arrays.asList(utilityProjects));
- for (Iterator it = hs.iterator(); it.hasNext();) {
- Object item = it.next();
- IProject utilProject = null;
- if (item instanceof IProject) {
- utilProject = (IProject) item;
- if (utilProject.getName().startsWith(".")) { //$NON-NLS-1$
- continue;
- }
- } else if (item instanceof IVirtualComponent)
- utilProject = ((IVirtualComponent) item).getProject();
- boolean existingEntry = false;
- if (containerEntries != null) {
- for (int j = 0; j < containerEntries.length; j++) {
- IClasspathEntry eachEntry = containerEntries[j];
- if (eachEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT && eachEntry.getPath().toString().equals("/" + utilProject.getName())) { //$NON-NLS-1$
- IVirtualReference ref = component.getReference(utilProject.getName());
- if (ref != null && ref.getRuntimePath().equals(libPath)) {
- existingEntry = true;
- }
- break;
- }
- }
- }
- classPathWLPSelection.createProjectElement(utilProject, existingEntry);
- classPathWLPSelection.setFilterLevel(ClassPathSelection.FILTER_NONE);
- }
-
- if (component != null && J2EEProjectUtilities.isDynamicWebProject(component.getProject())) {
- IVirtualReference[] newrefs = component.getReferences();
- for (int i = 0; i < newrefs.length; i++) {
- IVirtualReference ref = newrefs[i];
- IVirtualComponent referencedComponent = ref.getReferencedComponent();
- if (referencedComponent == null)
- continue;
- boolean isBinary = referencedComponent.isBinary();
- if (isBinary) {
- String unresolvedURI = ""; //$NON-NLS-1$
- try {
- unresolvedURI = ModuleURIUtil.getArchiveName(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent)));
- } catch (UnresolveableURIException e) {
- e.printStackTrace();
- }
- URI archiveURI = URI.createURI(unresolvedURI);
-
- boolean alreadyInList = false;
- Iterator iter = classPathWLPSelection.getClasspathElements().iterator();
- while (iter.hasNext()) {
- ClasspathElement tmpelement = (ClasspathElement) iter.next();
- if (tmpelement.getText().equals(archiveURI.lastSegment())) {
- alreadyInList = true;
- break;
- }
- }
- ClasspathElement element = null;
- if (!alreadyInList) {
- boolean inContainer = false;
- if (containerEntries != null) {
- String lastSegment = archiveURI.lastSegment();
- for (int j = 0; !inContainer && j < containerEntries.length; j++) {
- if (containerEntries[i].getPath().lastSegment().equals(lastSegment)) {
- inContainer = true;
- }
- }
- }
-
- if (inContainer) {
- element = classPathWLPSelection.createArchiveElement(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent)), referencedComponent.getName(), archiveURI.lastSegment());
- classPathWLPSelection.addClasspathElement(element, unresolvedURI);
- } else {
- element = classPathWLPSelection.createArchiveElement(URI.createURI(ModuleURIUtil.getHandleString(referencedComponent)), archiveURI.lastSegment(), null);
- classPathWLPSelection.addClasspathElement(element, unresolvedURI);
- }
- }
- }
- } // for
- }
- } catch (CoreException e) {
- } catch (Exception e) {
- Logger.getLogger().logError(e);
- }
- }
-
- public boolean isWLPModel() {
- return isWLPModel;
- }
-
- public void setWLPModel(boolean isWLPModel) {
- this.isWLPModel = isWLPModel;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelEvent.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelEvent.java
deleted file mode 100644
index 388409f28..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common;
-
-
-public class ClasspathModelEvent extends Object {
- protected int eventType;
- public static final int CLASS_PATH_CHANGED = 1;
- public static final int EAR_PROJECT_CHANGED = 2;
- public static final int MANIFEST_CHANGED = 3;
- public static final int CLASS_PATH_RESET = 4;
- public static final int MAIN_CLASS_CHANGED = 5;
- public static final int MODEL_SAVED = 6;
- public static final int IMPL_VERSION_CHANGED = 7;
-
- /**
- * Constructor for ClasspathModelEvent.
- */
- public ClasspathModelEvent(int eventType) {
- super();
- this.eventType = eventType;
- }
-
- /**
- * Gets the eventType.
- *
- * @return Returns a int
- */
- public int getEventType() {
- return eventType;
- }
-
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelListener.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelListener.java
deleted file mode 100644
index c3333f392..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModelListener.java
+++ /dev/null
@@ -1,14 +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.common;
-
-
-public interface ClasspathModelListener {
- void modelChanged(ClasspathModelEvent evt);
-} \ No newline at end of file
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
deleted file mode 100644
index 8f6cf9278..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/CreationConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.common;
-
-public interface CreationConstants {
-
- String DEFAULT_WEB_SOURCE_FOLDER = "src"; //$NON-NLS-1$
- String DEFAULT_EJB_SOURCE_FOLDER = "ejbModule";//$NON-NLS-1$
- String DEFAULT_CONNECTOR_SOURCE_FOLDER = "connectorModule";//$NON-NLS-1$
- String DEFAULT_APPCLIENT_SOURCE_FOLDER = "appClientModule";//$NON-NLS-1$
- String EJB_CLIENT_NAME ="ClientProject";//$NON-NLS-1$
- String CLIENT_JAR_URI="ClientJARURI";//$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EECommonMessages.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EECommonMessages.java
deleted file mode 100644
index afeeca861..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EECommonMessages.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 3, 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.common;
-
-import org.eclipse.osgi.util.NLS;
-
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class J2EECommonMessages extends NLS {
- private static final String BUNDLE_NAME = "j2ee_common";//$NON-NLS-1$
-
- private J2EECommonMessages() {
- // Do not instantiate
- }
-
- public static String ERR_SECURITY_ROLE_EMPTY;
- public static String ERR_SECURITY_ROLE_EXIST;
- public static String ERR_JAVA_CLASS_NAME_EMPTY;
- public static String ERR_JAVA_CLASS_NAME_EXIST;
- public static String ERR_JAVA_CLASS_FILE_NAME_EXIST;
- public static String ERR_JAVA_CLASS_FOLDER_NAME_EMPTY;
- public static String ERR_JAVA_CLASS_FOLDER_PROJECT_NOT_OPEN;
- public static String ERR_JAVA_CLASS_NOT_JAVA_PROJECT;
- public static String ERR_JAVA_CLASS_FOLDER_STATIC_PROJECT;
- public static String ERR_JAVA_CLASS_FOLDER_NOT_SOURCE;
- public static String ERR_JAVA_CLASS_NAME_QUALIFIED;
- public static String ERR_JAVA_CLASS_NAME_INVALID;
- public static String ERR_JAVA_CLASS_NAME_WARNING;
- public static String ERR_JAVA_CLASS_SUPERCLASS_NOT_EXIST;
- public static String ERR_JAVA_CLASS_SUPERCLASS_FINAL;
- public static String ERR_JAVA_PACAKGE_NAME_INVALID;
- public static String ERR_JAVA_PACKAGE_NAME_WARNING;
- public static String ERR_BOTH_FINAL_AND_ABSTRACT;
- public static String WebServiceClientGenerator_UI_0;
- public static String ERR_SECURITY_ROLE_LIST_EMPTY;
-
- public static String ERR_JAVA_CLASS_FOLDER_NOT_EXIST;
-
- public static String ERR_EMPTY_MODULE_NAME;
- public static String ERR_EMPTY_PROJECT_NAME;
- public static String ERR_PROJECT_NAME_EXISTS;
- public static String ERR_VERSION_NOT_SUPPORTED;
- public static String ERR_NOT_SUPPORTED;
- public static String ERR_JAVA_CLASS_FOLDER_NOT_ABSOLUTE;
-
- public static String J2EE_MODULE_CLASSPATH_CONTAINER_NAME;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, J2EECommonMessages.class);
- }
-
- public static String getResourceString(String key, Object[] args) {
- return NLS.bind(key, args);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EEVersionUtil.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EEVersionUtil.java
deleted file mode 100644
index f51d2e51f..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/J2EEVersionUtil.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 Mar 21, 2005
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.jst.j2ee.internal.common;
-
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-
-/**
- * @author nagrawal
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class J2EEVersionUtil {
-
- public static String getServletTextVersion(int aVersion) {
- switch (aVersion) {
- case J2EEVersionConstants.SERVLET_2_2:
- return J2EEVersionConstants.VERSION_2_2_TEXT;
-
- case J2EEVersionConstants.SERVLET_2_3:
- return J2EEVersionConstants.VERSION_2_3_TEXT;
-
- case J2EEVersionConstants.SERVLET_2_4:
- return J2EEVersionConstants.VERSION_2_4_TEXT;
- }
- return ""; //$NON-NLS-1$
-
- }
-
- public static String getEJBTextVersion(int aVersion) {
-
- switch (aVersion) {
- case J2EEVersionConstants.EJB_1_0_ID:
- return J2EEVersionConstants.VERSION_1_0_TEXT;
-
- case J2EEVersionConstants.EJB_1_1_ID:
- return J2EEVersionConstants.VERSION_1_1_TEXT;
-
- case J2EEVersionConstants.EJB_2_0_ID:
- return J2EEVersionConstants.VERSION_2_0_TEXT;
-
- case J2EEVersionConstants.EJB_2_1_ID:
- return J2EEVersionConstants.VERSION_2_1_TEXT;
- }
- return ""; //$NON-NLS-1$
- }
-
- public static String getJCATextVersion(int aVersion) {
- switch (aVersion) {
- case J2EEVersionConstants.JCA_1_0_ID:
- return J2EEVersionConstants.VERSION_1_0_TEXT;
-
- case J2EEVersionConstants.JCA_1_5_ID:
- return J2EEVersionConstants.VERSION_1_5_TEXT;
-
- }
- return ""; //$NON-NLS-1$
- }
-
- public static String getJ2EETextVersion(int aVersion) {
- switch (aVersion) {
- case J2EEVersionConstants.J2EE_1_2_ID:
- return J2EEVersionConstants.VERSION_1_2_TEXT;
-
- case J2EEVersionConstants.J2EE_1_3_ID:
- return J2EEVersionConstants.VERSION_1_3_TEXT;
-
- case J2EEVersionConstants.J2EE_1_4_ID:
- return J2EEVersionConstants.VERSION_1_4_TEXT;
-
- }
- return "";//$NON-NLS-1$
- }
-
- public static int convertAppClientVersionStringToJ2EEVersionID(String version) {
- if (version.equals(J2EEVersionConstants.VERSION_1_2_TEXT))
- return J2EEVersionConstants.J2EE_1_2_ID;
- if (version.equals(J2EEVersionConstants.VERSION_1_3_TEXT))
- return J2EEVersionConstants.J2EE_1_3_ID;
- if (version.equals(J2EEVersionConstants.VERSION_1_4_TEXT))
- return J2EEVersionConstants.J2EE_1_4_ID;
- // default
- return J2EEVersionConstants.J2EE_1_4_ID;
- }
-
- public static int convertEJBVersionStringToJ2EEVersionID(String version) {
- if (version.equals(J2EEVersionConstants.VERSION_1_1_TEXT))
- return J2EEVersionConstants.J2EE_1_2_ID;
- if (version.equals(J2EEVersionConstants.VERSION_2_0_TEXT))
- return J2EEVersionConstants.J2EE_1_3_ID;
- if (version.equals(J2EEVersionConstants.VERSION_2_1_TEXT))
- return J2EEVersionConstants.J2EE_1_4_ID;
- // default
- return J2EEVersionConstants.J2EE_1_4_ID;
- }
-
- public static int convertWebVersionStringToJ2EEVersionID(String version) {
- if (version.equals(J2EEVersionConstants.VERSION_2_2_TEXT))
- return J2EEVersionConstants.J2EE_1_2_ID;
- if (version.equals(J2EEVersionConstants.VERSION_2_3_TEXT))
- return J2EEVersionConstants.J2EE_1_3_ID;
- if (version.equals(J2EEVersionConstants.VERSION_2_4_TEXT))
- return J2EEVersionConstants.J2EE_1_4_ID;
- // default
- return J2EEVersionConstants.J2EE_1_4_ID;
- }
-
- public static int convertConnectorVersionStringToJ2EEVersionID(String version) {
- if (version.equals(J2EEVersionConstants.VERSION_1_0_TEXT))
- return J2EEVersionConstants.J2EE_1_3_ID;
- if (version.equals(J2EEVersionConstants.VERSION_1_5_TEXT))
- return J2EEVersionConstants.J2EE_1_4_ID;
- // default
- return J2EEVersionConstants.J2EE_1_4_ID;
- }
-
- public static int convertJ2EEVersionIDToEJBVersionID(int j2eeVersionId) {
- switch (j2eeVersionId) {
- case J2EEVersionConstants.J2EE_1_2_ID:
- return J2EEVersionConstants.EJB_1_1_ID;
- case J2EEVersionConstants.J2EE_1_3_ID:
- return J2EEVersionConstants.EJB_2_0_ID;
- case J2EEVersionConstants.J2EE_1_4_ID:
- return J2EEVersionConstants.EJB_2_1_ID;
- }
- // default
- return J2EEVersionConstants.EJB_2_1_ID;
- }
-
- public static int convertJ2EEVersionIDToWebVersionID(int j2eeVersionId) {
- switch (j2eeVersionId) {
- case J2EEVersionConstants.J2EE_1_2_ID:
- return J2EEVersionConstants.WEB_2_2_ID;
- case J2EEVersionConstants.J2EE_1_3_ID:
- return J2EEVersionConstants.WEB_2_3_ID;
- case J2EEVersionConstants.J2EE_1_4_ID:
- return J2EEVersionConstants.WEB_2_4_ID;
- }
- // default
- return J2EEVersionConstants.WEB_2_4_ID;
- }
-
- public static int convertJ2EEVersionIDToConnectorVersionID(int j2eeVersionId) {
- switch (j2eeVersionId) {
- case J2EEVersionConstants.J2EE_1_3_ID:
- return J2EEVersionConstants.JCA_1_0_ID;
- case J2EEVersionConstants.J2EE_1_4_ID:
- return J2EEVersionConstants.JCA_1_5_ID;
- }
- // default
- return J2EEVersionConstants.JCA_1_5_ID;
- }
-
- public static int convertVersionStringToInt(IVirtualComponent comp) {
- String version = J2EEProjectUtilities.getJ2EEProjectVersion(comp.getProject());
- if (J2EEProjectUtilities.isDynamicWebProject(comp.getProject()))
- return convertWebVersionStringToJ2EEVersionID(version);
- if (J2EEProjectUtilities.isEJBProject(comp.getProject()))
- return convertEJBVersionStringToJ2EEVersionID(version);
- if (J2EEProjectUtilities.isEARProject(comp.getProject()))
- return convertVersionStringToInt(version);
- if (J2EEProjectUtilities.isJCAProject(comp.getProject()))
- return convertConnectorVersionStringToJ2EEVersionID(version);
- if (J2EEProjectUtilities.isApplicationClientProject(comp.getProject()))
- return convertAppClientVersionStringToJ2EEVersionID(version);
- return 0;
- }
-
- public static int convertVersionStringToInt(String version) {
- int nVersion = 0;
-
- if( version.endsWith("")){ //$NON-NLS-1$
- nVersion = 0;
- }
- if (version.equals(J2EEVersionConstants.VERSION_1_0_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_0;
-
- if (version.equals(J2EEVersionConstants.VERSION_1_1_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_1;
-
- if (version.equals(J2EEVersionConstants.VERSION_1_2_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_2;
-
- if (version.equals(J2EEVersionConstants.VERSION_1_3_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_3;
-
- if (version.equals(J2EEVersionConstants.VERSION_1_4_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_4;
-
- if (version.equals(J2EEVersionConstants.VERSION_1_5_TEXT))
- nVersion = J2EEVersionConstants.VERSION_1_5;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_0_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_0;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_1_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_1;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_2_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_2;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_3_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_3;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_4_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_4;
-
- if (version.equals(J2EEVersionConstants.VERSION_2_5_TEXT))
- nVersion = J2EEVersionConstants.VERSION_2_5;
-
- return nVersion;
- }
- public static String convertVersionIntToString(int version) {
- String nVersion = null;
-
- if (version == J2EEVersionConstants.VERSION_1_0)
- nVersion = J2EEVersionConstants.VERSION_1_0_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_1_1)
- nVersion = J2EEVersionConstants.VERSION_1_1_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_1_2)
- nVersion = J2EEVersionConstants.VERSION_1_2_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_1_3)
- nVersion = J2EEVersionConstants.VERSION_1_3_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_1_4)
- nVersion = J2EEVersionConstants.VERSION_1_4_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_1_5)
- nVersion = J2EEVersionConstants.VERSION_1_5_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_0)
- nVersion = J2EEVersionConstants.VERSION_2_0_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_1)
- nVersion = J2EEVersionConstants.VERSION_2_1_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_2)
- nVersion = J2EEVersionConstants.VERSION_2_2_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_3)
- nVersion = J2EEVersionConstants.VERSION_2_3_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_4)
- nVersion = J2EEVersionConstants.VERSION_2_4_TEXT;
-
- if (version == J2EEVersionConstants.VERSION_2_5)
- nVersion = J2EEVersionConstants.VERSION_2_5_TEXT;
-
- return nVersion;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/UpdateProjectClasspath.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/UpdateProjectClasspath.java
deleted file mode 100644
index ccb94f067..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/UpdateProjectClasspath.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-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.jdt.internal.core.ClasspathEntry;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15;
-
-
-/**
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class UpdateProjectClasspath {
-
-
- public UpdateProjectClasspath(String sourceFolder, String componentName, IProject jProject){
- addSrcFolderToProject(sourceFolder, componentName, jProject);
- }
-
- private IClasspathEntry[] getClasspathEntries(String sourceFolder, String componentName,
- IProject jProject) {
-
- ArrayList list = new ArrayList();
- list.add(JavaCore.newSourceEntry(jProject.getFullPath().append(sourceFolder)));
-
- IClasspathEntry[] classpath = new IClasspathEntry[list.size()];
-
-
- IPath newOutputPath = null;
- for (int i = 0; i < classpath.length; i++) {
- classpath[i] = (IClasspathEntry) list.get(i);
- newOutputPath = Path.fromOSString(Path.SEPARATOR +jProject.getName() + "/bin/");
- ((ClasspathEntry)classpath[i]).specificOutputLocation = newOutputPath;
- }
- return classpath;
- }
-
- private void addSrcFolderToProject(String sourceFolder,String componentName,
- IProject jProject) {
-
- IJavaProject javaProject = JavaCore.create( jProject );
- try {
-
- IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
- List oldEntriesList,classpathList;
- IClasspathEntry[] newEntries = getClasspathEntries(sourceFolder, componentName,
- jProject);
- /**
- * Warning clean-up 12/05/2005
- */
- //int oldSize = oldEntries.length;
- //int newSize = newEntries.length;
-
- classpathList = new ArrayList();
- oldEntriesList = Arrays.asList(oldEntries);
- classpathList.addAll(oldEntriesList);
- for( int j=0; j< newEntries.length; j++){
- if(!oldEntriesList.contains(newEntries[j])) {
- classpathList.add(newEntries[j]);
- }
- }
- IClasspathEntry[] classpathEntries = (IClasspathEntry[]) classpathList.toArray(new IClasspathEntry[classpathList.size()]);
- javaProject.setRawClasspath(classpathEntries, null);
- }
- catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- private static IClasspathEntry[] getProjectDependency(IProject clientProj){
- IClasspathEntry projectEntry = JavaCore.newProjectEntry(clientProj.getFullPath(), true);
- return new IClasspathEntry[]{projectEntry};
- }
-
- private static boolean entryToChange(final IClasspathEntry entry, final IClasspathEntry[] entriesToChange) {
- for (int i = 0; i < entriesToChange.length; i++) {
- if (entriesToChange[i].equals(entry)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- * TODO this probably can be deleted
- * @param projectName
- * @param referencedProjectName
- * @param add
- */
- public static void updateProjectDependency(final String projectName, final String referencedProjectName, final boolean add) {
-
- IProject proj = ProjectUtilities.getProject( projectName );
- IProject refproj = ProjectUtilities.getProject( referencedProjectName );
- updateProjectDependency( proj, refproj, add );
-
- }
- /**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- * TODO this probably can be deleted
- * @param ejbProj
- * @param clientProj
- * @param add
- */
- public static void updateProjectDependency(final IProject ejbProj, final IProject clientProj, final boolean add) {
- final IJavaProject javaProject = JavaCore.create(ejbProj);
- try {
- final IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
- final IClasspathEntry[] entriesToChange = getProjectDependency(clientProj);
- final List classpathEntries = new ArrayList();
- for (int i = 0; i < oldEntries.length; i++) {
- if (!entryToChange(oldEntries[i], entriesToChange)) {
- classpathEntries.add(oldEntries[i]);
- }
- }
- if (add) {
- for (int j = 0; j < entriesToChange.length; j++) {
- boolean containsEntry = false;
- if (entriesToChange[j].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- for (int k = 0; k < classpathEntries.size(); k++) {
- String existingEntry = ((IClasspathEntry) classpathEntries.get(k)).getPath().segment(0);
- String newEntry = entriesToChange[j].getPath().segment(0);
- if (existingEntry.equals(newEntry)) {
- containsEntry = true;
- break;
- }
- }
- }
- if (!containsEntry)
- classpathEntries.add(entriesToChange[j]);
- }
- }
- javaProject.setRawClasspath((IClasspathEntry[]) classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), null);
- } catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/VirtualArchiveComponentAdapterFactory.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/VirtualArchiveComponentAdapterFactory.java
deleted file mode 100644
index a7b6a331e..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/VirtualArchiveComponentAdapterFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.common;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-
-public class VirtualArchiveComponentAdapterFactory implements IAdapterFactory {
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adapterType == VirtualArchiveComponent.ADAPTER_TYPE ) {
- VirtualArchiveComponent component = (VirtualArchiveComponent) adaptableObject;
- IPath path = J2EEProjectUtilities.getResolvedPathForArchiveComponent(component.getName());
- return path;
- }
- return null;
- }
-
-
- public Class[] getAdapterList() {
- return new Class[]{VirtualArchiveComponent.class};
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java
deleted file mode 100644
index 65f80357e..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.classpath;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathContainer;
-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.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-/**
- * This classpath container is based on the Component references; not the manifest entries. Other
- * mechanisms are in place to ensure that the component references are updated when the manifest is
- * updated, and also to make sure the manifest is updated when the component references are updated.
- *
- */
-public class J2EEComponentClasspathContainer implements IClasspathContainer {
-
- public static final String CONTAINER_ID = "org.eclipse.jst.j2ee.internal.module.container"; //$NON-NLS-1$
- public static final IPath CONTAINER_PATH = new Path(CONTAINER_ID);
-
- private IPath containerPath;
- private IJavaProject javaProject;
- private IClasspathEntry[] entries = new IClasspathEntry[0];
-
- private class LastUpdate {
- private int refCount = 0;
- private boolean[] isBinary = new boolean[refCount];
- private IPath[] paths = new IPath[refCount];
- }
-
- private LastUpdate lastUpdate = new LastUpdate();
-
- public J2EEComponentClasspathContainer(IPath path, IJavaProject javaProject) {
- this.containerPath = path;
- this.javaProject = javaProject;
- update();
- }
-
- protected void update() {
- IVirtualComponent component = ComponentCore.createComponent(javaProject.getProject());
- if (component == null) {
- return;
- }
- IVirtualReference[] refs = component.getReferences();
- IVirtualComponent comp = null;
-
- // avoid updating the container if references haven't changed
- if (refs.length == lastUpdate.refCount) {
- boolean refsChanged = false;
- for (int i = 0; i < lastUpdate.refCount && !refsChanged; i++) {
- comp = refs[i].getReferencedComponent();
- if (comp.isBinary() != lastUpdate.isBinary[i]) {
- refsChanged = true;
- } else {
- IPath path = null;
- if (comp.isBinary()) {
- VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) comp;
- java.io.File diskFile = archiveComp.getUnderlyingDiskFile();
- if (diskFile.exists())
- path = new Path(diskFile.getAbsolutePath());
- else {
- IFile iFile = archiveComp.getUnderlyingWorkbenchFile();
- path = iFile.getFullPath();
- }
- } else {
- path = comp.getProject().getFullPath();
- }
- if (!path.equals(lastUpdate.paths[i])) {
- refsChanged = true;
- }
- }
- }
- if (!refsChanged) {
- return;
- }
- }
-
- lastUpdate.refCount = refs.length;
- lastUpdate.isBinary = new boolean[lastUpdate.refCount];
- lastUpdate.paths = new IPath[lastUpdate.refCount];
-
- boolean isWeb = J2EEProjectUtilities.isDynamicWebProject(component.getProject());
- boolean shouldAdd = true;
-
- List entriesList = new ArrayList();
-
- try {
- for (int i = 0; i < refs.length; i++) {
- comp = refs[i].getReferencedComponent();
- lastUpdate.isBinary[i] = comp.isBinary();
- shouldAdd = !(isWeb && refs[i].getRuntimePath().equals(J2EEComponentReferenceUpdater.WEBLIB));
- if (!shouldAdd) {
- continue;
- }
- if (comp.isBinary()) {
- VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) comp;
- java.io.File diskFile = archiveComp.getUnderlyingDiskFile();
- if (diskFile.exists()) {
- lastUpdate.paths[i] = new Path(diskFile.getAbsolutePath());
- entriesList.add(JavaCore.newLibraryEntry(lastUpdate.paths[i], null, null));
- } else {
- IFile iFile = archiveComp.getUnderlyingWorkbenchFile();
- lastUpdate.paths[i] = iFile.getFullPath();
- entriesList.add(JavaCore.newLibraryEntry(lastUpdate.paths[i], null, null));
- }
- } else {
- IProject project = comp.getProject();
- lastUpdate.paths[i] = project.getFullPath();
- entriesList.add(JavaCore.newProjectEntry(lastUpdate.paths[i], false));
- }
- }
- } finally {
- entries = new IClasspathEntry[entriesList.size()];
- for (int i = 0; i < entries.length; i++) {
- entries[i] = (IClasspathEntry) entriesList.get(i);
- }
- }
- }
-
- public void install() {
- final IJavaProject[] projects = new IJavaProject[]{javaProject};
- final IClasspathContainer[] conts = new IClasspathContainer[]{this};
-
- try {
- JavaCore.setClasspathContainer(containerPath, projects, conts, null);
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- }
-
- public void refresh() {
- update();
- install();
- }
-
- public IClasspathEntry[] getClasspathEntries() {
- return entries;
- }
-
- public String getDescription() {
- return J2EECommonMessages.J2EE_MODULE_CLASSPATH_CONTAINER_NAME;
- }
-
- public int getKind() {
- return K_APPLICATION;
- }
-
- public IPath getPath() {
- return containerPath;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathInitializer.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathInitializer.java
deleted file mode 100644
index f2abd54e2..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathInitializer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.classpath;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.IJavaProject;
-
-public class J2EEComponentClasspathInitializer extends ClasspathContainerInitializer {
-
- public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException {
- J2EEComponentClasspathUpdater.init();
- (new J2EEComponentClasspathContainer(containerPath, javaProject)).install();
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java
deleted file mode 100644
index c84bff9d8..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.classpath;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jdt.core.IClasspathContainer;
-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.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.GlobalComponentChangeListener;
-import org.eclipse.wst.common.componentcore.GlobalComponentChangeNotifier;
-import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage;
-import org.eclipse.wst.common.componentcore.internal.ReferencedComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent;
-
-public class J2EEComponentClasspathUpdater extends AdapterImpl implements GlobalComponentChangeListener {
-
- private static J2EEComponentClasspathUpdater instance = null;
- private int pauseCount = 0;
- private Set updatesRequired = new HashSet();
- private IPath WEB_APP_LIBS_PATH = new Path("org.eclipse.jst.j2ee.internal.web.container");
-
- public static J2EEComponentClasspathUpdater getInstance() {
- if (instance == null) {
- init();
- }
- return instance;
- }
-
- public static void init() {
- if (instance == null) {
- instance = new J2EEComponentClasspathUpdater();
- GlobalComponentChangeNotifier.getInstance().addListener(instance);
- }
- }
-
- /**
- * Pauses updates; any caller of this method must ensure through a try/finally block that
- * resumeUpdates is subsequently called.
- */
- public void pauseUpdates() {
- synchronized (this) {
- pauseCount++;
- }
- }
-
- public void resumeUpdates() {
- Object[] projects = null;
- synchronized (this) {
- if (pauseCount > 0) {
- pauseCount--;
- }
- if (pauseCount > 0) {
- return;
- }
- projects = updatesRequired.toArray();
- updatesRequired.clear();
- }
- for (int i = 0; i < projects.length; i++) {
- updateModule((IProject) projects[i]);
- }
- }
-
- private final String MODULE_URI = "module:/resource";
-
- public void notifyChanged(Notification notification) {
- if (notification.getFeature() == ComponentcorePackage.eINSTANCE.getWorkbenchComponent_ReferencedComponents()) {
- switch (notification.getEventType()) {
- case Notification.REMOVE :
- ReferencedComponent oldRef = (ReferencedComponent) notification.getOldValue();
- URI handle = oldRef.getHandle();
- if (handle.toString().startsWith(MODULE_URI)) {
- String projectName = handle.segment(2);
- IProject project = ProjectUtilities.getProject(projectName);
- queueUpdate(project);
- }
- }
- }
- }
-
- public void editModelChanged(EditModelEvent anEvent) {
- switch (anEvent.getEventCode()) {
- case EditModelEvent.SAVE :
- case EditModelEvent.LOADED_RESOURCE :
- IProject project = anEvent.getEditModel().getProject();
- queueUpdate(project);
- break;
- }
- }
-
- public void queueUpdate(IProject project) {
- if (J2EEProjectUtilities.isEARProject(project)) {
- // TODO streamline the ear section so it only changes if the refs have changed
- queueUpdateEAR(project);
- } else if (J2EEProjectUtilities.isApplicationClientProject(project) || J2EEProjectUtilities.isEJBProject(project) || J2EEProjectUtilities.isDynamicWebProject(project) || J2EEProjectUtilities.isJCAProject(project) || J2EEProjectUtilities.isUtilityProject(project)) {
- queueUpdateModule(project);
- }
- }
-
- public void queueUpdateModule(IProject project) {
- synchronized (this) {
- if (pauseCount > 0) {
- if (!updatesRequired.contains(project)) {
- updatesRequired.add(project);
- }
- return;
- }
- }
- updateModule(project);
-
- }
-
- public void queueUpdateEAR(IProject earProject) {
- EARArtifactEdit edit = null;
- try {
- edit = EARArtifactEdit.getEARArtifactEditForRead(earProject);
- IVirtualReference[] refs = edit.getComponentReferences();
- IVirtualComponent comp = null;
- for (int i = 0; i < refs.length; i++) {
- comp = refs[i].getReferencedComponent();
- if (!comp.isBinary()) {
- queueUpdateModule(comp.getProject());
- }
- }
- } finally {
- if (edit != null) {
- edit.dispose();
- }
- }
- }
-
- private void updateModule(IProject project) {
- IClasspathContainer container = getWebAppLibrariesContainer(project);
- if (container != null) {
- ((FlexibleProjectContainer) container).refresh();
- }
- IProject[] earProjects = J2EEProjectUtilities.getReferencingEARProjects(project);
- if (earProjects.length == 0) {
- removeContainerFromModuleIfNecessary(project);
- return;
- }
- container = addContainerToModuleIfNecessary(project);
- if (container != null) {
- ((J2EEComponentClasspathContainer) container).update();
- }
- }
-
- public IClasspathContainer getWebAppLibrariesContainer(IProject webProject) {
- IJavaProject jproj = JavaCore.create(webProject);
- IClasspathContainer container = null;
- try {
- container = JavaCore.getClasspathContainer(WEB_APP_LIBS_PATH, jproj);
- } catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- return container;
- }
-
- private IClasspathContainer addContainerToModuleIfNecessary(IProject moduleProject) {
- IJavaProject jproj = JavaCore.create(moduleProject);
- IClasspathEntry entry = getJ2eeComponentClasspathEntry(jproj);
- if (entry == null) {
- try {
- entry = JavaCore.newContainerEntry(new Path(J2EEComponentClasspathContainer.CONTAINER_ID));
- addToClasspath(jproj, entry);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- }
- IClasspathContainer container = null;
- try {
- container = JavaCore.getClasspathContainer(entry.getPath(), jproj);
- } catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- return container;
- }
-
- private void removeContainerFromModuleIfNecessary(IProject moduleProject) {
- IJavaProject jproj = JavaCore.create(moduleProject);
- IClasspathEntry entry = getJ2eeComponentClasspathEntry(jproj);
- if (entry != null) {
- try {
- removeFromClasspath(jproj, entry);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- }
- }
-
- private void addToClasspath(final IJavaProject jproj, final IClasspathEntry entry) throws CoreException {
- final IClasspathEntry[] current = jproj.getRawClasspath();
- final IClasspathEntry[] updated = new IClasspathEntry[current.length + 1];
- System.arraycopy(current, 0, updated, 0, current.length);
- updated[current.length] = entry;
- jproj.setRawClasspath(updated, null);
- }
-
- private void removeFromClasspath(final IJavaProject jproj, final IClasspathEntry entry) throws CoreException {
- final IClasspathEntry[] current = jproj.getRawClasspath();
- final IClasspathEntry[] updated = new IClasspathEntry[current.length - 1];
- boolean removed = false;
- for (int i = 0; i < current.length; i++) {
- if (!removed) {
- if (current[i] == entry) {
- removed = true;
- } else {
- updated[i] = current[i];
- }
- } else {
- updated[i - 1] = current[i];
- }
- }
- jproj.setRawClasspath(updated, null);
- }
-
-
- private IClasspathEntry getJ2eeComponentClasspathEntry(IJavaProject jproj) {
- try {
- IClasspathEntry[] cpes;
- cpes = jproj.getRawClasspath();
- for (int j = 0; j < cpes.length; j++) {
- final IClasspathEntry cpe = cpes[j];
- if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
- if (cpe.getPath().equals(J2EEComponentClasspathContainer.CONTAINER_PATH)) {
- return cpe; // entry found
- }
- }
- }
- } catch (JavaModelException e) {
- Logger.getLogger().logError(e);
- }
- // entry not found
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentReferenceUpdater.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentReferenceUpdater.java
deleted file mode 100644
index 0dd96d38b..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentReferenceUpdater.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.classpath;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-
-public class J2EEComponentReferenceUpdater {
-
- public static IPath WEBLIB = new Path("/WEB-INF/lib"); //$NON-NLS-1$
-
- /**
- * Sets the references for modules in the list to only those defined in the MANIFEST.MF which
- * can be resolved through the specified ear. Any existing references will be removed, except in
- * the case of web apps; existing references mapping to WEB-INF/LIBS will be preserved.
- *
- * @param earProject
- * @param moduleComponents
- */
- public static void updateReferences(IProject earProject) {
- EARArtifactEdit earEdit = null;
- try {
- J2EEComponentClasspathUpdater.getInstance().pauseUpdates();
- J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(earProject);
- earEdit = EARArtifactEdit.getEARArtifactEditForRead(earProject);
- if (earEdit != null) {
- IVirtualReference[] earRefs = earEdit.getComponentReferences();
- for (int i = 0; i < earRefs.length; i++) {
- IVirtualComponent moduleComponent = earRefs[i].getReferencedComponent();
- if (moduleComponent.isBinary()) {
- continue;
- }
- String[] manifestClasspath = null;
- IVirtualFile vManifest = moduleComponent.getRootFolder().getFile(J2EEConstants.MANIFEST_URI);
- if (vManifest.exists()) {
- IFile manifestFile = vManifest.getUnderlyingFile();
- try {
- ArchiveManifest manifest = new ArchiveManifestImpl(manifestFile.getContents());
- manifestClasspath = manifest.getClassPathTokenized();
- } catch (IOException e) {
- Logger.getLogger().logError(e);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- }
-
- if (manifestClasspath == null) {
- manifestClasspath = new String[0];
- }
-
- // list rather than array incase manifest has bogus entries
- List compRefs = new ArrayList();
- for (int j = 0; j < manifestClasspath.length; j++) {
- IVirtualComponent comp = earEdit.getModuleByManifestURI(manifestClasspath[j]);
- if (comp != null) {
- compRefs.add(ComponentCore.createReference(moduleComponent, comp));
- }
- }
- if (J2EEProjectUtilities.isDynamicWebProject(moduleComponent.getProject())) {
- IVirtualReference[] moduleRefs = moduleComponent.getReferences();
- for (int j = 0; j < moduleRefs.length; j++) {
- if (moduleRefs[j].getRuntimePath().equals(WEBLIB)) {
- compRefs.add(moduleRefs[j]);
- }
- }
- }
-
- IVirtualReference[] compRefsArray = new IVirtualReference[compRefs.size()];
- for (int j = 0; j < compRefsArray.length; j++) {
- compRefsArray[j] = (IVirtualReference) compRefs.get(j);
- }
-
- moduleComponent.setReferences(compRefsArray);
- }
- }
- } catch (Exception e) {
- Logger.getLogger().logError(e);
- } finally {
- J2EEComponentClasspathUpdater.getInstance().resumeUpdates();
- if (earEdit != null)
- earEdit.dispose();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/INewJavaClassDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/INewJavaClassDataModelProperties.java
deleted file mode 100644
index 1d23d6cd7..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/INewJavaClassDataModelProperties.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.common.operations;
-
-import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties;
-
-public interface INewJavaClassDataModelProperties extends IArtifactEditOperationDataModelProperties {
-
- /**
- * Required, String property used to set the unqualified java class name for the new java class.
- */
- public static final String CLASS_NAME = "NewJavaClassDataModel.CLASS_NAME"; //$NON-NLS-1$
-
- /**
- * Optional, String property used to set the source folder location for the new java class. The first
- * source folder found in the project will be used if one is not specified.
- */
- public static final String SOURCE_FOLDER = "NewJavaClassDataModel.SOURCE_FOLDER"; //$NON-NLS-1$
-
- /**
- * Optional, String property used to to set the java package for the new java class. The default
- * package is used if one is not specified.
- */
- public static final String JAVA_PACKAGE = "NewJavaClassDataModel.JAVA_PACKAGE"; //$NON-NLS-1$
-
- /**
- * Optional, String property used to set the qualified java class name of the superclass of the
- * new java class.
- */
- public static final String SUPERCLASS = "NewJavaClassDataModel.SUPERCLASS"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set the visibility of the new java class. This is true
- * by default.
- */
- public static final String MODIFIER_PUBLIC = "NewJavaClassDataModel.MODIFIER_PUBLIC"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set whether the new java class is abstract. This is false
- * by default.
- */
- public static final String MODIFIER_ABSTRACT = "NewJavaClassDataModel.MODIFIER_ABSTRACT"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set whether the new java class is declared final. This is false
- * by default.
- */
- public static final String MODIFIER_FINAL = "NewJavaClassDataModel.MODIFIER_FINAL"; //$NON-NLS-1$
-
- /**
- * Optional, List property of all the qualified names of interfaces the new java class should implement.
- */
- public static final String INTERFACES = "NewJavaClassDataModel.INTERFACES"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set whether the new java class should generate a main method. This
- * is false by default.
- */
- public static final String MAIN_METHOD = "NewJavaClassDataModel.MAIN_METHOD"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set whether or not the constructor from the superclass should be
- * generated in the new java class. The default value is true.
- */
- public static final String CONSTRUCTOR = "NewJavaClassDataModel.CONSTRUCTOR"; //$NON-NLS-1$
-
- /**
- * Optional, boolean property used to set whether the new java class should add method stubs for unimplemented
- * methods defined in the interfaces of the interface list. This is true by default.
- */
- public static final String ABSTRACT_METHODS = "NewJavaClassDataModel.ABSTRACT_METHODS"; //$NON-NLS-1$
-
- /**
- * THIS PROPERTY SHOULD NOT BE SET, it's value is meant to be determined as a helper method
- */
- public static final String JAVA_PACKAGE_FRAGMENT_ROOT = "NewJavaClassDataModel.JAVA_PACKAGE_FRAGMENT_ROOT"; //$NON-NLS-1$
-
- /**
- * THIS PROPERTY SHOULD NOT BE SET, it's value is meant to be determined as a helper method
- */
- public static final String JAVA_SOURCE_FOLDER = "NewJavaClassDataModel.JAVA_SOURCE_FOLDER"; //$NON-NLS-1$
-
- /**
- * THIS PROPERTY SHOULD NOT BE SET, it's value is meant to be determined as a helper method
- */
- public static final String PROJECT = "NewJavaClassDataModel.PROJECT"; //$NON-NLS-1$
-
- /**
- * THIS PROPERTY SHOULD NOT BE SET, it's value is meant to be determined as a helper method
- */
- public static final String QUALIFIED_CLASS_NAME = "NewJavaClassDataModel.QUALIFIED_CLASS_NAME"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/J2EEModifierHelperCreator.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/J2EEModifierHelperCreator.java
deleted file mode 100644
index 16fa74fb1..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/J2EEModifierHelperCreator.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.operations;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.MethodElement;
-import org.eclipse.jst.j2ee.ejb.MethodPermission;
-import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl;
-import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility;
-import org.eclipse.wst.common.internal.emfworkbench.integration.ModifierHelper;
-
-
-/**
- * Insert the type's description here. Creation date: (4/8/2001 10:13:52 PM)
- *
- * @author: Administrator
- */
-public class J2EEModifierHelperCreator {
-
- public static ModifierHelper createAssemblyDescriptorHelper(EJBJar anEJBJar) {
- if (anEJBJar == null || anEJBJar.getAssemblyDescriptor() != null)
- return null;
- EjbPackage pack = EjbFactoryImpl.getPackage();
- EStructuralFeature sf = pack.getEJBJar_AssemblyDescriptor();
- return new ModifierHelper(anEJBJar, sf, null);
- }
-
- /**
- * return modifier helper that will create a method element with method type and param
- * associated with the methodSig and the methodpermission will be derived from the security
- * role.
- */
-
- public static ModifierHelper createMethodElementAsCopyHelper(MethodElement element, SecurityRole role) {
- if (role == null)
- return null;
- ModifierHelper tempHelper = new ModifierHelper();
- setMethodPermissionOwnerHelper(tempHelper, role);
- tempHelper.setFeature(getEjbPackage().getMethodPermission_MethodElements());
- tempHelper.setValue(EtoolsCopyUtility.createCopy(element));
- return tempHelper;
- }
-
- /**
- * return modifier helper that will create a method element with method type and param
- * associated with the methodSig and the methodpermission will be derived from the security
- * role.
- */
-
- public static ModifierHelper createMethodElementHelper(EnterpriseBean bean, SecurityRole role, String methodType, String methodSig) {
- if (role == null)
- return null;
- ModifierHelper tempHelper = new ModifierHelper();
- setMethodPermissionOwnerHelper(tempHelper, role);
- tempHelper.setFeature(getEjbPackage().getMethodPermission_MethodElements());
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Type(), methodType);
- int index = methodSig.indexOf("(");//$NON-NLS-1$
- String methodName = methodSig;
- String methodParms = null;
- if (index > -1) {
- methodName = methodSig.substring(0, index);
- methodParms = methodSig.substring(index + 1, methodSig.length() - 1);
- }
- if (methodParms != null)
- methodParms = methodParms.replace(',', ' ');
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Name(), methodName);
- if (methodParms != null)
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Parms(), methodParms);
- tempHelper.addAttribute(getEjbPackage().getMethodElement_EnterpriseBean(), bean);
- return tempHelper;
- }
-
- /**
- * return modifier helper that will create a method element with method type and param
- * associated with the methodSig and a new methodtransacton for a transtype.
- */
-
- public static ModifierHelper createMethodElementHelper(EnterpriseBean bean, String methodType, String methodSig, String transType) {
- if (bean == null)
- return null;
- ModifierHelper ownerHelper = createMethodTransactionHelper((EJBJar) bean.eContainer(), transType);
- ModifierHelper tempHelper = new ModifierHelper();
- tempHelper.setOwnerHelper(ownerHelper);
- tempHelper.setFeature(getEjbPackage().getMethodTransaction_MethodElements());
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Type(), methodType);
- int index = methodSig.indexOf("(");//$NON-NLS-1$
- String methodName = methodSig;
- String methodParms = null;
- if (index > -1) {
- methodName = methodSig.substring(0, index);
- methodParms = methodSig.substring(index + 1, methodSig.length() - 1);
- }
- if (methodParms != null)
- methodParms = methodParms.replace(',', ' ');
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Name(), methodName);
- if (methodParms != null)
- tempHelper.addAttribute(getEjbPackage().getMethodElement_Parms(), methodParms);
- tempHelper.addAttribute(getEjbPackage().getMethodElement_EnterpriseBean(), bean);
- return tempHelper;
- }
-
- public static ModifierHelper createMethodPermissionHelper(SecurityRole role) {
-
- if (role == null)
- return null;
-
- AssemblyDescriptor assembly = (AssemblyDescriptor) role.eContainer();
- EStructuralFeature sf = EjbPackage.eINSTANCE.getAssemblyDescriptor_MethodPermissions();
- ModifierHelper tempHelper = new ModifierHelper(assembly, sf, null);
- tempHelper.addAttribute(getEjbPackage().getMethodPermission_Roles(), role);
- return tempHelper;
- }
-
- /**
- * Create a helper that will create a new MethodTransaction with
- *
- * @aTransType.
- */
- public static ModifierHelper createMethodTransactionHelper(EJBJar anEJBJar, String aTransType) {
- if (anEJBJar == null)
- return null;
- ModifierHelper helper = new ModifierHelper();
- setAssemblyDescriptorOwnerHelper(helper, anEJBJar);
- helper.setFeature(getEjbPackage().getAssemblyDescriptor_MethodTransactions());
- helper.addAttribute(getEjbPackage().getMethodTransaction_TransactionAttribute(), aTransType);
- return helper;
- }
-
-
-
- protected static CommonPackage getCommonPackage() {
- return CommonPackage.eINSTANCE;
- }
-
- protected static EjbPackage getEjbPackage() {
- return EjbFactoryImpl.getPackage();
- }
-
- /**
- * Set the owner of
- *
- * @helper to be the existing AssemblyDescriptor from
- * @anEJBJar or set the ownerHelper of
- * @helper for the creation of a new AssemblyDescriptor when one does not exist.
- */
- public static void setAssemblyDescriptorOwnerHelper(ModifierHelper helper, EJBJar anEJBJar) {
- ModifierHelper ownerHelper = J2EEModifierHelperCreator.createAssemblyDescriptorHelper(anEJBJar);
- if (ownerHelper == null)
- helper.setOwner(anEJBJar.getAssemblyDescriptor());
- else
- helper.setOwnerHelper(ownerHelper);
- }
-
- /**
- * Set the owner of
- *
- * @helper to be the existing AssemblyDescriptor from
- * @anEJBJar or set the ownerHelper of
- * @helper for the creation of a new AssemblyDescriptor when one does not exist.
- */
- public static void setMethodPermissionOwnerHelper(ModifierHelper helper, SecurityRole role) {
- List roleList = new ArrayList(1);
- roleList.add(role);
- MethodPermission permission = ((AssemblyDescriptor) role.eContainer()).getMethodPermission(roleList);
- ModifierHelper ownerHelper = null;
- if (permission == null)
- ownerHelper = J2EEModifierHelperCreator.createMethodPermissionHelper(role);
-
- if (ownerHelper == null)
- helper.setOwner(permission);
- else
- helper.setOwnerHelper(ownerHelper);
- }
-
-
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProperties.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProperties.java
deleted file mode 100644
index a940e1f8c..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProperties.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.common.operations;
-
-import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProperties;
-import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15;
-
-/**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- *
- * @deprecated This should no longer be necessary because of the new EAR & Web Lib classpath
- * containers
- */
-public interface JARDependencyDataModelProperties {
-
- /**
- * String, the ear project name, required
- */
- public static final String EAR_PROJECT_NAME = "AbstractJARDependencyDataModel.EAR_PROJECT_NAME"; //$NON-NLS-1$
-
- public static final String REFERENCED_PROJECT_NAME = "AbstractJARDependencyDataModel.REFERENCED_PROJECT_NAME"; //$NON-NLS-1$
-
- /**
- * nested, required
- */
- public static final String PROJECT_NAME = UpdateManifestDataModelProperties.PROJECT_NAME;
-
-
- /**
- * Used for client JAR dependency inversion
- */
- public static final String OPPOSITE_PROJECT_NAME = "AbstractJARDependencyDataModel.OPPOSITE_PROJECT_NAME"; //$NON-NLS-1$
-
- /**
- * nested
- */
- public static final String JAR_LIST = UpdateManifestDataModelProperties.JAR_LIST;
-
- /**
- * type Integer, default JAR_MANIPULATION_ADD, other possible values are JAR_MANIPULATION_REMOVE
- * and JAR_MANIPULATION_INVERT
- */
- public static final String JAR_MANIPULATION_TYPE = "AbstractJARDependencyDataModel.JAR_MANIPULATION_TYPE"; //$NON-NLS-1$
-
- public static final String NESTED_MODEL_UPDATE_MAINFEST = "AbstractJARDependencyDataModel.NESTED_MODEL_UPDATE_MAINFEST"; //$NON-NLS-1$
-
- public static final int JAR_MANIPULATION_ADD = 0;
- public static final int JAR_MANIPULATION_REMOVE = 1;
- public static final int JAR_MANIPULATION_INVERT = 2;
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProvider.java
deleted file mode 100644
index 7423a5a50..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyDataModelProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 2, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.jst.j2ee.internal.common.operations;
-
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
-import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15;
-
-/**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- *
- * @deprecated This should no longer be necessary because of the new EAR & Web Lib classpath
- * containers
- */
-public class JARDependencyDataModelProvider extends AbstractDataModelProvider implements JARDependencyDataModelProperties {
-
- public Set getPropertyNames() {
- Set propertyNames = super.getPropertyNames();
- propertyNames.add(EAR_PROJECT_NAME);
- propertyNames.add(REFERENCED_PROJECT_NAME);
- propertyNames.add(JAR_MANIPULATION_TYPE);
- propertyNames.add(OPPOSITE_PROJECT_NAME);
- return propertyNames;
- }
-
- public void init() {
- super.init();
- IDataModel updateManifestDataModel = DataModelFactory.createDataModel(UpdateManifestDataModelProvider.class);
- model.addNestedModel(NESTED_MODEL_UPDATE_MAINFEST, updateManifestDataModel);
- }
-
- public Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(JAR_MANIPULATION_TYPE)) {
- return new Integer(JAR_MANIPULATION_ADD);
- }
- return super.getDefaultProperty(propertyName);
- }
-
- public IProject getEARProject() {
- return ProjectUtilities.getProject(getStringProperty(EAR_PROJECT_NAME));
- }
-
- /**
- * @return
- */
- public IDataModel getUpdateManifestDataModel() {
- return model.getNestedModel(NESTED_MODEL_UPDATE_MAINFEST);
- }
-
- public IProject getReferencedProject() {
- return ProjectUtilities.getProject(getStringProperty(REFERENCED_PROJECT_NAME));
- }
-
- public IProject getOppositeProject() {
- return ProjectUtilities.getProject(getStringProperty(OPPOSITE_PROJECT_NAME));
- }
-
- public IDataModelOperation getDefaultOperation() {
- return new JARDependencyOperation(model);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyOperation.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyOperation.java
deleted file mode 100644
index 3eac77ec3..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JARDependencyOperation.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Sep 2, 2003
- *
- */
-package org.eclipse.jst.j2ee.internal.common.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.workbench.utility.JemProjectUtilities;
-import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProperties;
-import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProvider;
-import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestOperation;
-import org.eclipse.jst.j2ee.internal.common.ClasspathModel;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15;
-import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress;
-
-/**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- *
- * @deprecated This should no longer be necessary because of the new EAR & Web Lib classpath
- * containers
- */
-public class JARDependencyOperation extends AbstractDataModelOperation implements JARDependencyDataModelProperties{
- public JARDependencyOperation(IDataModel dataModel) {
- super(dataModel);
- }
-
- public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- // TODO Auto-generated method stub
- return null;
- }
-
- private void saveModel(ClasspathModel model, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, CoreException {
- if (!model.isDirty())
- return;
- validateEdit(model);
- monitor.beginTask("", 2); //$NON-NLS-1$
- org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestOperation mfOperation = createManifestOperation(model);
- IHeadlessRunnableWithProgress buildPathOperation = createBuildPathOperation(model);
- try {
- mfOperation.execute(new SubProgressMonitor(monitor, 1), null);
- buildPathOperation.run(new SubProgressMonitor(monitor, 1));
- } catch (Exception e) {
- Logger.getLogger().logError(e);
- }
- }
-
- /**
- * @param model
- */
- protected void validateEdit(ClasspathModel aModel) throws CoreException {
- Set affectedFiles = aModel.getAffectedFiles();
- IFile[] files = (IFile[]) affectedFiles.toArray(new IFile[affectedFiles.size()]);
- IStatus result = J2EEPlugin.getWorkspace().validateEdit(files, null);
- if (!result.isOK())
- throw new CoreException(result);
- }
-
- protected UpdateJavaBuildPathOperation createBuildPathOperation(ClasspathModel aModel) {
- IJavaProject javaProject = JemProjectUtilities.getJavaProject(aModel.getProject());
- return new UpdateJavaBuildPathOperation(javaProject, aModel.getClassPathSelection());
- }
-
- private UpdateManifestOperation createManifestOperation(ClasspathModel aModel) {
- IDataModel updateManifestDataModel = DataModelFactory.createDataModel(UpdateManifestDataModelProvider.class);
- updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.PROJECT_NAME, aModel.getProject().getName());
- updateManifestDataModel.setBooleanProperty(UpdateManifestDataModelProperties.MERGE, false);
- updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.JAR_LIST, UpdateManifestDataModelProvider.convertClasspathStringToList(aModel.getClassPathSelection().toString()));
- updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, J2EEProjectUtilities.getManifestFile( aModel.getProject()));
- return new UpdateManifestOperation(updateManifestDataModel);
- }
-
-
- public final IStatus execute(IProgressMonitor monitor, IAdaptable adaptable) throws ExecutionException {
-
- IProject proj = ProjectUtilities.getProject(model.getStringProperty(JARDependencyDataModelProperties.PROJECT_NAME));
- IProject earProject = ProjectUtilities.getProject(model.getStringProperty(JARDependencyDataModelProperties.EAR_PROJECT_NAME));
-
- ClasspathModel clpModel = new ClasspathModel(null);
- IVirtualComponent earComponent = ComponentCore.createComponent( earProject );
- if( !earComponent.exists() )
- return OK_STATUS;
-
- clpModel.setSelectedEARComponent( earComponent );
- clpModel.setProject( proj );
-
- try {
- int jarManipulationType = model.getIntProperty(JARDependencyDataModelProperties.JAR_MANIPULATION_TYPE);
- switch (jarManipulationType) {
- case JARDependencyDataModelProperties.JAR_MANIPULATION_ADD :
- {
- List jarList = (List) model.getNestedModel(NESTED_MODEL_UPDATE_MAINFEST).getProperty(UpdateManifestDataModelProperties.JAR_LIST);
- if (!jarList.isEmpty()) {
- for (int i = 0; i < jarList.size(); i++) {
- String jarName = (String) jarList.get(i);
- clpModel.selectDependencyIfNecessary(jarName);
- }
- } else {
- IProject refproj = ProjectUtilities.getProject(model.getStringProperty(JARDependencyDataModelProperties.REFERENCED_PROJECT_NAME));
- clpModel.selectDependencyIfNecessary( refproj );
- }
- }
- break;
-
- case JARDependencyDataModelProperties.JAR_MANIPULATION_REMOVE :
- {
- List jarList = (List) model.getNestedModel(NESTED_MODEL_UPDATE_MAINFEST).getProperty(UpdateManifestDataModelProperties.JAR_LIST);
- for (int i = 0; i < jarList.size(); i++) {
- String jarName = (String) jarList.get(i);
- clpModel.removeDependency(jarName);
- }
- }
- break;
-
- case JARDependencyDataModelProperties.JAR_MANIPULATION_INVERT :
- {
- IProject refproj = ProjectUtilities.getProject(model.getStringProperty(JARDependencyDataModelProperties.REFERENCED_PROJECT_NAME));
- IProject oppositeProject = ProjectUtilities.getProject(model.getStringProperty(JARDependencyDataModelProperties.OPPOSITE_PROJECT_NAME));
- clpModel.getClassPathSelection().invertClientJARSelection( refproj, oppositeProject );
- }
- break;
-
- }
- if (clpModel.isDirty())
- try {
- saveModel(clpModel, monitor);
- } catch (InvocationTargetException e) {
- Logger.getLogger().logError(e);
- } catch (InterruptedException e) {
- Logger.getLogger().logError(e);
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- } finally {
- if (clpModel != null)
- clpModel.dispose();
- if (monitor != null)
- monitor.done();
- }
- return OK_STATUS;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JavaModelUtil.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JavaModelUtil.java
deleted file mode 100644
index ec80d61da..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/JavaModelUtil.java
+++ /dev/null
@@ -1,773 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Apr 30, 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.common.operations;
-
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IImportContainer;
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-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.ITypeHierarchy;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.compiler.CharOperation;
-
-//TODO this is a copy of the class in org.eclipse.jdt.ui and should be deleted once bugzilla 60567
-// is addressed
-/**
- *
- * @author jsholl
- *
- * To change the template for this generated type comment go to Window - Preferences - Java - Code
- * Generation - Code and Comments
- */
-public class JavaModelUtil {
- /**
- * Finds a type by its qualified type name (dot separated).
- *
- * @param jproject
- * The java project to search in
- * @param fullyQualifiedName
- * The fully qualified name (type name with enclosing type names and package (all
- * separated by dots))
- * @return The type found, or null if not existing
- */
- public static IType findType(IJavaProject jproject, String fullyQualifiedName) throws JavaModelException {
- //workaround for bug 22883
- IType type = jproject.findType(fullyQualifiedName);
- if (type != null)
- return type;
- IPackageFragmentRoot[] roots = jproject.getPackageFragmentRoots();
- for (int i = 0; i < roots.length; i++) {
- IPackageFragmentRoot root = roots[i];
- type = findType(root, fullyQualifiedName);
- if (type != null && type.exists())
- return type;
- }
- return null;
- }
-
- /**
- * Returns <code>true</code> if the given package fragment root is referenced. This means it
- * is own by a different project but is referenced by the root's parent. Returns
- * <code>false</code> if the given root doesn't have an underlying resource.
- */
- public static boolean isReferenced(IPackageFragmentRoot root) {
- IResource resource = root.getResource();
- if (resource != null) {
- IProject jarProject = resource.getProject();
- IProject container = root.getJavaProject().getProject();
- return !container.equals(jarProject);
- }
- return false;
- }
-
- private static IType findType(IPackageFragmentRoot root, String fullyQualifiedName) throws JavaModelException {
- IJavaElement[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- IJavaElement element = children[i];
- if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
- IPackageFragment pack = (IPackageFragment) element;
- if (!fullyQualifiedName.startsWith(pack.getElementName()))
- continue;
- IType type = findType(pack, fullyQualifiedName);
- if (type != null && type.exists())
- return type;
- }
- }
- return null;
- }
-
- private static IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException {
- ICompilationUnit[] cus = pack.getCompilationUnits();
- for (int i = 0; i < cus.length; i++) {
- ICompilationUnit unit = cus[i];
- IType type = findType(unit, fullyQualifiedName);
- if (type != null && type.exists())
- return type;
- }
- return null;
- }
-
- private static IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException {
- IType[] types = cu.getAllTypes();
- for (int i = 0; i < types.length; i++) {
- IType type = types[i];
- if (getFullyQualifiedName(type).equals(fullyQualifiedName))
- return type;
- }
- return null;
- }
-
- /**
- * Finds a type by package and type name.
- *
- * @param jproject
- * the java project to search in
- * @param pack
- * The package name
- * @param typeQualifiedName
- * the type qualified name (type name with enclosing type names (separated by dots))
- * @return the type found, or null if not existing
- * @deprecated Use IJavaProject.findType(String, String) instead
- */
- public static IType findType(IJavaProject jproject, String pack, String typeQualifiedName) throws JavaModelException {
- return jproject.findType(pack, typeQualifiedName);
- }
-
- /**
- * Finds a type container by container name. The returned element will be of type
- * <code>IType</code> or a <code>IPackageFragment</code>.<code>null</code> is returned
- * if the type container could not be found.
- *
- * @param jproject
- * The Java project defining the context to search
- * @param typeContainerName
- * A dot separarted name of the type container
- * @see #getTypeContainerName(IType)
- */
- public static IJavaElement findTypeContainer(IJavaProject jproject, String typeContainerName) throws JavaModelException {
- // try to find it as type
- IJavaElement result = jproject.findType(typeContainerName);
- if (result == null) {
- // find it as package
- IPath path = new Path(typeContainerName.replace('.', '/'));
- result = jproject.findElement(path);
- if (!(result instanceof IPackageFragment)) {
- result = null;
- }
-
- }
- return result;
- }
-
- /**
- * Finds a type in a compilation unit. Typical usage is to find the corresponding type in a
- * working copy.
- *
- * @param cu
- * the compilation unit to search in
- * @param typeQualifiedName
- * the type qualified name (type name with enclosing type names (separated by dots))
- * @return the type found, or null if not existing
- */
- public static IType findTypeInCompilationUnit(ICompilationUnit cu, String typeQualifiedName) throws JavaModelException {
- IType[] types = cu.getAllTypes();
- for (int i = 0; i < types.length; i++) {
- String currName = getTypeQualifiedName(types[i]);
- if (typeQualifiedName.equals(currName)) {
- return types[i];
- }
- }
- return null;
- }
-
- /**
- * Finds a a member in a compilation unit. Typical usage is to find the corresponding member in
- * a working copy.
- *
- * @param cu
- * the compilation unit (eg. working copy) to search in
- * @param member
- * the member (eg. from the original)
- * @return the member found, or null if not existing
- */
- public static IMember findMemberInCompilationUnit(ICompilationUnit cu, IMember member) {
- IJavaElement[] elements = cu.findElements(member);
- if (elements != null && elements.length > 0) {
- return (IMember) elements[0];
- }
- return null;
- }
-
-
- /**
- * Returns the element of the given compilation unit which is "equal" to the given element. Note
- * that the given element usually has a parent different from the given compilation unit.
- *
- * @param cu
- * the cu to search in
- * @param element
- * the element to look for
- * @return an element of the given cu "equal" to the given element
- */
- public static IJavaElement findInCompilationUnit(ICompilationUnit cu, IJavaElement element) {
- IJavaElement[] elements = cu.findElements(element);
- if (elements != null && elements.length > 0) {
- return elements[0];
- }
- return null;
- }
-
- /**
- * Returns the qualified type name of the given type using '.' as separators. This is a replace
- * for IType.getTypeQualifiedName() which uses '$' as separators. As '$' is also a valid
- * character in an id this is ambiguous. JavaCore PR: 1GCFUNT
- */
- public static String getTypeQualifiedName(IType type) {
- return type.getTypeQualifiedName('.');
- }
-
- /**
- * Returns the fully qualified name of the given type using '.' as separators. This is a replace
- * for IType.getFullyQualifiedTypeName which uses '$' as separators. As '$' is also a valid
- * character in an id this is ambiguous. JavaCore PR: 1GCFUNT
- */
- public static String getFullyQualifiedName(IType type) {
- return type.getFullyQualifiedName('.');
- }
-
- /**
- * Returns the fully qualified name of a type's container. (package name or enclosing type name)
- */
- public static String getTypeContainerName(IType type) {
- IType outerType = type.getDeclaringType();
- if (outerType != null) {
- return outerType.getFullyQualifiedName('.');
- }
- return type.getPackageFragment().getElementName();
- }
-
-
- /**
- * Concatenates two names. Uses a dot for separation. Both strings can be empty or
- * <code>null</code>.
- */
- public static String concatenateName(String name1, String name2) {
- StringBuffer buf = new StringBuffer();
- if (name1 != null && name1.length() > 0) {
- buf.append(name1);
- }
- if (name2 != null && name2.length() > 0) {
- if (buf.length() > 0) {
- buf.append('.');
- }
- buf.append(name2);
- }
- return buf.toString();
- }
-
- /**
- * Concatenates two names. Uses a dot for separation. Both strings can be empty or
- * <code>null</code>.
- */
- public static String concatenateName(char[] name1, char[] name2) {
- StringBuffer buf = new StringBuffer();
- if (name1 != null && name1.length > 0) {
- buf.append(name1);
- }
- if (name2 != null && name2.length > 0) {
- if (buf.length() > 0) {
- buf.append('.');
- }
- buf.append(name2);
- }
- return buf.toString();
- }
-
- /**
- * Evaluates if a member (possible from another package) is visible from elements in a package.
- *
- * @param member
- * The member to test the visibility for
- * @param pack
- * The package in focus
- */
- public static boolean isVisible(IMember member, IPackageFragment pack) throws JavaModelException {
-
- int type = member.getElementType();
- if (type == IJavaElement.INITIALIZER || (type == IJavaElement.METHOD && member.getElementName().startsWith("<"))) { //$NON-NLS-1$
- return false;
- }
-
- int otherflags = member.getFlags();
- IType declaringType = member.getDeclaringType();
- if (Flags.isPublic(otherflags) || (declaringType != null && declaringType.isInterface())) {
- return true;
- } else if (Flags.isPrivate(otherflags)) {
- return false;
- }
-
- IPackageFragment otherpack = (IPackageFragment) findParentOfKind(member, IJavaElement.PACKAGE_FRAGMENT);
- return (pack != null && otherpack != null && isSamePackage(pack, otherpack));
- }
-
- /**
- * Evaluates if a member in the focus' element hierarchy is visible from elements in a package.
- *
- * @param member
- * The member to test the visibility for
- * @param pack
- * The package of the focus element focus
- */
- public static boolean isVisibleInHierarchy(IMember member, IPackageFragment pack) throws JavaModelException {
- int type = member.getElementType();
- if (type == IJavaElement.INITIALIZER || (type == IJavaElement.METHOD && member.getElementName().startsWith("<"))) { //$NON-NLS-1$
- return false;
- }
-
- int otherflags = member.getFlags();
-
- IType declaringType = member.getDeclaringType();
- if (Flags.isPublic(otherflags) || Flags.isProtected(otherflags) || (declaringType != null && declaringType.isInterface())) {
- return true;
- } else if (Flags.isPrivate(otherflags)) {
- return false;
- }
-
- IPackageFragment otherpack = (IPackageFragment) findParentOfKind(member, IJavaElement.PACKAGE_FRAGMENT);
- return (pack != null && pack.equals(otherpack));
- }
-
-
- /**
- * Returns the package fragment root of <code>IJavaElement</code>. If the given element is
- * already a package fragment root, the element itself is returned.
- */
- public static IPackageFragmentRoot getPackageFragmentRoot(IJavaElement element) {
- return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- }
-
- /**
- * Returns the parent of the supplied java element that conforms to the given parent type or
- * <code>null</code>, if such a parent doesn't exit.
- *
- * @deprecated Use element.getParent().getAncestor(kind);
- */
- public static IJavaElement findParentOfKind(IJavaElement element, int kind) {
- if (element != null && element.getParent() != null) {
- return element.getParent().getAncestor(kind);
- }
- return null;
- }
-
- /**
- * Finds a method in a type. This searches for a method with the same name and signature.
- * Parameter types are only compared by the simple name, no resolving for the fully qualified
- * type name is done. Constructors are only compared by parameters, not the name.
- *
- * @param name
- * The name of the method to find
- * @param paramTypes
- * The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
- * @param isConstructor
- * If the method is a constructor
- * @return The first found method or <code>null</code>, if nothing found
- */
- public static IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException {
- return findMethod(name, paramTypes, isConstructor, type.getMethods());
- }
-
- /**
- * Finds a method by name. This searches for a method with a name and signature. Parameter types
- * are only compared by the simple name, no resolving for the fully qualified type name is done.
- * Constructors are only compared by parameters, not the name.
- *
- * @param name
- * The name of the method to find
- * @param paramTypes
- * The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
- * @param isConstructor
- * If the method is a constructor
- * @param methods
- * The methods to search in
- * @return The found method or <code>null</code>, if nothing found
- */
- public static IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IMethod[] methods) throws JavaModelException {
- for (int i = methods.length - 1; i >= 0; i--) {
- if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i])) {
- return methods[i];
- }
- }
- return null;
- }
-
-
- /**
- * Finds a method declararion in a type's hierarchy. The search is top down, so this returns the
- * first declaration of the method in the hierarchy. This searches for a method with a name and
- * signature. Parameter types are only compared by the simple name, no resolving for the fully
- * qualified type name is done. Constructors are only compared by parameters, not the name.
- *
- * @param type
- * Searches in this type's supertypes.
- * @param name
- * The name of the method to find
- * @param paramTypes
- * The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
- * @param isConstructor
- * If the method is a constructor
- * @return The first method found or null, if nothing found
- */
- public static IMethod findMethodDeclarationInHierarchy(ITypeHierarchy hierarchy, IType type, String name, String[] paramTypes, boolean isConstructor) throws JavaModelException {
- IType[] superTypes = hierarchy.getAllSupertypes(type);
- for (int i = superTypes.length - 1; i >= 0; i--) {
- IMethod first = findMethod(name, paramTypes, isConstructor, superTypes[i]);
- if (first != null && !Flags.isPrivate(first.getFlags())) {
- // the order getAllSupertypes does make assumptions of the order of inner elements
- // -> search recursivly
- IMethod res = findMethodDeclarationInHierarchy(hierarchy, first.getDeclaringType(), name, paramTypes, isConstructor);
- if (res != null) {
- return res;
- }
- return first;
- }
- }
- return null;
- }
-
- /**
- * Finds a method implementation in a type's classhierarchy. The search is bottom-up, so this
- * returns the nearest overridden method. Does not find methods in interfaces or abstract
- * methods. This searches for a method with a name and signature. Parameter types are only
- * compared by the simple name, no resolving for the fully qualified type name is done.
- * Constructors are only compared by parameters, not the name.
- *
- * @param type
- * Type to search the superclasses
- * @param name
- * The name of the method to find
- * @param paramTypes
- * The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
- * @param isConstructor
- * If the method is a constructor
- * @return The first method found or null, if nothing found
- */
- public static IMethod findMethodImplementationInHierarchy(ITypeHierarchy hierarchy, IType type, String name, String[] paramTypes, boolean isConstructor) throws JavaModelException {
- IType[] superTypes = hierarchy.getAllSuperclasses(type);
- for (int i = 0; i < superTypes.length; i++) {
- IMethod found = findMethod(name, paramTypes, isConstructor, superTypes[i]);
- if (found != null) {
- if (Flags.isAbstract(found.getFlags())) {
- return null;
- }
- return found;
- }
- }
- return null;
- }
-
- /**
- * Tests if a method equals to the given signature. Parameter types are only compared by the
- * simple name, no resolving for the fully qualified type name is done. Constructors are only
- * compared by parameters, not the name.
- *
- * @param name
- * Name of the method
- * @param paramTypes
- * The type signatures of the parameters e.g. <code>{"QString;","I"}</code>
- * @param isConstructor
- * Specifies if the method is a constructor
- * @return Returns <code>true</code> if the method has the given name and parameter types and
- * constructor state.
- */
- public static boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod curr) throws JavaModelException {
- if (isConstructor || name.equals(curr.getElementName())) {
- if (isConstructor == curr.isConstructor()) {
- String[] currParamTypes = curr.getParameterTypes();
- if (paramTypes.length == currParamTypes.length) {
- for (int i = 0; i < paramTypes.length; i++) {
- String t1 = Signature.getSimpleName(Signature.toString(paramTypes[i]));
- String t2 = Signature.getSimpleName(Signature.toString(currParamTypes[i]));
- if (!t1.equals(t2)) {
- return false;
- }
- }
- return true;
- }
- }
- }
- return false;
- }
-
-
- /**
- * Tests if two <code>IPackageFragment</code> s represent the same logical java package.
- *
- * @return <code>true</code> if the package fragments' names are equal.
- */
- public static boolean isSamePackage(IPackageFragment pack1, IPackageFragment pack2) {
- return pack1.getElementName().equals(pack2.getElementName());
- }
-
- /**
- * Checks whether the given type has a valid main method or not.
- */
- public static boolean hasMainMethod(IType type) throws JavaModelException {
- IMethod[] methods = type.getMethods();
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].isMainMethod()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the field is boolean.
- */
- public static boolean isBoolean(IField field) throws JavaModelException {
- return field.getTypeSignature().equals(Signature.SIG_BOOLEAN);
- }
-
- /**
- * Returns true if the element is on the build path of the given project
- *
- * @deprecated Use jproject.isOnClasspath(element);
- */
- public static boolean isOnBuildPath(IJavaProject jproject, IJavaElement element) {
- return jproject.isOnClasspath(element);
- }
-
- /**
- * Tests if the given element is on the class path of its containing project. Handles the case
- * that the containing project isn't a Java project.
- */
- public static boolean isOnClasspath(IJavaElement element) {
- IJavaProject project = element.getJavaProject();
- if (!project.exists())
- return false;
- return project.isOnClasspath(element);
- }
-
- /**
- * Resolves a type name in the context of the declaring type.
- *
- * @param refTypeSig
- * the type name in signature notation (for example 'QVector') this can also be an
- * array type, but dimensions will be ignored.
- * @param declaringType
- * the context for resolving (type where the reference was made in)
- * @return returns the fully qualified type name or build-in-type name. if a unresoved type
- * couldn't be resolved null is returned
- */
- public static String getResolvedTypeName(String refTypeSig, IType declaringType) throws JavaModelException {
- int arrayCount = Signature.getArrayCount(refTypeSig);
- char type = refTypeSig.charAt(arrayCount);
- if (type == Signature.C_UNRESOLVED) {
- int semi = refTypeSig.indexOf(Signature.C_SEMICOLON, arrayCount + 1);
- if (semi == -1) {
- throw new IllegalArgumentException();
- }
- String name = refTypeSig.substring(arrayCount + 1, semi);
-
- String[][] resolvedNames = declaringType.resolveType(name);
- if (resolvedNames != null && resolvedNames.length > 0) {
- return concatenateName(resolvedNames[0][0], resolvedNames[0][1]);
- }
- return null;
- }
- return Signature.toString(refTypeSig.substring(arrayCount));
- }
-
- /**
- * Returns if a CU can be edited.
- */
- public static boolean isEditable(ICompilationUnit cu) {
- IResource resource = toOriginal(cu).getResource();
- return (resource.exists() && !resource.getResourceAttributes().isReadOnly());
- }
-
- /**
- * Finds a qualified import for a type name.
- */
- public static IImportDeclaration findImport(ICompilationUnit cu, String simpleName) throws JavaModelException {
- IImportDeclaration[] existing = cu.getImports();
- for (int i = 0; i < existing.length; i++) {
- String curr = existing[i].getElementName();
- if (curr.endsWith(simpleName)) {
- int dotPos = curr.length() - simpleName.length() - 1;
- if ((dotPos == -1) || (dotPos > 0 && curr.charAt(dotPos) == '.')) {
- return existing[i];
- }
- }
- }
- return null;
- }
-
- //private static boolean PRIMARY_ONLY = false;
-
-
-
- /**
- * Returns the original element if the given element is a working copy. If the cu is already an
- * original the input element is returned. The returned element might not exist
- */
- public static IJavaElement toOriginal(IJavaElement element) {
- return element.getPrimaryElement();
- }
-
- /**
- * @deprecated Inline this method.
- */
- public static IMember toWorkingCopy(IMember member) {
- return member;
- }
-
- /**
- * @deprecated Inline this method.
- */
- public static IPackageDeclaration toWorkingCopy(IPackageDeclaration declaration) {
- return declaration;
- }
-
- /**
- * @deprecated Inline this method.
- */
- public static IJavaElement toWorkingCopy(IJavaElement elem) {
- return elem;
- }
-
- /**
- * @deprecated Inline this method.
- */
- public static IImportContainer toWorkingCopy(IImportContainer container) {
- return container;
-
- }
-
- /**
- * @deprecated Inline this method.
- */
- public static IImportDeclaration toWorkingCopy(IImportDeclaration importDeclaration) {
- return importDeclaration;
- }
-
-
- /**
- * @deprecated Inline this method.
- */
- public static ICompilationUnit toWorkingCopy(ICompilationUnit cu) {
- return cu;
- }
-
- /**
- * Returns true if a cu is a primary cu (original or shared working copy)
- */
- public static boolean isPrimary(ICompilationUnit cu) {
- return cu.getOwner() == null;
- }
-
-
- /*
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
- *
- * Reconciling happens in a separate thread. This can cause a situation where the Java element
- * gets disposed after an exists test has been done. So we should not log not present exceptions
- * when they happen in working copies.
- */
- public static boolean filterNotPresentException(CoreException exception) {
- if (!(exception instanceof JavaModelException))
- return true;
- JavaModelException je = (JavaModelException) exception;
- if (!je.isDoesNotExist())
- return true;
- IJavaElement[] elements = je.getJavaModelStatus().getElements();
- for (int i = 0; i < elements.length; i++) {
- IJavaElement element = elements[i];
- ICompilationUnit unit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
- if (unit == null)
- return true;
- if (!unit.isWorkingCopy())
- return true;
- }
- return false;
- }
-
- public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException {
- //workaround for 23656
- Set types = new HashSet(Arrays.asList(type.newSupertypeHierarchy(pm).getAllSupertypes(type)));
- IType objekt = type.getJavaProject().findType("java.lang.Object");//$NON-NLS-1$
- if (objekt != null)
- types.add(objekt);
- return (IType[]) types.toArray(new IType[types.size()]);
- }
-
- public static boolean isExcludedPath(IPath resourcePath, IPath[] exclusionPatterns) {
- char[] path = resourcePath.toString().toCharArray();
- for (int i = 0, length = exclusionPatterns.length; i < length; i++) {
- char[] pattern = exclusionPatterns[i].toString().toCharArray();
- if (CharOperation.pathMatch(pattern, path, true, '/')) {
- return true;
- }
- }
- return false;
- }
-
-
- /*
- * Returns whether the given resource path matches one of the exclusion patterns.
- *
- * @see IClasspathEntry#getExclusionPatterns
- */
- public final static boolean isExcluded(IPath resourcePath, char[][] exclusionPatterns) {
- if (exclusionPatterns == null)
- return false;
- char[] path = resourcePath.toString().toCharArray();
- for (int i = 0, length = exclusionPatterns.length; i < length; i++)
- if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/'))
- return true;
- return false;
- }
-
-
- /**
- * Force a reconcile of a compilation unit.
- *
- * @param unit
- */
- public static void reconcile(ICompilationUnit unit) throws JavaModelException {
- synchronized (unit) {
- unit.reconcile();
- }
- }
-
- private static Boolean fgIsJDTCore_1_5 = null;
-
- /**
- * Return true if JRE 1.5 in enabled.
- */
- public static boolean isJDTCore_1_5() {
- if (fgIsJDTCore_1_5 == null) {
- fgIsJDTCore_1_5 = new Boolean(JavaCore.getDefaultOptions().containsKey("org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation")); //$NON-NLS-1$
- }
- return fgIsJDTCore_1_5.booleanValue();
- }
-
-
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassDataModelProvider.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassDataModelProvider.java
deleted file mode 100644
index b42070890..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassDataModelProvider.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.operations;
-
-import java.lang.reflect.Modifier;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.workbench.utility.JemProjectUtilities;
-import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-
-/**
- * This data model provider is a subclass of AbstractDataModelProvider and follows the
- * IDataModelOperation and Data Model Wizard frameworks.
- *
- * @see org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider
- *
- * This data model provider extends the ArtifactEditOperationDataModelProvider to get project name
- * and artifact edit information that during the operation, the artifact edit model can be used to
- * save changes.
- * @see org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditOperationDataModelProvider
- *
- * The NewJavaClassDataModelProvider is used to store all the base properties which would be needed
- * to generate a new instance of a java class. Validations for these properties such as class name,
- * package name, superclass, and modifiers are also provided.
- *
- * The INewJavaClassDataModelProperties is implemented to store all of the property names.
- * @see org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties
- *
- * Clients must subclass this data model provider and the properties interface to use it and to
- * cache and provide their own specific attributes. They should also provide their own validation
- * methods and default values for the properties they add.
- *
- * The use of this class is EXPERIMENTAL and is subject to substantial changes.
- */
-public class NewJavaClassDataModelProvider extends ArtifactEditOperationDataModelProvider implements INewJavaClassDataModelProperties {
-
- /**
- * Subclasses may extend this method to perform their own validation. This method should not
- * return null. It does not accept null as a parameter.
- *
- * @see NewJavaClassDataModelProvider#validate(String)
- *
- * @param folderFullPath
- * @return IStatus
- */
- protected IStatus validateJavaSourceFolder(String folderFullPath) {
- // Ensure that the source folder path is not empty
- if (folderFullPath == null || folderFullPath.length() == 0) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NAME_EMPTY;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Ensure that the source folder path is absolute
- else if (!new Path(folderFullPath).isAbsolute()) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_ABSOLUTE;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- IProject project = getTargetProject();
- // Ensure project is not closed
- if (project == null) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Ensure project is accessible.
- if (!project.isAccessible()) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Ensure the project is a java project.
- try {
- if (!project.hasNature(JavaCore.NATURE_ID)) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NOT_JAVA_PROJECT;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- } catch (CoreException e) {
- Logger.getLogger().log(e);
- }
- // Ensure the selected folder is a valid java source folder for the component
- IFolder sourcefolder = getJavaSourceFolder();
- if (sourcefolder == null || (sourcefolder != null && !sourcefolder.getFullPath().equals(new Path(folderFullPath)))) {
- String msg = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_SOURCE, new String[]{folderFullPath});
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Valid source is selected
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * Subclasses may extend this method to perform their own retrieval of a default java source
- * folder. This implementation returns the first source folder in the project for the component.
- * This method may return null.
- *
- * @return IFolder instance of default java source folder
- */
- protected IFolder getDefaultJavaSourceFolder() {
- IProject project = getTargetProject();
- if (project == null)
- return null;
- IPackageFragmentRoot[] sources = J2EEProjectUtilities.getSourceContainers(project);
- // Try and return the first source folder
- if (sources.length > 0) {
- try {
- return (IFolder) sources[0].getCorrespondingResource();
- } catch (Exception e) {
- return null;
- }
- }
- return null;
- }
-
- /**
- * Subclasses may extend this method to create their own specialized default WTP operation. This
- * implementation creates an instance of the NewJavaClassOperation to create a new java class.
- * This method will not return null.
- *
- * @see WTPOperationDataModel#getDefaultOperation()
- * @see NewJavaClassOperation
- *
- * @return WTPOperation
- */
- public IDataModelOperation getDefaultOperation() {
- return new NewJavaClassOperation(getDataModel());
- }
-
- /**
- * Subclasses may extend this method to add their own data model's properties as valid base
- * properties.
- *
- * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getPropertyNames()
- */
- public Set getPropertyNames() {
- Set propertyNames = super.getPropertyNames();
- propertyNames.add(SOURCE_FOLDER);
- propertyNames.add(JAVA_PACKAGE);
- propertyNames.add(CLASS_NAME);
- propertyNames.add(SUPERCLASS);
- propertyNames.add(MODIFIER_PUBLIC);
- propertyNames.add(MODIFIER_ABSTRACT);
- propertyNames.add(MODIFIER_FINAL);
- propertyNames.add(INTERFACES);
- propertyNames.add(MAIN_METHOD);
- propertyNames.add(CONSTRUCTOR);
- propertyNames.add(ABSTRACT_METHODS);
- propertyNames.add(JAVA_PACKAGE_FRAGMENT_ROOT);
- propertyNames.add(JAVA_SOURCE_FOLDER);
- propertyNames.add(PROJECT);
- propertyNames.add(QUALIFIED_CLASS_NAME);
- return propertyNames;
- }
-
- /**
- * Subclasses may extend this method to add the default values for their own specific data model
- * properties. This declares the default values for the new java class. This method does not
- * accept null. It may return null.
- *
- * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getDefaultProperty(String)
- *
- * @param propertyName
- * @return default object value of the property
- */
- public Object getDefaultProperty(String propertyName) {
- // Get the default source folder for the project
- if (propertyName.equals(SOURCE_FOLDER)) {
- IFolder sourceFolder = getDefaultJavaSourceFolder();
- if (sourceFolder != null && sourceFolder.exists())
- return sourceFolder.getFullPath().toOSString();
- }
- // Use Object as the default superclass if one is not specified
- else if (propertyName.equals(SUPERCLASS))
- return new String("java.lang.Object"); //$NON-NLS-1$
- // Use public as default visibility
- else if (propertyName.equals(MODIFIER_PUBLIC))
- return new Boolean(true);
- // Generate constructors from the superclass by default
- else if (propertyName.equals(CONSTRUCTOR))
- return new Boolean(true);
- // Generate unimplemented methods from declared interfaces by default
- else if (propertyName.equals(ABSTRACT_METHODS))
- return new Boolean(true);
- else if (propertyName.equals(PROJECT))
- return getTargetProject();
- else if (propertyName.equals(JAVA_SOURCE_FOLDER))
- return getJavaSourceFolder();
- else if (propertyName.equals(JAVA_PACKAGE_FRAGMENT_ROOT))
- return getJavaPackageFragmentRoot();
- else if (propertyName.equals(QUALIFIED_CLASS_NAME))
- return getQualifiedClassName();
- return super.getDefaultProperty(propertyName);
- }
-
- /**
- * This method will return the qualified java class name as specified by the class name and
- * package name properties in the data model. This method should not return null.
- *
- * @see INewJavaClassDataModelProperties#CLASS_NAME
- * @see INewJavaClassDataModelProperties#JAVA_PACKAGE
- *
- * @return String qualified java classname
- */
- private String getQualifiedClassName() {
- // Use the java package name and unqualified class name to create a qualified java class
- // name
- String packageName = getStringProperty(JAVA_PACKAGE);
- String className = getStringProperty(CLASS_NAME);
- // Ensure the class is not in the default package before adding package name to qualified
- // name
- if (packageName != null && packageName.trim().length() > 0)
- return packageName + "." + className; //$NON-NLS-1$
- return className;
- }
-
- /**
- * Subclasses may override this method to provide their own validation of any of the data
- * model's properties. This implementation ensures that a java class can be properly generated
- * from the values as specified. This method will not return null. This method will not accept
- * null as a parameter.
- *
- * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#validate(java.lang.String)
- *
- * @param propertyName
- * @return IStatus of the validity of the specifiec property
- */
- public IStatus validate(String propertyName) {
- IStatus result = super.validate(propertyName);
- if (result != null && !result.isOK())
- return result;
- if (propertyName.equals(SOURCE_FOLDER))
- return validateJavaSourceFolder(getStringProperty(propertyName));
- if (propertyName.equals(JAVA_PACKAGE))
- return validateJavaPackage(getStringProperty(propertyName));
- if (propertyName.equals(CLASS_NAME)) {
- result = validateJavaClassName(getStringProperty(propertyName));
- if (result.isOK())
- result = canCreateTypeInClasspath(getStringProperty(CLASS_NAME));
- }
- if (propertyName.equals(SUPERCLASS))
- return validateSuperclass(getStringProperty(propertyName));
- if (propertyName.equals(MODIFIER_ABSTRACT) || propertyName.equals(MODIFIER_FINAL))
- return validateModifier(propertyName, getBooleanProperty(propertyName));
- return result;
- }
-
- /**
- * This method will validate whether the specified package name is a valid java package name. It
- * will be called during the doValidateProperty(String). This method will accept null. It will
- * not return null.
- *
- * @see NewJavaClassDataModelProvider#validate(String)
- *
- * @param packName --
- * the package name
- * @return IStatus of if the package name is valid
- */
- private IStatus validateJavaPackage(String packName) {
- if (packName != null && packName.trim().length() > 0) {
- // Use standard java conventions to validate the package name
- IStatus javaStatus = JavaConventions.validatePackageName(packName);
- if (javaStatus.getSeverity() == IStatus.ERROR) {
- String msg = J2EECommonMessages.ERR_JAVA_PACAKGE_NAME_INVALID + javaStatus.getMessage();
- return WTPCommonPlugin.createErrorStatus(msg);
- } else if (javaStatus.getSeverity() == IStatus.WARNING) {
- String msg = J2EECommonMessages.ERR_JAVA_PACKAGE_NAME_WARNING + javaStatus.getMessage();
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- }
- // java package name is valid
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * Subclasses may override this method to provide their own validation of the class name. This
- * implementation will verify if the specified class name is a valid UNQUALIFIED java class
- * name. This method will not accept null. It will not return null.
- *
- * @see NewJavaClassDataModelProvider#validate(String)
- *
- * @param className
- * @return IStatus of if java class name is valid
- */
- protected IStatus validateJavaClassName(String className) {
- // Do not allow qualified name
- if (className.lastIndexOf('.') != -1) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NAME_QUALIFIED;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Check Java class name by standard java conventions
- IStatus javaStatus = JavaConventions.validateJavaTypeName(className);
- if (javaStatus.getSeverity() == IStatus.ERROR) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NAME_INVALID + javaStatus.getMessage();
- return WTPCommonPlugin.createErrorStatus(msg);
- } else if (javaStatus.getSeverity() == IStatus.WARNING) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NAME_WARNING + javaStatus.getMessage();
- return WTPCommonPlugin.createWarningStatus(msg);
- }
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * This method will verify the specified superclass can be subclassed. It ensures the superclass
- * is a valid java class, that it exists, and that it is not final. This method will accept
- * null. It will not return null.
- *
- * @see NewJavaClassDataModelProvider#validate(String)
- *
- * @param superclassName
- * @return IStatus of if the superclass can be subclassed
- */
- private IStatus validateSuperclass(String superclassName) {
- // Ensure the superclass name is not empty
- if (superclassName == null || superclassName.trim().length() == 0) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NAME_EMPTY;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // In default case of Object, return OK right away
- if (superclassName.equals("java.lang.Object")) //$NON-NLS-1$
- return WTPCommonPlugin.OK_STATUS;
- // Ensure the unqualified java class name of the superclass is valid
- String className = superclassName;
- int index = superclassName.lastIndexOf("."); //$NON-NLS-1$
- if (index != -1) {
- className = superclassName.substring(index + 1);
- }
- IStatus status = validateJavaClassName(className);
- // If unqualified super class name is valid, ensure validity of superclass itself
- if (status.isOK()) {
- // If the superclass does not exist, throw an error
- IJavaProject javaProject = JemProjectUtilities.getJavaProject(getTargetProject());
- IType supertype = null;
- try {
- supertype = javaProject.findType(superclassName);
- } catch (Exception e) {
- // Just throw error below
- }
- if (supertype == null) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_SUPERCLASS_NOT_EXIST;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Ensure the superclass is not final
- int flags = -1;
- try {
- flags = supertype.getFlags();
- if (Modifier.isFinal(flags)) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_SUPERCLASS_FINAL;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- } catch (Exception e) {
- Logger.getLogger().log(e);
- }
- }
- // Return status of specified superclass
- return status;
- }
-
- /**
- * This method will ensure that if the abstract modifier is set, that final is not set, and
- * vice-versa, as this is not supported either way. This method will not accept null. It will
- * not return null.
- *
- * @see NewJavaClassDataModelProvider#validate(String)
- *
- * @param prop
- * @return IStatus of whether abstract value is valid
- */
- private IStatus validateModifier(String propertyName, boolean prop) {
- // Throw an error if both Abstract and Final are checked
- if (prop) {
- // Ensure final is not also checked
- if (propertyName.equals(MODIFIER_ABSTRACT) && getBooleanProperty(MODIFIER_FINAL)) {
- String msg = J2EECommonMessages.ERR_BOTH_FINAL_AND_ABSTRACT;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- // Ensure abstract is not also checked
- if (propertyName.equals(MODIFIER_FINAL) && getBooleanProperty(MODIFIER_ABSTRACT)) {
- String msg = J2EECommonMessages.ERR_BOTH_FINAL_AND_ABSTRACT;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- }
- // Abstract and final settings are valid
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * This method is intended for internal use only. This will check the java model for the
- * specified javaproject in the data model for the existence of the passed in qualified
- * classname. This method does not accept null. It may return null.
- *
- * @see NewJavaClassDataModelProvider#getTargetProject()
- * @see JavaModelUtil#findType(IJavaProject, String)
- *
- * @param fullClassName
- * @return IType for the specified classname
- */
- protected IStatus canCreateTypeInClasspath(String className) {
- // Retrieve the java project for the cached project
- IJavaProject javaProject = JemProjectUtilities.getJavaProject(getTargetProject());
- try {
- IPath path = new Path(getStringProperty(SOURCE_FOLDER) + "//" + getStringProperty(JAVA_PACKAGE)); //$NON-NLS-1$
- IPackageFragment pack = javaProject.findPackageFragment(path);
- if (pack != null) {
- ICompilationUnit cu = pack.getCompilationUnit(className + ".java"); //$NON-NLS-1$
- IResource resource = cu.getResource();
- if (resource.exists()) {
- String msg = J2EECommonMessages.ERR_JAVA_CLASS_NAME_EXIST;
- return WTPCommonPlugin.createErrorStatus(msg);
- }
- }
- return WTPCommonPlugin.OK_STATUS;
- } catch (Exception e) {
- Logger.getLogger().log(e);
- }
- return WTPCommonPlugin.OK_STATUS;
- }
-
- /**
- * This will return the IFolder instance for the specified folder name in the data model. This
- * method may return null.
- *
- * @see INewJavaClassDataModelProperties#SOURCE_FOLDER
- * @see NewJavaClassDataModelProvider#getAllSourceFolders()
- *
- * @return IFolder java source folder
- */
- protected final IFolder getJavaSourceFolder() {
- IPackageFragmentRoot[] sources = J2EEProjectUtilities.getSourceContainers(getTargetProject());
- // Ensure there is valid source folder(s)
- if (sources == null || sources.length == 0)
- return null;
- String folderFullPath = getStringProperty(SOURCE_FOLDER);
- // Get the source folder whose path matches the source folder name value in the data model
- for (int i = 0; i < sources.length; i++) {
- if (sources[i].getPath().equals(new Path(folderFullPath))) {
- try {
- return (IFolder) sources[i].getCorrespondingResource();
- } catch (Exception e) {
- break;
- }
- }
- }
- return null;
- }
-
- /**
- * Subclasses may extend this method to perform their own retrieval mechanism. This
- * implementation simply returns the JDT package fragment root for the selected source folder.
- * This method may return null.
- *
- * @see IJavaProject#getPackageFragmentRoot(org.eclipse.core.resources.IResource)
- *
- * @return IPackageFragmentRoot
- */
- protected IPackageFragmentRoot getJavaPackageFragmentRoot() {
- IProject project = getTargetProject();
- if (project != null) {
- IJavaProject aJavaProject = JemProjectUtilities.getJavaProject(project);
- // Return the source folder for the java project of the selected project
- if (aJavaProject != null) {
- IFolder sourcefolder = (IFolder) getProperty(JAVA_SOURCE_FOLDER);
- if (sourcefolder != null)
- return aJavaProject.getPackageFragmentRoot(sourcefolder);
- }
- }
- return null;
- }
-
- /**
- * This method ensures the source folder is updated if the component is changed.
- *
- * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#propertySet(String,
- * Object)
- *
- * @return boolean if property set successfully
- */
- public boolean propertySet(String propertyName, Object propertyValue) {
- boolean result = super.propertySet(propertyName, propertyValue);
- if (result) {
- if (COMPONENT_NAME.equals(propertyName)){
- if( getDefaultJavaSourceFolder() != null ){
- setProperty(SOURCE_FOLDER, getDefaultJavaSourceFolder().getFullPath().toOSString());
- }
- }
- }
- return result;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassOperation.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassOperation.java
deleted file mode 100644
index d89671487..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/NewJavaClassOperation.java
+++ /dev/null
@@ -1,821 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.operations;
-
-import java.io.ByteArrayInputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.workbench.utility.JemProjectUtilities;
-import org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditProviderOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * NewJavaClassOperation is a data model operation that is used to create a default instance of a new java class
- * based on the input and properties set in the NewJavaClassDataModelProvider.
- * @see org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider
- *
- * It is a subclass of ArtifactEditProviderOperation and clients can invoke this operation as is or it may be subclassed to
- * add additional or modify behaviour. The execute() method can be extended to drive this behaviour.
- * @see org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditProviderOperation
- *
- * The new java class is generated through the use of adding a series of static tokens defined within to
- * an ongoing string buffer.
- *
- * The use of this class is EXPERIMENTAL and is subject to substantial changes.
- *
- * This needs to be removed as it is legacy inherited from another team
- */
-public class NewJavaClassOperation extends ArtifactEditProviderOperation {
-
- // Tokens for string buffer creation of default java class
- protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
- protected static final String TAB = "\t"; //$NON-NLS-1$
- protected static final String SPACE = " "; //$NON-NLS-1$
- protected static final String DOT = "."; //$NON-NLS-1$
- protected static final String COMMA = ","; //$NON-NLS-1$
- protected static final String SEMICOLON = ";"; //$NON-NLS-1$
- protected static final String POUND = "#"; //$NON-NLS-1$
- protected static final String OPEN_PAR = "("; //$NON-NLS-1$
- protected static final String CLOSE_PAR = ")"; //$NON-NLS-1$
- protected static final String OPEN_BRA = "{"; //$NON-NLS-1$
- protected static final String CLOSE_BRA = "}"; //$NON-NLS-1$
- protected static final String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
-
- protected static final String JAVA_LANG_OBJECT = "java.lang.Object"; //$NON-NLS-1$
- protected static final String PACKAGE = "package "; //$NON-NLS-1$
- protected static final String CLASS = "class "; //$NON-NLS-1$
- protected static final String IMPORT = "import "; //$NON-NLS-1$
- protected static final String EXTENDS = "extends "; //$NON-NLS-1$
- protected static final String IMPLEMENTS = "implements "; //$NON-NLS-1$
- protected static final String THROWS = "throws "; //$NON-NLS-1$
- protected static final String SUPER = "super"; //$NON-NLS-1$
- protected static final String PUBLIC = "public "; //$NON-NLS-1$
- protected static final String PROTECTED = "protected "; //$NON-NLS-1$
- protected static final String PRIVATE = "private "; //$NON-NLS-1$
- protected static final String STATIC = "static "; //$NON-NLS-1$
- protected static final String ABSTRACT = "abstract "; //$NON-NLS-1$
- protected static final String FINAL = "final "; //$NON-NLS-1$
- protected static final String VOID = "void"; //$NON-NLS-1$
- protected static final String INT = "int"; //$NON-NLS-1$
- protected static final String BOOLEAN = "boolean"; //$NON-NLS-1$
- protected static final String MAIN_METHOD = "\tpublic static void main(String[] args) {"; //$NON-NLS-1$
- protected static final String TODO_COMMENT = "\t\t// TODO Auto-generated method stub"; //$NON-NLS-1$
- protected static final String RETURN_NULL = "\t\treturn null;"; //$NON-NLS-1$
- protected static final String RETURN_0 = "\t\treturn 0;"; //$NON-NLS-1$
- protected static final String RETURN_FALSE = "\t\treturn false;"; //$NON-NLS-1$
-
- /**
- * This is a list of all the calculated import statements that will need to be added
- */
- private List importStatements;
-
- /**
- * This is a NewJavaClassOperation constructor. Data models passed in should be instances
- * of NewJavaClassDataModel. This method does not accept null. It will not return null.
- * @see NewJavaClassDataModelProvider
- *
- * @param dataModel
- * @return NewJavaClassOperation
- */
- public NewJavaClassOperation(IDataModel dataModel) {
- super(dataModel);
- importStatements = new ArrayList();
- }
-
- /**
- * Subclasses may extend this method to add their own actions during execution.
- * The implementation of the execute method drives the running of the operation. This
- * method will create the source folder, the java package, and then create the java file.
- * This method will accept null.
- * @see AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- *
- * @param monitor ProgressMonitor
- * @throws CoreException
- * @throws InterruptedException
- * @throws InvocationTargetException
- */
- public IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- // Ensure source folder exists
- IFolder sourceFolder = createJavaSourceFolder();
- // Ensure java package exists
- IPackageFragment pack = createJavaPackage();
- // Create java class
- createJavaFile(sourceFolder, pack);
- return OK_STATUS;
- }
-
- /**
- * This method will return the java source folder as specified in the java class data model.
- * It will create the java source folder if it does not exist. This method may return null.
- * @see INewJavaClassDataModelProperties#SOURCE_FOLDER
- * @see IFolder#create(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
- *
- * @return IFolder the java source folder
- */
- protected final IFolder createJavaSourceFolder() {
- // Get the source folder name from the data model
- String folderFullPath = model.getStringProperty(INewJavaClassDataModelProperties.SOURCE_FOLDER);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFolder folder = root.getFolder(new Path(folderFullPath));
- // If folder does not exist, create the folder with the specified path
- if (!folder.exists()) {
- try {
- folder.create(true, true, null);
- } catch (CoreException e) {
- Logger.getLogger().log(e);
- }
- }
- // Return the source folder
- return folder;
- }
-
- /**
- * This method will return the java package as specified by the new java class data model.
- * If the package does not exist, it will create the package. This method should not return
- * null.
- * @see INewJavaClassDataModelProperties#JAVA_PACKAGE
- * @see IPackageFragmentRoot#createPackageFragment(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
- *
- * @return IPackageFragment the java package
- */
- protected final IPackageFragment createJavaPackage() {
- // Retrieve the package name from the java class data model
- String packageName = model.getStringProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE);
- IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT);
- IPackageFragment pack = packRoot.getPackageFragment(packageName);
- // Handle default package
- if (pack == null) {
- pack = packRoot.getPackageFragment(""); //$NON-NLS-1$
- }
- // Create the package fragment if it does not exist
- if (!pack.exists()) {
- String packName = pack.getElementName();
- try {
- pack = packRoot.createPackageFragment(packName, true, null);
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- }
- // Return the package
- return pack;
- }
-
- /**
- * Subclasses may extend this method to provide their own java file creation path.
- * This implementation will use the properties specified in the data model to create
- * a default java class. The class will be built using pre-defined tokens and will be
- * built up using a string buffer. The method getJavaFileContent will handle the building
- * of the string buffer while this method will write those contents to the file.
- * This method does not accept null parameters.
- * @see INewJavaClassDataModelProperties#CLASS_NAME
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @param sourceFolder
- * @param pack
- */
- protected void createJavaFile(IFolder sourceFolder, IPackageFragment pack) {
- // Retrieve properties from the java class data model
- String packageName = model.getStringProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE);
- String className = model.getStringProperty(INewJavaClassDataModelProperties.CLASS_NAME);
- String fileName = className + ".java"; //$NON-NLS-1$
- //ICompilationUnit cu = null;
- try {
- // Get the java file content from the string buffer
- String content = getJavaFileContent(pack, className);
- // Create the compilation unit
- pack.createCompilationUnit(fileName, content, true, null);
- byte[] contentBytes = content.getBytes();
- IPath packageFullPath = new Path(packageName.replace('.', IPath.SEPARATOR));
- IPath javaFileFullPath = packageFullPath.append(fileName);
- IFile file = sourceFolder.getFile(javaFileFullPath);
- // Set the contents in the file if it already exists
- if (file != null && file.exists()) {
- file.setContents(new ByteArrayInputStream(contentBytes), false, true, null);
- } // If the file does not exist, create it with the contents
- else if (file != null) {
- file.create(new ByteArrayInputStream(contentBytes), false, null);
- }
- // editModel.getWorkingCopy(cu, true); //Track CU.
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * This is intended for internal use only. This is where the string buffer for the contents
- * of the java file is built up using the properties in the data model and the predefined tokens.
- * This method will not accept null parameters. It will not return null.
- * @see NewJavaClassDataModelProvider
- * @see NewJavaClassOperation#createJavaFile(IFolder, IPackageFragment)
- *
- * @param pack
- * @param className
- * @return String java file contents
- */
- private String getJavaFileContent(IPackageFragment pack, String className) {
- // Create the superclass name
- String superclassName = model.getStringProperty(INewJavaClassDataModelProperties.SUPERCLASS);
- List interfaces = (List) model.getProperty(INewJavaClassDataModelProperties.INTERFACES);
- String packageStatement = getPackageStatement(pack);
- // Create the import statements
- setupImportStatements(pack, superclassName, interfaces);
- // Create the class declaration
- String classDeclaration = getClassDeclaration(superclassName, className, interfaces);
- // Create the fields
- String fields = getFields();
- // Create the methods
- String methods = getMethodStubs(superclassName, className);
-
- StringBuffer contents = new StringBuffer();
- // Add the package statement to the buffer
- contents.append(packageStatement);
- // Add all the import statements to the buffer
- for (int i = 0; i < importStatements.size(); i++) {
- contents.append(IMPORT + importStatements.get(i) + SEMICOLON);
- contents.append(lineSeparator);
- }
- contents.append(lineSeparator);
- // Add the class declaration to the buffer
- contents.append(classDeclaration);
- // Add the fields to the buffer
- contents.append(fields);
- // Add the method bodies to the buffer
- contents.append(methods);
- contents.append(CLOSE_BRA);
- // Return the contents of the buffer
- return contents.toString();
- }
-
- /**
- * This is intended for internal use only. This method will return a package string for
- * the class. It will not accept a null parameter. It will not return null.
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @param pack
- * @return String package statement
- */
- private String getPackageStatement(IPackageFragment pack) {
- StringBuffer sb = new StringBuffer();
- // If it is not default package, add package statement
- if (!pack.isDefaultPackage()) {
- sb.append(PACKAGE + pack.getElementName() + SEMICOLON);
- sb.append(lineSeparator);
- sb.append(lineSeparator);
- }
- // Return contents of buffer
- return sb.toString();
- }
-
- /**
- * This method is intended for internal use. It checks to see if the qualified class name
- * belongs to the specified package. This method will not accept nulls. It will not return null.
- * @see NewJavaClassOperation#setupImportStatements(IPackageFragment, String, List)
- *
- * @param packageFragment
- * @param className
- * @return boolean is class in this package?
- */
- private boolean isSamePackage(IPackageFragment packageFragment, String className) {
- if (className != null && className.length() > 0) {
- String sPackageName = packageFragment.getElementName();
- String classPackageName = Signature.getQualifier(className);
- // Does the qualified class's package name match the passed in package's name?
- if (classPackageName.equals(sPackageName))
- return true;
- }
- return false;
- }
-
- /**
- * This method is intended for internal use only. This method will set up the required import
- * statements and cache to the importStatements list.
- * This method does not accept null parameters.
- * @see NewJavaClassOperation#importStatements
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @param pack
- * @param superclassName
- * @param interfaces
- */
- private void setupImportStatements(IPackageFragment pack, String superclassName, List interfaces) {
- // If there is a superclass and it is not in the same package, add an import for it
- if (superclassName != null && superclassName.length() > 0) {
- if (!superclassName.equals(JAVA_LANG_OBJECT) && !isSamePackage(pack, superclassName)) {
- importStatements.add(superclassName);
- }
- }
- // Add an import the list of implemented interfaces
- if (interfaces != null && interfaces.size() > 0) {
- int size = interfaces.size();
- for (int i = 0; i < size; i++) {
- String interfaceName = (String) interfaces.get(i);
- importStatements.add(interfaceName);
- }
- }
- }
-
- /**
- * This class is intended for internal use only. This will build up the class declartion
- * statement based off the properties set in the java class data model.
- * This method does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @param superclassName
- * @param className
- * @param interfaces
- * @return String class declaration string
- */
- private String getClassDeclaration(String superclassName, String className, List interfaces) {
- StringBuffer sb = new StringBuffer();
- // Append appropriate modifiers
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.MODIFIER_PUBLIC))
- sb.append(PUBLIC);
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.MODIFIER_ABSTRACT))
- sb.append(ABSTRACT);
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.MODIFIER_FINAL))
- sb.append(FINAL);
- // Add the class token
- sb.append(CLASS);
- // Add the class name
- sb.append(className + SPACE);
- // If there is a superclass, add the extends and super class name
- if (superclassName != null && superclassName.length() > 0 && !superclassName.equals(JAVA_LANG_OBJECT)) {
- int index = superclassName.lastIndexOf(DOT);
- if (index != -1)
- superclassName = superclassName.substring(index + 1);
- sb.append(EXTENDS + superclassName + SPACE);
- }
- // If there are interfaces, add the implements and then interate over the interface list
- if (interfaces != null && interfaces.size() > 0) {
- sb.append(IMPLEMENTS);
- int size = interfaces.size();
- for (int i = 0; i < size; i++) {
- String interfaceName = (String) interfaces.get(i);
- int index = interfaceName.lastIndexOf(DOT);
- if (index != -1)
- interfaceName = interfaceName.substring(index + 1);
- sb.append(interfaceName);
- if (i < size - 1)
- sb.append(COMMA);
- sb.append(SPACE);
- }
- }
- sb.append(OPEN_BRA);
- sb.append(lineSeparator);
- // Return the finished class declaration string
- return sb.toString();
- }
-
- /**
- * Subclasses may extend this method to add their own fields. The default implementation
- * is not to have any fields. This method will not return null.
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @return String fields string
- */
- protected String getFields() {
- return EMPTY_STRING;
- }
-
- /**
- * This method is intended for internal use only. This will build up a string with the
- * contents of all the method stubs for the unimplemented methods defined in the interfaces.
- * It will also add inherited constructors from the superclass as appropriate.
- * This method does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getJavaFileContent(IPackageFragment, String)
- *
- * @param superclassName
- * @param className
- * @return String method stubs string
- */
- private String getMethodStubs(String superclassName, String className) {
- StringBuffer sb = new StringBuffer();
- IJavaProject javaProj = JemProjectUtilities.getJavaProject(getTargetProject());
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.MAIN_METHOD)) {
- // Add main method
- sb.append(MAIN_METHOD);
- sb.append(lineSeparator);
- sb.append(TODO_COMMENT);
- sb.append(lineSeparator);
- sb.append(TAB + CLOSE_BRA);
- sb.append(lineSeparator);
- sb.append(lineSeparator);
- }
-
- IType superClassType = null;
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.CONSTRUCTOR) || model.getBooleanProperty(INewJavaClassDataModelProperties.ABSTRACT_METHODS)) {
- // Find super class type
- try {
- superClassType = javaProj.findType(superclassName);
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- }
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.CONSTRUCTOR)) {
- // Implement constructors from superclass
- try {
- if (superClassType != null) {
- IMethod[] methods = superClassType.getMethods();
- for (int j = 0; j < methods.length; j++) {
- if (methods[j].isConstructor() && !Flags.isPrivate(methods[j].getFlags())) {
- String methodStub = getMethodStub(methods[j], superclassName, className);
- sb.append(methodStub);
- }
- }
- }
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- }
- // Add unimplemented methods defined in the interfaces list
- if (model.getBooleanProperty(INewJavaClassDataModelProperties.ABSTRACT_METHODS) && superClassType != null) {
- String methodStub = getUnimplementedMethodsFromSuperclass(superClassType, className);
- if (methodStub != null && methodStub.trim().length() > 0)
- sb.append(methodStub);
- methodStub = getUnimplementedMethodsFromInterfaces(superClassType, className, javaProj);
- if (methodStub != null && methodStub.trim().length() > 0)
- sb.append(methodStub);
- }
- // Add any user defined method stubs
- if (superClassType != null) {
- String userDefined = getUserDefinedMethodStubs(superClassType);
- if (userDefined != null && userDefined.trim().length() > 0)
- sb.append(userDefined);
- }
- // Return the methods string
- return sb.toString();
- }
-
- /**
- * This method is intended for internal use only. This will retrieve method stubs for
- * unimplemented methods in the superclass that will need to be created in the new class.
- * This method does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getMethodStubs(String, String)
- *
- * @param superClassType
- * @param className
- * @return String unimplemented methods defined in superclass
- */
- private String getUnimplementedMethodsFromSuperclass(IType superClassType, String className) {
- StringBuffer sb = new StringBuffer();
- try {
- // Implement abstract methods from superclass
- IMethod[] methods = superClassType.getMethods();
- for (int j = 0; j < methods.length; j++) {
- IMethod method = methods[j];
- int flags = method.getFlags();
- // Add if the method is abstract, not private or static, and the option is selected in data model
- if ((Flags.isAbstract(flags) && !Flags.isStatic(flags) && !Flags.isPrivate(flags)) || implementImplementedMethod(methods[j])) {
- String methodStub = getMethodStub(methods[j], superClassType.getFullyQualifiedName(), className);
- sb.append(methodStub);
- }
- }
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- // Return method stubs string
- return sb.toString();
- }
-
- /**
- * This method is intended for internal use only. This will retrieve method stubs for
- * unimplemented methods defined in the interfaces that will need to be created in the new class.
- * This method does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getMethodStubs(String, String)
- *
- * @param superClassType
- * @param className
- * @param javaProj
- * @return String unimplemented methods defined in interfaces
- */
- private String getUnimplementedMethodsFromInterfaces(IType superClassType, String className, IJavaProject javaProj) {
- StringBuffer sb = new StringBuffer();
- try {
- // Implement defined methods from interfaces
- List interfaces = (List) model.getProperty(INewJavaClassDataModelProperties.INTERFACES);
- if (interfaces != null) {
- for (int i = 0; i < interfaces.size(); i++) {
- String qualifiedClassName = (String) interfaces.get(i);
- IType interfaceType = javaProj.findType(qualifiedClassName);
- IMethod[] methodArray = interfaceType.getMethods();
- // Make sure the method isn't already defined in the heirarchy
- for (int j = 0; j < methodArray.length; j++) {
- if (isMethodImplementedInHierarchy(methodArray[j], superClassType))
- continue;
- String methodStub = getMethodStub(methodArray[j], qualifiedClassName, className);
- sb.append(methodStub);
- }
- }
- }
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- // Return method stubs string
- return sb.toString();
- }
-
- /**
- * This method is intended for internal use only. Checks to see if the passed type name
- * is of a primitive type. This method does not accept null. It will not return null.
- * @see Signature#getElementType(java.lang.String)
- *
- * @param typeName
- * @return boolean is type Primitive?
- */
- private boolean isPrimitiveType(String typeName) {
- char first = Signature.getElementType(typeName).charAt(0);
- return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
- }
-
- /**
- * This method is intended for internal use only. This will add import statements for the specified
- * type if it is determined to be necessary. This does accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getMethodStub(IMethod, String, String)
- *
- * @param refTypeSig
- * @param declaringType
- * @return String type signature
- * @throws JavaModelException
- */
- private String resolveAndAdd(String refTypeSig, IType declaringType) throws JavaModelException {
- String resolvedTypeName = JavaModelUtil.getResolvedTypeName(refTypeSig, declaringType);
- // Could type not be resolved and is import statement missing?
- if (resolvedTypeName != null && !importStatements.contains(resolvedTypeName) && !resolvedTypeName.startsWith("java.lang")) { //$NON-NLS-1$
- importStatements.add(resolvedTypeName);
- }
- return Signature.toString(refTypeSig);
- }
-
- /**
- * This method is intended for internal use only. This will use the predefined tokens to generate the
- * actual method stubs. This method does not accept null parameters. It will not return null.
- *
- * @param method
- * @param superClassName
- * @param className
- * @return String method stub
- */
- private String getMethodStub(IMethod method, String superClassName, String className) {
- StringBuffer sb = new StringBuffer();
- try {
- IType parentType = method.getDeclaringType();
- String name = method.getElementName();
- String[] paramTypes = method.getParameterTypes();
- String[] paramNames = method.getParameterNames();
- String[] exceptionTypes = method.getExceptionTypes();
-
- // Parameters String
- String paramString = EMPTY_STRING;
- int nP = paramTypes.length;
- for (int i = 0; i < nP; i++) {
- String type = paramTypes[i];
- // update import statements
- if (!isPrimitiveType(type)) {
- type = resolveAndAdd(type, parentType);
- } else {
- type = Signature.toString(type);
- }
-
- int index = type.lastIndexOf(DOT);
- if (index != -1)
- type = type.substring(index + 1);
- paramString += type + SPACE + paramNames[i];
- if (i < nP - 1)
- paramString += COMMA + SPACE;
- }
- // Java doc
- sb.append("\t/* (non-Java-doc)"); //$NON-NLS-1$
- sb.append(lineSeparator);
- sb.append("\t * @see "); //$NON-NLS-1$
- sb.append(superClassName + POUND + name + OPEN_PAR);
- sb.append(paramString);
- sb.append(CLOSE_PAR);
- sb.append(lineSeparator);
- sb.append("\t */"); //$NON-NLS-1$
- sb.append(lineSeparator);
- // access
- sb.append(TAB);
- if (Flags.isPublic(method.getFlags()))
- sb.append(PUBLIC);
- else if (Flags.isProtected(method.getFlags()))
- sb.append(PROTECTED);
- else if (Flags.isPrivate(method.getFlags()))
- sb.append(PRIVATE);
- String returnType = null;
- if (method.isConstructor()) {
- sb.append(className);
- } else {
- // return type
- returnType = method.getReturnType();
- if (!isPrimitiveType(returnType)) {
- returnType = resolveAndAdd(returnType, parentType);
- } else {
- returnType = Signature.toString(returnType);
- }
- int idx = returnType.lastIndexOf(DOT);
- if (idx == -1)
- sb.append(returnType);
- else
- sb.append(returnType.substring(idx + 1));
- sb.append(SPACE);
- // name
- sb.append(name);
- }
- // Parameters
- sb.append(OPEN_PAR + paramString + CLOSE_PAR);
- // exceptions
- int nE = exceptionTypes.length;
- if (nE > 0) {
- sb.append(SPACE + THROWS);
- for (int i = 0; i < nE; i++) {
- String type = exceptionTypes[i];
- if (!isPrimitiveType(type)) {
- type = resolveAndAdd(type, parentType);
- } else {
- type = Signature.toString(type);
- }
- int index = type.lastIndexOf(DOT);
- if (index != -1)
- type = type.substring(index + 1);
- sb.append(type);
- if (i < nE - 1)
- sb.append(COMMA + SPACE);
- }
- }
- sb.append(SPACE + OPEN_BRA);
- sb.append(lineSeparator);
- if (method.isConstructor()) {
- sb.append(TAB + TAB + SUPER + OPEN_PAR);
- for (int i = 0; i < nP; i++) {
- sb.append(paramNames[i]);
- if (i < nP - 1)
- sb.append(COMMA + SPACE);
- }
- sb.append(CLOSE_PAR + SEMICOLON);
- sb.append(lineSeparator);
- } else {
- String methodBody = getMethodBody(method, returnType);
- sb.append(methodBody);
- }
- sb.append(TAB + CLOSE_BRA);
- sb.append(lineSeparator);
- sb.append(lineSeparator);
- } catch (JavaModelException e) {
- Logger.getLogger().log(e);
- }
- return sb.toString();
- }
-
- /**
- * This method is intended for internal use only. It checks to see whether or not the
- * method is already implemented in the class heirarchy.
- * It does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getUnimplementedMethodsFromInterfaces(IType, String, IJavaProject)
- *
- * @param method
- * @param superClass
- * @return boolean is method already in heirarchy?
- */
- private boolean isMethodImplementedInHierarchy(IMethod method, IType superClass) {
- boolean ret = false;
- IMethod foundMethod = findMethodImplementationInHierarchy(method, superClass);
- // if the method exists and the property is set on the data model, then return true
- if (foundMethod != null && foundMethod.exists() && !implementImplementedMethod(method))
- ret = true;
- return ret;
- }
-
- /**
- * This method is intended for internal use only. This will recursively check the supertype heirarchy for
- * the passed in method. This will not accept null parameters. It will return null if the method does
- * not already exist in the heirarchy.
- * @see NewJavaClassOperation#isMethodImplementedInHierarchy(IMethod, IType)
- *
- * @param method
- * @param superClass
- * @return IMethod the method from the heirarchy
- */
- private IMethod findMethodImplementationInHierarchy(IMethod method, IType superClass) {
- IMethod implementedMethod = null;
- try {
- if (superClass != null && superClass.exists()) {
- ITypeHierarchy tH = superClass.newSupertypeHierarchy(new NullProgressMonitor());
- implementedMethod = findMethodImplementationInHierarchy(tH, superClass, method.getElementName(), method.getParameterTypes(), method.isConstructor());
- }
- } catch (JavaModelException e) {
- //Ignore
- }
- return implementedMethod;
- }
-
- /**
- * This method is intended for internal use only. This will recursively check the supertype heirarchy for
- * the passed in method. This will not accept null parameters. It will return null if the method does
- * not already exist in the heirarchy.
- * @see NewJavaClassOperation#findMethodImplementationInHierarchy(IMethod, IType)
- * @see JavaModelUtil#findMethodImplementationInHierarchy(ITypeHierarchy, IType, String, String[], boolean)
- *
- * @param tH
- * @param thisType
- * @param methodName
- * @param parameterTypes
- * @param isConstructor
- * @return IMethod
- * @throws JavaModelException
- */
- private IMethod findMethodImplementationInHierarchy(ITypeHierarchy tH, IType thisType, String methodName, String parameterTypes[], boolean isConstructor) throws JavaModelException {
- IMethod found = JavaModelUtil.findMethod(methodName, parameterTypes, isConstructor, thisType);
- // If method exists make sure it is not abstract
- if (found != null && !Flags.isAbstract(found.getFlags())) {
- return found;
- }
- // Check recursively
- return JavaModelUtil.findMethodImplementationInHierarchy(tH, thisType, methodName, parameterTypes, isConstructor);
- }
-
- /**
- * Subclasses may extend this method to provide their own specific method body definitions.
- * The default implementation is to add a todo, and to return the appropriate type.
- * This method does not accept null parameters. It will not return null.
- * @see NewJavaClassOperation#getMethodStub(IMethod, String, String)
- *
- * @param method
- * @param returnType
- * @return String method body
- */
- protected String getMethodBody(IMethod method, String returnType) {
- // Add a todo comment
- String body = TODO_COMMENT;
- body += lineSeparator;
- // Add the appropriate default return type
- if (returnType == null || returnType.equals(VOID))
- return body;
- if (returnType.equals(INT))
- body += RETURN_0;
- else if (returnType.equals(BOOLEAN))
- body += RETURN_FALSE;
- else
- body += RETURN_NULL;
- body += lineSeparator;
- // Return the method body
- return body;
- }
-
- /**
- * Subclasses may extend this method to provide their own user defined method stubs. The
- * default implementation to just return an empty string. This method will not accept
- * null parameter. It will not return null.
- * @see NewJavaClassOperation#getMethodStubs(String, String)
- *
- * @param superClassType
- * @return String user defined methods
- */
- protected String getUserDefinedMethodStubs(IType superClassType) {
- return EMPTY_STRING;
- }
-
- /**
- * Subclasses may extend this method to provide their own specialized return on which nonimplemented
- * methods to implement. This does not accept a null parameter. This will not return null.
- * The default implementation is to always return false.
- *
- * @param method
- * @return boolean should implement method?
- */
- protected boolean implementImplementedMethod(IMethod method) {
- return false;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/UpdateJavaBuildPathOperation.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/UpdateJavaBuildPathOperation.java
deleted file mode 100644
index f80182b27..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/UpdateJavaBuildPathOperation.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.common.operations;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection;
-import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement;
-import org.eclipse.wst.common.frameworks.internal.DoNotUseMeThisWillBeDeletedPost15;
-import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException;
-import org.eclipse.wst.common.frameworks.internal.operations.IHeadlessRunnableWithProgress;
-
-/**
- * {@link DoNotUseMeThisWillBeDeletedPost15}
- *
- * @deprecated This should no longer be necessary because of the new EAR & Web Lib classpath
- * containers
- */
-public class UpdateJavaBuildPathOperation implements IHeadlessRunnableWithProgress {
- protected IJavaProject javaProject;
- protected ClassPathSelection classPathSelection;
- // All the Java build path entries created by the classpath selection
- protected Set allClasspathEntries;
- protected List allUnselectedClasspathEntries;
-
- /**
- * UpdateJavaBuildPathOperation constructor comment.
- */
- public UpdateJavaBuildPathOperation(IJavaProject aJavaProject, ClassPathSelection aClassPathSelection) {
- super();
- javaProject = aJavaProject;
- classPathSelection = aClassPathSelection;
- allClasspathEntries = new HashSet();
- IClasspathEntry[] classpathEntry = aClassPathSelection.getClasspathEntriesForSelected();
- if (classpathEntry != null)
- allClasspathEntries.addAll(Arrays.asList(classpathEntry));
- }
-
- /**
- * UpdateJavaBuildPathOperation constructor comment.
- */
- public UpdateJavaBuildPathOperation(IJavaProject aJavaProject, ClassPathSelection selected, ClassPathSelection unselected) {
- super();
- javaProject = aJavaProject;
- classPathSelection = selected;
- allClasspathEntries = new HashSet();
- if (selected != null && !selected.getClasspathElements().isEmpty())
- allClasspathEntries.addAll(Arrays.asList(selected.getClasspathEntriesForSelected()));
-
- allUnselectedClasspathEntries = new ArrayList();
- if (unselected != null && !unselected.getClasspathElements().isEmpty())
- allUnselectedClasspathEntries.addAll(unselected.getClasspathElements());
- }
-
- public UpdateJavaBuildPathOperation(IJavaProject aJavaProject, ClassPathSelection selected, List unselected) {
- super();
- javaProject = aJavaProject;
- classPathSelection = selected;
- allClasspathEntries = new HashSet();
- if (selected != null && !selected.getClasspathElements().isEmpty())
- allClasspathEntries.addAll(Arrays.asList(selected.getClasspathEntriesForSelected()));
-
- allUnselectedClasspathEntries = new ArrayList();
- if (unselected != null && !unselected.isEmpty())
- allUnselectedClasspathEntries.addAll(unselected);
- }
-
- protected void ensureClasspathEntryIsExported(List cp, IClasspathEntry entry) {
- if (entry.isExported())
- return;
- int index = getIndex(cp, entry);
- IClasspathEntry newEntry = null;
- switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_PROJECT :
- newEntry = JavaCore.newProjectEntry(entry.getPath(), true);
- break;
- case IClasspathEntry.CPE_LIBRARY :
- newEntry = JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), true);
- break;
- case IClasspathEntry.CPE_VARIABLE :
- newEntry = JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath());
- default :
- break;
- }
- if (entry != null)
- cp.set(index, newEntry);
- }
-
- protected IClasspathEntry ensureElementInList(List cp, ClasspathElement element, IClasspathEntry predecessor) {
- IClasspathEntry addedEntry = null;
- // The element might have multiple entries in the case of
- // the imported_classes.jar file
- IClasspathEntry[] cpEntries = element.newClasspathEntries();
- if (cpEntries == null || cpEntries.length == 0)
- // indicates an invalid entry
- return null;
-
- int predecessorPos = predecessor == null ? -1 : getIndex(cp, predecessor);
- addedEntry = cpEntries[0];
- // Ensure that the first item is in the list, and follows
- // the predecessor if specified; preserve existing items in
- // the case of source attachments
- int pos = getIndex(cp, addedEntry);
- if (pos == -1) {
- if (predecessorPos == -1)
- cp.add(addedEntry);
- else
- cp.add(predecessorPos + 1, addedEntry);
- } else {
- addedEntry = (IClasspathEntry) cp.get(pos);
- if (pos < predecessorPos) {
- cp.remove(addedEntry);
- cp.add(predecessorPos, addedEntry);
- }
- }
- ensureClasspathEntryIsExported(cp, addedEntry);
-
- // Remove and add so we can ensure the proper order; this
- // is the case of the imported_classes.jar; we always want it
- // directly after the project
- for (int i = 1; i < cpEntries.length; i++) {
- int index = getIndex(cp, cpEntries[i]);
- if (index != -1) {
- addedEntry = (IClasspathEntry) cp.get(index);
- cp.remove(index);
- } else
- addedEntry = cpEntries[i];
- pos = getIndex(cp, cpEntries[0]);
- cp.add(pos + 1, addedEntry);
- }
- return addedEntry;
- }
-
- protected int getIndex(List cp, IClasspathEntry entry) {
- for (int i = 0; i < cp.size(); i++) {
- IClasspathEntry elmt = (IClasspathEntry) cp.get(i);
- if (elmt.getPath().equals(entry.getPath()))
- return i;
- }
- return -1;
- }
-
- protected void ensureElementNotInList(List cp, ClasspathElement element) {
- IClasspathEntry[] cpEntries = element.newClasspathEntries();
- if (cpEntries == null || cpEntries.length == 0)
- return;
- for (int i = 0; i < cpEntries.length; i++) {
- if (allClasspathEntries.contains(cpEntries[i]))
- // This may be included indirectly by a transitive dependency
- continue;
- int index = getIndex(cp, cpEntries[i]);
- if (index != -1)
- cp.remove(index);
- }
- }
-
- protected void ensureRemoveElementInList(List cp, ClasspathElement element) {
- IClasspathEntry[] cpEntries = element.newClasspathEntries();
- if (cpEntries == null || cpEntries.length == 0)
- return;
- for (int i = 0; i < cpEntries.length; i++) {
- if (cp.contains(cpEntries[i])) {
- int index = getIndex(cp, cpEntries[i]);
- if (index != -1)
- cp.remove(index);
- }
- }
- }
-
- /**
- * Runs this operation. Progress should be reported to the given progress monitor. This method
- * is usually invoked by an <code>IRunnableContext</code>'s<code>run</code> method, which
- * supplies the progress monitor. A request to cancel the operation should be honored and
- * acknowledged by throwing <code>InterruptedException</code>.
- *
- * @param monitor
- * the progress monitor to use to display progress and receive requests for
- * cancelation
- * @exception InvocationTargetException
- * if the run method must propagate a checked exception, it should wrap it inside
- * an <code>InvocationTargetException</code>; runtime exceptions are
- * automatically wrapped in an <code>InvocationTargetException</code> by the
- * calling context
- * @exception InterruptedException
- * if the operation detects a request to cancel, using
- * <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
- * <code>InterruptedException</code>
- *
- * @see IRunnableContext#run
- */
- public void run(org.eclipse.core.runtime.IProgressMonitor monitor) throws java.lang.reflect.InvocationTargetException, InterruptedException {
- try {
- String[] prevRequiredProjects = javaProject.getRequiredProjectNames();
- List cp = new ArrayList(Arrays.asList(javaProject.getRawClasspath()));
- List classpathElements = classPathSelection.getClasspathElements();
- IClasspathEntry predecessor = null;
- IClasspathEntry result = null;
- for (int i = 0; i < classpathElements.size(); i++) {
- ClasspathElement element = (ClasspathElement) classpathElements.get(i);
- if (element.isSelected()) {
- result = ensureElementInList(cp, element, predecessor);
- if (result != null)
- predecessor = result;
- } else
- ensureElementNotInList(cp, element);
- }
- filterUnselectedEntries(cp);
- IClasspathEntry[] newCp = ((IClasspathEntry[]) cp.toArray(new IClasspathEntry[cp.size()]));
- javaProject.setRawClasspath(newCp, monitor);
- updateRequiredProjects(javaProject, prevRequiredProjects, new SubProgressMonitor(monitor, 1));
- } catch (Exception ex) {
- throw new WFTWrappedException(ex);
- }
- }
-
- private void filterUnselectedEntries(List cp) {
- if (allUnselectedClasspathEntries != null) {
- for (int i = 0; i < allUnselectedClasspathEntries.size(); i++) {
- ClasspathElement element = (ClasspathElement) allUnselectedClasspathEntries.get(i);
- ensureRemoveElementInList(cp, element);
- }
- }
- }
-
- protected void updateRequiredProjects(IJavaProject jproject, String[] prevRequiredProjects, IProgressMonitor monitor) throws CoreException {
- String[] newRequiredProjects = jproject.getRequiredProjectNames();
-
- ArrayList prevEntries = new ArrayList(Arrays.asList(prevRequiredProjects));
- ArrayList newEntries = new ArrayList(Arrays.asList(newRequiredProjects));
-
- IProject proj = jproject.getProject();
- IProjectDescription projDesc = proj.getDescription();
-
- ArrayList newRefs = new ArrayList();
- IProject[] referencedProjects = projDesc.getReferencedProjects();
- for (int i = 0; i < referencedProjects.length; i++) {
- String curr = referencedProjects[i].getName();
- if (newEntries.remove(curr) || !prevEntries.contains(curr)) {
- newRefs.add(referencedProjects[i]);
- }
- }
- IWorkspaceRoot root = proj.getWorkspace().getRoot();
- for (int i = 0; i < newEntries.size(); i++) {
- String curr = (String) newEntries.get(i);
- newRefs.add(root.getProject(curr));
- }
- projDesc.setReferencedProjects((IProject[]) newRefs.toArray(new IProject[newRefs.size()]));
- proj.setDescription(projDesc, monitor);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/DefaultWSDLServiceHelper.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/DefaultWSDLServiceHelper.java
deleted file mode 100644
index 6e449ca54..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/DefaultWSDLServiceHelper.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 Feb 21, 2005
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author cbridgha
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class DefaultWSDLServiceHelper implements WSDLServiceHelper {
-
- /**
- *
- */
- public DefaultWSDLServiceHelper() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getPortName(java.lang.Object)
- */
- public String getPortName(Object port) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getServicePorts(java.lang.Object)
- */
- public Map getServicePorts(Object aService) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getServiceNamespaceURI(java.lang.Object)
- */
- public String getServiceNamespaceURI(Object aService) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getServiceDefinitionLocation(org.eclipse.emf.ecore.EObject)
- */
- public Object getServiceDefinitionLocation(EObject aService) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getPortBindingNamespaceURI(java.lang.Object)
- */
- public String getPortBindingNamespaceURI(Object aPort) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getServiceLocalPart(java.lang.Object)
- */
- public String getServiceLocalPart(Object aService) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getServiceQName(java.lang.Object)
- */
- public Object getServiceQName(Object aService) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getDefinitionServices(java.lang.Object)
- */
- public Map getDefinitionServices(Object aDefinition) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getWSDLDefinition(java.lang.String)
- */
- public Object getWSDLDefinition(String wsdlURL) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getWSDLDefinition(org.eclipse.emf.ecore.resource.Resource)
- */
- public Object getWSDLDefinition(Resource wsdlResource) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper#getWsdlServicesFromWsilFile(org.eclipse.core.resources.IFile)
- */
- public List getWsdlServicesFromWsilFile(IFile wsil) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isService(Object aService) {
- // TODO Auto-generated method stub
- return false;
- }
- public boolean isWSDLResource(Object aResource) {
- // TODO Auto-generated method stub
- return false;
- }
- public boolean isDefinition(Object aDefinition) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public List get13ServiceRefs(EObject j2eeObject) {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtManager.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtManager.java
deleted file mode 100644
index 369c7b9b1..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.webservices;
-
-public class WSDLServiceExtManager {
- public static WSDLServiceHelper extension;
-
- public static WSDLServiceHelper getServiceHelper() {
- return extension;
- }
-
- public static void registerWSDLServiceHelper(WSDLServiceHelper ext) {
- extension = ext;
- }
-
- public static void removeWSDLServiceHelper() {
- extension = null;
- }
-
- public WSDLServiceExtManager() {
- super();
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtensionRegistry.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtensionRegistry.java
deleted file mode 100644
index c006c96e5..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceExtensionRegistry.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Oct 29, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-
-/**
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class WSDLServiceExtensionRegistry extends RegistryReader {
-
- static final String EXTENSION_NAME = "WSDLServiceHelper"; //$NON-NLS-1$
- static final String ELEMENT_WSDL_HELPER = "wsdlHelper"; //$NON-NLS-1$
- static final String WSDL_HELPER_CLASS = "helperClass"; //$NON-NLS-1$
- private static WSDLServiceExtensionRegistry INSTANCE = null;
-
- public WSDLServiceExtensionRegistry() {
- super(J2EEPlugin.PLUGIN_ID, EXTENSION_NAME);
- }
-
- public static WSDLServiceExtensionRegistry getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new WSDLServiceExtensionRegistry();
- INSTANCE.readRegistry();
- }
- return INSTANCE;
- }
-
- /**
- * readElement() - parse and deal w/ an extension like: <earModuleExtension extensionClass =
- * "com.ibm.etools.web.plugin.WebModuleExtensionImpl"/>
- */
- public boolean readElement(IConfigurationElement element) {
- if (!element.getName().equals(ELEMENT_WSDL_HELPER))
- return false;
- WSDLServiceHelper extension = null;
- try {
- extension = (WSDLServiceHelper) element.createExecutableExtension(WSDL_HELPER_CLASS);
- } catch (Throwable e) {
- //Ignore
- }
- if (extension != null)
- addModuleExtension(extension);
- else // Register default do nothing helper......
- addModuleExtension(new DefaultWSDLServiceHelper());
- return true;
- }
-
-
- private static void addModuleExtension(WSDLServiceHelper ext) {
- WSDLServiceExtManager.registerWSDLServiceHelper(ext);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceHelper.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceHelper.java
deleted file mode 100644
index be9521778..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WSDLServiceHelper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 Feb 21, 2005
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author cbridgha
- *
- * This interface is intended to expand the visibility of wsdl api, without a direct dependency
- */
-public interface WSDLServiceHelper {
-
- public static final String WSIL_EXT = "wsil"; //$NON-NLS-1$
-
- public String getPortName(Object port);
- public Map getServicePorts(Object aService);
- public String getServiceNamespaceURI(Object aService);
- public Object getServiceDefinitionLocation(EObject aService);
- public String getPortBindingNamespaceURI(Object aPort);
- public String getServiceLocalPart(Object aService);
- public Object getServiceQName(Object aService);
- public Map getDefinitionServices(Object aDefinition);
- public Object getWSDLDefinition(String wsdlURL);
- public Object getWSDLDefinition(Resource wsdlResource);
- public List getWsdlServicesFromWsilFile(IFile wsil);
- public boolean isService(Object aService);
- public boolean isWSDLResource(Object aResource);
- public boolean isDefinition(Object aDefinition);
- public List get13ServiceRefs(EObject j2eeObject);
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServiceClientGenerator.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServiceClientGenerator.java
deleted file mode 100644
index 5797b899e..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServiceClientGenerator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Apr 28, 2004
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
-
-
-/**
- * Extension for generating web service clients
- */
-public abstract class WebServiceClientGenerator {
-
- public static final String GENERIC_J2EE_CONTAINER = J2EECommonMessages.WebServiceClientGenerator_UI_0;
-
- private List runtime = null;
-
- /**
- * Generates Web service client artifacts based on information obatined from the dataModel
- * (wsdlURL, serviceQName, outputWSDLFilePathName, projectName, shouldDeploy) After generating
- * the Web service client artifacts, sets the following on the dataModel: serviceInterfaceName,
- * serviceEndpointInterfaceName, didGenDescriptors
- *
- * @return Status for results
- */
- public abstract IStatus genWebServiceClientArtifacts(WebServicesClientDataHelper dataModel);
-
- public void setRuntime(List serverTargets) {
- runtime = serverTargets;
- }
-
- public List getServerTargets() {
- if (runtime == null)
- runtime = new ArrayList();
- return runtime;
- }
-
- public boolean isRuntimeSupported(String serverTargetID) {
- return getServerTargets().contains(serverTargetID);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataHelper.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataHelper.java
deleted file mode 100644
index 909295edb..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataHelper.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Apr 26, 2004
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-
-/**
- * WebServicesClientDataHelper Interface Extension - For use in generating Web Service Clients by
- * sharing data between J2EE operations and web services operations
- */
-public interface WebServicesClientDataHelper {
-
- /**
- * @return the URL for the associated original WSDL file referenced by the client
- */
- public String getWSDLUrl();
-
- /**
- * @return the QName of form http://someNamespace:someLocalPart for the associated web service
- * for the client
- */
- public String getServiceQName();
-
- /**
- * @return the name of the target project for the web service client
- */
- public String getProjectName();
-
- /**
- * @return the URI for the fileName path for the copied WSDL file into the client project
- */
- public String getOutputWSDLFileName();
-
- /**
- * @return the qualified classname of the generated Service Interface
- */
- public String getServiceInterfaceName();
-
- /**
- * @return the qualified classname of the generated Service Endpoint Interface
- */
- public String[] getServiceEndpointInterfaceNames();
-
- /**
- * @return should generate code for deployment?
- */
- public boolean shouldDeploy();
-
- /**
- * @return whether the extension generated the descriptors or not
- */
- public boolean shouldGenDescriptors();
-
- /**
- * Set the SEI classname for the web service client
- */
- public void setServiceInterfaceName(String name);
-
- /**
- * Set the SI classname for the web service client
- */
- public void setServiceEndpointInterfaceNames(String[] names);
-
- /**
- * Set whether descriptors were generated
- */
- public void setDidGenDescriptors(boolean b);
-}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataRegistry.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataRegistry.java
deleted file mode 100644
index 67160f679..000000000
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/webservices/WebServicesClientDataRegistry.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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 Apr 26, 2004
- */
-package org.eclipse.jst.j2ee.internal.webservices;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
-
-/**
- * Read the WebServicesClientDataExtensions
- */
-public class WebServicesClientDataRegistry extends RegistryReader {
-
- private static WebServicesClientDataRegistry INSTANCE = null;
- public static final String WS_CLIENT_EXTENSION_POINT = "WebServiceClientGenerator"; //$NON-NLS-1$
- public static final String GENERATOR = "generator"; //$NON-NLS-1$
- public static final String CLASS_NAME = "className"; //$NON-NLS-1$
- public static final String SERVER_TARGET = "serverTarget"; //$NON-NLS-1$
- public static final String RUNTIME = "runtime"; //$NON-NLS-1$
- private List wsClientDataExtensions = null;
-
- /**
- * Default constructor
- */
- public WebServicesClientDataRegistry() {
- super(J2EEPlugin.PLUGIN_ID, WS_CLIENT_EXTENSION_POINT);
- }
-
- public static WebServicesClientDataRegistry getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new WebServicesClientDataRegistry();
- INSTANCE.readRegistry();
- }
- return INSTANCE;
- }
-
- /**
- * @see org.eclipse.wst.common.frameworks.internal.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- if (!element.getName().equals(GENERATOR))
- return false;
- // Get the class specified in the extension point
- WebServiceClientGenerator helper = null;
- try {
- helper = (WebServiceClientGenerator) element.createExecutableExtension(CLASS_NAME);
- // get server target runtimes
- IConfigurationElement[] runtimes = element.getChildren(RUNTIME);
- List runtimeList = new ArrayList();
- for (int i = 0; i < runtimes.length; i++) {
- IConfigurationElement runtime = runtimes[i];
- String serverTarget = runtime.getAttribute(SERVER_TARGET);
- runtimeList.add(serverTarget);
- }
- helper.setRuntime(runtimeList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- // Add data helper class to registry extensions list
- if (helper != null) {
- getWSClientGeneratorExtensions().add(helper);
- return true;
- }
- return false;
- }
-
- public List getWSClientGeneratorExtensions() {
- if (wsClientDataExtensions == null)
- wsClientDataExtensions = new ArrayList();
- return wsClientDataExtensions;
- }
-}

Back to the top