diff options
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org')
239 files changed, 0 insertions, 33835 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/common/jdt/internal/integration/ui/WTPUIWorkingCopyManager.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/common/jdt/internal/integration/ui/WTPUIWorkingCopyManager.java deleted file mode 100644 index 686b14e15..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/common/jdt/internal/integration/ui/WTPUIWorkingCopyManager.java +++ /dev/null @@ -1,474 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.common.jdt.internal.integration.ui; - - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider; -import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput; -import org.eclipse.jdt.ui.IWorkingCopyManager; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jst.common.jdt.internal.integration.WTPWorkingCopyManager; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.wst.common.frameworks.internal.SaveFailedException; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * Insert the type's description here. Creation date: (4/25/2001 7:05:36 PM) - * - * @author: Administrator - */ -public class WTPUIWorkingCopyManager extends WTPWorkingCopyManager { - private IWorkingCopyManager javaWorkingCopyManager; - private ICompilationUnitDocumentProvider cuDocumentProvider; - private HashMap editorInputs; - private CoreException lastError; - - /** - * WTPUIWorkingCopyManager constructor comment. - */ - public WTPUIWorkingCopyManager() { - super(); - cuDocumentProvider = JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); - javaWorkingCopyManager = JavaUI.getWorkingCopyManager(); - } - - protected void syncConnect(final IEditorInput input, final ICompilationUnit cu) throws CoreException { - Display d = Display.getCurrent(); - if (d != null) { - lastError = null; - d.syncExec(new Runnable() { - public void run() { - try { - connect(input, cu); - } catch (CoreException e) { - lastError = e; - } - } - }); - } else - connect(input, cu); - if (lastError != null) - throw lastError; - } - - /** - * Connect the CompilationUnitDocumentProvider to the - * - * @input and connect the annotation model from the provider to the IDocument of the - * @input. - */ - protected void connect(IEditorInput input, ICompilationUnit cu) throws CoreException { - if (input != null && javaWorkingCopyManager != null && cuDocumentProvider != null ) { - javaWorkingCopyManager.connect(input); - getEditorInputs().put(cu, input); - IDocument doc = cuDocumentProvider.getDocument(input); - if (doc != null && cuDocumentProvider.getAnnotationModel(input)!= null) - cuDocumentProvider.getAnnotationModel(input).connect(doc); - } - } - - protected void revertWorkingCopies() { - if (getEditorInputs().isEmpty()) - return; - Iterator it = getEditorInputs().values().iterator(); - IEditorInput input; - while (it.hasNext()) { - input = (IEditorInput) it.next(); - revert(input); - } - } - - /** - * Disonnect the CompilationUnitDocumentProvider from the - * - * @input and disconnect the annotation model from the provider from the IDocument of the - * @input. - */ - protected void disconnect(IEditorInput input) { - IDocument doc = cuDocumentProvider.getDocument(input); - cuDocumentProvider.getAnnotationModel(input).disconnect(doc); - javaWorkingCopyManager.disconnect(input); - } - - protected void revert(IEditorInput input) { - try { - cuDocumentProvider.resetDocument(input); - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - IDocument doc = cuDocumentProvider.getDocument(input); - IAnnotationModel model = cuDocumentProvider.getAnnotationModel(input); - - if (model instanceof AbstractMarkerAnnotationModel) { - AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model; - markerModel.resetMarkers(); - } - model.disconnect(doc); - javaWorkingCopyManager.disconnect(input); - } - - protected void disconnectEditorInputs() { - Iterator it = getEditorInputs().values().iterator(); - IEditorInput input; - while (it.hasNext()) { - input = (IEditorInput) it.next(); - disconnect(input); - } - } - - protected void discardExistingCompilationUnits() { - if (getEditorInputs().isEmpty()) - return; - Iterator it = getEditorInputs().values().iterator(); - IEditorInput input; - while (it.hasNext()) { - input = (IEditorInput) it.next(); - disconnect(input); - } - } - - public Set getAffectedFiles() { - Set aSet = new HashSet(); - Iterator it = getEditorInputs().keySet().iterator(); - ICompilationUnit unit = null; - IResource resource = null; - while (it.hasNext()) { - unit = (ICompilationUnit) it.next(); - if (isDirty(unit)) { - try { - resource = unit.getUnderlyingResource(); - } catch (JavaModelException ignore) { - continue; - } - if (resource instanceof IFile) - aSet.add(resource); - } - } - return aSet; - } - - protected IEditorInput getEditorInput(ICompilationUnit cu) { - IEditorInput input = primGetEditorInput(cu); - if (input == null) { - try { - input = getEditorInput((IJavaElement) cu); - } catch (JavaModelException e) { - //Ignore - } - } - return input; - } - - protected IEditorInput getEditorInput(IJavaElement element) throws JavaModelException { - while (element != null) { - switch (element.getElementType()) { - case IJavaElement.COMPILATION_UNIT : { - ICompilationUnit cu = (ICompilationUnit) element; - if (cu.isWorkingCopy()) - cu = cu.getPrimary(); - IResource resource = cu.getUnderlyingResource(); - if (resource.getType() == IResource.FILE) - return new FileEditorInput((IFile) resource); - break; - } - case IJavaElement.CLASS_FILE : - return new InternalClassFileEditorInput((IClassFile) element); - } - element = element.getParent(); - } - return null; - } - - /** - * Insert the method's description here. Creation date: (4/25/2001 7:30:20 PM) - * - * @return java.util.HashMap - */ - protected java.util.HashMap getEditorInputs() { - if (editorInputs == null) - editorInputs = new HashMap(20); - return editorInputs; - } - - /** - * Returns the working copy remembered for the compilation unit encoded in the given editor - * input. Does not connect the edit model to the working copy. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if the input does - * not encode an editor input, or if there is no remembered working copy for this - * compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getExistingWorkingCopy(ICompilationUnit cu) throws CoreException { - if (cu == null || cu.isWorkingCopy()) { - return cu; - } - ICompilationUnit newCU = super.getExistingWorkingCopy(cu); - if (newCU != null) - return newCU; - IEditorInput editorInput = getEditorInput(cu); - return javaWorkingCopyManager.getWorkingCopy(editorInput); - } - - /** - * Returns the working copy remembered for the compilation unit. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if there is no - * remembered working copy for this compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws org.eclipse.core.runtime.CoreException { - if (forNewCU) - return super.getWorkingCopy(cu, forNewCU); - return primGetWorkingCopy(cu); - } - - public boolean isDirty(ICompilationUnit cu) { - if (cu == null) - return false; - IDocumentProvider p = cuDocumentProvider; - return p == null ? false : p.canSaveDocument(getEditorInput(cu)); - } - - /** - * mustSaveDocument method comment. - */ - public boolean isSaveNeeded() { - Iterator it = getEditorInputs().entrySet().iterator(); - while (it.hasNext()) { - if (cuDocumentProvider.mustSaveDocument(it.next())) - return true; - } - return false; - } - - protected void primDispose() { - super.primDispose(); - discardExistingCompilationUnits(); - editorInputs = null; - javaWorkingCopyManager = null; - } - - protected void primRevert() { - super.primRevert(); - revertWorkingCopies(); - editorInputs = null; - javaWorkingCopyManager = null; - } - - protected IEditorInput primGetEditorInput(ICompilationUnit cu) { - return (IEditorInput) getEditorInputs().get(cu); - } - - /** - * Returns the working copy remembered for the compilation unit encoded in the given editor - * input. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if the input does - * not encode an editor input, or if there is no remembered working copy for this - * compilation unit - */ - protected org.eclipse.jdt.core.ICompilationUnit primGetWorkingCopy(ICompilationUnit cu) throws CoreException { - if (cu == null) { - return cu; - } - ICompilationUnit primary = cu.getPrimary(); - ICompilationUnit newCU = getNewCompilationUnitWorkingCopy(primary); - if (newCU != null) - return newCU; - IEditorInput editorInput = primGetEditorInput(primary); - if (editorInput == null) { - editorInput = getEditorInput(cu); - syncConnect(editorInput, cu); - } - if (cu.isWorkingCopy()) - return cu; - return javaWorkingCopyManager.getWorkingCopy(editorInput); - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - protected void primSaveCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - super.primSaveCompilationUnits(null); - saveExistingCompilationUnits(monitor); - } - - protected void primSaveDocument(IEditorInput input, IDocument doc, IProgressMonitor monitor) throws CoreException { - try { - cuDocumentProvider.saveDocument(monitor, input, doc, true); // overwrite if needed - } catch (CoreException ex) { - if (!isFailedWriteFileFailure(ex)) - throw ex; - IResource resource = (IResource) input.getAdapter(IRESOURCE_CLASS); - if (resource == null || resource.getType() != IResource.FILE || !resource.getResourceAttributes().isReadOnly()) - throw ex; - - if (getSaveHandler().shouldContinueAndMakeFileEditable((IFile) resource)) - cuDocumentProvider.saveDocument(monitor, input, doc, false); - else - throw ex; - } - } - - protected void saveDocument(IEditorInput input, IProgressMonitor monitor) { - IDocument doc = cuDocumentProvider.getDocument(input); - boolean canSave = cuDocumentProvider.canSaveDocument(input); - try { - if (canSave) { - ICompilationUnit unit = javaWorkingCopyManager.getWorkingCopy(input); - synchronized (unit) { - cuDocumentProvider.aboutToChange(input); - primSaveDocument(input, doc, monitor); - } - } - } catch (CoreException e) { - WTPCommonPlugin.getDefault().getLogger().logError(e); - throw new SaveFailedException(e); - } finally { - if (canSave) - cuDocumentProvider.changed(input); - } - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - protected void saveExistingCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - if (getEditorInputs().isEmpty()) - return; - if (!validateState()) { - if (monitor != null) - monitor.setCanceled(true); - return; - } - Iterator it = getEditorInputs().entrySet().iterator(); - Map.Entry entry; - // ICompilationUnit cu; - IEditorInput input; - try { - while (it.hasNext()) { - entry = (Map.Entry) it.next(); - // cu = (ICompilationUnit) entry.getKey(); - input = (IEditorInput) entry.getValue(); - try { - saveDocument(input, null); - } finally { - disconnect(input); - } - } - } finally { - getEditorInputs().clear(); - } - } - - /** - * Call validateEdit for all read only IFiles corresponding to each WorkingCopy. - * - * @return boolean - */ - private boolean validateState() { - List readOnlyFiles = getReadOnlyModifiedFiles(); - if (readOnlyFiles != null && !readOnlyFiles.isEmpty()) { - IFile[] files = new IFile[readOnlyFiles.size()]; - readOnlyFiles.toArray(files); - IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - Object ctx = win == null ? null : win.getShell(); - IStatus status = ResourcesPlugin.getWorkspace().validateEdit(files, ctx); - return status.isOK(); - } - return true; - } - - private List getReadOnlyModifiedFiles() { - List readOnlyFiles = null; - IFile readOnlyFile = null; - Iterator it = getEditorInputs().entrySet().iterator(); - Map.Entry entry; - // ICompilationUnit cu; - IEditorInput input; - IDocumentProvider docProv = cuDocumentProvider; - while (it.hasNext()) { - readOnlyFile = null; - entry = (Map.Entry) it.next(); - // cu = (ICompilationUnit) entry.getKey(); - input = (IEditorInput) entry.getValue(); - if (docProv.canSaveDocument(input)) - readOnlyFile = getReadOnlyFile(input); - if (readOnlyFile != null) { - if (readOnlyFiles == null) - readOnlyFiles = new ArrayList(); - readOnlyFiles.add(readOnlyFile); - } - } - return readOnlyFiles; - } - - private IFile getReadOnlyFile(IEditorInput input) { - if (input instanceof IFileEditorInput) { - IFileEditorInput finput = (IFileEditorInput) input; - IFile file = finput.getFile(); - if (file.isReadOnly()) - return file; - } - return null; - } - - - protected void addDeletedCompilationUnit(ICompilationUnit cu) { - IEditorInput input = primGetEditorInput(cu); - if (input != null) - disconnect(input); - getEditorInputs().remove(cu); - super.addDeletedCompilationUnit(cu); - } - - /** - * @see com.ibm.etools.j2ee.workbench.IJ2EEWorkingCopyManager#hasWorkingCopies() - */ - public boolean hasWorkingCopies() { - return super.hasWorkingCopies() || (editorInputs != null && !editorInputs.isEmpty()); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AddModulestoEARPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AddModulestoEARPropertiesPage.java deleted file mode 100644 index 448a9f71e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AddModulestoEARPropertiesPage.java +++ /dev/null @@ -1,1357 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - * Stefan Dimov, stefan.dimov@sap.com - bugs 207826, 222651 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -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.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProperties; -import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProvider; -import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.jst.j2ee.internal.dialogs.ChangeLibDirDialog; -import org.eclipse.jst.j2ee.internal.dialogs.DependencyConflictResolveDialog; -import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.ui.DoubleCheckboxTableItem; -import org.eclipse.jst.j2ee.internal.ui.DoubleCheckboxTableViewer; -import org.eclipse.jst.j2ee.model.IEARModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.project.EarUtilities; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.j2ee.project.facet.EarFacetRuntimeHandler; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider; -import org.eclipse.jst.javaee.application.Application; -import org.eclipse.jst.jee.project.facet.EarCreateDeploymentFilesDataModelProvider; -import org.eclipse.jst.jee.project.facet.ICreateDeploymentFilesDataModelProperties; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -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.datamodel.IDataModelProvider; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - - -public class AddModulestoEARPropertiesPage implements IJ2EEDependenciesControl, Listener { - - protected final String PATH_SEPARATOR = AvailableJ2EEComponentsForEARContentProvider.PATH_SEPARATOR; - protected final IProject project; - protected final J2EEDependenciesPage propPage; - protected IVirtualComponent earComponent = null; - protected Text componentNameText; - protected Label availableModules; - protected CheckboxTableViewer availableComponentsViewer; - protected Button selectAllButton; - protected Button deselectAllButton; - protected Button projectJarButton; - protected Button externalJarButton; - protected Button addVariableButton; - protected Button changeLibPathButton; - protected Composite buttonColumn; - - protected String libDir = null; - protected String oldLibDir; - protected List j2eeComponentList = new ArrayList(); - protected List javaProjectsList = new ArrayList(); - protected List j2eeLibElementList = new ArrayList(); - protected List javaLibProjectsList = new ArrayList(); - protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS; - protected boolean isVersion5; - protected Set libsToUncheck; - protected Listener tableListener; - protected Listener labelListener; - - //[Bug 238264] the cached list of jars selected using 'add jar' or 'add external jars' - protected List<IVirtualComponent> addedJARComponents = new ArrayList<IVirtualComponent>(); - - - /** - * Constructor for AddModulestoEARPropertiesControl. - */ - public AddModulestoEARPropertiesPage(final IProject project, final J2EEDependenciesPage page) { - this.project = project; - this.propPage = page; - earComponent = ComponentCore.createComponent(project); - boolean hasEE5Facet = false; - try { - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if(facetedProject != null){ - IProjectFacetVersion facetVersion = facetedProject.getProjectFacetVersion(EarUtilities.ENTERPRISE_APPLICATION_FACET); - if(facetVersion.equals(EarUtilities.ENTERPRISE_APPLICATION_50)){ - hasEE5Facet = true; - } - } - } catch (CoreException e) { - Logger.getLogger().log(e); - } - - if(hasEE5Facet){ - String earDDVersion = JavaEEProjectUtilities.getJ2EEDDProjectVersion(project); - if (earDDVersion.equals(J2EEVersionConstants.VERSION_5_0_TEXT)) { - isVersion5 = true; - Application app = (Application)ModelProviderManager.getModelProvider(project).getModelObject(); - if (app != null) - oldLibDir = app.getLibraryDirectory(); - if (oldLibDir == null) oldLibDir = J2EEConstants.EAR_DEFAULT_LIB_DIR; - libDir = oldLibDir; - } - } - libsToUncheck = new HashSet(); - } - - public Composite createContents(final Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - J2EEDependenciesPage.createDescriptionComposite(composite, ManifestUIResourceHandler.EAR_Modules_Desc); - createListGroup(composite); - refresh(); - Dialog.applyDialogFont(parent); - return composite; - } - - protected void createListGroup(Composite parent) { - Composite listGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - layout.marginHeight = 0; - listGroup.setLayout(layout); - GridData gData = new GridData(GridData.FILL_BOTH); - gData.horizontalIndent = 5; - listGroup.setLayoutData(gData); - - availableModules = new Label(listGroup, SWT.NONE); - gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - availableModules.setText(J2EEUIMessages.getResourceString("AVAILABLE_J2EE_COMPONENTS")); //$NON-NLS-1$ = "Available dependent JARs:" - availableModules.setLayoutData(gData); - createTableComposite(listGroup); - } - - public boolean performOk() { - NullProgressMonitor monitor = new NullProgressMonitor(); - if (isVersion5) { - if (libDir.length() == 0) { - - MessageDialog dlg = new MessageDialog(null, - J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR), - null, J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR_WARN_QUESTION), - MessageDialog.QUESTION, new String[] {J2EEUIMessages.YES_BUTTON, - J2EEUIMessages.NO_BUTTON, - J2EEUIMessages.CANCEL_BUTTON}, 1); - switch (dlg.open()) { - case 0: break; - case 1: { - handleChangeLibDirButton(false); - return false; - } - case 2: return false; - default: return false; - } - } - updateLibDir(monitor); - } - removeModulesFromEAR(monitor); - addModulesToEAR(monitor); - refresh(); - return true; - } - - public void performDefaults() { - } - - public boolean performCancel() { - return true; - } - - public void dispose() { - Table table = null; - if (availableComponentsViewer != null) { - table = availableComponentsViewer.getTable(); - if (table == null) - return; - } - table.removeListener(SWT.Dispose, tableListener); - table.removeListener(SWT.KeyDown, tableListener); - table.removeListener(SWT.MouseMove, tableListener); - table.removeListener(SWT.MouseHover, tableListener); - } - - public void setVisible(boolean visible) { - } - - private List newJ2EEModulesToAdd(boolean inLibFolder){ - if (inLibFolder && !isVersion5) return null; - List newComps = new ArrayList(); - List comps = inLibFolder ? j2eeLibElementList : j2eeComponentList; - if (comps != null && !comps.isEmpty()){ - for (int i = 0; i < comps.size(); i++){ - IVirtualComponent handle = (IVirtualComponent)comps.get(i); - if (ClasspathDependencyUtil.isClasspathComponentDependency(handle)) { - continue; - } - if( !inEARAlready(handle)) - newComps.add(handle); - } - } - return newComps; - } - - private void updateLibDir(IProgressMonitor monitor) { - if (libDir.equals(oldLibDir)) return; - final IEARModelProvider earModel = (IEARModelProvider)ModelProviderManager.getModelProvider(project); - final Application app = (Application)ModelProviderManager.getModelProvider(project).getModelObject(); - oldLibDir = app.getLibraryDirectory(); - if (oldLibDir == null) oldLibDir = J2EEConstants.EAR_DEFAULT_LIB_DIR; - earModel.modify(new Runnable() { - public void run() { - app.setLibraryDirectory(libDir); - }}, null); - } - - protected void createDD(IProgressMonitor monitor) { - if( earComponent != null ){ - IDataModelOperation op = generateEARDDOperation(); - try { - op.execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - } - } - - private void execAddOp(IProgressMonitor monitor, List componentList, String path) throws CoreException { - if (componentList == null || componentList.isEmpty()) return; - IDataModel dm = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); - - dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComponent); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentList); - - //[Bug 238264] the uri map needs to be manually set correctly - Map uriMap = new HashMap(); - IVirtualComponent virtComp; - String virtCompURIMapName; - for(int i=0; i<componentList.size(); i++) { - virtComp = (IVirtualComponent)componentList.get(i); - virtCompURIMapName = getVirtualComponentNameWithExtension(virtComp); - uriMap.put(virtComp, virtCompURIMapName); - } - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap); - - if (isVersion5) dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path); - - IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - if (stat != OK_STATUS) - throw new CoreException(stat); - try { - dm.getDefaultOperation().execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - } - - private void execAddOp1(IProgressMonitor monitor, List jProjList, List j2eeCompList, String path) - throws CoreException { - if (!jProjList.isEmpty()) { - Set moduleProjects = new HashSet(); - for (int i = 0; i < jProjList.size(); i++) { - try { - IProject proj = (IProject) jProjList.get(i); - moduleProjects.add(proj); - IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider()); - migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME, proj.getName()); - migrationdm.getDefaultOperation().execute(monitor, null); - - - IDataModel refdm = DataModelFactory.createDataModel(new CreateReferenceComponentsDataModelProvider()); - List targetCompList = (List) refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - - IVirtualComponent targetcomponent = ComponentCore.createComponent(proj); - targetCompList.add(targetcomponent); - - refdm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComponent); - refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, targetCompList); - if (isVersion5) refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path); - - - // referenced java projects should have archiveName attribute - ((Map)refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP)).put(targetcomponent, proj.getName().replace(' ', '_') + IJ2EEModuleConstants.JAR_EXT); - - refdm.getDefaultOperation().execute(monitor, null); - j2eeCompList.add(targetcomponent); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - } - EarFacetRuntimeHandler.updateModuleProjectRuntime(earComponent.getProject(), moduleProjects, new NullProgressMonitor()); - } // end - - } - - private IStatus addModulesToEAR(IProgressMonitor monitor) { - IStatus stat = OK_STATUS; - try { - if( earComponent != null ){ - final List list = newJ2EEModulesToAdd(false); - final List bndList = newJ2EEModulesToAdd(true); - final boolean shouldRun = (list != null && !list.isEmpty()) || !javaProjectsList.isEmpty(); - final boolean shouldBndRun = isVersion5 && - ((bndList != null && !bndList.isEmpty()) || !javaLibProjectsList.isEmpty()); - if(shouldRun || shouldBndRun){ - IWorkspaceRunnable runnable = new IWorkspaceRunnable(){ - - public void run(IProgressMonitor monitor) throws CoreException{ - if (shouldRun) { - execAddOp(monitor, list, J2EEConstants.EAR_ROOT_DIR); - execAddOp1(monitor, javaProjectsList, j2eeComponentList, J2EEConstants.EAR_ROOT_DIR); - } - if (shouldBndRun) { - execAddOp(monitor, bndList, libDir); - execAddOp1(monitor, javaLibProjectsList, j2eeLibElementList, libDir); - } - } - }; - J2EEUIPlugin.getWorkspace().run(runnable, monitor); - } - } - } catch (Exception e) { - Logger.getLogger().log(e); - } - - //[Bug 238264] clear out the cache because they should all either be added as references now - // or no longer checked and therefor not wanted by the user - this.addedJARComponents.clear(); - - return OK_STATUS; - } - - private void remComps(List list, String path) { - if( !list.isEmpty()){ - try { - // retrieve all dependencies on these components within the scope of the EAR - Map dependentComps = getEARModuleDependencies(earComponent, list); - // remove the components from the EAR - IDataModelOperation op = removeComponentFromEAROperation(earComponent, list, path); - op.execute(null, null); - // if that succeeded, remove all EAR-scope J2EE dependencies on these components - J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(earComponent.getProject()); - removeEARComponentDependencies(dependentComps); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - } - } - - private IStatus removeModulesFromEAR(IProgressMonitor monitor) { - IStatus stat = OK_STATUS; - if (!isVersion5) { - if(earComponent != null && j2eeComponentList != null) { - List list = getComponentsToRemove(); - remComps(list, J2EEConstants.EAR_ROOT_DIR); - } - } else { - if( earComponent != null && j2eeComponentList != null) { - List[] list = getComponentsToRemoveUpdate(!libDir.equals(oldLibDir)); - remComps(list[0], J2EEConstants.EAR_ROOT_DIR); - - remComps(list[1], oldLibDir); - } - } - return stat; - } - - private Map getEARModuleDependencies(final IVirtualComponent earComponent, final List components) { - final Map dependentComps = new HashMap(); - // get all current references to project within the scope of this EAR - for (int i = 0; i < components.size(); i++) { - - final List compsForProject = new ArrayList(); - final IVirtualComponent comp = (IVirtualComponent) components.get(i); - final IProject[] dependentProjects = DependencyGraphManager.getInstance().getDependencyGraph().getReferencingComponents(comp.getProject()); - for (int j = 0; j < dependentProjects.length; j++) { - final IProject project = dependentProjects[j]; - // if this is an EAR, can skip - if (J2EEProjectUtilities.isEARProject(project)) { - continue; - } - final IVirtualComponent dependentComp = ComponentCore.createComponent(project); - // ensure that the project's share an EAR - final IProject[] refEARs = J2EEProjectUtilities.getReferencingEARProjects(project); - boolean sameEAR = false; - for (int k = 0; k < refEARs.length; k++) { - if (refEARs[k].equals(earComponent.getProject())) { - sameEAR = true; - break; - } - } - if (!sameEAR) { - continue; - } - // if the dependency is a web lib dependency, can skip - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - IVirtualReference ref = dependentComp.getReference(comp.getName()); - if (ref != null && ref.getRuntimePath().equals(new Path("/WEB-INF/lib"))) { //$NON-NLS-1$ - continue; - } - } - compsForProject.add(dependentComp); - } - dependentComps.put(comp, compsForProject); - } - return dependentComps; - } - - private void removeEARComponentDependencies(final Map dependentComps) throws ExecutionException { - final Iterator targets = dependentComps.keySet().iterator(); - while (targets.hasNext()) { - final IVirtualComponent target = (IVirtualComponent) targets.next(); - final List sources = (List) dependentComps.get(target); - for (int i = 0; i < sources.size(); i++) { - final IVirtualComponent source = (IVirtualComponent) sources.get(i); - final IDataModel model = DataModelFactory.createDataModel(new RemoveReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, source); - final List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.add(target); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - model.getDefaultOperation().execute(null, null); - // update the manifest - removeManifestDependency(source, target); - } - } - } - - private void removeManifestDependency(final IVirtualComponent source, final IVirtualComponent target) - throws ExecutionException { - final String sourceProjName = source.getProject().getName(); - String targetProjName; - if (target instanceof J2EEModuleVirtualArchiveComponent) { - targetProjName = ((J2EEModuleVirtualArchiveComponent)target).getName(); - String[] pathSegments = targetProjName.split(PATH_SEPARATOR); - targetProjName = pathSegments[pathSegments.length - 1]; - } else { - targetProjName = target.getProject().getName(); - } - final IProgressMonitor monitor = new NullProgressMonitor(); - final IFile manifestmf = J2EEProjectUtilities.getManifestFile(source.getProject()); - final ArchiveManifest mf = J2EEProjectUtilities.readManifest(source.getProject()); - if (mf == null) - return; - final IDataModel updateManifestDataModel = DataModelFactory.createDataModel(new UpdateManifestDataModelProvider()); - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.PROJECT_NAME, sourceProjName); - updateManifestDataModel.setBooleanProperty(UpdateManifestDataModelProperties.MERGE, false); - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, manifestmf); - String[] cp = mf.getClassPathTokenized(); - List cpList = new ArrayList(); - String cpToRemove = (targetProjName.endsWith(".jar")) ? - targetProjName : - targetProjName + ".jar";//$NON-NLS-1$ - for (int i = 0; i < cp.length; i++) { - if (!cp[i].equals(cpToRemove)) { - cpList.add(cp[i]); - } - } - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.JAR_LIST, cpList); - updateManifestDataModel.getDefaultOperation().execute(monitor, null ); - } - - protected IDataModelOperation generateEARDDOperation() { - IDataModel model = DataModelFactory.createDataModel(new EarCreateDeploymentFilesDataModelProvider()); - model.setProperty(ICreateDeploymentFilesDataModelProperties.GENERATE_DD, earComponent); - model.setProperty(ICreateDeploymentFilesDataModelProperties.TARGET_PROJECT, project); - return model.getDefaultOperation(); - } - - protected IDataModelOperation removeComponentFromEAROperation(IVirtualComponent sourceComponent, List targetComponentsHandles, String dir) { - IDataModel model = DataModelFactory.createDataModel(new RemoveComponentFromEnterpriseApplicationDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentsHandles); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, dir); - return model.getDefaultOperation(); - } - - protected List getComponentsToRemove(){ - //j2eeComponentList = getCheckedJ2EEElementsAsList(); - List list = new ArrayList(); - if( earComponent != null && list != null ){ - IVirtualReference[] oldrefs = earComponent.getReferences(); - for (int j = 0; j < oldrefs.length; j++) { - IVirtualReference ref = oldrefs[j]; - IVirtualComponent handle = ref.getReferencedComponent(); - if(!j2eeComponentList.contains(handle) && (isVersion5 ? !j2eeLibElementList.contains(handle) : true)){ - if ((handle instanceof VirtualArchiveComponent) && (isPhysicallyAdded((VirtualArchiveComponent)handle))) - continue; - list.add(handle); - } - } - } - return list; - } - - // EAR5 case - protected List[] getComponentsToRemoveUpdate(boolean dirUpdated){ - //j2eeComponentList = getCheckedJ2EEElementsAsList(); - List[] list = new ArrayList[2]; - list[0] = new ArrayList(); - list[1] = new ArrayList(); - if( earComponent != null && list != null ){ - IVirtualReference[] oldrefs = earComponent.getReferences(); - for (int j = 0; j < oldrefs.length; j++) { - IVirtualReference ref = oldrefs[j]; - IVirtualComponent handle = ref.getReferencedComponent(); - if (handle instanceof VirtualArchiveComponent) { - VirtualArchiveComponent comp = (VirtualArchiveComponent)handle; - if (isPhysicallyAdded(comp)) - continue; - } - if(!j2eeComponentList.contains(handle) && ref.getRuntimePath().isRoot()) { - list[0].add(handle); - } - if((!j2eeLibElementList.contains(handle) || dirUpdated) && - ref.getRuntimePath().toString().equals(oldLibDir)) { - list[1].add(handle); - } - } - } - return list; - } - - - public void handleEvent(Event event) { - if (event.widget == selectAllButton) - handleSelectAllButtonPressed(); - else if (event.widget == deselectAllButton) - handleDeselectAllButtonPressed(); - else if(event.widget == projectJarButton) - handleSelectProjectJarButton(); - else if(event.widget == externalJarButton) - handleSelectExternalJarButton(); - else if(event.widget == addVariableButton) - handleSelectVariableButton(); - else if(event.widget == changeLibPathButton) { - this.handleChangeLibDirButton(true); - } - } - - private void handleSelectAllButtonPressed() { - availableComponentsViewer.setAllChecked(true); - j2eeComponentList = getCheckedJ2EEElementsAsList(true); - javaProjectsList = getCheckedJavaProjectsAsList(true); - if (isVersion5) { - j2eeLibElementList = getCheckedJ2EEElementsAsList(false); - javaLibProjectsList = getCheckedJavaProjectsAsList(false); - } - } - - private void handleDeselectAllButtonPressed() { - availableComponentsViewer.setAllChecked(false); - if (isVersion5) { - ((DoubleCheckboxTableViewer)availableComponentsViewer).setAllSecondChecked(false); - libsToUncheck.clear(); - } - j2eeComponentList = new ArrayList(); - javaProjectsList = new ArrayList(); - if (isVersion5) { - j2eeLibElementList = new ArrayList(); - javaLibProjectsList = new ArrayList(); - } - } - - /** - * [Bug 238264] - * Add an archive as a potential new reference for this.earComponent - * NOTE1: the given archive will not be added as a potential reference if there is already a reference to it - * NOTE2: the given archive will only be added as an actual reference when this.performOk is invoked - * - * @param archive the archive to add as a potential new reference in this.earComponent - * - */ - private void addPotentialNewReference(IVirtualComponent archive) { - //check to see if a reference to the given archive already exists - IVirtualReference [] existingRefs = earComponent.getReferences(); - IVirtualComponent referencedComponent; - boolean refAlreadyExists = false; - for(int i=0;i<existingRefs.length && !refAlreadyExists;i++){ - referencedComponent = existingRefs[i].getReferencedComponent(); - refAlreadyExists = referencedComponent.equals(archive); - } - - //only add the archive as a potentialy new reference if it does not already exist - if(!refAlreadyExists) { - this.j2eeComponentList.add(archive); - this.addedJARComponents.add(archive); - } else { - //TODO should inform user that they selected an already referenced archive? - } - } - - private void handleSelectExternalJarButton(){ - IPath[] selected= BuildPathDialogAccess.chooseExternalJAREntries(propPage.getShell()); - - if (selected != null) { - for (int i= 0; i < selected.length; i++) { - - String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; - IVirtualComponent archive = ComponentCore.createArchiveComponent( earComponent.getProject(), type + - selected[i].toString()); - - this.addPotentialNewReference(archive); - } - refresh(); - } - - } - - private void handleSelectVariableButton(){ - IPath existingPath[] = new Path[0]; - IPath[] paths = BuildPathDialogAccess.chooseVariableEntries(propPage.getShell(), existingPath); - - if (paths != null) { - refresh(); - for (int i = 0; i < paths.length; i++) { - IPath resolvedPath= JavaCore.getResolvedVariablePath(paths[i]); - - java.io.File file = new java.io.File(resolvedPath.toOSString()); - if( file.isFile() && file.exists()){ - String type = VirtualArchiveComponent.VARARCHIVETYPE + IPath.SEPARATOR; - - IVirtualComponent archive = ComponentCore.createArchiveComponent( earComponent.getProject(), type + - paths[i].toString()); - - this.addPotentialNewReference(archive); - }else{ - //display error - } - } - refresh(); - } - } - - private void handleChangeLibDirButton(boolean warnBlank) { - IVirtualFile vFile = earComponent.getRootFolder().getFile(new Path(J2EEConstants.APPLICATION_DD_URI)); - if (!vFile.exists()) { - if (!MessageDialog.openQuestion(null, - J2EEUIMessages.getResourceString(J2EEUIMessages.NO_DD_MSG_TITLE), - J2EEUIMessages.getResourceString(J2EEUIMessages.GEN_DD_QUESTION))) return; - createDD(new NullProgressMonitor()); - } - Application app = (Application)ModelProviderManager.getModelProvider(project).getModelObject(); - if (libDir == null) { - libDir = app.getLibraryDirectory(); - if (libDir == null) libDir = J2EEConstants.EAR_DEFAULT_LIB_DIR; - } - - ChangeLibDirDialog dlg = new ChangeLibDirDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(), libDir, warnBlank); - if (dlg.open() == Dialog.CANCEL) return; - libDir = dlg.getValue().trim(); - if (libDir.length() > 0) { - if (!libDir.startsWith(J2EEConstants.EAR_ROOT_DIR)) libDir = IPath.SEPARATOR + libDir; - } - setLibDirInContentProvider(); - refresh(); - } - - - protected void createTableComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridData gData = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gData); - fillComposite(composite); - } - - public void fillComposite(Composite parent) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - createTable(parent); - createButtonColumn(parent); - } - - protected void createButtonColumn(Composite parent) { - buttonColumn = createButtonColumnComposite(parent); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - buttonColumn.setLayoutData(data); - createPushButtons(); - } - - protected void createPushButtons() { - selectAllButton = createPushButton(SELECT_ALL_BUTTON); - deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON); - projectJarButton = createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.PROJECT_JAR));//$NON-NLS-1$ - externalJarButton = createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.EXTERNAL_JAR));//$NON-NLS-1$ - addVariableButton = createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.ADDVARIABLE));//$NON-NLS-1$ - if (isVersion5) changeLibPathButton = createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.CHANGE_LIB_DIR));//$NON-NLS-1$ - } - - protected Button createPushButton(String label) { - Button aButton = primCreatePushButton(label, buttonColumn); - aButton.addListener(SWT.Selection, this); - aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - return aButton; - } - - public Button primCreatePushButton(String label, Composite aButtonColumn) { - Button aButton = new Button(aButtonColumn, SWT.PUSH); - aButton.setText(label); - return aButton; - } - - public Composite createButtonColumnComposite(Composite parent) { - Composite aButtonColumn = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 0; - layout.marginWidth = 0; - aButtonColumn.setLayout(layout); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - aButtonColumn.setLayoutData(data); - return aButtonColumn; - } - - public Group createGroup(Composite parent) { - return new Group(parent, SWT.NULL); - } - - protected void createTable(Composite parent) { - availableComponentsViewer = createavailableComponentsViewer(parent); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); - availableComponentsViewer.getTable().setLayoutData(gd); - - if (earComponent != null) { - int j2eeVersion = J2EEVersionUtil.convertVersionStringToInt(earComponent); - AvailableJ2EEComponentsForEARContentProvider provider = new AvailableJ2EEComponentsForEARContentProvider(earComponent, j2eeVersion); - availableComponentsViewer.setContentProvider(provider); - availableComponentsViewer.setLabelProvider(provider); - setLibDirInContentProvider(); - addTableListeners(); - } - } - - private void setLibDirInContentProvider() { - IContentProvider prov = availableComponentsViewer.getContentProvider(); - if (prov instanceof AvailableJ2EEComponentsForEARContentProvider) - ((AvailableJ2EEComponentsForEARContentProvider)prov).setCurrentLibDir(libDir); - } - - protected void addTableListeners() { - addCheckStateListener(); - addHoverHelpListeners(); - } - - protected void addHoverHelpListeners() { - final Table table = availableComponentsViewer.getTable(); - createLabelListener(table); - createTableListener(table); - table.addListener(SWT.Dispose, tableListener); - table.addListener(SWT.KeyDown, tableListener); - table.addListener(SWT.MouseMove, tableListener); - table.addListener(SWT.MouseHover, tableListener); - } - - protected void createLabelListener(final Table table) { - labelListener = new Listener () { - public void handleEvent (Event event) { - Label label = (Label)event.widget; - Shell shell = label.getShell (); - switch (event.type) { - case SWT.MouseDown: - Event e = new Event (); - e.item = (TableItem) label.getData ("_TABLEITEM"); - table.setSelection (new TableItem [] {(TableItem) e.item}); - table.notifyListeners (SWT.Selection, e); - shell.dispose (); - table.setFocus(); - break; - case SWT.MouseExit: - shell.dispose (); - break; - } - } - }; - } - - protected void createTableListener(final Table table) { - tableListener = new Listener () { - Shell tip = null; - Label label = null; - public void handleEvent (Event event) { - switch (event.type) { - case SWT.Dispose: - case SWT.KeyDown: - case SWT.MouseMove: { - if (tip == null) break; - tip.dispose (); - tip = null; - label = null; - break; - } - case SWT.MouseHover: { - TableItem item = table.getItem (new Point (event.x, event.y)); - if (item != null) { - if (!item.getGrayed()) - return; - if (tip != null && !tip.isDisposed ()) tip.dispose (); - tip = new Shell (PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - tip.setBackground (Display.getDefault().getSystemColor (SWT.COLOR_INFO_BACKGROUND)); - FillLayout layout = new FillLayout (); - layout.marginWidth = 2; - tip.setLayout (layout); - label = new Label (tip, SWT.WRAP); - label.setForeground (Display.getDefault().getSystemColor (SWT.COLOR_INFO_FOREGROUND)); - label.setBackground (Display.getDefault().getSystemColor (SWT.COLOR_INFO_BACKGROUND)); - label.setData ("_TABLEITEM", item); - label.setText (J2EEUIMessages.getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS)); - label.addListener (SWT.MouseExit, labelListener); - label.addListener (SWT.MouseDown, labelListener); - Point size = tip.computeSize (SWT.DEFAULT, SWT.DEFAULT); - Rectangle rect = item.getBounds (0); - Point pt = table.toDisplay (rect.x, rect.y); - tip.setBounds (pt.x, pt.y - size.y, size.x, size.y); - tip.setVisible (true); - } - } - } - } - }; - } - - protected void addCheckStateListener() { - availableComponentsViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - CheckboxTableViewer vr = (CheckboxTableViewer)event.getSource(); - Object element = event.getElement(); - if (vr.getGrayed(element)) - vr.setChecked(element, !vr.getChecked(element)); - Object o = event.getSource(); - if (!(event instanceof SecondCheckBoxStateChangedEvent) && (isVersion5)) { - Object[] items = ((DoubleCheckboxTableViewer)vr).getUncheckedItems(); - for (int i = 0; i < items.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)items[i]; - if (item.getSecondChecked()) { - item.setSecondChecked(false); - libsToUncheck.remove(event.getElement()); - } - } - } - if ((event instanceof SecondCheckBoxStateChangedEvent)) { - SecondCheckBoxStateChangedEvent evt = (SecondCheckBoxStateChangedEvent)event; - DoubleCheckboxTableItem tblItem = evt.getTableItem(); - if (tblItem.getSecondChecked() && isConflict(tblItem.getData())) { - DependencyConflictResolveDialog dlg = new DependencyConflictResolveDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(), DependencyConflictResolveDialog.DLG_TYPE_2); - if (dlg.open() == DependencyConflictResolveDialog.BTN_ID_CANCEL) { - tblItem.setSecondChecked(false); - return; - } - } - if (tblItem.getSecondChecked()) { - if (!tblItem.getChecked()) - tblItem.setChecked(true); - libsToUncheck.add(event.getElement()); - } else { - libsToUncheck.remove(event.getElement()); - } - } - j2eeComponentList = getCheckedJ2EEElementsAsList(true); - javaProjectsList = getCheckedJavaProjectsAsList(true); - if (isVersion5) { - j2eeLibElementList = getCheckedJ2EEElementsAsList(false); - javaLibProjectsList = getCheckedJavaProjectsAsList(false); - - } - } - }); - } - - protected List getCPComponentsInEar(boolean inLibFolder) { - List list = new ArrayList(); - Map pathToComp = new HashMap(); - IVirtualReference refs[] = earComponent.getReferences(); - for( int i=0; i< refs.length; i++){ - IVirtualReference ref = refs[i]; - if ((ref.getRuntimePath().isRoot() && !inLibFolder) || - (!ref.getRuntimePath().isRoot() && inLibFolder) || - !isVersion5) { - - IVirtualComponent comp = ref.getReferencedComponent(); - AvailableJ2EEComponentsForEARContentProvider.addClasspathComponentDependencies(list, pathToComp, comp); - } - } - return list; - } - - protected List getComponentsInEar(boolean inLibFolder) { - List list = new ArrayList(); - IVirtualReference refs[] = earComponent.getReferences(); - for( int i=0; i< refs.length; i++){ - IVirtualReference ref = refs[i]; - if ((ref.getRuntimePath().isRoot() && !inLibFolder) || - (!ref.getRuntimePath().isRoot() && inLibFolder) || - !isVersion5) { - - IVirtualComponent comp = ref.getReferencedComponent(); - list.add(comp); - } - } - return list; - } - - /** - * - * @param componentHandle - * @return - * @description returns true is a component is already in the EAR as a dependent - */ - protected boolean inEARAlready(IVirtualComponent component){ - IVirtualReference refs[] = earComponent.getReferences(); - for( int i=0; i< refs.length; i++){ - IVirtualReference ref = refs[i]; - if ( ref.getReferencedComponent().equals( component )) - return true; - } - return false; - } - - // The next two are used in EAR5 case - protected List getCheckedJ2EEElementsAsList(boolean singleChecked) { - Object[] elements; - if (isVersion5) { - elements = singleChecked ? ((DoubleCheckboxTableViewer)availableComponentsViewer).getSingleCheckedElements(): - ((DoubleCheckboxTableViewer)availableComponentsViewer).getDoubleCheckedElements(); - - } else { - elements = availableComponentsViewer.getCheckedElements(); - } - List list; - if (elements == null || elements.length == 0) - list = new ArrayList(0); // Collections.EMPTY_LIST would cause UnsupportedOperationException when a later attempt to add to it is made - else { - list = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - if (elements[i] instanceof IVirtualComponent) { - list.add(elements[i]); - } - } - } - return list; - } - - protected List getCheckedJavaProjectsAsList(boolean single) { - Object[] elements; - if (isVersion5) { - elements = single ? ((DoubleCheckboxTableViewer)availableComponentsViewer).getSingleCheckedElements() : - ((DoubleCheckboxTableViewer)availableComponentsViewer).getDoubleCheckedElements(); - } else { - elements = availableComponentsViewer.getCheckedElements(); - } - - List list; - if (elements == null || elements.length == 0) - list = new ArrayList(0); // Collections.EMPTY_LIST would cause UnsupportedOperationException when a later attempt to add to it is made - else { - list = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - if (elements[i] instanceof IProject) { - list.add(elements[i]); - } - } - } - return list; - } - - protected List getLibFolderLibsAsList() { - Object[] items = ((DoubleCheckboxTableViewer)availableComponentsViewer).getSecondCheckedItems(); - List list; - if (items == null || items.length == 0) - list = new ArrayList(0); // Collections.EMPTY_LIST would cause UnsupportedOperationException when a later attempt to add to it is made - else { - list = new ArrayList(); - for (int i = 0; i < items.length; i++) { - Object element = ((DoubleCheckboxTableItem)items[i]).getData(); - if (element instanceof IProject) { - list.add(element); - } - } - } - return list; - } - - public CheckboxTableViewer createavailableComponentsViewer(Composite parent) { - int flags = SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI; - - Table table = isVersion5 ? new Table(parent, flags) : new Table(parent, flags); - availableComponentsViewer = isVersion5 ? new DoubleCheckboxTableViewer(table, 2) : new CheckboxTableViewer(table); - - // set up table layout - TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout(); - tableLayout.addColumnData(new ColumnWeightData(200, true)); - tableLayout.addColumnData(new ColumnWeightData(200, true)); - if (isVersion5) tableLayout.addColumnData(new ColumnWeightData(200, true)); - table.setLayout(tableLayout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - availableComponentsViewer.setSorter(null); - - // table columns - TableColumn fileNameColumn = new TableColumn(table, SWT.NONE, 0); - fileNameColumn.setText(ManifestUIResourceHandler.JAR_Module_UI_); - fileNameColumn.setResizable(true); - - TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1); - projectColumn.setText(ManifestUIResourceHandler.Project_UI_); - projectColumn.setResizable(true); - - if (isVersion5) { - TableColumn bndColumn = new TableColumn(table, SWT.NONE, 2); - bndColumn.setText(ManifestUIResourceHandler.Packed_In_Lib_UI_); - bndColumn.setResizable(true); - } - - tableLayout.layout(table, true); - return availableComponentsViewer; - - } - - private boolean secondShouldBeDisabled(IVirtualComponent component) { - if(component.isBinary()) return false; - if (JavaEEProjectUtilities.isApplicationClientComponent(component)) return true; - if (JavaEEProjectUtilities.isEARProject(component.getProject()) && component.isBinary()) return false; - if (JavaEEProjectUtilities.isEJBComponent(component)) return true; - if (JavaEEProjectUtilities.isDynamicWebComponent(component)) return true; - if (JavaEEProjectUtilities.isJCAComponent(component)) return true; - if (JavaEEProjectUtilities.isStaticWebProject(component.getProject())) return true; - if (JavaEEProjectUtilities.isProjectOfType(component.getProject(), IJ2EEFacetConstants.JAVA)) return false; - return false; - } - - private boolean isPhysicallyAdded(VirtualArchiveComponent component) { - IPath p = null; - try { - p = component.getProjectRelativePath(); - return true; - } catch (IllegalArgumentException e) { - return false; - } - } - - private boolean isInLibDir(VirtualArchiveComponent comp) { - IPath p = comp.getProjectRelativePath(); - if (p.segmentCount() == 2) - return false; - return true; - } - - - public void refresh() { - - IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot(); - availableComponentsViewer.setInput(input); - GridData data = new GridData(GridData.FILL_BOTH); - int numlines = Math.min(10, availableComponentsViewer.getTable().getItemCount()); - data.heightHint = availableComponentsViewer.getTable().getItemHeight() * numlines; - availableComponentsViewer.getTable().setLayoutData(data); - - //[Bug 238264] for all the jars in the cache temparaly list them in the grid - // until the user applys the changes - for(IVirtualComponent jarComponent : this.addedJARComponents) { - availableComponentsViewer.add(jarComponent); - } - - TableItem [] items = availableComponentsViewer.getTable().getItems(); - List list = new ArrayList(); - //Object[] comps = getComponentsInEar(); - List cpComps; - List cpLibComps = new LinkedList(); - HashSet j2eeComponentSet = new HashSet(); - HashSet j2eeLibComponentSet = new HashSet(); - if (isVersion5) { - if( j2eeComponentList.isEmpty() ){ - List comps = getComponentsInEar(false); - j2eeComponentList.addAll(comps); - } - if( j2eeLibElementList.isEmpty() ){ - List comps = getComponentsInEar(true); - j2eeLibElementList.addAll(comps); - } - // get all Classpath contributions to the Ear - cpComps = getCPComponentsInEar(false); - j2eeComponentList.addAll(cpComps); - cpLibComps = getCPComponentsInEar(true); - j2eeLibElementList.addAll(cpLibComps); - for (int i = 0; i < j2eeLibElementList.size(); i++) { - j2eeLibComponentSet.add(j2eeLibElementList.get(i)); - } - - } else { - if( j2eeComponentList.isEmpty() ){ - List comps = getComponentsInEar(false); - j2eeComponentList.addAll(comps); - } - // get all Classpath contributions to the Ear - cpComps = getCPComponentsInEar(false); - j2eeComponentList.addAll(cpComps); - } - for (int i = 0; i < j2eeComponentList.size(); i++) { - j2eeComponentSet.add(j2eeComponentList.get(i)); - } - - for (int i = 0; i < items.length; i++) { - Object element = items[i].getData(); - try { - if (element instanceof IVirtualComponent || - (element instanceof IProject && ((IProject) element).hasNature(JavaCore.NATURE_ID))) { - if (j2eeComponentSet.contains(element)) { - list.add(element); - } - boolean shouldBeDisabled = false; - if (element instanceof VirtualArchiveComponent) { - shouldBeDisabled = isPhysicallyAdded((VirtualArchiveComponent)element); - if (shouldBeDisabled) { - items[i].setChecked(true); - items[i].setGrayed(true); - } - } - if (isVersion5) { - DoubleCheckboxTableItem dcbItem = (DoubleCheckboxTableItem)items[i]; - boolean secondEnabled = true; - if (element instanceof IVirtualComponent) - secondEnabled = !secondShouldBeDisabled((IVirtualComponent) element); - if (shouldBeDisabled) { - dcbItem.setSecondChecked(isInLibDir((VirtualArchiveComponent)element)); - dcbItem.setSecondEnabled(false); - } else { - dcbItem.setSecondChecked(j2eeLibComponentSet.contains(element)); - dcbItem.setSecondEnabled(secondEnabled); - } - if (j2eeLibComponentSet.contains(element)) list.add(element); - } - } - } catch (CoreException e) { - J2EEUIPlugin.logError(0, e.getMessage(), e); - } - } - - for (int i = 0; i < list.size(); i++) - availableComponentsViewer.setChecked(list.get(i), true); - GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - buttonColumn.setLayoutData(btndata); - - } - - private boolean isConflict(Object lib) { - IProject libProj = (lib instanceof IProject) ? (IProject)lib : ((IVirtualComponent)lib).getProject(); - IProject earProject = earComponent.getProject(); - try { - IVirtualComponent cmp = ComponentCore.createComponent(earProject); - IProject[] earRefProjects = earProject.getReferencedProjects(); - for (int i = 0; i < earRefProjects.length; i++) { - if (!J2EEProjectUtilities.isEARProject(earRefProjects[i]) && - !earRefProjects[i].equals(libProj)) { - IVirtualComponent cmp1 = ComponentCore.createComponent(earRefProjects[i]); - IVirtualReference[] refs = cmp1.getReferences(); - for (int j = 0; j < refs.length; j++) { - if (refs[j].getReferencedComponent().getProject().equals(libProj)) return true; - } - } - } - return false; - } catch (CoreException ce) { - Logger.getLogger().log(ce); - } - return false; - } - - private void handleSelectProjectJarButton(){ - IPath[] selected= BuildPathDialogAccess.chooseJAREntries(propPage.getShell(), project.getLocation(), new IPath[0]); - - if (selected != null) { - for (int i= 0; i < selected.length; i++) { - //IPath fullPath = project.getFile(selected[i]).getFullPath(); - String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; - IVirtualComponent archive = ComponentCore.createArchiveComponent( earComponent.getProject(), type + - selected[i].makeRelative().toString()); - - this.addPotentialNewReference(archive); - } - refresh(); - } - - } - - /** - * [Bug 238264] - * determines a unique URI mapping name for a given component - * this is in case two components have the same name. - * - * @return returns a valid (none duplicate) uri mapping name for the given component\ - */ - private String getURIMappingName(IVirtualComponent archive) { - - //get the default uri map name for the given archive - IPath componentPath = Path.fromOSString(archive.getName()); - String uriMapName = componentPath.lastSegment().replace(' ', '_'); - - - //check to be sure this uri mapping is not already in use by another reference - boolean dupeArchiveName; - String refedCompName; - int lastDotIndex; - String increment; - IVirtualReference [] existingRefs = earComponent.getReferences(); - for(int i=0;i<existingRefs.length;i++){ - refedCompName = existingRefs[i].getReferencedComponent().getName(); - - //if uri mapping names of the refed component and the given archive are the same - // find a new uri map name for the given archive - if(existingRefs[i].getArchiveName().equals(uriMapName)){ - dupeArchiveName = true; - //find a new uriMapName for the given component - for(int j=1; dupeArchiveName; j++){ - lastDotIndex = uriMapName.lastIndexOf('.'); - increment = "_"+j; //$NON-NLS-1$ - - //create the new potential name - if(lastDotIndex != -1){ - uriMapName = uriMapName.substring(0, lastDotIndex) + increment + uriMapName.substring(lastDotIndex); - } else { - uriMapName = uriMapName.substring(0)+increment; - } - - //determine if the new potential name is valid - for(int k=0; k<existingRefs.length; k++) { - dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName); - if(dupeArchiveName) { - break; - } - } - } - } - } - - return uriMapName; - } - - /** - * Method returns the name of the given IVirtualComponent being sure the correct extension - * is on the end of the name, this is important for internal projects. Added for [Bug 241509] - * - * @param virtComp the IVirtualComponent to get the name of with the correct extension - * @return the name of the given IVirtualComponent with the correct extension - */ - private String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) { - String virtCompURIMapName = this.getURIMappingName(virtComp); - - boolean linkedToEAR = true; - try { - if(virtComp.isBinary()){ - linkedToEAR = ((J2EEModuleVirtualArchiveComponent)virtComp).isLinkedToEAR(); - ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(false); - } - if(JavaEEProjectUtilities.isDynamicWebComponent(virtComp)) { - if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.WAR_EXT)) { - //web module URIs need to end in WAR - virtCompURIMapName += IJ2EEModuleConstants.WAR_EXT; - } - } else if(JavaEEProjectUtilities.isJCAComponent(virtComp)) { - if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.RAR_EXT)) { - //connector module URIs need to end in RAR - virtCompURIMapName += IJ2EEModuleConstants.RAR_EXT; - } - } else if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.JAR_EXT)) { - //all other modules (EJB, AppClient, Utility) need to end in JAR - virtCompURIMapName += IJ2EEModuleConstants.JAR_EXT; - } - } finally { - if(virtComp.isBinary()){ - ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(linkedToEAR); - } - } - return virtCompURIMapName; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AvailableJ2EEComponentsForEARContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AvailableJ2EEComponentsForEARContentProvider.java deleted file mode 100644 index 3eed372c7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/AvailableJ2EEComponentsForEARContentProvider.java +++ /dev/null @@ -1,297 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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 - * Stefan Dimov, stefan.dimov@sap.com - bug 207826 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection; -import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.model.IEARModelProvider; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.application.Application; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -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; - -public class AvailableJ2EEComponentsForEARContentProvider implements IStructuredContentProvider, ITableLabelProvider { - - final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR); - - private int j2eeVersion; - private IVirtualComponent earComponent; - private boolean isEE5 = false; - private String libDir = null; - - - public AvailableJ2EEComponentsForEARContentProvider(IVirtualComponent aEarComponent, int j2eeVersion) { - super(); - this.j2eeVersion = j2eeVersion; - earComponent = aEarComponent; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - if (null != earComponent){ - isEE5 = J2EEProjectUtilities.isJEEProject(earComponent.getProject()); - } - Object[] empty = new Object[0]; - if (!(inputElement instanceof IWorkspaceRoot)) - return empty; - IProject[] projects = ((IWorkspaceRoot) inputElement).getProjects(); - if (projects == null || projects.length == 0) - return empty; - List validCompList = new ArrayList(); - Map pathToComp = new HashMap(); - for (int i = 0; i < projects.length; i++) { - // get flexible project - IProject project = projects[i]; - if(ModuleCoreNature.isFlexibleProject(project)){ - IVirtualComponent component = ComponentCore.createComponent(project); - if (J2EEProjectUtilities.isApplicationClientProject(project) || - J2EEProjectUtilities.isEJBProject(project) || - J2EEProjectUtilities.isDynamicWebProject(project) || - J2EEProjectUtilities.isJCAProject(project) || - J2EEProjectUtilities.isUtilityProject(project) ){ - int compJ2EEVersion = J2EEVersionUtil.convertVersionStringToInt(component); - if( compJ2EEVersion <= j2eeVersion){ - validCompList.add(component); - } else if(isEE5){ - validCompList.add(component); - } - }else if(null != earComponent && J2EEProjectUtilities.isEARProject(project)){ - //find the ArchiveComponent - if(component.equals( earComponent )){ - if (isEE5) { - Application app = (Application)ModelProviderManager.getModelProvider(project).getModelObject(); - if (libDir == null) - libDir = app.getLibraryDirectory(); - if (libDir == null) - libDir = J2EEConstants.EAR_DEFAULT_LIB_DIR; - } - IVirtualReference[] newrefs = component.getReferences(); - for( int k=0; k< newrefs.length; k++ ){ - IVirtualReference tmpref = newrefs[k]; - IVirtualComponent referencedcomp = tmpref.getReferencedComponent(); - boolean isBinary = referencedcomp.isBinary(); - if( isBinary ){ - if (shouldShow(referencedcomp)) - validCompList.add(referencedcomp); - } else { - addClasspathComponentDependencies(validCompList, pathToComp, referencedcomp); - } - } - } - } - } else - try { - if (project.exists() && project.isAccessible() && project.hasNature("org.eclipse.jdt.core.javanature") ){ //$NON-NLS-1$ - if( !project.getName().startsWith(".") ) //$NON-NLS-1$ - validCompList.add(project); - } - } catch (CoreException e) { - Logger.getLogger().log(e); - } - } - return validCompList.toArray(); - } - - public void setCurrentLibDir(String libDir) { - this.libDir = libDir; - } - - private boolean shouldShow(IVirtualComponent component) { - if (!(component instanceof VirtualArchiveComponent)) - return true; - - VirtualArchiveComponent comp = (VirtualArchiveComponent)component; - IPath p = null; - try { - p = comp.getProjectRelativePath(); - } catch (IllegalArgumentException e) { - return true; - } - if ((p == null) && (p.segmentCount() == 0)) - return true; - IContainer f = earComponent.getRootFolder().getUnderlyingFolder(); - String rootFolderName = f.getProjectRelativePath().segment(0); - if (!p.segment(0).equals(rootFolderName)) - return false; - if (p.segmentCount() == 2) - return true; - if (isEE5) { - String strippedLibDir = stripSeparators(libDir); - String[] libDirSegs = strippedLibDir.split(PATH_SEPARATOR); - if (p.segmentCount() - 2 != libDirSegs.length) - return false; - for (int i = 0; i < libDirSegs.length; i++) - if (!libDirSegs[i].equals(p.segment(i + 1))) - return false; - return true; - } - return false; - } - - private String stripSeparators(String dir) { - if (dir.startsWith(PATH_SEPARATOR)) - dir = dir.substring(1); - if (dir.endsWith(PATH_SEPARATOR)) - dir = dir.substring(0, dir.length() - 1); - return dir; - } - - public static void addClasspathComponentDependencies(final List componentList, final Map pathToComp, final IVirtualComponent referencedComponent) { - if (referencedComponent instanceof J2EEModuleVirtualComponent) { - J2EEModuleVirtualComponent j2eeComp = (J2EEModuleVirtualComponent) referencedComponent; - IVirtualReference[] cpRefs = j2eeComp.getJavaClasspathReferences(); - for (int j=0; j < cpRefs.length; j++) { - String unresolvedURI = null; - // only ../ mappings supported at this level - if (!cpRefs[j].getRuntimePath().equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH)) { - continue; - } - // if the absolute path for this component already has a mapping, skip (the comp might be contributed by more than - // one child module) - final IPath path = ClasspathDependencyUtil.getClasspathVirtualReferenceLocation(cpRefs[j]); - final IVirtualComponent comp = (IVirtualComponent) pathToComp.get(path); - if (comp != null) { - // replace with a temp VirtualArchiveComponent whose IProject is set to a new pseudo name that is - // the concatenation of all project contributions for that archive - if (comp instanceof VirtualArchiveComponent) { - final VirtualArchiveComponent oldComp = (VirtualArchiveComponent) comp; - componentList.remove(comp); - final VirtualArchiveComponent newComponent = ClassPathSelection.updateDisplayVirtualArchiveComponent(oldComp, cpRefs[j]); - pathToComp.put(path, newComponent); - componentList.add(newComponent); - } - continue; - } else { - pathToComp.put(path, cpRefs[j].getReferencedComponent()); - } - componentList.add(cpRefs[j].getReferencedComponent()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - if (element instanceof IVirtualComponent) { - IVirtualComponent comp = (IVirtualComponent)element; - String name = ""; //$NON-NLS-1$ - if( columnIndex == 0 ){ - if (ClasspathDependencyUtil.isClasspathComponentDependency(comp)) { - return ClasspathDependencyUtil.getClasspathComponentDependencyDisplayString(comp); - } - IModelProvider provider = ModelProviderManager.getModelProvider(earComponent.getProject()); - if (provider instanceof IEARModelProvider) - { - name = ((IEARModelProvider)provider).getModuleURI(comp); - } - if( name == null || name == "" ){ //$NON-NLS-1$ - name = comp.getName(); - } - return name; - } else if (columnIndex == 1) { - return comp.getProject().getName(); - } else if (columnIndex == 2) { - return ""; //$NON-NLS-1$ - } - } else if (element instanceof IProject){ - if (columnIndex != 2) { - return ((IProject)element).getName(); - } else { - return ""; //$NON-NLS-1$ - } - } - return null; - } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - //do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, - * java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - //do nothing - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClassHelperAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClassHelperAdapterFactory.java deleted file mode 100644 index 163ae74c2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClassHelperAdapterFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jst.j2ee.internal.ejb.provider.J2EEJavaClassProviderHelper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; - -public class ClassHelperAdapterFactory implements IAdapterFactory { - - private static final Class IFILE_CLASS = IFile.class; - private static final Class IRESOURCE_CLASS = IResource.class; - - private static final Class[] ADAPTER_TYPES = new Class[] { - IFILE_CLASS, IRESOURCE_CLASS - }; - - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(IRESOURCE_CLASS == adapterType || IFILE_CLASS == adapterType) { - if(adaptableObject instanceof J2EEJavaClassProviderHelper) { - J2EEJavaClassProviderHelper provider = (J2EEJavaClassProviderHelper) adaptableObject; - try { - IResource resource = (IResource) provider.getAdapter(IRESOURCE_CLASS); - return resource; - } catch (RuntimeException e) { - J2EEUIPlugin.logError(0, e.getMessage(), e); - return null; - } - } - } - return null; - } - - public Class[] getAdapterList() { - return ADAPTER_TYPES; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClasspathTableManager.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClasspathTableManager.java deleted file mode 100644 index ffa69b251..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ClasspathTableManager.java +++ /dev/null @@ -1,647 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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 - * Stefan Dimov, stefan.dimov@sap.com - bug 207826 - *******************************************************************************/ -/* - * Created on Jan 17, 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; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection; -import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; -import org.eclipse.jst.j2ee.internal.common.ClasspathModel; -import org.eclipse.jst.j2ee.internal.common.ClasspathModelEvent; -import org.eclipse.jst.j2ee.internal.dialogs.DependencyConflictResolveDialog; -import org.eclipse.jst.j2ee.internal.listeners.IValidateEditListener; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.wizard.AvailableJarsProvider; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class ClasspathTableManager implements Listener, ICommonManifestUIConstants { - - protected Button useClientJARsBtn; - protected Button useServerJARsBtn; - protected Button useAnyJARsBtn; - protected Button upButton; - protected Button downButton; - protected Button selectAllButton; - protected Button deselectAllButton; - protected IClasspathTableOwner owner; - protected Composite buttonColumn; - protected ClasspathModel model; - protected CheckboxTableViewer availableJARsViewer; - protected IValidateEditListener validateEditListener; - /** - * @deprecated this field should be removed - */ - protected boolean isWLPEntry; - protected Group radioGroup; - - protected boolean readOnly; - protected AvailableJarsProvider availableJarsProvider; - protected Button externalJarButton; - protected Button projectJarButton; - protected Button addVariableButton; - - protected Set compsToUncheck = new HashSet(); - - /** - * Constructor for ButtonBarManager. - */ - public ClasspathTableManager(IClasspathTableOwner owner, ClasspathModel model) { - this(owner, model, null); - } - - public ClasspathTableManager(IClasspathTableOwner owner, ClasspathModel model, IValidateEditListener listener) { - super(); - this.owner = owner; - this.model = model; - this.validateEditListener = listener; - } - public void fillComposite(Composite parent) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - createRadioGroup(parent); - createTable(parent); - createButtonColumn(parent); - } - - public void fillWLPComposite(Composite parent) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - createTable(parent); - createWLPButtonColumn(parent); - } - - public void fillWebRefComposite(Composite parent) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - createTable(parent); - createWebRefButtonColumn(parent); - } - - private void initializeEJBClientDefaults() { - if (model == null || model.getClassPathSelection() == null) - return; - boolean shouldUseServerJARs = false; - ClassPathSelection selection = model.getClassPathSelection(); - int filterLevel; - boolean ejbSelected = selection.isAnyEJBJarSelected(); - boolean clientSelected = selection.isAnyEJBClientJARSelected(); - if (ejbSelected && clientSelected) - filterLevel = ClassPathSelection.FILTER_NONE; - else if (shouldUseServerJARs) { - if (clientSelected) - filterLevel = ClassPathSelection.FILTER_NONE; - else - filterLevel = ClassPathSelection.FILTER_EJB_CLIENT_JARS; - } else { - if (ejbSelected) - filterLevel = ClassPathSelection.FILTER_NONE; - else - filterLevel = ClassPathSelection.FILTER_EJB_SERVER_JARS; - } - initFilterLevel(filterLevel); - } - - private void initFilterLevel(int filterLevel) { - model.getClassPathSelection().setFilterLevel(filterLevel); - switch (filterLevel) { - case (ClassPathSelection.FILTER_NONE) : - useAnyJARsBtn.setSelection(true); - useClientJARsBtn.setSelection(false); - useServerJARsBtn.setSelection(false); - break; - case (ClassPathSelection.FILTER_EJB_CLIENT_JARS) : - useAnyJARsBtn.setSelection(false); - useClientJARsBtn.setSelection(false); - useServerJARsBtn.setSelection(true); - break; - case (ClassPathSelection.FILTER_EJB_SERVER_JARS) : - useAnyJARsBtn.setSelection(false); - useClientJARsBtn.setSelection(true); - useServerJARsBtn.setSelection(false); - break; - } - } - - private void createRadioGroup(Composite parent) { - radioGroup = owner.createGroup(parent); - radioGroup.setText(EJB_CLIENT_RADIO_UI_); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.horizontalIndent = 0; - GridLayout layout = new GridLayout(3, false); - radioGroup.setLayout(layout); - radioGroup.setLayoutData(data); - - useServerJARsBtn = createRadioButton(USE_EJB_SERVER_JARs_UI_, radioGroup); - useClientJARsBtn = createRadioButton(USE_EJB_CLIENT_JARs_UI_, radioGroup); - useAnyJARsBtn = createRadioButton(USE_BOTH_UI_, radioGroup); - initializeEJBClientDefaults(); - } - - protected void createButtonColumn(Composite parent) { - buttonColumn = owner.createButtonColumnComposite(parent); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - buttonColumn.setLayoutData(data); - createPushButtons(); - } - - protected void createWLPButtonColumn(Composite parent) { - buttonColumn = owner.createButtonColumnComposite(parent); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - buttonColumn.setLayoutData(data); - createWLPPushButtons(); - } - - protected void createWebRefButtonColumn(Composite parent) { - buttonColumn = owner.createButtonColumnComposite(parent); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - buttonColumn.setLayoutData(data); - createWebRefPushButtons(); - } - - protected void createTable(Composite parent) { - availableJARsViewer = owner.createAvailableJARsViewer(parent); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); - availableJARsViewer.getTable().setLayoutData(gd); - availableJarsProvider = new AvailableJarsProvider(); - availableJARsViewer.setContentProvider(availableJarsProvider); - availableJARsViewer.setLabelProvider(availableJarsProvider); - addTableListeners(); - } - - protected void createWLPPushButtons() { - selectAllButton = createPushButton(SELECT_ALL_BUTTON); - deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON); - projectJarButton = createPushButton(J2EEUIMessages.getResourceString("PROJECT_JAR")); //$NON-NLS-1$ - externalJarButton = createPushButton(J2EEUIMessages.getResourceString("EXTERNAL_JAR")); //$NON-NLS-1$ - addVariableButton = createPushButton(J2EEUIMessages.getResourceString("ADDVARIABLE"));//$NON-NLS-1$ - if (isReadOnly()) { - selectAllButton.setEnabled(false); - deselectAllButton.setEnabled(false); - projectJarButton.setEnabled(false); - externalJarButton.setEnabled(false); - addVariableButton.setEnabled(false); - } - } - - protected void createWebRefPushButtons() { - selectAllButton = createPushButton(SELECT_ALL_BUTTON); - deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON); - if (isReadOnly()) { - selectAllButton.setEnabled(false); - deselectAllButton.setEnabled(false); - } - } - - protected void createPushButtons() { - upButton = createPushButton(UP_BUTTON); - downButton = createPushButton(DOWN_BUTTON); - selectAllButton = createPushButton(SELECT_ALL_BUTTON); - deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON); - if (isReadOnly()) { - upButton.setEnabled(false); - downButton.setEnabled(false); - selectAllButton.setEnabled(false); - deselectAllButton.setEnabled(false); - } - } - - protected void createWebLibPushButtons() { - selectAllButton = createPushButton(SELECT_ALL_BUTTON); - deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON); - projectJarButton = createPushButton(J2EEUIMessages.getResourceString("PROJECT_JAR")); //$NON-NLS-1$ - externalJarButton = createPushButton(J2EEUIMessages.getResourceString("EXTERNAL_JAR")); //$NON-NLS-1$ - addVariableButton = createPushButton(J2EEUIMessages.getResourceString("ADDVARIABLE"));//$NON-NLS-1$ - if (isReadOnly()) { - selectAllButton.setEnabled(false); - deselectAllButton.setEnabled(false); - } - } - - protected Button createPushButton(String label) { - Button aButton = owner.primCreatePushButton(label, buttonColumn); - aButton.addListener(SWT.Selection, this); - aButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - return aButton; - } - - protected Button createRadioButton(String label, Composite parent) { - Button aButton = owner.primCreateRadioButton(label, parent); - aButton.addListener(SWT.Selection, this); - return aButton; - } - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - - ClasspathModelEvent evt = new ClasspathModelEvent(ClasspathModelEvent.CLASS_PATH_CHANGED); - model.fireNotification(evt); - if (event.widget == upButton) - upButtonSelected(); - else if (event.widget == downButton) - downButtonSelected(); - else if (event.widget == selectAllButton) - selectAllButtonSelected(); - else if (event.widget == deselectAllButton) - deselectAllButtonSelected(); - else if (event.widget == useServerJARsBtn) - handleServerJARsButtonSelected(); - else if (event.widget == useClientJARsBtn) - handleClientJARsButtonSelected(); - else if (event.widget == useAnyJARsBtn) - handleAnyJARsButtonSelected(); - else if(event.widget == projectJarButton) - handleSelectProjectJarButton(); - else if(event.widget == externalJarButton) - handleSelectExternalJarButton(); - else if(event.widget == addVariableButton) - handleSelectVariableButton(); - } - - private void handleSelectExternalJarButton(){ - //owner.handleSelectExternalJarButton(); - if( owner instanceof WebLibDependencyPropertiesPage){ - WebLibDependencyPropertiesPage control = (WebLibDependencyPropertiesPage)owner; - control.handleSelectExternalJarButton(); - } - } - private void handleSelectProjectJarButton(){ - //owner.handleSelectExternalJarButton(); - if( owner instanceof WebLibDependencyPropertiesPage){ - WebLibDependencyPropertiesPage control = (WebLibDependencyPropertiesPage)owner; - control.handleSelectProjectJarButton(); - } - } - - private void handleSelectVariableButton(){ - //owner.handleSelectVariableButton(); - if( owner instanceof WebLibDependencyPropertiesPage){ - WebLibDependencyPropertiesPage control = (WebLibDependencyPropertiesPage)owner; - control.handleSelectVariableButton(); - } - } - - private void handleServerJARsButtonSelected() { - model.selectFilterLevel(ClassPathSelection.FILTER_EJB_CLIENT_JARS); - refresh(); - } - - private void handleClientJARsButtonSelected() { - model.selectFilterLevel(ClassPathSelection.FILTER_EJB_SERVER_JARS); - refresh(); - } - - private void handleAnyJARsButtonSelected() { - model.selectFilterLevel(ClassPathSelection.FILTER_NONE); - refresh(); - } - - public boolean validatateEdit() { - return validateEditListener.validateState().isOK(); - } - - protected void deselectAllButtonSelected() { - if (!validatateEdit()) - return; - availableJARsViewer.setAllChecked(false); - model.setAllClasspathElementsSelected(false); - compsToUncheck.clear(); - } - - protected void selectAllButtonSelected() { - if (!validatateEdit()) - return; - availableJARsViewer.setAllChecked(true); - Object[] elements = availableJARsViewer.getCheckedElements(); - model.setAllClasspathElementsSelected(Arrays.asList(elements), true); - for (int i = 0; i < elements.length; i++) { - ClasspathElement el = (ClasspathElement)elements[i]; - el.getComponent().getAdapter(IVirtualComponent.class); - IVirtualComponent ar = el.getTargetComponent(); - IVirtualComponent comp = (ar instanceof J2EEModuleVirtualArchiveComponent) ? ar : el.getComponent(); - if (isLibrary(comp)) - compsToUncheck.add(comp); - } - } - - protected java.util.List getSelectionAsList() { - return ((IStructuredSelection) availableJARsViewer.getSelection()).toList(); - } - - protected java.util.List getCheckedLibsAsList() { - List res = new LinkedList(); - Iterator it = compsToUncheck.iterator(); - while (it.hasNext()) { - IVirtualComponent comp = (IVirtualComponent)it.next(); - res.add(comp); - } - return res; - } - - protected void downButtonSelected() { - if (!validatateEdit()) - return; - model.moveDown(getSelectionAsList()); - refresh(); - } - - protected void upButtonSelected() { - if (!validatateEdit()) - return; - model.moveUp(getSelectionAsList()); - refresh(); - } - - /* - * Updates the enable state of the all buttons - */ - protected void updateButtonEnablements() { - int[] indices = availableJARsViewer.getTable().getSelectionIndices(); - if (upButton != null && downButton != null) { - upButton.setEnabled(canMoveUp(indices)); - downButton.setEnabled(canMoveDown(indices, availableJARsViewer.getTable().getItemCount())); - } - } - - protected boolean canMoveUp(int[] indices) { - return canMove(indices, 0); - } - - protected boolean canMoveDown(int[] indices, int itemCount) { - return canMove(indices, itemCount - 1); - } - - protected boolean canMove(int[] indices, int referenceIndex) { - int length = indices.length; - if (length == 0) - return false; - for (int i = 0; i < length; i++) { - if (indices[i] == referenceIndex) - return false; - } - return true; - } - - protected void addTableListeners() { - addCheckStateListener(); - addSelectionListener(); - } - - protected void addCheckStateListener() { - availableJARsViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - availableJARCheckStateChanged(event); - } - }); - } - - private boolean isLibrary(IVirtualComponent component) { - if (J2EEProjectUtilities.isApplicationClientComponent(component)) return false; - if (J2EEProjectUtilities.isEARProject(component.getProject()) && component.isBinary()) return true; - if (J2EEProjectUtilities.isEJBComponent(component)) return false; - if (J2EEProjectUtilities.isDynamicWebComponent(component)) return false; - if (J2EEProjectUtilities.isJCAComponent(component)) return false; - if (J2EEProjectUtilities.isStaticWebProject(component.getProject())) return false; - if (J2EEProjectUtilities.isProjectOfType(component.getProject(), IJ2EEFacetConstants.JAVA)) return true; - return true; - } - - protected void availableJARCheckStateChanged(CheckStateChangedEvent event) { - ClasspathElement el = (ClasspathElement)event.getElement(); - //226823 targeting a regular java project from web libs - if(el.getComponent() == null){ - ClasspathElement element = (ClasspathElement) event.getElement(); - model.setSelection(element, event.getChecked()); - return; - } - el.getComponent().getAdapter(IVirtualComponent.class); - IVirtualComponent ar = el.getTargetComponent(); - IVirtualComponent comp = (ar instanceof J2EEModuleVirtualArchiveComponent) ? ar : el.getComponent(); - CheckboxTableViewer v = (CheckboxTableViewer)event.getSource(); - if (isLibrary(comp) && event.getChecked()) { - if (isConflict(comp)) { - DependencyConflictResolveDialog dlg = new DependencyConflictResolveDialog(PlatformUI. - getWorkbench(). - getActiveWorkbenchWindow(). - getShell(), - DependencyConflictResolveDialog.DLG_TYPE_1); - if (dlg.open() == dlg.BTN_ID_CANCEL) { - v.setChecked(el, false); - return; - } - - } - compsToUncheck.add(comp); - } else if (!event.getChecked()) { - compsToUncheck.remove(comp); - } - if (!J2EEProjectUtilities.isStandaloneProject(model.getComponent().getProject()) && (isReadOnly() || !validatateEdit() || (isMyClientJAR(event) && !event.getChecked()))) { - availableJARsViewer.setChecked(event.getElement(), !event.getChecked()); - return; - } - ClasspathElement element = (ClasspathElement) event.getElement(); - model.setSelection(element, event.getChecked()); - } - - - private boolean isConflict(IVirtualComponent lib) { - IProject[] ears = J2EEProjectUtilities.getReferencingEARProjects(lib.getProject()); - for (int i = 0; i < ears.length; i++) { - if (J2EEProjectUtilities.isJEEProject(ears[i])) { - IVirtualComponent cmp = ComponentCore.createComponent(ears[i]); - IVirtualReference[] refs = cmp.getReferences(); - for (int j = 0; j < refs.length; j++) { - if (model.getProject().equals(refs[j].getReferencedComponent().getProject())) { - IVirtualReference ref = cmp.getReference(lib.getName()); - if (!ref.getRuntimePath().isRoot()) return true; - } - } - } - } - return false; - } - - - - /** - * @param event - * @return - */ - private boolean isMyClientJAR(CheckStateChangedEvent event) { - ClasspathElement element = (ClasspathElement) event.getElement(); - if(getClasspathSelection() != null) - return getClasspathSelection().isMyClientJAR(element); - return false; - } - - protected void addSelectionListener() { - availableJARsViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - tableSelectionChanged(); - } - }); - } - - protected void tableSelectionChanged() { - if (!isReadOnly()) - updateButtonEnablements(); - } - - protected ClassPathSelection getClasspathSelection() { - if (model == null || model.getSelectedEARComponent() == null && !(J2EEProjectUtilities.isStandaloneProject(model.getComponent().getProject()))) - return null; - return model.getClassPathSelection(); - } - - public void refreshCheckedItems() { - if (getClasspathSelection() == null) - return; - java.util.List elements = getClasspathSelection().getClasspathElements(); - for (int i = 0; i < elements.size(); i++) { - ClasspathElement element = (ClasspathElement) elements.get(i); - availableJARsViewer.setChecked(element, element.isSelected()); - if (element.isClasspathDependency()) { - availableJARsViewer.setGrayed(element, true); - } - } - } - - public void refresh() { - final IProject project = model.getComponent().getProject(); - // if not a web project and it is either referenced by an EAR or a dynamic web project. - if (!isWLPEntry() && (!J2EEProjectUtilities.isStandaloneProject(project) || - (J2EEProjectUtilities.getReferencingWebProjects(project).length > 0))) { - availableJARsViewer.setInput(getClasspathSelection()); - GridData data = new GridData(GridData.FILL_BOTH); - int numlines = Math.min(10, availableJARsViewer.getTable().getItemCount()); - data.heightHint = availableJARsViewer.getTable().getItemHeight() * numlines; - availableJARsViewer.getTable().setLayoutData(data); - refreshCheckedItems(); - updateButtonEnablements(); - } else { - availableJARsViewer.setInput(model.getClassPathSelectionForWLPs()); - GridData data = new GridData(GridData.FILL_BOTH); - int numlines = Math.min(10, availableJARsViewer.getTable().getItemCount()); - data.heightHint = availableJARsViewer.getTable().getItemHeight() * numlines; - availableJARsViewer.getTable().setLayoutData(data); - refreshWLPCheckedItems(); - } - } - - private void refreshWLPCheckedItems() { - if (availableJARsViewer.getInput() != null) { - java.util.List elements = ((ClassPathSelection) availableJARsViewer.getInput()).getClasspathElements(); - for (int i = 0; i < elements.size(); i++) { - ClasspathElement element = (ClasspathElement) elements.get(i); - availableJARsViewer.setChecked(element, element.isSelected()); - if (element.isClasspathDependency()) { - availableJARsViewer.setGrayed(element, true); - } - } - } - } - - /** - * Gets the model. - * @return Returns a ClasspathModel - */ - public ClasspathModel getModel() { - return model; - } - - /** - * Sets the model. - * @param model The model to set - */ - public void setModel(ClasspathModel model) { - this.model = model; - initializeEJBClientDefaults(); - } - - /** - * Returns the readOnly. - * @return boolean - */ - public boolean isReadOnly() { - return readOnly; - } - - - /** - * Sets the readOnly. - * @param readOnly The readOnly to set - */ - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public boolean isWLPEntry() { - return model.isWLPModel(); - } - - /** - * @deprecated do not use this method - * @param isWLPEntry - */ - public void setWLPEntry(boolean isWLPEntry) { - this.isWLPEntry = isWLPEntry; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IClasspathTableOwner.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IClasspathTableOwner.java deleted file mode 100644 index 94f64b383..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IClasspathTableOwner.java +++ /dev/null @@ -1,37 +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 Jan 17, 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; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public interface IClasspathTableOwner { - Button primCreatePushButton(String label, Composite buttonColumn); - Button primCreateRadioButton(String label, Composite parent); - CheckboxTableViewer createAvailableJARsViewer(Composite parent); - Composite createButtonColumnComposite(Composite parent); - //Button createHideEJBClientJARsButton(Composite parent); This method is never used hence commeting it out - vkb - Group createGroup(Composite parent); -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ICommonManifestUIConstants.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ICommonManifestUIConstants.java deleted file mode 100644 index a6c4542a0..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ICommonManifestUIConstants.java +++ /dev/null @@ -1,46 +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 Jan 17, 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; - -import org.eclipse.jst.j2ee.internal.common.CommonEditResourceHandler; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public interface ICommonManifestUIConstants { - String UP_BUTTON = ManifestUIResourceHandler.Up_1; - String DOWN_BUTTON = ManifestUIResourceHandler.Down_2; - String SELECT_ALL_BUTTON = ManifestUIResourceHandler.Select_All_3; - String DE_SELECT_ALL_BUTTON = ManifestUIResourceHandler.Deselect_All_4; - String ERROR_READING_MANIFEST_DIALOG_TITLE = ManifestUIResourceHandler.ERROR_READING_MANIFEST_DIALOG_TITLE; - String SAVE_MANIFEST_WITH_ERROR =ManifestUIResourceHandler.SAVE_MANIFEST_WITH_ERROR; - String ERROR_READING_MANIFEST_DIALOG_MESSAGE_EDITOR = ManifestUIResourceHandler.ERROR_READING_MANIFEST_DIALOG_MESSAGE_EDITOR; - String ERROR_READING_MANIFEST_DIALOG_MESSAGE_PROP_PAGE = ManifestUIResourceHandler.ERROR_READING_MANIFEST_DIALOG_MESSAGE_PROP_PAGE; - String MANIFEST_PROBLEM_1 = ManifestUIResourceHandler.MANIFEST_PROBLEM_1; - String MANIFEST_PROBLEM_2 = ManifestUIResourceHandler.MANIFEST_PROBLEM_2; - String MANIFEST_PROBLEM_3 = ManifestUIResourceHandler.MANIFEST_PROBLEM_3; - String MANIFEST_PROBLEM_4 = ManifestUIResourceHandler.MANIFEST_PROBLEM_4; - String REDIRECT_TEXT_EDITOR_UI_ = ManifestUIResourceHandler.REDIRECT_TEXT_EDITOR_UI_; - - String EJB_CLIENT_RADIO_UI_ = CommonEditResourceHandler.getString("EJB_CLIENT_RADIO_UI_"); //$NON-NLS-1$ - String USE_EJB_SERVER_JARs_UI_ = CommonEditResourceHandler.getString("USE_EJB_SERVER_JARs_UI_"); //$NON-NLS-1$ - String USE_EJB_CLIENT_JARs_UI_ = CommonEditResourceHandler.getString("USE_EJB_CLIENT_JARs_UI_"); //$NON-NLS-1$ - String USE_BOTH_UI_ = CommonEditResourceHandler.getString("USE_BOTH_UI_"); //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IJ2EEDependenciesControl.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IJ2EEDependenciesControl.java deleted file mode 100644 index 6005131bb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/IJ2EEDependenciesControl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * rfrost@bea.com - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.swt.widgets.Composite; - -/** - * Interface for classes that implement a portion the "J2EE Module Dependencies" - * property page logic. - */ -public interface IJ2EEDependenciesControl extends ICommonManifestUIConstants { - - /** - * Creates the Composite associated with this control. - * @param parent Parent Composite. - * @return Composite for the control. - */ - Composite createContents(Composite parent); - - /** - * Called when the property page's <code>performOk()</code> method is called. - * @return - */ - boolean performOk(); - - /** - * Called when the property page's <code>performDefaults()</code> method is called. - * @return - */ - void performDefaults(); - - /** - * Called when the property page's <code>performCancel()</code> method is called. - * @return - */ - boolean performCancel(); - - /** - * Called when the property page's <code>setVisible()</code> method is called. - * @return - */ - void setVisible(boolean visible); - - /** - * Called when the property page's <code>dispose()</code> method is called. - * @return - */ - void dispose(); -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEComponentProjectMigrator.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEComponentProjectMigrator.java deleted file mode 100644 index fdf5cb31d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEComponentProjectMigrator.java +++ /dev/null @@ -1,643 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.emf.ecore.resource.Resource; -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.WorkbenchResourceHelperBase; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; -import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties; -import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider; -import org.eclipse.jst.common.project.facet.WtpUtils; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.jst.j2ee.internal.earcreation.EarFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.internal.ejb.project.operations.EjbFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.internal.ejb.project.operations.IEjbFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.jca.project.facet.ConnectorFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.project.facet.AppClientFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.project.facet.IAppClientFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.UtilityFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.web.project.facet.WebFacetInstallDataModelProvider; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.navigator.CommonViewer; -import org.eclipse.ui.navigator.INavigatorContentService; -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.componentcore.internal.ComponentType; -import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; -import org.eclipse.wst.common.componentcore.internal.IComponentProjectMigrator; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.SimpleValidateEdit; -import org.eclipse.wst.project.facet.SimpleWebFacetInstallDataModelProvider; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerUtil; - -public class J2EEComponentProjectMigrator implements IComponentProjectMigrator { - - private static final String WEB_LIB_CONTAINER = "org.eclipse.jst.j2ee.internal.web.container"; - private static final String WEB_LIB_PATH = "/WEB-INF/lib"; - private static final String OLD_DEPLOYABLES_PATH = ".deployables"; - private IProject project; - - private static final String[] J2EE_CONTENT_EXTENSION_IDS = new String[] { - "org.eclipse.jst.navigator.j2ee.ui.EARDDContent", //$NON-NLS-1$ - "org.eclipse.jst.navigator.j2ee.ui.WebDDContent", //$NON-NLS-1$ - "org.eclipse.jst.navigator.j2ee.ui.EJBDDContent", //$NON-NLS-1$ - "org.eclipse.jst.navigator.j2ee.ui.ConnectorDDContent" //$NON-NLS-1$ - }; - - private static final String PROJECT_EXPLORER = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$ - - public J2EEComponentProjectMigrator() { - super(); - // TODO Auto-generated constructor stub - } - - public void migrateProject(IProject aProject) { - if (aProject.isAccessible() && (aProject.getFile(StructureEdit.MODULE_META_FILE_NAME).exists())) { - // The file corresponding to StructureEdit.MODULE_META_FILE_NAME is crucial to migration. - // If it does not exist, the project cannot be migrated. We should never fail the test for existence - // of the file, if we do then something has gone badly wrong. - Resource resource = WorkbenchResourceHelperBase.getResource(aProject.getFile(StructureEdit.MODULE_META_FILE_NAME), false); - if(resource != null && resource.isLoaded()){ - // Unload the resource because the model inside the StructureEdit was cached when the - // the project was imported, and files may have moved due to migration (.wtpmodules for example). - resource.unload(); - } - - final List files = new ArrayList(); - files.add(aProject.getFile(J2EEProjectUtilities.DOT_PROJECT)); - files.add(aProject.getFile(J2EEProjectUtilities.DOT_CLASSPATH)); - files.add(aProject.getFile(StructureEdit.MODULE_META_FILE_NAME)); - if(SimpleValidateEdit.validateEdit(files)){ - project = aProject; - - removeComponentBuilders(project); - if (multipleComponentsDetected()) - createNewProjects(); - String facetid = getFacetFromProject(project); - if (facetid.length() == 0) - addFacets(project); - J2EEComponentClasspathUpdater.getInstance().queueUpdate(project); - } - } - ensureJ2EEContentExtensionsEnabled(); - } - - /** - * Ensure the J2EE content extension ids are enabled on the project explorer - * for the projects being migrated. - */ - private void ensureJ2EEContentExtensionsEnabled() { - IViewPart view = null; - try { - view = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().findView(PROJECT_EXPLORER); - } catch (Exception e) { - //Just bail and return if there is no view - } - if (view == null) - return; - - INavigatorContentService contentService = (INavigatorContentService) view.getAdapter(INavigatorContentService.class); - CommonViewer viewer = (CommonViewer) view.getAdapter(CommonViewer.class); - - // Set the J2EE content extensions as enabled now that we have set the J2EE facets - if (contentService != null) - contentService.getActivationService().activateExtensions(J2EE_CONTENT_EXTENSION_IDS, false); - - // Update the viewer if we are in the current UI thread - if (viewer != null) { - Display display = viewer.getControl().getDisplay(); - if (display!=null && Thread.currentThread().equals(display.getThread())) - viewer.refresh(); - } - } - - private void createNewProjects() { - - StructureEdit se = null; - try { - se = StructureEdit.getStructureEditForWrite(project); - List comps = se.getComponentModelRoot().getComponents(); - List removedComps = new ArrayList(); - for (int i = 1;i<comps.size();i++) { - WorkbenchComponent comp = (WorkbenchComponent) comps.get(i); - IWorkspace ws = ResourcesPlugin.getWorkspace(); - IProject newProj = ws.getRoot().getProject(comp.getName()); - if (!newProj.exists()) { - try { - createProj(newProj,(!comp.getComponentType().getComponentTypeId().equals(J2EEProjectUtilities.ENTERPRISE_APPLICATION))); - WtpUtils.addNatures(newProj); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - if (comp!=null && comp.getComponentType()!=null) - addFacetsToProject(newProj,comp.getComponentType().getComponentTypeId(),comp.getComponentType().getVersion(),false); - removedComps.add(comp); - IFolder compFolder = project.getFolder(comp.getName()); - if (compFolder.exists()) - try { - compFolder.delete(true,null); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - se.getComponentModelRoot().getComponents().removeAll(removedComps); - se.save(null); - - } finally { - if (se != null) - se.dispose(); - } - - - } - - private void createProj(IProject newProj, boolean isJavaProject) throws CoreException { - newProj.create(null); - IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(newProj.getName()); -// if (isJavaProject) -// description.setNatureIds(new String[]{JavaCore.NATURE_ID}); - description.setLocation(null); - newProj.open(null); - newProj.setDescription(description, null); - } - - private boolean multipleComponentsDetected() { - StructureEdit se = null; - try { - se = StructureEdit.getStructureEditForRead(project); - if (se == null) return false; - if (se.getComponentModelRoot() == null) return false; - return se.getComponentModelRoot().getComponents().size() > 1; - } finally { - if (se != null) - se.dispose(); - } - } - - private void removeComponentBuilders(IProject aProject) { - try { - aProject.refreshLocal(IResource.DEPTH_INFINITE,null); - } catch (CoreException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - //IJavaProject javaP = JemProjectUtilities.getJavaProject(aProject); - List oldBuilders = new ArrayList(); - oldBuilders.add("org.eclipse.wst.common.modulecore.ComponentStructuralBuilder"); - oldBuilders.add("org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver"); - oldBuilders.add("org.eclipse.wst.common.modulecore.DependencyGraphBuilder"); - try { - J2EEProjectUtilities.removeBuilders(aProject,oldBuilders); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public String getFacetFromProject(IProject aProject) { - return J2EEProjectUtilities.getJ2EEProjectType(aProject); - } - - - protected IDataModel setupJavaInstallAction(IProject aProject, boolean existing,String srcFolder) { - IDataModel dm = DataModelFactory.createDataModel(new JavaFacetInstallDataModelProvider()); - dm.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - String jVersion = "1.4"; - IScopeContext context = new ProjectScope( project ); - IEclipsePreferences prefs - = context.getNode( JavaCore.PLUGIN_ID ); - if (JavaCore.VERSION_1_5.equals(prefs.get(JavaCore.COMPILER_COMPLIANCE,JavaCore.VERSION_1_4))) { - jVersion = "5.0"; - } - dm.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, jVersion); //$NON-NLS-1$ - if (!existing) - dm.setStringProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME, srcFolder); //$NON-NLS-1$ - return dm; - } - - protected IDataModel setupUtilInstallAction(IProject aProject,String specVersion) { - IDataModel aFacetInstallDataModel = DataModelFactory.createDataModel(new UtilityFacetInstallDataModelProvider()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, specVersion); - aFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR,false); - aFacetInstallDataModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME,null); - return aFacetInstallDataModel; - } - protected IDataModel setupEarInstallAction(IProject aProject,String specVersion) { - IDataModel earFacetInstallDataModel = DataModelFactory.createDataModel(new EarFacetInstallDataModelProvider()); - earFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - earFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, specVersion); - - return earFacetInstallDataModel; - } - protected IDataModel setupAppClientInstallAction(IProject aProject,String specVersion) { - IDataModel aFacetInstallDataModel = DataModelFactory.createDataModel(new AppClientFacetInstallDataModelProvider()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, specVersion); - aFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR,false); - aFacetInstallDataModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME,null); - aFacetInstallDataModel.setBooleanProperty(IAppClientFacetInstallDataModelProperties.CREATE_DEFAULT_MAIN_CLASS,false); - return aFacetInstallDataModel; - } - protected IDataModel setupConnectorInstallAction(IProject aProject,String specVersion) { - IDataModel aFacetInstallDataModel = DataModelFactory.createDataModel(new ConnectorFacetInstallDataModelProvider()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - aFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, specVersion); - aFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR,false); - aFacetInstallDataModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME,null); - return aFacetInstallDataModel; - } - - private void addFacets(IProject aProject) { - StructureEdit edit = null; - try { - edit = StructureEdit.getStructureEditForWrite(aProject); - if (edit == null) return; // Not a component project.... - edit.getModuleStructuralModel().setUseOldFormat(true); - if (edit.getComponent() == null) return; // Can't migrate - ComponentType type = edit.getComponent().getComponentType(); - if (type == null) return; // Can't migrate - String compId = type.getComponentTypeId(); - String specVersion = edit.getComponent().getComponentType().getVersion(); - moveMetaProperties(edit.getComponent(),type); - addFacetsToProject(aProject, compId, specVersion,true); - } - finally { - if (edit != null) { - edit.save(null); - edit.getModuleStructuralModel().setUseOldFormat(false); - edit.dispose(); - } - } - - } - - private void moveMetaProperties(WorkbenchComponent component, ComponentType type) { - List props = type.getProperties(); - List compProps = component.getProperties(); - for (Iterator iter = props.iterator(); iter.hasNext();) { - Property element = (Property) iter.next(); - Property newProp = ComponentcoreFactory.eINSTANCE.createProperty(); - newProp.setName(element.getName()); - newProp.setValue(element.getValue()); - compProps.add(newProp); - } - props.clear(); - } - - private void addFacetsToProject(IProject aProject, String compId, String specVersion,boolean existing) { - if (compId.equals(J2EEProjectUtilities.DYNAMIC_WEB)) - installWEBFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.EJB)) - installEJBFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.APPLICATION_CLIENT)) - installAppClientFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.ENTERPRISE_APPLICATION)) - installEARFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.JCA)) - installConnectorFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.UTILITY)) - installUtilityFacets(aProject,specVersion,existing); - else if (compId.equals(J2EEProjectUtilities.STATIC_WEB)) - installStaticWebFacets(aProject,specVersion,existing); - } - - private void installStaticWebFacets(IProject project2, String specVersion, boolean existing) { - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, project2.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - //facetDMs.add(setupJavaInstallAction(webProj,existing,CreationConstants.DEFAULT_WEB_SOURCE_FOLDER)); - IDataModel newModel = setupStaticWebInstallAction(project2); - facetDMs.add(newModel); - //setRuntime(webProj,dm); //Setting runtime property - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - } - - private IDataModel setupStaticWebInstallAction(IProject project2) { - IDataModel webFacetInstallDataModel = DataModelFactory.createDataModel(new SimpleWebFacetInstallDataModelProvider()); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, project2.getName()); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, "1.0"); - - return webFacetInstallDataModel; - } - - private void installUtilityFacets(IProject aProject, String specVersion, boolean existing) { - replaceDeployablesOutputIfNecessary(project); - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - facetDMs.add(setupJavaInstallAction(aProject,existing,"src")); - IDataModel newModel = setupUtilInstallAction(aProject,specVersion); - facetDMs.add(newModel); - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - - } - - private void installConnectorFacets(IProject aProject, String specVersion, boolean existing) { - replaceDeployablesOutputIfNecessary(project); - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - facetDMs.add(setupJavaInstallAction(aProject,existing,J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.JCA_CONTENT_FOLDER))); - IDataModel newModel = setupConnectorInstallAction(aProject,specVersion); - facetDMs.add(newModel); - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - - } - - private void installEARFacets(IProject aProject, String specVersion, boolean existing) { - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel newModel = setupEarInstallAction(aProject,specVersion); - facetDMs.add(newModel); - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - - } - - private void installAppClientFacets(IProject aProject, String specVersion, boolean existing) { - replaceDeployablesOutputIfNecessary(project); - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - facetDMs.add(setupJavaInstallAction(aProject,existing,J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.APP_CLIENT_CONTENT_FOLDER))); - IDataModel newModel = setupAppClientInstallAction(aProject,specVersion); - facetDMs.add(newModel); - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - - } - - private void installEJBFacets(IProject ejbProject2,String ejbVersion, boolean existing) { - replaceDeployablesOutputIfNecessary(project); - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, ejbProject2.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - facetDMs.add(setupJavaInstallAction(ejbProject2,existing,J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.EJB_CONTENT_FOLDER))); - IDataModel newModel = setupEjbInstallAction(ejbProject2,ejbVersion,existing); - facetDMs.add(newModel); - //setRuntime(ejbProject2,dm); //Setting runtime property - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } - - } - private void installWEBFacets(IProject webProj,String specVersion, boolean existing) { - removeOldWebContainerIfNecessary(project); - replaceDeployablesOutputIfNecessary(project); - - IDataModel dm = DataModelFactory.createDataModel(new FacetProjectCreationDataModelProvider()); - dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, webProj.getName()); - FacetDataModelMap facetDMs = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - facetDMs.add(setupJavaInstallAction(webProj,existing, CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER))); - IDataModel newModel = setupWebInstallAction(webProj,specVersion); - facetDMs.add(newModel); - //setRuntime(webProj,dm); //Setting runtime property - try { - /** - * Warning cleanup 12/07/2005 - */ - //IStatus stat = dm.getDefaultOperation().execute(null,null); - dm.getDefaultOperation().execute(null,null); - } catch (ExecutionException e) { - Throwable realException = e.getCause(); - if (realException != null && realException instanceof CoreException) { - IStatus st = ((CoreException)realException).getStatus(); - if (st != null) - System.out.println(st); - realException.printStackTrace(); - } - } catch (Exception ex) { - if (ex != null && ex instanceof CoreException) { - IStatus st = ((CoreException)ex).getStatus(); - if (st != null) - System.out.println(st); - ex.printStackTrace(); - } - } - - - } - private void replaceDeployablesOutputIfNecessary(IProject proj) { - - - IJavaProject jproj = JemProjectUtilities.getJavaProject(proj); - final IClasspathEntry[] current; - boolean deployablesFound = false; - try { - current = jproj.getRawClasspath(); - List updatedList = new ArrayList(); - IPath sourcePath = null; - for (int i = 0; i < current.length; i++) { - IClasspathEntry entry = current[i]; - if ((entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) && (entry.getOutputLocation() != null && entry.getOutputLocation().toString().indexOf(OLD_DEPLOYABLES_PATH) != -1)) { - sourcePath = entry.getPath(); - updatedList.add(JavaCore.newSourceEntry(sourcePath)); - deployablesFound = true; - } - else - updatedList.add(entry); - } - if (deployablesFound) { - IClasspathEntry[] updated = (IClasspathEntry[])updatedList.toArray(new IClasspathEntry[updatedList.size()]); - jproj.setRawClasspath(updated, null); - jproj.save(null, true); - } - } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - - } - - private void removeOldWebContainerIfNecessary(IProject webProj) { - - IJavaProject jproj = JemProjectUtilities.getJavaProject(webProj); - final IClasspathEntry[] current; - try { - current = jproj.getRawClasspath(); - List updatedList = new ArrayList(); - boolean useDefaultWebAppLibraries = J2EEComponentClasspathContainerUtils.getDefaultUseWebAppLibraries(); - for (int i = 0; i < current.length; i++) { - IClasspathEntry entry = current[i]; - // the web container is added to the classpath if: - // 1. they don't have an entry for WEB_LIB_CONTAINER AND - // 2. they have an entry for WEB_LIB_PATH BUT - // they do not have the preference checked to use the Web App classpath container - if ((entry.getPath().toString().indexOf(WEB_LIB_CONTAINER) == -1) && - ((entry.getPath().toString().indexOf(WEB_LIB_PATH) == -1) || !useDefaultWebAppLibraries)) - updatedList.add(entry); - } - IClasspathEntry[] updated = (IClasspathEntry[])updatedList.toArray(new IClasspathEntry[updatedList.size()]); - jproj.setRawClasspath(updated, null); - jproj.save(null, true); - } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - protected IRuntime getRuntimeByID(String id) { - IRuntime[] targets = ServerUtil.getRuntimes("", ""); - for (int i = 0; i < targets.length; i++) { - IRuntime target = targets[i]; - if (id.equals(target.getId())) - return target; - } - return null; - } - - protected IDataModel setupEjbInstallAction(IProject aProject,String ejbVersion, boolean existing) { - IDataModel ejbFacetInstallDataModel = DataModelFactory.createDataModel(new EjbFacetInstallDataModelProvider()); - ejbFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - ejbFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, ejbVersion); - ejbFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR,false); - ejbFacetInstallDataModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME,null); - if (!existing) - ejbFacetInstallDataModel.setProperty(IEjbFacetInstallDataModelProperties.CONFIG_FOLDER, J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.EJB_CONTENT_FOLDER)); - return ejbFacetInstallDataModel; - } - - protected IDataModel setupWebInstallAction(IProject aProject,String specVersion) { - IDataModel webFacetInstallDataModel = DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider()); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME, aProject.getName()); - webFacetInstallDataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, specVersion); - webFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR,false); - webFacetInstallDataModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME,null); - return webFacetInstallDataModel; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEDependenciesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEDependenciesPage.java deleted file mode 100644 index 31d0c7997..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEDependenciesPage.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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 implementation as prop page heirarchy - * rfrost@bea.com - conversion to single property page impl - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * Primary project property page for J2EE dependencies; content is dynamically - * generated based on the project facets and will be comprised by a - * set of IJ2EEDependenciesControl implementations. - */ -public class J2EEDependenciesPage extends PropertyPage { - - public String DESCRIPTION = J2EEUIMessages.getResourceString("DESCRIPTION"); //$NON-NLS-1$ - - private IProject project; - private IJ2EEDependenciesControl[] controls = new IJ2EEDependenciesControl[0]; - - public J2EEDependenciesPage() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - - // Need to find out what type of project we are handling - project = (IProject) getElement().getAdapter(IResource.class); - boolean isEAR = false; - boolean isWEB = false; - try { - final IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if (facetedProject == null) { - return getFacetErrorComposite(parent); - } - isEAR = facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE)); - isWEB = facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE)); - } catch (CoreException ce) { - return getFacetErrorComposite(parent); - } - - if (isEAR) { - return createEARContent(parent); - } else if (isWEB) { - return createWebContent(parent); - } else { - return createNonEARContent(parent); - } - } - - private Composite getFacetErrorComposite(final Composite parent) { - final String errorCheckingFacet = ManifestUIResourceHandler.Error_Checking_Project_Facets; - setErrorMessage(errorCheckingFacet); - setValid(false); - return getErrorComposite(parent, errorCheckingFacet); - } - - private Composite getErrorComposite(final Composite parent, final String error) { - final Composite composite = new Composite(parent, SWT.NONE); - final GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - final Label label= new Label(composite, SWT.NONE); - label.setText(error); - return composite; - } - - private Composite createEARContent(final Composite parent) { - controls = new IJ2EEDependenciesControl[1]; - controls[0] = new AddModulestoEARPropertiesPage(project, this); - return controls[0].createContents(parent); - } - - private Composite createWebContent(final Composite parent) { - final boolean standalone = J2EEProjectUtilities.isStandaloneProject(project); - - if (standalone) { - // only need to create the Web Libraries page - controls = new IJ2EEDependenciesControl[1]; - controls[0] = new WebLibDependencyPropertiesPage(project, this); - return controls[0].createContents(parent); - } else { - // Create a tabbed folder with both "J2EE Modules" and "Web Libraries" - final TabFolder folder = new TabFolder(parent, SWT.LEFT); - folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - folder.setFont(parent.getFont()); - - // Create the two tabs - controls = new IJ2EEDependenciesControl[2]; - - controls[0] = new JARDependencyPropertiesPage(project, this); - TabItem tab = new TabItem(folder, SWT.NONE); - tab.setControl(controls[0].createContents(folder)); - tab.setText(ManifestUIResourceHandler.J2EE_Modules); - controls[1] = new WebLibDependencyPropertiesPage(project, this); - tab = new TabItem(folder, SWT.NONE); - tab.setControl(controls[1].createContents(folder)); - tab.setText(ManifestUIResourceHandler.Web_Libraries); - - folder.setSelection(0); - return folder; - } - } - - private Composite createNonEARContent(final Composite parent) { - controls = new IJ2EEDependenciesControl[1]; - final boolean standalone = J2EEProjectUtilities.isStandaloneProject(project); - if (standalone) { - // if not referenced by an EAR, check if referenced by a dynamic web project - if (J2EEProjectUtilities.getReferencingWebProjects(project).length > 0) { - controls[0] = new WebRefDependencyPropertiesPage(project, this); - } else { - return getUnreferencedErrorComposite(parent); - } - } else { - controls[0] = new JARDependencyPropertiesPage(project, this); - } - - return controls[0].createContents(parent); - } - - private Composite getUnreferencedErrorComposite(final Composite parent) { - final String msg = ManifestUIResourceHandler.Unreferenced_Module_Error; - setErrorMessage(msg); - return getErrorComposite(parent, msg); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - for (int i = 0; i < controls.length; i++) { - if (controls[i] != null) { - if (!controls[i].performOk()) { - return false; - } - } - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#performDefaults() - */ - public void performDefaults() { - for (int i = 0; i < controls.length; i++) { - if (controls[i] != null) { - controls[i].performDefaults(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferencePage#performCancel() - */ - public boolean performCancel() { - for (int i = 0; i < controls.length; i++) { - if (controls[i] != null) { - if (!controls[i].performCancel()) { - return false; - } - } - } - return super.performCancel(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - for (int i = 0; i < controls.length; i++) { - if (controls[i] != null) { - controls[i].setVisible(visible); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - public void dispose() { - super.dispose(); - for (int i = 0; i < controls.length; i++) { - if(controls[i] != null){ - controls[i].dispose(); - } - } - } - - protected static void createDescriptionComposite(final Composite parent, final String description) { - Composite descriptionComp = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - descriptionComp.setLayout(layout); - descriptionComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - fillDescription(descriptionComp, description); - } - - private static void fillDescription(Composite c, String s) { - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 250; - Text text = new Text(c, SWT.READ_ONLY | SWT.WRAP); - text.setLayoutData(data); - text.setText(s); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEPropertiesConstants.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEPropertiesConstants.java deleted file mode 100644 index ddfb3eec6..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/J2EEPropertiesConstants.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Apr 8, 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; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -/** - * @author vijayb - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public interface J2EEPropertiesConstants { - //J2EEUIMessages.getResourceString("Import_Classes"); - public String J2EE_LEVEL = J2EEUIMessages.getResourceString("J2EE_Level"); //$NON-NLS-1$ - public String J2EE_12 = J2EEUIMessages.getResourceString("J2EE_12"); //$NON-NLS-1$ - public String J2EE_12_DESCRIPTION = J2EEUIMessages.getResourceString("J2EE_12_DESCRIPTION"); //$NON-NLS-1$ - public String J2EE_13 = J2EEUIMessages.getResourceString("J2EE_13"); //$NON-NLS-1$ - public String J2EE_13_DESCRIPTION = J2EEUIMessages.getResourceString("J2EE_13_DESCRIPTION"); //$NON-NLS-1$ - public String J2EE_14_DESCRIPTION = J2EEUIMessages.getResourceString("J2EE_14_DESCRIPTION"); //$NON-NLS-1$ - public String EJB_LEVEL = J2EEUIMessages.getResourceString("EJB_LEVEL"); //$NON-NLS-1$ - public String EJB_11 = J2EEUIMessages.getResourceString("EJB_11"); //$NON-NLS-1$ - public String EJB_11_DESCRIPTION = J2EEUIMessages.getResourceString("EJB_11_DESCRIPTION"); //$NON-NLS-1$ - public String EJB_20 = J2EEUIMessages.getResourceString("EJB_20"); //$NON-NLS-1$ - public String EJB_20_DESCRIPTION = J2EEUIMessages.getResourceString("EJB_20_DESCRIPTION"); //$NON-NLS-1$ - public String EJB_21_DESCRIPTION = J2EEUIMessages.getResourceString("EJB_21_DESCRIPTION"); //$NON-NLS-1$ - public String CONNECTOR_LEVEL = J2EEUIMessages.getResourceString("CONNECTOR_LEVEL"); //$NON-NLS-1$ - public String CONNECTOR_10 = J2EEUIMessages.getResourceString("CONNECTOR_10"); //$NON-NLS-1$ - public String CONNECTOR_15 = J2EEUIMessages.getResourceString("CONNECTOR_15"); //$NON-NLS-1$ - public String CONNECTOR_10_DESCRIPTION = J2EEUIMessages.getResourceString("CONNECTOR_10_DESCRIPTION"); //$NON-NLS-1$ - public String CONNECTOR_15_DESCRIPTION = J2EEUIMessages.getResourceString("CONNECTOR_15_DESCRIPTION"); //$NON-NLS-1$ - public String WEB_LEVEL = J2EEUIMessages.getResourceString("WEB_LEVEL"); //$NON-NLS-1$ - public String WEB_22_DESCRIPTION = J2EEUIMessages.getResourceString("WEB_22_DESCRIPTION"); //$NON-NLS-1$ - public String WEB_23_DESCRIPTION = J2EEUIMessages.getResourceString("WEB_23_DESCRIPTION"); //$NON-NLS-1$ - public String WEB_24_DESCRIPTION = J2EEUIMessages.getResourceString("WEB_24_DESCRIPTION"); //$NON-NLS-1$ - public String APP_CLIENT_LEVEL = J2EEUIMessages.getResourceString("APP_CLIENT_LEVEL"); //$NON-NLS-1$ - public String APP_CLIENT_12_DESCRIPTION = J2EEUIMessages.getResourceString("APP_CLIENT_12_DESCRIPTION"); //$NON-NLS-1$ - public String APP_CLIENT_13_DESCRIPTION = J2EEUIMessages.getResourceString("APP_CLIENT_13_DESCRIPTION"); //$NON-NLS-1$ - public String APP_CLIENT_14_DESCRIPTION = J2EEUIMessages.getResourceString("APP_CLIENT_14_DESCRIPTION"); //$NON-NLS-1$ - public String DESCRIPTION = J2EEUIMessages.getResourceString("DESCRIPTION"); //$NON-NLS-1$ - public String WEB_CONTEXT_ROOT = J2EEUIMessages.getResourceString("WEB_CONTEXT_ROOT"); //$NON-NLS-1$ - public String WEB_CONTENT_FOLDER_NAME = J2EEUIMessages.getResourceString("WEB_CONTENT_FOLDER_NAME"); //$NON-NLS-1$ - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java deleted file mode 100644 index bdcab2f56..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java +++ /dev/null @@ -1,1099 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - * Stefan Dimov, stefan.dimov@sap.com - bug 207826 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.jar.Manifest; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -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.emf.common.util.URI; -import org.eclipse.jdt.core.ElementChangedEvent; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IElementChangedListener; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaElementDelta; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection; -import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement; -import org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProperties; -import org.eclipse.jst.j2ee.application.internal.operations.UpdateManifestDataModelProvider; -import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.j2ee.classpathdep.UpdateClasspathAttributeUtil; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; -import org.eclipse.jst.j2ee.internal.common.ClasspathModel; -import org.eclipse.jst.j2ee.internal.common.ClasspathModelEvent; -import org.eclipse.jst.j2ee.internal.common.ClasspathModelListener; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.jst.j2ee.internal.listeners.IValidateEditListener; -import org.eclipse.jst.j2ee.internal.listeners.ValidateEditListener; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.model.IEARModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.application.Application; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -import org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFile; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -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.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.ui.WTPUIPlugin; -import org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class JARDependencyPropertiesPage implements IJ2EEDependenciesControl, IClasspathTableOwner, Listener, ClasspathModelListener, IElementChangedListener { - - protected final IProject project; - protected final J2EEDependenciesPage propPage; - protected IOException caughtManifestException; - protected boolean isDirty; - protected Text classPathText; - protected Text componentNameText; - protected ClasspathModel model; - protected CCombo availableAppsCombo; - protected ClasspathTableManager tableManager; - protected IValidateEditListener validateEditListener; - protected Label manifestLabel; - protected Label enterpriseApplicationLabel; - protected Label availableDependentJars; - private final Display display; - private boolean isDisposed = false; - - /** - * Constructor for JARDependencyPropertiesControl - */ - public JARDependencyPropertiesPage(final IProject project, final J2EEDependenciesPage page) { - super(); - J2EEComponentClasspathUpdater.getInstance().pauseUpdates(); - this.project = project; - this.propPage = page; - this.display = propPage.getShell().getDisplay(); - } - - /** - * Returns false if page should not be displayed for the project. - */ - protected void initialize() { - model = createClasspathModel(); - model.setProject(project); - if (model.getComponent() != null) { - model.addListener(this); - updateModelManifest(); - initializeValidateEditListener(); - } - } - - protected ClasspathModel createClasspathModel(){ - return new ClasspathModel(null, false); - } - - public void dispose() { - isDisposed = true; - JavaCore.removeElementChangedListener(this); - J2EEComponentClasspathUpdater.getInstance().resumeUpdates(); - } - - private void updateModelManifest() { - if (JemProjectUtilities.isBinaryProject(project) || model.getAvailableEARComponents().length == 0) - return; - - IVirtualComponent component = ComponentCore.createComponent(project); - if(component != null){ - IVirtualFile vManifest = component.getRootFolder().getFile(new Path(J2EEConstants.MANIFEST_URI)); - if(vManifest.exists()){ - IFile iManifest = vManifest.getUnderlyingFile(); - if(iManifest != null && iManifest.exists()){ - InputStream in = null; - try { - in = iManifest.getContents(); - ArchiveManifest mf = new ArchiveManifestImpl(new Manifest(in)); - model.primSetManifest(mf); - } catch (CoreException e) { - Logger.getLogger().logError(e); - model.primSetManifest(new ArchiveManifestImpl()); - } catch (IOException iox) { - Logger.getLogger().logError(iox); - model.primSetManifest(new ArchiveManifestImpl()); - caughtManifestException = iox; - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException weTried) { - // Ignore - } - } - } - } - } - } - } - - - protected void initializeValidateEditListener() { - validateEditListener = new ValidateEditListener(null, model); - validateEditListener.setShell(propPage.getShell()); - } - - public void setVisible(boolean visible) { - if (visible) { - if (caughtManifestException != null && !model.isDirty()) { - ManifestErrorPrompter.showManifestException(propPage.getShell(), ERROR_READING_MANIFEST_DIALOG_MESSAGE_PROP_PAGE, false, caughtManifestException); - } - } - } - - /** - * Refreshes the ClasspathModel if the project classpath is changed. - */ - public void elementChanged(final ElementChangedEvent event) { - if (event.getType() == ElementChangedEvent.POST_CHANGE && classpathChanged(event.getDelta())) { - // trigger a recomputation and refresh for the currently selected EAR - if (!isDisposed) { - display.asyncExec (new Runnable () { - public void run () { - if (!isDisposed) { - handleClasspathChange(); - } - } - }); - } - } - } - - /** - * Called to refresh the UI when the classpath changes - */ - protected void handleClasspathChange() { - model.resetClassPathSelection(); - refresh(); - } - - private boolean classpathChanged(final IJavaElementDelta delta) { - final int kind = delta.getKind(); - if (kind == IJavaElementDelta.CHANGED) { - final int flags = delta.getFlags(); - final IJavaElement element = delta.getElement(); - if (element instanceof IJavaModel) { - if ((flags & IJavaElementDelta.F_CHILDREN) == IJavaElementDelta.F_CHILDREN) { - final IJavaElementDelta[] children = delta.getChangedChildren(); - for (int i = 0; i < children.length; i++) { - // check all of the IJavaProject children - if (classpathChanged(children[i])) { - return true; - } - } - } - } else if (element instanceof IJavaProject) { - // check if we either have a direct indication of a classpath change or a delta on the - // .classpath file (changes to classpath entry attributes only give us this...) - final IJavaProject jproject = (IJavaProject) element; - final IProject eventProject = jproject.getProject(); - if (eventProject.equals(project)) { - if ((flags & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) { - return true; - } - final IResourceDelta[] deltas = delta.getResourceDeltas(); - if (deltas != null) { - for (int i = 0; i < deltas.length; i++) { - if (deltas[i].getProjectRelativePath().toString().equals(".classpath")) { //$NON-NLS-1$ - return true; - } - } - } - } - } - } - return false; - } - - public Composite createContents(Composite parent) { - initialize(); - Composite composite = createBasicComposite(parent); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - if (model.getComponent() != null) { - if (!isValidComponent()) - return composite; - J2EEDependenciesPage.createDescriptionComposite(composite, ManifestUIResourceHandler.J2EE_Modules_Desc); - createProjectLabelsGroup(composite); - createListGroup(composite); - createTextGroup(composite); - refresh(); - } - Dialog.applyDialogFont(parent); - postCreateContents(); - return composite; - } - - /** - * Called at the end of createContents(). - */ - protected void postCreateContents() { - // register this object as an IElementChangedListener so that it will react to user changes to the Java build path - JavaCore.addElementChangedListener(this); - } - - /** - * @param comp - * @return - */ - protected Composite createBasicComposite(Composite comp) { - Composite composite = new Composite(comp, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - return composite; - } - - protected boolean isValidComponent() { - if (J2EEProjectUtilities.isEARProject(project)) { - propPage.setErrorMessage(ManifestUIResourceHandler.EAR_Module_Dep_Error); - return false; - } else if (J2EEProjectUtilities.isStandaloneProject(model.getComponent().getProject())) { - propPage.setErrorMessage(ClasspathModel.NO_EAR_MESSAGE); - return false; - } - return true; - } - - protected void createProjectLabelsGroup(Composite parent) { - - Composite labelsGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - labelsGroup.setLayout(layout); - labelsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - /* - * Label label = new Label(labelsGroup, SWT.NONE); - * label.setText(ManifestUIResourceHandler.Project_name__UI_); - * - * componentNameText = new Text(labelsGroup, SWT.BORDER); GridData data = new - * GridData(GridData.FILL_HORIZONTAL); componentNameText.setEditable(false); - * componentNameText.setLayoutData(data); componentNameText.setText(project.getName()); - */ - - createEnterpriseAppsControls(labelsGroup); - - } - - private void createEnterpriseAppsControls(Composite labelsGroup) { - - enterpriseApplicationLabel = new Label(labelsGroup, SWT.NONE); - enterpriseApplicationLabel.setText(ManifestUIResourceHandler.EAR_Project_Name__UI__UI_); - - availableAppsCombo = new CCombo(labelsGroup, SWT.READ_ONLY | SWT.BORDER); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - availableAppsCombo.setLayoutData(gd); - - availableAppsCombo.addListener(SWT.Selection, this); - - } - - protected void createListGroup(Composite parent) { - Composite listGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - layout.marginHeight = 0; - listGroup.setLayout(layout); - GridData gData = new GridData(GridData.FILL_BOTH); - gData.horizontalIndent = 5; - listGroup.setLayoutData(gData); - - availableDependentJars = new Label(listGroup, SWT.NONE); - gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - availableDependentJars.setText(ManifestUIResourceHandler.Available_dependent_JARs__UI_); - availableDependentJars.setLayoutData(gData); - createTableComposite(listGroup); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.etools.j2ee.common.ui.classpath.IClasspathTableOwner#createGroup(org.eclipse.swt.widgets.Composite) - */ - public Group createGroup(Composite parent) { - return new Group(parent, SWT.NULL); - } - - protected void createTextGroup(Composite parent) { - - Composite textGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - textGroup.setLayout(layout); - textGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL)); - - createClassPathText(textGroup); - - } - - protected void createClassPathText(Composite textGroup) { - - manifestLabel = new Label(textGroup, SWT.NONE); - manifestLabel.setText(ManifestUIResourceHandler.Manifest_Class_Path__UI_); - - classPathText = new Text(textGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - GridData gData = new GridData(GridData.FILL_BOTH); - gData.widthHint = 400; - gData.heightHint = 100; - classPathText.setLayoutData(gData); - classPathText.setEditable(false); - } - - protected void createTableComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridData gData = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gData); - tableManager = new ClasspathTableManager(this, model, validateEditListener); - tableManager.fillComposite(composite); - } - - /** - * @see IClasspathTableOwner#createAvailableJARsViewer(Composite) - */ - public CheckboxTableViewer createAvailableJARsViewer(Composite parent) { - int flags = SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI; - - Table table = new Table(parent, flags); - CheckboxTableViewer availableJARsViewer = new CheckboxTableViewer(table); - - // set up table layout - TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout(); - tableLayout.addColumnData(new ColumnWeightData(200, true)); - tableLayout.addColumnData(new ColumnWeightData(200, true)); - table.setLayout(tableLayout); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - // do not create sorter otherwise order will go wrong - //availableJARsViewer.setSorter(new ViewerSorter()); - - // table columns - TableColumn fileNameColumn = new TableColumn(table, SWT.NONE, 0); - fileNameColumn.setText(ManifestUIResourceHandler.JAR_Module_UI_); - fileNameColumn.setResizable(true); - - TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1); - projectColumn.setText(ManifestUIResourceHandler.Project_UI_); - projectColumn.setResizable(true); - tableLayout.layout(table, true); - return availableJARsViewer; - - } - - /** - * @see IClasspathTableOwner#createButtonColumnComposite(Composite) - */ - public Composite createButtonColumnComposite(Composite parent) { - Composite buttonColumn = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 0; - layout.marginWidth = 0; - buttonColumn.setLayout(layout); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - buttonColumn.setLayoutData(data); - return buttonColumn; - } - - /** - * @see IClasspathTableOwner - */ - public Button primCreatePushButton(String label, Composite buttonColumn) { - Button aButton = new Button(buttonColumn, SWT.PUSH); - aButton.setText(label); - return aButton; - } - - /** - * @see IClasspathTableOwner - */ - public Button primCreateRadioButton(String label, Composite parent) { - Button aButton = new Button(parent, SWT.RADIO); - aButton.setText(label); - return aButton; - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == availableAppsCombo) - availableAppsSelected(event); - } - - protected void availableAppsSelected(Event event) { - int index = availableAppsCombo.getSelectionIndex(); - model.selectEAR(index); - } - - protected void populateApps() { - IVirtualComponent[] components = model.getAvailableEARComponents(); - String[] values = new String[components.length]; - for (int i = 0; i < components.length; i++) { - values[i] = components[i].getProject().getName(); - } - if (availableAppsCombo != null) { - availableAppsCombo.setItems(values); - IVirtualComponent selected = model.getSelectedEARComponent(); - if (selected != null) { - int index = Arrays.asList(components).indexOf(selected); - availableAppsCombo.select(index); - } else - availableAppsCombo.clearSelection(); - } - } - - protected void refresh() { - populateApps(); - if (tableManager != null) { - tableManager.refresh(); - } - refreshText(); - } - - - public void refreshText() { - ClassPathSelection sel = model.getClassPathSelection(); - if (sel != null && classPathText != null) - classPathText.setText(sel == null ? "" : sel.toString()); //$NON-NLS-1$ - } - - /** - * @see ClasspathModelListener#modelChanged(ClasspathModelEvent) - */ - public void modelChanged(ClasspathModelEvent evt) { - if (evt.getEventType() == ClasspathModelEvent.CLASS_PATH_CHANGED) { - isDirty = true; - refreshText(); - } else if (evt.getEventType() == ClasspathModelEvent.EAR_PROJECT_CHANGED) { - tableManager.refresh(); - } - } - - public void performDefaults() { - model.resetClassPathSelection(); - refresh(); - isDirty = false; - model.dispose(); - } - - public boolean performCancel() { - model.dispose(); - return true; - } - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - if (!isDirty) - return true; - modifyEARBundledLibs(); - WorkspaceModifyComposedOperation composed = new WorkspaceModifyComposedOperation(createManifestOperation()); - createClasspathAttributeUpdateOperation(composed, model.getClassPathSelection(), false); - try { - new ProgressMonitorDialog(propPage.getShell()).run(true, true, composed); - } catch (InvocationTargetException ex) { - String title = ManifestUIResourceHandler.An_internal_error_occurred_ERROR_; - String msg = title; - if (ex.getTargetException() != null && ex.getTargetException().getMessage() != null) - msg = ex.getTargetException().getMessage(); - MessageDialog.openError(propPage.getShell(), title, msg); - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex); - return false; - } catch (InterruptedException e) { - // cancelled - return false; - } finally { - model.dispose(); - } - isDirty = false; - return true; - } - - List getUnSelectedClassPathElementsForJ2EEDependency() { - List unselectedForJ2EE = getUnSelectedClassPathSelection().getClasspathElements(); - - List unselected = new ArrayList(); - if (model != null && model.getClassPathSelectionForWLPs() != null) { - List wlpSelected = model.getClassPathSelectionForWLPs().getSelectedClasspathElements(); - - java.util.Iterator it = unselectedForJ2EE.iterator(); - - while (it.hasNext()) { - ClasspathElement element = (ClasspathElement) it.next(); - java.util.Iterator wlpIterator = wlpSelected.iterator(); - boolean found = false; - while (wlpIterator.hasNext()) { - ClasspathElement wlpElement = (ClasspathElement) wlpIterator.next(); - String text = element.getText(); - int index = text.indexOf(".jar"); - if (index != -1) { - text = text.substring(0, index); - if (text.equals(wlpElement.getText())) { - found = true; - break; - } - } - } - if (!found) { - if (!unselected.contains(element)) - unselected.add(element); - } - - } - } - return unselected; - } - - - /** - * @deprecated don't use this method it will be deleted - * @return - */ - List getUnSelectedClassPathElementsForWebDependency() { - List unselectedForWLP = getUnSelectedClassPathSelectionForWLPs().getClasspathElements(); - List unselected = new ArrayList(); - if (model != null && model.getClassPathSelection() != null) { - List j2eeSelected = model.getClassPathSelection().getSelectedClasspathElements(); - java.util.Iterator it = unselectedForWLP.iterator(); - - while (it.hasNext()) { - ClasspathElement element = (ClasspathElement) it.next(); - java.util.Iterator j2eeIterator = j2eeSelected.iterator(); - boolean found = false; - while (j2eeIterator.hasNext()) { - ClasspathElement j2eeElement = (ClasspathElement) j2eeIterator.next(); - String text = j2eeElement.getText(); - int index = text.indexOf(".jar"); - if( index != -1 ){ - text = text.substring(0, index); - if (element.getText().equals(text)) { - found = true; - break; - } - } - } - if (!found) { - if (!unselected.contains(element)) - unselected.add(element); - } - - } - } else { - unselected = unselectedForWLP; - } - return unselected; - } - - /** - * DoNotUseMeThisWillBeDeletedPost15 - * @return - */ - protected WorkspaceModifyComposedOperation createJ2EEComponentDependencyOperations() { - WorkspaceModifyComposedOperation composedOp = null; - List selected = getSelectedClassPathSelection().getClasspathElements(); - List unselected = getUnSelectedClassPathElementsForJ2EEDependency(); - - List targetComponentsHandles = new ArrayList(); - for (int i = 0; i < selected.size(); i++) { - ClasspathElement element = (ClasspathElement) selected.get(i); - IVirtualComponent component = element.getComponent(); - if (null != component) { - targetComponentsHandles.add(component); - } - } - if (!targetComponentsHandles.isEmpty()) { - composedOp = new WorkspaceModifyComposedOperation(); - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(ComponentUtilities.createReferenceComponentOperation(model.getComponent(), targetComponentsHandles))); - } - targetComponentsHandles = new ArrayList(); - for (int i = 0; i < unselected.size(); i++) { - ClasspathElement element = (ClasspathElement) unselected.get(i); - IProject elementProject = element.getProject(); - if (elementProject != null) { - if (ModuleCoreNature.isFlexibleProject(elementProject)) { - IVirtualComponent targetComp = ComponentCore.createComponent(elementProject); - targetComponentsHandles.add(targetComp); - } - } else { - URI archiveURI = element.getArchiveURI(); - if (archiveURI != null && !archiveURI.equals("")) { //$NON-NLS-1$ - String name = ""; //$NON-NLS-1$ - try { - String type = ModuleURIUtil.getArchiveType(archiveURI); - String tmpname = ModuleURIUtil.getArchiveName(archiveURI); - name = type + IPath.SEPARATOR + tmpname; - } catch (UnresolveableURIException e) { - Logger.getLogger().logError(e.getMessage()); - } - if (!name.equals("")) { //$NON-NLS-1$ - IVirtualReference ref = model.getComponent().getReference(name); - if (ref != null) { - IVirtualComponent referenced = ref.getReferencedComponent(); - targetComponentsHandles.add(referenced); - } - } - } - } - } - if (!targetComponentsHandles.isEmpty()) { - if (composedOp == null) - composedOp = new WorkspaceModifyComposedOperation(); - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(ComponentUtilities.removeReferenceComponentOperation(model.getComponent(), targetComponentsHandles))); - } - return composedOp; - } - - - /** - * This should be moved to the {@link WebLibDependencyPropertiesPage} because it is only used there. - * @return - */ - protected WorkspaceModifyComposedOperation createComponentDependencyOperations() { - WorkspaceModifyComposedOperation composedOp = null; - final ClassPathSelection selectedWLPs = getSelectedClassPathSelectionForWLPs(); - List selected = selectedWLPs.getClasspathElements(); - List unselected = getUnSelectedClassPathSelectionForWLPs().getClasspathElements(); - - List targetComponentsHandles = new ArrayList(); - for (int i = 0; i < selected.size(); i++) { - ClasspathElement element = (ClasspathElement) selected.get(i); - if (element.isClasspathDependency() || element.isClasspathEntry()) { - continue; - } - IProject elementProject = element.getProject(); - if (elementProject != null) { - IVirtualComponent targetComp = ComponentCore.createComponent(elementProject); - targetComponentsHandles.add(targetComp); - } - } - if (!targetComponentsHandles.isEmpty()) { - composedOp = new WorkspaceModifyComposedOperation(); - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(ComponentUtilities.createWLPReferenceComponentOperation(model.getComponent(), targetComponentsHandles))); - } - targetComponentsHandles = new ArrayList(); - for (int i = 0; i < unselected.size(); i++) { - ClasspathElement element = (ClasspathElement) unselected.get(i); - if (element.isClasspathDependency() || element.isClasspathEntry()) { - continue; - } - IProject elementProject = element.getProject(); - if (elementProject != null) { - if (ModuleCoreNature.isFlexibleProject(elementProject)) { - IVirtualComponent targetComp = ComponentCore.createComponent(elementProject); - targetComponentsHandles.add(targetComp); - } - } else { - URI archiveURI = element.getArchiveURI(); - if (archiveURI != null && !archiveURI.equals("")) { //$NON-NLS-1$ - String name = ""; //$NON-NLS-1$ - try { - String type = ModuleURIUtil.getArchiveType(archiveURI); - String tmpname = ModuleURIUtil.getArchiveName(archiveURI); - name = type + IPath.SEPARATOR + tmpname; - } catch (UnresolveableURIException e) { - Logger.getLogger().logError(e.getMessage()); - } - if (!name.equals("")) { //$NON-NLS-1$ - IVirtualReference ref = model.getComponent().getReference(name); - IVirtualComponent referenced = ref.getReferencedComponent(); - targetComponentsHandles.add(referenced); - } - } - } - } - if (!targetComponentsHandles.isEmpty()) { - if (composedOp == null) { - composedOp = new WorkspaceModifyComposedOperation(); - } - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(ComponentUtilities.removeWLPReferenceComponentOperation(model.getComponent(), targetComponentsHandles))); - } - - if (composedOp == null) { - composedOp = new WorkspaceModifyComposedOperation(); - } - createClasspathAttributeUpdateOperation(composedOp, model.getClassPathSelectionForWLPs(), true); - - return composedOp; - } - - protected WorkspaceModifyComposedOperation createFlexProjectOperations() { - WorkspaceModifyComposedOperation composedOp = null; - Object[] elements = tableManager.availableJARsViewer.getCheckedElements(); - for (int i = 0; i < elements.length; i++) { - ClasspathElement element = (ClasspathElement) elements[i]; - IProject elementProject = element.getProject(); - try { - if (elementProject != null && !elementProject.hasNature(IModuleConstants.MODULE_NATURE_ID)) { - if (composedOp == null) { - composedOp = new WorkspaceModifyComposedOperation(); - } - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(elementProject, false))); - } - } catch (CoreException e) { - Logger.getLogger().logError(e); - } - } - return composedOp; - } - - protected ClassPathSelection getUnSelectedClassPathSelectionForWLPs() { - ClassPathSelection selection = new ClassPathSelection(); - Object[] checkedElements = tableManager.availableJARsViewer.getCheckedElements(); - List modelElements = model.getClassPathSelectionForWLPs().getClasspathElements(); - for (int i = 0; i < modelElements.size(); i++) { - List checkedElementsList = Arrays.asList(checkedElements); - if (!checkedElementsList.contains(modelElements.get(i))) { - selection.getClasspathElements().add(modelElements.get(i)); - } - } - return selection; - } - - private ClassPathSelection getSelectedClassPathSelection() { - ClassPathSelection selection = new ClassPathSelection(); - Object[] checkedElements = tableManager.availableJARsViewer.getCheckedElements(); - for (int i = 0; i < checkedElements.length; i++) { - selection.getClasspathElements().add(checkedElements[i]); - } - return selection; - } - - protected ClassPathSelection getUnSelectedClassPathSelection() { - ClassPathSelection selection = new ClassPathSelection(); - Object[] checkedElements = tableManager.availableJARsViewer.getCheckedElements(); - List modelElements = model.getClassPathSelection().getClasspathElements(); - for (int i = 0; i < modelElements.size(); i++) { - List checkedElementsList = Arrays.asList(checkedElements); - if (!checkedElementsList.contains(modelElements.get(i))) { - selection.getClasspathElements().add(modelElements.get(i)); - } - } - return selection; - } - - - private ClassPathSelection getSelectedClassPathSelectionForWLPs() { - ClassPathSelection selection = new ClassPathSelection(); - Object[] checkedElements = tableManager.availableJARsViewer.getCheckedElements(); - for (int i = 0; i < checkedElements.length; i++) { - selection.getClasspathElements().add(checkedElements[i]); - } - return selection; - } - - protected UpdateManifestOperation createManifestOperation() { - return new UpdateManifestOperation(project.getName(), model.getClassPathSelection().toString(), true); - } - - protected void createClasspathAttributeUpdateOperation(final WorkspaceModifyComposedOperation composedOp, final ClassPathSelection selection, final boolean isWebApp) { - final Map selectedEntriesToRuntimePath = new HashMap(); - final Map unselectedEntriesToRuntimePath = new HashMap(); - final List elements = selection.getClasspathElements(); - for (int i = 0; i < elements.size(); i++) { - final ClasspathElement element = (ClasspathElement) elements.get(i); - if (element.isClasspathEntry()) { - final IClasspathEntry entry = element.getClasspathEntry(); - final IClasspathAttribute attrib = ClasspathDependencyUtil.checkForComponentDependencyAttribute(entry); - boolean hasDepAttrib = false; - if (attrib != null && attrib.getName().equals(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY)) { - hasDepAttrib = true; - } - final IPath runtimePath = ClasspathDependencyUtil.getRuntimePath(attrib, isWebApp, ClasspathDependencyUtil.isClassFolderEntry(entry)); - if (element.isSelected()) { - // only add if we don't already have the attribute - if (!hasDepAttrib) { - selectedEntriesToRuntimePath.put(entry, runtimePath); - } - } else { - // only add if we already have the attribute - if (hasDepAttrib) { - unselectedEntriesToRuntimePath.put(entry, runtimePath); - } - } - } - } - - // if there are any attributes to add, create an operation to add all necessary attributes - if (!selectedEntriesToRuntimePath.isEmpty()) { - IDataModelOperation op = UpdateClasspathAttributeUtil.createAddDependencyAttributesOperation(project.getName(), selectedEntriesToRuntimePath); - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(op)); - } - // if there are any attributes to remove, create an operation to remove all necessary attributes - if (!unselectedEntriesToRuntimePath.isEmpty()) { - IDataModelOperation op = UpdateClasspathAttributeUtil.createRemoveDependencyAttributesOperation(project.getName(), unselectedEntriesToRuntimePath); - composedOp.addRunnable(WTPUIPlugin.getRunnableWithProgress(op)); - } - } - - protected boolean isReadOnly() { - return JemProjectUtilities.isBinaryProject(project) && (project.findMember(IModuleConstants.COMPONENT_FILE_PATH) == null) ; - } - - protected void modifyEARBundledLibs() { - List compsToUncheckList = tableManager.getCheckedLibsAsList(); - if (compsToUncheckList.size() == 0) return; - Set allCompsToUncheck = new HashSet(); - Set allCompNamesToUncheck = new HashSet(); - for (int i = 0; i < compsToUncheckList.size(); i++) { - IVirtualComponent comp = (IVirtualComponent)compsToUncheckList.get(i); - allCompsToUncheck.add(comp); - if (comp instanceof J2EEModuleVirtualArchiveComponent) allCompNamesToUncheck.add(comp.getName()); - } - IProject[] ears = J2EEProjectUtilities.getReferencingEARProjects(project); - for (int i = 0; i < ears.length; i++) { - IEARModelProvider earModel = (IEARModelProvider)ModelProviderManager.getModelProvider(ears[i]); - if (J2EEProjectUtilities.isJEEProject(ears[i])) { - IVirtualComponent earComponent = ComponentCore.createComponent(ears[i]); - List listToUncheck = createListToUncheck(earComponent, allCompsToUncheck, allCompNamesToUncheck); - if (listToUncheck.size() == 0) continue; - removeModulesFromEAR(new NullProgressMonitor(), earComponent, listToUncheck); - addModulesToEAR(new NullProgressMonitor(), earComponent, listToUncheck); - } - } - } - //--------------------------------- - private IStatus removeModulesFromEAR(IProgressMonitor monitor, final IVirtualComponent earComponent, final List compsToUncheckList) { - IStatus stat = IDataModelProvider.OK_STATUS; - String libDir = ((Application)ModelProviderManager.getModelProvider(earComponent.getProject()).getModelObject()).getLibraryDirectory(); - libDir = (libDir == null) ? J2EEConstants.EAR_DEFAULT_LIB_DIR : libDir; - Map dependentComps = getEARModuleDependencies(earComponent, compsToUncheckList); - try { - IDataModelOperation op = removeComponentFromEAROperation(earComponent, compsToUncheckList, libDir); - op.execute(null, null); - J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(earComponent.getProject()); - removeEARComponentDependencies(dependentComps); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - return stat; - } - - - private IStatus addModulesToEAR(IProgressMonitor monitor, final IVirtualComponent earComponent, final List compsToUncheckList) { - IStatus stat = IDataModelProvider.OK_STATUS; - try { - IWorkspaceRunnable runnable = new IWorkspaceRunnable(){ - public void run(IProgressMonitor monitor) throws CoreException{ - execAddOp(monitor, compsToUncheckList, J2EEConstants.EAR_ROOT_DIR, earComponent); - } - }; - J2EEUIPlugin.getWorkspace().run(runnable, monitor); - } catch (Exception e) { - Logger.getLogger().log(e); - } - return IDataModelProvider.OK_STATUS; - } - - private List createListToUncheck(IVirtualComponent earComponent, Set compsToUncheckList, Set compNamesToUncheck) { - LinkedList res = new LinkedList(); - IVirtualReference[] refs = earComponent.getReferences(); - for (int j = 0; j < refs.length; j++) { - if (!refs[j].getRuntimePath().isRoot() && - (compsToUncheckList.contains(refs[j].getReferencedComponent()) || - compNamesToUncheck.contains(refs[j].getReferencedComponent().getName()))) { - res.add(refs[j].getReferencedComponent()); - } - } - return res; - } - - private void execAddOp(IProgressMonitor monitor, List list, String path, IVirtualComponent earComponent) throws CoreException { - IDataModel dm = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider()); - - dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, earComponent); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, list); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path); - - IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - if (stat != IDataModelProvider.OK_STATUS) - throw new CoreException(stat); - try { - dm.getDefaultOperation().execute(monitor, null); - } catch (ExecutionException e) { - Logger.getLogger().log(e); - } - } - - - protected IDataModelOperation removeComponentFromEAROperation(IVirtualComponent sourceComponent, List targetComponentsHandles, String dir) { - IDataModel model = DataModelFactory.createDataModel(new RemoveComponentFromEnterpriseApplicationDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, sourceComponent); - List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.addAll(targetComponentsHandles); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, dir); - return model.getDefaultOperation(); - } - - private Map getEARModuleDependencies(final IVirtualComponent earComponent, final List components) { - final Map dependentComps = new HashMap(); - // get all current references to project within the scope of this EAR - for (int i = 0; i < components.size(); i++) { - - final List compsForProject = new ArrayList(); - final IVirtualComponent comp = (IVirtualComponent) components.get(i); - final IProject[] dependentProjects = DependencyGraphManager.getInstance().getDependencyGraph().getReferencingComponents(comp.getProject()); - for (int j = 0; j < dependentProjects.length; j++) { - final IProject project = dependentProjects[j]; - // if this is an EAR, can skip - if (J2EEProjectUtilities.isEARProject(project)) { - continue; - } - final IVirtualComponent dependentComp = ComponentCore.createComponent(project); - // ensure that the project's share an EAR - final IProject[] refEARs = J2EEProjectUtilities.getReferencingEARProjects(project); - boolean sameEAR = false; - for (int k = 0; k < refEARs.length; k++) { - if (refEARs[k].equals(earComponent.getProject())) { - sameEAR = true; - break; - } - } - if (!sameEAR) { - continue; - } - // if the dependency is a web lib dependency, can skip - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - IVirtualReference ref = dependentComp.getReference(comp.getName()); - if (ref != null && ref.getRuntimePath().equals(new Path("/WEB-INF/lib"))) { //$NON-NLS-1$ - continue; - } - } - compsForProject.add(dependentComp); - } - dependentComps.put(comp, compsForProject); - } - return dependentComps; - } - - private void removeEARComponentDependencies(final Map dependentComps) throws ExecutionException { - final Iterator targets = dependentComps.keySet().iterator(); - while (targets.hasNext()) { - final IVirtualComponent target = (IVirtualComponent) targets.next(); - final List sources = (List) dependentComps.get(target); - for (int i = 0; i < sources.size(); i++) { - final IVirtualComponent source = (IVirtualComponent) sources.get(i); - final IDataModel model = DataModelFactory.createDataModel(new RemoveReferenceComponentsDataModelProvider()); - model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, source); - final List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST); - modHandlesList.add(target); - model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList); - model.getDefaultOperation().execute(null, null); - // update the manifest - removeManifestDependency(source, target); - } - } - } - - private void removeManifestDependency(final IVirtualComponent source, final IVirtualComponent target) - throws ExecutionException { - final String sourceProjName = source.getProject().getName(); - final String targetProjName = target.getProject().getName(); - final IProgressMonitor monitor = new NullProgressMonitor(); - final IFile manifestmf = J2EEProjectUtilities.getManifestFile(source.getProject()); - final ArchiveManifest mf = J2EEProjectUtilities.readManifest(source.getProject()); - if (mf == null) - return; - final IDataModel updateManifestDataModel = DataModelFactory.createDataModel(new UpdateManifestDataModelProvider()); - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.PROJECT_NAME, sourceProjName); - updateManifestDataModel.setBooleanProperty(UpdateManifestDataModelProperties.MERGE, false); - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.MANIFEST_FILE, manifestmf); - String[] cp = mf.getClassPathTokenized(); - List cpList = new ArrayList(); - String cpToRemove = targetProjName + ".jar";//$NON-NLS-1$ - for (int i = 0; i < cp.length; i++) { - if (!cp[i].equals(cpToRemove)) { - cpList.add(cp[i]); - } - } - updateManifestDataModel.setProperty(UpdateManifestDataModelProperties.JAR_LIST, cpList); - updateManifestDataModel.getDefaultOperation().execute(monitor, null ); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestErrorPrompter.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestErrorPrompter.java deleted file mode 100644 index e70c7e7b1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestErrorPrompter.java +++ /dev/null @@ -1,54 +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 Jan 17, 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; - -import org.eclipse.jst.j2ee.internal.plugin.ErrorDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class ManifestErrorPrompter implements ICommonManifestUIConstants { - - /** - * Constructor for ManifestErrorPrompter. - */ - private ManifestErrorPrompter() { - super(); - } - - public static boolean showManifestException(Shell shell, String baseMessage, boolean includeCancel, Throwable caught) { - StringBuffer msg = new StringBuffer(baseMessage); - msg.append("\n"); //$NON-NLS-1$ - msg.append(MANIFEST_PROBLEM_1); - msg.append("\n"); //$NON-NLS-1$ - msg.append(MANIFEST_PROBLEM_2); - msg.append("\n"); //$NON-NLS-1$ - msg.append(MANIFEST_PROBLEM_3); - msg.append("\n"); //$NON-NLS-1$ - msg.append(MANIFEST_PROBLEM_4); - return ErrorDialog.openError(shell, - ERROR_READING_MANIFEST_DIALOG_TITLE, - msg.toString(), - caught, - 0, includeCancel); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestUIResourceHandler.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestUIResourceHandler.java deleted file mode 100644 index 50c1f238b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ManifestUIResourceHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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 - * Stefan Dimov, stefan.dimov@sap.com - bug 207826 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.osgi.util.NLS; - -public final class ManifestUIResourceHandler extends NLS { - - private static final String BUNDLE_NAME = "manifest_ui";//$NON-NLS-1$ - - private ManifestUIResourceHandler() { - // Do not instantiate - } - - public static String Up_1; - public static String Down_2; - public static String Select_All_3; - public static String Deselect_All_4; - public static String ERROR_READING_MANIFEST_DIALOG_TITLE; - public static String SAVE_MANIFEST_WITH_ERROR; - public static String ERROR_READING_MANIFEST_DIALOG_MESSAGE_EDITOR; - public static String ERROR_READING_MANIFEST_DIALOG_MESSAGE_PROP_PAGE; - public static String MANIFEST_PROBLEM_1; - public static String MANIFEST_PROBLEM_2; - public static String MANIFEST_PROBLEM_3; - public static String MANIFEST_PROBLEM_4; - public static String An_internal_error_occurred_ERROR_; - public static String Project_name__UI_; - public static String EAR_Project_Name__UI__UI_; - public static String Available_dependent_JARs__UI_; - public static String Manifest_Class_Path__UI_; - public static String JAR_Module_UI_; - public static String Packed_In_Lib_UI_; - public static String Project_UI_; - public static String EAR_Modules; - public static String EAR_Modules_Desc; - public static String J2EE_Modules; - public static String J2EE_Modules_Desc; - public static String Web_Libraries; - public static String Web_Libraries_Desc; - public static String Web_Ref_Desc; - public static String EAR_Module_Dep_Error; - public static String Unreferenced_Module_Error; - public static String Jar_Dep_One_Module_Error; - public static String Web_Lib_Error; - public static String REDIRECT_TEXT_EDITOR_UI_; - public static String Error_Checking_Project_Facets; - public static String WEB_LIB_LIST_DESCRIPTION; - public static String Dynamic_Web_Error; - public static String No_Web_Reference_Error; - - static { - NLS.initializeMessages(BUNDLE_NAME, ManifestUIResourceHandler.class); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/SecondCheckBoxStateChangedEvent.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/SecondCheckBoxStateChangedEvent.java deleted file mode 100644 index df0df7ec2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/SecondCheckBoxStateChangedEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 SAP AG 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: - * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.ICheckable; -import org.eclipse.jst.j2ee.internal.ui.DoubleCheckboxTableItem; - -public class SecondCheckBoxStateChangedEvent extends CheckStateChangedEvent { - - private DoubleCheckboxTableItem item = null; - - public SecondCheckBoxStateChangedEvent(ICheckable source, - Object element, - boolean state) { - super(source, element, state); - } - - public void setTableItem(DoubleCheckboxTableItem itm) { - item = itm; - } - - public DoubleCheckboxTableItem getTableItem() { - return item; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/UpdateManifestOperation.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/UpdateManifestOperation.java deleted file mode 100644 index bae87743b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/UpdateManifestOperation.java +++ /dev/null @@ -1,86 +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 Jan 17, 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; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException; - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class UpdateManifestOperation implements org.eclipse.jface.operation.IRunnableWithProgress { - protected String projectName; - protected String classPathValue; - protected boolean replace; -/** - * UpdateManifestOperation constructor comment. - */ -public UpdateManifestOperation(String aProjectName, String aSpaceDelimitedPath, boolean replaceInsteadOfMerge) { - super(); - projectName = aProjectName; - classPathValue = aSpaceDelimitedPath; - replace = replaceInsteadOfMerge; -} -protected IProject getProject() { - return J2EEPlugin.getWorkspace().getRoot().getProject(projectName); -} -/** - * 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 { - IProject p = getProject(); - try { - ArchiveManifest mf = J2EEProjectUtilities.readManifest(p); - if (mf == null) - mf = new ArchiveManifestImpl(); - mf.addVersionIfNecessary(); - if (replace) - mf.setClassPath(classPathValue); - else - mf.mergeClassPath(ArchiveUtil.getTokens(classPathValue)); - J2EEProjectUtilities.writeManifest(p, mf); - } catch (java.io.IOException ex) { - throw new WFTWrappedException(ex); - } -} -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebLibDependencyPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebLibDependencyPropertiesPage.java deleted file mode 100644 index d5045bc02..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebLibDependencyPropertiesPage.java +++ /dev/null @@ -1,274 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement; -import org.eclipse.jst.j2ee.internal.common.ClasspathModel; -import org.eclipse.jst.j2ee.internal.common.ClasspathModelListener; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; -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; -import org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation; - -public class WebLibDependencyPropertiesPage extends JARDependencyPropertiesPage implements IClasspathTableOwner, Listener, ClasspathModelListener { - - public WebLibDependencyPropertiesPage(final IProject project, final J2EEDependenciesPage page) { - super(project, page); - } - - protected ClasspathModel createClasspathModel() { - return new ClasspathModel(null, true); - } - - public Composite createContents(Composite parent) { - initialize(); - Composite composite = createBasicComposite(parent); - if (model.getComponent() != null) { - if (!isValidWebModule()) - return composite; - J2EEDependenciesPage.createDescriptionComposite(composite, ManifestUIResourceHandler.Web_Libraries_Desc); - // createProjectLabelsGroup(composite); - createListGroup(composite); - handleWLPSupport(); - setEnablement(); - } - Dialog.applyDialogFont(parent); - postCreateContents(); - return composite; - } - - protected void createProjectLabelsGroup(Composite parent) { - - Composite labelsGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - labelsGroup.setLayout(layout); - labelsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label label = new Label(labelsGroup, SWT.NONE); - label.setText(ManifestUIResourceHandler.Project_name__UI_); - - componentNameText = new Text(labelsGroup, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - componentNameText.setEditable(false); - componentNameText.setLayoutData(data); - componentNameText.setText(project.getName()); - } - - protected void createListGroup(Composite parent) { - Composite listGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - layout.marginHeight = 0; - listGroup.setLayout(layout); - GridData gData = new GridData(GridData.FILL_BOTH); - gData.horizontalIndent = 5; - listGroup.setLayoutData(gData); - - availableDependentJars = new Label(listGroup, SWT.NONE); - gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - availableDependentJars.setText(ManifestUIResourceHandler.Available_dependent_JARs__UI_); - availableDependentJars.setLayoutData(gData); - createTableComposite(listGroup); - } - - protected void createTableComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridData gData = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gData); - tableManager = new ClasspathTableManager(this, model, validateEditListener); - tableManager.fillWLPComposite(composite); - } - - protected boolean isValidWebModule() { - if (!J2EEProjectUtilities.isDynamicWebProject(project)) { - propPage.setErrorMessage(ManifestUIResourceHandler.Web_Lib_Error); - return false; - } - return true; - } - - protected void setEnablement() { - if (tableManager.availableJARsViewer.getTable().getItems().length == 0) { - tableManager.selectAllButton.setEnabled(false); - tableManager.deselectAllButton.setEnabled(false); - } else { - tableManager.selectAllButton.setEnabled(true); - tableManager.deselectAllButton.setEnabled(true); - } - } - - private void handleWLPSupport() { - availableDependentJars.setText(ManifestUIResourceHandler.WEB_LIB_LIST_DESCRIPTION); - tableManager.refresh(); - } - - @Override - protected void handleClasspathChange() { - model.resetClassPathSelectionForWLPs(); - super.handleClasspathChange(); - setEnablement(); - } - - public boolean performOk() { - if (model.getComponent() == null || !isValidWebModule()) { - return true; - } - if (!isDirty) { - return true; - } - try { - boolean createdFlexProjects = runWLPOp(createFlexProjectOperations()); - boolean createdComponentDependency = false; - if (createdFlexProjects) { - createdComponentDependency = runWLPOp(createComponentDependencyOperations()); - isDirty = false; - } - // treat as a classpath change for refresh purposes - // XXX this refresh is not working - suspect it is because the virtual component dependencies are - // not consistently being recomputed - //handleClasspathChange(); - return createdComponentDependency; - } finally { - model.dispose(); - } - } - - private boolean runWLPOp(WorkspaceModifyComposedOperation composed) { - try { - if (composed != null) - new ProgressMonitorDialog(propPage.getShell()).run(true, true, composed); - } catch (InvocationTargetException ex) { - ex.printStackTrace(); - if (ex.getCause() != null) { - ex.getCause().printStackTrace(); - } - String title = ManifestUIResourceHandler.An_internal_error_occurred_ERROR_; - String msg = title; - if (ex.getTargetException() != null && ex.getTargetException().getMessage() != null) - msg = ex.getTargetException().getMessage(); - MessageDialog.openError(propPage.getShell(), title, msg); - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex); - return false; - } catch (InterruptedException e) { - // cancelled - return false; - } - return true; - } - - private void createRef(String aComponentName){ - IVirtualComponent archive = ComponentCore.createArchiveComponent(model.getComponent().getProject(), aComponentName); - - // To do: check if archive component already exists - IVirtualReference ref = ComponentCore.createReference(model.getComponent(), archive, new Path("/WEB-INF/lib")); //$NON-NLS-1$ - model.getComponent().addReferences(new IVirtualReference [] { ref }); - - ClasspathElement element = createClassPathElement(archive, archive.getName()); -// ClassPathSelection selection = createClassPathSelectionForExternalJar(element); - model.getClassPathSelectionForWLPs().getClasspathElements().add(element); - } - - public void handleSelectExternalJarButton() { - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - IPath[] selected = BuildPathDialogAccess.chooseExternalJAREntries(propPage.getShell()); - if (selected != null) { - String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; - for (int i = 0; i < selected.length; i++) { - createRef(type + selected[i].toString()); - } - refresh(); - } - } - } - - public void handleSelectVariableButton() { - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - IPath existingPath[] = new Path[0]; - IPath[] selected = BuildPathDialogAccess.chooseVariableEntries(propPage.getShell(), existingPath); - - if (selected != null) { - String type = VirtualArchiveComponent.VARARCHIVETYPE + IPath.SEPARATOR; - for (int i = 0; i < selected.length; i++) { - IPath resolvedPath = JavaCore.getResolvedVariablePath(selected[i]); - java.io.File file = new java.io.File(resolvedPath.toOSString()); - if (file.isFile() && file.exists()) { - createRef(type + selected[i].toString()); - } else { - // display error - } - } - refresh(); - } - } - } - - private ClasspathElement createClassPathElement(IVirtualComponent archiveComp, String unresolvedName) { - - URI uri = URI.createURI(ModuleURIUtil.getHandleString(archiveComp)); - ClasspathElement element = new ClasspathElement(uri); - element.setValid(false); - element.setSelected(true); - element.setRelativeText(unresolvedName); - element.setText(unresolvedName); - element.setEarProject(null); - return element; - } - -// private ClassPathSelection createClassPathSelectionForExternalJar(ClasspathElement element) { -// ClassPathSelection selection = new ClassPathSelection(); -// selection.getClasspathElements().add(element); -// return selection; -// } - -// private ClassPathSelection createClassPathSelectionForProjectJar(ClasspathElement element) { -// ClassPathSelection selection = new ClassPathSelection(); -// selection.getClasspathElements().add(element); -// return selection; -// } - - public void handleSelectProjectJarButton() { - if (J2EEProjectUtilities.isDynamicWebProject(project)) { - IPath[] selected = BuildPathDialogAccess.chooseJAREntries(propPage.getShell(), project.getLocation(), new IPath[0]); - if (selected != null) { - String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; - for (int i = 0; i < selected.length; i++) { - createRef(type + selected[i].makeRelative().toString()); - } - refresh(); - } - } - - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebRefDependencyPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebRefDependencyPropertiesPage.java deleted file mode 100644 index 3827e1abb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WebRefDependencyPropertiesPage.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * rfrost@bea.com - derived from WebLibDependencyPropertiesPage for projects referenced just from a dynamic web project. - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; - -/** - * Supports UI manipulation of the published/exported classpath entries for projects referenced by dynamic web projects. - */ -public class WebRefDependencyPropertiesPage extends JARDependencyPropertiesPage { - - public WebRefDependencyPropertiesPage(final IProject project, final J2EEDependenciesPage page) { - super(project, page); - } - - @Override - public Composite createContents(Composite parent) { - initialize(); - Composite composite = createBasicComposite(parent); - if (model.getComponent() != null) { - if (!isValidComponent()) { - return composite; - } - J2EEDependenciesPage.createDescriptionComposite(composite, ManifestUIResourceHandler.Web_Ref_Desc); - createListGroup(composite); - tableManager.refresh(); - setEnablement(); - } - Dialog.applyDialogFont(parent); - postCreateContents(); - return composite; - } - - @Override - protected void createTableComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridData gData = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gData); - tableManager = new ClasspathTableManager(this, model, validateEditListener); - tableManager.setReadOnly(isReadOnly()); - tableManager.fillWebRefComposite(composite); - } - - @Override - protected boolean isValidComponent() { - // must have the Java nature and cannot be a dynamic web project - boolean isJavaProject = false; - try { - isJavaProject = project.hasNature(JavaCore.NATURE_ID); - } catch (CoreException ce) {} - if (J2EEProjectUtilities.isDynamicWebProject(project) || !isJavaProject) { - propPage.setErrorMessage(ManifestUIResourceHandler.Dynamic_Web_Error); - return false; - } else if (J2EEProjectUtilities.getReferencingWebProjects(project).length == 0) { - propPage.setErrorMessage(ManifestUIResourceHandler.No_Web_Reference_Error); - return false; - } - return true; - } - - protected void setEnablement() { - if (tableManager.availableJARsViewer.getTable().getItems().length == 0) { - tableManager.selectAllButton.setEnabled(false); - tableManager.deselectAllButton.setEnabled(false); - } else { - tableManager.selectAllButton.setEnabled(true); - tableManager.deselectAllButton.setEnabled(true); - } - } - - @Override - protected void handleClasspathChange() { - super.handleClasspathChange(); - setEnablement(); - } - - @Override - public boolean performOk() { - if (model.getComponent() == null || !isValidComponent()) { - return true; - } - if (!isDirty) { - return true; - } - return super.performOk(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WorkspaceModifyComposedOperation.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WorkspaceModifyComposedOperation.java deleted file mode 100644 index 0b51edca2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/WorkspaceModifyComposedOperation.java +++ /dev/null @@ -1,50 +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 Jan 17, 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; - -import java.util.List; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.operation.IRunnableWithProgress; - -/** - * WARNING: This class will be deleted - * - * @deprecated use {@link org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation} - */ -public class WorkspaceModifyComposedOperation extends org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation { - public WorkspaceModifyComposedOperation(ISchedulingRule rule) { - super(rule); - } - - public WorkspaceModifyComposedOperation() { - super(); - } - - public WorkspaceModifyComposedOperation(ISchedulingRule rule, List nestedRunnablesWithProgress) { - super(rule, nestedRunnablesWithProgress); - } - - public WorkspaceModifyComposedOperation(List nestedRunnablesWithProgress) { - super(nestedRunnablesWithProgress); - } - - public WorkspaceModifyComposedOperation(IRunnableWithProgress nestedOp) { - super(nestedOp); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java deleted file mode 100644 index 9d9a71ef2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionDelegate.java +++ /dev/null @@ -1,225 +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.actions; - - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; - - -public abstract class AbstractActionDelegate implements org.eclipse.ui.IActionDelegate { - protected ISelection selection; - protected boolean allowsMultiSelect = false; - public static final Class IPROJECT_CLASS = IProject.class; - private final static String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - private final static String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - - /** - * EditModuleDependencyAction constructor comment. - */ - public AbstractActionDelegate() { - super(); - } - - /** - * Applicable only when this action does not allow multi select - */ - protected IProject getProject() { - return getProject(getSelectedElement()); - } - - protected List getProjects() { - if ((selection == null) || !(selection instanceof IStructuredSelection)) - return Collections.EMPTY_LIST; - - List result = new ArrayList(); - IStructuredSelection struct = (IStructuredSelection) selection; - Iterator it = struct.iterator(); - while (it.hasNext()) { - IProject p = getProject(it.next()); - if (p != null) - result.add(p); - } - return result; - } - - protected IProject getProject(Object element) { - - if (isSupportedAction(element)) - return ProjectUtilities.getProject((EObject) element); - else if (element instanceof IAdaptable) - return (IProject) ((IAdaptable) element).getAdapter(IPROJECT_CLASS); - else - return null; - } - - protected IStructuredSelection getStructuredSelection() { - if ((selection == null) || !(selection instanceof IStructuredSelection)) - return null; - else if (selection.isEmpty()) { - selection = J2EEUIPlugin.getCurrentSelection(); - } - return (IStructuredSelection) selection; - } - - /* - * Only return if there is exactly one item selected - */ - protected Object getSelectedElement() { - IStructuredSelection sel = getStructuredSelection(); - return sel == null ? null : sel.getFirstElement(); - } - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getActiveWorkbenchWindow(); - } - - /** - * Can the receiver be executed for - * - * @element - */ - protected abstract boolean isSupportedAction(Object element); - - /** - * @deprecated use {@link #primRun(Shell)} - */ - protected void primRun(IProject project, Shell shell) { - //Deprecated - } - - /** - * Subclasses should override this instead of {@link #run(org.eclipse.jface.action.IAction)} - */ - protected void primRun(Shell shell) { - primRun(getProject(), shell); - } - - /** - * Performs this action. - * <p> - * This method is called when the delegating action has been triggered. Implement this method to - * do the actual work. - * </p> - * - * @param action - * the action proxy that handles the presentation portion of the action - */ - public void run(org.eclipse.jface.action.IAction action) { - - Shell shell = getWorkbenchWindow().getShell(); - setActionStateFromProjects(action); - if (!action.isEnabled()) - MessageDialog.openInformation(shell, J2EEUIMessages.getResourceString("INFORMATION_UI_"), J2EEUIMessages.getResourceString("CHOSEN_OP_NOT_AVAILABLE")); //$NON-NLS-2$ = "The chosen operation is not currently available." //$NON-NLS-1$ = "Information" - else { - try { - primRun(shell); - } catch (Throwable t) { - org.eclipse.jst.j2ee.internal.plugin.ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - } - - - } - - /** - * Notifies this action delegate that the selection in the workbench has changed. - * <p> - * Implementers can use this opportunity to change the availability of the action or to modify - * other presentation properties. - * </p> - * - * @param action - * the action proxy that handles presentation portion of the action - * @param aSelection - * the current selection in the workbench - */ - public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection aSelection) { - this.selection = aSelection; - setActionState(action); - } - - protected void setActionState(IAction action) { - if (allowsMultiSelect) - setActionStateForMultiSelect(action); - else - setActionStateForSingleSelect(action); - } - - protected void setActionStateForSingleSelect(IAction action) { - IStructuredSelection sel = getStructuredSelection(); - if (sel == null || sel.size() != 1) { - action.setEnabled(false); - return; - } - setActionStateFromProjects(action); - } - - protected void setActionStateForMultiSelect(IAction action) { - setActionStateFromProjects(action); - } - - protected void setActionStateFromProjects(IAction action) { - IStructuredSelection sel = getStructuredSelection(); - boolean allOk = false; - if (sel != null && !sel.isEmpty()) { - allOk = true; - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - IProject project = getProject(o); - if (project == null || !project.isOpen()) { - allOk = false; - break; - } - } - } - action.setEnabled(allOk); - } - - /** - * Returns the allowsMultiSelect. - * - * @return boolean - */ - public boolean allowsMultiSelect() { - return allowsMultiSelect; - } - - - /** - * Sets the allowsMultiSelect. - * - * @param allowsMultiSelect - * The allowsMultiSelect to set - */ - public void setAllowsMultiSelect(boolean allowsMultiSelect) { - this.allowsMultiSelect = allowsMultiSelect; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java deleted file mode 100644 index 1dbce3ddc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractActionWithDelegate.java +++ /dev/null @@ -1,69 +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.actions; - - - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionDelegate; - - -public abstract class AbstractActionWithDelegate extends org.eclipse.ui.actions.SelectionListenerAction { - protected IActionDelegate delegate; - - /** - * EditModuleDependencyAction constructor comment. - * - * @param text - * java.lang.String - */ - public AbstractActionWithDelegate() { - super("");//$NON-NLS-1$ - initLabel(); - initDelegate(); - } - - protected abstract IActionDelegate createDelegate(); - - protected abstract String getLabel(); - - protected void initDelegate() { - delegate = createDelegate(); - } - - protected void initLabel() { - setText(getLabel()); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - delegate.run(this); - } - - /** - * Updates this action in response to the given selection. - * <p> - * The <code>SelectionListenerAction</code> implementation of this method returns - * <code>true</code>. Subclasses may extend to react to selection changes; however, if the - * super method returns <code>false</code>, the overriding method must also return - * <code>false</code>. - * </p> - * - * @param selection - * the new selection - * @return <code>true</code> if the action should be enabled for this selection, and - * <code>false</code> otherwise - */ - protected boolean updateSelection(IStructuredSelection selection) { - delegate.selectionChanged(this, selection); - return this.isEnabled(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java deleted file mode 100644 index fbd602ea1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.actions; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * Action for opening a J2EE resource from the J2EE navigator. - */ -public abstract class AbstractOpenAction extends SelectionListenerAction implements IActionDelegate2 { - // //$NON-NLS-1$ - protected IEditorDescriptor currentDescriptor; - protected Object srcObject; - - protected AbstractOpenAction(String text) { - super(text); - } - - protected static IEditorDescriptor findEditorDescriptor(String id) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - return registry.findEditor(id); - } - - protected void setAttributesFromDescriptor() { - if (currentDescriptor == null) - return; - //setText(currentDescriptor.getLabel()); - setToolTipText(currentDescriptor.getLabel()); - //setImageDescriptor(currentDescriptor.getImageDescriptor()); - } - - /** - * The structured selection has changed in the workbench. Subclasses should override this method - * to react to the change. Returns true if the action should be enabled for this selection, and - * false otherwise. - * - * When this method is overridden, the super method must always be invoked. If the super method - * returns false, this method must also return false. - * - * @param sel - * the new structured selection - */ - public boolean updateSelection(IStructuredSelection s) { - srcObject = null; - if (!super.updateSelection(s)) - return false; - - if (s.size() != 1) - return false; - - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //Dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - runWithEvent(event); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - // TODO Auto-generated method stub - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - // TODO HACK! - updateSelection((IStructuredSelection) selection); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java deleted file mode 100644 index d652982bd..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardAction.java +++ /dev/null @@ -1,147 +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.actions; - - -import java.util.Iterator; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.activities.WorkbenchActivityHelper; - - -public abstract class AbstractOpenWizardAction extends org.eclipse.jface.action.Action { - // //$NON-NLS-1$ - - private IWorkbench fWorkbench; - - private Class[] fActivatedOnTypes; - - private boolean fAcceptEmptySelection; - - protected AbstractOpenWizardAction() { - //Default constructor - } - - public AbstractOpenWizardAction(IWorkbench workbench, String label, Class[] activatedOnTypes, boolean acceptEmptySelection) { - super(label); - fWorkbench = workbench; - fActivatedOnTypes = activatedOnTypes; - fAcceptEmptySelection = acceptEmptySelection; - } - - public AbstractOpenWizardAction(IWorkbench workbench, String label, boolean acceptEmptySelection) { - this(workbench, label, null, acceptEmptySelection); - } - - public boolean canActionBeAdded() { - ISelection selection = getCurrentSelection(); - if (selection == null || selection.isEmpty()) { - return fAcceptEmptySelection; - } - if (fActivatedOnTypes != null) { - if (selection instanceof IStructuredSelection) { - return isEnabled(((IStructuredSelection) selection).iterator()); - } - return false; - } - return true; - } - - /** - * Create the specific Wizard (to be implemented by a subclass) - */ - abstract protected Wizard createWizard(); - - protected IStructuredSelection getCurrentSelection() { - IWorkbenchWindow window = J2EEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - - } - return null; - } - - protected IWorkbench getWorkbench() { - return fWorkbench; - } - - private boolean isEnabled(Iterator iter) { - while (iter.hasNext()) { - Object obj = iter.next(); - if (!isOfAcceptedType(obj) || !shouldAcceptElement(obj)) { - return false; - } - } - return true; - } - - private boolean isOfAcceptedType(Object obj) { - for (int i = 0; i < fActivatedOnTypes.length; i++) { - if (fActivatedOnTypes[i].isInstance(obj)) { - return true; - } - } - return false; - } - - protected String getDialogText() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_LBL); - } - - /** - * The user has invoked this action. - */ - public void run() { - Wizard wizard = createWizard(); - if (wizard instanceof IWorkbenchWizard) { - IStructuredSelection sel = null; - if (null != getCurrentSelection()) - sel = getCurrentSelection(); - else - sel = new StructuredSelection(); - ((IWorkbenchWizard) wizard).init(J2EEUIPlugin.getDefault().getWorkbench(), sel); - } - if (WorkbenchActivityHelper.allowUseOf(null,wizard)) { - IWorkbenchWindow window = J2EEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.create(); - String text = getDialogText(); - if (null != text) { - dialog.getShell().setText(text); - } - dialog.open(); - } - } - - protected void setWorkbench(IWorkbench workbench) { - fWorkbench = workbench; - } - - /** - * can be overridden to add more checks obj is guaranteed to be instance of one of the accepted - * types - */ - protected boolean shouldAcceptElement(Object obj) { - return true; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java deleted file mode 100644 index ccc42ae8c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/AbstractOpenWizardWorkbenchAction.java +++ /dev/null @@ -1,62 +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.actions; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; - - -public abstract class AbstractOpenWizardWorkbenchAction extends AbstractOpenWizardAction implements org.eclipse.ui.IWorkbenchWindowActionDelegate { - protected AbstractOpenWizardWorkbenchAction() { - //Default - } - - public AbstractOpenWizardWorkbenchAction(IWorkbench workbench, String label, Class[] activatedOnTypes, boolean acceptEmptySelection) { - super(workbench, label, null, acceptEmptySelection); - } - - public AbstractOpenWizardWorkbenchAction(IWorkbench workbench, String label, boolean acceptEmptySelection) { - super(workbench, label, null, acceptEmptySelection); - } - - /** - * @see AbstractOpenWizardAction#dispose - */ - public void dispose() { - // do nothing. - setWorkbench(null); - } - - /** - * @see AbstractOpenWizardAction#init - */ - public void init(IWorkbenchWindow window) { - setWorkbench(window.getWorkbench()); - } - - /** - * @see IActionDelegate#run - */ - public void run(IAction action) { - run(); - } - - /** - * @see IActionDelegate#selectionChanged - */ - public void selectionChanged(IAction action, ISelection selection) { - // do nothing. Action doesn't depend on selection. - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java deleted file mode 100644 index 7cc713191..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/BaseAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 27, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.ErrorDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IWorkbenchWindow; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public abstract class BaseAction extends Action implements IActionDelegate { - - protected IStructuredSelection selection = null; - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getPluginWorkbench().getActiveWorkbenchWindow(); - } - - public void setSelection(IStructuredSelection selection) { - this.selection = selection; - } - - public void run() { - Shell shell = getWorkbenchWindow().getShell(); - if (null == selection) { - ISelection autoselection = getWorkbenchWindow().getSelectionService().getSelection(); - if (autoselection instanceof IStructuredSelection) - this.selection = (IStructuredSelection) autoselection; - } - - try { - primRun(shell); - this.selection = null; - } catch (Throwable t) { - Logger.getLogger().logError(t); - String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - - } - - protected abstract void primRun(Shell shell); - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - setSelection((IStructuredSelection) aSelection); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java deleted file mode 100644 index 1f2bba954..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ComponentEditorInput.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.actions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class ComponentEditorInput implements IEditorInput { - - private IVirtualComponent component; - - public ComponentEditorInput(IVirtualComponent component){ - this.component = component; - } - - public boolean exists() { - return component.exists(); - } - - public ImageDescriptor getImageDescriptor() { - return null; - } - - public String getName() { - return component.getName(); - } - - public IPersistableElement getPersistable() { - return null; - } - - public String getToolTipText() { - return ""; //$NON-NLS-1$ - } - - public Object getAdapter(Class adapter) { - return null; - } - - public IVirtualComponent getComponent(){ - return component; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java deleted file mode 100644 index 0122ba5e5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ForceClasspathUpdateAction.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c)2006 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.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; -import org.eclipse.ui.IActionDelegate; - -public class ForceClasspathUpdateAction extends Action implements IActionDelegate{ - - private List projectsList = new ArrayList(); - - public void run() { - J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectsList); - } - - public void run(IAction action) { - J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectsList); - } - - public void selectionChanged(IAction action, ISelection selection) { - action.setEnabled(setSelection(selection)); - } - - private boolean setSelection(ISelection selection){ - projectsList.clear(); - if(selection != null && selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - if (structuredSelection.size() > 0) { - Iterator iterator = structuredSelection.iterator(); - while(iterator.hasNext()){ - Object next = iterator.next(); - if (next instanceof IProject) { - projectsList.add(next); - } else { - projectsList.clear(); - return false; - } - } - } else { // empty selection - return false; - } - return true; - } - return false; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java deleted file mode 100644 index e25fc0c3a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/IJ2EEUIContextIds.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.actions; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; - - -/** - * Insert the type's description here. Creation date: (9/6/2001 12:23:02 PM) - * - * @author: Administrator - */ -public interface IJ2EEUIContextIds { - // New creation wizards - public static final String NEW_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_NEW_EAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_EAR_ADD_MODULES_PAGE = J2EEUIPlugin.PLUGIN_ID + ".NEW_EAR_ADD_MODULES_PAGE"; //$NON-NLS-1$ - public static final String NEW_EAR_COMP_PAGE = J2EEUIPlugin.PLUGIN_ID + ".NEW_EAR_COMP_PAGE"; //$NON-NLS-1$ - public static final String EAR_NEW_MODULE_PROJECTS_PAGE = J2EEUIPlugin.PLUGIN_ID + ".EAR_NEW_MODULE_PROJECTS_PAGE"; //$NON-NLS-1$ - public static final String NEW_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_NEW_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_APPCLIENT_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_NEW_APPCLIENT_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String NEW_EJB_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".EJB_NEW_EJB_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_CONNECTOR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".JCA_NEWIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_CONNECTOR_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".JCA_NEWIZARD_PAGE3"; //$NON-NLS-1$ - public static final String NEW_JAVA_COMPONENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_JAVA_COMPONENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_JAVA_CLASS_OPTION_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_JAVA_CLASS_OPTION_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String NEW_UTILITY_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".NEW_UTILITY_WIZARD_P1"; //$NON-NLS-1$ - public static final String NEW_UTILITY_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".NEW_UTILITY_WIZARD_P3"; //$NON-NLS-1$ - - // Import, export wizards - public static final String IMPORT_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_EAR_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String IMPORT_EAR_WIZARD_P3 = J2EEUIPlugin.PLUGIN_ID + ".EAR_IMPORT_EAR_WIZARD_PAGE3"; //$NON-NLS-1$ - public static final String IMPORT_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_IMPORT_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_IMPORT_EJB_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_RAR_WIZARD_PAGE = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_RAR_WIZARD_PAGE"; //$NON-NLS-1$ - public static final String IMPORT_UTILITY_JAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_UTILITY_JAR_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_UTILITY_JAR_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_UTILITY_JAR_WIZARD_PAGE2"; //$NON-NLS-1$ - public static final String IMPORT_CLASS_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_CLASS_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String IMPORT_CLASS_WIZARD_P2 = J2EEUIPlugin.PLUGIN_ID + ".IMPORT_CLASS_WIZARD_PAGE2"; //$NON-NLS-1$ - - public static final String EXPORT_EAR_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EAR_EXPORT_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_APPCLIENT_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".APPCLIENT_EXPORT_APPCLIENT_WIZARD_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_EJB_WIZARD_P1 = J2EEUIPlugin.PLUGIN_ID + ".EJB_EXPORT_PAGE1"; //$NON-NLS-1$ - public static final String EXPORT_RAR_WIZARD_PAGE = J2EEUIPlugin.PLUGIN_ID + ".EXPORT_RAR_WIZARD_PAGE"; //$NON-NLS-1$ - - // dialogs - public static final String DELEATE_EAR_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm2000"; //$NON-NLS-1$ - public static final String DELEATE_MODULE_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm2010"; //$NON-NLS-1$ - public static final String RENAME_EAR_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm3000"; //$NON-NLS-1$ - public static final String RENAME_MODULE_DIALOG_1 = J2EEUIPlugin.PLUGIN_ID + ".navm3010"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java deleted file mode 100644 index abff48694..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/ImportClassesAction.java +++ /dev/null @@ -1,63 +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 Mar 31, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.ClassesImportWizard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ImportClassesAction extends WTPBaseAction { - - public static String LABEL = J2EEUIMessages.getResourceString("Import_Classes"); //$NON-NLS-1$ - - public ImportClassesAction() { - super(); - setText(LABEL); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.common.actions.BaseAction#primRun(org.eclipse.swt.widgets.Shell) - */ - protected void primRun(Shell shell) { - IProject project = ProjectUtilities.getProject(getSelection().getFirstElement()); - ClassesImportWizard wizard = new ClassesImportWizard(project); - - - wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); - wizard.setDialogSettings(J2EEUIPlugin.getDefault().getDialogSettings()); - - WizardDialog dialog = new WizardDialog(shell, wizard); - - dialog.create(); - dialog.getShell().setSize(550, 550); - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java deleted file mode 100644 index 4a833892f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteAction.java +++ /dev/null @@ -1,419 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.actions; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.ui.actions.SelectionDispatchAction; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.delete.DeleteOptions; -import org.eclipse.jst.j2ee.internal.dialogs.DeleteEARDialog; -import org.eclipse.jst.j2ee.internal.dialogs.DeleteModuleDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EEDeleteDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EEDeleteUIConstants; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.actions.DeleteResourceAction; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - -public class J2EEDeleteAction extends SelectionDispatchAction implements J2EEDeleteUIConstants { - - protected Shell shell; - //Used for EAR delete - protected Set referencedProjects; - protected List projects; - protected DeleteOptions options; - // added for IRefactoringAction behavior - protected ISelectionProvider provider = null; - - - - /** - * Constructor for DeleteModuleAction. - * - * @param text - */ - public J2EEDeleteAction(IWorkbenchSite site, Shell parent) { - super(site); - setText(DELETE); - shell = parent; - } - - public J2EEDeleteAction(IWorkbenchSite site, ISelectionProvider newProvider) { - super(site); - setText(DELETE); - shell = J2EEUIPlugin.getActiveWorkbenchWindow().getShell(); - provider = newProvider; - } - - protected void reset() { - referencedProjects = null; - projects = null; - options = null; - } - - protected boolean getEnableStateBasedOnSelection(IStructuredSelection selection) { - if (selection.isEmpty()) - return false; - return isSelectionApplicable() && isSelectionSomeJ2EE(); - } - - /** - * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected void updateSelection(IStructuredSelection selection) { - update(selection); - } - - protected boolean isSelectionApplicable() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isJ2EEModule(o) && !isApplication(o) && !isProjectOrJavaProject(o)) - return false; - } - return true; - } - - protected boolean isSelectionSomeJ2EE() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (isJ2EEModule(o) || isApplication(o)) - return true; - } - return false; - } - - - protected boolean isSelectionAllDDRoots() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isJ2EEModule(o)) - return false; - } - return true; - } - - protected boolean isSelectionAllApplications() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!isApplication(o)) - return false; - } - return true; - } - - protected boolean isJ2EEModule(Object o) { - //TODO switch to virtual comp -// if (o instanceof WorkbenchComponent) { -// WorkbenchComponent module = (WorkbenchComponent) o; -// String moduleType = module.getComponentType().getComponentTypeId(); -// //TODO need to add connector, app client, ear, ejb client -// return moduleType.equals(IModuleConstants.JST_WEB_MODULE) || moduleType.equals(IModuleConstants.JST_EJB_MODULE); -// } - return CommonUtil.isDeploymentDescriptorRoot(o, false); - } - - protected boolean isApplication(Object o) { - return (o instanceof Application) || isJ2EEApplicationProject(o); - } - - protected boolean isProjectOrJavaProject(Object o) { - return (o instanceof IProject) || (o instanceof IJavaProject); - } - - protected List getProjects() { - if (projects == null) { - projects = new ArrayList(); - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator iterator = sel.iterator(); - IProject project = null; - Object o = null; - while (iterator.hasNext()) { - o = iterator.next(); - if (o instanceof IJavaProject) - o = ((IJavaProject) o).getProject(); - if (o instanceof IProject) { - projects.add(o); - addEJBClientProjectIfNecessary((IProject) o, projects); - } else if (o instanceof EObject) { - EObject obj = (EObject) o; - project = ProjectUtilities.getProject(obj); - if (project == null) - throw new RuntimeException(J2EEUIMessages.getResourceString("Project_should_not_be_null_1_EXC_")); //$NON-NLS-1$ - projects.add(project); - addEJBClientProjectIfNecessary(project, projects); - } else { - throw new RuntimeException(J2EEUIMessages.getResourceString("Non-project_in_selection_2_EXC_")); //$NON-NLS-1$ - } - } - } - return projects; - } - - /** - * @param project - * @param localProjects - */ - private void addEJBClientProjectIfNecessary(IProject project, List localProjects) { - IVirtualComponent comp = ComponentCore.createComponent(project); - EJBArtifactEdit edit = EJBArtifactEdit.getEJBArtifactEditForRead(comp); - if (edit != null && edit.hasEJBClientJARProject()) - localProjects.add(edit.getEJBClientJarModule().getProject()); - } - - /** - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - try { - J2EEDeleteDialog dlg = null; - if (isSelectionAllApplications()) - dlg = new DeleteEARDialog(shell, getReferencedProjects()); - else if (isSelectionAllDDRoots()) - dlg = new DeleteModuleDialog(shell); - else { - if (confirmStandardDelete()) - runResourceDeleteAction(); - return; - } - - dlg.open(); - if (dlg.getReturnCode() == Window.CANCEL) - return; - options = dlg.getDeleteOptions(); - if (options != null) - options.setSelectedProjects(getProjects()); - else - return; - if (!(ensureEditorsSaved() && validateState())) - return; - deleteProjectsIfNecessary(); - deleteMetadataIfNecessary(); - presentStatusIfNeccessary(); - } finally { - reset(); - } - } - - private boolean ensureEditorsSaved() { - return CommonEditorUtility.promptToSaveAllDirtyEditors(); - } - - protected boolean confirmStandardDelete() { - return MessageDialog.openConfirm(shell, DELETE_PROJECTS, CUSTOM_DELETE_MIX_MATCH); - } - - protected Set getReferencedProjects() { - if (referencedProjects == null) - computeReferencedProjects(); - return referencedProjects; - } - - protected void computeReferencedProjects() { - //TODO fix up to use components -// getProjects(); -// referencedProjects = new HashSet(); -// for (int i = 0; i < projects.size(); i++) { -// IProject project = (IProject) projects.get(i); -// EARNatureRuntime runtime = EARNatureRuntime.getRuntime(project); -// if (runtime == null) -// continue; -// EAREditModel editModel = runtime.getEarEditModelForRead(this); -// try { -// referencedProjects.addAll(editModel.getModuleMappedProjects()); -// } finally { -// editModel.releaseAccess(this); -// } -// } - } - -// protected DeleteModuleOperation getDeleteModuleOperation() { -// if (deleteModuleOperation == null) -// deleteModuleOperation = new DeleteModuleOperation(options); -// return deleteModuleOperation; -// } - - protected void deleteMetadataIfNecessary() { - if (!shouldDeleteMetaData()) - return; - -// IRunnableWithProgress runnable = WTPUIPlugin.getRunnableWithProgress(getDeleteModuleOperation()); -// ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(shell); -// -// try { -// monitorDialog.run(false, false, runnable); -// } catch (InvocationTargetException e) { -// handleException(e); -// } catch (InterruptedException e) { -// //Ignore -// } - } - - protected boolean shouldDeleteMetaData() { - if (deleteProjectsFailedOrCancelled()) - return false; - return primShouldDeleteMetaData(); - } - - protected boolean primShouldDeleteMetaData() { - return options != null && (options.shouldDeleteModules() || options.shouldDeleteModuleDependencies()); - } - - protected boolean deleteProjectsFailedOrCancelled() { - if (options == null || !options.shouldDeleteProjects()) - return false; - return deletedProjectsExist(); - } - - protected boolean deletedProjectsExist() { - List deletedProjects = options.getAllProjectsToDelete(); - for (int i = 0; i < deletedProjects.size(); i++) { - IProject project = (IProject) deletedProjects.get(i); - if (project.exists()) - return true; - } - return false; - } - - protected void deleteProjectsIfNecessary() { - if (options.shouldDeleteProjects()) - runResourceDeleteAction(); - } - - protected void runResourceDeleteAction() { - DeleteResourceAction action = new DeleteResourceAction(shell); - List localProjects = null; - if (options == null) - localProjects = getProjects(); - else - localProjects = options.getAllProjectsToDelete(); - Iterator it = localProjects.iterator(); - while (it.hasNext()) { - IProject p = (IProject) it.next(); - if (!p.exists()) - it.remove(); - } - IStructuredSelection sel = new StructuredSelection(localProjects); - action.selectionChanged(sel); - action.run(); - } - - public void handleException(InvocationTargetException e) { - Logger.getLogger().logError(e); - IStatus status = J2EEPlugin.newErrorStatus(IStatus.ERROR, DELETE_ERROR, e); - ErrorDialog.openError(shell, DELETE_ERROR, DELETE_NOT_COMPLETED, status); - } - - /** - * Update the action's enable state according to the current selection of the used selection - * provider. - */ - public void update() { - IStructuredSelection selection = null; - - if (provider != null) { - selection = (IStructuredSelection) provider.getSelection(); - selectionChanged((ISelection) selection); - } else { - selection = (IStructuredSelection) getSelection(); - - if (selection == null) { - setEnabled(false); - } else { - updateSelection(selection); - } - } - } - - protected boolean isJ2EEApplicationProject(Object o) { - if (o instanceof IProject) { - IProject project = (IProject) o; - if (J2EEProjectUtilities.isEARProject(project)) - return true; - } - return false; - } - - protected void setEnabledFromSelection(IStructuredSelection selection) { - if (selection == null) { - setEnabled(false); - } else { - setEnabled(getEnableStateBasedOnSelection(selection)); - } - } - - /** - * @see SelectionDispatchAction#selectionChanged(ISelection) - */ - public void selectionChanged(ISelection selection) { - if (selection instanceof IStructuredSelection) - setEnabledFromSelection((IStructuredSelection) selection); - else - super.selectionChanged(selection); - } - - protected boolean validateState() { - // TODO Fix validateState - // if (!primShouldDeleteMetaData()) - // return true; - // - // IValidateEditListener listener = new ValidateEditListener(null, - // getDeleteModuleOperation().getDeleteEditModel()); - // listener.setShell(shell); - // return listener.validateState().isOK(); - return true; - } - - protected void presentStatusIfNeccessary() { - IStatus status = null; -// if (deleteModuleOperation != null) -// status = deleteModuleOperation.getStatus(); - - if (status == null || status.isOK()) - return; - - ErrorDialog.openError(shell, null, null, status, IStatus.ERROR); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java deleted file mode 100644 index 97d00f3d1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeleteModuleActionPopulator.java +++ /dev/null @@ -1,47 +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 Jun 16, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author mdelder - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EEDeleteModuleActionPopulator {//implements WTPOperationDataModelUICreator { - - - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.operation.extension.ui.WTPOperationDataModelUICreator#createDataModel(java.lang.String, - * java.lang.String, org.eclipse.jface.viewers.IStructuredSelection, - * org.eclipse.ui.IWorkbenchSite) - */ - public IDataModel createDataModel(String extendedOperationId, String operationClass, IStructuredSelection selection, IWorkbenchSite site) { - //TODO fix up -// J2EEDeleteAction deleteAction = new J2EEDeleteAction(site, (ISelectionProvider) null); -// WTPOperationDataModel dataModel = IActionWTPOperationDataModel.createDataModel(deleteAction, selection, site.getSelectionProvider(), site.getShell()); -// return dataModel; - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java deleted file mode 100644 index 47b6593e9..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 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.actions; - -import java.text.MessageFormat; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.deploy.DeployerRegistry; -import org.eclipse.jst.j2ee.internal.deploy.J2EEDeployOperation; -import org.eclipse.jst.j2ee.internal.dialogs.RuntimeSelectionDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; -import org.eclipse.wst.server.core.IRuntime; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEDeployAction extends BaseAction { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.ui.actions.BaseAction#primRun(org.eclipse.swt.widgets.Shell) - */ - protected void primRun(Shell shell) { - - if (checkEnabled(shell)) { - final IStructuredSelection deploySelection = selection; - Job deployJob = new Job("Deploy") { - protected IStatus run(IProgressMonitor monitor) { - IStatus result = null; - J2EEDeployOperation op = new J2EEDeployOperation(deploySelection.toArray()); - try { - result = op.execute(monitor, null); - } catch (Exception e) { - result = new Status(IStatus.ERROR, WTPCommonPlugin.PLUGIN_ID, IStatus.ERROR, WTPResourceHandler.getString("27"), e); //$NON-NLS-1$ - Logger.getLogger().logError(e); - } finally { - - } - return result; - } - }; - - - try { - deployJob.setUser(true); - deployJob.schedule(); - } catch (Exception e) { - //Ignore - } - - } - - } - - /* - * - */ - public J2EEDeployAction() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - super.selectionChanged(action, aSelection); - action.setEnabled(true); - } - - - public boolean checkEnabled(Shell shell) { - - try { - DeployerRegistry reg = DeployerRegistry.instance(); - - List components = DeployerRegistry.getSelectedModules(selection.toArray()); - for (int i = 0; i < components.size(); i++) { - IVirtualComponent component = (IVirtualComponent) components.get(i); - IProject proj = component.getProject(); - if (proj == null) { - displayMessageDialog(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_FOUND") , shell); - return false; - } - - IRuntime runtime = J2EEProjectUtilities.getServerRuntime(proj); - if (runtime == null) { - String message = MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_NOT_FOUND"), new String []{proj.getName()}); - RuntimeSelectionDialog selectionDialog = new RuntimeSelectionDialog(shell, - J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"), - null /* default image */, - message, - MessageDialog.ERROR, - new String[] { IDialogConstants.OK_LABEL }, 0, proj) ; - selectionDialog.open(); - runtime = J2EEProjectUtilities.getServerRuntime(proj); - if (runtime == null) - return false; - } - List visitors = reg.getDeployModuleExtensions(proj, runtime); - if (visitors.isEmpty()) { - displayMessageDialog(MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_SUPPORTED"), new String []{proj.getName()}), shell); - return false; - } - - } - - return true; - } catch (CoreException e) { - System.out.println("Deploy Action recovering from problem verifying enablement."); //$NON-NLS-1$ - e.printStackTrace(); - } - return false; - } - - private void displayMessageDialog(String message, Shell shell) { - String title = J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"); - MessageDialog dialog = new MessageDialog(shell, - title, - null /* default image */, - message, - MessageDialog.ERROR, - new String[] { IDialogConstants.OK_LABEL }, 0) ; - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java deleted file mode 100644 index e4f227f29..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEModuleRenameChange.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 26, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - - -/** - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EEModuleRenameChange extends Change { - -// private String newName; - private IProject target; -// private boolean renameDependencies; - - public J2EEModuleRenameChange(IProject target, String newName, boolean renameDependencies) { - this.target = target; -// this.newName = newName; -// this.renameDependencies = renameDependencies; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#getName() - */ - public String getName() { - return J2EERenameUIConstants.RENAME_MODULES; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor) - */ - public void initializeValidationData(IProgressMonitor pm) { - //Do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor) - */ - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { - if (target != null) - return RefactoringStatus.create(Status.OK_STATUS); - return RefactoringStatus.create(new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, 0, "", null)); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change perform(IProgressMonitor pm) throws CoreException { -// try { - -// RenameModuleOperation renameOp = new RenameModuleOperation(getRenameOptions()); -// renameOp.run(pm); - - //String contextRoot = getServerContextRoot(); - // TODO fix up rename and context root operations - //if (webNature != null) { - //new UpdateWebContextRootMetadataOperation(newTarget, webNature.getContextRoot()).run(pm); -// if(contextRoot.equals("") == false){ //$NON-NLS-1$ -// new UpdateWebContextRootMetadataOperation(target, contextRoot).run(pm); -// } else if (J2EENature.getRegisteredRuntime(target) == null) -// new RenameUtilityJarMetadataOperation(target, newTarget).run(pm); -// } catch (InvocationTargetException e) { -// //Ignore -// } catch (InterruptedException e) { -// //Ignore -// } - return null; - } - - protected String getServerContextRoot() { - WebArtifactEdit webEdit = null; - try{ - webEdit = WebArtifactEdit.getWebArtifactEditForRead(target); - if (webEdit != null) - return webEdit.getServerContextRoot(); - } finally { - if (webEdit != null ) - webEdit.dispose(); - } - return ""; //$NON-NLS-1$ - } - - /** - * @return - */ - /**@deprecated - * If this method is not used it should be removed at a later time, marking as deprecated - * Warning cleanup 12/07/2005 - */ -// private RenameOptions getRenameOptions() { -// RenameOptions options = new RenameOptions(); -// options.setNewName(this.newName); -// options.setSelectedProjects(Collections.singletonList(this.target)); -// // TODO check module type for EAR type -// //options.setIsEARRename(EARNatureRuntime.getRuntime(this.target) != null); -// options.setRenameModuleDependencies(this.renameDependencies); -// options.setRenameModules(true); -// options.setRenameProjects(false); -// return options; -// } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement() - */ - public Object getModifiedElement() { - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java deleted file mode 100644 index 3890197bd..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameAction.java +++ /dev/null @@ -1,391 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.actions; - - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.ui.actions.SelectionDispatchAction; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameDialog; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.jst.j2ee.internal.dialogs.RenameModuleDialog; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.RenameResourceAction; -import org.eclipse.wst.common.componentcore.UnresolveableURIException; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; - -public class J2EERenameAction extends SelectionDispatchAction implements J2EERenameUIConstants { - - protected Shell shell; - //Used for EAR rename - protected Set referencedProjects; - protected List modules; - protected RenameOptions options; - // added for IRefactoringAction behavior - protected ISelectionProvider provider = null; -// protected RenameModuleOperation renameModuleOperation = null; - - /** - * Constructor for RenameModuleAction. - * - * @param text - */ - public J2EERenameAction(IWorkbenchSite site, Shell parent) { - super(site); - setText(RENAME); - shell = parent; - } - - public J2EERenameAction(IWorkbenchSite site, ISelectionProvider newProvider) { - super(site); - setText(RENAME); - shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - provider = newProvider; - } - - protected void reset() { -// if (renameModuleOperation != null) { -// renameModuleOperation.release(); -// renameModuleOperation = null; -// } - referencedProjects = null; - modules = null; - options = null; - } - - /** - * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected void updateSelection(IStructuredSelection selection) { - super.update(selection); - } - - /** - * @see SelectionDispatchAction#selectionChanged(ISelection) - */ - public void selectionChanged(ISelection selection) { - if (selection instanceof IStructuredSelection) - setEnabledFromSelection((IStructuredSelection) selection); - else - super.selectionChanged(selection); - } - - protected void setEnabledFromSelection(IStructuredSelection selection) { - if (selection == null) { - setEnabled(false); - } else { - if (selection.toList().size() != 1) { - setEnabled(false); - } else { - setEnabled(getEnableStateBasedOnSelection(selection)); - } - } - } - - protected boolean getEnableStateBasedOnSelection(IStructuredSelection selection) { - if (selection.isEmpty()) - return false; - return isSelectionAllDDRoots() || isSelectionAllApplications(); - } - - protected boolean isSelectionAllDDRoots() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - //TODO check for j2ee workbench module selection - if (!CommonUtil.isDeploymentDescriptorRoot(o, false) /*&& !isJ2EEProject(o)*/) - return false; - } - return true; - } - - protected boolean isSelectionAllApplications() { - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator it = sel.iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (!(o instanceof Application) && !isJ2EEApplicationProject(o)) - return false; - } - return true; - } - - - protected List getModules() { - if (modules == null) { - modules = new ArrayList(); - IStructuredSelection sel = (StructuredSelection) getSelection(); - Iterator iterator = sel.iterator(); - WorkbenchComponent module = null; - Object o = null; - while (iterator.hasNext()) { - o = iterator.next(); - if (o instanceof WorkbenchComponent) { - modules.add(o); - } else if (o instanceof EObject) { - EObject obj = (EObject) o; - IProject project = ProjectUtilities.getProject(obj); - StructureEdit moduleCore = null; - try { - moduleCore = StructureEdit.getStructureEditForRead(project); - URI uri = obj.eResource().getURI(); - ComponentResource[] resources = moduleCore.findResourcesBySourcePath(uri); - for (int i=0; i<resources.length; i++) { - module = resources[i].getComponent(); - if (module !=null) - break; - } - if (module == null) - throw new RuntimeException(J2EEUIMessages.getResourceString("Project_should_not_be_null_1_ERROR_")); //$NON-NLS-1$ - modules.add(module); - } catch (UnresolveableURIException e) { - //Ignore - } finally { - if (moduleCore !=null) - moduleCore.dispose(); - } - } else { - throw new RuntimeException(J2EEUIMessages.getResourceString("Non-project_in_selection_2_ERROR_")); //$NON-NLS-1$ - } - } - } - return modules; - } - - /** - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - try { - List localModules = getModules(); - if (localModules.size() != 1) - return; - WorkbenchComponent module = (WorkbenchComponent) localModules.get(0); - J2EERenameDialog dlg = null; - - // if all we are doing is renaming an EAR, let the base platform do it - if (isSelectionAllApplications()) { - RenameResourceAction action = new RenameResourceAction(shell); - action.selectionChanged(new StructuredSelection(module)); - action.run(); - } else { - String contextRoot = ""; //$NON-NLS-1$ - //TODO add context root to the module model - //contextRoot = module.getServerContextRoot(); - dlg = new RenameModuleDialog(shell, module.getName(), contextRoot); - dlg.open(); - if (dlg.getReturnCode() == Window.CANCEL) - return; - - options = dlg.getRenameOptions(); - if (options != null) - options.setSelectedProjects(localModules); - - if (!(ensureEditorsSaved() && validateState())) - return; - renameProjectsIfNecessary(); - renameMetadataIfNecessary(); - presentStatusIfNeccessary(); - } - } finally { - reset(); - } - } - - - private boolean ensureEditorsSaved() { - return CommonEditorUtility.promptToSaveAllDirtyEditors(); - } - - protected Set getReferencedProjects() { - if (referencedProjects == null) - computeReferencedProjects(); - return referencedProjects; - } - - protected void computeReferencedProjects() { - getModules(); - referencedProjects = new HashSet(); - for (int i = 0; i < modules.size(); i++) { - //WorkbenchComponent module = (WorkbenchComponent) modules.get(i); - //TODO fix up code here for modules instead of projects -// EARNatureRuntime runtime = EARNatureRuntime.getRuntime(project); -// if (runtime == null) -// continue; -// EAREditModel editModel = runtime.getEarEditModelForRead(this); -// try { -// referencedProjects.addAll(editModel.getModuleMappedProjects()); -// } finally { -// editModel.releaseAccess(this); -// } - } - } - - protected void renameMetadataIfNecessary() { - if (!shouldRenameMetaData()) - return; -// RenameModuleOperation op = getRenameModuleOperation(); -// IRunnableWithProgress runnable = WTPUIPlugin.getRunnableWithProgress(op); -// ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(shell); -// -// try { -// monitorDialog.run(false, false, runnable); -// } catch (InvocationTargetException e) { -// handleException(e); -// } catch (InterruptedException e) { -// //Ignore -// } - } - - protected boolean shouldRenameMetaData() { - if (renameProjectsFailedOrCancelled()) - return false; - - return primShouldRenameMetaData(); - } - - protected boolean renameProjectsFailedOrCancelled() { - if (options == null || !options.shouldRenameProjects()) - return false; - return renamedProjectsExist(); - } - - protected boolean renamedProjectsExist() { - List renamedProjects = options.getAllProjectsToRename(); - for (int i = 0; i < renamedProjects.size(); i++) { - IProject project = (IProject) renamedProjects.get(i); - if (project.exists()) - return true; - } - return false; - } - - protected void renameProjectsIfNecessary() { - if (options == null || !options.shouldRenameProjects()) - return; - J2EERenameResourceAction action = new J2EERenameResourceAction(shell); - action.setNewName(options.getNewName()); - IStructuredSelection sel = new StructuredSelection(options.getAllProjectsToRename()); - action.selectionChanged(sel); - action.run(); - - // only web projects should have a context root - String newContextRoot = options.getNewContextRoot(); - if (newContextRoot != null && options.shouldRenameProjects()) { - //WorkbenchComponent module = (WorkbenchComponent) getModules().get(0); - try { - // TODO add server context root to the module model - //module.setServerContextRoot(newContextRoot); - } catch (Throwable t) { - //Ignore - } - } - } - - public void handleException(InvocationTargetException e) { - Logger.getLogger().logError(e); - IStatus status = J2EEPlugin.newErrorStatus(IStatus.ERROR, RENAME_ERROR, e); - ErrorDialog.openError(shell, RENAME_ERROR, RENAME_NOT_COMPLETED, status); - } - - /** - * Update the action's enable state according to the current selection of the used selection - * provider. - */ - public void update() { - IStructuredSelection selection = null; - - if (provider != null) { - selection = (IStructuredSelection) provider.getSelection(); - super.update(selection); - } else { - selection = (IStructuredSelection) getSelection(); - - if (selection == null) { - setEnabled(false); - } else { - updateSelection(selection); - } - } - } - - protected boolean isJ2EEApplicationProject(Object o) { - if (o instanceof IProject) { - IProject project = (IProject) o; - if (J2EEProjectUtilities.isEARProject(project)) - return true; - } - return false; - } - - protected boolean validateState() { - if (!primShouldRenameMetaData()) - return true; - -// IValidateEditListener listener = new ValidateEditListener(null, getRenameModuleOperation().getRenameEditModel()); -// listener.setShell(shell); -// return listener.validateState().isOK(); - return false; - } - - protected boolean primShouldRenameMetaData() { - return options != null && (options.shouldRenameModules() || options.shouldRenameModuleDependencies()); - } - -// protected RenameModuleOperation getRenameModuleOperation() { -// if (renameModuleOperation == null) { -// renameModuleOperation = new RenameModuleOperation(options); -// } -// return renameModuleOperation; -// } - - protected void presentStatusIfNeccessary() { - IStatus status = null; - -// if (renameModuleOperation != null) { -// status = renameModuleOperation.getStatus(); -// } - - if (status == null || status.isOK()) - return; - - ErrorDialog.openError(shell, null, null, status, IStatus.ERROR); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java deleted file mode 100644 index e52b7c605..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameParticipant.java +++ /dev/null @@ -1,95 +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 26, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.j2ee.internal.dialogs.J2EERenameUIConstants; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; -import org.eclipse.wst.common.frameworks.internal.AdaptabilityUtility; - - -/** - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EERenameParticipant extends RenameParticipant { - - private static final Class IPROJECT_CLASS = IProject.class; - - public J2EERenameParticipant() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - if (element == null) - return false; - - IProject project = (IProject) AdaptabilityUtility.getAdapter(element, IPROJECT_CLASS); - if (project.isAccessible()) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { - Object[] targetElements = getProcessor().getElements(); - if (targetElements == null || targetElements.length != 1) - return null; - IProject project = (IProject) AdaptabilityUtility.getAdapter(targetElements[0], IPROJECT_CLASS); - - if (project != null) - return new J2EEModuleRenameChange(project, getArguments().getNewName(), getArguments().getUpdateReferences()); - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - return J2EERenameUIConstants.RENAME; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { - return RefactoringStatus.create(Status.OK_STATUS); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java deleted file mode 100644 index f927e1cac..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EERenameResourceAction.java +++ /dev/null @@ -1,67 +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.actions; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.RenameResourceAction; - -public class J2EERenameResourceAction extends RenameResourceAction { - String newName = null; - - /** - * Creates a new action. Using this constructor directly will rename using a dialog (if - * necessary) rather than the inline editor of a ResourceNavigator. Note that a rename happens - * on one and only one resource at a time. - * - * @param shell - * the shell for any dialogs - */ - public J2EERenameResourceAction(Shell shell) { - super(shell); - } - - /** - * Return the new name to be given to the target resource. - * - * @return java.lang.String - */ - protected String queryNewResourceName(final IResource resource) { - String retVal = null; - - if (newName == null || newName.length() < 1) { - retVal = super.queryNewResourceName(resource); - } else { - retVal = newName; - } - - return retVal; - } - - /** - * Gets the newName. - * - * @return Returns a String - */ - public String getNewName() { - return newName; - } - - /** - * Sets the newName. - * - * @param newName - * The newName to set - */ - public void setNewName(String newName) { - this.newName = newName; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java deleted file mode 100644 index 2d0657e3b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEResourceOpenListener.java +++ /dev/null @@ -1,56 +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 2, 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.actions; - -import org.eclipse.jface.viewers.IOpenListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; - -/** - * @author Admin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class J2EEResourceOpenListener implements IOpenListener{ - - private OpenJ2EEResourceAction action; - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IOpenListener#open(org.eclipse.jface.viewers.OpenEvent) - */ - - public void open(OpenEvent anEvent) { - ISelection selection = anEvent.getSelection(); - if (selection instanceof IStructuredSelection) { - - if (getAction().updateSelection((IStructuredSelection)selection)) - action.run(); - } - - } - - /** - * @return - */ - private OpenJ2EEResourceAction getAction() { - if (action == null) - action = new OpenJ2EEResourceAction(); - return action; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java deleted file mode 100644 index b8a2f7e0e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewAppClientComponentAction.java +++ /dev/null @@ -1,48 +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.actions; - - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard; -import org.eclipse.ui.IWorkbench; - - -public class NewAppClientComponentAction extends AbstractOpenWizardWorkbenchAction { - - // TODO MDE 02-28 Find correct label - public static String LABEL = J2EEUIMessages.getResourceString("NewApplClientModuleAction_UI_0"); //$NON-NLS-1$ - private static final String ICON = "new_appclientproject_wiz"; //$NON-NLS-1$ - - public NewAppClientComponentAction() { - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewAppClientComponentAction(IWorkbench workbench, String label, Class[] acceptedTypes) { - super(workbench, label, acceptedTypes, false); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected Wizard createWizard() { - return new AppClientProjectWizard(); - } - - protected boolean shouldAcceptElement(Object obj) { - return true; /* NewGroup.isOnBuildPath(obj) && !NewGroup.isInArchive(obj); */ - } - - protected String getDialogText() { - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java deleted file mode 100644 index 3c96cb23b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewEARComponentAction.java +++ /dev/null @@ -1,48 +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.actions; - - - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard; -import org.eclipse.ui.IWorkbench; - - -public class NewEARComponentAction extends AbstractOpenWizardWorkbenchAction { - // TODO MDE 02-28 Find correct label - public static String LABEL = J2EEUIMessages.getResourceString("NewEARModuleAction_UI_0"); //$NON-NLS-1$ - private static final String ICON = "newear_wiz"; //$NON-NLS-1$ - - public NewEARComponentAction() { - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewEARComponentAction(IWorkbench workbench, String label, Class[] acceptedTypes) { - super(workbench, label, acceptedTypes, false); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected Wizard createWizard() { - return new EarProjectWizard(); - } - - protected boolean shouldAcceptElement(Object obj) { - return true; /* NewGroup.isOnBuildPath(obj) && !NewGroup.isInArchive(obj); */ - } - - protected String getDialogText() { - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEArtifactDropDownAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEArtifactDropDownAction.java deleted file mode 100644 index f92be5c99..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEArtifactDropDownAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 SAP AG 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; - - -/** - * A wizard is added to the "New Java EE Artifact" drop down if it has a parameter 'javaeeartifact': - * <wizard - * name="My Java EE Project Wizard" - * icon="icons/wiz.gif" - * category="mycategory" - * id="xx.MyWizard"> - * <class class="org.xx.MyWizard"> - * <parameter name="javaeeartifact" value="true"/> - * </class> - * <description> - * My Wizard - * </description> - * </wizard> - */ -public class NewJavaEEArtifactDropDownAction extends NewJavaEEDropDownAction implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { - - private final static String ATT_JAVAEEARTIFACT = "javaeeartifact";//$NON-NLS-1$ - - @Override - protected String getTypeAttribute() { - return ATT_JAVAEEARTIFACT; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEDropDownAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEDropDownAction.java deleted file mode 100644 index 67d9f3e38..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEDropDownAction.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 SAP AG 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import java.util.ArrayList; -import java.util.Arrays; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.internal.ui.util.CoreUtility; -import org.eclipse.jdt.internal.ui.util.PixelConverter; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -import org.eclipse.ui.PlatformUI; - -public abstract class NewJavaEEDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { - - public static class NewJavaEEWizardAction extends Action implements Comparable { - - private final static String ATT_NAME = "name";//$NON-NLS-1$ - private final static String ATT_CLASS = "class";//$NON-NLS-1$ - private final static String ATT_ICON = "icon";//$NON-NLS-1$ - private final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$ - - private Shell fShell; - private IStructuredSelection fSelection; - private IConfigurationElement fConfigurationElement; - - private int menuIndex; - - public NewJavaEEWizardAction(IConfigurationElement element) { - fConfigurationElement= element; - setText(element.getAttribute(ATT_NAME)); - - String description = getDescriptionFromConfig(fConfigurationElement); - setDescription(description); - setToolTipText(description); - setImageDescriptor(getIconFromConfig(fConfigurationElement)); - setMenuIndex(getMenuIndexFromConfig(fConfigurationElement)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - Shell shell = getShell(); - try { - INewWizard wizard = createWizard(); - wizard.init(PlatformUI.getWorkbench(), getSelection()); - - WizardDialog dialog = new WizardDialog(shell, wizard); - PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont()); - dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20)); - dialog.create(); - int res = dialog.open(); - - notifyResult(res == Window.OK); - } catch (CoreException e) { - Logger.getLogger().log(e); - } - } - - /** - * Returns the configured selection. If no selection has been configured using {@link #setSelection(IStructuredSelection)}, - * the currently selected element of the active workbench is returned. - * @return the configured selection - */ - protected IStructuredSelection getSelection() { - if (fSelection == null) { - return evaluateCurrentSelection(); - } - return fSelection; - } - - private IStructuredSelection evaluateCurrentSelection() { - IWorkbenchWindow window = J2EEUIPlugin.getActiveWorkbenchWindow(); - if (window != null) { - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - } - return StructuredSelection.EMPTY; - } - - /** - * Configures the selection to be used as initial selection of the wizard. - * @param selection the selection to be set or <code>null</code> to use the selection of the active workbench window - */ - public void setSelection(IStructuredSelection selection) { - fSelection = selection; - } - - /** - * Returns the configured shell. If no shell has been configured using {@link #setShell(Shell)}, - * the shell of the currently active workbench is returned. - * @return the configured shell - */ - protected Shell getShell() { - if (fShell == null) { - return J2EEUIPlugin.getActiveWorkbenchShell(); - } - return fShell; - } - - /** - * Configures the shell to be used as parent shell by the wizard. - * @param shell the shell to be set or <code>null</code> to use the shell of the active workbench window - */ - public void setShell(Shell shell) { - fShell = shell; - } - - private String getDescriptionFromConfig(IConfigurationElement config) { - IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION); - if (children.length >= 1) { - return children[0].getValue(); - } - return ""; //$NON-NLS-1$ - } - - private ImageDescriptor getIconFromConfig(IConfigurationElement config) { - String iconName = config.getAttribute(ATT_ICON); - if (iconName != null) { - return J2EEUIPlugin.imageDescriptorFromPlugin(config.getContributor().getName(), iconName); - } - return null; - } - - private int getMenuIndexFromConfig(IConfigurationElement config) { - IConfigurationElement[] classElements = config.getChildren(TAG_CLASS); - if (classElements.length > 0) { - for (IConfigurationElement classElement : classElements) { - IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER); - for (IConfigurationElement paramElement : paramElements) { - if (ATT_MENUINDEX.equals(paramElement.getAttribute(TAG_NAME))) { - return Integer.parseInt(paramElement.getAttribute(TAG_VALUE)); - } - } - } - } - return Integer.MAX_VALUE; - } - - protected INewWizard createWizard() throws CoreException { - return (INewWizard) CoreUtility.createExtension(fConfigurationElement, ATT_CLASS); - } - - public int getMenuIndex() { - return menuIndex; - } - - public void setMenuIndex(int menuIndex) { - this.menuIndex = menuIndex; - } - - public int compareTo(Object o) { - NewJavaEEWizardAction action = (NewJavaEEWizardAction) o; - return getMenuIndex() - action.getMenuIndex(); - } - } - - protected final static String TAG_WIZARD = "wizard";//$NON-NLS-1$ - protected final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$ - protected final static String TAG_NAME = "name";//$NON-NLS-1$ - protected final static String TAG_VALUE = "value";//$NON-NLS-1$ - protected final static String TAG_CLASS = "class"; //$NON-NLS-1$ - protected final static String ATT_MENUINDEX = "menuIndex";//$NON-NLS-1$ - protected final static String PL_NEW = "newWizards"; //$NON-NLS-1$ - - protected Menu fMenu; - - protected Shell fWizardShell; - - public NewJavaEEDropDownAction() { - fMenu = null; - setMenuCreator(this); - } - - public void dispose() { - if (fMenu != null) { - fMenu.dispose(); - fMenu = null; - } - } - - public Menu getMenu(Menu parent) { - return null; - } - - public Menu getMenu(Control parent) { - if (fMenu == null) { - fMenu = new Menu(parent); - NewJavaEEWizardAction[] actions = getActionFromDescriptors(); - for (NewJavaEEWizardAction action : actions) { - action.setShell(fWizardShell); - ActionContributionItem item = new ActionContributionItem(action); - item.fill(fMenu, -1); - } - } - return fMenu; - } - - public void run() { - getDefaultAction().run(); - } - - public Action getDefaultAction() { - Action[] actions = getActionFromDescriptors(); - if (actions.length > 0) - return actions[0]; - return null; - } - - public NewJavaEEWizardAction[] getActionFromDescriptors() { - ArrayList<NewJavaEEWizardAction> containers = new ArrayList<NewJavaEEWizardAction>(); - - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, PL_NEW); - if (extensionPoint != null) { - IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for (IConfigurationElement element : elements) { - if (element.getName().equals(TAG_WIZARD) && isJavaEEProjectWizard(element)) { - containers.add(new NewJavaEEWizardAction(element)); - } - } - } - - NewJavaEEWizardAction[] actions = (NewJavaEEWizardAction[]) containers.toArray(new NewJavaEEWizardAction[containers.size()]); - Arrays.sort(actions); - return actions; - } - - protected boolean isJavaEEProjectWizard(IConfigurationElement element) { - IConfigurationElement[] classElements = element.getChildren(TAG_CLASS); - if (classElements.length > 0) { - for (IConfigurationElement classElement : classElements) { - IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER); - for (IConfigurationElement paramElement : paramElements) { - if (getTypeAttribute().equals(paramElement.getAttribute(TAG_NAME))) { - return Boolean.valueOf(paramElement.getAttribute(TAG_VALUE)).booleanValue(); - } - } - } - } - // old way, deprecated - if (Boolean.valueOf(element.getAttribute(getTypeAttribute())).booleanValue()) { - return true; - } - return false; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - fWizardShell = window.getShell(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - - } - - protected abstract String getTypeAttribute(); - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEProjectDropDownAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEProjectDropDownAction.java deleted file mode 100644 index 490cdaf1b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/NewJavaEEProjectDropDownAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 SAP AG 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.actions; - -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; - - -/** - * A wizard is added to the "New Java EE Project" drop down if it has a parameter 'javaeeproject': - * <wizard - * name="My Java EE Project Wizard" - * icon="icons/wiz.gif" - * category="mycategory" - * id="xx.MyWizard"> - * <class class="org.xx.MyWizard"> - * <parameter name="javaeeproject" value="true"/> - * </class> - * <description> - * My Wizard - * </description> - * </wizard> - */ -public class NewJavaEEProjectDropDownAction extends NewJavaEEDropDownAction implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { - - private final static String ATT_JAVAEEPROJECT = "javaeeproject";//$NON-NLS-1$ - - @Override - protected String getTypeAttribute() { - return ATT_JAVAEEPROJECT; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java deleted file mode 100644 index fff4abef4..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/OpenJ2EEResourceAction.java +++ /dev/null @@ -1,414 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.actions; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit; -import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities; -import org.eclipse.jst.j2ee.internal.componentcore.ComponentArchiveOptions; -import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper; -import org.eclipse.jst.j2ee.internal.ejb.provider.J2EEJavaClassProviderHelper; -import org.eclipse.jst.j2ee.internal.plugin.BinaryEditorUtilities; -import org.eclipse.jst.j2ee.internal.plugin.J2EEEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webservice.wsdd.BeanLink; -import org.eclipse.jst.j2ee.webservice.wsdd.EJBLink; -import org.eclipse.jst.j2ee.webservice.wsdd.ServletLink; -import org.eclipse.jst.jee.archive.IArchive; -import org.eclipse.jst.jee.archive.IArchiveResource; -import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -/** - * Action for opening a J2EE resource from the J2EE navigator. - */ -public class OpenJ2EEResourceAction extends AbstractOpenAction { - - public static final String ID = "org.eclipse.jst.j2ee.internal.internal.ui.actions.OpenJ2EEResourceAction"; //$NON-NLS-1$ - public static final String JAVA_EDITOR_ID = "org.eclipse.jst.j2ee.internal.internal.ejb.ui.java.EnterpriseBeanJavaEditor"; //$NON-NLS-1$ - public static final String BASE_JAVA_EDITOR_ID = "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$ - - protected static IEditorDescriptor javaEditorDescriptor; - protected static IEditorDescriptor baseJavaEditorDescriptor; - - /** - * Create an instance of this class - */ - public OpenJ2EEResourceAction() { - super("Open"); //$NON-NLS-1$ - } - - /** - * Returns the action ID. - */ - public String getID() { - return ID; - } - - public static IEditorDescriptor getJavaEditorDescriptor() { - if (javaEditorDescriptor == null) - javaEditorDescriptor = findEditorDescriptor(JAVA_EDITOR_ID); - return javaEditorDescriptor; - } - - public static IEditorDescriptor getBaseJavaEditorDescriptor() { - if (baseJavaEditorDescriptor == null) - baseJavaEditorDescriptor = findEditorDescriptor(BASE_JAVA_EDITOR_ID); - return baseJavaEditorDescriptor; - } - - protected void openAppropriateEditor(IVirtualComponent c){ - if (c == null){ - return; - } - IWorkbenchPage page = null; - IEditorPart editor = null; - try { - page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - - IEditorInput editorInput = null; - - //[Bug 237794] if component c is a JEE 5 archive then editorInput needs to be a BinaryEditorInput - if (c instanceof VirtualArchiveComponent) { - JavaEEQuickPeek qp = JavaEEBinaryComponentHelper.getJavaEEQuickPeek(c); - //[Bug 239440] because Connectors are opened with the basic XML editor and not a specialized editor they need binary editor input - if( qp.getJavaEEVersion() == JavaEEQuickPeek.JEE_5_0_ID || qp.getType() == JavaEEQuickPeek.CONNECTOR_TYPE) { - String path = ((EObject)srcObject).eResource().getURI().toString(); - editorInput = BinaryEditorUtilities.getBinaryEditorInput((VirtualArchiveComponent)c, path); - } - } - - //this is for all other cases - if(editorInput == null) { - editorInput = new ComponentEditorInput(c); - } - - editor = page.openEditor(editorInput, currentDescriptor.getId()); - if (editor instanceof ISetSelectionTarget) - ((ISetSelectionTarget) editor).selectReveal(getStructuredSelection()); - } catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), J2EEUIMessages.getResourceString("Problems_Opening_Editor_ERROR_"), e.getMessage()); //$NON-NLS-1$ = "Problems Opening Editor" - } - } - - - /** - * open the appropriate editor - */ - protected void openAppropriateEditor(IResource r) { - if (r == null) - return; - IWorkbenchPage page = null; - IEditorPart editor = null; - try { - page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - editor = page.openEditor(new FileEditorInput((IFile) r), currentDescriptor.getId()); - if (editor instanceof ISetSelectionTarget) - ((ISetSelectionTarget) editor).selectReveal(getStructuredSelection()); - } catch (Exception e) { - MessageDialog.openError(page.getWorkbenchWindow().getShell(), J2EEUIMessages.getResourceString("Problems_Opening_Editor_ERROR_"), e.getMessage()); //$NON-NLS-1$ = "Problems Opening Editor" - } - } - - /** - * The user has invoked this action - */ - public void run() { - if (!isEnabled()) - return; - - if (srcObject instanceof J2EEJavaClassProviderHelper) { - ((J2EEJavaClassProviderHelper) srcObject).openInEditor(); - return; - } - - if( isEJB3BeanObject(srcObject) ){ - String name = ""; //$NON-NLS-1$ - if( srcObject instanceof org.eclipse.jst.javaee.ejb.SessionBean ){ - org.eclipse.jst.javaee.ejb.SessionBean bean = (org.eclipse.jst.javaee.ejb.SessionBean)srcObject; - name = bean.getEjbClass(); - }else if(srcObject instanceof org.eclipse.jst.javaee.ejb.MessageDrivenBean){ - org.eclipse.jst.javaee.ejb.MessageDrivenBean bean = (org.eclipse.jst.javaee.ejb.MessageDrivenBean)srcObject; - name = bean.getEjbClass(); - }else if(srcObject instanceof org.eclipse.jst.javaee.ejb.EntityBean){ - org.eclipse.jst.javaee.ejb.EntityBean bean = (org.eclipse.jst.javaee.ejb.EntityBean)srcObject; - name = bean.getEjbClass(); - } - - IResource resource = WorkbenchResourceHelper.getFile((EObject)srcObject); - if(resource != null) { - IProject project = resource.getProject(); - IJavaProject javaProject = JavaCore.create(project); - if(javaProject.exists()){ - IType type = null; - try { - //if name is null then can't get type - if(name != null) { - type = javaProject.findType( name ); - } - - //if type is null then can't open its editor, so open editor for the resource - if(type != null) { - ICompilationUnit cu = type.getCompilationUnit(); - EditorUtility.openInEditor(cu); - } else{ - openAppropriateEditor(resource); - } - } catch (JavaModelException e) { - J2EEUIPlugin.logError(-1, e.getMessage(), e); - } catch (PartInitException e) { - J2EEUIPlugin.logError(-1, e.getMessage(), e); - } - - } - } - return; - } - - if (srcObject instanceof EObject) { - EObject ro = (EObject) srcObject; - IProject p = ProjectUtilities.getProject(ro); - - if (ro instanceof BeanLink) { - openBeanLinkInJavaEditor((BeanLink) ro, p); - return; - } - IResource resource = WorkbenchResourceHelper.getFile((EObject)srcObject); - if(resource != null && resource.exists()){ - openAppropriateEditor(resource); - } else if(ro.eResource() != null) { - ModuleFile moduleFile = ArchiveUtil.getModuleFile(ro); - if (moduleFile != null) { - ArchiveOptions options = moduleFile.getOptions(); - if(options instanceof ComponentArchiveOptions) { - IVirtualComponent component = ((ComponentArchiveOptions)options).getComponent(); - openAppropriateEditor(component); - } - } else { - //if can't get a ModuleFile then get the component from the archive - IArchive archive = JavaEEArchiveUtilities.findArchive(ro); - if(archive != null) { - IVirtualComponent component = JavaEEArchiveUtilities.findComponent(archive); - if(component != null){ - openAppropriateEditor(component); - } - } - } - } - } else if (srcObject instanceof Resource) { - openAppropriateEditor(WorkbenchResourceHelper.getFile((Resource)srcObject)); - } - } - - /** - * The structured selection has changed in the workbench. Subclasses should override this method - * to react to the change. Returns true if the action should be enabled for this selection, and - * false otherwise. - * - * When this method is overridden, the super method must always be invoked. If the super method - * returns false, this method must also return false. - * - * @param sel the new structured selection - */ - public boolean updateSelection(IStructuredSelection s) { - if (!super.updateSelection(s)) - return false; - - // Make sure this is one of the selections we can handle, - // then set the source object as is. The run() will do the hard stuff. - Object obj = s.getFirstElement(); - - if (obj instanceof J2EEJavaClassProviderHelper) { - currentDescriptor = getJavaEditorDescriptor(); - } else if (obj instanceof BeanLink) { - currentDescriptor = getBaseJavaEditorDescriptor(); - } else if(isEJB3BeanObject(obj)) { - //[241685] if it is a EJB 3 bean the class is specially opened by the run() method - } else if (obj instanceof EObject) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IFile file = WorkbenchResourceHelper.getFile((EObject)obj); - if(file != null) { - if(file.exists()){ - IContentType contentType = IDE.getContentType(file); - currentDescriptor = registry.getDefaultEditor(file.getName(), contentType); - } else { - currentDescriptor = null; - return false; - } - } else if (((EObject)obj).eResource() != null) { - //[Bug 237794] if the file is null then it maybe a binary resource in an archive - // attempt to get the resource from the archive and the content type from that - EObject eObj = (EObject) obj; - IArchive archive = JavaEEArchiveUtilities.findArchive(eObj); - if(archive != null) { - IPath path = new Path(((EObject)obj).eResource().getURI().toString()); - if(archive.containsArchiveResource(path)) { - InputStream stream = null; - try { - IArchiveResource resource = archive.getArchiveResource(path); - stream = resource.getInputStream(); - IContentType type = Platform.getContentTypeManager().findContentTypeFor(stream, path.lastSegment()); - currentDescriptor = registry.getDefaultEditor(path.lastSegment(),type); - } catch (FileNotFoundException e) { - J2EEUIPlugin.logError(-1, e.getMessage(), e); - } catch (IOException e) { - J2EEUIPlugin.logError(-1, e.getMessage(), e); - } finally { - if(stream != null) { - try { - stream.close(); - } catch (IOException e) { - J2EEUIPlugin.logError(-1, e.getMessage(), e); - } - } - } - - } - } - } - } - else if (obj instanceof Resource) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IFile file = WorkbenchResourceHelper.getFile((Resource)obj); - IContentType contentType = IDE.getContentType(file); - currentDescriptor = registry.getDefaultEditor(file.getName(), contentType); - } - else { - currentDescriptor = null; - return false; - } - setAttributesFromDescriptor(); - srcObject = obj; - return true; - } - - /** - * @param link - */ - private void openBeanLinkInJavaEditor(BeanLink link, IProject p) { - String linkName = null; - JavaClass javaClass = null; - IVirtualComponent comp = ComponentUtilities.findComponent(link); - // Handle EJB Link case - if (link instanceof EJBLink) { - linkName = ((EJBLink) link).getEjbLink(); - EJBArtifactEdit artifactEdit = null; - try { - artifactEdit = EJBArtifactEdit.getEJBArtifactEditForRead(comp); - EJBJar ejbJar = artifactEdit.getEJBJar(); - if (ejbJar == null) - return; - EnterpriseBean bean = ejbJar.getEnterpriseBeanNamed(linkName); - if (bean == null) - return; - javaClass = bean.getEjbClass(); - } finally { - if (artifactEdit!=null) - artifactEdit.dispose(); - } - } - // Handle Servlet Link case - else { - linkName = ((ServletLink) link).getServletLink(); - WebArtifactEdit artifactEdit = null; - try { - artifactEdit = WebArtifactEdit.getWebArtifactEditForRead(comp); - WebApp webApp = artifactEdit.getWebApp(); - if (webApp == null) - return; - Servlet servlet = webApp.getServletNamed(linkName); - if (servlet == null) - return; - javaClass = servlet.getServletClass(); - } finally { - if (artifactEdit!=null) - artifactEdit.dispose(); - } - } - // Open java editor on the selected objects associated java file - try { - J2EEEditorUtility.openInEditor(javaClass, p); - } catch (Exception cantOpen) { - J2EEUIPlugin.logError(-1, cantOpen.getMessage(), cantOpen); - } - } - - protected EObject getRootObject(Object obj) { - if (obj instanceof EObject) { - EObject refObj = (EObject) obj; - while (refObj != null && refObj.eContainer() != null) - refObj = refObj.eContainer(); - return refObj; - } - return null; - } - - /** - * Determines if the given object is a EJB 3 Bean - * [241685] first added - * - * @param obj determine weather this object is an EJB 3 bean or not - * @return true if obj is a EJB 3 bean, false otherwise - */ - private boolean isEJB3BeanObject(Object obj) { - boolean isBean = - obj instanceof org.eclipse.jst.javaee.ejb.SessionBean || - obj instanceof org.eclipse.jst.javaee.ejb.MessageDrivenBean || - obj instanceof org.eclipse.jst.javaee.ejb.EntityBean; - - return isBean; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java deleted file mode 100644 index 5433410e9..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WTPBaseAction.java +++ /dev/null @@ -1,122 +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 Jul 7, 2004 - * - * TODO To change the template for this generated file go to Window - Preferences - Java - Code - * Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.actions; - - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.ErrorDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IWorkbenchWindow; - - - -public abstract class WTPBaseAction extends Action implements IActionDelegate2 { - private final static String ERROR_OCCURRED_TITLE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_TITLE"); //$NON-NLS-1$ - private final static String ERROR_OCCURRED_MESSAGE = J2EEUIMessages.getResourceString("ERROR_OCCURRED_MESSAGE"); //$NON-NLS-1$ - - protected IStructuredSelection selection = null; - - protected IWorkbenchWindow getWorkbenchWindow() { - return J2EEUIPlugin.getPluginWorkbench().getActiveWorkbenchWindow(); - } - - public void setSelection(IStructuredSelection selection) { - this.selection = selection; - } - - public void run() { - Shell shell = getWorkbenchWindow().getShell(); - if (null == selection) { - ISelection autoselection = getWorkbenchWindow().getSelectionService().getSelection(); - if (autoselection instanceof IStructuredSelection) - this.selection = (IStructuredSelection) autoselection; - } - - try { - primRun(shell); - this.selection = null; - } catch (Throwable t) { - ErrorDialog.openError(shell, ERROR_OCCURRED_TITLE, ERROR_OCCURRED_MESSAGE, t, 0, false); - } - - } - - protected abstract void primRun(Shell shell); - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#dispose() - */ - public void dispose() { - //dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - //init - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection aSelection) { - setSelection((IStructuredSelection) aSelection); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, - * org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - run(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - - /** - * @return Returns the selection. - */ - protected IStructuredSelection getSelection() { - return selection; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java deleted file mode 100644 index ec3fac904..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/actions/WorkspaceModifyComposedOperation.java +++ /dev/null @@ -1,44 +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.actions; - -import java.util.List; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.operation.IRunnableWithProgress; - -/** - * WARNING: This class will be deleted - * - * @deprecated use {@link org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation} - */ -public class WorkspaceModifyComposedOperation extends org.eclipse.wst.common.frameworks.internal.ui.WorkspaceModifyComposedOperation { - public WorkspaceModifyComposedOperation(ISchedulingRule rule) { - super(rule); - } - - public WorkspaceModifyComposedOperation() { - super(); - } - - public WorkspaceModifyComposedOperation(ISchedulingRule rule, List nestedRunnablesWithProgress) { - super(rule, nestedRunnablesWithProgress); - } - - public WorkspaceModifyComposedOperation(List nestedRunnablesWithProgress) { - super(nestedRunnablesWithProgress); - } - - public WorkspaceModifyComposedOperation(IRunnableWithProgress nestedOp) { - super(nestedOp); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.java deleted file mode 100644 index ff07596f9..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * rfrost@bea.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.classpathdep.ui; - -import java.net.URL; - -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Shell; - -public class ClasspathDependencyAttributeConfiguration extends ClasspathAttributeConfiguration { - - private static ImageDescriptor descriptor = null; - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#canEdit(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public boolean canEdit(ClasspathAttributeAccess attribute) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#canRemove(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public boolean canRemove(ClasspathAttributeAccess attribute) { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getImageDescriptor(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public ImageDescriptor getImageDescriptor(ClasspathAttributeAccess attribute) { - if (descriptor == null) { - final URL gifImageURL = (URL) J2EEPlugin.getPlugin().getImage("CPDep"); //$NON-NLS-1$ - if (gifImageURL != null) { - descriptor = ImageDescriptor.createFromURL(gifImageURL); - } - } - return descriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getNameLabel(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public String getNameLabel(ClasspathAttributeAccess attribute) { - return Resources.nameLabel; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getValueLabel(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public String getValueLabel(ClasspathAttributeAccess attribute) { - final IClasspathAttribute attrib = attribute.getClasspathAttribute(); - if (attrib != null) { - final String value = attrib.getValue(); - if (value != null) { - if (value.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER)) { - return Resources.containerMapping; - } - return value; - } - } - return Resources.unspecified; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#performEdit(org.eclipse.swt.widgets.Shell, org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public IClasspathAttribute performEdit(Shell shell, - ClasspathAttributeAccess attribute) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#performRemove(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) { - return JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY, null); - } - - private static final class Resources extends NLS { - public static String nameLabel; - public static String unspecified; - public static String containerMapping; - static - { - initializeMessages( ClasspathDependencyAttributeConfiguration.class.getName(), - Resources.class ); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.properties deleted file mode 100644 index 3f050ff33..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyAttributeConfiguration.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2007 BEA Systems, Inc. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# rfrost@bea.com - initial API and implementation -############################################################################### -nameLabel = Publish/export dependency -unspecified = (None) -containerMapping = Added to parent module
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.java deleted file mode 100644 index 3d0a77886..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.java +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * rfrost@bea.com - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.classpathdep.ui; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jst.j2ee.classpathdep.UpdateClasspathAttributeUtil; -import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.IMarkerResolution; -import org.eclipse.ui.IMarkerResolutionGenerator; -import org.eclipse.wst.validation.internal.ConfigurationConstants; - -/** - * IMarkerResolutionGenerator for classpath dependency validator problem markers. - */ -public final class ClasspathDependencyValidatorMarkerResolutions implements IMarkerResolutionGenerator { - - /* (non-Javadoc) - * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker) - */ - public IMarkerResolution[] getResolutions(final IMarker marker) { - // generate resolutions based on type of validation problem marker - String messageId = null; - String cpEntryPath = null; - try { - messageId = (String) marker.getAttribute(ConfigurationConstants.VALIDATION_MARKER_MESSAGEID); - cpEntryPath = (String) marker.getAttribute(ConfigurationConstants.VALIDATION_MARKER_GROUP); - } catch (CoreException ce) { - Logger.getLogger(J2EEUIPlugin.PLUGIN_ID).logError(ce); - return new IMarkerResolution[0]; - } - - if (messageId == null || cpEntryPath == null || cpEntryPath.length() == 0) { - return new IMarkerResolution[0]; - } - - if (ClasspathDependencyValidator.AppClientProject.equals(messageId)) { - // can apply to multiple cp entries so not currently supporting a quick fix... - } else if (ClasspathDependencyValidator.DuplicateClassFolderEntry.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.DuplicateArchiveName.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.FilteredContainer.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.InvalidNonWebRuntimePath.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.InvalidWebRuntimePath.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.NonTaggedExportedClasses.equals(messageId)) { - // quick fix adds the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, true), - new AddClasspathNonDependencyAttributeResolution(cpEntryPath)}; - } else if (ClasspathDependencyValidator.ProjectClasspathEntry.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } else if (ClasspathDependencyValidator.RootMappingNonEARWARRef.equals(messageId)) { - // can apply to multiple cp entries so not currently supporting a quick fix... - } else if (ClasspathDependencyValidator.SourceEntry.equals(messageId)) { - // quick fix removes the dependency - return new IMarkerResolution[] { new UpdateClasspathDependencyAttributeResolution(cpEntryPath, false) }; - } - - return new IMarkerResolution[0]; - } - - private static IClasspathEntry getClasspathEntryForMarker(final IMarker marker, final String cpEntryPath) throws CoreException { - final IProject proj = marker.getResource().getProject(); - if (proj != null && proj.hasNature(JavaCore.NATURE_ID)) { - final IJavaProject jProject = JavaCore.create(proj); - if (cpEntryPath != null) { - IClasspathEntry[] rawCp = jProject.getRawClasspath(); - for (int i = 0; i < rawCp.length; i++) { - if (rawCp[i].getPath().toString().equals(cpEntryPath)) { - return rawCp[i]; - } - } - } - } - return null; - } - - /* Resolution that add/removes the classpath dependency attribute */ - private static final class UpdateClasspathDependencyAttributeResolution implements IMarkerResolution { - private final boolean add; - private final String cpEntryPath; - public UpdateClasspathDependencyAttributeResolution(final String cpEntryPath, final boolean add) { - this.add = add; - this.cpEntryPath = cpEntryPath; - } - - public String getLabel() { - if (add) { - return Resources.addClasspathDependencyAttribute; - } - return Resources.removeClasspathDependencyAttribute; - } - - public void run(final IMarker marker) { - final IProject proj = marker.getResource().getProject(); - try { - final IClasspathEntry cpEntry = getClasspathEntryForMarker(marker, cpEntryPath); - if (add) { - UpdateClasspathAttributeUtil.addDependencyAttribute(null, proj.getName(), cpEntry); - } else { - UpdateClasspathAttributeUtil.removeDependencyAttribute(null, proj.getName(), cpEntry); - } - } catch (CoreException ce){ - ErrorDialog.openError(null, Resources.errorDialogTitle, - Resources.errorDialogMessage, - ce.getStatus()); - } catch (ExecutionException ee){ - ErrorDialog.openError(null, Resources.errorDialogTitle, - Resources.errorDialogMessage, - new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, 0, ee.getLocalizedMessage(), ee)); - } - } - } - - /* Resolution that adds the classpath nondependency attribute */ - private static final class AddClasspathNonDependencyAttributeResolution implements IMarkerResolution { - private final String cpEntryPath; - public AddClasspathNonDependencyAttributeResolution(final String cpEntryPath) { - this.cpEntryPath = cpEntryPath; - } - - public String getLabel() { - return Resources.addClasspathNonDependencyAttribute; - } - - public void run(final IMarker marker) { - final IProject proj = marker.getResource().getProject(); - try { - final IClasspathEntry cpEntry = getClasspathEntryForMarker(marker, cpEntryPath); - UpdateClasspathAttributeUtil.addNonDependencyAttribute(null, proj.getName(), cpEntry); - } catch (CoreException ce){ - ErrorDialog.openError(null, Resources.errorDialogTitle, - Resources.errorDialogMessage, - ce.getStatus()); - } catch (ExecutionException ee){ - ErrorDialog.openError(null, Resources.errorDialogTitle, - Resources.errorDialogMessage, - new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, 0, ee.getLocalizedMessage(), ee)); - } - } - } - - private static final class Resources extends NLS { - public static String removeClasspathDependencyAttribute; - public static String addClasspathDependencyAttribute; - public static String addClasspathNonDependencyAttribute; - public static String errorDialogTitle; - public static String errorDialogMessage; - - static - { - initializeMessages( ClasspathDependencyValidatorMarkerResolutions.class.getName(), - Resources.class ); - } - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.properties deleted file mode 100644 index c21e5af92..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathDependencyValidatorMarkerResolutions.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2007 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 -############################################################################### -addClasspathDependencyAttribute = Mark the associated raw classpath entry as a publish/export dependency. -addClasspathNonDependencyAttribute = Exclude the associated raw classpath entry from the set of potential publish/export dependencies. -removeClasspathDependencyAttribute = Remove publish/export dependency on the associated raw classpath entry. -errorDialogTitle = Error -errorDialogMessage = Failed while applying the quick fix.
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.java deleted file mode 100644 index ccc92105d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * rfrost@bea.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.classpathdep.ui; - -import java.net.URL; - -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Shell; - -public class ClasspathNonDependencyAttributeConfiguration extends ClasspathAttributeConfiguration { - - private static ImageDescriptor descriptor = null; - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#canEdit(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public boolean canEdit(ClasspathAttributeAccess attribute) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#canRemove(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public boolean canRemove(ClasspathAttributeAccess attribute) { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getImageDescriptor(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public ImageDescriptor getImageDescriptor(ClasspathAttributeAccess attribute) { - if (descriptor == null) { - final URL gifImageURL = (URL) J2EEPlugin.getPlugin().getImage("CPDep"); //$NON-NLS-1$ - if (gifImageURL != null) { - descriptor = ImageDescriptor.createFromURL(gifImageURL); - } - } - return descriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getNameLabel(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public String getNameLabel(ClasspathAttributeAccess attribute) { - return Resources.nameLabel; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#getValueLabel(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public String getValueLabel(ClasspathAttributeAccess attribute) { - return Resources.unspecified; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#performEdit(org.eclipse.swt.widgets.Shell, org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public IClasspathAttribute performEdit(Shell shell, - ClasspathAttributeAccess attribute) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration#performRemove(org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration.ClasspathAttributeAccess) - */ - public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) { - return JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_NON_DEPENDENCY, null); - } - - private static final class Resources extends NLS { - public static String nameLabel; - public static String unspecified; - static - { - initializeMessages( ClasspathNonDependencyAttributeConfiguration.class.getName(), - Resources.class ); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.properties deleted file mode 100644 index 5234408ef..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/classpathdep/ui/ClasspathNonDependencyAttributeConfiguration.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2007 BEA Systems, Inc. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# rfrost@bea.com - initial API and implementation -############################################################################### -nameLabel = Excluded from publish/export structure -unspecified = (None)
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/AppClientArchiveUIResourceHandler.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/AppClientArchiveUIResourceHandler.java deleted file mode 100644 index f610fcf6b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/AppClientArchiveUIResourceHandler.java +++ /dev/null @@ -1,59 +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.client.actions; - - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class AppClientArchiveUIResourceHandler { - - private static ResourceBundle fgResourceBundle; - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("appclientarchiveui");//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String, String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ExportApplicationClientAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ExportApplicationClientAction.java deleted file mode 100644 index 296fd5543..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ExportApplicationClientAction.java +++ /dev/null @@ -1,51 +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 Mar 27, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.client.actions; - -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.actions.BaseAction; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.AppClientComponentExportWizard; -import org.eclipse.swt.widgets.Shell; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ExportApplicationClientAction extends BaseAction { - public static String LABEL = J2EEUIPlugin.getDefault().getDescriptor().getResourceString("%client.export.action.label_ui_"); //$NON-NLS-1$ - private static final String ICON = "appclient_export_wiz"; //$NON-NLS-1$ - - public ExportApplicationClientAction() { - super(); - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected void primRun(Shell shell) { - AppClientComponentExportWizard wizard = new AppClientComponentExportWizard(); - J2EEUIPlugin plugin = J2EEUIPlugin.getDefault(); - wizard.init(plugin.getWorkbench(), selection); - - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.create(); - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ImportApplicationClientAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ImportApplicationClientAction.java deleted file mode 100644 index eec615500..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/client/actions/ImportApplicationClientAction.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 Mar 27, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.client.actions; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.actions.BaseAction; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.AppClientComponentImportWizard; -import org.eclipse.swt.widgets.Shell; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ImportApplicationClientAction extends BaseAction { - - public static String LABEL = AppClientArchiveUIResourceHandler.getString("Application_Client_Import_UI_"); //$NON-NLS-1$ - private static final String ICON = "appclient_import_wiz"; //$NON-NLS-1$ - - public ImportApplicationClientAction() { - super(); - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected void primRun(Shell shell) { - - AppClientComponentImportWizard wizard = new AppClientComponentImportWizard(); - - J2EEUIPlugin plugin = J2EEUIPlugin.getDefault(); - - wizard.init(plugin.getWorkbench(), StructuredSelection.EMPTY); - - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.create(); - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/AbstractOverrideCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/AbstractOverrideCommand.java deleted file mode 100644 index 42564f6ca..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/AbstractOverrideCommand.java +++ /dev/null @@ -1,97 +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.command; - - -import java.util.Collection; - -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.emf.edit.command.AbstractOverrideableCommand; -import org.eclipse.emf.edit.domain.EditingDomain; - -/** - * Insert the type's description here. Creation date: (06/07/01 10:56:08 AM) - * - * @author: Administrator - */ -public abstract class AbstractOverrideCommand extends AbstractCommand { - private AbstractOverrideableCommand overridable; - private J2EEClipboard j2eeClipboard; - - /** - * AbstractOverrideCommand constructor comment. - */ - protected AbstractOverrideCommand() { - super(); - } - - public AbstractOverrideCommand(AbstractOverrideableCommand command) { - super(command.getLabel(), command.getDescription()); - setOverridable(command); - } - - public boolean canExecute() { - return super.canExecute() && overridable.doCanExecute(); - } - - public boolean canUndo() { - return overridable.doCanUndo(); - } - - public Collection getAffectedObjects() { - return overridable.doGetAffectedObjects(); - } - - public EditingDomain getDomain() { - return getOverridable().getDomain(); - } - - /** - * Insert the method's description here. Creation date: (06/07/01 11:19:27 AM) - * - * @return org.eclipse.jst.j2ee.internal.internal.internal.command.J2EEClipboard - */ - public J2EEClipboard getJ2eeClipboard() { - return j2eeClipboard; - } - - /** - * Insert the method's description here. Creation date: (06/07/01 10:58:33 AM) - * - * @return AbstractOverrideableCommand - */ - public AbstractOverrideableCommand getOverridable() { - return overridable; - } - - public Collection getResult() { - return getJ2eeClipboard(); - } - - /** - * Insert the method's description here. Creation date: (06/07/01 11:19:27 AM) - * - * @param newJ2eeClipboard - * org.eclipse.jst.j2ee.internal.internal.internal.command.J2EEClipboard - */ - protected void setJ2eeClipboard(J2EEClipboard newJ2eeClipboard) { - j2eeClipboard = newJ2eeClipboard; - } - - /** - * Insert the method's description here. Creation date: (06/07/01 10:58:33 AM) - * - * @param AbstractOverrideableCommand - */ - protected void setOverridable(AbstractOverrideableCommand newOverridable) { - overridable = newOverridable; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEClipboard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEClipboard.java deleted file mode 100644 index 4e4ab253f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEClipboard.java +++ /dev/null @@ -1,83 +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.command; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; - -public class J2EEClipboard extends ArrayList { - /** - * Warning cleanup 12/07/2005 - */ - private static final long serialVersionUID = 8713021573099134096L; - private Map bindings; - private Map extensions; - - /** - * J2EEClipboard constructor comment. - */ - public J2EEClipboard(Collection defaultClipboard) { - super(defaultClipboard); - } - - public boolean addAll(Collection c) { - boolean result = super.addAll(c); - if (result && (c instanceof J2EEClipboard)) - addAllExtra((J2EEClipboard) c); - return result; - } - - protected void addAllExtra(J2EEClipboard c) { - getBindings().putAll(c.getBindings()); - getExtensions().putAll(c.getExtensions()); - } - - protected void addBinding(EObject boundObject, EObject binding) { - getBindings().put(boundObject, binding); - } - - protected void addExtension(EObject extendedObject, EObject extension) { - getExtensions().put(extendedObject, extension); - } - - public EObject getBinding(EObject o) { - return (EObject) getBindings().get(o); - } - - protected Map getBindings() { - if (bindings == null) - bindings = new HashMap(10); - return bindings; - } - - public EObject getExtension(EObject o) { - return (EObject) getExtensions().get(o); - } - - protected Map getExtensions() { - if (extensions == null) - extensions = new HashMap(10); - return extensions; - } - - public boolean hasBindings() { - return bindings != null && !bindings.isEmpty(); - } - - public boolean hasExtensions() { - return extensions != null && !extensions.isEmpty(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECompoundCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECompoundCommand.java deleted file mode 100644 index bf103abeb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECompoundCommand.java +++ /dev/null @@ -1,191 +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.command; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; - -/** - * Insert the type's description here. Creation date: (06/13/01 10:27:16 AM) - * - * @author: Administrator - */ -public class J2EECompoundCommand extends CompoundCommand { - /** - * J2EECompoundCommand constructor comment. - */ - public J2EECompoundCommand() { - super(); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - */ - public J2EECompoundCommand(int resultIndex) { - super(resultIndex); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - * @param label - * java.lang.String - */ - public J2EECompoundCommand(int resultIndex, String label) { - super(resultIndex, label); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - public J2EECompoundCommand(int resultIndex, String label, String description) { - super(resultIndex, label, description); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - * @param label - * java.lang.String - * @param description - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(int resultIndex, String label, String description, java.util.List commandList) { - super(resultIndex, label, description, commandList); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - * @param label - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(int resultIndex, String label, java.util.List commandList) { - super(resultIndex, label, commandList); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param resultIndex - * int - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(int resultIndex, java.util.List commandList) { - super(resultIndex, commandList); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param label - * java.lang.String - */ - public J2EECompoundCommand(String label) { - super(label); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - public J2EECompoundCommand(String label, String description) { - super(label, description); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(String label, String description, java.util.List commandList) { - super(label, description, commandList); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(String label, java.util.List commandList) { - super(label, commandList); - } - - /** - * J2EECompoundCommand constructor comment. - * - * @param commandList - * java.util.List - */ - public J2EECompoundCommand(java.util.List commandList) { - super(commandList); - } - - protected Collection getMergedAffectedObjectsCollection() { - J2EEClipboard result = new J2EEClipboard(new ArrayList()); - - for (Iterator commands = commandList.iterator(); commands.hasNext();) { - Command command = (Command) commands.next(); - result.addAll(command.getAffectedObjects()); - } - - return result; - } - - protected Collection getMergedResultCollection() { - J2EEClipboard result = new J2EEClipboard(new ArrayList()); - - for (Iterator commands = commandList.iterator(); commands.hasNext();) { - Command command = (Command) commands.next(); - result.addAll(command.getResult()); - } - - return result; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyCommand.java deleted file mode 100644 index 51dc0bdc3..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyCommand.java +++ /dev/null @@ -1,81 +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.command; - - -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.internal.emf.utilities.CopyGroup; -import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility; - - -public class J2EECopyCommand extends AbstractCommand { - protected EObject objectToCopy; - protected EObject bindingToCopy; - protected EObject extensionToCopy; - protected J2EEClipboard result; - protected EtoolsCopyUtility copyUtil; - - public J2EECopyCommand(EObject object, EObject binding, EObject extension, EtoolsCopyUtility copyUtility) { - objectToCopy = object; - bindingToCopy = binding; - extensionToCopy = extension; - copyUtil = copyUtility; - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void execute() { - CopyGroup group = new CopyGroup(); - - group.add(objectToCopy); - - if (bindingToCopy != null) - group.add(bindingToCopy); - if (extensionToCopy != null) - group.add(extensionToCopy); - copyUtil.copy(group); - EObject copy = copyUtil.getCopy(objectToCopy); - result = new J2EEClipboard(Collections.singleton(copy)); - - if (bindingToCopy != null) - result.addBinding(copy, copyUtil.getCopy(bindingToCopy)); - if (extensionToCopy != null) - result.addExtension(copy, copyUtil.getCopy(extensionToCopy)); - } - - public Collection getAffectedObjects() { - return result; - } - - public Collection getResult() { - return result; - } - - protected boolean prepare() { - return true; - } - - /** - * This will again perform the command activity required to redo the effect after undoing the - * effect. The effect, if any, of calling redo before undo is called is undefined. Note that if - * you implement redo to call execute then any derived class will be restricted to by that - * decision also. - */ - public void redo() { - //redo - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyFromClipboardCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyFromClipboardCommand.java deleted file mode 100644 index 5581decf7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyFromClipboardCommand.java +++ /dev/null @@ -1,96 +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.command; - - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.emf.common.command.AbstractCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.j2ee.internal.provider.J2EEUIEditingDomain; -import org.eclipse.wst.common.internal.emf.utilities.CopyGroup; -import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility; - - -/** - * Insert the type's description here. Creation date: (06/11/01 8:45:21 AM) - * - * @author: Administrator - */ -public class J2EECopyFromClipboardCommand extends AbstractCommand { - private J2EEUIEditingDomain domain; - private J2EEClipboard result; - private EtoolsCopyUtility copyUtil; - - public J2EECopyFromClipboardCommand(J2EEUIEditingDomain editingDomain) { - domain = editingDomain; - - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void execute() { - if (copyUtil != null) - return; - copyUtil = new EtoolsCopyUtility(); - J2EEClipboard clipboard = domain.getJ2EEClipboard(); - result = new J2EEClipboard(new ArrayList(0)); - for (int i = 0; i < clipboard.size(); i++) { - CopyGroup group = new CopyGroup(); - EObject o = (EObject) clipboard.get(i); - group.add(o); - EObject bnd = clipboard.getBinding(o); - if (bnd != null) - group.add(bnd); - EObject ext = clipboard.getExtension(o); - if (ext != null) - group.add(ext); - copyUtil.copy(group); - EObject copy = copyUtil.getCopy(o); - result.add(copy); - if (bnd != null) - result.addBinding(copy, copyUtil.getCopy(bnd)); - if (ext != null) - result.addExtension(copy, copyUtil.getCopy(ext)); - } - //Reset the util so redo will actuall redo - copyUtil = null; - } - - public Collection getAffectedObjects() { - return result; - } - - public Collection getResult() { - return result; - } - - protected boolean prepare() { - return true; - } - - /** - * This will again perform the command activity required to redo the effect after undoing the - * effect. The effect, if any, of calling redo before undo is called is undefined. Note that if - * you implement redo to call execute then any derived class will be restricted to by that - * decision also. - */ - public void redo() { - execute(); - } - - public void undo() { - result = null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyToClipboardOverrideCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyToClipboardOverrideCommand.java deleted file mode 100644 index eb42b83f8..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EECopyToClipboardOverrideCommand.java +++ /dev/null @@ -1,84 +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.command; - - -import java.util.Iterator; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.common.command.UnexecutableCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.command.CopyToClipboardCommand; -import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopyUtility; - - -public class J2EECopyToClipboardOverrideCommand extends CopyToClipboardCommand { - //The collection of source objects, with bindings and extensions, if any exist - protected J2EEClipboard extendedSourceObjects; - protected boolean onlyRefObjects = true; - - public J2EECopyToClipboardOverrideCommand(CopyToClipboardCommand cmd) { - super(cmd.getDomain(), cmd.getSourceObjects()); - } - - protected Command createCopyCommand() { - CompoundCommand cmd = new J2EECompoundCommand(CompoundCommand.MERGE_COMMAND_ALL); - Iterator it = extendedSourceObjects.iterator(); - EtoolsCopyUtility copyUtil = new EtoolsCopyUtility(); - while (it.hasNext()) { - Object o = it.next(); - if (!(o instanceof EObject)) { - cmd.append(UnexecutableCommand.INSTANCE); - } else { - EObject r = (EObject) o; - cmd.append(new J2EECopyCommand(r, extendedSourceObjects.getBinding(r), extendedSourceObjects.getExtension(r), copyUtil)); - } - } - return cmd.unwrap(); - } - - protected boolean prepare() { - prepareSourceObjects(); - if (!onlyRefObjects) { - copyCommand = UnexecutableCommand.INSTANCE; - return copyCommand.canExecute(); - } - - if (!extendedSourceObjects.hasBindings() && !extendedSourceObjects.hasExtensions()) - return super.prepare(); - - copyCommand = createCopyCommand(); - return copyCommand.canExecute(); - } - - protected void prepareSourceObjects() { - extendedSourceObjects = new J2EEClipboard(getSourceObjects()); - Iterator it = getSourceObjects().iterator(); - while (it.hasNext()) { - Object o = it.next(); - if (o instanceof EObject) { - // EObject r = (EObject) o; - // TODO switch to adaptable commands - // EObject bnd = BindingAndExtensionHelper.getBinding(r); - // EObject ext = BindingAndExtensionHelper.getExtension(r); - // if (bnd != null) - // extendedSourceObjects.addBinding(r, bnd); - // if (ext != null) - // extendedSourceObjects.addExtension(r, ext); - } else { - //Right now we can only handle ref objects in the tree - onlyRefObjects = false; - return; - } - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEPasteFromClipboardOverrideCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEPasteFromClipboardOverrideCommand.java deleted file mode 100644 index d51a6d5d0..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEPasteFromClipboardOverrideCommand.java +++ /dev/null @@ -1,150 +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.command; - - -import java.util.Collection; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandWrapper; -import org.eclipse.emf.common.command.StrictCompoundCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.PasteFromClipboardCommand; -import org.eclipse.jst.j2ee.common.internal.util.IDUtility; -import org.eclipse.jst.j2ee.internal.provider.J2EEUIEditingDomain; - - -public class J2EEPasteFromClipboardOverrideCommand extends PasteFromClipboardCommand { - private J2EECopyFromClipboardCommand copyCommand; - private Command addBindingsCommand; - private Command addExtensionsCommand; - - public J2EEPasteFromClipboardOverrideCommand(PasteFromClipboardCommand p) { - super(p.getDomain(), p.getOwner(), p.getFeature(), p.getIndex(), false); - } - - public void doExecute() { - super.doExecute(); - executeAddBindings(); - executeAddExtensions(); - J2EEClipboard result = (J2EEClipboard) doGetResult(); - for (int i = 0; i < result.size(); i++) { - EObject o = (EObject) result.get(i); - if (result.getBinding(o) != null || result.getExtension(o) != null) - IDUtility.setDefaultID(o, true); - } - } - - public Collection doGetAffectedObjects() { - return copyCommand.getAffectedObjects(); - } - - public Collection doGetResult() { - return copyCommand.getResult(); - } - - public void doRedo() { - super.doRedo(); - if (addBindingsCommand != null) - addBindingsCommand.redo(); - if (addExtensionsCommand != null) - addExtensionsCommand.redo(); - } - - public void doUndo() { - super.doUndo(); - if (addBindingsCommand != null) - addBindingsCommand.undo(); - if (addExtensionsCommand != null) - addExtensionsCommand.undo(); - } - - protected void executeAddBindings() { - if (addBindingsCommand != null && addBindingsCommand.canExecute()) - addBindingsCommand.execute(); - } - - protected void executeAddExtensions() { - if (addExtensionsCommand != null && addExtensionsCommand.canExecute()) - addExtensionsCommand.execute(); - } - - public J2EEClipboard getCopiedClipoard() { - return (J2EEClipboard) copyCommand.getResult(); - } - - protected J2EEClipboard getJ2EEClipboard() { - return (J2EEClipboard) domain.getClipboard(); - } - - protected boolean prepare() { - if (getJ2EEClipboard() == null) - return false; - command = new StrictCompoundCommand(); - - copyCommand = new J2EECopyFromClipboardCommand((J2EEUIEditingDomain) domain); - command.append(copyCommand); - - command.append(new CommandWrapper() { - protected Command createCommand() { - Command addCommand = AddCommand.create(getDomain(), getOwner(), getFeature(), copyCommand.getResult(), getIndex()); - return addCommand; - } - }); - prepareBindingCommand(copyCommand); - prepareExtensionCommand(copyCommand); - - boolean result; - if (optimize) { - // This will determine canExecute as efficiently as possible. - // - result = optimizedCanExecute(); - } else { - // This will actually execute the copy command in order to check if the add can execute. - // - result = command.canExecute(); - } - - return result; - } - - protected void prepareBindingCommand(final J2EECopyFromClipboardCommand cmd) { - if (!getJ2EEClipboard().hasBindings()) - return; - //TODO make adaptable command - // addBindingsCommand = new CommandWrapper() { - // protected Command createCommand() { - // Object bindingOwner = BindingAndExtensionHelper.getBindingAddOwner((EObject)getOwner()); - // Collection bindingsCopies = getCopiedClipoard().getBindings().values(); - // Command addCommand = AddCommand.create(getDomain(), bindingOwner, null, bindingsCopies, - // CommandParameter.NO_INDEX); - // return addCommand; - // } - // }; - } - - protected void prepareExtensionCommand(final J2EECopyFromClipboardCommand cmd) { - if (!getJ2EEClipboard().hasExtensions()) - return; - // TODO make adaptable command - // addExtensionsCommand = new CommandWrapper() { - // protected Command createCommand() { - // Object extensionOwner = - // BindingAndExtensionHelper.getExtensionAddOwner((EObject)getOwner()); - // Collection extensionsCopies = getCopiedClipoard().getExtensions().values(); - // Command addCommand = AddCommand.create(getDomain(), extensionOwner, null, - // extensionsCopies, CommandParameter.NO_INDEX); - // return addCommand; - // } - // }; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EERemoveOverrideCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EERemoveOverrideCommand.java deleted file mode 100644 index ab6103904..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EERemoveOverrideCommand.java +++ /dev/null @@ -1,170 +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.command; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.command.RemoveCommand; - -/** - * Insert the type's description here. Creation date: (06/07/01 10:44:02 AM) - * - * @author: Administrator - */ -public class J2EERemoveOverrideCommand extends AbstractOverrideCommand { - private RemoveCommand bindingsRemoveCommand; - private RemoveCommand extensionsRemoveCommand; - private ResourceSet resourceSet; - - /** - * J2EERemoveOverrideCommand constructor comment. - */ - protected J2EERemoveOverrideCommand() { - super(); - } - - public J2EERemoveOverrideCommand(RemoveCommand command) { - super(command); - } - - protected RemoveCommand createRemoveCommand(Collection elements) { - return (RemoveCommand) RemoveCommand.create(getDomain(), elements); - } - - /** - * This will perform the command activity required for the effect. The effect of calling execute - * when canExecute returns false, or when canExecute hasn't been called, is undefined. - */ - public void execute() { - /* - * For each object being removed, check if it has a binding, and an extension Make - * collections of these, make a command parameter for each collection, an instantiate a - * remove command - */ - - Collection objects = getRemoveCommand().getCollection(); - List bindings = new ArrayList(objects.size()); - List extensions = new ArrayList(objects.size()); - Iterator it = objects.iterator(); - while (it.hasNext()) { - EObject o = (EObject) it.next(); - if (resourceSet == null) - resourceSet = o.eResource().getResourceSet(); - // TODO make command adaptable - // EObject binding = BindingAndExtensionHelper.getBinding(o); - // if (binding != null) { - // bindings.add(binding); - // getJ2eeClipboard().addBinding(o, binding); - // } - // EObject extension = BindingAndExtensionHelper.getExtension(o); - // if (extension != null) { - // extensions.add(extension); - // getJ2eeClipboard().addExtension(o, extension); - // } - } - if (!bindings.isEmpty()) - setBindingsRemoveCommand(createRemoveCommand(bindings)); - - if (!extensions.isEmpty()) - setExtensionsRemoveCommand(createRemoveCommand(extensions)); - - executeAllChildren(); - } - - protected void executeAllChildren() { - executeNested(bindingsRemoveCommand); - executeNested(extensionsRemoveCommand); - getOverridable().doExecute(); - } - - protected void executeNested(RemoveCommand cmd) { - if (cmd != null && cmd.doCanExecute()) { - cmd.doExecute(); - // Collection result = cmd.getResult(); - //TODO - // BindingAndExtensionHelper.resolveAllProxies(result, resourceSet); - } - } - - /** - * Insert the method's description here. Creation date: (06/07/01 1:32:44 PM) - * - * @return RemoveCommand - */ - protected RemoveCommand getBindingsRemoveCommand() { - return bindingsRemoveCommand; - } - - /** - * Insert the method's description here. Creation date: (06/07/01 1:32:44 PM) - * - * @return RemoveCommand - */ - protected RemoveCommand getExtensionsRemoveCommand() { - return extensionsRemoveCommand; - } - - public RemoveCommand getRemoveCommand() { - return (RemoveCommand) getOverridable(); - } - - protected boolean prepare() { - setJ2eeClipboard(new J2EEClipboard(getRemoveCommand().getCollection())); - return true; - } - - /** - * This will again perform the command activity required to redo the effect after undoing the - * effect. The effect, if any, of calling redo before undo is called is undefined. Note that if - * you implement redo to call execute then any derived class will be restricted to by that - * decision also. - */ - public void redo() { - executeAllChildren(); - } - - /** - * Insert the method's description here. Creation date: (06/07/01 1:32:44 PM) - * - * @param newBindingsRemoveCommand - * RemoveCommand - */ - protected void setBindingsRemoveCommand(RemoveCommand newBindingsRemoveCommand) { - bindingsRemoveCommand = newBindingsRemoveCommand; - } - - /** - * Insert the method's description here. Creation date: (06/07/01 1:32:44 PM) - * - * @param newExtensionsRemoveCommand - * RemoveCommand - */ - protected void setExtensionsRemoveCommand(RemoveCommand newExtensionsRemoveCommand) { - extensionsRemoveCommand = newExtensionsRemoveCommand; - } - - public void undo() { - getRemoveCommand().doUndo(); - undoNested(bindingsRemoveCommand); - undoNested(extensionsRemoveCommand); - } - - protected void undoNested(RemoveCommand cmd) { - if (cmd != null && cmd.doCanUndo()) - cmd.doUndo(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEStrictCompoundCommand.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEStrictCompoundCommand.java deleted file mode 100644 index e0df82ab7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/command/J2EEStrictCompoundCommand.java +++ /dev/null @@ -1,99 +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.command; - -import org.eclipse.emf.common.command.StrictCompoundCommand; - - - -/** - * Overridden to provide an accessor to the pessimistic field. This is needed for the case of - * undo/redo paste. We need the nested copy commmand in the paste command to redo itself when the - * paste command is copied, otherwise we run into sed exception. - */ -public class J2EEStrictCompoundCommand extends StrictCompoundCommand { - /** - * J2EEStrictCompoundCommand constructor comment. - */ - public J2EEStrictCompoundCommand() { - super(); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - * - * @param label - * java.lang.String - */ - public J2EEStrictCompoundCommand(String label) { - super(label); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - */ - public J2EEStrictCompoundCommand(String label, String description) { - super(label, description); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param description - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EEStrictCompoundCommand(String label, String description, java.util.List commandList) { - super(label, description, commandList); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - * - * @param label - * java.lang.String - * @param commandList - * java.util.List - */ - public J2EEStrictCompoundCommand(String label, java.util.List commandList) { - super(label, commandList); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - * - * @param commandList - * java.util.List - */ - public J2EEStrictCompoundCommand(java.util.List commandList) { - super(commandList); - } - - /** - * J2EEStrictCompoundCommand constructor comment. - */ - public J2EEStrictCompoundCommand(boolean pessimistic) { - super(); - setIsPessismistic(pessimistic); - } - - public void setIsPessismistic(boolean aBool) { - isPessimistic = aBool; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java deleted file mode 100644 index ea7adc712..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseDeployableArtifactAdapterFactory.java +++ /dev/null @@ -1,38 +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 Jan 18, 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.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; - -public class EnterpriseDeployableArtifactAdapterFactory extends ModuleArtifactAdapterDelegate implements IAdapterFactory { - - public Object getAdapter(Object adaptableObject, Class adapterType) { - return null; - } - - public Class[] getAdapterList() { - return new Class[] {ILaunchable.class }; - } - - public IModuleArtifact getModuleArtifact(Object obj) { - return EnterpriseApplicationDeployableAdapterUtil.getModuleObject(obj); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java deleted file mode 100644 index b3cb39e4e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/EnterpriseModuleArtifact.java +++ /dev/null @@ -1,43 +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.deployables; - -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; - -/** - * @author blancett - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class EnterpriseModuleArtifact implements IModuleArtifact { - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.IModuleArtifact#getModule() - */ - public IModule getModule() { - // TODO Auto-generated method stub - return null; - } - - public Class[] getAdapterList() { - return new Class[] { IModuleArtifact.class, ILaunchable.class }; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java deleted file mode 100644 index 212774545..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableAdapterFactory.java +++ /dev/null @@ -1,50 +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.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.wst.server.core.IModuleArtifact; - - -public class J2EEDeployableAdapterFactory implements IAdapterFactory { - public Object getAdapter(Object adaptableObject, Class adapterType) { - IModuleArtifact moduleArtifact = null; -/* if (adapterType == IModuleArtifact.class ) { - - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.web.deployables.WebModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.web.deployables.WebModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.ejb.internal.deployables.IEJBModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.ejb.internal.deployables.IEJBModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.deployables.EnterpriseModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.jst.j2ee.internal.deployables.EnterpriseModuleArtifact"); - } - if (moduleArtifact == null && Platform.getAdapterManager().hasAdapter(adaptableObject, "org.eclipse.wst.web.internal.deployables.IStaticWebModuleArtifact")) { - moduleArtifact = (IModuleArtifact) Platform.getAdapterManager().loadAdapter(adaptableObject, "org.eclipse.wst.web.internal.deployables.IStaticWebModuleArtifact"); - } - }*/ - return moduleArtifact; - } - - public Class[] getAdapterList() { - return new Class[]{IModuleArtifact.class, ILaunchable.class}; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ChangeLibDirDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ChangeLibDirDialog.java deleted file mode 100644 index 0326fa4da..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ChangeLibDirDialog.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 SAP AG 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: - * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.dialogs; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.widgets.Shell; - -public class ChangeLibDirDialog extends InputDialog { - private boolean warnBlank; - - public ChangeLibDirDialog(Shell parentShell, String initialValue, boolean warnBlank) { - super(parentShell, J2EEUIMessages.getResourceString(J2EEUIMessages.CHANGE_LIB_DIR_HEAD), - J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_LIB_DIR_PROPMPT), initialValue, null); - this.warnBlank = warnBlank; - } - - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - String res = getText().getText().trim(); - if (res.length() == 0) { - if (warnBlank) - if (!MessageDialog.openQuestion(this.getShell(), - J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR), - J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR_CONFIRM))) return; - } else { - if (res.startsWith("" + IPath.SEPARATOR)); //$NON-NLS-1$ - res = res.substring(1); - String[] segments = res.split("" + IPath.SEPARATOR); //$NON-NLS-1$ - Path p = new Path(""); //$NON-NLS-1$ - boolean valid = true; - for (int i = 0; i < segments.length; i++) { - valid = p.isValidSegment(segments[i]); - if (!valid) - break; - } - if (!valid) { - MessageDialog.openError(null, - J2EEUIMessages.getResourceString(J2EEUIMessages.INVALID_PATH), - J2EEUIMessages.getResourceString(J2EEUIMessages.INVALID_PATH_MSG)); - return; - } - } - } - super.buttonPressed(buttonId); - } -} - diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARComposite.java deleted file mode 100644 index fa025152a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARComposite.java +++ /dev/null @@ -1,270 +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.dialogs; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.j2ee.internal.delete.DeleteOptions; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.model.WorkbenchLabelProvider; - - -public class DeleteEARComposite extends Composite implements J2EEDeleteUIConstants, Listener, ICheckStateListener { - - protected DeleteEARDialog dialog; - protected Button deleteAppProjectsBtn; - protected Button deleteRefProjectsBtn; - protected Composite radioComposite; - protected Button detailsBtn; - protected DeleteModuleReferencesComposite moduleRefsComposite; - protected CheckboxTableViewer projectsList; - protected boolean listCreated = false; - protected Map referencedProjects; - protected WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); - - /** - * Constructor for DeleteEARComposite. - * - * @param parent - * @param style - */ - public DeleteEARComposite(Composite parent, DeleteEARDialog dialog, int style, Set referencedProjects) { - super(parent, style); - this.dialog = dialog; - initReferencedProjects(referencedProjects); - addChildren(); - } - - /** - * Answer the referenced projects which the user has chosen to also delete - */ - public java.util.List getSelectedReferencedProjects() { - if (deleteAppProjectsBtn.getSelection()) - return Collections.EMPTY_LIST; - java.util.List result = new ArrayList(); - for (Iterator iter = referencedProjects.entrySet().iterator(); iter.hasNext();) { - Map.Entry element = (Map.Entry) iter.next(); - boolean isSelected = ((Boolean) element.getValue()).booleanValue(); - if (isSelected) - result.add(element.getKey()); - } - return result; - } - - /** - * @see J2EEDeleteDialog#createDeleteOptions() - */ - public DeleteOptions createDeleteOptions() { - DeleteOptions opts = new DeleteOptions(); - opts.setIsEARDelete(true); - opts.setDeleteProjects(true); - opts.setDeleteModuleDependencies(moduleRefsComposite.shouldDeleteModuleDependencies()); - opts.setDeleteModules(moduleRefsComposite.shouldDeleteModules()); - opts.setSelectedReferencedProjects(getSelectedReferencedProjects()); - return opts; - } - - - - protected void initReferencedProjects(Set projects) { - referencedProjects = new HashMap(); - for (Iterator iter = projects.iterator(); iter.hasNext();) { - IProject project = (IProject) iter.next(); - referencedProjects.put(project, Boolean.TRUE); - } - } - - protected void addChildren() { - setLayout(); - addRadioComposite(); - moduleRefsComposite = new DeleteModuleReferencesComposite(this, SWT.NONE, true); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalIndent = 10; - moduleRefsComposite.setLayoutData(data); - //setup defaults - deleteAppProjectsBtn.setSelection(true); - deleteAppProjectsBtnSelected(); - } - - protected void setLayout() { - GridLayout lay = new GridLayout(); - lay.numColumns = 1; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - } - - protected void addRadioComposite() { - radioComposite = new Composite(this, SWT.NONE); - GridLayout lay = new GridLayout(); - lay.numColumns = 2; - radioComposite.setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - radioComposite.setLayoutData(data); - deleteAppProjectsBtn = new Button(radioComposite, SWT.RADIO); - deleteAppProjectsBtn.setText(DELETE_EAR_PROJECTS); - deleteAppProjectsBtn.addListener(SWT.Selection, this); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - deleteAppProjectsBtn.setLayoutData(data); - - deleteRefProjectsBtn = new Button(radioComposite, SWT.RADIO); - deleteRefProjectsBtn.setText(DELETE_REFERENCED_PROJECTS); - deleteRefProjectsBtn.addListener(SWT.Selection, this); - deleteRefProjectsBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - detailsBtn = new Button(radioComposite, SWT.PUSH); - detailsBtn.setText(IDialogConstants.SHOW_DETAILS_LABEL); - detailsBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - detailsBtn.addListener(SWT.Selection, this); - detailsBtn.setEnabled(false); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == deleteAppProjectsBtn) - deleteAppProjectsBtnSelected(); - else if (event.widget == deleteRefProjectsBtn) - deleteRefProjectsBtnSelected(); - else if (event.widget == detailsBtn) - detailsBtnSelected(); - } - - protected void deleteAppProjectsBtnSelected() { - if (deleteAppProjectsBtn.getSelection()) { - if (listCreated) - toggleDetailsArea(); - detailsBtn.setEnabled(false); - moduleRefsComposite.setButtonsEnabled(false); - } - } - - protected void deleteRefProjectsBtnSelected() { - if (deleteRefProjectsBtn.getSelection()) { - detailsBtn.setEnabled(true); - moduleRefsComposite.setButtonsEnabled(true); - } - } - - /** - * Toggles the unfolding of the details area. This is triggered by the user pressing the details - * button. - */ - protected void toggleDetailsArea() { - Point windowSize = getShell().getSize(); - Point oldSize = dialog.getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - if (listCreated) { - projectsList.getControl().dispose(); - listCreated = false; - detailsBtn.setText(IDialogConstants.SHOW_DETAILS_LABEL); - } else { - createDropDownList(); - detailsBtn.setText(IDialogConstants.HIDE_DETAILS_LABEL); - } - - Point newSize = dialog.getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); - } - - protected void createDropDownList() { - // create the list - projectsList = CheckboxTableViewer.newCheckList(radioComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - projectsList.setLabelProvider(createLabelProvider()); - projectsList.setSorter(new ViewerSorter() {/*viewersorter*/}); - projectsList.addCheckStateListener(this); - // fill the list - populateList(); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); - data.heightHint = projectsList.getTable().getItemHeight() * referencedProjects.size(); - data.horizontalSpan = 2; - data.horizontalIndent = 10; - projectsList.getTable().setLayoutData(data); - - listCreated = true; - } - - protected void populateList() { - for (Iterator iter = referencedProjects.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - projectsList.add(entry.getKey()); - boolean checked = ((Boolean) entry.getValue()).booleanValue(); - projectsList.setChecked(entry.getKey(), checked); - } - } - - protected void detailsBtnSelected() { - toggleDetailsArea(); - } - - /** - * @see ICheckStateListener#checkStateChanged(CheckStateChangedEvent) - */ - public void checkStateChanged(CheckStateChangedEvent event) { - referencedProjects.put(event.getElement(), new Boolean(event.getChecked())); - } - - protected ITableLabelProvider createLabelProvider() { - return new ITableLabelProvider() { - public void dispose() { - //dispose - } - - public Image getColumnImage(Object element, int columnIndex) { - return workbenchLabelProvider.getImage(element); - } - - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - return workbenchLabelProvider.getText(element); - } - - public void addListener(ILabelProviderListener listener) { - //do nothing - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - //do nothing - } - }; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARDialog.java deleted file mode 100644 index 48f41f5e1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteEARDialog.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.dialogs; - - -import java.util.Set; - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -public class DeleteEARDialog extends J2EEDeleteDialog { - protected DeleteEARComposite deleteComposite; - protected Set referencedProjects; - - /** - * Constructor for DeleteEARDialog. - * - * @param parentShell - * @param dialogTitle - */ - public DeleteEARDialog(Shell parentShell, Set referencedProjects) { - super(parentShell, DELETE_EAR_OPTIONS); - this.referencedProjects = referencedProjects; - } - - - /** - * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(Composite) - */ - protected Control createCustomArea(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.DELEATE_EAR_DIALOG_1); //$NON-NLS-1$ - deleteComposite = new DeleteEARComposite(parent, this, SWT.NONE, referencedProjects); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalIndent = 10; - deleteComposite.setLayoutData(data); - return deleteComposite; - } - - /** - * @see J2EEDeleteDialog#createDeleteOptions() - */ - public void createDeleteOptions() { - deleteOptions = deleteComposite.createDeleteOptions(); - } - - /** - * @see org.eclipse.jface.window.Window#getContents() - */ - public Control getContents() { - return super.getContents(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleComposite.java deleted file mode 100644 index ceda40a34..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleComposite.java +++ /dev/null @@ -1,127 +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.dialogs; - - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; - -public class DeleteModuleComposite extends Composite implements J2EEDeleteUIConstants, Listener { - - // protected Button deleteProjectsCheckBox; - protected Button deleteAppProjectsBtn; - protected Button deleteRefProjectsBtn; - protected Composite radioComposite; - protected DeleteModuleReferencesComposite moduleRefsComposite; - - - /** - * Constructor for DeleteModuleComposite. - * - * @param parent - * @param style - */ - public DeleteModuleComposite(Composite parent, int style) { - super(parent, style); - addChildren(); - - } - - protected void addChildren() { - addDeleteProjectsGroup(); - addDeleteModuleRefsComposite(); - //set default values - deleteAppProjectsBtn.setSelection(true); - deleteAppProjectsBtnSelected(); - } - - protected void addDeleteProjectsGroup() { - GridLayout lay = new GridLayout(); - lay.numColumns = 1; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - - radioComposite = new Composite(this, SWT.NONE); - lay = new GridLayout(); - lay.numColumns = 2; - radioComposite.setLayout(lay); - data = new GridData(GridData.FILL_BOTH); - radioComposite.setLayoutData(data); - deleteAppProjectsBtn = new Button(radioComposite, SWT.RADIO); - deleteAppProjectsBtn.setText(DELETE_PROJECTS_ONLY); - deleteAppProjectsBtn.addListener(SWT.Selection, this); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - deleteAppProjectsBtn.setLayoutData(data); - - deleteRefProjectsBtn = new Button(radioComposite, SWT.RADIO); - deleteRefProjectsBtn.setText(DELETE_PROJECT_REFERENCES); - deleteRefProjectsBtn.addListener(SWT.Selection, this); - deleteRefProjectsBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - } - - protected void addDeleteModuleRefsComposite() { - moduleRefsComposite = new DeleteModuleReferencesComposite(this, SWT.NONE, false); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalIndent = 10; - moduleRefsComposite.setLayoutData(data); - } - - - protected void addSeparator() { - Label sep = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - sep.setLayoutData(data); - } - - public boolean shouldDeleteProjects() { - // return deleteProjectsCheckBox.getSelection(); - // the project should be deleted, since delete was the selected action - return true; - } - - - public boolean shouldDeleteModuleDependencies() { - return moduleRefsComposite.shouldDeleteModuleDependencies(); - } - - public boolean shouldDeleteModules() { - return moduleRefsComposite.shouldDeleteModules(); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == deleteAppProjectsBtn) - deleteAppProjectsBtnSelected(); - else if (event.widget == deleteRefProjectsBtn) - deleteRefProjectsBtnSelected(); - } - - protected void deleteAppProjectsBtnSelected() { - if (deleteAppProjectsBtn.getSelection()) { - moduleRefsComposite.setButtonsEnabled(false); - } - } - - protected void deleteRefProjectsBtnSelected() { - if (deleteRefProjectsBtn.getSelection()) { - moduleRefsComposite.setButtonsEnabled(true); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleDialog.java deleted file mode 100644 index cfb80fe79..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleDialog.java +++ /dev/null @@ -1,50 +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.dialogs; - - - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.delete.DeleteOptions; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - - -public class DeleteModuleDialog extends J2EEDeleteDialog implements J2EEDeleteUIConstants { - - protected DeleteModuleComposite deleteComposite; - - public DeleteModuleDialog(Shell parentShell) { - super(parentShell, DELETE_MODULE_OPTIONS); - } - - protected Control createCustomArea(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.DELEATE_MODULE_DIALOG_1); //$NON-NLS-1$ - deleteComposite = new DeleteModuleComposite(parent, SWT.NONE); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalIndent = 10; - deleteComposite.setLayoutData(data); - return deleteComposite; - } - - public void createDeleteOptions() { - deleteOptions = new DeleteOptions(); - deleteOptions.setDeleteProjects(deleteComposite.shouldDeleteProjects()); - deleteOptions.setDeleteModules(deleteComposite.shouldDeleteModules()); - deleteOptions.setDeleteModuleDependencies(deleteComposite.shouldDeleteModuleDependencies()); - } - -} - diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleReferencesComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleReferencesComposite.java deleted file mode 100644 index 393189d18..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DeleteModuleReferencesComposite.java +++ /dev/null @@ -1,85 +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.dialogs; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -public class DeleteModuleReferencesComposite extends Composite implements J2EEDeleteUIConstants, Listener { - - protected Button deleteModulesCheckbox; - protected Button deleteModuleDependenciesCheckbox; - protected boolean isEARDelete; - - /** - * Constructor for DeleteModuleReferencesComposite. - * - * @param parent - * @param style - */ - public DeleteModuleReferencesComposite(Composite parent, int style, boolean isEARDelete) { - super(parent, style); - this.isEARDelete = isEARDelete; - addChildren(); - } - - protected void addChildren() { - GridLayout lay = new GridLayout(); - lay.numColumns = 1; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - - addDeleteModulesCheckbox(); - addDeleteModuleDependenciesCheckbox(); - } - - protected void addDeleteModuleDependenciesCheckbox() { - deleteModuleDependenciesCheckbox = new Button(this, SWT.CHECK); - deleteModuleDependenciesCheckbox.setText(DELETE_MODULE_DEPENDENCIES); - - } - - protected void addDeleteModulesCheckbox() { - deleteModulesCheckbox = new Button(this, SWT.CHECK); - String label = isEARDelete ? DELETE_MODULES_OTHER : DELETE_MODULES; - deleteModulesCheckbox.setText(label); - deleteModulesCheckbox.addListener(SWT.Selection, this); - } - - public boolean shouldDeleteModuleDependencies() { - return deleteModuleDependenciesCheckbox.getSelection(); - } - - public boolean shouldDeleteModules() { - return deleteModulesCheckbox.getSelection(); - } - - public void setButtonsEnabled(boolean enabled) { - deleteModuleDependenciesCheckbox.setSelection(enabled); - deleteModulesCheckbox.setSelection(enabled); - deleteModuleDependenciesCheckbox.setEnabled(enabled); - deleteModulesCheckbox.setEnabled(enabled); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == deleteModulesCheckbox && deleteModulesCheckbox.getSelection() && !deleteModuleDependenciesCheckbox.getSelection()) - deleteModuleDependenciesCheckbox.setSelection(true); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DependencyConflictResolveDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DependencyConflictResolveDialog.java deleted file mode 100644 index 1e90841b3..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/DependencyConflictResolveDialog.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 SAP AG 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: - * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.dialogs; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.widgets.Shell; - -public class DependencyConflictResolveDialog extends MessageDialogWithToggle { - - public static final int BTN_ID_OK = 0; - public static final int BTN_ID_CANCEL = 1; - - public static final int DLG_TYPE_1 = 1; - public static final int DLG_TYPE_2 = 2; - - public static final String DONT_SHOW_AGAIN = "DependencyConflictResolveDialog.DONT_SHOW_AGAIN"; //$NON-NLS-1$ - - public DependencyConflictResolveDialog(Shell parentShell, - int dlgType) { - - super(parentShell, - J2EEUIMessages.getResourceString(J2EEUIMessages.DEPENDENCY_CONFLICT_TITLE), - null, - J2EEUIMessages.getResourceString((dlgType == DLG_TYPE_1) ? - J2EEUIMessages.DEPENDENCY_CONFLICT_MSG_1 : - J2EEUIMessages.DEPENDENCY_CONFLICT_MSG_2) - - , MessageDialog.WARNING, - - new String[] { J2EEUIMessages.OK_BUTTON, - J2EEUIMessages.CANCEL_BUTTON }, - BTN_ID_CANCEL, - J2EEUIMessages.getResourceString(J2EEUIMessages.DO_NOT_SHOW_WARNING_AGAIN), - false); - } - - public int open() { - if (getPrefStore().getBoolean(DONT_SHOW_AGAIN)) - return BTN_ID_OK; - setToggleState(getPrefStore().getBoolean(DONT_SHOW_AGAIN)); - return super.open(); - } - - public boolean close() { - getPrefStore().setValue(DONT_SHOW_AGAIN, getToggleState()); - return super.close(); - } - - public IPreferenceStore getPrefStore() { - return J2EEUIPlugin.getDefault().getPreferenceStore(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/FilteredFileSelectionDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/FilteredFileSelectionDialog.java deleted file mode 100644 index 5442f2c17..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/FilteredFileSelectionDialog.java +++ /dev/null @@ -1,75 +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.dialogs; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -public class FilteredFileSelectionDialog extends ElementTreeSelectionDialog { - protected String[] fExtensions; - /** - * FilteredFileSelectionDialog constructor comment. - * - * @param parent - * Shell - * @parent extensions String[] - */ - public FilteredFileSelectionDialog(Shell parent, String[] extensions) { - this(parent, null, null, extensions, false); - } - /** - * FilteredFileSelectionDialog constructor comment. - * - * @param parent - * Shell - * @param title - * String - * @param message - * String - * @parent extensions String[] - * @param allowMultiple - * boolean - */ - public FilteredFileSelectionDialog(Shell parent, String title, String message, String[] extensions, boolean allowMultiple) { - super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); - - setTitle(title); - if (title == null) - setTitle(J2EEUIMessages.getResourceString("File_Selection_UI_")); //$NON-NLS-1$ - if (message == null) - message = J2EEUIMessages.getResourceString("Select_a_file__UI_"); //$NON-NLS-1$ - setMessage(message); - setAllowMultiple(true); - setExtensions(extensions); - addFilter(new TypedFileViewerFilter(extensions)); - setValidator(new TypedElementSelectionValidator(new Class[]{IFile.class}, allowMultiple)); - - } - public String[] getExtensions() { - return fExtensions; - } - public void setExtensions(String[] extensions) { - fExtensions = extensions; - } - - public void setHelp(String helpCode) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(this.getParentShell(), helpCode); //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteDialog.java deleted file mode 100644 index be97f20db..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteDialog.java +++ /dev/null @@ -1,50 +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.dialogs; - - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.delete.DeleteOptions; -import org.eclipse.swt.widgets.Shell; - - -public abstract class J2EEDeleteDialog extends MessageDialog implements J2EEDeleteUIConstants { - - protected DeleteOptions deleteOptions; - - /** - * Constructor for J2EEDeleteDialog. - * - * @param parentShell - * @param dialogTitle - * @param dialogTitleImage - * @param dialogMessage - * @param dialogImageType - * @param dialogButtonLabels - * @param defaultIndex - */ - public J2EEDeleteDialog(Shell parentShell, String dialogTitle) { - super(parentShell, dialogTitle, null, DELETE_DIALOG_MESSAGE, QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0); - } - - public DeleteOptions getDeleteOptions() { - return deleteOptions; - } - - - public abstract void createDeleteOptions(); - - protected void buttonPressed(int buttonId) { - if (buttonId == 0) - createDeleteOptions(); - super.buttonPressed(buttonId); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteUIConstants.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteUIConstants.java deleted file mode 100644 index 2ae744b61..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeleteUIConstants.java +++ /dev/null @@ -1,29 +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.dialogs; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -public interface J2EEDeleteUIConstants { - String DELETE = J2EEUIMessages.getResourceString("Delete_1"); //$NON-NLS-1$ - String DELETE_PROJECTS = J2EEUIMessages.getResourceString("Delete_selected_project(s)_2"); //$NON-NLS-1$ - String DELETE_MODULES = J2EEUIMessages.getResourceString("Remove_module(s)_from_all_Enterprise_Applications_3"); //$NON-NLS-1$ - String DELETE_MODULES_OTHER = J2EEUIMessages.getResourceString("Remove_module(s)_from_all_other_Enterprise_Applications_4"); //$NON-NLS-1$ - String DELETE_MODULE_DEPENDENCIES = J2EEUIMessages.getResourceString("Remove_module_dependencies_referencing_selected_project(s)_5"); //$NON-NLS-1$ - String DELETE_MODULE_OPTIONS = J2EEUIMessages.getResourceString("Delete_Module_Options_6"); //$NON-NLS-1$ - String DELETE_EAR_OPTIONS = J2EEUIMessages.getResourceString("Delete_Enterprise_Application_Options_7"); //$NON-NLS-1$ - String DELETE_NOT_COMPLETED = J2EEUIMessages.getResourceString("Delete_could_not_be_completed_8"); //$NON-NLS-1$ - String DELETE_ERROR = J2EEUIMessages.getResourceString("Delete_error_9"); //$NON-NLS-1$ - String DELETE_DIALOG_MESSAGE = J2EEUIMessages.getResourceString("What_would_you_like_to_delete__10"); //$NON-NLS-1$ - String DELETE_EAR_PROJECTS = J2EEUIMessages.getResourceString("Delete_selected_Enterprise_Application_project(s)_only_11"); //$NON-NLS-1$ - String DELETE_REFERENCED_PROJECTS = J2EEUIMessages.getResourceString("Also_delete_module_and_utility_Java_projects_12"); //$NON-NLS-1$ - String DELETE_PROJECTS_ONLY = J2EEUIMessages.getResourceString("Delete_selected_project(s)_only_13"); //$NON-NLS-1$ - String DELETE_PROJECT_REFERENCES = J2EEUIMessages.getResourceString("Also_delete_references_to_selected_project(s)_14"); //$NON-NLS-1$ - String CUSTOM_DELETE_MIX_MATCH = J2EEUIMessages.getResourceString("CUSTOM_DELETE_MIX_MATCH_UI_"); //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployStatusDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployStatusDialog.java deleted file mode 100644 index 9e29ba990..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployStatusDialog.java +++ /dev/null @@ -1,334 +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 May 11, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.dialogs; - - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * @author sagarwal - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Generation - Code and Comments - */ -public class J2EEDeployStatusDialog extends ProgressMonitorDialog implements J2EEDeployUIConstants { - - /** - * Reserve room for this many list items. - */ - private static final int LIST_ITEM_COUNT = 7; - private int severity = IStatus.OK; - public Color DESC_COLOR = new Color(null, 255, 255, 255); - /** - * The Details button. - */ - private Button detailsButton; - - /** - * The SWT list control that displays the error details. - */ - private Text text; - - /** - * Indicates whether the error details viewer is currently created. - */ - private boolean textCreated = false; - - /** - * List of the main error object's detailed errors (element type: - * <code>J2EEMigrationStatus</code>). - */ - private java.util.List statusList; - - /** - * @param parent - */ - public J2EEDeployStatusDialog(Shell parent, List status) { - super(parent); - setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL | SWT.RESIZE); // no - statusList = status; - } - - /** - * Called just after the operation is run. Default behaviour is to decrement the nesting depth, - * and close the dialog. - * - * @plannedfor 3.0 - */ - protected void finishedRun() { - decrementNestingDepth(); - clearCursors(); - cancel.setEnabled(true); - detailsButton.setEnabled(true); - computeSeverity(); - setDeploymentStatus(); - } - - /** - * - */ - private void setDeploymentStatus() { - setMessageOrDefault(); - imageLabel.setImage(getImage()); - } - - protected void setMessageOrDefault() { - switch (getSeverity()) { - case IStatus.ERROR : - message = DEPLOY_ERRORS_REPORT; - break; - case IStatus.WARNING : - message = DEPLOY_WARNINGS_REPORT; - break; - default : - message = DEPLOY_SUCCESS_REPORT; - break; - } - setMessage(message); - } - - - protected void createCancelButton(Composite parent) { - super.createCancelButton(parent); - cancel.setText(IDialogConstants.OK_LABEL); - } - - /* - * (non-Javadoc) Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - // cancel button - createCancelButton(parent); - detailsButton = createButton(parent, IDialogConstants.DETAILS_ID, IDialogConstants.SHOW_DETAILS_LABEL, false); - detailsButton.setEnabled(false); - } - - /* - * (non-Javadoc) Method declared on Dialog. Handles the pressing of the Ok or Details button in - * this dialog. If the Ok button was pressed then close this dialog. If the Details button was - * pressed then toggle the displaying of the error details area. Note that the Details button - * will only be visible if the error being displayed specifies child details. - */ - protected void buttonPressed(int id) { - if (id == IDialogConstants.DETAILS_ID) { // was the details button pressed? - toggleDetailsArea(); - } else { - logStatus(); - super.buttonPressed(id); - - } - } - - /* - * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage() - */ - - - protected Image getImage() { - switch (getSeverity()) { - case IStatus.ERROR : - return this.getErrorImage(); - case IStatus.WARNING : - return this.getWarningImage(); - default : - return this.getInfoImage(); - } - } - - protected Text createDropDownText(Composite parent) { - // create the list - text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); - // fill the list - populateText(text); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); - data.horizontalSpan = 2; - data.heightHint = text.getLineHeight() * LIST_ITEM_COUNT; - text.setLayoutData(data); - textCreated = true; - return text; - } - - private void logStatus() { - Iterator aenum = statusList.iterator(); - StringBuffer sb = new StringBuffer(); - sb.append(message); - while (aenum.hasNext()) { - IStatus childStatus = (IStatus) aenum.next(); - populateText(sb, childStatus, 0); - } - Logger.getLogger().logInfo(sb.toString()); - - } - - /** - * Populates the list using this error dialog's status object. This walks the child stati of the - * status object and displays them in a list. The format for each entry is status_path : - * status_message If the status's path was null then it (and the colon) are omitted. - */ - private void populateText(Text someText) { - Iterator aenum = statusList.iterator(); - StringBuffer sb = new StringBuffer(); - while (aenum.hasNext()) { - IStatus childStatus = (IStatus) aenum.next(); - //sb.append("Deployment results for " + childStatus.); - populateText(sb, childStatus, 0); - } - someText.setText(sb.toString()); - - } - - private void populateText(StringBuffer sb, IStatus status, int nesting) { - for (int i = 0; i < nesting; i++) { - sb.append(" "); //$NON-NLS-1$ - } - sb.append(getMessageForDisplay(status)); - sb.append('\n'); - IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { - populateText(sb, children[i], nesting + 1); - } - } - - /** - * Toggles the unfolding of the details area. This is triggered by the user pressing the details - * button. - */ - private void toggleDetailsArea() { - Point windowSize = getShell().getSize(); - Point oldSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - if (textCreated) { - text.dispose(); - textCreated = false; - detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL); - } else { - text = createDropDownText((Composite) getContents()); - detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL); - text.setEditable(false); - text.setBackground(DESC_COLOR); - } - - Point newSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); - } - - public String getMessageForDisplay(IStatus status) { - String messageString = status.getMessage(); - return messageString; - - } - - protected String getSeverityText(IStatus status) { - switch (status.getSeverity()) { - case IStatus.ERROR : - return ERROR_TEXT; - case IStatus.WARNING : - return WARNING_TEXT; - case IStatus.INFO : - return INFO_TEXT; - case IStatus.OK : - return OK_TEXT; - default : - return ""; //$NON-NLS-1$ - } - } - - private void setSeverity(int sev) { - if (severity == IStatus.ERROR) - return; - if (sev == IStatus.ERROR) - severity = IStatus.ERROR; - else if (sev == IStatus.WARNING) { - severity = IStatus.WARNING; - } - } - - private int getSeverity() { - return severity; - } - - private int computeSeverity() { - Iterator aenum = statusList.iterator(); - while (aenum.hasNext()) { - IStatus childStatus = (IStatus) aenum.next(); - setSeverity(childStatus.getSeverity()); - if (getSeverity() == IStatus.ERROR) - return getSeverity(); - computeSeverity(childStatus); - if (getSeverity() == IStatus.ERROR) - getSeverity(); - } - return getSeverity(); - } - - private void computeSeverity(IStatus status) { - IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { - computeSeverity(children[i]); - if (getSeverity() == IStatus.ERROR) - return; - } - } - - /* - * (non-Javadoc) Method declared in Window. - */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(DEPLOY_DIALOG_TITLE); - //shell.setSize(600,200); don't set the size this breaks the dialog for linux. - } - - /* - * (non-Javadoc) Method declared on Dialog. - */ - protected Control createDialogArea(Composite parent) { - Control control = super.createDialogArea(parent); - setMessage(DEPLOYMENT_IN_PROGRESS); - return control; - } - - /** - * Set the message in the message label. - */ - private void setMessage(String messageString) { - //must not set null text in a label - message = messageString == null ? "" : messageString; //$NON-NLS-1$ - if (messageLabel == null || messageLabel.isDisposed()) - return; - messageLabel.setText(message); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployUIConstants.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployUIConstants.java deleted file mode 100644 index dfe358952..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EEDeployUIConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.dialogs; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -public interface J2EEDeployUIConstants { - public static final String ERROR_TEXT = J2EEUIMessages.getResourceString("DEPLOY_ERROR_TEXT"); //$NON-NLS-1$ - public static final String WARNING_TEXT = J2EEUIMessages.getResourceString("DEPLOY_WARNING_TEXT"); //$NON-NLS-1$ - public static final String INFO_TEXT = J2EEUIMessages.getResourceString("DEPLOY_INFO_TEXT"); //$NON-NLS-1$ - public static final String OK_TEXT = J2EEUIMessages.getResourceString("DEPLOY_OK_TEXT"); //$NON-NLS-1$ - public static final String DEPLOYMENT_IN_PROGRESS = J2EEUIMessages.getResourceString("DEPLOYMENT_IN_PROGRESS"); //$NON-NLS-1$ - public static final String DEPLOY_SUCCESS_REPORT = J2EEUIMessages.getResourceString("DEPLOY_SUCCESS_REPORT"); //$NON-NLS-1$ - public static final String DEPLOY_WARNINGS_REPORT = J2EEUIMessages.getResourceString("DEPLOY_WARNINGS_REPORT"); //$NON-NLS-1$ - public static final String DEPLOY_ERRORS_REPORT = J2EEUIMessages.getResourceString("DEPLOY_ERRORS_REPORT"); //$NON-NLS-1$ - public static final String DEPLOY_DIALOG_TITLE = J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"); //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameDialog.java deleted file mode 100644 index 6dcbf118d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameDialog.java +++ /dev/null @@ -1,51 +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.dialogs; - - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.swt.widgets.Shell; - - -public abstract class J2EERenameDialog extends MessageDialog implements J2EERenameUIConstants { - - protected RenameOptions renameOptions; - protected String currentName = null; - - /** - * Constructor for J2EERenameDialog. - * - * @param parentShell - * @param dialogTitle - * @param dialogTitleImage - * @param dialogMessage - * @param dialogImageType - * @param dialogButtonLabels - * @param defaultIndex - */ - public J2EERenameDialog(Shell parentShell, String dialogTitle, String name) { - super(parentShell, dialogTitle, null, RENAME_DIALOG_MESSAGE, QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0); - currentName = name; - } - - public RenameOptions getRenameOptions() { - return renameOptions; - } - - - public abstract void createRenameOptions(); - - protected void buttonPressed(int buttonId) { - if (buttonId == 0) - createRenameOptions(); - super.buttonPressed(buttonId); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameUIConstants.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameUIConstants.java deleted file mode 100644 index baa574d2a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/J2EERenameUIConstants.java +++ /dev/null @@ -1,27 +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.dialogs; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -public interface J2EERenameUIConstants { - String RENAME = J2EEUIMessages.getResourceString("Rename_1"); //$NON-NLS-1$ - String RENAME_PROJECTS = J2EEUIMessages.getResourceString("Rename_selected_project_2"); //$NON-NLS-1$ - String RENAME_MODULES = J2EEUIMessages.getResourceString("Rename_module_in_all_Enterprise_Applications_3"); //$NON-NLS-1$ - String RENAME_MODULES_OTHER = J2EEUIMessages.getResourceString("Rename_module_in_all_other_Enterprise_Applications_4"); //$NON-NLS-1$ - String RENAME_MODULE_DEPENDENCIES = J2EEUIMessages.getResourceString("Rename_module_dependencies_referencing_selected_project_5"); //$NON-NLS-1$ - String RENAME_MODULE_OPTIONS = J2EEUIMessages.getResourceString("Rename_Module_Options_6"); //$NON-NLS-1$ - String RENAME_EAR_OPTIONS = J2EEUIMessages.getResourceString("Rename_Enterprise_Application_Options_7"); //$NON-NLS-1$ - String RENAME_NOT_COMPLETED = J2EEUIMessages.getResourceString("Rename_could_not_be_completed_8"); //$NON-NLS-1$ - String RENAME_ERROR = J2EEUIMessages.getResourceString("Rename_error_9"); //$NON-NLS-1$ - String RENAME_DIALOG_MESSAGE = J2EEUIMessages.getResourceString("What_would_you_like_to_rename_this_to__10"); //$NON-NLS-1$ - String RENAME_CONTEXT_ROOT = J2EEUIMessages.getResourceString("Context_Root__11"); //$NON-NLS-1$ - String RENAME_EAR_PROJECTS = J2EEUIMessages.getResourceString("Rename_selected_Enterprise_Application_project_only_12"); //$NON-NLS-1$ - String RENAME_REFERENCED_PROJECTS = J2EEUIMessages.getResourceString("Also_rename_module_and_utility_Java_projects_13"); //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ListMessageDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ListMessageDialog.java deleted file mode 100644 index 8808b1db2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/ListMessageDialog.java +++ /dev/null @@ -1,211 +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.dialogs; - - - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Shell; - -/** - * Insert the type's description here. Creation date: (9/7/2001 11:28:24 AM) - * - * @author: Administrator - */ -public class ListMessageDialog extends org.eclipse.jface.dialogs.MessageDialog { - protected String[] listItems; - protected List list; - - /** - * EJBSelectiveImportDialog constructor comment. - * - * @param parentShell - * org.eclipse.swt.widgets.Shell - * @param dialogTitle - * java.lang.String - * @param dialogTitleImage - * org.eclipse.swt.graphics.Image - * @param dialogMessage - * java.lang.String - * @param dialogImageType - * int - * @param dialogButtonLabels - * java.lang.String[] - * @param defaultIndex - * int - */ - public ListMessageDialog(org.eclipse.swt.widgets.Shell parentShell, String dialogTitle, org.eclipse.swt.graphics.Image dialogTitleImage, String dialogMessage, int dialogImageType, java.lang.String[] dialogButtonLabels, int defaultIndex) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); - } - - /** - * ListMessageDialog constructor comment. - * - * @param parentShell - * org.eclipse.swt.widgets.Shell - * @param dialogTitle - * java.lang.String - * @param dialogTitleImage - * org.eclipse.swt.graphics.Image - * @param dialogMessage - * java.lang.String - * @param dialogImageType - * int - * @param dialogButtonLabels - * java.lang.String[] - * @param defaultIndex - * int - */ - public ListMessageDialog(org.eclipse.swt.widgets.Shell parentShell, String dialogTitle, org.eclipse.swt.graphics.Image dialogTitleImage, String dialogMessage, int dialogImageType, java.lang.String[] dialogButtonLabels, int defaultIndex, String[] names) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); - listItems = names; - } - - /** - * Creates and returns the contents of an area of the dialog which appears below the message and - * above the button bar. - * <p> - * The default implementation of this framework method returns <code>null</code>. Subclasses - * may override. - * </p> - * - * @param the - * parent composite to contain the custom area - * @return the custom area control, or <code>null</code> - */ - protected Control createCustomArea(Composite parent) { - - Composite composite = new Composite(parent, 0); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - if (listItems != null) { - list = new List(composite, SWT.BORDER); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - list.setLayoutData(data); - list.setItems(listItems); - } - - return composite; - - } - - /** - * Convenience method to open a simple confirm (OK/Cancel) dialog. - * - * @param parent - * the parent shell of the dialog, or <code>null</code> if none - * @param title - * the dialog's title, or <code>null</code> if none - * @param message - * the message - * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise - */ - public static boolean openConfirm(Shell parent, String title, String message, String[] items) { - ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default - // window icon - message, QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0, items); // OK - // is - // the - // default - return dialog.open() == 0; - } - - /** - * Convenience method to open a standard error dialog. - * - * @param parent - * the parent shell of the dialog, or <code>null</code> if none - * @param title - * the dialog's title, or <code>null</code> if none - * @param message - * the message - */ - public static void openError(Shell parent, String title, String message, String[] items) { - ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default - // window icon - message, ERROR, new String[]{IDialogConstants.OK_LABEL}, 0, items); // ok is the - // default - dialog.open(); - return; - } - - /** - * Convenience method to open a standard information dialog. - * - * @param parent - * the parent shell of the dialog, or <code>null</code> if none - * @param title - * the dialog's title, or <code>null</code> if none - * @param message - * the message - */ - public static void openInformation(Shell parent, String title, String message, String[] items) { - ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default - // window icon - message, INFORMATION, new String[]{IDialogConstants.OK_LABEL}, 0, items); - // ok is the default - dialog.open(); - return; - } - - /** - * Convenience method to open a simple Yes/No question dialog. - * - * @param parent - * the parent shell of the dialog, or <code>null</code> if none - * @param title - * the dialog's title, or <code>null</code> if none - * @param message - * the message - * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise - */ - public static boolean openQuestion(Shell parent, String title, String message, String[] items) { - ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default - // window icon - message, QUESTION, new String[]{IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0, items); // yes - // is - // the - // default - return dialog.open() == 0; - } - - /** - * Convenience method to open a standard warning dialog. - * - * @param parent - * the parent shell of the dialog, or <code>null</code> if none - * @param title - * the dialog's title, or <code>null</code> if none - * @param message - * the message - */ - public static void openWarning(Shell parent, String title, String message, String[] items) { - ListMessageDialog dialog = new ListMessageDialog(parent, title, null, // accept the default - // window icon - message, WARNING, new String[]{IDialogConstants.OK_LABEL}, 0, items); // ok is - // the - // default - dialog.open(); - return; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARComposite.java deleted file mode 100644 index c74e3b81d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARComposite.java +++ /dev/null @@ -1,265 +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.dialogs; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.model.WorkbenchLabelProvider; - - -public class RenameEARComposite extends Composite implements J2EERenameUIConstants, Listener, ICheckStateListener { - - protected Button renameAppProjectsBtn; - protected Button renameRefProjectsBtn; - protected Composite radioComposite; - protected Button detailsBtn; - protected RenameModuleReferencesComposite moduleRefsComposite; - protected CheckboxTableViewer projectsList; - protected boolean listCreated = false; - protected Map referencedProjects; - protected WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); - - /** - * Constructor for RenameEARComposite. - * - * @param parent - * @param style - */ - public RenameEARComposite(Composite parent, int style, Set referencedProjects) { - super(parent, style); - initReferencedProjects(referencedProjects); - addChildren(); - } - - /** - * Answer the referenced projects which the user has chosen to also rename - */ - public java.util.List getSelectedReferencedProjects() { - if (renameAppProjectsBtn.getSelection()) - return Collections.EMPTY_LIST; - java.util.List result = new ArrayList(); - for (Iterator iter = referencedProjects.entrySet().iterator(); iter.hasNext();) { - Map.Entry element = (Map.Entry) iter.next(); - boolean isSelected = ((Boolean) element.getValue()).booleanValue(); - if (isSelected) - result.add(element.getKey()); - } - return result; - } - - /** - * @see J2EERenameDialog#createRenameOptions() - */ - public RenameOptions createRenameOptions() { - RenameOptions opts = new RenameOptions(); - opts.setIsEARRename(true); - opts.setRenameProjects(true); - opts.setRenameModuleDependencies(moduleRefsComposite.shouldRenameModuleDependencies()); - opts.setRenameModules(moduleRefsComposite.shouldRenameModules()); - opts.setSelectedReferencedProjects(getSelectedReferencedProjects()); - return opts; - } - - - - protected void initReferencedProjects(Set projects) { - referencedProjects = new HashMap(); - for (Iterator iter = projects.iterator(); iter.hasNext();) { - IProject project = (IProject) iter.next(); - referencedProjects.put(project, Boolean.TRUE); - } - } - - protected void addChildren() { - setLayout(); - addRadioComposite(); - moduleRefsComposite = new RenameModuleReferencesComposite(this, SWT.NONE, true); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalIndent = 10; - moduleRefsComposite.setLayoutData(data); - } - - protected void setLayout() { - GridLayout lay = new GridLayout(); - lay.numColumns = 1; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - } - - protected void addRadioComposite() { - radioComposite = new Composite(this, SWT.NONE); - GridLayout lay = new GridLayout(); - lay.numColumns = 2; - radioComposite.setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - radioComposite.setLayoutData(data); - renameAppProjectsBtn = new Button(radioComposite, SWT.RADIO); - renameAppProjectsBtn.setText(RENAME_EAR_PROJECTS); - renameAppProjectsBtn.addListener(SWT.Selection, this); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - renameAppProjectsBtn.setLayoutData(data); - - renameRefProjectsBtn = new Button(radioComposite, SWT.RADIO); - renameRefProjectsBtn.setText(RENAME_REFERENCED_PROJECTS); - renameRefProjectsBtn.addListener(SWT.Selection, this); - renameRefProjectsBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - detailsBtn = new Button(radioComposite, SWT.PUSH); - detailsBtn.setText(IDialogConstants.SHOW_DETAILS_LABEL); - detailsBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - detailsBtn.addListener(SWT.Selection, this); - detailsBtn.setEnabled(false); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == renameAppProjectsBtn) - renameAppProjectsBtnSelected(); - else if (event.widget == renameRefProjectsBtn) - renameRefProjectsBtnSelected(); - else if (event.widget == detailsBtn) - detailsBtnSelected(); - } - - protected void renameAppProjectsBtnSelected() { - if (renameAppProjectsBtn.getSelection()) { - if (listCreated) - toggleDetailsArea(); - detailsBtn.setEnabled(false); - moduleRefsComposite.setButtonsEnabled(false); - } - } - - protected void renameRefProjectsBtnSelected() { - if (renameRefProjectsBtn.getSelection()) { - detailsBtn.setEnabled(true); - moduleRefsComposite.setButtonsEnabled(true); - } - } - - /** - * Toggles the unfolding of the details area. This is triggered by the user pressing the details - * button. - */ - protected void toggleDetailsArea() { - Point windowSize = getShell().getSize(); - Point oldSize = getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - if (listCreated) { - projectsList.getControl().dispose(); - listCreated = false; - detailsBtn.setText(IDialogConstants.SHOW_DETAILS_LABEL); - } else { - createDropDownList(); - detailsBtn.setText(IDialogConstants.HIDE_DETAILS_LABEL); - } - - Point newSize = getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT); - - getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); - } - - protected void createDropDownList() { - // create the list - projectsList = CheckboxTableViewer.newCheckList(radioComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - projectsList.setLabelProvider(createLabelProvider()); - projectsList.setSorter(new ViewerSorter() {/*viewersorter*/}); - projectsList.addCheckStateListener(this); - // fill the list - populateList(); - - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = projectsList.getTable().getItemHeight() * referencedProjects.size(); - data.horizontalSpan = 2; - data.horizontalIndent = 10; - projectsList.getTable().setLayoutData(data); - - listCreated = true; - } - - protected void populateList() { - for (Iterator iter = referencedProjects.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - projectsList.add(entry.getKey()); - boolean checked = ((Boolean) entry.getValue()).booleanValue(); - projectsList.setChecked(entry.getKey(), checked); - } - } - - protected void detailsBtnSelected() { - toggleDetailsArea(); - } - - /** - * @see ICheckStateListener#checkStateChanged(CheckStateChangedEvent) - */ - public void checkStateChanged(CheckStateChangedEvent event) { - referencedProjects.put(event.getElement(), new Boolean(event.getChecked())); - } - - protected ITableLabelProvider createLabelProvider() { - return new ITableLabelProvider() { - public void dispose() { - //dispose - } - - public Image getColumnImage(Object element, int columnIndex) { - return workbenchLabelProvider.getImage(element); - } - - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - return workbenchLabelProvider.getText(element); - } - - public void addListener(ILabelProviderListener listener) { - //do nothing - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - //do nothing - } - }; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARDialog.java deleted file mode 100644 index 770e058c6..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameEARDialog.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.dialogs; - - -import java.util.Set; - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -public class RenameEARDialog extends J2EERenameDialog { - protected RenameEARComposite renameComposite; - protected Set referencedProjects; - - /** - * Constructor for RenameEARDialog. - * - * @param parentShell - * @param dialogTitle - */ - public RenameEARDialog(Shell parentShell, Set referencedProjects, String name) { - super(parentShell, RENAME_EAR_OPTIONS, name); - this.referencedProjects = referencedProjects; - } - - - /** - * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(Composite) - */ - protected Control createCustomArea(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.RENAME_EAR_DIALOG_1); //$NON-NLS-1$ - renameComposite = new RenameEARComposite(parent, SWT.NONE, referencedProjects); - // renameComposite.setNewName(currentName); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalIndent = 10; - renameComposite.setLayoutData(data); - return renameComposite; - } - - /** - * @see J2EERenameDialog#createRenameOptions() - */ - public void createRenameOptions() { - renameOptions = renameComposite.createRenameOptions(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleComposite.java deleted file mode 100644 index 0923fced8..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleComposite.java +++ /dev/null @@ -1,181 +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.dialogs; - - -import java.text.MessageFormat; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; - - -public class RenameModuleComposite extends Composite implements J2EERenameUIConstants, Listener { - - // protected Button renameProjectsCheckBox; - protected RenameModuleReferencesComposite moduleRefsComposite; - protected Text newNameText = null; - protected Text newContextRootText = null; - protected Label newContextRootLabel = null; - protected String oldName = null; - protected Button OKButton = null; - protected Label statusMessageLabel = null; - - /** - * Constructor for RenameModuleComposite. - * - * @param parent - * @param style - */ - public RenameModuleComposite(Composite parent, int style) { - super(parent, style); - addChildren(); - } - - protected void addChildren() { - addRenameProjectsGroup(); - addSeparator(); - addRenameModuleRefsComposite(); - //Add in a label for status messages if required - statusMessageLabel = new Label(this, SWT.NONE); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - statusMessageLabel.setLayoutData(data); - statusMessageLabel.setFont(this.getFont()); - } - - protected void addRenameProjectsGroup() { - GridLayout lay = new GridLayout(); - lay.numColumns = 2; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - - newNameText = new Text(this, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - newNameText.setLayoutData(data); - - newContextRootLabel = new Label(this, SWT.NONE); - newContextRootLabel.setText(RENAME_CONTEXT_ROOT); - data = new GridData(GridData.FILL_HORIZONTAL); - newContextRootLabel.setLayoutData(data); - - newContextRootText = new Text(this, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - newContextRootText.setLayoutData(data); - - /* - * renameProjectsCheckBox = new Button(this, SWT.CHECK); - * renameProjectsCheckBox.setText(RENAME_PROJECTS); - * renameProjectsCheckBox.setSelection(true); - * renameProjectsCheckBox.addListener(SWT.Selection, this); data = new - * GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; - * renameProjectsCheckBox.setLayoutData(data); - */ - } - - protected void addRenameModuleRefsComposite() { - moduleRefsComposite = new RenameModuleReferencesComposite(this, SWT.NONE, false); - } - - protected void addSeparator() { - Label sep = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - sep.setLayoutData(data); - } - - public boolean shouldRenameProjects() { - // return renameProjectsCheckBox.getSelection(); - // always rename the project - return true; - } - - public boolean shouldRenameModuleDependencies() { - return moduleRefsComposite.shouldRenameModuleDependencies(); - } - - public boolean shouldRenameModules() { - return moduleRefsComposite.shouldRenameModules(); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == newNameText && OKButton != null) { - String newName = newNameText.getText(); - if (newName.trim().length() == 0) { - statusMessageLabel.setText("");//$NON-NLS-1$ - OKButton.setEnabled(false); - return; - } - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject newProject = root.getProject(newName); - if (newProject.exists()) { - statusMessageLabel.setForeground(JFaceColors.getErrorText(statusMessageLabel.getDisplay())); - String[] names = {newName}; - statusMessageLabel.setText(MessageFormat.format(J2EEUIMessages.getResourceString("Project_already_exists."), names)); //$NON-NLS-1$ - OKButton.setEnabled(false); - } else { - statusMessageLabel.setText("");//$NON-NLS-1$ - OKButton.setEnabled(true); - } - } - } - - public String getNewName() - - { - return newNameText.getText(); - } - - public void setNewName(String newName) { - oldName = newName; - newNameText.setText(newName); - newNameText.selectAll(); - newNameText.addListener(SWT.Modify, this); - } - - public String getNewContextRoot() { - return newContextRootText.getText(); - } - - public void setNewContextRoot(String newContextRoot) { - if (newContextRoot != null && newContextRoot.length() > 1) { - newContextRootText.setText(newContextRoot); - } else { - newContextRootLabel.setVisible(false); - newContextRootText.setVisible(false); - } - } - - /** - * Sets the OKButton. - * - * @param OKButton - * The OKButton to set - */ - public void setOKButton(Button oKButton) { - OKButton = oKButton; - OKButton.setEnabled(false); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleDialog.java deleted file mode 100644 index a5ea814b8..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleDialog.java +++ /dev/null @@ -1,65 +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.dialogs; - - - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.rename.RenameOptions; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - - -public class RenameModuleDialog extends J2EERenameDialog implements J2EERenameUIConstants { - - protected RenameModuleComposite renameComposite; - protected String contextRoot = null; - - public RenameModuleDialog(Shell parentShell, String name, String oldContextRoot) { - super(parentShell, RENAME_MODULE_OPTIONS, name); - contextRoot = oldContextRoot; - } - - protected Control createCustomArea(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.RENAME_MODULE_DIALOG_1); //$NON-NLS-1$ - renameComposite = new RenameModuleComposite(parent, SWT.NONE); - renameComposite.setNewName(currentName); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalIndent = 10; - renameComposite.setLayoutData(data); - renameComposite.setNewContextRoot(contextRoot); - return renameComposite; - } - - public void createRenameOptions() { - renameOptions = new RenameOptions(); - renameOptions.setRenameProjects(renameComposite.shouldRenameProjects()); - renameOptions.setRenameModules(renameComposite.shouldRenameModules()); - renameOptions.setRenameModuleDependencies(renameComposite.shouldRenameModuleDependencies()); - renameOptions.setNewName(renameComposite.getNewName()); - renameOptions.setNewContextRoot(renameComposite.getNewContextRoot()); - } - - /* - * (non-Javadoc) Method declared on Dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - Button OKButton = null; - super.createButtonsForButtonBar(parent); - OKButton = getButton(0); - renameComposite.setOKButton(OKButton); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleReferencesComposite.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleReferencesComposite.java deleted file mode 100644 index 7614aabb0..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RenameModuleReferencesComposite.java +++ /dev/null @@ -1,88 +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.dialogs; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -public class RenameModuleReferencesComposite extends Composite implements J2EERenameUIConstants, Listener { - - protected Button renameModulesCheckbox; - protected Button renameModuleDependenciesCheckbox; - protected boolean isEARRename; - - /** - * Constructor for RenameModuleReferencesComposite. - * - * @param parent - * @param style - */ - public RenameModuleReferencesComposite(Composite parent, int style, boolean isEARRename) { - super(parent, style); - this.isEARRename = isEARRename; - addChildren(); - } - - protected void addChildren() { - GridLayout lay = new GridLayout(); - lay.numColumns = 1; - setLayout(lay); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - setLayoutData(data); - - addRenameModulesCheckbox(); - addRenameModuleDependenciesCheckbox(); - } - - protected void addRenameModuleDependenciesCheckbox() { - renameModuleDependenciesCheckbox = new Button(this, SWT.CHECK); - renameModuleDependenciesCheckbox.setSelection(true); - renameModuleDependenciesCheckbox.setText(RENAME_MODULE_DEPENDENCIES); - - } - - protected void addRenameModulesCheckbox() { - renameModulesCheckbox = new Button(this, SWT.CHECK); - renameModulesCheckbox.setSelection(true); - String label = isEARRename ? RENAME_MODULES_OTHER : RENAME_MODULES; - renameModulesCheckbox.setText(label); - renameModulesCheckbox.addListener(SWT.Selection, this); - } - - public boolean shouldRenameModuleDependencies() { - return renameModuleDependenciesCheckbox.getSelection(); - } - - public boolean shouldRenameModules() { - return renameModulesCheckbox.getSelection(); - } - - public void setButtonsEnabled(boolean enabled) { - renameModuleDependenciesCheckbox.setSelection(enabled); - renameModulesCheckbox.setSelection(enabled); - renameModuleDependenciesCheckbox.setEnabled(enabled); - renameModulesCheckbox.setEnabled(enabled); - } - - /** - * @see Listener#handleEvent(Event) - */ - public void handleEvent(Event event) { - if (event.widget == renameModulesCheckbox && renameModulesCheckbox.getSelection() && !renameModuleDependenciesCheckbox.getSelection()) - renameModuleDependenciesCheckbox.setSelection(true); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RuntimeSelectionDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RuntimeSelectionDialog.java deleted file mode 100644 index a49b9220a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/RuntimeSelectionDialog.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.dialogs; - -import java.text.MessageFormat; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.PreferencesUtil; -import org.eclipse.ui.forms.events.IHyperlinkListener; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.wst.server.core.IRuntime; - - -/** - * @author Administrator - * - */ -public class RuntimeSelectionDialog extends MessageDialog { - private IProject project = null; - private String configuredMessage; - - /** - * @param parentShell - * @param dialogTitle - * @param dialogTitleImage - * @param dialogMessage - * @param dialogImageType - * @param dialogButtonLabels - * @param defaultIndex - */ - public RuntimeSelectionDialog(Shell parentShell, String dialogTitle, - Image dialogTitleImage, String dialogMessage, int dialogImageType, - String[] dialogButtonLabels, int defaultIndex, IProject project) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, - dialogImageType, dialogButtonLabels, defaultIndex); - this.project = project; - this.configuredMessage = MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_CONFIGURED"), new String []{project.getName()}); - } - - protected Control createCustomArea(Composite parent) { - - //Composite composite = new Composite(parent, 0); - createHyperLink(parent); - return parent; - - } - - private void createHyperLink(Composite parent) { - Hyperlink link = new Hyperlink(parent,SWT.None); - GridData layout = new GridData(GridData.HORIZONTAL_ALIGN_END); - layout.horizontalSpan = 2; - link.setLayoutData(layout); - link.setUnderlined(true); - Color color = new Color(parent.getDisplay(),new RGB(0,0,255) ); - link.setForeground(color); - link.setText("Configure Target Runtime..."); - link.addHyperlinkListener(new IHyperlinkListener() { - public static final String DATA_NO_LINK = "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$ - - public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) { - } - - public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) { - } - - public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { - String id = getPreferencePageID(); - PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[]{id}, DATA_NO_LINK).open(); // - //(getShell(), id, new String[]{id}, DATA_NO_LINK).open(); - try { - updateWidgets(); - } catch (Exception ie) { - - } - } - - private String getPreferencePageID() { - return "org.eclipse.wst.common.project.facet.ui.internal.RuntimesPropertyPage"; - } - }); - - } - - private void updateWidgets() { - if (getTargetRuntime() != null) { - messageLabel.setText(configuredMessage); - imageLabel.setImage(this.getInfoImage()); - } else { - messageLabel.setText(message); - imageLabel.setImage(getErrorImage()); - } - - } - - private IRuntime getTargetRuntime() { - try { - IRuntime runtime = J2EEProjectUtilities.getServerRuntime(project); - return runtime; - } catch (CoreException e) { - e.printStackTrace(); - } - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TwoArrayQuickSorter.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TwoArrayQuickSorter.java deleted file mode 100644 index 62d6907f2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TwoArrayQuickSorter.java +++ /dev/null @@ -1,126 +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.dialogs; - -/** - * @author jialin - * - * To change the template for this generated type comment go to Window - - * Preferences - Java - Code Generation - Code and Comments - */ -import java.util.Comparator; - -import org.eclipse.jface.util.Assert; - -/** - * Quick sort to sort key-value pairs. The keys and arrays are specified in - * separate arrays. - * - * @plannedfor 2.0 - */ -public class TwoArrayQuickSorter { - - private Comparator fComparator; - - /** - * Default comparator. - */ - public static final class StringComparator implements Comparator { - private boolean fIgnoreCase; - - StringComparator(boolean ignoreCase) { - fIgnoreCase = ignoreCase; - } - - public int compare(Object left, Object right) { - return fIgnoreCase ? ((String) left).compareToIgnoreCase((String) right) : ((String) left).compareTo((String) right); - } - } - - /** - * Creates a sorter with default string comparator. The keys are assumed to - * be strings. - * - * @param ignoreCase - * specifies whether sorting is case sensitive or not. - */ - public TwoArrayQuickSorter(boolean ignoreCase) { - fComparator = new StringComparator(ignoreCase); - } - - /** - * Creates a sorter with a comparator. - * - * @param comparator - * the comparator to order the elements. The comparator must not - * be <code>null</code>. - */ - public TwoArrayQuickSorter(Comparator comparator) { - fComparator = comparator; - } - - /** - * Sorts keys and values in parallel. - * - * @param keys - * the keys to use for sorting. - * @param values - * the values associated with the keys. - */ - public void sort(Object[] keys, Object[] values) { - if ((keys == null) || (values == null)) { - Assert.isTrue(false, "Either keys or values in null"); //$NON-NLS-1$ - return; - } - - if (keys.length <= 1) - return; - - internalSort(keys, values, 0, keys.length - 1); - } - - private void internalSort(Object[] keys, Object[] values, int left, int right) { - int original_left = left; - int original_right = right; - - Object mid = keys[(left + right) / 2]; - do { - while (fComparator.compare(keys[left], mid) < 0) - left++; - - while (fComparator.compare(mid, keys[right]) < 0) - right--; - - if (left <= right) { - swap(keys, left, right); - swap(values, left, right); - left++; - right--; - } - } while (left <= right); - - if (original_left < right) - internalSort(keys, values, original_left, right); - - if (left < original_right) - internalSort(keys, values, left, original_right); - } - - /* - * Swaps x[a] with x[b]. - */ - private static final void swap(Object x[], int a, int b) { - Object t = x[a]; - x[a] = x[b]; - x[b] = t; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeJavaSearchScope.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeJavaSearchScope.java deleted file mode 100644 index 6c430f694..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeJavaSearchScope.java +++ /dev/null @@ -1,352 +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.dialogs; - -import java.util.ArrayList; -import java.util.HashSet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IOpenable; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; - -/** - * This class was derived from JavaSearchScope as that class did not have a - * provision to exclude classpath entries that are not exported A Java-specific - * scope for searching relative to one or more java elements. - */ -public class TypeJavaSearchScope implements IJavaSearchScope { - - private boolean includeExportedClassPathEntriesOnly = true; - - private ArrayList elements; - - /* - * The paths of the resources in this search scope (or the classpath - * entries' paths if the resources are projects) - */ - private IPath[] paths; - private boolean[] pathWithSubFolders; - private int pathsCount; - - private IPath[] enclosingProjectsAndJars; - - public TypeJavaSearchScope() { - this.initialize(); - - // disabled for now as this could be expensive - // JavaModelManager.getJavaModelManager().rememberScope(this); - } - - private void addEnclosingProjectOrJar(IPath path) { - int length = this.enclosingProjectsAndJars.length; - for (int i = 0; i < length; i++) { - if (this.enclosingProjectsAndJars[i].equals(path)) - return; - } - System.arraycopy(this.enclosingProjectsAndJars, 0, this.enclosingProjectsAndJars = new IPath[length + 1], 0, length); - this.enclosingProjectsAndJars[length] = path; - } - - /** - * Method addProject. This method adds all the classpath entries for the - * current project to the search scope. - * - * @param javaProject - * @param includesPrereqProjects - * @param visitedProjects - * @throws JavaModelException - */ - public void addProject(IJavaProject javaProject, boolean includesPrereqProjects, HashSet visitedProjects) throws JavaModelException { - IProject project = javaProject.getProject(); - if (!project.isAccessible() || !visitedProjects.add(project)) - return; - - this.addEnclosingProjectOrJar(project.getFullPath()); - - IClasspathEntry[] entries = javaProject.getResolvedClasspath(true); - IJavaModel model = javaProject.getJavaModel(); - for (int i = 0, length = entries.length; i < length; i++) { - IClasspathEntry entry = entries[i]; - switch (entry.getEntryKind()) { - case IClasspathEntry.CPE_LIBRARY : - IPath path = entry.getPath(); - this.add(path, true); - this.addEnclosingProjectOrJar(path); - break; - case IClasspathEntry.CPE_PROJECT : - if (includesPrereqProjects) { - this.add(model.getJavaProject(entry.getPath().lastSegment()), true, visitedProjects); - } - break; - case IClasspathEntry.CPE_SOURCE : - this.add(entry.getPath(), true); - break; - } - } - } - - /** - * Method add. This method filters out all the classpath entries of the - * project which are not exported. - * - * @param javaProject - * @param includesPrereqProjects - * @param visitedProjects - * @throws JavaModelException - */ - public void add(IJavaProject javaProject, boolean includesPrereqProjects, HashSet visitedProjects) throws JavaModelException { - IProject project = javaProject.getProject(); - if (!project.isAccessible() || !visitedProjects.add(project)) - return; - - this.addEnclosingProjectOrJar(project.getFullPath()); - - IClasspathEntry[] entries = javaProject.getResolvedClasspath(true); - IJavaModel model = javaProject.getJavaModel(); - for (int i = 0, length = entries.length; i < length; i++) { - IClasspathEntry entry = entries[i]; - if (includeExportedClassPathEntriesOnly()) { - if (!entry.isExported() && entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) - continue; - } - switch (entry.getEntryKind()) { - case IClasspathEntry.CPE_LIBRARY : - IPath path = entry.getPath(); - this.add(path, true); - this.addEnclosingProjectOrJar(path); - break; - case IClasspathEntry.CPE_PROJECT : - if (includesPrereqProjects) { - this.add(model.getJavaProject(entry.getPath().lastSegment()), true, visitedProjects); - } - break; - case IClasspathEntry.CPE_SOURCE : - this.add(entry.getPath(), true); - break; - } - } - } - public void add(IJavaElement element) throws JavaModelException { - IPackageFragmentRoot root = null; - switch (element.getElementType()) { - case IJavaElement.JAVA_MODEL : - // a workspace sope should be used - break; - case IJavaElement.JAVA_PROJECT : - this.add((IJavaProject) element, true, new HashSet(2)); - break; - case IJavaElement.PACKAGE_FRAGMENT_ROOT : - root = (IPackageFragmentRoot) element; - this.add(root.getPath(), true); - break; - case IJavaElement.PACKAGE_FRAGMENT : - root = (IPackageFragmentRoot) element.getParent(); - if (root.isArchive()) { - this.add(root.getPath().append(new Path(element.getElementName().replace('.', '/'))), false); - } else { - IResource resource = element.getUnderlyingResource(); - if (resource != null && resource.isAccessible()) { - this.add(resource.getFullPath(), false); - } - } - break; - default : - // remember sub-cu (or sub-class file) java elements - if (element instanceof IMember) { - if (this.elements == null) { - this.elements = new ArrayList(); - } - this.elements.add(element); - } - this.add(this.fullPath(element), true); - - // find package fragment root including this java element - IJavaElement parent = element.getParent(); - while (parent != null && !(parent instanceof IPackageFragmentRoot)) { - parent = parent.getParent(); - } - if (parent instanceof IPackageFragmentRoot) { - root = (IPackageFragmentRoot) parent; - } - } - - if (root != null) { - if (root.getKind() == IPackageFragmentRoot.K_BINARY) { - this.addEnclosingProjectOrJar(root.getPath()); - } else { - this.addEnclosingProjectOrJar(root.getJavaProject().getProject().getFullPath()); - } - } - } - - /** - * Adds the given path to this search scope. Remember if subfolders need to - * be included as well. - */ - private void add(IPath path, boolean withSubFolders) { - if (this.paths.length == this.pathsCount) { - System.arraycopy(this.paths, 0, this.paths = new IPath[this.pathsCount * 2], 0, this.pathsCount); - System.arraycopy(this.pathWithSubFolders, 0, this.pathWithSubFolders = new boolean[this.pathsCount * 2], 0, this.pathsCount); - } - this.paths[this.pathsCount] = path; - this.pathWithSubFolders[this.pathsCount++] = withSubFolders; - } - - /* - * (non-Javadoc) - * - * @see IJavaSearchScope#encloses(String) - */ - public boolean encloses(String resourcePathString) { - IPath resourcePath; - int separatorIndex = resourcePathString.indexOf(JAR_FILE_ENTRY_SEPARATOR); - if (separatorIndex != -1) { - resourcePath = new Path(resourcePathString.substring(0, separatorIndex)).append(new Path(resourcePathString.substring(separatorIndex + 1))); - } else { - resourcePath = new Path(resourcePathString); - } - return this.encloses(resourcePath); - } - - /** - * Returns whether this search scope encloses the given path. - */ - private boolean encloses(IPath path) { - for (int i = 0; i < this.pathsCount; i++) { - if (this.pathWithSubFolders[i]) { - if (this.paths[i].isPrefixOf(path)) { - return true; - } - } else { - IPath scopePath = this.paths[i]; - if (scopePath.isPrefixOf(path) && (scopePath.segmentCount() == path.segmentCount() - 1)) { - return true; - } - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see IJavaSearchScope#encloses(IJavaElement) - */ - public boolean encloses(IJavaElement element) { - if (this.elements != null) { - for (int i = 0, length = this.elements.size(); i < length; i++) { - IJavaElement scopeElement = (IJavaElement) this.elements.get(i); - IJavaElement searchedElement = element; - while (searchedElement != null) { - if (searchedElement.equals(scopeElement)) { - return true; - } - searchedElement = searchedElement.getParent(); - } - } - return false; - } - return this.encloses(this.fullPath(element)); - } - - /* - * (non-Javadoc) - * - * @see IJavaSearchScope#enclosingProjectsAndJars() - */ - public IPath[] enclosingProjectsAndJars() { - return this.enclosingProjectsAndJars; - } - private IPath fullPath(IJavaElement element) { - if (element instanceof IPackageFragmentRoot) { - return ((IPackageFragmentRoot) element).getPath(); - } - IJavaElement parent = element.getParent(); - IPath parentPath = parent == null ? null : this.fullPath(parent); - IPath childPath; - if (element instanceof IPackageFragment) { - childPath = new Path(element.getElementName().replace('.', '/')); - } else if (element instanceof IOpenable) { - childPath = new Path(element.getElementName()); - } else { - return parentPath; - } - return parentPath == null ? childPath : parentPath.append(childPath); - } - - protected void initialize() { - this.paths = new IPath[1]; - this.pathWithSubFolders = new boolean[1]; - this.pathsCount = 0; - this.enclosingProjectsAndJars = new IPath[0]; - } - /** - * Gets the includeExportedClassPathEntriesOnly. - * - * @return Returns a boolean - */ - public boolean includeExportedClassPathEntriesOnly() { - return includeExportedClassPathEntriesOnly; - } - - /** - * Sets the includeExportedClassPathEntriesOnly. - * - * @param includeExportedClassPathEntriesOnly - * The includeExportedClassPathEntriesOnly to set - */ - public void setIncludeExportedClassPathEntriesOnly(boolean includeExportedClassPathEntriesOnly) { - this.includeExportedClassPathEntriesOnly = includeExportedClassPathEntriesOnly; - } - /** - * @see IJavaSearchScope#includesBinaries() - * @deprecated - */ - public boolean includesBinaries() { - return true; - } - - /** - * @see IJavaSearchScope#includesClasspaths() - * @deprecated - */ - public boolean includesClasspaths() { - return true; - } - - /** - * @see IJavaSearchScope#setIncludesBinaries(boolean) - * @deprecated - */ - public void setIncludesBinaries(boolean includesBinaries) { - //Default nothing - } - - /** - * @see IJavaSearchScope#setIncludesClasspaths(boolean) - * @deprecated - */ - public void setIncludesClasspaths(boolean includesClasspaths) { - //Default nothing - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeSearchEngine.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeSearchEngine.java deleted file mode 100644 index 353d443b8..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypeSearchEngine.java +++ /dev/null @@ -1,65 +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.dialogs; - -import java.util.HashSet; - -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.core.search.SearchEngine; - -public class TypeSearchEngine extends SearchEngine { - - /** - * Constructor for TypeSearchEngine. - */ - public TypeSearchEngine() { - super(); - } - - /** - * Constructor for TypeSearchEngine. - * - * @param workingCopies - */ - public TypeSearchEngine(ICompilationUnit[] workingCopies) { - super(workingCopies); - } - - /** - * Method createJavaSearchScopeForAProject. Given a project it returns the - * scope of the classes within the project's scope - * - * @param project - * @param includeReferencedProjects - * @param includeExportedClassPathEntriesOnly - * @return IJavaSearchScope - */ - public static IJavaSearchScope createJavaSearchScopeForAProject(IJavaProject project, boolean includeReferencedProjects, boolean includeExportedClassPathEntriesOnly) { - if (!includeExportedClassPathEntriesOnly) { - IJavaElement javaElements[] = new IJavaElement[]{project}; - return SearchEngine.createJavaSearchScope(javaElements, includeReferencedProjects); - } - TypeJavaSearchScope scope = new TypeJavaSearchScope(); - scope.setIncludeExportedClassPathEntriesOnly(true); - HashSet visitedProjects = new HashSet(2); - try { - scope.addProject(project, includeReferencedProjects, visitedProjects); - } catch (JavaModelException e) { - // ignore - } - return scope; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypedFileViewerFilter.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypedFileViewerFilter.java deleted file mode 100644 index 7b4253487..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/dialogs/TypedFileViewerFilter.java +++ /dev/null @@ -1,72 +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.dialogs; - -import java.util.Hashtable; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.Viewer; - -public class TypedFileViewerFilter extends org.eclipse.jface.viewers.ViewerFilter { - private String[] fAcceptedExtensions; - private Hashtable visitedElements; - public TypedFileViewerFilter(String[] acceptedExtensions) { - fAcceptedExtensions = acceptedExtensions; - visitedElements = new Hashtable(); - } - public boolean isFilterProperty(Object element, Object property) { - return false; - } - public boolean isValid(Object element) { - if (IFile.class.isInstance(element)) - return isValidFile((IFile) element); - if (IContainer.class.isInstance(element)) - return isValidContainer((IContainer) element); - return false; - } - /* - * A valid container is one that contains at least one valid member. - */ - public boolean isValidContainer(IContainer container) { - IResource[] members; - Object valid = visitedElements.get(container); - if (valid != null) - return ((Boolean) valid).booleanValue(); - try { - members = container.members(); - for (int i = 0; i < members.length; i++) { - if (isValid(members[i])) { - visitedElements.put(container, Boolean.TRUE); - return true; - } - } - } catch (CoreException e) { - // Do nothing - } - visitedElements.put(container, Boolean.FALSE); - return false; - } - public boolean isValidFile(IFile file) { - String ext = file.getFileExtension(); - for (int i = 0; i < fAcceptedExtensions.length; i++) { - if (fAcceptedExtensions[i].equalsIgnoreCase(ext)) { - return true; - } - } - return false; - } - public boolean select(Viewer viewer, Object parentElement, Object element) { - return isValid(element); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ArchiveEARUIResourceHandler.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ArchiveEARUIResourceHandler.java deleted file mode 100644 index 1682ee1a2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ArchiveEARUIResourceHandler.java +++ /dev/null @@ -1,59 +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.ear.actions; - - - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class ArchiveEARUIResourceHandler { - - private static ResourceBundle fgResourceBundle; - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("archiveearui");//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String, String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/EARImportListContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/EARImportListContentProvider.java deleted file mode 100644 index 31c247184..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/EARImportListContentProvider.java +++ /dev/null @@ -1,72 +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.ear.actions; - - -import org.eclipse.jst.j2ee.internal.wizard.TableObjects; - -/** - * Insert the type's description here. Creation date: (5/7/2001 11:39:11 AM) - * - * @author: Administrator - */ -public class EARImportListContentProvider implements org.eclipse.jface.viewers.IStructuredContentProvider { - /** - * EARImportListContentProvider constructor comment. - */ - public EARImportListContentProvider() { - super(); - } - - /** - * Disposes of this content provider. This is called by the viewer when it is disposed. - */ - public void dispose() { - //dispose - } - - /** - * Returns the elements to display in the viewer when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. The result is not - * modified by the viewer. - * - * @param inputElement - * the input element - * @return the array of elements to display in the viewer - */ - public java.lang.Object[] getElements(Object inputElement) { - if (inputElement instanceof TableObjects) - return ((TableObjects) inputElement).getTableObjects().toArray(); - return new Object[0]; //should throw exception instead - } - - /** - * Notifies this content provider that the given viewer's input has been switched to a different - * element. - * <p> - * A typical use for this method is registering the content provider as a listener to changes on - * the new input (using model-specific means), and deregistering the viewer from the old input. - * In response to these change notifications, the content provider propagates the changes to the - * viewer. - * </p> - * - * @param viewer - * the viewer - * @param oldInput - * the old input element, or <code>null</code> if the viewer did not previously - * have an input - * @param newInput - * the new input element, or <code>null</code> if the viewer does not have an input - */ - public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ExportEARAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ExportEARAction.java deleted file mode 100644 index a7078ae50..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ExportEARAction.java +++ /dev/null @@ -1,52 +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 Mar 27, 2003 - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.ear.actions; - -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.actions.BaseAction; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.EARComponentExportWizard; -import org.eclipse.swt.widgets.Shell; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ExportEARAction extends BaseAction { - - public static String LABEL = J2EEUIPlugin.getDefault().getDescriptor().getResourceString("%ear.export.action.description_ui_");//$NON-NLS-1$ - private static final String ICON = "export_ear_wiz"; //$NON-NLS-1$ - - public ExportEARAction() { - super(); - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public void primRun(Shell shell) { - EARComponentExportWizard wizard = new EARComponentExportWizard(); - J2EEUIPlugin plugin = J2EEUIPlugin.getDefault(); - - wizard.init(plugin.getWorkbench(), selection); - - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.create(); - dialog.open(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ImportEARAction.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ImportEARAction.java deleted file mode 100644 index 305c3ec95..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ImportEARAction.java +++ /dev/null @@ -1,55 +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 Mar 27, 2003 - * - * To change this generated comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.ear.actions; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.actions.BaseAction; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.wizard.EARComponentImportWizard; -import org.eclipse.swt.widgets.Shell; - - -/** - * @author jsholl - * - * To change this generated comment go to Window>Preferences>Java>Code Generation>Code and Comments - */ -public class ImportEARAction extends BaseAction { - public static String LABEL = ArchiveEARUIResourceHandler.getString("Import_EAR"); //$NON-NLS-1$ - private static final String ICON = "import_ear_wiz"; //$NON-NLS-1$ - - public ImportEARAction() { - super(); - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - protected void primRun(Shell shell) { - - EARComponentImportWizard wizard = new EARComponentImportWizard(); - - J2EEUIPlugin plugin = J2EEUIPlugin.getDefault(); - - wizard.init(plugin.getWorkbench(), StructuredSelection.EMPTY); - - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.create(); - dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ModulesProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ModulesProvider.java deleted file mode 100644 index 4914e7f12..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ear/actions/ModulesProvider.java +++ /dev/null @@ -1,138 +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.ear.actions; - - -import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection; - -/** - * Insert the type's description here. Creation date: (8/22/2001 2:27:24 PM) - * - * @author: Administrator - */ -public class ModulesProvider implements org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.IStructuredContentProvider { - /** - * ModulesProvider constructor comment. - */ - public ModulesProvider() { - super(); - } - - /** - * Adds a listener to this label provider. Has no effect if an identical listener is already - * registered. - * <p> - * Label provider listeners are informed about state changes that affect the rendering of the - * viewer that uses this label provider. - * </p> - * - * @param listener - * a label provider listener - */ - public void addListener(org.eclipse.jface.viewers.ILabelProviderListener listener) { - //do nothing - } - - /** - * Disposes of this content provider. This is called by the viewer when it is disposed. - */ - public void dispose() { - //dispose - } - - /** - * Returns the elements to display in the viewer when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. The result is not - * modified by the viewer. - * - * @param inputElement - * the input element - * @return the array of elements to display in the viewer - */ - public java.lang.Object[] getElements(java.lang.Object inputElement) { - return ((java.util.List) inputElement).toArray(); - } - - /** - * Returns the image for the label of the given element. The image is owned by the label - * provider and must not be disposed directly. Instead, dispose the label provider when no - * longer needed. - * - * @param element - * the element for which to provide the label image - * @return the image used to label the element, or <code>null</code> if these is no image for - * the given object - */ - public org.eclipse.swt.graphics.Image getImage(Object element) { - return null; - } - - /** - * Returns the text for the label of the given element. - * - * @param element - * the element for which to provide the label text - * @return the text string used to label the element, or <code>null</code> if these is no text - * label for the given object - */ - public String getText(Object element) { - return ((ClassPathSelection) element).getText(); - } - - /** - * Notifies this content provider that the given viewer's input has been switched to a different - * element. - * <p> - * A typical use for this method is registering the content provider as a listener to changes on - * the new input (using model-specific means), and deregistering the viewer from the old input. - * In response to these change notifications, the content provider propagates the changes to the - * viewer. - * </p> - * - * @param viewer - * the viewer - * @param oldInput - * the old input element, or <code>null</code> if the viewer did not previously - * have an input - * @param newInput - * the new input element, or <code>null</code> if the viewer does not have an input - */ - public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } - - /** - * Returns whether the label would be affected by a change to the given property of the given - * element. This can be used to optimize a non-structural viewer update. If the property - * mentioned in the update does not affect the label, then the viewer need not update the label. - * - * @param element - * the element - * @param property - * the property - * @return <code>true</code> if the label would be affected, and <code>false</code> if it - * would be unaffected - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * Removes a listener to this label provider. Has no affect if an identical listener is not - * registered. - * - * @param listener - * a label provider listener - */ - public void removeListener(org.eclipse.jface.viewers.ILabelProviderListener listener) { - //do nothing - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/AbstractMethodsContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/AbstractMethodsContentProvider.java deleted file mode 100644 index 1eccf4525..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/AbstractMethodsContentProvider.java +++ /dev/null @@ -1,316 +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.ejb.provider; - - -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor; -import org.eclipse.jst.j2ee.ejb.CMPAttribute; -import org.eclipse.jst.j2ee.ejb.EjbMethodElementComparator; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.MethodElement; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.wst.common.frameworks.internal.ui.DisplayUtility; - - -public abstract class AbstractMethodsContentProvider extends AdapterFactoryContentProvider { - protected static EStructuralFeature ME_EJB_SF = EjbFactoryImpl.getPackage().getMethodElement_EnterpriseBean(); - protected static EStructuralFeature JAR_ASSEMBLY_SF = EjbFactoryImpl.getPackage().getEJBJar_AssemblyDescriptor(); - private static final EStructuralFeature ECORE_BEAN_NAME = EcorePackage.eINSTANCE.getENamedElement_Name(); //ENAMED_ELEMENT__NAME - protected Comparator meComparator; - protected boolean isRoot = true; - - public class EJBMethodItem { - public EObject refObject; - public EnterpriseBean ejb; - - public EJBMethodItem(EObject aRefObject, EnterpriseBean anEJB) { - refObject = aRefObject; - ejb = anEJB; - } - - } - - /** - * Constructor for AbstractMethodsContentProvider. - * - * @param adapterFactory - */ - public AbstractMethodsContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - public AbstractMethodsContentProvider(AdapterFactory adapterFactory, boolean root) { - super(adapterFactory); - isRoot = root; - } - - protected Comparator getEnterpriseBeanComparator() { - return EJBNameComparator.singleton(); - } - - protected Comparator getMethodElementComparator() { - if (meComparator == null) - meComparator = new EjbMethodElementComparator(); - return meComparator; - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof AbstractMethodsContentProvider.EJBMethodItem) - return getMethodElements((AbstractMethodsContentProvider.EJBMethodItem) parentElement); - return new Object[0]; - } - - protected Object[] getMethodElements(AbstractMethodsContentProvider.EJBMethodItem ejbItem) { - EObject refObject = ejbItem.refObject; - if (refObject == null) - return new Object[0]; - List elements = getMethodElements(refObject, ejbItem.ejb); - Object[] result = elements.toArray(); - if (result.length == 1) - return result; - Arrays.sort(result, getMethodElementComparator()); - return result; - } - - protected abstract List getMethodElements(EObject aRefObject, EnterpriseBean anEJB); - - protected Object[] getEnterpriseBeans(EObject parentElement, List someMethodElements) { - if (someMethodElements.isEmpty()) - return new Object[0]; - Set ejbs = new HashSet(); - EnterpriseBean ejb = null; - MethodElement me = null; - for (int i = 0; i < someMethodElements.size(); i++) { - me = (MethodElement) someMethodElements.get(i); - ejb = me.getEnterpriseBean(); - if (ejb != null) - ejbs.add(ejb); - } - Object[] result = ejbs.toArray(); - if (result.length != 1) - Arrays.sort(result, getEnterpriseBeanComparator()); - ejb = null; - for (int i = 0; i < result.length; i++) { - ejb = (EnterpriseBean) result[i]; - result[i] = new EJBMethodItem(parentElement, ejb); - } - return result; - } - - protected AssemblyDescriptor getAssemblyDescriptor(EnterpriseBean ejb) { - if (ejb == null) - return null; - return ejb.getEjbJar().getAssemblyDescriptor(); - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof AbstractMethodsContentProvider.EJBMethodItem) - return true; - return false; - } - - protected TreeViewer getTreeViewer() { - return (TreeViewer) viewer; - } - - protected void refreshTreeViewer(Object obj) { - if (viewer != null) - DisplayUtility.asyncExec(createRefreshTreeRunnable(obj)); - } - - protected void refreshTreeViewer() { - if (viewer != null) - DisplayUtility.asyncExec(createRefreshTreeRunnable(null)); - } - - protected void refreshTreeViewer(MethodElement me) { - refreshTreeViewer(me.eContainer()); - } - - protected void refreshTreeViewer(List aList) { - if (aList.isEmpty()) - return; - refreshTreeViewer((MethodElement) aList.get(0)); - } - - protected void addToTreeViewer(final MethodElement me) { - if (viewer == null) - return; - DisplayUtility.asyncExec(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - // findMethodItem() should be run in a Display thread - EJBMethodItem item = findMethodItem(me); - if (item != null) - DisplayUtility.asyncExec(createAddItemTreeRunnable(item, me)); - else - refreshTreeViewer(me.eContainer()); - - } - }); - } - - protected void removeFromTreeViewer(final EObject parent, final MethodElement me) { - if (viewer == null) - return; - DisplayUtility.asyncExec(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - EnterpriseBean ejb = me.getEnterpriseBean(); - EJBMethodItem item = findMethodItem(ejb, parent); - if (item != null) - refreshTreeViewer(item); - else - refreshTreeViewer((Object) null); - } - }); - } - - protected EJBMethodItem findMethodItem(MethodElement me) { - return findMethodItem(me.getEnterpriseBean(), me.eContainer()); - } - - protected EJBMethodItem findMethodItem(EnterpriseBean ejb, EObject parentMethod) { - TreeItem[] items = getTreeViewer().getTree().getItems(); - return findMethodItem(ejb, parentMethod, items); - } - - protected EJBMethodItem findMethodItem(EnterpriseBean ejb, EObject parentMethod, TreeItem[] items) { - TreeItem item = null; - Object data = null; - EJBMethodItem methodItem = null, found = null; - for (int i = 0; i < items.length; i++) { - item = items[i]; - data = item.getData(); - if (data instanceof EJBMethodItem) { - methodItem = (EJBMethodItem) data; - if (methodItem.ejb == ejb && methodItem.refObject == parentMethod) - return methodItem; - } - found = findMethodItem(ejb, parentMethod, item.getItems()); - if (found != null) - return found; - } - return null; - } - - /* - * @see INotifyChangedListener#notifyChanged(new ENotificationImpl((InternalEObject)Object, - * int,(EStructuralFeature) Object, Object, Object, int)) - */ - public void notifyChanged(Notification notifier) { - if (notifier.getEventType() == Notification.RESOLVE) - return; - else if (notifier.getOldValue() instanceof CMPAttribute && notifier.getNewValue() == null) - return; - else if (notifier.getFeature() == ME_EJB_SF) { - refreshTreeViewer((MethodElement) notifier.getNotifier()); - return; - } else if (notifier.getFeature() == ECORE_BEAN_NAME) { - refreshTreeViewer(); - return; - } else if (getMethodElementsReference() == notifier.getFeature()) { - if (notifier.getEventType() == Notification.ADD) - addToTreeViewer((MethodElement) notifier.getNewValue()); - else if (notifier.getEventType() == Notification.REMOVE) - removeFromTreeViewer((EObject) notifier.getNotifier(), (MethodElement) notifier.getOldValue()); - return; - } else if (notifier.getFeature() == JAR_ASSEMBLY_SF && isRoot) { - updateTreeInput(notifier.getNewValue()); - } else if (notifier.getFeature() == getMethodElementsContainerReference()) - super.notifyChanged(notifier); - } - - /** - * @param notifier - */ - protected void updateTreeInput(final Object target) { - DisplayUtility.asyncExec(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - - getTreeViewer().setInput(target); //reset the input - getTreeViewer().refresh(target); - - } - }); - } - - private Runnable createAddItemTreeRunnable(final Object parent, final MethodElement me) { - return new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - getTreeViewer().add(parent, me); - } - }; - } - - private Runnable createRefreshTreeRunnable(final Object target) { - return new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - if (target != null) - getTreeViewer().refresh(target); - else - getTreeViewer().refresh(); - } - }; - } - - protected abstract EStructuralFeature getMethodElementsReference(); - - protected abstract EStructuralFeature getMethodElementsContainerReference(); -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/BeanClassProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/BeanClassProviderHelper.java deleted file mode 100644 index 38a42ebce..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/BeanClassProviderHelper.java +++ /dev/null @@ -1,57 +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.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -/** - * Insert the type's description here. Creation date: (6/21/2001 12:29:49 AM) - * - * @author: Administrator - */ -public class BeanClassProviderHelper extends J2EEJavaClassProviderHelper { - private static Image image; - - /** - * BeanClassProviderHelper constructor comment. - */ - public BeanClassProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:53:09 PM) - * - * @return org.eclipse.jem.internal.java.JavaClass - */ - public JavaClass getJavaClass() { - return getEjb().getEjbClass(); - } - - protected String getOverlayKey() { - return "ejb_module_ovr";//$NON-NLS-1$ - } - - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("EJB_Class_UI_", new Object[]{className}); //$NON-NLS-1$ = "EJB Class" - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/EJBUIMessages.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/EJBUIMessages.java deleted file mode 100644 index d03ed28bf..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/EJBUIMessages.java +++ /dev/null @@ -1,31 +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.ejb.provider; - -import org.eclipse.osgi.util.NLS; - - -public class EJBUIMessages extends NLS { - - private static final String BUNDLE_NAME = "j2ee_ejb_ui";//$NON-NLS-1$ - - private EJBUIMessages() { - // Do not instantiate - } - - public static String GroupedEJBJarItemProvider_UI_0; - public static String GroupedEJBJarItemProvider_UI_1; - public static String GroupedEJBJarItemProvider_UI_2; - - static { - NLS.initializeMessages(BUNDLE_NAME, EJBUIMessages.class); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ExcludeListContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ExcludeListContentProvider.java deleted file mode 100644 index 12c91ca8d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ExcludeListContentProvider.java +++ /dev/null @@ -1,140 +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.ejb.provider; - - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor; -import org.eclipse.jst.j2ee.ejb.CMPAttribute; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.ExcludeList; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; - - -public class ExcludeListContentProvider extends AbstractMethodsContentProvider { - private static final EStructuralFeature EXCLUDE_ME_SF = EjbFactoryImpl.getPackage().getExcludeList_MethodElements(); - private static final EStructuralFeature AD_EL_SF = EjbFactoryImpl.getPackage().getAssemblyDescriptor_ExcludeList(); - protected static final EStructuralFeature ECORE_BEAN_NAME = EcorePackage.eINSTANCE.getENamedElement_Name(); //ENAMED_ELEMENT__NAME - - /** - * Constructor for ExcludeListContentProvider. - * - * @param adapterFactory - * @param root - * @param viewer - */ - public ExcludeListContentProvider(AdapterFactory adapterFactory, boolean root) { - super(adapterFactory, root); - } - - /** - * Constructor for ExcludesListContentProvider. - * - * @param adapterFactory - */ - public ExcludeListContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - protected Object[] getEnterpriseBeans(ExcludeList list) { - List mes = list.getMethodElements(); - return getEnterpriseBeans(list, mes); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElements(EObject, EnterpriseBean) - */ - protected List getMethodElements(EObject aRefObject, EnterpriseBean anEJB) { - if (!(aRefObject instanceof ExcludeList)) - return Collections.EMPTY_LIST; - ExcludeList parentList = (ExcludeList) aRefObject; - if (parentList == null) - return Collections.EMPTY_LIST; - return parentList.getMethodElements(anEJB); - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - super.getElements(inputElement); - ExcludeList list = null; - if (inputElement instanceof EJBJar) { - EJBJar jar = (EJBJar) inputElement; - if (jar.getAssemblyDescriptor() != null) - list = jar.getAssemblyDescriptor().getExcludeList(); - if (list != null) - return getEnterpriseBeans(list); - } - if (inputElement instanceof AssemblyDescriptor) { - list = ((AssemblyDescriptor) inputElement).getExcludeList(); - if (list != null) - return getEnterpriseBeans(list); - } - return new Object[0]; - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.ejb.ui.providers.AbstractMethodsContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof ExcludeList) - return getEnterpriseBeans((ExcludeList) parentElement); - return super.getChildren(parentElement); - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.ejb.ui.providers.AbstractMethodsContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof ExcludeList) - return !((ExcludeList) element).getMethodElements().isEmpty(); - return super.hasChildren(element); - } - - public void notifyChanged(Notification notifier) { - if ((notifier.getFeature() == EXCLUDE_ME_SF && notifier.getNotifier() instanceof ExcludeList) || notifier.getFeature() == ECORE_BEAN_NAME) { - if (notifier.getEventType() == Notification.RESOLVE) - return; - if (isRoot) - refreshTreeViewer(); - else - refreshTreeViewer(notifier.getNotifier()); - } - if (notifier.getOldValue() instanceof CMPAttribute && notifier.getNewValue() == null) - return; - if (notifier.getFeature() == getMethodElementsReference() || notifier.getFeature() == getMethodElementsContainerReference()) - super.notifyChanged(notifier); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElementsReference() - */ - protected EStructuralFeature getMethodElementsReference() { - return EXCLUDE_ME_SF; - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.ejb.ui.providers.AbstractMethodsContentProvider#getMethodElementsContainerReference() - */ - protected EStructuralFeature getMethodElementsContainerReference() { - return AD_EL_SF; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBItemProvider.java deleted file mode 100644 index 6645c6f34..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBItemProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.ejb.provider; - -import java.util.Collection; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.internal.provider.J2EEItemProvider; - - - -/** - * This class is the item provider for EJB groups - */ -public abstract class GroupedEJBItemProvider extends J2EEItemProvider { - - public GroupedEJBItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent, Collection children) { - super(adapterFactory, text, image, parent, children); - } - - public IFile getAssociatedFile() { - - try { - EJBJar ejbJar = (EJBJar) getParent(); - if(ejbJar != null && ejbJar.eResource() != null) { - return WorkbenchResourceHelperBase.getIFile(ejbJar.eResource().getURI()); - } - } catch (Throwable t) { - - } - return null; - } - - public abstract String getText(Object object); -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBJarItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBJarItemProvider.java deleted file mode 100644 index 5efe5cb94..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEJBJarItemProvider.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.ejb.provider; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationWrapper; -import org.eclipse.emf.common.notify.impl.NotificationImpl; -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.Entity; -import org.eclipse.jst.j2ee.ejb.MessageDriven; -import org.eclipse.jst.j2ee.ejb.Session; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.provider.J2EEItemProvider; - - -/** - * @author Sachin P Patel - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class GroupedEJBJarItemProvider extends EJBJarItemProvider { - - private GroupedSessionItemProvider sessionProvider = null; - private GroupedEntityItemProvider entityProvider = null; - private GroupedMessageItemProvider messageProvider = null; - - private static Hashtable sessionTable = new Hashtable(); - private static Hashtable entityTable = new Hashtable(); - private static Hashtable messageTable = new Hashtable(); - - private static final String SESSION = EJBUIMessages.GroupedEJBJarItemProvider_UI_0; - private static final String ENTITY = EJBUIMessages.GroupedEJBJarItemProvider_UI_1; - private static final String MESSAGE = EJBUIMessages.GroupedEJBJarItemProvider_UI_2; - - // Normally there is one instance of an item provider for all instances of the objecct - // in the tree. The item provider would be stateless. However, because we are doing tricks - // here, we are keeping track of all items this provider manages. The key in the map is the - // object (EJBJar), and the value is the children nodes that we inserted - - protected Map children = new HashMap(); - private boolean showAssemblyDescriptor; - private boolean isDisposing; - - public GroupedEJBJarItemProvider(AdapterFactory adapterFactory, boolean showAssemblyDescriptor) { - super(adapterFactory); - this.showAssemblyDescriptor = showAssemblyDescriptor; - } - - public Collection getChildren(Object object) { - List result = initChildren(object); - if (showAssemblyDescriptor) { - if (((EJBJar) object).getAssemblyDescriptor() != null) - result.add(((EJBJar) object).getAssemblyDescriptor()); - } - return result; - } - - protected List initChildren(Object object) { - EJBJar ejbJar = (EJBJar) object; - List allRootBeans = getAllRootBeans(ejbJar); - - boolean is20Jar = is20Jar(ejbJar); - - List localChildren = new ArrayList(5); - - List entityBeans = new ArrayList(); - List sessionBeans = new ArrayList(); - List messageBeans = new ArrayList(); - - catagorizeBeans(allRootBeans, entityBeans, sessionBeans, messageBeans); - orderBeans(entityBeans); - orderBeans(sessionBeans); - orderBeans(messageBeans); - - //ENABLE FOR: NOT TO SHOW EMPTY GROUPS - //if (sessionBeans.size() > 0) { - if (sessionTable.get(ejbJar) == null) { - //create new item provider instance - sessionProvider = new GroupedSessionItemProvider(adapterFactory, null, getImage(SESSION), object, sessionBeans); - sessionTable.put(ejbJar, sessionProvider); - localChildren.add(sessionProvider); - } else { - //use existing instance from table - localChildren.add(sessionTable.get(ejbJar)); - } - //} - - //ENABLE FOR: NOT TO SHOW EMPTY GROUPS - //if (entityBeans.size() > 0) { - if (entityTable.get(ejbJar) == null) { - //create new item provider instance - entityProvider = new GroupedEntityItemProvider(adapterFactory, null, getImage(ENTITY), object, entityBeans); - entityTable.put(ejbJar, entityProvider); - localChildren.add(entityProvider); - } else { - //use existing instance from table - localChildren.add(entityTable.get(ejbJar)); - } - //} - - //ENABLE FOR: NOT TO SHOW EMPTY GROUPS - //if (is20Jar && messageBeans.size() > 0) { - if (is20Jar) { - if (messageTable.get(ejbJar) == null) { - //create new item provider instance - messageProvider = new GroupedMessageItemProvider(adapterFactory, null, getImage(MESSAGE), object, messageBeans); - messageTable.put(ejbJar, messageProvider); - localChildren.add(messageProvider); - } else { - //use existing instance from table - localChildren.add(messageTable.get(ejbJar)); - } - } - //} - - children.put(object, localChildren); - - return localChildren; - } - - protected void orderBeans(List beans) { - Object[] beansArray = beans.toArray(); - Arrays.sort(beansArray, EJBNameComparator.singleton()); - beans.clear(); - beans.addAll(Arrays.asList(beansArray)); - } - - protected static List getAllRootBeans(EJBJar ejbJar) { - return ejbJar.getEnterpriseBeans(); - } - - protected void catagorizeBeans(List allRootBeans, List entityBeans, List sessionBeans, List messageBeans) { - for (int i = 0; i < allRootBeans.size(); i++) { - if (((EnterpriseBean) allRootBeans.get(i)).isSession()) { - sessionBeans.add(allRootBeans.get(i)); - } else if (((EnterpriseBean) allRootBeans.get(i)).isEntity()) { - entityBeans.add(allRootBeans.get(i)); - } else if (((EnterpriseBean) allRootBeans.get(i)).isMessageDriven()) { - messageBeans.add(allRootBeans.get(i)); - } - } - } - - static protected GroupedSessionItemProvider getSessionNode(Object object) { - return (GroupedSessionItemProvider) sessionTable.get(object); - } - - static protected GroupedEntityItemProvider getEntityNode(Object object) { - return (GroupedEntityItemProvider) entityTable.get(object); - } - - static protected GroupedMessageItemProvider getMessageNode(Object object) { - return (GroupedMessageItemProvider) messageTable.get(object); - } - - public Object getImage(String type) { - if (type.equals(SESSION)) - return J2EEPlugin.getPlugin().getImage("sessionBean_obj"); //$NON-NLS-1$ - else if (type.equals(MESSAGE)) - return J2EEPlugin.getPlugin().getImage("message_bean_obj"); //$NON-NLS-1$ - else if (type.equals(ENTITY)) - return J2EEPlugin.getPlugin().getImage("entitybean_obj"); //$NON-NLS-1$ - else - return null; - } - - private boolean is20Jar(EJBJar ejbJar) { - switch (ejbJar.getVersionID()) { - case J2EEVersionConstants.EJB_1_0_ID : - case J2EEVersionConstants.EJB_1_1_ID : - return false; - case J2EEVersionConstants.EJB_2_0_ID : - case J2EEVersionConstants.EJB_2_1_ID : - default : - return true; - } - } - - public void notifyChanged(Notification notification) { - if (notification.getEventType() == Notification.REMOVING_ADAPTER && notification.getOldValue() == this && !isDisposing) { - removeTarget(notification); - return; - } - if (notification.getFeature() == EjbPackage.eINSTANCE.getEJBJar_EnterpriseBeans()) { - J2EEItemProvider provider = beansChanged((EJBJar) notification.getNotifier(), notification.getEventType(), notification.getOldValue(), notification.getNewValue(), notification.getPosition()); - - //EJB's group has not been added yet, need to add group to tree before EJB can be added - if (provider == null) { - Notification msg = new NotificationImpl(Notification.ADD, null, getEJBItemProvider((EnterpriseBean) notification.getNewValue()), 1); - NotificationWrapper notificationWrapper = new NotificationWrapper(notification.getNotifier(), msg); - fireNotifyChanged(notificationWrapper); - provider = beansChanged((EJBJar) notification.getNotifier(), notification.getEventType(), notification.getOldValue(), notification.getNewValue(), notification.getPosition()); - } - - //Fire notification for EJB add or remove - NotificationWrapper notificationWrapper = new NotificationWrapper(provider, notification); - fireNotifyChanged(notificationWrapper); - - //ENABLE FOR: NOT TO SHOW EMPTY GROUPS - //If Group is empty remove the group - /* - * if (provider != null && provider.getChildren().size() == 0) { Notification msg = new - * NotificationImpl(Notification.REMOVE, provider, null, 1); notificationWrapper = new - * NotificationWrapper(notification.getNotifier(), msg); - * fireNotifyChanged(notificationWrapper); - * - * //Group is removed so flush out table entry if (provider instanceof - * GroupedSessionItemProvider) { sessionTable.remove(notification.getNotifier()); - * provider = null; } else if (provider instanceof GroupedEntityItemProvider) { - * entityTable.remove(notification.getNotifier()); provider = null; } else if (provider - * instanceof GroupedMessageItemProvider) { - * messageTable.remove(notification.getNotifier()); provider = null; } - * - * //If all groups are removed remove the extended children List allChildren = new - * ArrayList(this.getChildren((EJBJar) notification.getNotifier())); - * if(sessionTable.get(notification.getNotifier()) == null && - * entityTable.get(notification.getNotifier()) == null && - * messageTable.get(notification.getNotifier()) == null) { for(int i = 0; i < - * allChildren.size(); i++) { Notification message = new - * NotificationImpl(Notification.REMOVE, allChildren.get(i), null, 1); - * notificationWrapper = new NotificationWrapper(notification.getNotifier(), message); - * fireNotifyChanged(notificationWrapper); } this.getChildren((EJBJar) - * notification.getNotifier()).clear(); } } - */ - } else { - super.notifyChanged(notification); - } - } - - protected J2EEItemProvider beansChanged(EJBJar ejbJar, int eventType, Object oldValue, Object newValue, int pos) { - J2EEItemProvider provider = getItemProvider(ejbJar, oldValue, newValue); - - if (provider != null) { - Collection grandChildren = provider.getChildren(); - - switch (eventType) { - case Notification.ADD : { - if (!grandChildren.contains(newValue)) - grandChildren.add(newValue); - - break; - } - case Notification.ADD_MANY : { - grandChildren.addAll((Collection) newValue); - break; - } - case Notification.REMOVE : { - grandChildren.remove(oldValue); - break; - } - case Notification.REMOVE_MANY : { - grandChildren.removeAll((Collection) oldValue); - break; - } - } - } else { - //GroupedProvider for new bean does not exist, create one. - List allRootBeans = getAllRootBeans(ejbJar); - - List entityBeans = new ArrayList(); - List sessionBeans = new ArrayList(); - List messageBeans = new ArrayList(); - - catagorizeBeans(allRootBeans, entityBeans, sessionBeans, messageBeans); - - if (newValue instanceof Session) { - sessionProvider = new GroupedSessionItemProvider(adapterFactory, null, getImage(SESSION), ejbJar, sessionBeans); - sessionTable.put(ejbJar, sessionProvider); - } else if (newValue instanceof Entity) { - entityProvider = new GroupedEntityItemProvider(adapterFactory, null, getImage(ENTITY), ejbJar, entityBeans); - entityTable.put(ejbJar, entityProvider); - } else if (newValue instanceof MessageDriven) { - messageProvider = new GroupedMessageItemProvider(adapterFactory, null, getImage(MESSAGE), ejbJar, messageBeans); - messageTable.put(ejbJar, messageProvider); - } - } - return provider; - } - - static public J2EEItemProvider getEJBJarItemProvider(EJBJar ejbJar, Object bean) { - J2EEItemProvider provider = null; - if (ejbJar != null && bean != null) { - if (bean instanceof Session) { - provider = getSessionNode(ejbJar); - } else if (bean instanceof Entity) { - provider = getEntityNode(ejbJar); - } else if (bean instanceof MessageDriven) { - provider = getMessageNode(ejbJar); - } - } - return provider; - } - - static public J2EEItemProvider getEJBItemProvider(EnterpriseBean bean) { - if (bean != null) { - EJBJar ejbJar = bean.getEjbJar(); - return getEJBJarItemProvider(ejbJar, bean); - } - return null; - } - - protected J2EEItemProvider getItemProvider(EJBJar ejbJar, Object oldValue, Object newValue) { - if (newValue != null) - return getEJBJarItemProvider(ejbJar, newValue); - else if (oldValue != null) - return getEJBJarItemProvider(ejbJar, oldValue); - else - return null; - } - - public static boolean isRootBean(EnterpriseBean bean) { - List allRootBeans = getAllRootBeans(bean.getEjbJar()); - if (allRootBeans != null && allRootBeans.contains(bean)) { - return true; - } - return false; - } - - // Utility method for garbage collection - if EJBJar removed, remove - // all entires in table for EJBJar - static public void flushOutTableEntriesForEJBJar(EJBJar ejbJar) { - sessionTable.remove(ejbJar); - entityTable.remove(ejbJar); - messageTable.remove(ejbJar); - } - - public boolean hasChildren(Object parent) { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.ejb.provider.EJBJarItemProvider#removeTarget(org.eclipse.emf.common.notify.Notification) - */ - protected void removeTarget(Notification not) { - if (not.getNotifier() instanceof EJBJar) - flushOutTableEntriesForEJBJar((EJBJar) not.getNotifier()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose() - */ - public void dispose() { - try { - isDisposing = true; - super.dispose(); - } finally { - isDisposing = false; - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEntityItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEntityItemProvider.java deleted file mode 100644 index 0dbb40b2d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedEntityItemProvider.java +++ /dev/null @@ -1,37 +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.ejb.provider; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - - -/** - * @author Sachin Patel - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class GroupedEntityItemProvider extends GroupedEJBItemProvider { - - public static final String ENTITY = J2EEUIMessages.getResourceString("Entity_UI_"); //$NON-NLS-1$ - - public GroupedEntityItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent, Collection children) { - super(adapterFactory, text, image, parent, children); - } - - public String getText(Object object) { - return ENTITY; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedMessageItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedMessageItemProvider.java deleted file mode 100644 index 6c977b2d2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedMessageItemProvider.java +++ /dev/null @@ -1,38 +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.ejb.provider; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - - - -/** - * @author Sachin Patel - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class GroupedMessageItemProvider extends GroupedEJBItemProvider { - - public static final String MESSAGE_BEANS = J2EEUIMessages.getResourceString("Message_Driven_Beans_UI_"); //$NON-NLS-1$ - - public GroupedMessageItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent, Collection children) { - super(adapterFactory, text, image, parent, children); - } - - public String getText(Object object) { - return MESSAGE_BEANS; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedSessionItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedSessionItemProvider.java deleted file mode 100644 index 15c28172c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/GroupedSessionItemProvider.java +++ /dev/null @@ -1,37 +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.ejb.provider; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - - -/** - * @author Sachin Patel - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class GroupedSessionItemProvider extends GroupedEJBItemProvider { - - public static final String SESSION_BEANS = J2EEUIMessages.getResourceString("Session_Beans_UI_"); //$NON-NLS-1$ - - public GroupedSessionItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent, Collection children) { - super(adapterFactory, text, image, parent, children); - } - - public String getText(Object object) { - return SESSION_BEANS; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/HomeInterfaceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/HomeInterfaceProviderHelper.java deleted file mode 100644 index 6c37abe75..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/HomeInterfaceProviderHelper.java +++ /dev/null @@ -1,60 +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.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -/** - * Insert the type's description here. Creation date: (6/20/2001 11:23:30 PM) - * - * @author: Administrator - */ -public class HomeInterfaceProviderHelper extends J2EEJavaClassProviderHelper { - private static Image image; - - /** - * HomeInterfaceProviderHelper constructor comment. - * - * @param cls - * org.eclipse.jem.internal.java.JavaClass - */ - public HomeInterfaceProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:53:49 PM) - * - * @return org.eclipse.jem.internal.java.JavaClass - */ - public JavaClass getJavaClass() { - return getEjb().getHomeInterface(); - } - - protected String getOverlayKey() { - return "home_interface_overlay_obj";//$NON-NLS-1$ - } - - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Home_Interface_UI_", new Object[]{className}); //$NON-NLS-1$ = "Home Interface" - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEContainerManagedEntityItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEContainerManagedEntityItemProvider.java deleted file mode 100644 index ec5f13c6b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEContainerManagedEntityItemProvider.java +++ /dev/null @@ -1,46 +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.ejb.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; - - -/** - * Insert the type's description here. Creation date: (6/20/2001 6:58:51 PM) - * - * @author: Administrator - */ -public class J2EEContainerManagedEntityItemProvider extends ContainerManagedEntityItemProvider { - /** - * J2EEContainerManagedEntityItemProvider constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - */ - public J2EEContainerManagedEntityItemProvider(EjbItemProviderAdapterFactory adapterFactory) { - super(adapterFactory); - } - - public Collection getChildren(Object object) { - List result = new ArrayList(); - result.addAll(super.getChildren(object)); - J2EEJavaClassProviderHelper.addChildren((ContainerManagedEntity) object, result); - result.addAll(((ContainerManagedEntity) object).getEnvironmentProperties()); - result.addAll(J2EEReferenceProviderHelper.getReferences((EnterpriseBean) object)); - return result; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEjbItemProviderAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEjbItemProviderAdapterFactory.java deleted file mode 100644 index f888d86cc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEjbItemProviderAdapterFactory.java +++ /dev/null @@ -1,80 +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.ejb.provider; - -import org.eclipse.emf.common.notify.Adapter; - - -/** - * Insert the type's description here. Creation date: (6/20/2001 7:20:07 PM) - * - * @author: Administrator - */ -public class J2EEEjbItemProviderAdapterFactory extends org.eclipse.jst.j2ee.internal.ejb.provider.EjbItemProviderAdapterFactory { - /** - * J2EEEjbItemProviderAdapterFactory constructor comment. - */ - public J2EEEjbItemProviderAdapterFactory() { - super(); - } - - /** - * This creates an adapter for a - * {@link org.eclipse.jst.j2ee.internal.internal.ejb.ContainerManagedEntity}. - */ - public Adapter createContainerManagedEntityAdapter() { - if (containerManagedEntityItemProvider == null) { - containerManagedEntityItemProvider = new J2EEContainerManagedEntityItemProvider(this); - } - - return containerManagedEntityItemProvider; - } - - /** - * This creates an adapter for a {@link org.eclipse.jst.j2ee.internal.internal.ejb.EJBJar}. - */ - public Adapter createEJBJarAdapter() { - if (eJBJarItemProvider == null) { - eJBJarItemProvider = new GroupedEJBJarItemProvider(this, true); - } - - return eJBJarItemProvider; - } - - /** - * This creates an adapter for a {@link org.eclipse.jst.j2ee.internal.internal.ejb.Entity}. - */ - public Adapter createEntityAdapter() { - if (entityItemProvider == null) { - entityItemProvider = new J2EEEntityItemProvider(this); - } - - return entityItemProvider; - } - - /** - * This creates an adapter for a {@link org.eclipse.jst.j2ee.internal.internal.ejb.Session}. - */ - public Adapter createSessionAdapter() { - if (sessionItemProvider == null) { - sessionItemProvider = new J2EESessionItemProvider(this); - } - - return sessionItemProvider; - } - - public Adapter createMessageDrivenAdapter() { - if (messageDrivenItemProvider == null) { - messageDrivenItemProvider = new J2EEMessageDrivenItemProvider(this); - } - return messageDrivenItemProvider; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEntityItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEntityItemProvider.java deleted file mode 100644 index 037d4d67e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEEntityItemProvider.java +++ /dev/null @@ -1,43 +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.ejb.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jst.j2ee.ejb.Entity; - - -/** - * Insert the type's description here. Creation date: (6/20/2001 11:10:06 PM) - * - * @author: Administrator - */ -public class J2EEEntityItemProvider extends EntityItemProvider { - /** - * J2EEEntityItemProvider constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - */ - public J2EEEntityItemProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory) { - super(adapterFactory); - } - - public Collection getChildren(Object object) { - List result = new ArrayList(); - result.addAll(super.getChildrenSuper(object)); - J2EEJavaClassProviderHelper.addChildren((Entity) object, result); - return result; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEJavaClassProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEJavaClassProviderHelper.java deleted file mode 100644 index 00fe427db..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEJavaClassProviderHelper.java +++ /dev/null @@ -1,146 +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.ejb.provider; - - -import java.util.Collection; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.Entity; -import org.eclipse.jst.j2ee.internal.plugin.J2EEEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.common.frameworks.internal.ui.OverlayIcon; - -public abstract class J2EEJavaClassProviderHelper implements IAdaptable { - private EnterpriseBean ejb; - public static final Class IRESOURCE_CLASS = IResource.class; - public static final Class IPROJECT_CLASS = IProject.class; - - /** - * J2EEJavaClassProviderHelper constructor comment. - */ - public J2EEJavaClassProviderHelper(EnterpriseBean anEJB) { - super(); - setEjb(anEJB); - } - - public static void addChildren(Entity ejb, Collection children) { - addChildren((EnterpriseBean) ejb, children); - if (ejb.getPrimaryKey() != null) - children.add(new PrimaryKeyClassProviderHelper(ejb)); - } - - public static void addChildren(EnterpriseBean ejb, Collection children) { - - if (ejb.getHomeInterface() != null) - children.add(new HomeInterfaceProviderHelper(ejb)); - if (ejb.getRemoteInterface() != null) - children.add(new RemoteInterfaceProviderHelper(ejb)); - if (ejb.getLocalHomeInterface() != null) - children.add(new LocalHomeInterfaceProviderHelper(ejb)); - if (ejb.getLocalInterface() != null) - children.add(new LocalInterfaceProviderHelper(ejb)); - if (ejb.getEjbClass() != null) - children.add(new BeanClassProviderHelper(ejb)); - } - - protected Image createImage() { - ImageDescriptor base = J2EEUIPlugin.getDefault().getImageDescriptor("jcu_obj");//$NON-NLS-1$ - if (base == null) - return null; - ImageDescriptor overlay = getOverlayDescriptor(); - if (overlay == null) - return base.createImage(); - return new OverlayIcon(base, new ImageDescriptor[][]{{overlay}}).createImage(); - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:47:24 PM) - * - * @return org.eclipse.jst.j2ee.internal.internal.ejb.EnterpriseBean - */ - public org.eclipse.jst.j2ee.ejb.EnterpriseBean getEjb() { - return ejb; - } - - public Image getImage() { - return null; - } - - /** - * Insert the method's description here. Creation date: (6/20/2001 10:30:54 PM) - * - * @return JavaClass - */ - public abstract JavaClass getJavaClass(); - - protected ImageDescriptor getOverlayDescriptor() { - return J2EEUIPlugin.getDefault().getImageDescriptor(getOverlayKey()); - } - - protected abstract String getOverlayKey(); - - protected IProject getProject() { - return ProjectUtilities.getProject(getJavaClass()); - } - - public String getStatusLineMessage() { - if (getJavaClass() != null) - return getTypeString(getJavaClass().getQualifiedName()); - return ""; //$NON-NLS-1$ - } - - public String getText() { - if (getJavaClass() != null) - return getJavaClass().getName(); - return ""; //$NON-NLS-1$ - } - - public abstract String getTypeString(String className); - - public void openInEditor() { - IProject project = ProjectUtilities.getProject(getJavaClass()); - try { - J2EEEditorUtility.openInEditor(getJavaClass(), project); - } catch (Exception cantOpen) { - //Ignore - } - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:47:24 PM) - * - * @param newEjb - * org.eclipse.jst.j2ee.internal.internal.ejb.EnterpriseBean - */ - public void setEjb(org.eclipse.jst.j2ee.ejb.EnterpriseBean newEjb) { - ejb = newEjb; - } - - /** - * @see IAdaptable#EcoreUtil.getAdapter(eAdapters(),Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IRESOURCE_CLASS) - return J2EEEditorUtility.getFile(getJavaClass()); - if (adapter == IPROJECT_CLASS) - return getProject(); - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEMessageDrivenItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEMessageDrivenItemProvider.java deleted file mode 100644 index a01558641..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEMessageDrivenItemProvider.java +++ /dev/null @@ -1,40 +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.ejb.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jst.j2ee.ejb.MessageDriven; - - -/** - * @author jsholl - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class J2EEMessageDrivenItemProvider extends MessageDrivenItemProvider { - - public J2EEMessageDrivenItemProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory) { - super(adapterFactory); - } - - public Collection getChildren(Object object) { - List result = new ArrayList(); - result.addAll(super.getChildrenSuper(object)); - J2EEJavaClassProviderHelper.addChildren((MessageDriven) object, result); - return result; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEReferenceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEReferenceProviderHelper.java deleted file mode 100644 index b8b894876..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EEReferenceProviderHelper.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on May 6, 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.ejb.provider; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; - - -/** - * @author jsholl - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class J2EEReferenceProviderHelper { - - public static Collection getReferences(EnterpriseBean bean) { - List result = new ArrayList(); - if (!bean.getEjbRefs().isEmpty()) - result.addAll(bean.getEjbRefs()); - if (!bean.getEjbLocalRefs().isEmpty()) - result.addAll(bean.getEjbLocalRefs()); - if (!bean.getResourceRefs().isEmpty()) - result.addAll(bean.getResourceRefs()); - if (!bean.getSecurityRoleRefs().isEmpty()) - result.addAll(bean.getSecurityRoleRefs()); - if (!bean.getResourceEnvRefs().isEmpty()) - result.addAll(bean.getResourceEnvRefs()); - return result; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EESessionItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EESessionItemProvider.java deleted file mode 100644 index d64d2751b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/J2EESessionItemProvider.java +++ /dev/null @@ -1,54 +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.ejb.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jst.j2ee.ejb.Session; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; - - -/** - * Insert the type's description here. Creation date: (6/20/2001 11:10:48 PM) - * - * @author: Administrator - */ -public class J2EESessionItemProvider extends org.eclipse.jst.j2ee.internal.ejb.provider.SessionItemProvider { - /** - * J2EESessionItemProvider constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - */ - public J2EESessionItemProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory) { - super(adapterFactory); - } - - public Collection getChildren(Object object) { - List result = new ArrayList(); - result.addAll(super.getChildrenSuper(object)); - addServiceEndpointInterface((Session) object, result); - J2EEJavaClassProviderHelper.addChildren((Session) object, result); - return result; - } - - /** - * @param session - * @param result - */ - private void addServiceEndpointInterface(Session session, Collection children) { - if (session.getVersionID() >= J2EEVersionConstants.EJB_2_1_ID && session.getServiceEndpoint() != null) - children.add(new ServiceEndpointInterfaceProviderHelper(session)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalHomeInterfaceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalHomeInterfaceProviderHelper.java deleted file mode 100644 index cfea51ac7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalHomeInterfaceProviderHelper.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -public class LocalHomeInterfaceProviderHelper extends J2EEJavaClassProviderHelper { - - private static Image image; - - /** - * Constructor for LocalHomeInterfaceProviderHelper. - * - * @param anEJB - */ - public LocalHomeInterfaceProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - /** - * @see J2EEJavaClassProviderHelper#getJavaClass() - */ - public JavaClass getJavaClass() { - return getEjb().getLocalHomeInterface(); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * @see J2EEJavaClassProviderHelper#getOverlayKey() - */ - protected String getOverlayKey() { - return "local_home_interface_overlay_obj"; //$NON-NLS-1$ - } - - /** - * @see J2EEJavaClassProviderHelper#getTypeString(String) - */ - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Local_Home_Interface_UI_", new Object[]{className}); //$NON-NLS-1$ = "Local Home Interface"; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalInterfaceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalInterfaceProviderHelper.java deleted file mode 100644 index 9a9af2dcb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/LocalInterfaceProviderHelper.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - **************************************************************************************************/ -package org.eclipse.jst.j2ee.internal.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -public class LocalInterfaceProviderHelper extends J2EEJavaClassProviderHelper { - - private static Image image; - - /** - * Constructor for LocalInterfaceProviderHelper. - * - * @param anEJB - */ - public LocalInterfaceProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * @see J2EEJavaClassProviderHelper#getJavaClass() - */ - public JavaClass getJavaClass() { - return getEjb().getLocalInterface(); - } - - /** - * @see J2EEJavaClassProviderHelper#getOverlayKey() - */ - protected String getOverlayKey() { - return "local_interface_overlay_obj";//$NON-NLS-1$ - } - - /** - * @see J2EEJavaClassProviderHelper#getTypeString(String) - */ - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Local_Interface_UI_", new Object[]{className}); //$NON-NLS-1$ = "Local Interface" - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodPermissionsContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodPermissionsContentProvider.java deleted file mode 100644 index e2109e970..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodPermissionsContentProvider.java +++ /dev/null @@ -1,129 +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.ejb.provider; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor; -import org.eclipse.jst.j2ee.ejb.CMPAttribute; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.MethodPermission; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; - - -public class MethodPermissionsContentProvider extends AbstractMethodsContentProvider { - private static final EStructuralFeature PERMISSION_MES_SF = EjbFactoryImpl.getPackage().getMethodPermission_MethodElements(); - private static final EStructuralFeature PERMISSION_MES_UNCHECKED_SF = EjbFactoryImpl.getPackage().getMethodPermission_Unchecked(); - private static final EStructuralFeature PERMISSION_MES_ROLES_SF = EjbFactoryImpl.getPackage().getMethodPermission_Roles(); - private static final EStructuralFeature AD_MP_SF = EjbFactoryImpl.getPackage().getAssemblyDescriptor_MethodPermissions(); - - /** - * Constructor for MethodPermissionsContentProvider. - * - * @param adapterFactory - * @param root - * @param viewer - */ - public MethodPermissionsContentProvider(AdapterFactory adapterFactory, boolean root) { - super(adapterFactory, root); - } - - /** - * Constructor for MethodPermissionsContentProvider. - * - * @param adapterFactory - */ - public MethodPermissionsContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof MethodPermission) - return getEnterpriseBeans((MethodPermission) parentElement); - return super.getChildren(parentElement); - } - - protected Object[] getEnterpriseBeans(MethodPermission mp) { - List mes = mp.getMethodElements(); - return getEnterpriseBeans(mp, mes); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElements(EObject, EnterpriseBean) - */ - protected List getMethodElements(EObject aRefObject, EnterpriseBean anEJB) { - if (!(aRefObject instanceof MethodPermission)) - return Collections.EMPTY_LIST; - MethodPermission parentMP = (MethodPermission) aRefObject; - if (parentMP == null) - return Collections.EMPTY_LIST; - return parentMP.getMethodElements(anEJB); - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - super.getElements(inputElement); - if (inputElement instanceof EJBJar) { - EJBJar jar = (EJBJar) inputElement; - if (jar.getAssemblyDescriptor() != null) - return jar.getAssemblyDescriptor().getMethodPermissions().toArray(); - } - if (inputElement instanceof AssemblyDescriptor) - return ((AssemblyDescriptor) inputElement).getMethodPermissions().toArray(); - return new Object[0]; - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof MethodPermission) - return !((MethodPermission) element).getMethodElements().isEmpty(); - return super.hasChildren(element); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElementsReference() - */ - protected EStructuralFeature getMethodElementsReference() { - return PERMISSION_MES_SF; - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.ejb.ui.providers.AbstractMethodsContentProvider#getMethodElementsContainerReference() - */ - protected EStructuralFeature getMethodElementsContainerReference() { - return AD_MP_SF; - } - - /** - * @see org.eclipse.emf.edit.provider.INotifyChangedListener#notifyChanged(Notification) - */ - public void notifyChanged(Notification notification) { - if (notification.getFeature() == PERMISSION_MES_SF || notification.getFeature() == AD_MP_SF) - refreshTreeViewer(); - else if (notification.getOldValue() instanceof CMPAttribute && notification.getNewValue() == null) - return; - if (notification.getFeature() == PERMISSION_MES_UNCHECKED_SF || notification.getFeature() == PERMISSION_MES_ROLES_SF || notification.getFeature() == getMethodElementsReference() || notification.getFeature() == getMethodElementsContainerReference()) - super.notifyChanged(notification); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodTransactionContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodTransactionContentProvider.java deleted file mode 100644 index fe0e1b797..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/MethodTransactionContentProvider.java +++ /dev/null @@ -1,117 +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.ejb.provider; - - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.MethodTransaction; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; - - -public class MethodTransactionContentProvider extends AbstractMethodsContentProvider { - private static final EStructuralFeature TRANSACTION_MES_SF = EjbFactoryImpl.getPackage().getMethodTransaction_MethodElements(); - private static final EStructuralFeature AD_MT_SF = EjbFactoryImpl.getPackage().getAssemblyDescriptor_MethodTransactions(); - - /** - * Constructor for MethodTransactionContentProvider. - * - * @param adapterFactory - * @param root - * @param viewer - */ - public MethodTransactionContentProvider(AdapterFactory adapterFactory, boolean root) { - super(adapterFactory, root); - } - - /** - * Constructor for MethodTransationContentProvider. - * - * @param adapterFactory - */ - public MethodTransactionContentProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof MethodTransaction) - return getEnterpriseBeans((MethodTransaction) parentElement); - return super.getChildren(parentElement); - } - - protected Object[] getEnterpriseBeans(MethodTransaction mt) { - List mes = mt.getMethodElements(); - return getEnterpriseBeans(mt, mes); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElements(EObject, EnterpriseBean) - */ - protected List getMethodElements(EObject aRefObject, EnterpriseBean anEJB) { - if (!(aRefObject instanceof MethodTransaction)) - return Collections.EMPTY_LIST; - MethodTransaction parentMT = (MethodTransaction) aRefObject; - if (parentMT == null) - return Collections.EMPTY_LIST; - return parentMT.getMethodElements(anEJB); - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - super.getElements(inputElement); - if (inputElement instanceof EJBJar) { - EJBJar jar = (EJBJar) inputElement; - if (jar.getAssemblyDescriptor() != null) - return jar.getAssemblyDescriptor().getMethodTransactions().toArray(); - } - if (inputElement instanceof AssemblyDescriptor) - return ((AssemblyDescriptor) inputElement).getMethodTransactions().toArray(); - return new Object[0]; - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof MethodTransaction) - return !((MethodTransaction) element).getMethodElements().isEmpty(); - return super.hasChildren(element); - } - - /* - * @see AbstractMethodsContentProvider#getMethodElementsReference() - */ - protected EStructuralFeature getMethodElementsReference() { - return TRANSACTION_MES_SF; - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.ejb.ui.providers.AbstractMethodsContentProvider#getMethodElementsContainerReference() - */ - protected EStructuralFeature getMethodElementsContainerReference() { - return AD_MT_SF; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/PrimaryKeyClassProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/PrimaryKeyClassProviderHelper.java deleted file mode 100644 index a2893b519..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/PrimaryKeyClassProviderHelper.java +++ /dev/null @@ -1,61 +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.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.Entity; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -/** - * Insert the type's description here. Creation date: (6/21/2001 12:28:55 AM) - * - * @author: Administrator - */ -public class PrimaryKeyClassProviderHelper extends J2EEJavaClassProviderHelper { - private static Image image; - - /** - * PrimaryKeyClassProviderHelper constructor comment. - * - * @param cls - * org.eclipse.jem.internal.java.JavaClass - */ - public PrimaryKeyClassProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:54:22 PM) - * - * @return org.eclipse.jem.internal.java.JavaClass - */ - public JavaClass getJavaClass() { - return ((Entity) getEjb()).getPrimaryKey(); - } - - protected String getOverlayKey() { - return "key_interf_ov";//$NON-NLS-1$ - } - - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Primary_Key_Class_UI_", new Object[]{className}); //$NON-NLS-1$ = "Primary Key Class" - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/RemoteInterfaceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/RemoteInterfaceProviderHelper.java deleted file mode 100644 index 3fcb79009..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/RemoteInterfaceProviderHelper.java +++ /dev/null @@ -1,60 +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.ejb.provider; - - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -/** - * Insert the type's description here. Creation date: (6/21/2001 12:28:12 AM) - * - * @author: Administrator - */ -public class RemoteInterfaceProviderHelper extends J2EEJavaClassProviderHelper { - private static Image image; - - /** - * RemoteInterfaceProviderHelper constructor comment. - * - * @param cls - * org.eclipse.jem.internal.java.JavaClass - */ - public RemoteInterfaceProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:55:48 PM) - * - * @return org.eclipse.jem.internal.java.JavaClass - */ - public JavaClass getJavaClass() { - return getEjb().getRemoteInterface(); - } - - protected String getOverlayKey() { - return "remote_interface_overlay_obj";//$NON-NLS-1$ - } - - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Remote_Interface_UI_", new Object[]{className}); //$NON-NLS-1$ = "Remote Interface" - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ServiceEndpointInterfaceProviderHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ServiceEndpointInterfaceProviderHelper.java deleted file mode 100644 index 5ad2b0c2e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ejb/provider/ServiceEndpointInterfaceProviderHelper.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Mar 19, 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.ejb.provider; - -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.ejb.Session; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; - - -/** - * @author dfholttp - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class ServiceEndpointInterfaceProviderHelper extends J2EEJavaClassProviderHelper { - private static Image image; - - /** - * @param anEJB - */ - public ServiceEndpointInterfaceProviderHelper(EnterpriseBean anEJB) { - super(anEJB); - } - - public Image getImage() { - if (image == null) - image = createImage(); - return image; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 1:53:49 PM) - * - * @return org.eclipse.jem.internal.java.JavaClass - */ - public JavaClass getJavaClass() { - return ((Session) getEjb()).getServiceEndpoint(); - } - - protected String getOverlayKey() { - //TODO: DFH we need an icon - return "";//$NON-NLS-1$ - } - - public String getTypeString(String className) { - return J2EEUIMessages.getResourceString("Service_Endpoint_Interface_UI_", new Object[]{className}); //$NON-NLS-1$ = "Home Interface" - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/IValidateEditListener.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/IValidateEditListener.java deleted file mode 100644 index 0544eb584..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/IValidateEditListener.java +++ /dev/null @@ -1,43 +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.listeners; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.swt.events.ShellListener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IPartListener; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter; - - -public interface IValidateEditListener extends ResourceStateValidatorPresenter, IPartListener, ShellListener { - /** - * This method should be called by any action that is about to edit any contents of any IFile. - */ - public IStatus validateState(); - - /** - * Return true if there are any read only IFiles that are being managed. - * - * @return boolean - * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#getResources() - */ - boolean hasReadOnlyFiles(); - - /** - * This method should be called prior to saving the contents. It returns true if the contents - * can be saved. - */ - boolean checkSave() throws CoreException; - - /** - * Use this method to set the Shell that will be used to prompt to the user. - */ - void setShell(Shell aShell); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/ValidateEditListener.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/ValidateEditListener.java deleted file mode 100644 index d8c8a9636..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/listeners/ValidateEditListener.java +++ /dev/null @@ -1,330 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.listeners; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.dialogs.ListMessageDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.IValidateEditContext; -import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidator; - -public class ValidateEditListener extends ShellAdapter implements IValidateEditListener, IValidateEditContext { - - protected ResourceStateValidator fValidator; - private boolean fNeedsStateValidation = true; - private Shell fShell; - private IWorkbenchPart fPart; - private boolean fHasReadOnlyFiles = false; - private boolean firstReadOnlyFileAttempt = true; - private boolean fMessageUp = false; - private boolean fIsActivating = false; - private boolean fIsDeactivating = false; - private boolean inconsistentResult; - private boolean inconsistentOverwriteResult; - - public ValidateEditListener() { - super(); - try { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - IWorkbench wb = PlatformUI.getWorkbench(); - if (wb == null) return; - IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); - if (window == null && wb.getWorkbenchWindowCount()>0) { - for (int i=0; i<wb.getWorkbenchWindows().length; i++) { - window = wb.getWorkbenchWindows()[i]; - if (window != null) - break; - } - - } - if (window!=null) - setShell(window.getShell()); - } - }); - - } catch (Exception e) { - e.printStackTrace(); - } - } - /** - * Constructor for ValidateEditHandler. - */ - public ValidateEditListener(IWorkbenchPart part, ResourceStateValidator aValidator) { - super(); - fPart = part; - fValidator = aValidator; - if (part != null) - part.getSite().getPage().addPartListener(this); - if (getShell() != null) - getShell().addShellListener(this); - } - - protected Shell getShell() { - if (fShell == null) { - if (fPart != null && fPart.getSite() != null) - fShell = fPart.getSite().getShell(); - } - return fShell; - } - - /** - * @see IValidateEditListener#getValidator() - */ - public ResourceStateValidator getValidator() { - return fValidator; - } - - /** - * @see IValidateEditListener#getNeedsStateValidation() - */ - public boolean getNeedsStateValidation() { - return fNeedsStateValidation; - } - - /** - * @see IValidateEditListener#setNeedsStateValidation(boolean) - */ - public void setNeedsStateValidation(boolean needsStateValidation) { - fNeedsStateValidation = needsStateValidation; - } - - /** - * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter#promptForInconsistentFileRefresh(List) - */ - public boolean promptForInconsistentFileRefresh(List inconsistentFiles) { - if (inconsistentFiles == null || inconsistentFiles.size() == 0) // this case should never - // occur. - return false; - - List inconsistentFileNames = new ArrayList(); - for (int i = 0; inconsistentFiles.size() > i; i++) { - Object file = inconsistentFiles.get(i); - if (file instanceof Resource) { - IFile aFile = WorkbenchResourceHelper.getFile((Resource) file); - inconsistentFileNames.add(aFile.getFullPath().toOSString()); - } else if (file instanceof IResource) { - IResource resfile = (IResource) file; - if (!resfile.exists()) { - return false; - } - inconsistentFileNames.add(resfile.getFullPath().toOSString()); - } - } - - final String title = J2EEUIMessages.getResourceString("Inconsistent_Files_3"); //$NON-NLS-1$ - final String message = J2EEUIMessages.getResourceString("The_following_workspace_files_are_inconsistent_with_the_editor_4") + J2EEUIMessages.getResourceString("Update_the_editor_with_the_workspace_contents__5"); //$NON-NLS-1$ //$NON-NLS-2$ - final String[] fileNames = (String[])inconsistentFileNames.toArray(new String[inconsistentFileNames.size()]); - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - inconsistentResult = ListMessageDialog.openQuestion(getShell(), title, message, fileNames); - } - }); - return inconsistentResult; - } - - /** - * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter#getValidateEditContext() - */ - public Object getValidateEditContext() { - return getShell(); - } - - /** - * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - if (part == fPart) { - handleActivation(); - } - } - - protected void handleActivation() { - if (fIsActivating) - return; - fIsActivating = true; - try { - fValidator.checkActivation(this); - updatePartReadOnly(); - } catch (CoreException e) { - // do nothing for now - } finally { - fIsActivating = false; - } - } - - /** - * @see org.eclipse.swt.events.ShellListener#shellActivated(ShellEvent) - */ - public void shellActivated(ShellEvent event) { - handleActivation(); - } - - /** - * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) { - //do nothing - } - - /** - * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - if (part == fPart) - part.getSite().getPage().removePartListener(this); - if (getShell() != null) - getShell().removeShellListener(this); - } - - /** - * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) { - if (part == fPart) { - if (fIsDeactivating) - return; - fIsDeactivating = true; - try { - fValidator.lostActivation(this); - updatePartReadOnly(); - } catch (CoreException e) { - // do nothing for now - } finally { - fIsDeactivating = true; - } - } - } - - /** - * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) { - //do nothing - } - - public IStatus validateState() { - IWorkbench wb = PlatformUI.getWorkbench(); - if ((fShell==null) && (wb != null && (wb.getActiveWorkbenchWindow() != null))) - fShell=wb.getActiveWorkbenchWindow().getShell(); - if (fNeedsStateValidation) { - setNeedsStateValidation(false); - try { - final IStatus status = fValidator.validateState(this); - if (status.getSeverity() == IStatus.ERROR) { - setNeedsStateValidation(true); - if (!fMessageUp) { - fMessageUp = true; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - MessageDialog.openError(getShell(), J2EEUIMessages.getResourceString("Error_checking_out_files_10"), status.getMessage()); //$NON-NLS-1$ - } - }); - fMessageUp = false; - } - } - fValidator.checkActivation(this); - updatePartReadOnly(); - return status; - } catch (CoreException e) { - // do nothing for now - } - } - return ResourceStateValidator.OK_STATUS; - } - - /** - * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter#promptForInconsistentFileOverwrite(List) - */ - public boolean promptForInconsistentFileOverwrite(List inconsistentFiles) { - int size = inconsistentFiles.size(); - List files = new ArrayList(); - IFile file = null; - for (int i = 0; i < size; i++) { - file = (IFile) inconsistentFiles.get(i); - files.add(file.getFullPath().toString()); - } - final String[] items = (String[])files.toArray(new String[files.size()]); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - inconsistentOverwriteResult = ListMessageDialog.openQuestion(getShell(), J2EEUIMessages.getResourceString("Inconsistent_files_detected_11"), //$NON-NLS-1$ - J2EEUIMessages.getResourceString("The_following_files_are_inconsistent_with_the_file_system._Do_you_want_to_save_and_overwrite_these_files_on_the_file_system__12_WARN_"), //$NON-NLS-1$ - items); - } - }); - return inconsistentOverwriteResult; - } - - protected boolean checkReadOnly() { - fHasReadOnlyFiles = fValidator.checkReadOnly(); - return fHasReadOnlyFiles; - } - - /** - * @see IValidateEditListener#hasReadOnlyFiles() - */ - public boolean hasReadOnlyFiles() { - if (firstReadOnlyFileAttempt) { - checkReadOnly(); - firstReadOnlyFileAttempt = false; - } - return fHasReadOnlyFiles; - } - - /** - * Method updatePartReadOnly. - */ - protected void updatePartReadOnly() { - if (!getNeedsStateValidation()) { - checkReadOnly(); - setNeedsStateValidation(true); - } else { //So that J2EEXMLActionBarContributor get updated info when editor Activated. - firstReadOnlyFileAttempt = true; - } - } - - public boolean checkSave() throws CoreException { - return validateState().isOK() && getValidator().checkSave(this); - } - - public void setShell(Shell aShell) { - fShell = aShell; - } - - public void setEditModel(EditModel anEditModel) { - fValidator = anEditModel; - - } - - public IStatus validateState(EditModel anEditModel) { - setEditModel(anEditModel); - return validateState(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/perspective/J2EEPerspective.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/perspective/J2EEPerspective.java deleted file mode 100644 index f181cdb39..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/perspective/J2EEPerspective.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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 7, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.perspective; - -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IProgressConstants; -import org.eclipse.ui.views.IViewDescriptor; - -/** - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class J2EEPerspective implements org.eclipse.ui.IPerspectiveFactory { - - protected static String ID_SERVERS_VIEW = "org.eclipse.wst.server.ui.ServersView"; //$NON-NLS-1$ - protected static String ID_J2EE_HIERARCHY_VIEW = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$ - - private static String ID_WST_SNIPPETS_VIEW = "org.eclipse.wst.common.snippets.internal.ui.SnippetsView"; //$NON-NLS-1$ - private static final String ID_SEARCH_VIEW = "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$ - private static final String ID_DATA_VIEW = "org.eclipse.datatools.connectivity.DataSourceExplorerNavigator"; //$NON-NLS-1$ - public static final String ID_CONSOLE_VIEW= "org.eclipse.ui.console.ConsoleView"; //$NON-NLS-1$ - public static final String ID_MARKERS_VIEW= "org.eclipse.ui.views.AllMarkersView"; - public static final String ID_TASKLIST_VIEW= "org.eclipse.mylyn.tasks.ui.views.tasks"; - - public J2EEPerspective() { - super(); - //If preference exists for alternate view, replace. - String viewerID = J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.ID_PERSPECTIVE_HIERARCHY_VIEW); - if (viewerID != null) - ID_J2EE_HIERARCHY_VIEW = viewerID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout) - */ - public void createInitialLayout(IPageLayout layout) { - defineLayout(layout); - defineActions(layout); - } - - - - public void defineActions(IPageLayout layout) { - layout.addActionSet("org.eclipse.jst.j2ee.J2eeMainActionSet"); //$NON-NLS-1$ - layout.addActionSet("org.eclipse.jdt.ui.JavaActionSet"); //$NON-NLS-1$ - - layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); - layout.addActionSet(IDebugUIConstants.DEBUG_ACTION_SET); - - layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); - - layout.addShowViewShortcut(ID_J2EE_HIERARCHY_VIEW); - layout.addShowViewShortcut(ID_SERVERS_VIEW); - layout.addShowViewShortcut(ID_DATA_VIEW); - layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS); - layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); - layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET); - layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); - layout.addShowViewShortcut(ID_WST_SNIPPETS_VIEW); - layout.addShowViewShortcut(ID_MARKERS_VIEW); - layout.addShowViewShortcut(ID_TASKLIST_VIEW); - - // views - search - layout.addShowViewShortcut(ID_SEARCH_VIEW); - // views - debugging - layout.addShowViewShortcut(ID_CONSOLE_VIEW); - - layout.addShowInPart(ID_J2EE_HIERARCHY_VIEW); - } - - public void defineLayout(IPageLayout layout) { - // Editors are placed for free. - String editorArea = layout.getEditorArea(); - - // Top left. - IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, editorArea);//$NON-NLS-1$ - topLeft.addView(ID_J2EE_HIERARCHY_VIEW); - topLeft.addPlaceholder(IPageLayout.ID_RES_NAV); - topLeft.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY); - topLeft.addPlaceholder(JavaUI.ID_PACKAGES_VIEW); - - // Bottom right. - IFolderLayout bottomRight = layout.createFolder("bottomRight", IPageLayout.BOTTOM, 0.7f, editorArea);//$NON-NLS-1$ - bottomRight.addView(ID_MARKERS_VIEW); - bottomRight.addView(IPageLayout.ID_PROP_SHEET); - bottomRight.addView(ID_SERVERS_VIEW); - addDBViewIfPresent(layout,bottomRight); - bottomRight.addView(ID_WST_SNIPPETS_VIEW); - - bottomRight.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW); - bottomRight.addPlaceholder(IPageLayout.ID_TASK_LIST); - bottomRight.addPlaceholder(ID_CONSOLE_VIEW); - bottomRight.addPlaceholder(IPageLayout.ID_BOOKMARKS); - bottomRight.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); - bottomRight.addPlaceholder(ID_SEARCH_VIEW); - - // Top right. - IFolderLayout topRight = layout.createFolder("topRight", IPageLayout.RIGHT, 0.7f, editorArea);//$NON-NLS-1$ - topRight.addView(IPageLayout.ID_OUTLINE); - addTLViewIfPresent(layout, topRight); - - } - private void addDBViewIfPresent(IPageLayout page,IFolderLayout bottomRight) { - // TODO Auto-generated method stub - IViewDescriptor dbView = PlatformUI.getWorkbench().getViewRegistry().find(ID_DATA_VIEW); - if (dbView != null) - bottomRight.addView(ID_DATA_VIEW); - } - private void addTLViewIfPresent(IPageLayout page,IFolderLayout topRight) { - // TODO Auto-generated method stub - IViewDescriptor tlView = PlatformUI.getWorkbench().getViewRegistry().find(ID_TASKLIST_VIEW); - if (tlView != null) - topRight.addView(ID_TASKLIST_VIEW); - } -} - - - diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/BinaryEditorUtilities.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/BinaryEditorUtilities.java deleted file mode 100644 index 143a99a46..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/BinaryEditorUtilities.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.plugin; - -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.jdt.core.IJavaModelStatusConstants; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.JavaModelManager; -import org.eclipse.jdt.internal.core.JavaModelStatus; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jee.archive.internal.ArchiveUtil; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IPersistableElement; -import org.eclipse.ui.IStorageEditorInput; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; - -public class BinaryEditorUtilities { - - private static class JarEntryFile extends PlatformObject implements - IStorage { - private String entryName; - private String zipName; - private IPath path; - - public JarEntryFile(String entryName, String zipName) { - this.entryName = entryName; - this.zipName = zipName; - this.path = new Path(this.entryName); - } - - public InputStream getContents() throws CoreException { - - try { - if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - //$ANALYSIS-IGNORE - System.out.println("(" + Thread.currentThread() + ") [JarEntryFile.getContents()] Creating ZipFile on " + this.zipName); - } - ZipFile zipFile = ArchiveUtil.newZipFile(this.zipName); - ZipEntry zipEntry = zipFile.getEntry(this.entryName); - if (zipEntry == null) { - throw new JavaModelException(new JavaModelStatus( - IJavaModelStatusConstants.INVALID_PATH, - this.entryName)); - } - return zipFile.getInputStream(zipEntry); - } catch (IOException e) { - throw new JavaModelException(e, - IJavaModelStatusConstants.IO_EXCEPTION); - } - } - - /** - * @see IStorage#getFullPath - */ - public IPath getFullPath() { - return this.path; - } - - /** - * @see IStorage#getName - */ - public String getName() { - return this.path.lastSegment(); - } - - /** - * @see IStorage#isReadOnly() - */ - public boolean isReadOnly() { - return true; - } - - /** - * @see IStorage#isReadOnly() - */ - public String toString() { - return "JarEntryFile[" + this.zipName + "::" + this.entryName + "]"; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$ - } - } - - private static class JarEntryEditorInput implements IStorageEditorInput { - - private IStorage fJarEntryFile; - - public JarEntryEditorInput(IStorage jarEntryFile) { - fJarEntryFile = jarEntryFile; - } - - /* - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof JarEntryEditorInput)) - return false; - JarEntryEditorInput other = (JarEntryEditorInput) obj; - return fJarEntryFile.equals(other.fJarEntryFile); - } - - /* - * @see IEditorInput#getPersistable() - */ - public IPersistableElement getPersistable() { - return null; - } - - /* - * @see IEditorInput#getName() - */ - public String getName() { - return fJarEntryFile.getName(); - } - - /* - * @see IEditorInput#getFullPath() - */ - public String getFullPath() { - return fJarEntryFile.getFullPath().toString(); - } - - /* - * @see IEditorInput#getContentType() - */ - public String getContentType() { - return fJarEntryFile.getFullPath().getFileExtension(); - } - - /* - * @see IEditorInput#getToolTipText() - */ - public String getToolTipText() { - return fJarEntryFile.getFullPath().toString(); - } - - /* - * @see IEditorInput#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - IEditorRegistry registry = PlatformUI.getWorkbench() - .getEditorRegistry(); - return registry.getImageDescriptor(fJarEntryFile.getFullPath() - .getFileExtension()); - } - - /* - * @see IEditorInput#exists() - */ - public boolean exists() { - // JAR entries can't be deleted - return true; - } - - /* - * @see IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /* - * see IStorageEditorInput#getStorage() - */ - public IStorage getStorage() { - return fJarEntryFile; - } - } - - public static IEditorInput getBinaryEditorInput( - VirtualArchiveComponent component, String archiveRelativePath) { - - IEditorInput input = null; - IPath archivePath = component.getWorkspaceRelativePath(); - - //[Bug 238616] if there is no workspace relative path then the archive is outside - // the workspace so get the OS path directly from the file - if(archivePath != null) { - input = getBinaryEditorInput(archivePath, archiveRelativePath); - } else { - String archiveOSPath = component.getUnderlyingDiskFile().getPath(); - input = getBinaryEditorInput(archiveOSPath, archiveRelativePath); - } - - return input; - } - - public static IEditorInput getBinaryEditorInput(IPath archivePath, - String archiveRelativePath) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceRoot root = workspace.getRoot(); - IResource resource = root.findMember(archivePath); - if (resource == null) { - return null; - } - String archiveOSPath = resource.getLocation().toOSString(); - IEditorInput editorInput = getBinaryEditorInput(archiveOSPath, archiveRelativePath); - return editorInput; - } - - /** - * [Bug 238616] - * - * Gets binary editor input given an OS relative path to an archive and - * the archive relative path to a file - * - * @param archiveOSPath the OS relative path to the archive - * @param archiveRelativePath the archive relative path to the file to get binary editor input for - * @return - */ - public static IEditorInput getBinaryEditorInput(String archiveOSPath, - String archiveRelativePath) { - JarEntryFile jarFile = new JarEntryFile(archiveRelativePath, archiveOSPath); - JarEntryEditorInput editorInput = new JarEntryEditorInput(jarFile); - return editorInput; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/CommonEditorUtility.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/CommonEditorUtility.java deleted file mode 100644 index 6bad64ff4..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/CommonEditorUtility.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.plugin; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.EditorManager; - - - -/** - * @author cbridgha - * - */ -public class CommonEditorUtility { - - public static final Class IRESOURCE_CLASS = IResource.class; - - private CommonEditorUtility() { - super(); - } - - /** - * Returns an array of all editors that have an unsaved content. If the identical content is - * presented in more than one editor, only one of those editor parts is part of the result. - * - * @return an array of all dirty editor parts. - */ - public static IEditorPart[] getDirtyEditors() { - return getDirtyEditors(null); - } - - /** - * Returns an array of all editors that have an unsaved content, where the content is include in - * one of the projects in the List parameter. If the identical content is presented in more than - * one editor, only one of those editor parts is part of the result. - * - * @return an array of all dirty editor parts. - */ - public static IEditorPart[] getDirtyEditors(List projects) { - Set inputs = new HashSet(); - List result = new ArrayList(0); - IWorkbench workbench = J2EEUIPlugin.getPluginWorkbench(); - IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); - for (int i = 0; i < windows.length; i++) { - IWorkbenchPage[] pages = windows[i].getPages(); - for (int x = 0; x < pages.length; x++) { - IEditorPart[] editors = pages[x].getDirtyEditors(); - for (int z = 0; z < editors.length; z++) { - IEditorPart ep = editors[z]; - IEditorInput input = ep.getEditorInput(); - if (!inputs.contains(input) && (projects == null || inputInProjects(input, projects))) { - inputs.add(input); - result.add(ep); - } - } - } - } - return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]); - } - - public static boolean inputInProjects(IEditorInput input, List projects) { - IResource res = (IResource) input.getAdapter(IRESOURCE_CLASS); - IProject project = res == null ? null : res.getProject(); - if (project == null) - return false; - for (int i = 0; i < projects.size(); i++) { - if (project.equals(projects.get(i))) - return true; - } - return false; - } - - public static boolean promptToSaveAllDirtyEditors() { - return promptToSaveDirtyEditors(Arrays.asList(getDirtyEditors())); - } - - public static boolean promptToSaveDirtyEditors(List dirtyEditors) { - if (dirtyEditors.isEmpty()) - return true; - return EditorManager.saveAll(dirtyEditors, true, true,false, J2EEUIPlugin.getActiveWorkbenchWindow()); - } - - /** - * This will close all editors without prompting for save. - * @param dirtyEditors - * @return true is succeeded, false if not - */ - public static void closeAllEditors() { - - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - page.closeAllEditors(false); - - } - - public static boolean promptToSaveDirtyEditorsInProjects(List projects) { - return promptToSaveDirtyEditors(Arrays.asList(getDirtyEditors(projects))); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/ErrorDialog.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/ErrorDialog.java deleted file mode 100644 index 60f11eef6..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/ErrorDialog.java +++ /dev/null @@ -1,192 +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.plugin; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTError; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Added a Details button to the MessageDialog to show the exception stack trace. - * - * Borrowed from an eclipse InternalErrorDialog - */ -public class ErrorDialog extends MessageDialog { - protected static final String[] LABELS_OK = {IDialogConstants.OK_LABEL}; - protected static final String[] LABELS_OK_CANCEL = {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}; - protected static final String[] LABELS_OK_DETAILS = {IDialogConstants.OK_LABEL, IDialogConstants.SHOW_DETAILS_LABEL}; - protected static final String[] LABELS_OK_CANCEL_DETAILS = {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL, IDialogConstants.SHOW_DETAILS_LABEL}; - private Throwable detail; - private int detailButtonID = -1; - private Text text; - private String message; - //Workaround. SWT does not seem to set the default button if - //there is not control with focus. Bug: 14668 - private int defaultButtonIndex = 0; - /** - * Size of the text in lines. - */ - private static final int TEXT_LINE_COUNT = 15; - - public ErrorDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, Throwable detail, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); - defaultButtonIndex = defaultIndex; - this.detail = detail; - message = dialogMessage; - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.RESIZE); - } - - //Workaround. SWT does not seem to set rigth the default button if - //there is not control with focus. Bug: 14668 - public int open() { - create(); - Button b = getButton(defaultButtonIndex); - b.setFocus(); - b.getShell().setDefaultButton(b); - return super.open(); - } - - /** - * Set the detail button; - */ - public void setDetailButton(int index) { - detailButtonID = index; - } - - /* - * (non-Javadoc) Method declared on Dialog. - */ - protected void buttonPressed(int buttonId) { - if (buttonId == detailButtonID) { - toggleDetailsArea(); - } else { - setReturnCode(buttonId); - close(); - } - } - - /** - * Toggles the unfolding of the details area. This is triggered by the user pressing the details - * button. - */ - private void toggleDetailsArea() { - Point windowSize = getShell().getSize(); - Point oldSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - if (text != null) { - text.dispose(); - text = null; - getButton(detailButtonID).setText(IDialogConstants.SHOW_DETAILS_LABEL); - } else { - createDropDownText((Composite) getContents()); - getButton(detailButtonID).setText(IDialogConstants.HIDE_DETAILS_LABEL); - } - Point newSize = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT); - getShell().setSize(new Point(windowSize.x, windowSize.y + (newSize.y - oldSize.y))); - } - - /** - * Create this dialog's drop-down list component. - * - * @param parent - * the parent composite - * @return the drop-down list component - */ - protected void createDropDownText(Composite parent) { - // create the list - text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - // print the stacktrace in the text field - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - detail.printStackTrace(ps); - if ((detail instanceof SWTError) && (((SWTError) detail).throwable != null)) { - ps.println("\n*** Stack trace of contained exception ***"); //$NON-NLS-1$ - ((SWTError) detail).throwable.printStackTrace(ps); - } else if ((detail instanceof SWTException) && (((SWTException) detail).throwable != null)) { - ps.println("\n*** Stack trace of contained exception ***"); //$NON-NLS-1$ - ((SWTException) detail).throwable.printStackTrace(ps); - } - ps.flush(); - baos.flush(); - text.setText(baos.toString()); - } catch (IOException e) { - //Ignore - } - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); - data.heightHint = text.getLineHeight() * TEXT_LINE_COUNT; - text.setLayoutData(data); - } - - public static boolean openError(Shell parent, String title, String message, Throwable detail, int defaultIndex, boolean showCancel) { - String[] labels; - if (detail == null) - labels = showCancel ? LABELS_OK_CANCEL : LABELS_OK; - else - labels = showCancel ? LABELS_OK_CANCEL_DETAILS : LABELS_OK_DETAILS; - ErrorDialog dialog = new ErrorDialog(parent, title, null, // accept - // the - // default - // window - // icon - message, detail, ERROR, labels, defaultIndex); - if (detail != null) - dialog.setDetailButton(labels.length - 1); - return dialog.open() == 0; - } - - protected Control createDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parent.getFont()); - ((GridLayout) composite.getLayout()).numColumns = 2; - // create image - Image image = composite.getDisplay().getSystemImage(SWT.ICON_ERROR); - if (image != null) { - Label label = new Label(composite, 0); - image.setBackground(label.getBackground()); - label.setImage(image); - label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING)); - } - // create message - if (message != null) { - Label label = new Label(composite, SWT.WRAP); - label.setText(message); - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - label.setFont(parent.getFont()); - } - return composite; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectActionFilter.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectActionFilter.java deleted file mode 100644 index 844f4de72..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectActionFilter.java +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.ui.IActionFilter; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class FacetedProjectActionFilter - - implements IActionFilter - -{ - public boolean testAttribute( final Object target, - final String name, - final String value ) - { - - if( name.equals( "facet" ) ) //$NON-NLS-1$ - { - IProject project = (IProject)target; - IFacetedProject fproj = null; - if(project.isAccessible()){ - try { - fproj = ProjectFacetsManager.create( project ); - } catch (CoreException e1) { - Logger.getLogger().logError(e1); - } - } - - if( fproj != null ){ - final int colon = value.indexOf( ':' ); - final String fid; - final String vexprstr; - - if( colon == -1 || colon == value.length() - 1 ) - { - fid = value; - vexprstr = null; - } - else - { - fid = value.substring( 0, colon ); - vexprstr = value.substring( colon + 1 ); - } - - if( ! ProjectFacetsManager.isProjectFacetDefined( fid ) ) - { - return false; - } - - final IProjectFacet f = ProjectFacetsManager.getProjectFacet( fid ); - - if( ! fproj.hasProjectFacet( f ) ) - { - return false; - } - - if( vexprstr == null ) - { - return true; - } - else - { - final IProjectFacetVersion fv = fproj.getInstalledVersion( f ); - - try - { - if( f.getVersions( vexprstr ).contains( fv ) ) - { - return true; - } - } - catch( CoreException e ) - { - //EJBUIPlugin.getDefault().log - } - } - - return false; - } - else - { - return false; - } - } - return true; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectAdapterFactory.java deleted file mode 100644 index 4ee36d0aa..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/FacetedProjectAdapterFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.ui.IActionFilter; - -public class FacetedProjectAdapterFactory implements IAdapterFactory { - - - private static final Class[] ADAPTER_TYPES = { IActionFilter.class }; - - public Object getAdapter( final Object adaptable, - final Class adapterType ) - { - if( adapterType == IActionFilter.class ) - { - return new FacetedProjectActionFilter(); - } - else - { - return null; - } - } - - public Class[] getAdapterList() - { - return ADAPTER_TYPES; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEEditorUtility.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEEditorUtility.java deleted file mode 100644 index 6fce02a03..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEEditorUtility.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 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.plugin; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; -import org.eclipse.jem.internal.adapters.jdom.JavaClassJDOMAdaptor; -import org.eclipse.jem.internal.java.adapters.ReadAdaptor; -import org.eclipse.jem.java.JavaClass; -import org.eclipse.jem.java.JavaPackage; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -/** - * A number of routines for working with JavaElements in editors - * - * Use 'isOpenInEditor' to test if an element is already open in a editor Use 'openInEditor' to - * force opening an element in a editor With 'getWorkingCopy' you get the working copy (element in - * the editor) of an element - */ -public class J2EEEditorUtility { - // //$NON-NLS-1$ - public static final String EJB_JAVA_EDITOR_ID = "org.eclipse.jst.j2ee.internal.internal.ejb.ui.misc.EJBJavaEditor"; //$NON-NLS-1$ - - public static ICompilationUnit getCompilationUnit(JavaClass javaClass) { - IProject project = ProjectUtilities.getProject(javaClass); - if (project == null) - return null; - return getCompilationUnit(javaClass, project); - } - - public static ICompilationUnit getCompilationUnit(JavaClass javaClass, IProject project) { - if (javaClass == null) - return null; - IJavaProject javaProj = getJavaProject(project); - if (javaProj == null) - return null; - return getCompilationUnit(javaClass, javaProj); - } - - public static ICompilationUnit getCompilationUnit(JavaClass javaClass, IJavaProject javaProject) { - if (javaClass == null) - return null; - IType type = getType(javaClass); - if (type != null) - return type.getCompilationUnit(); - return null; - } - - public static IType getType(JavaClass javaClass) { - if (javaClass != null) { - JavaClassJDOMAdaptor adaptor = (JavaClassJDOMAdaptor) EcoreUtil.getRegisteredAdapter(javaClass, ReadAdaptor.TYPE_KEY); - if (adaptor != null) - return adaptor.getSourceType(); - } - return null; - } - - public static IEditorInput getEditorInput(Object input) { - if (input instanceof EObject) - return new FileEditorInput(WorkbenchResourceHelper.getFile((EObject) input)); - if (input instanceof IFile) - return new FileEditorInput((IFile) input); - return null; - } - - public static IFile getFile(JavaClass javaClass) { - ICompilationUnit comp = getCompilationUnit(javaClass); - if (comp == null) - return null; - IEditorInput input = null; - input = EditorUtility.getEditorInput(comp); - if (input != null) { - return (IFile) input.getAdapter(IFile.class); - } - return null; - } - - public static IJavaProject getJavaProject(IProject aProject) { - if (aProject == null) - return null; - IJavaModel javaModel = JemProjectUtilities.getJavaModel(); - return javaModel.getJavaProject(aProject.getName()); - } - - /** - * Return the IPackageFragment for the JavaPackage for - * - * @javaClass. - */ - public static IPackageFragment getPackageFragment(JavaClass javaClass, IJavaProject javaProject) { - if (javaProject != null) { - try { - JavaPackage javaPackage = (JavaPackage) javaClass.eContainer(); - String packageName = javaPackage.getName(); - IPackageFragment[] pkgFrags = javaProject.getPackageFragments(); - for (int i = 0; i < pkgFrags.length; i++) { - if ((pkgFrags[i].getElementName().equals(packageName))) - return pkgFrags[i]; - } - } catch (JavaModelException e) { - //Ignore - } - } - return null; - } - - /** - * Opens a Java editor for the given element if the element is a Java compilation unit or a Java - * class file. - * - * @return the IEditorPart or null if wrong element type or opening failed - */ - public static IEditorPart openInEditor(JavaClass javaClass, IProject aProject) throws JavaModelException, PartInitException { - return openInEditor(javaClass, getJavaProject(aProject)); - } - - /** - * Opens a Java editor for the given element if the element is a Java compilation unit or a Java - * class file. - * - * @return the IEditorPart or null if wrong element type or opening failed - */ - public static IEditorPart openInEditor(JavaClass javaClass, IJavaProject javaProject) throws JavaModelException, PartInitException { - if (javaClass == null || javaProject == null) - return null; - IType type = getType(javaClass); - if (type == null) - return openInEditor(getCompilationUnit(javaClass, javaProject)); - return EditorUtility.openInEditor(type); - } - - - /** - * Opens a Java editor for the given element if the element is a Java compilation unit or a Java - * class file. - * - * @return the IEditorPart or null if wrong element type or opening failed - */ - public static IEditorPart openInEditor(JavaClass javaClass, IJavaProject javaProject, String editorId) throws JavaModelException, PartInitException { - return openInEditor(getCompilationUnit(javaClass, javaProject), editorId); - } - - /** - * Opens a Java editor for the given element if the element is a Java compilation unit or a Java - * class file. - * - * @return the IEditorPart or null if wrong element type or opening failed - */ - public static IEditorPart openInEditor(ICompilationUnit aCompilationUnit) throws JavaModelException, PartInitException { - return EditorUtility.openInEditor(aCompilationUnit); - } - - /** - * Opens a Java editor for the given element if the element is a Java compilation unit or a Java - * class file. - * - * @return the IEditorPart or null if wrong element type or opening failed - */ - public static IEditorPart openInEditor(ICompilationUnit aCompilationUnit, String editorId) throws JavaModelException, PartInitException { - return openInEditor(EditorUtility.getEditorInput(aCompilationUnit), editorId); - } - - private static IEditorPart openInEditor(IEditorInput input, String editorID) throws PartInitException { - if (input != null) { - IWorkbenchPage p = J2EEUIPlugin.getActiveWorkbenchWindow().getActivePage(); - if (p != null) - return p.openEditor(input, editorID, true); - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIAdapterFactory.java deleted file mode 100644 index 372f44c2e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIAdapterFactory.java +++ /dev/null @@ -1,56 +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 Jun 30, 2004 - */ -package org.eclipse.jst.j2ee.internal.plugin; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.emf.ecore.EObject; - -/** - * @author jlanuti - */ -public class J2EEUIAdapterFactory implements IAdapterFactory { - - protected static final Class ILAUNCHABLE_CLASS = ILaunchable.class; - - /** - * Default Constructor - */ - public J2EEUIAdapterFactory() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof EObject) { - if (adapterType == ILAUNCHABLE_CLASS) - return adaptableObject; - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[]{ILAUNCHABLE_CLASS}; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIContextIds.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIContextIds.java deleted file mode 100644 index 7d8053c05..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIContextIds.java +++ /dev/null @@ -1,30 +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 Feb 27, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.plugin; - -/** - * @author vijayb - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public interface J2EEUIContextIds { - - // Delete Enterprise Bean Dialog - public static final String DELETE_ENTERPRISE_BEAN_DIALOG = J2EEUIPlugin.PLUGIN_ID + ".delb1000"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIMessages.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIMessages.java deleted file mode 100644 index a2eeb6e4a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIMessages.java +++ /dev/null @@ -1,245 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 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 - * Stefan Dimov, stefan.dimov@sap.com - bug 207826 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.plugin; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.wst.common.frameworks.internal.Messages; - - -public class J2EEUIMessages extends Messages { - - private static final J2EEUIMessages INSTANCE = new J2EEUIMessages(); - - public static final String PROJECT_LOC_LBL = "1"; //$NON-NLS-1$ - public static final String TARGET_RUNTIME_LBL = "2"; //$NON-NLS-1$ - public static final String J2EE_VERSION_LBL = "3"; //$NON-NLS-1$ - public static final String IMAGE_LOAD_ERROR = "4"; //$NON-NLS-1$ - public static final String APP_PROJECT_WIZ_TITLE = "5"; //$NON-NLS-1$ - public static final String APP_PROJECT_MAIN_PG_TITLE = "6"; //$NON-NLS-1$ - public static final String APP_PROJECT_MAIN_PG_DESC = "7"; //$NON-NLS-1$ - public static final String APP_PROJECT_MODULES_PG_TITLE = "8"; //$NON-NLS-1$ - public static final String APP_PROJECT_MODULES_PG_DESC = "9"; //$NON-NLS-1$ - public static final String APP_PROJECT_MODULES_PG_SELECT = "10"; //$NON-NLS-1$ - public static final String APP_PROJECT_MODULES_PG_DESELECT = "11"; //$NON-NLS-1$ - public static final String APP_PROJECT_MODULES_PG_NEW = "12"; //$NON-NLS-1$ - public static final String EAR_PROJECT_FOR_MODULE_CREATION = "13"; //$NON-NLS-1$ - public static final String NEW_THREE_DOTS_E = "14"; //$NON-NLS-1$ - public static final String NEW_THREE_DOTS_W = "14a"; //$NON-NLS-1$ - public static final String LINK_MODULETO_EAR_PROJECT = "15"; //$NON-NLS-1$ - public static final String NEW_MOD_SEL_PG_TITLE = "16"; //$NON-NLS-1$ - public static final String NEW_MOD_SEL_PG_DESC = "17"; //$NON-NLS-1$ - public static final String NEW_MOD_WIZ_TITLE = "18"; //$NON-NLS-1$ - public static final String NEW_MOD_SEL_PG_DEF_BTN = "19"; //$NON-NLS-1$ - public static final String APP_CLIENT_PROJ_LBL = "20"; //$NON-NLS-1$ - public static final String EJB_PROJ_LBL = "21"; //$NON-NLS-1$ - public static final String WEB_PROJ_LBL = "22"; //$NON-NLS-1$ - public static final String JCA_PROJ_LBL = "23"; //$NON-NLS-1$ - - public static final String APP_CLIENT_PROJECT_WIZ_TITLE = "24"; //$NON-NLS-1$ - public static final String APP_CLIENT_VERSION_LBL = "3"; //$NON-NLS-1$ - public static final String APP_CLIENT_PROJECT_MAIN_PG_TITLE = "25"; //$NON-NLS-1$ - public static final String APP_CLIENT_SETTINGS = "101"; //$NON-NLS-1$ - - public static final String APP_CLIENT_PROJECT_MAIN_PG_DESC = "26"; //$NON-NLS-1$ - public static final String MODULES_DEPENDENCY_PAGE_TITLE = "27"; //$NON-NLS-1$ - - public static final String MODULES_DEPENDENCY_PAGE_DESC = "28"; //$NON-NLS-1$ - public static final String MODULES_DEPENDENCY_PAGE_AVAILABLE_JARS = "29"; //$NON-NLS-1$ - public static final String MODULES_DEPENDENCY_PAGE_CLASSPATH = "30"; //$NON-NLS-1$ - public static final String MODULES_DEPENDENCY_PAGE_TABLE_MODULE = "31"; //$NON-NLS-1$ - public static final String MODULES_DEPENDENCY_PAGE_TABLE_PROJECT = "32"; //$NON-NLS-1$ - public static final String NEW_LBL = "33"; //$NON-NLS-1$ - public static final String APP_CLIENT_IMPORT_MAIN_PG_DESC = "34"; //$NON-NLS-1$ - public static final String APP_CLIENT_IMPORT_MAIN_PG_TITLE = "35"; //$NON-NLS-1$ - public static final String APP_CLIENT_IMPORT_FILE_LABEL = "36"; //$NON-NLS-1$ - - public static final String APP_CLIENT_IMPORT_PROJECT_LABEL = "37"; //$NON-NLS-1$ - - public static final String IMPORT_WIZ_TITLE = "38"; //$NON-NLS-1$ - public static final String EAR_IMPORT_MAIN_PG_DESC = "39"; //$NON-NLS-1$ - public static final String EAR_IMPORT_MAIN_PG_TITLE = "40"; //$NON-NLS-1$ - public static final String EAR_IMPORT_FILE_LABEL = "41"; //$NON-NLS-1$ - public static final String OVERWRITE_RESOURCES = "42"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_TYPE = "43"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_TYPE_BINARY = "44"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_TYPE_SOURCE = "45"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PARTIAL_DEVELOPMENT = "46"; //$NON-NLS-1$ - public static final String EAR_IMPORT_DESELECT_ALL_UTIL_BUTTON = "48"; //$NON-NLS-1$ - public static final String EAR_IMPORT_SELECT_ALL_UTIL_BUTTON = "47"; //$NON-NLS-1$ - public static final String EAR_IMPORT_JARS_GROUP = "49"; //$NON-NLS-1$ - public static final String EAR_IMPORT_SELECT_UTIL_JARS_TO_BE_PROJECTS = "50"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_PG_DESC = "51"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_PG_TITLE = "52"; //$NON-NLS-1$ - public static final String PROJECT_LOCATIONS_GROUP = "53"; //$NON-NLS-1$ - public static final String NEW_PROJECT_GROUP_DESCRIPTION = "54"; //$NON-NLS-1$ - public static final String USE_DEFAULT_ROOT_RADIO = "55"; //$NON-NLS-1$ - public static final String USE_ALTERNATE_ROOT_RADIO = "56"; //$NON-NLS-1$ - public static final String SELECT_DIRECTORY_DLG = "57"; //$NON-NLS-1$ - public static final String EAR_IMPORT_Modules_in_EAR = "58"; //$NON-NLS-1$ - public static final String EAR_IMPORT_New_Project_Name = "59"; //$NON-NLS-1$ - public static final String EAR_IMPORT_FILENAMES = "60"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECTNAMES = "61"; //$NON-NLS-1$ - public static final String J2EE_EXPORT_DESTINATION = "62"; //$NON-NLS-1$ - public static final String J2EE_EXPORT_OVERWRITE_CHECKBOX = "63"; //$NON-NLS-1$ - public static final String J2EE_EXPORT_SOURCE_CHECKBOX = "64"; //$NON-NLS-1$ - public static final String APP_CLIENT_EXPORT_MAIN_PG_TITLE = "65"; //$NON-NLS-1$ - public static final String APP_CLIENT_EXPORT_MAIN_PG_DESC = "66"; //$NON-NLS-1$ - public static final String EXPORT_WIZ_TITLE = "67"; //$NON-NLS-1$ - public static final String EAR_EXPORT_MAIN_PG_TITLE = "68"; //$NON-NLS-1$ - public static final String EAR_EXPORT_MAIN_PG_DESC = "69"; //$NON-NLS-1$ - public static final String EAR_EXPORT_INCLUDE_PROJECT_FILES = "70"; //$NON-NLS-1$ - public static final String EAR_EXPORT_INCLUDE_PROJECT_FILES_DESC = "71"; //$NON-NLS-1$ - public static final String EAR_IMPORT_INCLUDE_PROJECT = "72"; //$NON-NLS-1$ - public static final String EAR_IMPORT_OVERWRITE_NESTED = "74"; //$NON-NLS-1$ - public static final String DELETE_PROJECT = "75"; //$NON-NLS-1$ - public static final String EAR_IMPORT_PROJECT_LABEL = "76"; //$NON-NLS-1$ - - //string for migration - public static final String ERROR_OCCURRED_TITLE = "77"; //$NON-NLS-1$ - public static final String ERROR_OCCURRED_MESSAGE = "78"; //$NON-NLS-1$ - public static final String BINARY_PROJECT = "79"; //$NON-NLS-1$ - public static final String ACTION_CANNOT_BE_PERFORMED_ON_BIN_PROJECT = "80"; //$NON-NLS-1$ - public static final String INFORMATION_UI_ = "81"; //$NON-NLS-1$ - public static final String CHOSEN_OP_NOT_AVAILABLE = "82"; //$NON-NLS-1$ - - public static final String CREATE_EJB_CLIENT_JAR = "90"; //$NON-NLS-1$ - public static final String USE_ANNOTATIONS = "91"; //$NON-NLS-1$ - public static final String USE_ANNOTATIONS_SERVLET = "98"; //$NON-NLS-1$ - public static final String ADD_ANNOTATIONS_SUPPORT = "92"; //$NON-NLS-1$ - public static final String BROWSE_LABEL = "93"; //$NON-NLS-1$ - public static final String NAME_LABEL = "94"; //$NON-NLS-1$ - - public static final String APP_CLIENT_CREATE_MAIN = "95"; //$NON-NLS-1$ - public static final String CREATE_DEFAULT_SESSION_BEAN = "96"; //$NON-NLS-1$ - - public static final String MODULE_NAME = "99"; //$NON-NLS-1$ - public static final String MODULE_VERSION_LABEL = "100"; //$NON-NLS-1$ - - public static final String J2EE_UTILITY_JAR_LISTEAR_IMPORT_SELECT_UTIL_JARS_TO_BE_PROJECTS = "97"; //$NON-NLS-1$ - - public static final String J2EE_EXPORT_RUNTIME = "103"; //$NON-NLS-1$ - - public static final String FLEXIBLE_PROJECT_WIZ_TITLE = "FlexibleProjectCreationWizard.title"; //$NON-NLS-1$ - public static final String FLEXIBLE_PROJECT_MAIN_PG_TITLE = "FlexibleProjectCreationWizard.mainPage.title"; //$NON-NLS-1$ - public static final String FLEXIBLE_PROJECT_MAIN_PG_DESC = "FlexibleProjectCreationWizard.mainPage.desc"; //$NON-NLS-1$ - public static final String EAR_COMPONENT_WIZ_TITLE = "EARComponentCreationWizard.title"; //$NON-NLS-1$ - public static final String EAR_COMPONENT_MAIN_PG_TITLE = "EARComponentCreationWizard.mainPage.title"; //$NON-NLS-1$ - public static final String EAR_COMPONENT_MAIN_PG_DESC = "EARComponentCreationWizard.mainPage.desc"; //$NON-NLS-1$ - public static final String EAR_COMPONENT_SECOND_PG_TITLE = "EARComponentCreationWizard.secondPage.title"; //$NON-NLS-1$ - public static final String EAR_COMPONENT_SECOND_PG_DESC = "EARComponentCreationWizard.secondPage.desc"; //$NON-NLS-1$ - public static final String J2EE_MODULE_DEPENDENCIES_LABEL = "J2EEModuleDependencies.label"; //$NON-NLS-1$ - public static final String APPCLIENT_COMPONENT_WIZ_TITLE = "AppClientComponentCreationWizard.title"; //$NON-NLS-1$ - public static final String APPCLIENT_COMPONENT_MAIN_PG_TITLE = "AppClientComponentCreationWizard.mainPage.title"; //$NON-NLS-1$ - public static final String APPCLIENT_COMPONENT_MAIN_PG_DESC = "AppClientComponentCreationWizard.mainPage.desc"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_WIZ_TITLE = "DefaultJ2EEComponentCreationWizard.title"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_TITLE = "DefaultJ2EEComponentCreationWizard.page.title"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_DESC = "DefaultJ2EEComponentCreationWizard.page.desc"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_EJB_MODULE_LBL = "DefaultJ2EEComponentCreationWizard.page.label.ejb"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_WEB_MODULE_LBL = "DefaultJ2EEComponentCreationWizard.page.label.web"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_JCA_MODULE_LBL = "DefaultJ2EEComponentCreationWizard.page.label.jca"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_APPCLIENT_MODULE_LBL = "DefaultJ2EEComponentCreationWizard.page.label.appclient"; //$NON-NLS-1$ - public static final String DEFAULT_COMPONENT_PAGE_NEW_MOD_SEL_PG_DEF_BTN = "DefaultJ2EEComponentCreationWizard.page.button.select"; //$NON-NLS-1$ - - public final static String EMPTY_STRING = ""; //$NON-NLS-1$ - public final static String FOLDER_LABEL = getResourceString("FOLDER_LABEL"); //$NON-NLS-1$ - public final static String BROWSE_BUTTON_LABEL = getResourceString("BROWSE_BUTTON_LABEL"); //$NON-NLS-1$ - public final static String JAVA_PACKAGE_LABEL = getResourceString("JAVA_PACKAGE_LABEL"); //$NON-NLS-1$ - public final static String CLASS_NAME_LABEL = getResourceString("CLASS_NAME_LABEL"); //$NON-NLS-1$ - public final static String SUPERCLASS_LABEL = getResourceString("SUPERCLASS_LABEL"); //$NON-NLS-1$ - public final static String CONTAINER_SELECTION_DIALOG_TITLE = getResourceString("CONTAINER_SELECTION_DIALOG_TITLE"); //$NON-NLS-1$ - public final static String CONTAINER_SELECTION_DIALOG_DESC = getResourceString("CONTAINER_SELECTION_DIALOG_DESC"); //$NON-NLS-1$ - public final static String CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG = getResourceString("CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG"); //$NON-NLS-1$ - public final static String PACKAGE_SELECTION_DIALOG_TITLE = getResourceString("PACKAGE_SELECTION_DIALOG_TITLE"); //$NON-NLS-1$ - public final static String PACKAGE_SELECTION_DIALOG_DESC = getResourceString("PACKAGE_SELECTION_DIALOG_DESC"); //$NON-NLS-1$ - public final static String PACKAGE_SELECTION_DIALOG_MSG_NONE = getResourceString("PACKAGE_SELECTION_DIALOG_MSG_NONE"); //$NON-NLS-1$ - public final static String SUPERCLASS_SELECTION_DIALOG_TITLE = getResourceString("SUPERCLASS_SELECTION_DIALOG_TITLE"); //$NON-NLS-1$ - public final static String SUPERCLASS_SELECTION_DIALOG_DESC = getResourceString("SUPERCLASS_SELECTION_DIALOG_DESC"); //$NON-NLS-1$ - public final static String JAVA_CLASS_MODIFIERS_LABEL = getResourceString("JAVA_CLASS_MODIFIERS_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_INTERFACES_LABEL = getResourceString("JAVA_CLASS_INTERFACES_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_METHOD_STUBS_LABEL = getResourceString("JAVA_CLASS_METHOD_STUBS_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_PUBLIC_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_PUBLIC_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_FINAL_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_FINAL_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_MAIN_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_MAIN_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String JAVA_CLASS_INHERIT_CHECKBOX_LABEL = getResourceString("JAVA_CLASS_INHERIT_CHECKBOX_LABEL"); //$NON-NLS-1$ - public final static String ADD_BUTTON_LABEL = getResourceString("ADD_BUTTON_LABEL"); //$NON-NLS-1$ - public static final String REMOVE_BUTTON = getResourceString("REMOVE_BUTTON"); //$NON-NLS-1$ - public static final String YES_BUTTON = getResourceString("YES_BUTTON"); //$NON-NLS-1$ - public static final String NO_BUTTON = getResourceString("NO_BUTTON"); //$NON-NLS-1$ - public static final String OK_BUTTON = getResourceString("OK_BUTTON"); //$NON-NLS-1$ - public static final String CANCEL_BUTTON = getResourceString("CANCEL_BUTTON"); //$NON-NLS-1$ - public static final String BINARY = getResourceString("BINARY"); //$NON-NLS-1$ - public final static String INTERFACE_SELECTION_DIALOG_TITLE = getResourceString("INTERFACE_SELECTION_DIALOG_TITLE"); //$NON-NLS-1$ - - public static final String JAVAUTIL_COMPONENT_WIZ_TITLE="JAVAUTIL_COMPONENT_WIZ_TITLE"; //$NON-NLS-1$ - public static final String JAVAUTILITY_MAIN_PG_TITLE = "JAVAUTILITY_MAIN_PG_TITLE";//$NON-NLS-1$ - public final static String JAVAUTILITY_MAIN_PG_DESC = "JAVAUTILITY_MAIN_PG_DESC";//$NON-NLS-1$ - public static final String AVAILABLE_J2EE_COMPONENTS="AVAILABLE_J2EE_COMPONENTS"; //$NON-NLS-1$ - public static final String EXTERNAL_JAR="EXTERNAL_JAR";//$NON-NLS-1$ - public static final String PROJECT_JAR="PROJECT_JAR";//$NON-NLS-1$ - public static final String ADDVARIABLE="ADDVARIABLE";//$NON-NLS-1$ - public static final String CHANGE_LIB_DIR ="CHANGE_LIB_DIR";//$NON-NLS-1$ - public static final String NO_DD_MSG_TITLE = "NO_DD_MSG_TITLE";//$NON-NLS-1$ - public static final String GEN_DD_QUESTION = "GEN_DD_QUESTION";//$NON-NLS-1$ - - public static final String CHANGE_LIB_DIR_HEAD = "CHANGE_LIB_DIR_HEAD";//$NON-NLS-1$ - public static final String NEW_LIB_DIR_PROPMPT = "NEW_LIB_DIR_PROPMPT";//$NON-NLS-1$ - public static final String BLANK_LIB_DIR = "BLANK_LIB_DIR";//$NON-NLS-1$ - public static final String BLANK_LIB_DIR_CONFIRM = "BLANK_LIB_DIR_CONFIRM";//$NON-NLS-1$ - public static final String BLANK_LIB_DIR_WARN_QUESTION = "BLANK_LIB_DIR_WARN_QUESTION";//$NON-NLS-1$ - public static final String INVALID_PATH = "INVALID_PATH";//$NON-NLS-1$ - public static final String INVALID_PATH_MSG = "INVALID_PATH_MSG";//$NON-NLS-1$ - public static final String DEPENDENCY_CONFLICT_TITLE = "DEPENDENCY_CONFLICT_TITLE";//$NON-NLS-1$ - public static final String DEPENDENCY_CONFLICT_MSG_1 = "DEPENDENCY_CONFLICT_MSG_1";//$NON-NLS-1$ - public static final String DEPENDENCY_CONFLICT_MSG_2 = "DEPENDENCY_CONFLICT_MSG_2";//$NON-NLS-1$ - public static final String DO_NOT_SHOW_WARNING_AGAIN = "DO_NOT_SHOW_WARNING_AGAIN";//$NON-NLS-1$ - - public static final String SUPPORTMULTIPLEMODULES="SUPPORTMULTIPLEMODULES";//$NON-NLS-1$ - public static final String SOURCEFOLDER="SOURCEFOLDER";//$NON-NLS-1$ - public static final String CONTENT_FOLDER = "102"; //$NON-NLS-1$ - - public static final String HOVER_HELP_FOR_DISABLED_LIBS = "HOVER_HELP_FOR_DISABLED_LIBS"; //$NON-NLS-1$ - public static final String JAVA_EE_PREFERENCE_PAGE_NAME = "JAVA_EE_PREFERENCE_PAGE_NAME"; //$NON-NLS-1$ - public static final String JAVA_EE_PREFERENCE_PAGE_JET_TEMPLATE = "JAVA_EE_PREFERENCE_PAGE_JET_TEMPLATE"; //$NON-NLS-1$ - public static final String JAVA_EE_PREFERENCE_PAGE_DYN_TRANSLATION_BTN_NAME = "JAVA_EE_PREFERENCE_PAGE_DYN_TRANSLATION_BTN_NAME"; //$NON-NLS-1$ - /** - * Returns the string from the resource bundle, or 'key' if not found. - */ - public static String getResourceString(String key) { - return INSTANCE.doGetResourceString(key); - } - - public static String getResourceString(String key, Object[] args) { - return INSTANCE.doGetResourceString(key, args); - } - - private J2EEUIMessages() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.Messages#initializeBundle() - */ - protected void initializeBundle() { - try { - resourceBundle = ResourceBundle.getBundle("j2ee_ui"); //$NON-NLS-1$ - } catch (MissingResourceException x) { - //Ignore - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPlugin.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPlugin.java deleted file mode 100644 index 153124942..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPlugin.java +++ /dev/null @@ -1,343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.plugin; - -import java.io.IOException; -import java.net.URL; -import java.util.HashSet; - -import org.eclipse.core.internal.boot.PlatformURLConnection; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive; -import org.eclipse.jst.j2ee.internal.wizard.ImportUtil; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; - - -/** - * The main plugin class to be used in the desktop. - */ -public class J2EEUIPlugin extends AbstractUIPlugin { - - public static final String PLUGIN_ID = "org.eclipse.jst.j2ee.ui"; //$NON-NLS-1$ - - //The shared instance. - private static J2EEUIPlugin plugin; - private static IPath location; - - /** - * The constructor. - */ - public J2EEUIPlugin() { - super(); - plugin = this; - } - - /** - * Returns the shared instance. - */ - public static J2EEUIPlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - public static IPath getInstallLocation() { - if (location == null) { - URL url = getInstallURL(); - try { - String installLocation = ((PlatformURLConnection) url.openConnection()).getURLAsLocal().getFile(); - location = new Path(installLocation); - } catch (IOException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logWarning(J2EEPluginResourceHandler.getString("Install_Location_Error_", new Object[]{url}) + e); //$NON-NLS-1$ - } - } - return location; - } - - public static URL getInstallURL() { - return getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ - } - - public static String getArchiveDefaultProjectName(Archive anArchive) { - if (anArchive == null) - return null; - int type = getArchiveType(anArchive); - return getTypeDefaultProjectName(anArchive.getURI(), type); - } - - public static String getArchiveDefaultUtilProjectName(Archive anArchive) { - if (anArchive == null) - return null; - int type = getArchiveType(anArchive); - return getTypeDefaultUtilProjectName(anArchive.getName(), type); - } - - public static String getArchiveDefaultProjectName(Archive anArchive, HashSet moduleNames) { - if (anArchive == null) - return null; - int type = getArchiveType(anArchive); - return getTypeDefaultProjectName(anArchive.getURI(), type, moduleNames); - } - - public static int getArchiveType(Archive anArchive) { - int type = ImportUtil.UNKNOWN; - try { - try { - if (anArchive.isEJBJarFile()) - type = ImportUtil.EJBJARFILE; - else if (anArchive.isWARFile()) - type = ImportUtil.WARFILE; - else if (anArchive.isApplicationClientFile()) - type = ImportUtil.CLIENTJARFILE; - else if (anArchive.isRARFile()) - type = ImportUtil.RARFILE; - else if (anArchive.isEARFile()) - type = ImportUtil.EARFILE; - } catch (Exception e) { - //Ignore - } - } finally { - if (anArchive != null) - anArchive.close(); - } - return type; - } - - public static String getTypeDefaultProjectName(String text, int type) { - IPath path = new Path(text); - text = path.makeRelative().removeFileExtension().lastSegment(); - - boolean exists = false; - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(text); - if (project != null && project.exists()) - exists = true; - if (exists && text.toLowerCase().indexOf(ImportUtil.SUFFIXES[type].toLowerCase()) == -1) - text = text + ImportUtil.SUFFIXES[type]; - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int j = 1; j < 10; j++) { - boolean found = false; - String iteratedProjectName = text + ((j == 1) ? "" : Integer.toString(j)); //$NON-NLS-1$ - for (int i = 0; !found && (i < projects.length); i++) { - if ((projects[i]).getName().equalsIgnoreCase(iteratedProjectName)) { - found = true; - } - } - if (!found) - return iteratedProjectName; - } - return text; - } - - private static String getTypeDefaultProjectName(String text, int type, HashSet moduleNames) { - IPath path = new Path(text); - text = path.makeRelative().removeFileExtension().lastSegment(); - - boolean isValidName = moduleNames.add(text); - boolean exists = false; - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(text); - if (project != null && project.exists()) - exists = true; - if (!isValidName || (exists && text.toLowerCase().indexOf(ImportUtil.SUFFIXES[type].toLowerCase()) == -1)) - text = text + ImportUtil.SUFFIXES[type]; - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int j = 1; j < 10; j++) { - boolean found = false; - String iteratedProjectName = text + ((j == 1) ? "" : Integer.toString(j)); //$NON-NLS-1$ - for (int i = 0; !found && (i < projects.length); i++) { - if ((projects[i]).getName().equalsIgnoreCase(iteratedProjectName)) { - found = true; - } - } - if (!found) - return iteratedProjectName; - } - return text; - } - - // the following two methods are used by web editor - - private static String getTypeDefaultUtilProjectName(String text, int type) { - text = text.substring(text.lastIndexOf(java.io.File.separator) + 1); - int i = text.lastIndexOf('.'); - if (i > 0) - text = text.substring(0, i); - if (text.toLowerCase().indexOf(ImportUtil.SUFFIXES[type].toLowerCase()) == -1) - text = text + ImportUtil.SUFFIXES[type]; - IProject[] projects = getWorkspace().getRoot().getProjects(); - for (int j = 0; j < 10; j++) { - boolean found = false; - String iteratedProjectName = text + ((j == 0) ? "" : Integer.toString(j)); //$NON-NLS-1$ - for (i = 0; !found && (i < projects.length); i++) { - if ((projects[i]).getName().equalsIgnoreCase(iteratedProjectName)) { - found = true; - } - } - if (!found) - return iteratedProjectName; - } - return text; - } - - /** - * Get a .gif from the image registry. - */ - public Image getImage(String key) { - ImageRegistry imageRegistry = getImageRegistry(); - Image image = imageRegistry.get(key); - if (image == null || image.isDisposed()) { - ImageDescriptor descriptor = getImageDescriptor(key); - if (descriptor != null) { - image = descriptor.createImage(); - imageRegistry.put(key, image); - } - } - return image; - } - - /** - * This gets a .gif from the icons folder. - */ - public ImageDescriptor getImageDescriptor(String key) { - ImageDescriptor imageDescriptor = null; - URL gifImageURL = getImageURL(key); - if (gifImageURL != null) - imageDescriptor = ImageDescriptor.createFromURL(gifImageURL); - return imageDescriptor; - } - - /** - * @param key - * @return - */ - private URL getImageURL(String key) { - return J2EEPlugin.getImageURL(key, getBundle()); - } - - public static IWorkbenchWindow getActiveWorkbenchWindow() { - return getPluginWorkbench().getActiveWorkbenchWindow(); - } - - /** - * Return the workbench - * - * This method is internal to the j2ee plugin and must not be called by any other plugins. - */ - - public static IWorkbench getPluginWorkbench() { - return getDefault().getWorkbench(); - } - - public static Shell getActiveWorkbenchShell() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window != null) { - return window.getShell(); - } - return null; - } - - public static IStructuredSelection getCurrentSelection() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window != null) { - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - - } - return null; - } - - - /** - * Record an error against this plugin's log. - * - * @param aCode - * @param aMessage - * @param anException - */ - public static void logError(int aCode, String aMessage, - Throwable anException) { - getDefault().getLog().log( - createErrorStatus(aCode, aMessage, anException)); - } - - /** - * - * Record a message against this plugin's log. - * - * @param severity - * @param aCode - * @param aMessage - * @param exception - */ - public static void log(int severity, int aCode, String aMessage, - Throwable exception) { - log(createStatus(severity, aCode, aMessage, exception)); - } - - /** - * - * Record a status against this plugin's log. - * - * @param aStatus - */ - public static void log(IStatus aStatus) { - getDefault().getLog().log(aStatus); - } - - /** - * Create a status associated with this plugin. - * - * @param severity - * @param aCode - * @param aMessage - * @param exception - * @return A status configured with this plugin's id and the given parameters. - */ - public static IStatus createStatus(int severity, int aCode, - String aMessage, Throwable exception) { - return new Status(severity, PLUGIN_ID, aCode, - aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$ - } - - /** - * - * @param aCode - * @param aMessage - * @param exception - * @return A status configured with this plugin's id and the given parameters. - */ - public static IStatus createErrorStatus(int aCode, String aMessage, - Throwable exception) { - return createStatus(IStatus.ERROR, aCode, aMessage, exception); - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPluginIcons.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPluginIcons.java deleted file mode 100644 index 674084238..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEUIPluginIcons.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Nov 10, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.plugin; - -/** - * @author jsholl - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class J2EEUIPluginIcons { - - public static String EAR_IMPORT_WIZARD_BANNER = "import_ear_wiz"; //$NON-NLS-1$ - public static final String JCA_IMPORT_WIZARD_BANNER = "import_rar_wiz"; //$NON-NLS-1$ - public static final String EJB_IMPORT_WIZARD_BANNER = "import_ejbjar_wiz"; //$NON-NLS-1$ - public static final String APP_CLIENT_IMPORT_WIZARD_BANNER = "import_appclient_wiz"; //$NON-NLS-1$ - public static final String WEB_IMPORT_WIZARD_BANNER = "import_war_wiz"; //$NON-NLS-1$ - public static final String EAR_WIZ_BANNER = "ear_wiz"; //$NON-NLS-1$ - public static final String APP_CLIENT_PROJECT_WIZARD_BANNER = "appclient_wiz"; //$NON-NLS-1$ - //EJB Icons - public static final String EJB_PROJECT_WIZARD_BANNER = "ejbproject_wiz"; //$NON-NLS-1$ - //WEB Icons - public static final String WEB_PROJECT_WIZARD_BANNER = "war_wiz"; //$NON-NLS-1$ - //JCA Icons - public static final String JCA_PROJECT_WIZARD_BANNER = "connector_wiz"; //$NON-NLS-1$ - public static final String APP_CLIENT_EXPORT_WIZARD_BANNER = "export_appclient_wiz"; //$NON-NLS-1$ - public static final String EJB_EXPORT_WIZARD_BANNER = "export_ejbjar_obj"; //$NON-NLS-1$; - public static final String WEB_EXPORT_WIZARD_BANNER = "export_war_wiz"; //$NON-NLS-1$; - public static final String JCA_EXPORT_WIZARD_BANNER = "export_rar_wiz"; //$NON-NLS-1$; - public static final String EAR_EXPORT_WIZARD_BANNER = "export_ear_wiz"; //$NON-NLS-1$; - - //Migration Wizard Icons - - public static final String WARNING_TASK = "showwarn_tsk"; //$NON-NLS-1$ - - public static final String CLIENT_BANNER = "ejbclientjar_wizban"; //$NON-NLS-1$ - - public static final String MIGRATION_WIZARD_BANNER = "versionmigrate3_wiz"; //$NON-NLS-1$ - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEViewerSorter.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEViewerSorter.java deleted file mode 100644 index 27dcf804b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/J2EEViewerSorter.java +++ /dev/null @@ -1,53 +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.plugin; - - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; - -public class J2EEViewerSorter extends ViewerSorter { - - /** - * Constructor for J2EEViewerSorter. - */ - public J2EEViewerSorter() { - super(); - } - - - - /** - * @see ViewerSorter#compare(Viewer, Object, Object) - */ - public int compare(Viewer viewer, Object e1, Object e2) { - if (shouldSort(e1, e2)) - return super.compare(viewer, e1, e2); - return 0; - } - - protected boolean isEnterpriseBean(Object o) { - return o instanceof EnterpriseBean; - } - - protected boolean isDeploymentDescriptorRoot(Object o) { - return CommonUtil.isDeploymentDescriptorRoot(o); - } - - protected boolean shouldSort(Object e1, Object e2) { - return (isDeploymentDescriptorRoot(e1) && isDeploymentDescriptorRoot(e2)) || (isEnterpriseBean(e1) && isEnterpriseBean(e2)) || ((e1 instanceof IFile) && (e2 instanceof IFile)); - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/UIProjectUtilities.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/UIProjectUtilities.java deleted file mode 100644 index deb4f97e1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/plugin/UIProjectUtilities.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 2, 2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.plugin; - -import java.util.ArrayList; -import java.util.Iterator; -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.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.provider.ItemProvider; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * Utility class for retrieving the project from the specified selection - */ -public class UIProjectUtilities { - - /** - * @param selection - * The current selection - * @return The first project (regardless of nature) in the selection - */ - public static IProject getSelectedProject(IStructuredSelection selection) { - return getSelectedProject(selection, (String[]) null); - } - - /** - * @param selection - * The current selection - * @param expectedNatureId - * The required Nature ID - * @return The first project, only if the first project has the given nature - */ - public static IProject getSelectedProject(IStructuredSelection selection, String expectedNatureId) { - return getSelectedProject(selection, new String[] {expectedNatureId}); - } - - /** - * - * @param selection - * The current selection - * @param possibleNatureIds - * A list of possible nature ids - * @return The first project selected, only if it has AT LEAST ONE of the possible nature ids - */ - public static IProject getSelectedProject(IStructuredSelection selection, String[] possibleNatureIds) { - IProject[] projects = getAllSelectedProjects(selection, possibleNatureIds); - if (projects == null || projects.length==0) - return null; - return projects[0]; - } - - /** - * - * @param selection - * The current selection - * @return All selected Projects, regardless of nature - */ - public static IProject[] getAllSelectedProjects(IStructuredSelection selection) { - return getAllSelectedProjects(selection, (String[]) null); - } - - /** - * - * @param selection - * The current selection - * @param expectedNatureId - * The expected nature id - * @return All selected Projects which have the expected nature id - */ - public static IProject[] getAllSelectedProjects(IStructuredSelection selection, String expectedNatureId) { - return getAllSelectedProjects(selection, new String[] {expectedNatureId}); - } - - /** - * - * @param selection - * The current selection - * @param possibleNatureIds - * a list of possible nature ids - * @return All selected Projects which have AT LEAST ONE of the given nature ids - */ - public static IProject[] getAllSelectedProjects(IStructuredSelection selection, String[] possibleNatureIds) { - if (selection != null && !selection.isEmpty()) { - Object obj = null; - List projects = new ArrayList(); - Iterator selectionIterator = selection.iterator(); - while (selectionIterator.hasNext()) { - obj = selectionIterator.next(); - IProject project = null; - if (obj instanceof IProject) - project = (IProject) obj; - else if (obj instanceof IAdaptable) { - project = (IProject) ((IAdaptable) obj).getAdapter(IProject.class); - if (project == null) { - //Check for IJavaElements. - IJavaElement javaElement = (IJavaElement) ((IAdaptable) obj).getAdapter(IJavaElement.class); - if (javaElement != null) { - project = javaElement.getJavaProject().getProject(); - } - } - } - // Selection may not be adaptable to a project so continue trying to get selected project - if (project == null && obj instanceof EObject) - project = ProjectUtilities.getProject((EObject) obj); - else if (project == null && obj instanceof ItemProvider) { - Object temp = ((ItemProvider) obj).getParent(EObject.class); - if (temp != null && temp instanceof EObject) - project = ProjectUtilities.getProject((EObject) temp); - } - else if (project == null && obj instanceof IFile) - project = ProjectUtilities.getProject(obj); - - if (project != null && possibleNatureIds != null && possibleNatureIds.length > 0) { - try { - for (int i = 0; i < possibleNatureIds.length; i++) - if (project.hasNature(possibleNatureIds[i])) - projects.add(project); - } catch (CoreException e) { - //Ignore - } - } - - else - projects.add(project); - } - IProject[] finalProjects = new IProject[projects.size()]; - projects.toArray(finalProjects); - return finalProjects; - } - return new IProject[0]; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryContentProvider.java deleted file mode 100644 index fc2c1c3b1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryContentProvider.java +++ /dev/null @@ -1,132 +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.provider; - - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.emf.edit.provider.ITreeItemContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.ejb.provider.GroupedEJBJarItemProvider; - - -public class J2EEAdapterFactoryContentProvider extends AdapterFactoryContentProvider { - protected MethodsProviderDelegate methodsProviderDelegate; - protected static final Class ITreeItemContentProviderClass = ITreeItemContentProvider.class; - protected List roots = new ArrayList(); - - /** - * J2EEAdapterFactoryContentProvider constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - */ - public J2EEAdapterFactoryContentProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory) { - super(adapterFactory); - methodsProviderDelegate = new MethodsProviderDelegate(adapterFactory); - } - - public Object getParent(Object object) { - - if (MethodsProviderDelegate.providesContentFor(object)) - return methodsProviderDelegate.getParent(object); - - //Added so internalExpand() in AbstractTreeViewer knows that EJB's parent is now instance - // of J2EEItemProvider - //rather than EJBJar only if bean is root bean - if (object instanceof EnterpriseBean && GroupedEJBJarItemProvider.isRootBean((EnterpriseBean) object)) { - J2EEItemProvider provider = GroupedEJBJarItemProvider.getEJBItemProvider((EnterpriseBean) object); - if (provider != null) { - return provider; - } - } - - Object parent = super.getParent(object); - - // if (parent == null) { - // if (object instanceof EObject) - // return J2EERoot.instance().groupFor((EObject) object); - // } - return parent; - } - - protected boolean isEMFEditObject(Object object) { - ITreeItemContentProvider treeItemContentProvider = (ITreeItemContentProvider) adapterFactory.adapt(object, ITreeItemContentProviderClass); - return treeItemContentProvider != null; - } - - /* - * @see ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - - if (MethodsProviderDelegate.providesContentFor(parentElement)) - return methodsProviderDelegate.getChildren(parentElement); - else if (isEMFEditObject(parentElement)) - return super.getChildren(parentElement); - else - return null; - } - - /* - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - return getRoots(inputElement); - // else if (MethodsProviderDelegate.providesContentFor(inputElement)) - // return methodsProviderDelegate.getChildren(inputElement); - // return super.getElements(inputElement); - } - - public Object[] getRoots(Object parent) { - if (roots.isEmpty()) { - Object[] j2eeGroups = super.getChildren(parent); - roots.addAll(Arrays.asList(j2eeGroups)); - } - return roots.toArray(); - } - - /* - * @see ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - if (MethodsProviderDelegate.providesContentFor(element)) - return methodsProviderDelegate.hasChildren(element); - else if (isEMFEditObject(element)) - return super.hasChildren(element); - else - return false; - } - - /** - * @see IContentProvider#dispose() - */ - public void dispose() { - super.dispose(); - if (methodsProviderDelegate != null) - methodsProviderDelegate.dispose(); - } - - /** - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) { - super.inputChanged(aViewer, oldInput, newInput); - methodsProviderDelegate.inputChanged(aViewer, oldInput, newInput); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryLabelProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryLabelProvider.java deleted file mode 100644 index 026758bc3..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEAdapterFactoryLabelProvider.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.provider; - - -import java.io.File; -import java.net.URL; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.provider.IItemLabelProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.common.CommonPackage; -import org.eclipse.jst.j2ee.common.internal.util.CommonUtil; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; -import org.eclipse.jst.j2ee.internal.ejb.provider.AbstractMethodsContentProvider; -import org.eclipse.jst.j2ee.internal.ejb.provider.J2EEJavaClassProviderHelper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * Insert the type's description here. Creation date: (6/20/2001 10:40:41 PM) - * - * @author: Administrator - */ -public class J2EEAdapterFactoryLabelProvider extends AdapterFactoryLabelProvider { - // //$NON-NLS-1$ - protected static final Class IItemLabelProviderClass = IItemLabelProvider.class; - private static final EStructuralFeature ROLE_NAME_SF = CommonPackage.eINSTANCE.getSecurityRole_RoleName(); - private static final EStructuralFeature ROLES_SF = EjbFactoryImpl.getPackage().getMethodPermission_Roles(); - - - /** - * This is used for delegation to get labels for server objects, which don't fit into EMF edit - */ - protected WorkbenchLabelProvider wbLabelProvider; - - public J2EEAdapterFactoryLabelProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory) { - super(adapterFactory); - wbLabelProvider = new WorkbenchLabelProvider(); - } - - public Image getImage(Object object) { - if (object instanceof J2EEJavaClassProviderHelper) - return ((J2EEJavaClassProviderHelper) object).getImage(); - else if (isEMFEditObject(object)) - return super.getImage(object); - else if (object instanceof AbstractMethodsContentProvider.EJBMethodItem) - return super.getImage(((AbstractMethodsContentProvider.EJBMethodItem) object).ejb); - else if (object instanceof File) { - URL url = (URL) J2EEPlugin.getPlugin().getImage("jar_obj"); //$NON-NLS-1$ - return ImageDescriptor.createFromURL(url).createImage(); - } - return wbLabelProvider.getImage(object); - } - - public String getText(Object object) { - - if (object instanceof J2EEJavaClassProviderHelper) - return ((J2EEJavaClassProviderHelper) object).getText(); - else if (isEMFEditObject(object)) { - if (CommonUtil.isDeploymentDescriptorRoot(object)) - return J2EEUIMessages.getResourceString("Deployment_Descriptor_UI_") + ": " + super.getText(object); //$NON-NLS-1$ //$NON-NLS-2$ - return super.getText(object); - } else if (object instanceof AbstractMethodsContentProvider.EJBMethodItem) - return super.getText(((AbstractMethodsContentProvider.EJBMethodItem) object).ejb); - else if (object instanceof IFile) { - return ((IFile) object).getName(); - } else if (object instanceof File) { - return ((File)object).getName(); - } - return wbLabelProvider.getText(object); - } - - protected boolean isEMFEditObject(Object object) { - IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(object, IItemLabelProviderClass); - return itemLabelProvider != null; - } - - /* - * @see INotifyChangedListener#notifyChanged(new ENotificationImpl((InternalEObject)Object, - * int,(EStructuralFeature) Object, Object, Object, int)) - */ - public void notifyChanged(Notification notification) { - Object feature = notification.getFeature(); - if (feature == ROLE_NAME_SF || feature == ROLES_SF) - fireLabelProviderChanged(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProvider.java deleted file mode 100644 index d37e20823..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProvider.java +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.ApplicationPackage; -import org.eclipse.jst.j2ee.application.internal.impl.ApplicationFactoryImpl; -import org.eclipse.jst.j2ee.internal.application.provider.ApplicationItemProvider; -import org.eclipse.jst.j2ee.internal.ejb.provider.J2EENotificationImpl; - -public class J2EEApplicationItemProvider extends ApplicationItemProvider implements IAdaptable { - - protected static final Class IRESOURCE_CLASS = IResource.class; - protected static final Class IPROJECT_CLASS = IProject.class; - - protected Map children = new HashMap(); - protected List resourceAdapters = null; - - /** - * Constructor for J2EEApplicationItemProvider. - * - * @param adapterFactory - */ - public J2EEApplicationItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildren(Object) - */ - public Collection getChildren(Object object) { - List localChildren = (List) children.get(object); - if (localChildren == null) - return initChildren(object); - return localChildren; - } - - protected List initChildren(Object object) { - Application app = (Application) object; - List localChildren = new ArrayList(2); - // MDE: changed getParent(object) to just app - localChildren.add(new ModulesItemProvider(getAdapterFactory(), null, null, app)); - - // IProject project = ProjectUtilities.getProject(app); - // IVirtualComponent ear = ComponentUtilities.findComponent(app); - // TODO switch to retrieve referenceComponents - // EAREditModel editModel = null; - // try { - // EARNatureRuntime runtime = EARNatureRuntime.getRuntime(project); - // if (runtime != null) { - // editModel = runtime.getEarEditModelForRead(this); - // EARProjectMap map = editModel.getEARProjectMap(); - // localChildren.add(map); - // map.eResource().eAdapters().add(getNewAdapter(app)); - // } - // } finally { - // if (editModel != null) - // editModel.releaseAccess(this); - // } - localChildren.add(new J2EEUtilityJarItemProvider(app, getAdapterFactory(), this)); - - children.put(object, localChildren); - return localChildren; - } - - protected ModulesItemProvider getModulesNode(Object object) { - return (ModulesItemProvider) ((List) getChildren(object)).get(0); - } - - - /** - * @see Adapter#notifyChanged(new ENotificationImpl((InternalEObject)Notifier, - * int,(EStructuralFeature) EObject, Object, Object, int)) - * @deprecated - */ - public void notifyChanged(Notification notification) { - switch (notification.getFeatureID(Application.class)) { - case ApplicationPackage.APPLICATION__MODULES : - break; - default : - super.notifyChanged(notification); - } - if (notification.getEventType() == Notification.REMOVING_ADAPTER && notification.getOldValue() == this) - children.remove(notification.getNotifier()); - else if (notification.getFeature() == ApplicationFactoryImpl.getPackage().getApplication_Modules()) - modulesChanged((Application) notification.getNotifier(), notification.getEventType(), notification.getOldValue(), notification.getNewValue(), notification.getPosition()); - } - - protected void modulesChanged(Application app, int eventType, Object oldValue, Object newValue, int pos) { - ModulesItemProvider provider = getModulesNode(app); - Collection grandChildren = provider.getChildren(); - switch (eventType) { - case Notification.ADD : { - grandChildren.add(newValue); - break; - } - case Notification.ADD_MANY : { - grandChildren.addAll((Collection) newValue); - break; - } - case Notification.REMOVE : { - grandChildren.remove(oldValue); - break; - } - case Notification.REMOVE_MANY : { - grandChildren.removeAll((Collection) oldValue); - break; - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose() - */ - public void dispose() { - super.dispose(); - List adapters = getResourceAdapters(); - ResourceAdapter adapter = null; - for (int i = 0; i < adapters.size(); i++) { - adapter = (ResourceAdapter) adapters.get(i); - adapter.getTarget().eAdapters().remove(adapter); - } - } - - protected class ResourceAdapter extends AdapterImpl { - - private Application app = null; - - public ResourceAdapter(Application app) { - this.app = app; - } - - public void notifyChanged(Notification notification) { - - Resource res = (Resource) notification.getNotifier(); - if (notification.getEventType() == Notification.SET && notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED && !res.isLoaded()) { - J2EEApplicationItemProvider.this.children.remove(app); - res.eAdapters().remove(ResourceAdapter.this); - fireNotifyChanged(new J2EENotificationImpl(app, Notification.MOVE, (Object) null, (Object) null, 0)); - - } - } - } - - protected ResourceAdapter getNewAdapter(Application key) { - ResourceAdapter adapter = new ResourceAdapter(key); - getResourceAdapters().add(adapter); - return adapter; - } - - /** - * @return Returns the resourceAdapters. - */ - protected List getResourceAdapters() { - if (resourceAdapters == null) - resourceAdapters = new ArrayList(); - return resourceAdapters; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProviderAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProviderAdapterFactory.java deleted file mode 100644 index 0434b30f5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEApplicationItemProviderAdapterFactory.java +++ /dev/null @@ -1,34 +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.provider; - - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jst.j2ee.internal.application.provider.ApplicationItemProviderAdapterFactory; - - -public class J2EEApplicationItemProviderAdapterFactory extends ApplicationItemProviderAdapterFactory { - - /** - * Constructor for J2EEApplicationAdapterFactory. - */ - public J2EEApplicationItemProviderAdapterFactory() { - super(); - } - - /** - * @see ApplicationAdapterFactory#createApplicationAdapter() - */ - public Adapter createApplicationAdapter() { - return new J2EEApplicationItemProvider(this); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEBinaryModulesItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEBinaryModulesItemProvider.java deleted file mode 100644 index bf14b2df7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEBinaryModulesItemProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.provider; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -public class J2EEBinaryModulesItemProvider extends J2EEItemProvider { - - public J2EEBinaryModulesItemProvider(Application app, AdapterFactory adapterFactory, Collection children) { - super(adapterFactory, children); - } - - public String getText(Object obj) { - return J2EEUIMessages.BINARY; - } - - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("folder"); //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEEditingDomain.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEEditingDomain.java deleted file mode 100644 index ab07bd12f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEEditingDomain.java +++ /dev/null @@ -1,152 +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.provider; - - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.CopyToClipboardCommand; -import org.eclipse.emf.edit.command.CreateCopyCommand; -import org.eclipse.emf.edit.command.DragAndDropCommand; -import org.eclipse.emf.edit.command.InitializeCopyCommand; -import org.eclipse.emf.edit.command.MoveCommand; -import org.eclipse.emf.edit.command.OverrideableCommand; -import org.eclipse.emf.edit.command.PasteFromClipboardCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.ReplaceCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; - -/** - * Custom editing domain which provides hooks for creating override commands; should not be used - * directly but can be subclassed to override commands as necessary. All the override methods by - * default return null, so a subclass may override only a subset of the commands. - */ -public class J2EEEditingDomain extends AdapterFactoryEditingDomain { - /** - * J2EEEditingDomain constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - * @param commandStack - * CommandStack - */ - public J2EEEditingDomain(org.eclipse.emf.common.notify.AdapterFactory adapterFactory, CommandStack commandStack) { - super(adapterFactory, commandStack); - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createAddOverrideCommand(AddCommand addCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createCopyToClipboardOverrideCommand(CopyToClipboardCommand copyToClipboardCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createCreateCopyOverrideCommand(CreateCopyCommand createCopyCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createDragAndDropOverrideCommand(DragAndDropCommand dragAndDropCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createInitializeCopyOverrideCommand(InitializeCopyCommand initializeCopyCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createMoveOverrideCommand(MoveCommand moveCommand) { - return null; - } - - public Command createOverrideCommand(OverrideableCommand command) { - if (command instanceof AddCommand) { - AddCommand addCommand = (AddCommand) command; - return createAddOverrideCommand(addCommand); - } else if (command instanceof RemoveCommand) { - RemoveCommand removeCommand = (RemoveCommand) command; - return createRemoveOverrideCommand(removeCommand); - } else if (command instanceof SetCommand) { - SetCommand setCommand = (SetCommand) command; - return createSetOverrideCommand(setCommand); - } else if (command instanceof ReplaceCommand) { - ReplaceCommand replaceCommand = (ReplaceCommand) command; - return createReplaceOverrideCommand(replaceCommand); - } else if (command instanceof MoveCommand) { - MoveCommand moveCommand = (MoveCommand) command; - return createMoveOverrideCommand(moveCommand); - } else if (command instanceof CreateCopyCommand) { - CreateCopyCommand createCopyCommand = (CreateCopyCommand) command; - return createCreateCopyOverrideCommand(createCopyCommand); - } else if (command instanceof InitializeCopyCommand) { - InitializeCopyCommand initializeCopyCommand = (InitializeCopyCommand) command; - return createInitializeCopyOverrideCommand(initializeCopyCommand); - } else if (command instanceof CopyToClipboardCommand) { - CopyToClipboardCommand copyToClipboardCommand = (CopyToClipboardCommand) command; - return createCopyToClipboardOverrideCommand(copyToClipboardCommand); - } else if (command instanceof PasteFromClipboardCommand) { - PasteFromClipboardCommand pasteFromClipboardCommand = (PasteFromClipboardCommand) command; - return createPasteFromClipboardOverrideCommand(pasteFromClipboardCommand); - } else if (command instanceof DragAndDropCommand) { - DragAndDropCommand dragAndDropCommand = (DragAndDropCommand) command; - return createDragAndDropOverrideCommand(dragAndDropCommand); - } else { - return null; - } - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createPasteFromClipboardOverrideCommand(PasteFromClipboardCommand pasteFromClipboardCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createRemoveOverrideCommand(RemoveCommand removeCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createReplaceOverrideCommand(ReplaceCommand replaceCommand) { - return null; - } - - /** - * The default is not to override this command; subclasses can override if necessary - */ - protected Command createSetOverrideCommand(SetCommand setCommand) { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEModulemapItemProviderAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEModulemapItemProviderAdapterFactory.java deleted file mode 100644 index 1aacd78cb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEModulemapItemProviderAdapterFactory.java +++ /dev/null @@ -1,33 +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.provider; - - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapAdapterFactory; - -public class J2EEModulemapItemProviderAdapterFactory extends ModulemapItemProviderAdapterFactory { - - /** - * Constructor for J2EEModulemapItemProviderAdapterFactory. - */ - public J2EEModulemapItemProviderAdapterFactory() { - super(); - } - - /** - * @see ModulemapAdapterFactory#createEARProjectMapAdapter() - */ - public Adapter createEARProjectMapAdapter() { - return new J2EEUtilityJavaProjectsItemProvider(this, false); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEProviderUtility.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEProviderUtility.java deleted file mode 100644 index 3839ba39c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEProviderUtility.java +++ /dev/null @@ -1,38 +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.provider; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper; - -public class J2EEProviderUtility { - - private J2EEProviderUtility() { - super(); - } - - public static String prependProjectName(EObject object, String label) { - String projectName = null; - if (object.eResource() != null) { - IProject proj = WorkbenchResourceHelper.getProject(object.eResource()); - if (proj != null) - projectName = proj.getName(); - } - - if (projectName == null || projectName.equals(label)) - return label; - else if (label == null || label.length() == 0) - return projectName; - else - return projectName + ": " + label; //$NON-NLS-1$ - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUIEditingDomain.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUIEditingDomain.java deleted file mode 100644 index 4ce6309ac..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUIEditingDomain.java +++ /dev/null @@ -1,73 +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.provider; - - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.command.CopyToClipboardCommand; -import org.eclipse.emf.edit.command.PasteFromClipboardCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.jst.j2ee.internal.command.J2EEClipboard; -import org.eclipse.jst.j2ee.internal.command.J2EECopyToClipboardOverrideCommand; -import org.eclipse.jst.j2ee.internal.command.J2EEPasteFromClipboardOverrideCommand; -import org.eclipse.jst.j2ee.internal.command.J2EERemoveOverrideCommand; - - -public class J2EEUIEditingDomain extends J2EEEditingDomain { - /** - * J2EEUIEditingDomain constructor comment. - * - * @param adapterFactory - * org.eclipse.emf.common.notify.AdapterFactory - * @param commandStack - * CommandStack - */ - public J2EEUIEditingDomain(org.eclipse.emf.common.notify.AdapterFactory adapterFactory, CommandStack commandStack) { - super(adapterFactory, commandStack); - turnTraceOnIfDebugging(); - } - - protected Command createCopyToClipboardOverrideCommand(CopyToClipboardCommand copyToClipboardCommand) { - - if (copyToClipboardCommand instanceof J2EECopyToClipboardOverrideCommand) - return null; - return new J2EECopyToClipboardOverrideCommand(copyToClipboardCommand); - } - - protected Command createPasteFromClipboardOverrideCommand(PasteFromClipboardCommand pasteFromClipboardCommand) { - if (pasteFromClipboardCommand instanceof J2EEPasteFromClipboardOverrideCommand) - return null; - if (!(getClipboard() instanceof J2EEClipboard)) - return null; - return new J2EEPasteFromClipboardOverrideCommand(pasteFromClipboardCommand); - } - - protected Command createRemoveOverrideCommand(RemoveCommand removeCommand) { - return new J2EERemoveOverrideCommand(removeCommand); - } - - public J2EEClipboard getJ2EEClipboard() { - return (J2EEClipboard) getClipboard(); - } - - public Object getParent(Object object) { - Object parent = super.getParent(object); - if (parent != null) - return parent; - if (object instanceof EObject) - return ((EObject) object).eContainer(); - return null; - } - - protected void turnTraceOnIfDebugging() { - //AbstractCommand.Trace.enable(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJarItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJarItemProvider.java deleted file mode 100644 index 5e8e8797d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJarItemProvider.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.provider; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; - -/** - * @author jsholl - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class J2EEUtilityJarItemProvider extends J2EEItemProvider { - - public final static String UTILITY_JARS = J2EEUIMessages.getResourceString("Utility_JARs_UI_"); //$NON-NLS-1$ - - private boolean childrenLoaded = false; - private Application application = null; - - /** - * Constructor for J2EEUtilityJarItemProvider. - */ - public J2EEUtilityJarItemProvider(Application app, AdapterFactory adapterFactory, Object parent) { - super(adapterFactory); - setParent(parent); - application = app; - UtilityJarResourceChangeListener.INSTANCE.addUtilityJarItemProvider(ProjectUtilities.getProject(application), this); - } - - public boolean hasChildren(Object object) { - getChildren(object); - return !children.isEmpty(); - } - - public Collection getChildren(final Object object) { - if (!childrenLoaded) { - try { - disableNotification(); - org.eclipse.swt.custom.BusyIndicator.showWhile(null, new Runnable() { - public void run() { - computeChildren(); - } - }); - } finally { - enableNotification(); - } - } - return children; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#dispose() - */ - public void dispose() { - super.dispose(); - UtilityJarResourceChangeListener.INSTANCE.removeUtilityJarItemProvider(ProjectUtilities.getProject(application), this); - - } - - /** - * @see org.eclipse.emf.edit.provider.ItemProvider#getChildren(Object) - */ - private void computeChildren() { - childrenLoaded = true; - IVirtualComponent ear = ComponentUtilities.findComponent(application); - if (ear != null) { - EARArtifactEdit earEdit = null; - try { - earEdit = EARArtifactEdit.getEARArtifactEditForRead(ear); - IVirtualReference[] modules = earEdit.getUtilityModuleReferences(); - for (int i = 0; i < modules.length; i++) { - IVirtualComponent module = modules[i].getReferencedComponent(); - if (module.isBinary()) { - VirtualArchiveComponent virtualArchiveComponent = (VirtualArchiveComponent) module; - java.io.File diskFile = virtualArchiveComponent.getUnderlyingDiskFile(); - if (diskFile.exists()) - children.add(diskFile); - else { - // we will assume the component name is in synch with the module uri - IFile utilityJar = virtualArchiveComponent.getUnderlyingWorkbenchFile(); - if (utilityJar != null) - children.add(utilityJar); - } - } else { - - } - if (module.getProject() == null || !module.getProject().isAccessible()) - continue; - // return only jars for utility components - if (J2EEProjectUtilities.isUtilityProject(module.getProject())) { - IProject project = ProjectUtilities.getProject(application); - if (project == null) - continue; - // we will assume the component name is in synch with the module uri - IFile utilityJar = project.getFile(module.getName() + ".jar"); //$NON-NLS-1$ - if (utilityJar != null) { - if (utilityJar.exists()) - children.add(utilityJar); - else - children.add(new UtilityModuleProjectItemProvider(getAdapterFactory(),module.getProject(),this)); - } - - } - } - } finally { - if (earEdit != null) { - earEdit.dispose(); - } - } - } - } - - // private Collection getJars(List list, IResource[] members) { - // for (int i = 0; i < members.length; i++) { - // if (isJarFile(members[i])) { - // list.add(members[i]); - // } else if (members[i].getType() == IResource.FOLDER) { - // try { - // getJars(list, ((IFolder) members[i]).members()); - // } catch (CoreException e) { - // Logger.getLogger().logError(e); - // } - // } - // } - // return list; - // } - - public static boolean isJarFile(IResource member) { - return member.getType() == IResource.FILE && member.getName().toLowerCase().endsWith(".jar"); //$NON-NLS-1$ - } - - public static boolean isComponentFile(IResource member) { - return member.getType() == IResource.FILE && member.getName().toLowerCase().endsWith(IModuleConstants.COMPONENT_FILE_NAME); - } - - - /** - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getImage(Object) - */ - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("folder"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getText(Object) - */ - public String getText(Object object) { - return UTILITY_JARS; - } - - // assume this resource is a jar resource - public void utilityJarChanged(IResource resource, IResourceDelta delta) { - if (childrenLoaded) { - if (delta.getKind() == IResourceDelta.ADDED && !children.contains(resource)) { - children.add(resource); - } else if (delta.getKind() == IResourceDelta.REMOVED && children.contains(resource)) { - children.remove(resource); - } - } - } - - protected static class UtilityJarResourceChangeListener implements IResourceChangeListener, IResourceDeltaVisitor { - - protected static final UtilityJarResourceChangeListener INSTANCE = new UtilityJarResourceChangeListener(); - - private boolean listening = false; - private Map earProjectsToUtilityJarProviderMap; - - public void addUtilityJarItemProvider(IProject project, J2EEUtilityJarItemProvider utilityJarItemProvider) { - List providers = getProviders(project); - if (providers != null) - providers.add(utilityJarItemProvider); - if (!listening) { - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - listening = true; - } - } - - /** - * @param project - * @return - */ - private List getProviders(IProject project) { - List result = (List) getEarProjectsToUtilityJarProviderMap().get(project); - if (result == null && project != null) - getEarProjectsToUtilityJarProviderMap().put(project, (result = new ArrayList())); - return result; - } - - /** - * @return - */ - private Map getEarProjectsToUtilityJarProviderMap() { - if (earProjectsToUtilityJarProviderMap == null) - earProjectsToUtilityJarProviderMap = new HashMap(); - return earProjectsToUtilityJarProviderMap; - } - - public void removeUtilityJarItemProvider(IProject project, J2EEUtilityJarItemProvider utilityJarItemProvider) { - List providers = getProviders(project); - providers.remove(utilityJarItemProvider); - if (providers.isEmpty()) - getEarProjectsToUtilityJarProviderMap().remove(project); - - if (getEarProjectsToUtilityJarProviderMap().isEmpty()) { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - listening = false; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - event.getDelta().accept(this); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta) - */ - public boolean visit(IResourceDelta delta) { - switch (delta.getResource().getType()) { - case IResource.ROOT : - case IResource.FOLDER : - return true; - - case IResource.PROJECT : - return getEarProjectsToUtilityJarProviderMap().containsKey(delta.getResource()); - case IResource.FILE : { - IResource resource = delta.getResource(); - if (isComponentFile(resource)) { - List utilityJarItemProviders = getProviders(resource.getProject()); - for (int i = 0; i < utilityJarItemProviders.size(); i++) { - ((J2EEUtilityJarItemProvider) utilityJarItemProviders.get(i)).getChildren().clear(); - ((J2EEUtilityJarItemProvider) utilityJarItemProviders.get(i)).computeChildren(); - } - } - return false; - } - - } - return false; - } - } - - public IFile getAssociatedFile() { - - try { - if (application != null && application.eResource() != null) { - return WorkbenchResourceHelperBase.getIFile(application.eResource().getURI()); - } - } catch (Throwable t) { - - } - return null; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJavaProjectsItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJavaProjectsItemProvider.java deleted file mode 100644 index 7e773b5ee..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/J2EEUtilityJavaProjectsItemProvider.java +++ /dev/null @@ -1,55 +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.provider; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.provider.ItemProviderAdapter; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; - -public class J2EEUtilityJavaProjectsItemProvider extends EARProjectMapItemProvider { - - public final static String UTILITY_JAVA_PROJECTS = J2EEUIMessages.getResourceString("Utility_Java_Projects_UI_"); //$NON-NLS-1$ - - /** - * Constructor for UtilityJARsItemProvider. - * - * @param adapterFactory - */ - public J2EEUtilityJavaProjectsItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * Constructor for UtilityJARsItemProvider. - * - * @param adapterFactory - * @param includeModules - */ - public J2EEUtilityJavaProjectsItemProvider(AdapterFactory adapterFactory, boolean includeModules) { - super(adapterFactory, includeModules); - } - - /** - * @see ItemProviderAdapter#getImage(Object) - */ - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("folder"); //$NON-NLS-1$ - } - - /** - * @see ItemProviderAdapter#getText(Object) - */ - public String getText(Object object) { - return UTILITY_JAVA_PROJECTS; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/MethodsProviderDelegate.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/MethodsProviderDelegate.java deleted file mode 100644 index 1200806d7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/MethodsProviderDelegate.java +++ /dev/null @@ -1,119 +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.provider; - - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.ejb.ExcludeList; -import org.eclipse.jst.j2ee.ejb.MethodPermission; -import org.eclipse.jst.j2ee.ejb.MethodTransaction; -import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl; -import org.eclipse.jst.j2ee.internal.ejb.provider.AbstractMethodsContentProvider; -import org.eclipse.jst.j2ee.internal.ejb.provider.ExcludeListContentProvider; -import org.eclipse.jst.j2ee.internal.ejb.provider.MethodPermissionsContentProvider; -import org.eclipse.jst.j2ee.internal.ejb.provider.MethodTransactionContentProvider; - - -public class MethodsProviderDelegate implements ITreeContentProvider { - - protected ExcludeListContentProvider excludeListContentProvider; - protected MethodPermissionsContentProvider methodPermissionsContentProvider; - protected MethodTransactionContentProvider methodTransactionContentProvider; - - protected static EObject EL_META = EjbFactoryImpl.getPackage().getExcludeList(); - protected static EObject MP_META = EjbFactoryImpl.getPackage().getMethodPermission(); - protected static EObject MT_META = EjbFactoryImpl.getPackage().getMethodTransaction(); - - public static boolean providesContentFor(Object object) { - return object instanceof AbstractMethodsContentProvider.EJBMethodItem || object instanceof MethodPermission || object instanceof MethodTransaction || object instanceof ExcludeList; - } - - public MethodsProviderDelegate(AdapterFactory adapterFactory) { - super(); - excludeListContentProvider = new ExcludeListContentProvider(adapterFactory, false); - methodPermissionsContentProvider = new MethodPermissionsContentProvider(adapterFactory, false); - methodTransactionContentProvider = new MethodTransactionContentProvider(adapterFactory, false); - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - if (excludeListContentProvider != null) - excludeListContentProvider.dispose(); - if (methodPermissionsContentProvider != null) - methodPermissionsContentProvider.dispose(); - if (methodTransactionContentProvider != null) - methodTransactionContentProvider.dispose(); - } - - public AbstractMethodsContentProvider getContentProvider(Object object) { - EObject metaClass = null; - if (object instanceof AbstractMethodsContentProvider.EJBMethodItem) - metaClass = ((AbstractMethodsContentProvider.EJBMethodItem) object).refObject.eClass(); - else - metaClass = ((EObject) object).eClass(); - - if (metaClass == EL_META) - return excludeListContentProvider; - else if (metaClass == MP_META) - return methodPermissionsContentProvider; - else if (metaClass == MT_META) - return methodTransactionContentProvider; - - return null; - } - - - /** - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - excludeListContentProvider.inputChanged(viewer, oldInput, newInput); - methodPermissionsContentProvider.inputChanged(viewer, oldInput, newInput); - methodTransactionContentProvider.inputChanged(viewer, oldInput, newInput); - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object) - */ - public Object[] getChildren(Object parentElement) { - AbstractMethodsContentProvider prov = getContentProvider(parentElement); - return prov == null ? null : prov.getChildren(parentElement); - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object) - */ - public Object getParent(Object element) { - AbstractMethodsContentProvider prov = getContentProvider(element); - return prov == null ? null : prov.getParent(element); - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object) - */ - public boolean hasChildren(Object element) { - AbstractMethodsContentProvider prov = getContentProvider(element); - return prov != null && prov.hasChildren(element); - } - - /** - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - AbstractMethodsContentProvider prov = getContentProvider(inputElement); - return prov == null ? null : prov.getElements(inputElement); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/ModulesItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/ModulesItemProvider.java deleted file mode 100644 index 038cf30b7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/ModulesItemProvider.java +++ /dev/null @@ -1,287 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.provider; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.application.Module; -import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -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; - -public class ModulesItemProvider extends J2EEItemProvider { - public static final String MODULES = J2EEUIMessages.getResourceString("Modules_UI_"); //$NON-NLS-1$ - - /** - * Constructor for ModulesItemProvider. - */ - public ModulesItemProvider() { - super(); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param children - */ - public ModulesItemProvider(Collection children) { - super(children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - */ - public ModulesItemProvider(String text) { - super(text); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - * @param children - */ - public ModulesItemProvider(String text, Collection children) { - super(text, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - * @param image - */ - public ModulesItemProvider(String text, Object image) { - super(text, image); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - * @param image - * @param children - */ - public ModulesItemProvider(String text, Object image, Collection children) { - super(text, image, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - * @param image - * @param parent - */ - public ModulesItemProvider(String text, Object image, Object parent) { - super(text, image, parent); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param text - * @param image - * @param parent - * @param children - */ - public ModulesItemProvider(String text, Object image, Object parent, Collection children) { - super(text, image, parent, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - */ - public ModulesItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text) { - super(adapterFactory, text); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - * @param image - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text, Object image) { - super(adapterFactory, text, image); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - * @param image - * @param parent - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent) { - super(adapterFactory, text, image, parent); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param children - */ - public ModulesItemProvider(AdapterFactory adapterFactory, Collection children) { - super(adapterFactory, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - * @param children - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text, Collection children) { - super(adapterFactory, text, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - * @param image - * @param children - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text, Object image, Collection children) { - super(adapterFactory, text, image, children); - } - - /** - * Constructor for ModulesItemProvider. - * - * @param adapterFactory - * @param text - * @param image - * @param parent - * @param children - */ - public ModulesItemProvider(AdapterFactory adapterFactory, String text, Object image, Object parent, Collection children) { - super(adapterFactory, text, image, parent, children); - } - - - /** - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getImage(Object) - */ - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("folder"); //$NON-NLS-1$ - } - - public Application getParentApplication() { - return (Application) getParent(); - } - - public IFile getAssociatedFile() { - - try { - Application application = getParentApplication(); - if (application != null && application.eResource() != null) { - return WorkbenchResourceHelperBase.getIFile(application.eResource().getURI()); - } - } catch (Throwable t) { - - } - return null; - } - - - /** - * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(Object) - */ - public String getText(Object object) { - return MODULES; - } - - public boolean hasChildren(Object object) { - getChildren(object); - return !localChildren.isEmpty(); - } - - private List localChildren = null; - - public Collection getChildren(Object object) { - return initChildren(object); - } - - protected List initChildren(Object object) { - localChildren = new ArrayList(); - Application app = (Application) getParent(); - IVirtualComponent ear = ComponentUtilities.findComponent(app); - List modules = app.getModules(); - List binaryModules = new ArrayList(); - IVirtualReference[] refs = ear.getReferences(); - for (int i = 0; i < modules.size(); i++) { - Module module = (Module) modules.get(i); - String moduleURI = module.getUri(); - boolean foundBinary = false; - for (int j = 0; j < refs.length && !foundBinary; j++) { - IVirtualComponent component = refs[j].getReferencedComponent(); - if (component.isBinary()) { - if (refs[j].getArchiveName().equals(moduleURI)) { - foundBinary = true; - JavaEEBinaryComponentHelper helper = null; - try { - helper = new JavaEEBinaryComponentHelper(component); - Object binaryModule = helper.getPrimaryRootObject(); - if (binaryModule != null) { - binaryModules.add(binaryModule); - } - } finally { - if(helper != null){ - helper.dispose(); - } - } - } - } - } - if (!foundBinary) { - localChildren.add(module); - } - } - - if (!binaryModules.isEmpty()) { - localChildren.add(new J2EEBinaryModulesItemProvider(app, getAdapterFactory(), binaryModules)); - } - - return localChildren; - - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/UtilityModuleProjectItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/UtilityModuleProjectItemProvider.java deleted file mode 100644 index d3c650e7c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/provider/UtilityModuleProjectItemProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.provider; - -import java.util.Collection; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.provider.ItemProviderAdapter; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; - -public class UtilityModuleProjectItemProvider extends J2EEItemProvider { - - private IProject utilProject; - - public UtilityModuleProjectItemProvider(AdapterFactory adapterFactory, IProject project, Object parent) { - super(adapterFactory); - setParent(parent); - utilProject = project; - // TODO Auto-generated constructor stub - } - - /** - * @see ItemProviderAdapter#getImage(Object) - */ - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("icons/full/obj16/prjutiljar_obj"); //$NON-NLS-1$ - } - - /** - * @see ItemProviderAdapter#getText(Object) - */ - public String getText(Object object) { - - return utilProject.getName(); - } - - @Override - public Collection<?> getChildren(Object object) { - // TODO Auto-generated method stub - return super.getChildren(object); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableItem.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableItem.java deleted file mode 100644 index 7ffb5a95d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableItem.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 SAP AG 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: - * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.ui; - -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jst.j2ee.internal.SecondCheckBoxStateChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; - -public class DoubleCheckboxTableItem extends TableItem { - - protected int mSecondCheckboxColumnIndex; - protected Button secondCheckBox; - protected SelectionListener selLstnr; - protected ICheckStateListener tblLstnr = null; - protected DoubleCheckboxTableViewer tableViewer; - - public DoubleCheckboxTableItem (Table parent, int style, int secondCheckboxColumnIndex, DoubleCheckboxTableViewer tableViewer) { - super(parent, style); - mSecondCheckboxColumnIndex = secondCheckboxColumnIndex; - this.tableViewer = tableViewer; - createCheckBox(parent); - } - - public DoubleCheckboxTableItem(Table parent, int style, int index, int secondCheckboxColumnIndex, DoubleCheckboxTableViewer tableViewer) { - super(parent, style, index); - mSecondCheckboxColumnIndex = secondCheckboxColumnIndex; - this.tableViewer = tableViewer; - createCheckBox(parent); - } - - public void setSecondChecked (boolean checked) { - secondCheckBox.setSelection(checked); - } - - public boolean getSecondChecked() { - return secondCheckBox.getSelection(); - } - - public void setSecondGrayed(boolean grayed) { - secondCheckBox.setGrayed(grayed); - } - - public boolean getSecondGrayed() { - return secondCheckBox.getGrayed(); - } - - public void setSecondEnabled(boolean enabled) { - secondCheckBox.setEnabled(enabled); - } - - public boolean getSecondEnabled() { - return secondCheckBox.getEnabled(); - } - - public boolean isSecondEnabled() { - return secondCheckBox.isEnabled(); - } - - private void createCheckBox(Table parentTable) { - secondCheckBox = new Button(parentTable, SWT.CHECK | SWT.FLAT); - secondCheckBox.pack(); - final DoubleCheckboxTableItem th = this; - selLstnr = new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - SecondCheckBoxStateChangedEvent evt = new SecondCheckBoxStateChangedEvent(tableViewer, - getData(), - getChecked()); - evt.setTableItem(th); - tblLstnr.checkStateChanged(evt); - } - public void widgetDefaultSelected(SelectionEvent e) {} - }; - secondCheckBox.addSelectionListener(selLstnr); - } - - public Button getSecondCheckBox() { - return secondCheckBox; - } - - public void dispose() { - disposeSecondCheckbox(); - super.dispose(); - } - - protected void disposeSecondCheckbox() { - if (secondCheckBox != null) { - secondCheckBox.removeSelectionListener(selLstnr); - secondCheckBox.dispose(); - secondCheckBox = null; - } - selLstnr = null; - } - - void setTableListener(ICheckStateListener tblLstnr) { - this.tblLstnr = tblLstnr; - } - - protected void checkSubclass () {} - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableViewer.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableViewer.java deleted file mode 100644 index f837b9213..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/DoubleCheckboxTableViewer.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 SAP AG 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: - * Stefan Dimov, stefan.dimov@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.ui; - -import java.util.ArrayList; -import java.util.Hashtable; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ViewerRow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.TableEditor; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; - -public class DoubleCheckboxTableViewer extends CheckboxTableViewer { - - protected int mSecondCheckboxColumnIndex; - protected ICheckStateListener lstnr = null; - - public DoubleCheckboxTableViewer(Table table, int secondCheckBoxColumnIndex) { - super(table); - if (secondCheckBoxColumnIndex < 1) - throw new IllegalArgumentException( - "The index of the second column with check box must be bigger than zero"); //$NON-NLS-1$ - - mSecondCheckboxColumnIndex = secondCheckBoxColumnIndex; - } - - public void addCheckStateListener(ICheckStateListener listener) { - super.addCheckStateListener(listener); - lstnr = listener; - } - - public void removeCheckStateListener(ICheckStateListener listener) { - super.removeCheckStateListener(listener); - lstnr = null; - getTable().getItems(); - for (int i = 0; i < getTable().getItems().length; i++) { - DoubleCheckboxTableItem it = (DoubleCheckboxTableItem)getTable().getItem(i); - it.setTableListener(null); - } - } - - protected ViewerRow internalCreateNewRowPart(int style, int rowIndex) { - DoubleCheckboxTableItem item; - if (rowIndex >= 0) { - item = new DoubleCheckboxTableItem(getTable(), style, rowIndex, mSecondCheckboxColumnIndex, this); - } else { - item = new DoubleCheckboxTableItem(getTable(), style, mSecondCheckboxColumnIndex, this); - } - item.setTableListener(lstnr); - TableEditor editor = new TableEditor(getTable()); - editor.minimumWidth = item.getSecondCheckBox().getSize ().x; - editor.horizontalAlignment = SWT.CENTER; - editor.setEditor(item.getSecondCheckBox(), item, mSecondCheckboxColumnIndex); - return getViewerRowFromItem(item); - } - - public Object[] getSecondCheckedItems() { - TableItem[] children = getTable().getItems(); - ArrayList v = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)children[i]; - if (item.getSecondChecked()) { - v.add(item); - } - } - return v.toArray(); - } - - public void setAllSecondChecked(boolean state) { - TableItem[] children = getTable().getItems(); - for (int i = 0; i < children.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)children[i]; - item.setSecondChecked(state); - } - } - - public Object[] getSingleCheckedElements() { - TableItem[] children = getTable().getItems(); - ArrayList v = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)children[i]; - if (item.getChecked() && (!item.getSecondChecked())) { - v.add(item.getData()); - } - } - return v.toArray(); - } - - public Object[] getDoubleCheckedElements() { - TableItem[] children = getTable().getItems(); - ArrayList v = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)children[i]; - if (item.getChecked() && item.getSecondChecked()) { - v.add(item.getData()); - } - } - return v.toArray(); - } - - public Object[] getUncheckedItems() { - TableItem[] children = getTable().getItems(); - ArrayList v = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - TableItem item = children[i]; - if (!item.getChecked()) { - v.add(item); - } - } - return v.toArray(); - } - - - public Object[] getSecondUncheckedElements() { - TableItem[] children = getTable().getItems(); - ArrayList v = new ArrayList(children.length); - for (int i = 0; i < children.length; i++) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)children[i]; - if (!item.getSecondChecked()) { - v.add(item.getData()); - } - } - return v.toArray(); - } - - public void setSecondCheckedItems(Object[] inputItems) { - assertElementsNotNull(inputItems); - Hashtable set = new Hashtable(); - for (int i = 0; i < inputItems.length; ++i) { - set.put(inputItems[i], inputItems[i]); - } - TableItem[] items = getTable().getItems(); - for (int i = 0; i < items.length; ++i) { - DoubleCheckboxTableItem item = (DoubleCheckboxTableItem)items[i]; - boolean check = set.containsKey(item); - if (item.getSecondChecked() != check) { - item.setSecondChecked(check); - } - - } - } - - @Override - protected void doRemove(int start, int end) { - // ensure that the second check box is disposed - for (int i = start; i <= end; i++) { - disposeSecondCheckboxOfItem(i); - } - - super.doRemove(start, end); - } - - @Override - protected void doRemove(int[] indices) { - // ensure that the second check box is disposed - for (int i : indices) { - disposeSecondCheckboxOfItem(i); - } - - super.doRemove(indices); - } - - private void disposeSecondCheckboxOfItem(int index) { - TableItem item = getTable().getItem(index); - if (item instanceof DoubleCheckboxTableItem) { - ((DoubleCheckboxTableItem) item).disposeSecondCheckbox(); - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEPropertiesPage.java deleted file mode 100644 index fff1160ac..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/J2EEPropertiesPage.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.ui; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.jst.j2ee.internal.J2EEPropertiesConstants; -import org.eclipse.jst.j2ee.internal.ui.refactoring.RenameContextRootChange; -import org.eclipse.jst.j2ee.internal.ui.refactoring.RenameContextRootRefactoringProcessor; -import org.eclipse.jst.j2ee.internal.ui.refactoring.RenameContextRootWizard; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.ltk.ui.refactoring.RefactoringWizard; -import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; - -public class J2EEPropertiesPage extends PropertyPage implements J2EEPropertiesConstants { - - private Text contextRootNameField; - private boolean dirty = false; - - /** - * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) - */ - protected Control createContents(Composite parent) { - Composite c = parent; - IProject project = getProject(); - if (project != null - && JavaEEProjectUtilities.getJ2EEProjectType(project).equals( - JavaEEProjectUtilities.DYNAMIC_WEB) - || JavaEEProjectUtilities.getJ2EEProjectType(project).equals( - JavaEEProjectUtilities.STATIC_WEB)) { - - c = new Composite(parent, SWT.NONE); - - Label contextRootLabel = new Label(c, SWT.NONE); - contextRootLabel.setText(J2EEPropertiesConstants.WEB_CONTEXT_ROOT); - - contextRootNameField = new Text(c, SWT.BORDER); - contextRootNameField.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - dirty = !contextRootNameField.getText().equals( - ComponentUtilities.getServerContextRoot(getProject())); - validateText(); - } - }); - GridLayoutFactory.fillDefaults().numColumns(2).applyTo(c); - GridDataFactory.defaultsFor(contextRootLabel).applyTo(contextRootLabel); - GridDataFactory.defaultsFor(contextRootNameField).grab(true, false).applyTo( - contextRootNameField); - } - applyDialogFont(c); - return c; - } - - @Override - public void createControl(Composite parent) { - super.createControl(parent); - refresh(); - refreshApplyButton(); - } - - private void validateText() { - IStatus status = RenameContextRootChange - .validateContextRoot(contextRootNameField.getText()); - if (!status.isOK()) { - setErrorMessage(status.getMessage()); - setValid(false); - } - else { - setErrorMessage(null); - setValid(true); - refreshApplyButton(); - } - } - - private void refreshApplyButton() { - if (dirty) { - if (getApplyButton() != null) { - getApplyButton().setEnabled(true); - } - } - else { - if (getApplyButton() != null) { - getApplyButton().setEnabled(false); - } - } - } - - public void refresh() { - if (contextRootNameField != null) { - String s = ComponentUtilities.getServerContextRoot(getProject()); - if (s == null) { - s = ""; //$NON-NLS-1$ - } - contextRootNameField.setText(s); - validateText(); - } - } - - private IProject getProject() { - - Object element = getElement(); - if (element == null) { - return null; - } - if (element instanceof IProject) { - IProject project = (IProject) element; - return project; - } - return null; - - } - - private int doRefactor() { - int id = IDialogConstants.OK_ID; - if (dirty) { - RenameContextRootRefactoringProcessor processor = new RenameContextRootRefactoringProcessor(); - processor.setProject(getProject()); - processor.setNewName(contextRootNameField.getText()); - RenameContextRootWizard wizard = new RenameContextRootWizard(processor, - RefactoringWizard.DIALOG_BASED_USER_INTERFACE); - wizard.setPrompt(false); - RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wizard); - - try { - id = operation.run(getShell(), ""); //$NON-NLS-1$ - } - catch (InterruptedException ee) { - - } - if (id == IDialogConstants.OK_ID) { - dirty = false; - refresh(); - } - } - - return id; - } - - @Override - protected void performApply() { - doRefactor(); - } - - @Override - protected void performDefaults() { - refresh(); - } - - public boolean performOk() { - return doRefactor() == IDialogConstants.OK_ID; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.java deleted file mode 100644 index 00aaeb696..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.java +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2008 Oracle - * 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: - * Konstantin Komissarchik - initial implementation and ongoing maintenance - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.ui; - -import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener; -import org.eclipse.jst.common.project.facet.ui.libprov.osgi.OsgiBundlesLibraryProviderInstallPanel; -import org.eclipse.jst.j2ee.internal.common.classpath.WtpOsgiBundlesLibraryProviderInstallOperationConfig; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> - */ - -public class WtpOsgiBundlesLibraryProviderInstallPanel - - extends OsgiBundlesLibraryProviderInstallPanel - -{ - @Override - protected Control createFooter( final Composite composite ) - { - final WtpOsgiBundlesLibraryProviderInstallOperationConfig cfg - = (WtpOsgiBundlesLibraryProviderInstallOperationConfig) getOperationConfig(); - - final Button copyOnPublishCheckBox = new Button( composite, SWT.CHECK ); - copyOnPublishCheckBox.setText( Resources.copyLibraries ); - copyOnPublishCheckBox.setSelection( cfg.isIncludeWithApplicationEnabled() ); - - copyOnPublishCheckBox.addSelectionListener - ( - new SelectionAdapter() - { - @Override - public void widgetSelected( final SelectionEvent event ) - { - cfg.setIncludeWithApplicationEnabled( copyOnPublishCheckBox.getSelection() ); - } - } - ); - - final IPropertyChangeListener listener = new IPropertyChangeListener() - { - public void propertyChanged( final String property, - final Object oldValue, - final Object newValue ) - { - copyOnPublishCheckBox.setSelection( cfg.isIncludeWithApplicationEnabled() ); - } - }; - - cfg.addListener( listener, WtpOsgiBundlesLibraryProviderInstallOperationConfig.PROP_INCLUDE_WITH_APPLICATION_ENABLED ); - - copyOnPublishCheckBox.addDisposeListener - ( - new DisposeListener() - { - public void widgetDisposed( final DisposeEvent event ) - { - cfg.removeListener( listener ); - } - } - ); - - return copyOnPublishCheckBox; - } - - private static final class Resources - - extends NLS - - { - public static String copyLibraries; - - static - { - initializeMessages( WtpOsgiBundlesLibraryProviderInstallPanel.class.getName(), - Resources.class ); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.properties deleted file mode 100644 index 3a7071535..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpOsgiBundlesLibraryProviderInstallPanel.properties +++ /dev/null @@ -1 +0,0 @@ -copyLibraries = Include libraries with this application diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.java deleted file mode 100644 index f457e1272..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.java +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2008 Oracle - * 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: - * Konstantin Komissarchik - initial implementation and ongoing maintenance - ******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.ui; - -import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener; -import org.eclipse.jst.common.project.facet.ui.libprov.user.UserLibraryProviderInstallPanel; -import org.eclipse.jst.j2ee.internal.common.classpath.WtpUserLibraryProviderInstallOperationConfig; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a> - */ - -public class WtpUserLibraryProviderInstallPanel - - extends UserLibraryProviderInstallPanel - -{ - @Override - protected Control createControlNextToManageHyperlink( final Composite composite ) - { - final WtpUserLibraryProviderInstallOperationConfig cfg - = (WtpUserLibraryProviderInstallOperationConfig) getOperationConfig(); - - final Button copyOnPublishCheckBox = new Button( composite, SWT.CHECK ); - copyOnPublishCheckBox.setText( Resources.copyLibraries ); - copyOnPublishCheckBox.setSelection( cfg.isIncludeWithApplicationEnabled() ); - - copyOnPublishCheckBox.addSelectionListener - ( - new SelectionAdapter() - { - @Override - public void widgetSelected( final SelectionEvent event ) - { - cfg.setIncludeWithApplicationEnabled( copyOnPublishCheckBox.getSelection() ); - } - } - ); - - final IPropertyChangeListener listener = new IPropertyChangeListener() - { - public void propertyChanged( final String property, - final Object oldValue, - final Object newValue ) - { - copyOnPublishCheckBox.setSelection( cfg.isIncludeWithApplicationEnabled() ); - } - }; - - cfg.addListener( listener, WtpUserLibraryProviderInstallOperationConfig.PROP_INCLUDE_WITH_APPLICATION_ENABLED ); - - copyOnPublishCheckBox.addDisposeListener - ( - new DisposeListener() - { - public void widgetDisposed( final DisposeEvent event ) - { - cfg.removeListener( listener ); - } - } - ); - - return copyOnPublishCheckBox; - } - - private static final class Resources - - extends NLS - - { - public static String copyLibraries; - - static - { - initializeMessages( WtpUserLibraryProviderInstallPanel.class.getName(), - Resources.class ); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.properties deleted file mode 100644 index 3a7071535..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/WtpUserLibraryProviderInstallPanel.properties +++ /dev/null @@ -1 +0,0 @@ -copyLibraries = Include libraries with this application diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java deleted file mode 100644 index 768e3462a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/preferences/JavaEEPreferencePage.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.jst.j2ee.internal.ui.preferences; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -public class JavaEEPreferencePage extends PreferencePage implements - IWorkbenchPreferencePage { - - private Preferences preferences; - private String name = J2EEPlugin.DYNAMIC_TRANSLATION_OF_JET_TEMPLATES_PREF_KEY; - private Button showReferences; - private boolean dynamicTranslation; - - public JavaEEPreferencePage() { - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_NAME)); - } - - @Override - protected void performDefaults() { - preferences.setToDefault(name); - J2EEPlugin.getDefault().savePluginPreferences(); - dynamicTranslation = preferences.getBoolean(name); - showReferences.setSelection(dynamicTranslation); - super.performDefaults(); - } - - @Override - protected Control createContents(Composite parent) { - Composite result= new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth= 0; - layout.verticalSpacing= convertVerticalDLUsToPixels(10); - layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - result.setLayout(layout); - Group buttonComposite= new Group(result, SWT.NONE); - buttonComposite.setLayout(new GridLayout()); - buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - buttonComposite.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_JET_TEMPLATE)); - - showReferences = new Button(buttonComposite, SWT.CHECK); - showReferences.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVA_EE_PREFERENCE_PAGE_DYN_TRANSLATION_BTN_NAME)); //$NON-NLS-1$ - showReferences.setSelection(dynamicTranslation); - showReferences.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - dynamicTranslation = showReferences.getSelection(); - } - }); - return result; - } - - public void init(IWorkbench workbench) { - preferences = J2EEPlugin.getDefault().getPluginPreferences(); - dynamicTranslation = preferences.getBoolean(name); - } - - @Override - public boolean performOk() { - preferences.setValue(name, showReferences.getSelection()); - J2EEPlugin.getDefault().savePluginPreferences(); - return super.performOk(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/ContextRootInputPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/ContextRootInputPage.java deleted file mode 100644 index 4c49b496c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/ContextRootInputPage.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.ui.refactoring; - -import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class ContextRootInputPage extends UserInputWizardPage { - - private final RenameContextRootRefactoringProcessor fProcessor; - private Text fNameField; - - public ContextRootInputPage(String name, RenameContextRootRefactoringProcessor processor) { - super(name); - this.fProcessor = processor; - } - - public void createControl(Composite parent) { - Composite c = new Composite(parent, SWT.NONE); - - Label label = new Label(c, SWT.NONE); - label.setText(J2EEUIMessages.getResourceString("NewContextRoot")); //$NON-NLS-1$ - - fNameField = new Text(c, SWT.BORDER); - fNameField.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); - - fNameField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validatePage(); - } - - }); - String oldName = fProcessor.getOldContextRoot(); - if (oldName != null && oldName.length() > 0) { - fNameField.setText(oldName); - fNameField.setSelection(0, oldName.length()); - } - - GridLayoutFactory.swtDefaults().numColumns(2).applyTo(c); - - setControl(c); - fNameField.setFocus(); - - validatePage(); - } - - private void validatePage() { - String text = fNameField.getText(); - RefactoringStatus status = fProcessor.validateNewElementName(text); - setPageComplete(status); - } - - @Override - protected boolean performFinish() { - initializeRefactoring(); - return super.performFinish(); - } - - @Override - public IWizardPage getNextPage() { - initializeRefactoring(); - return super.getNextPage(); - } - - private void initializeRefactoring() { - fProcessor.setNewName(fNameField.getText()); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootChange.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootChange.java deleted file mode 100644 index d42229eef..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootChange.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - package org.eclipse.jst.j2ee.internal.ui.refactoring; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.ProjectSupportResourceHandler; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -import com.ibm.icu.util.StringTokenizer; - -public class RenameContextRootChange extends Change { - - private final IProject project; - private final String newContextRoot; - private final String oldContextRoot; - private IDataModel model; - - public RenameContextRootChange(IProject project, String newContextRoot, String oldContextRoot) { - this.project = project; - this.oldContextRoot = oldContextRoot; - this.newContextRoot = newContextRoot; - } - - @Override - public Object getModifiedElement() { - return project; - } - - @Override - public String getName() { - return J2EEUIMessages.getResourceString("RenameContextRootFromXtoY", new String[]{oldContextRoot, //$NON-NLS-1$ - newContextRoot}); - } - - @Override - public void initializeValidationData(IProgressMonitor pm) { - - } - - public static IStatus validateContextRoot(String name) { - IStatus status = Status.OK_STATUS; - if (name == null || name.length() == 0) { - // this was added because the error message shouldnt be shown - // initially. It should be shown only if context - // root field is edited to - status = new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, - ProjectSupportResourceHandler.getString( - ProjectSupportResourceHandler.Context_Root_cannot_be_empty_2, - new Object[0])); - - } - - if (!(name.indexOf(' ') > -1)) { - StringTokenizer stok = new StringTokenizer(name, "."); //$NON-NLS-1$ - while (stok.hasMoreTokens()) { - String token = stok.nextToken(); - for (int i = 0; i < token.length(); i++) { - if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') - && !(token.charAt(i) == '/') - && Character.isLetterOrDigit(token.charAt(i)) == false) { - if (Character.isWhitespace(token.charAt(i)) == false) { - status = new Status( - IStatus.ERROR, - J2EEUIPlugin.PLUGIN_ID, - ProjectSupportResourceHandler - .getString( - ProjectSupportResourceHandler.The_character_is_invalid_in_a_context_root, - new Object[] { - (new Character(token.charAt(i))).toString() - })); - - } - } - } - } - } // en/ end of if(name.trim - else { - status = new Status(IStatus.ERROR, J2EEUIPlugin.PLUGIN_ID, - ProjectSupportResourceHandler.getString( - ProjectSupportResourceHandler.Names_cannot_contain_whitespace_, - new Object[0])); - - } - return status; - - } - - @Override - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - IStatus phase1 = validateContextRoot(newContextRoot); - if (phase1.isOK()) - return new RefactoringStatus(); - else - return RefactoringStatus.create(phase1); - } - - @Override - public Change perform(IProgressMonitor pm) throws CoreException { - - ComponentUtilities.setServerContextRoot(project, newContextRoot); - - return new RenameContextRootChange(project, oldContextRoot, newContextRoot); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootRefactoringProcessor.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootRefactoringProcessor.java deleted file mode 100644 index 2564e1b5c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootRefactoringProcessor.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.ui.refactoring; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.ParticipantManager; -import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; -import org.eclipse.ltk.core.refactoring.participants.RenameArguments; -import org.eclipse.ltk.core.refactoring.participants.RenameProcessor; -import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; - -public class RenameContextRootRefactoringProcessor extends RenameProcessor { - - private IProject fProject; - private String fNewName; - private boolean fUpdateReferences; - - @Override - public RefactoringStatus checkFinalConditions(IProgressMonitor pm, - CheckConditionsContext context) throws CoreException, OperationCanceledException { - if (!isApplicable()) - return RefactoringStatus.createErrorStatus(J2EEUIMessages - .getResourceString("RefactoringNoInit")); //$NON-NLS-1$ - return validateNewElementName(fNewName); - } - - @Override - public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - return new RefactoringStatus(); - } - - @Override - public Change createChange(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - if (isApplicable() && fNewName != null) - return new RenameContextRootChange(getProject(), fNewName, getOldContextRoot()); - return null; - } - - @Override - public Object[] getElements() { - if (getProject() == null) - return new Object[0]; - return new Object[] { - getProject() - }; - } - - @Override - public String getIdentifier() { - return "org.eclipse.jst.j2ee.ChangeContextRootRefactoringProcessor"; //$NON-NLS-1$ - } - - @Override - public String getProcessorName() { - return J2EEUIMessages.getResourceString("RenameContextRoot"); //$NON-NLS-1$ - } - - public IProject getProject() { - return fProject; - } - - @Override - public boolean isApplicable() throws CoreException { - return getProject() != null; - } - - private RenameArguments getRenameArguments() { - return new RenameArguments(fNewName, fUpdateReferences); - } - - @Override - public RefactoringParticipant[] loadParticipants(RefactoringStatus status, - SharableParticipants sharedParticipants) throws CoreException { - String[] natures = new String[0]; - IProject project = getProject(); - if (project != null && fNewName != null) { - natures = project.getDescription().getNatureIds(); - return ParticipantManager.loadRenameParticipants(status, this, project, - getRenameArguments(), natures, sharedParticipants); - } - return new RefactoringParticipant[0]; - } - - public void setProject(IProject project) { - this.fProject = project; - } - - public void setNewName(String newName) { - this.fNewName = newName; - } - - public void setUpdateReferences(boolean updateReferences) { - this.fUpdateReferences = updateReferences; - } - - public RefactoringStatus validateNewElementName(String newName) { - return RefactoringStatus.create(RenameContextRootChange.validateContextRoot(newName)); - } - - public String getOldContextRoot() { - return J2EEProjectUtilities.getServerContextRoot(getProject()); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootWizard.java deleted file mode 100644 index 2919f8d44..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/refactoring/RenameContextRootWizard.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.ui.refactoring; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; -import org.eclipse.ltk.ui.refactoring.RefactoringWizard; - -public class RenameContextRootWizard extends RefactoringWizard { - - private boolean prompt = true; - - public RenameContextRootWizard(RenameContextRootRefactoringProcessor processor, int flags) { - super(new RenameRefactoring(processor), flags); - setDefaultPageTitle(J2EEUIMessages.getResourceString("RenameContextRoot")); //$NON-NLS-1$ - - setChangeCreationCancelable(true); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - @Override - protected void addUserInputPages() { - if (prompt) { - addPage(new ContextRootInputPage("", //$NON-NLS-1$ - (RenameContextRootRefactoringProcessor) getRefactoring().getAdapter( - RenameContextRootRefactoringProcessor.class))); - } - } - - public void setPrompt(boolean prompt) { - this.prompt = prompt; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/AnnotationIconDecorator.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/AnnotationIconDecorator.java deleted file mode 100644 index c1fc699d6..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/AnnotationIconDecorator.java +++ /dev/null @@ -1,120 +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 Aug 18, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.ui.util; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.common.internal.annotations.controller.AnnotationsController; -import org.eclipse.jst.common.internal.annotations.controller.AnnotationsControllerHelper; -import org.eclipse.jst.common.internal.annotations.controller.AnnotationsControllerManager; -import org.eclipse.jst.j2ee.ejb.EnterpriseBean; -import org.eclipse.jst.j2ee.internal.ejb.provider.BeanClassProviderHelper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.swt.graphics.Image; - -/** - * Add overlay for annotated objects - */ -public class AnnotationIconDecorator extends LabelProvider implements ILightweightLabelDecorator { - - protected static final String ANNOTATION_IMAGE_DESC_STRING = "annotation_bean_overlay"; //$NON-NLS-1$ - protected static final String ANNOTATION_DISABLED_IMAGE_DESC_STRING = "dis_annotation_bean_overlay"; //$NON-NLS-1$ - private static final ImageDescriptor ANNOTATION_IMG_DESC = getImageDescriptor(ANNOTATION_IMAGE_DESC_STRING); - private static final ImageDescriptor ANNOTATION_DISABLED_IMG_DESC = getImageDescriptor(ANNOTATION_DISABLED_IMAGE_DESC_STRING); - - public AnnotationIconDecorator() { - super(); - } - - /** - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, - * org.eclipse.jface.viewers.IDecoration) - */ - private boolean isAnnotatedSupported(EObject target) { - boolean bAnnotationSupported = false; - if (AnnotationsControllerHelper.INSTANCE.isAnnotated(target)) { - bAnnotationSupported = true; - } - return bAnnotationSupported; - } - - private AnnotationsController getControllerForProject(IProject targetProject) { - AnnotationsController controller = AnnotationsControllerManager.INSTANCE.getAnnotationsController(targetProject); - return controller; - } - - public void decorate(Object element, IDecoration decoration) { - EObject eObject = null; - if (element instanceof BeanClassProviderHelper) { - BeanClassProviderHelper beanClassHelper = (BeanClassProviderHelper) element; - eObject = beanClassHelper.getEjb(); - } else if (element instanceof EnterpriseBean || element instanceof Servlet) - eObject = (EObject) element; - if (eObject == null) - return; - if (isAnnotatedSupported(eObject)) { - if (isAnnotationEnabled(eObject)) { - if (ANNOTATION_IMG_DESC != null) - decoration.addOverlay(ANNOTATION_IMG_DESC); - } else { - if (ANNOTATION_DISABLED_IMG_DESC != null) - decoration.addOverlay(ANNOTATION_DISABLED_IMG_DESC); - } - } - } - - /** - * @param bean - * @return - */ - private boolean isAnnotationEnabled(EObject eObject) { - IFile annotatedSource = null; - /* short circuit if possible */ - if (AnnotationsControllerManager.INSTANCE.isAnyAnnotationsSupported()) { - IProject targetProject = ProjectUtilities.getProject(eObject); - AnnotationsController controller = getControllerForProject(targetProject); - if (controller != null) - annotatedSource = controller.getEnabledAnnotationFile(eObject); - } - return (annotatedSource != null) ? true : false; - } - - public Image decorateImage(Image image, Object element) { - return image; - } - - /** - * @see ILabelDecorator#decorateText(String, Object) - */ - public String decorateText(String text, Object element) { - return text; - } - - protected static ImageDescriptor getImageDescriptor(String imageFileName) { - if (imageFileName != null) - return J2EEUIPlugin.getDefault().getImageDescriptor(imageFileName); - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/BinaryProjectUIHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/BinaryProjectUIHelper.java deleted file mode 100644 index 42056563f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/ui/util/BinaryProjectUIHelper.java +++ /dev/null @@ -1,44 +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.ui.util; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.widgets.Shell; - -public class BinaryProjectUIHelper { - - public static final String DIALOG_TITLE = J2EEUIMessages.getResourceString("BINARY_PROJECT"); //$NON-NLS-1$ - public static final String DIALOG_MESSAGE = J2EEUIMessages.getResourceString("ACTION_CANNOT_BE_PERFORMED_ON_BIN_PROJECT"); //$NON-NLS-1$ - - /** - * Constructor for BinaryProjectUIHelper. - */ - public BinaryProjectUIHelper() { - super(); - } - - public static void displayError(Shell parent) { - MessageDialog.openError(parent, DIALOG_TITLE, DIALOG_MESSAGE); - return; - } - - public static boolean displayErrorIfBinaryProject(Shell parent, IProject aProject) { - boolean isBinary = JemProjectUtilities.isBinaryProject(aProject); - if (isBinary) - displayError(parent); - return isBinary; - } -} - diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebAppItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebAppItemProvider.java deleted file mode 100644 index 910c233fc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebAppItemProvider.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 29, 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.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationWrapper; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppItemProvider; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage; -import org.eclipse.jst.j2ee.webapplication.WelcomeFileList; -import org.eclipse.jst.j2ee.webservice.wsclient.WebServicesClient; -import org.eclipse.jst.j2ee.webservice.wsclient.Webservice_clientPackage; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelListener; - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEWebAppItemProvider extends WebAppItemProvider { - - private List children = new ArrayList(); - private boolean isInitializing = false; - private WebErrorPageGroupItemProvider webErrorPageGroup; - private WebServletGroupItemProvider webServletGroup; - private WebServletMappingGroupItemProvider webServletMappingGroup; - private WebFiltersGroupItemProvider webFiltersGroup; - private WebFilterMappingGroupItemProvider webFilterMappingGroup; - private WebReferencesGroupItemProvider webRefsGroup; - private WebSecurityGroupItemProvider webSecurityGroup; - private J2EEWebServiceClientDDManager clientMgr; - private WebListenerGroupItemProvider webListenerGroup; - private WebWelcomeFileGroupItemProvider webWelcomeFileGroup; - private WebContextParamGroupItemProvider webContextParamGroup; - - /** - * Listen and fire updates for 1.3 web service clients - */ - private class J2EEWebServiceClientDDManager extends AdapterImpl implements EditModelListener { - private WeakReference weakWebApp; - WebServicesClient client; - - public J2EEWebServiceClientDDManager(WeakReference weakWebApp) { - this.weakWebApp = weakWebApp; - init(); - } - - - - public void init() { - // TODO fix up notification - // editModel = webServiceMgr.getWSEditModel(ProjectUtilities.getProject(webApp)); - // if (editModel != null) { - // editModel.addListener(this); - // if (editModel.get13WebServicesClientResource() != null) { - // client = editModel.get13WebServicesClientResource().getWebServicesClient(); - // if (client != null) - // client.eAdapters().add(this); - // } - // } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelListener#editModelChanged(org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent) - */ - public void editModelChanged(EditModelEvent anEvent) { - // TODO fix up notification - // if (editModel == null) - // init(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification notification) { - if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY || notification.getEventType() == Notification.REMOVE || notification.getEventType() == Notification.REMOVE_MANY) { - if (notification.getFeatureID(WebServicesClient.class) == Webservice_clientPackage.WEB_SERVICES_CLIENT__SERVICE_REFS) { - NotificationWrapper notificationWrapper = new NotificationWrapper(webRefsGroup, notification); - fireNotifyChanged(notificationWrapper); - } - } - super.notifyChanged(notification); - } - - public void dispose() { - // TODO fix up notification - - webErrorPageGroup.dispose(); - webContextParamGroup.dispose(); - webWelcomeFileGroup.dispose(); - webServletGroup.dispose(); - webServletMappingGroup.dispose(); - webFiltersGroup.dispose(); - webFilterMappingGroup.dispose(); - webRefsGroup.dispose(); - webSecurityGroup.dispose(); - webListenerGroup.dispose(); - - weakWebApp = null; - if (client != null) - client.eAdapters().remove(this); - children.clear(); - } - } - - /** - * Default constructor - */ - public J2EEWebAppItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * Initialize the list of children - */ - private void initChildren() { - if (isInitializing) - return; - - isInitializing = true; - try { - children.clear(); - if (clientMgr == null) { - clientMgr = new J2EEWebServiceClientDDManager(weakWebApp); - } -// if (!((WebApp)weakWebApp.get()).getErrorPages().isEmpty()) { -// children.add(webErrorPageGroup = new WebErrorPageGroupItemProvider(adapterFactory, weakWebApp)); -// } else { -// WebErrorPageGroupItemProvider child = null; -// for (int i=0; i < children.size(); i++) { -// Object object = children.get(i); -// if (object instanceof WebErrorPageGroupItemProvider) { -// child = (WebErrorPageGroupItemProvider) object; -// break; -// } -// } -// if (child != null) { -// child.dispose(); -// } -// } -// if (!((WebApp)weakWebApp.get()).getContextParams().isEmpty()) { -// children.add(webContextParamGroup = new WebContextParamGroupItemProvider(adapterFactory, weakWebApp)); -// } else { -// WebContextParamGroupItemProvider child = null; -// for (int i=0; i < children.size(); i++) { -// Object object = children.get(i); -// if (object instanceof WebContextParamGroupItemProvider) { -// child = (WebContextParamGroupItemProvider) object; -// break; -// } -// } -// if (child != null) { -// child.dispose(); -// } -// } -// WelcomeFileList welcomeFileList = ((WebApp)weakWebApp.get()).getFileList(); -// if (welcomeFileList != null && !welcomeFileList.getFile().isEmpty()) { -// children.add(webWelcomeFileGroup = new WebWelcomeFileGroupItemProvider(adapterFactory, weakWebApp)); -// } else { -// WebWelcomeFileGroupItemProvider child = null; -// for (int i=0; i < children.size(); i++) { -// Object object = children.get(i); -// if (object instanceof WebWelcomeFileGroupItemProvider) { -// child = (WebWelcomeFileGroupItemProvider) object; -// break; -// } -// } -// if (child != null) { -// child.dispose(); -// } -// } - - children.add(webErrorPageGroup = new WebErrorPageGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webContextParamGroup = new WebContextParamGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webWelcomeFileGroup = new WebWelcomeFileGroupItemProvider(adapterFactory, weakWebApp)); - - children.add(webServletGroup = new WebServletGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webServletMappingGroup = new WebServletMappingGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webFiltersGroup = new WebFiltersGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webFilterMappingGroup = new WebFilterMappingGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webRefsGroup = new WebReferencesGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webSecurityGroup = new WebSecurityGroupItemProvider(adapterFactory, weakWebApp)); - children.add(webListenerGroup = new WebListenerGroupItemProvider(adapterFactory, weakWebApp)); - } finally { - isInitializing = false; - } - } - - protected WeakReference weakWebApp = null; - - public Collection getChildren(Object object) { - if (object instanceof WebApp) { - WebApp webApp = (WebApp) object; - // If uninitialized or web app needs to re-initialize, init the children - if(weakWebApp == null || children.isEmpty() || webApp != weakWebApp.get()) { - weakWebApp = new WeakReference(webApp); - initChildren(); - } -// if (isInitializing) return children; -// isInitializing = true; -// updateContextParams(webApp); -// updateWelcomePages(webApp); -// isInitializing = false; - return children; - } - return Collections.EMPTY_LIST; - } - - private void updateContextParams(WebApp webApp) { - EList contextParams = webApp.getContextParams(); - if (contextParams == null || contextParams.isEmpty()) { - if (webContextParamGroup != null) { - children.remove(webContextParamGroup); - webContextParamGroup.dispose(); - webContextParamGroup = null; - } - } else if (webContextParamGroup == null) { - children.add(webContextParamGroup = new WebContextParamGroupItemProvider(adapterFactory, weakWebApp)); - } - } - - private void updateWelcomePages(WebApp webApp) { - WelcomeFileList fileList = webApp.getFileList(); - if (fileList == null || fileList.getFile().isEmpty()) { - if (webWelcomeFileGroup != null) { - children.remove(webWelcomeFileGroup); - webWelcomeFileGroup.dispose(); - webWelcomeFileGroup = null; - } - } else if (webWelcomeFileGroup == null) { - children.add(webWelcomeFileGroup = new WebWelcomeFileGroupItemProvider(adapterFactory, weakWebApp)); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification notification) { - // We only care about adds and removes for the different item provider - // groups - if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY || notification.getEventType() == Notification.REMOVE || notification.getEventType() == Notification.REMOVE_MANY) { - Object notifier = null; - switch (notification.getFeatureID(WebApp.class)) { - case WebapplicationPackage.WEB_APP__ERROR_PAGES : - notifier = webErrorPageGroup; - break; - case WebapplicationPackage.WEB_APP__CONTEXT_PARAMS : - notifier = webContextParamGroup; - break; - case WebapplicationPackage.WEB_APP__FILE_LIST : - notifier = webWelcomeFileGroup; - break; - case WebapplicationPackage.WEB_APP__SERVLETS : - notifier = webServletGroup; - break; - case WebapplicationPackage.WEB_APP__SERVLET_MAPPINGS : - notifier = webServletMappingGroup; - break; - case WebapplicationPackage.WEB_APP__FILTERS : - notifier = webFiltersGroup; - break; - case WebapplicationPackage.WEB_APP__FILTER_MAPPINGS : - notifier = webFilterMappingGroup; - break; - case WebapplicationPackage.WEB_APP__EJB_LOCAL_REFS : - case WebapplicationPackage.WEB_APP__EJB_REFS : - case WebapplicationPackage.WEB_APP__MESSAGE_DESTINATION_REFS : - case WebapplicationPackage.WEB_APP__RESOURCE_ENV_REFS : - case WebapplicationPackage.WEB_APP__RESOURCE_REFS : - case WebapplicationPackage.WEB_APP__SERVICE_REFS : - notifier = webRefsGroup; - break; - case WebapplicationPackage.WEB_APP__SECURITY_ROLES : - case WebapplicationPackage.WEB_APP__CONSTRAINTS : - notifier = webSecurityGroup; - break; - case WebapplicationPackage.WEB_APP__LISTENERS : - notifier = webListenerGroup; - break; - } - if (notifier != null) { - NotificationWrapper notificationWrapper = new NotificationWrapper(notifier, notification); - fireNotifyChanged(notificationWrapper); - return; - } - } - super.notifyChanged(notification); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.IDisposable#dispose() - */ - public void dispose() { - if (clientMgr != null) - clientMgr.dispose(); - super.dispose(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebItemProviderAdapterFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebItemProviderAdapterFactory.java deleted file mode 100644 index 1b67ce5cd..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/J2EEWebItemProviderAdapterFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Mar 29, 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.war.ui.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jst.j2ee.internal.web.providers.WebapplicationItemProviderAdapterFactory; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class J2EEWebItemProviderAdapterFactory extends WebapplicationItemProviderAdapterFactory { - - /** - * Default constructor - */ - public J2EEWebItemProviderAdapterFactory() { - super(); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.webapplication.util.WebapplicationAdapterFactory#createWebAppAdapter() - */ - public Adapter createWebAppAdapter() { - if (webAppItemProvider == null) - webAppItemProvider = new J2EEWebAppItemProvider(this); - return webAppItemProvider; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebContextParamGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebContextParamGroupItemProvider.java deleted file mode 100644 index 9b1a4a688..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebContextParamGroupItemProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Created on Mar 29, 2004 - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebContextParamGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebContextParamGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - if (weakWebApp!=null) { - Object webApp = weakWebApp.get(); - if(null != webApp){ - result.addAll(((WebApp)webApp).getContextParams()); - } - } - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("initializ_parameter_context"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Context_Parameters_2"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebErrorPageGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebErrorPageGroupItemProvider.java deleted file mode 100644 index 8b76b9e7c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebErrorPageGroupItemProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Created on Mar 29, 2004 - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebErrorPageGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebErrorPageGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - if (weakWebApp!=null) { - Object webApp = weakWebApp.get(); - if(null != webApp){ - result.addAll(((WebApp)webApp).getErrorPages()); - } - } - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("error_page"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Error_Pages_1"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFilterMappingGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFilterMappingGroupItemProvider.java deleted file mode 100644 index beae5d9bc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFilterMappingGroupItemProvider.java +++ /dev/null @@ -1,80 +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 Jun 11, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class WebFilterMappingGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebFilterMappingGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory,weakWebApp); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - Object webApp = weakWebApp.get(); - if(null != webApp){ - return ((WebApp)webApp).getFilterMappings(); - } - return Collections.EMPTY_LIST; - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("filter_mapping"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Filter_Mappings_1"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFiltersGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFiltersGroupItemProvider.java deleted file mode 100644 index d3809b12f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebFiltersGroupItemProvider.java +++ /dev/null @@ -1,84 +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 Mar 29, 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.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebFiltersGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebFiltersGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /** - * This returns Filter.gif. - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("filter"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - Object webApp = weakWebApp.get(); - if(webApp != null){ - result.addAll(((WebApp)webApp).getFilters()); - } - return getSortedChildren(result); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(java.lang.Object) - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Filters_1"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebGroupItemProvider.java deleted file mode 100644 index 1a29568df..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebGroupItemProvider.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 Aug 11, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jst.j2ee.common.Listener; -import org.eclipse.jst.j2ee.internal.provider.J2EEItemProvider; -import org.eclipse.jst.j2ee.webapplication.Filter; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; - -/** - * @author jlanuti - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public abstract class WebGroupItemProvider extends J2EEItemProvider { - - class WebGroupComparator implements Comparator { - public int compare(Object o1, Object o2) { - if (o1 instanceof Servlet) { - Servlet s1 = (Servlet)o1; - Servlet s2 = (Servlet)o2; - if (s1.getServletName() != null && s2.getServletName() != null) - return s1.getServletName().compareTo(s2.getServletName()); - return -1; - } - else if (o1 instanceof Filter) { - Filter f1 = (Filter) o1; - Filter f2 = (Filter) o2; - if (f1.getName() != null && f2.getName() != null) - return f1.getName().compareTo(f2.getName()); - return -1; - } - else if (o1 instanceof Listener) { - Listener l1 = (Listener) o1; - Listener l2 = (Listener) o2; - if (l1.getListenerClassName() != null && l2.getListenerClassName() !=null) - return l1.getListenerClassName().compareTo(l2.getListenerClassName()); - return -1; - } - else return -1; - } - } - - protected WeakReference weakWebApp; - - public WebGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory); - this.weakWebApp = weakWebApp; - } - - public Collection getSortedChildren(List theChildren) { - Collections.sort(theChildren, new WebGroupComparator()); - return theChildren; - } - - public void dispose() { - // TODO Auto-generated method stub - super.dispose(); - weakWebApp = null; - } - - - public IFile getAssociatedFile() { - - try { - WebApp webapp = (WebApp) weakWebApp.get(); - if(webapp != null && webapp.eResource() != null) { - return WorkbenchResourceHelperBase.getIFile(webapp.eResource().getURI()); - } - } catch (Throwable t) { - - } - return null; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebListenerGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebListenerGroupItemProvider.java deleted file mode 100644 index d58e81fd5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebListenerGroupItemProvider.java +++ /dev/null @@ -1,84 +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 Jun 11, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class WebListenerGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebListenerGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /** - * This returns Filter.gif. - */ - public Object getImage(Object object) { - return J2EEPlugin.getDefault().getImage("listener"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - Object webApp = weakWebApp.get(); - if(webApp != null){ - result.addAll(((WebApp)webApp).getListeners()); - } - return getSortedChildren(result); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(java.lang.Object) - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("LISTENER"); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebReferencesGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebReferencesGroupItemProvider.java deleted file mode 100644 index a5fcbbcbe..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebReferencesGroupItemProvider.java +++ /dev/null @@ -1,119 +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 Mar 29, 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.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.internal.webservices.WSDLServiceExtManager; -import org.eclipse.jst.j2ee.internal.webservices.WSDLServiceHelper; -import org.eclipse.jst.j2ee.webapplication.WebApp; - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebReferencesGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebReferencesGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - Object obj = weakWebApp.get(); - if (null != obj) { - WebApp webApp = (WebApp) obj; - if (!webApp.getEjbLocalRefs().isEmpty()) - result.addAll(webApp.getEjbLocalRefs()); - if (!webApp.getEjbRefs().isEmpty()) - result.addAll(webApp.getEjbRefs()); - if (!webApp.getResourceEnvRefs().isEmpty()) - result.addAll(webApp.getResourceEnvRefs()); - if (!webApp.getResourceRefs().isEmpty()) - result.addAll(webApp.getResourceRefs()); - if (!webApp.getMessageDestinationRefs().isEmpty()) - result.addAll(webApp.getMessageDestinationRefs()); - if (!webApp.getServiceRefs().isEmpty()) - result.addAll(webApp.getServiceRefs()); - Collection serviceRefs = null; - try { - WSDLServiceHelper serviceHelper = WSDLServiceExtManager.getServiceHelper(); - serviceRefs = serviceHelper.get13ServiceRefs(webApp); - } catch (Exception re) { - serviceRefs = Collections.EMPTY_LIST; - } - - if (serviceRefs != null && !serviceRefs.isEmpty()) - result.addAll(serviceRefs); - } - return result; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return J2EEPlugin.getDefault().getImage("resourceRef_obj"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("References_1"); //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebSecurityGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebSecurityGroupItemProvider.java deleted file mode 100644 index 9da0aad4a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebSecurityGroupItemProvider.java +++ /dev/null @@ -1,98 +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 Mar 29, 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.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebSecurityGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebSecurityGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Security_1"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - Object obj = weakWebApp.get(); - if (null != obj) { - WebApp webApp = (WebApp) obj; - if (!webApp.getSecurityRoles().isEmpty()) - result.addAll(webApp.getSecurityRoles()); - if (!webApp.getConstraints().isEmpty()) - result.addAll(webApp.getConstraints()); - } - return result; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return J2EEPlugin.getPlugin().getImage("security_role");//$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletGroupItemProvider.java deleted file mode 100644 index 471866e5c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletGroupItemProvider.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 29, 2004 - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebServletGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebServletGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - if (weakWebApp!=null) { - Object webApp = weakWebApp.get(); - if(null != webApp){ - result.addAll(((WebApp)webApp).getServlets()); - } - } - return getSortedChildren(result); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("servlet"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Servlets_1"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletMappingGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletMappingGroupItemProvider.java deleted file mode 100644 index 536b0ac28..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebServletMappingGroupItemProvider.java +++ /dev/null @@ -1,92 +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 Jun 11, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Style - Code Templates - */ -public class WebServletMappingGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebServletMappingGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - Object webApp = weakWebApp.get(); - if (null != webApp) { - return ((WebApp) webApp).getServletMappings(); - } - return Collections.EMPTY_LIST; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("servlet_mapping"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Servlet_Mappings_2"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebWelcomeFileGroupItemProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebWelcomeFileGroupItemProvider.java deleted file mode 100644 index 204cca3c2..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/war/ui/util/WebWelcomeFileGroupItemProvider.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Created on Mar 29, 2004 - */ -package org.eclipse.jst.j2ee.internal.war.ui.util; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WelcomeFileList; - - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class WebWelcomeFileGroupItemProvider extends WebGroupItemProvider { - - /** - * @param adapterFactory - */ - public WebWelcomeFileGroupItemProvider(AdapterFactory adapterFactory, WeakReference weakWebApp) { - super(adapterFactory, weakWebApp); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getChildren(java.lang.Object) - */ - public Collection getChildren(Object object) { - List result = new ArrayList(); - if (weakWebApp!=null) { - Object webApp = weakWebApp.get(); - if (null != webApp) { - WelcomeFileList fileList = ((WebApp)webApp).getFileList(); - if (fileList != null) { - result.addAll(fileList.getFile()); - } - } - } - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getImage() - */ - public Object getImage(Object object) { - return WebPlugin.getDefault().getImage("welcome_list"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ItemProvider#getText() - */ - public String getText(Object object) { - return WebAppEditResourceHandler.getString("Welcome_Pages_1"); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object object) { - return !getChildren(object).isEmpty(); - } - - /* (non-Javadoc) - * @see org.eclipse.emf.edit.provider.ITreeItemContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object object) { - return weakWebApp.get(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AnnotationsStandaloneGroup.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AnnotationsStandaloneGroup.java deleted file mode 100644 index e977b505b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AnnotationsStandaloneGroup.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * Created on Mar 29, 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.wizard; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper; - -/** - * @author jlanuti - * - * To change the template for this generated type comment go to Window - Preferences - Java - Code - * Generation - Code and Comments - */ -public class AnnotationsStandaloneGroup { - - protected Object model; - protected Object synchHelper; - protected Button useAnnotations; - private boolean isForBean; - private boolean useServletString = false; - public static final String EJBTAGSET = "ejb"; //$NON-NLS-1$ - - /** - * Constructor - */ - public AnnotationsStandaloneGroup(Composite parent, Object model, boolean forBean) { - this(parent, model, forBean, false); - } - - /** - * Constructor - */ - public AnnotationsStandaloneGroup(Composite parent, Object model, boolean forBean, boolean useServlet) { - super(); - synchHelper = new DataModelSynchHelper((IDataModel)model); - this.model = model; - this.isForBean = forBean; - this.useServletString = useServlet; - - buildComposites(parent); - } - - /** - * @param parent - */ - protected void buildComposites(Composite parent) { - // Add separator - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 3; - separator.setLayoutData(gd); - // Add spacer - Label spacer = new Label(parent, SWT.NONE); - GridData gd1 = new GridData(GridData.FILL_HORIZONTAL); - gd1.horizontalSpan = 3; - spacer.setLayoutData(gd1); - // Add annotations checkbox and label - useAnnotations = new Button(parent, SWT.CHECK); - String labelText; - if (useServletString) - labelText = J2EEUIMessages.getResourceString(J2EEUIMessages.USE_ANNOTATIONS_SERVLET); - else if (isForBean) - labelText = J2EEUIMessages.getResourceString(J2EEUIMessages.USE_ANNOTATIONS); - else - labelText = J2EEUIMessages.getResourceString(J2EEUIMessages.ADD_ANNOTATIONS_SUPPORT); - useAnnotations.setText(labelText); - ((DataModelSynchHelper)synchHelper).synchCheckbox(useAnnotations, IAnnotationsDataModel.USE_ANNOTATIONS, null); - GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); - gd2.horizontalSpan = 2; - useAnnotations.setLayoutData(gd2); - Dialog.applyDialogFont(parent); - } - - public void dispose() { - ((IDataModel)model).removeListener((DataModelSynchHelper)synchHelper); - synchHelper = null; - model = null; - } - - public void setEnablement(IProject project) { - //TODO Remove - this is to be handled by the provider of the DataModel. - } - - - - public void setUseServlet(boolean aBoolean) { - useServletString = aBoolean; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentExportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentExportWizard.java deleted file mode 100644 index 9fe83e20f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentExportWizard.java +++ /dev/null @@ -1,76 +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.wizard; - -import org.eclipse.jst.j2ee.application.internal.operations.AppClientComponentExportDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.ui.IExportWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * <p> - * Wizard used to export J2EE Application Client module structures from the Eclipse Workbench to a - * deployable Application Client Archive *.jar file. - * </p> - */ -public final class AppClientComponentExportWizard extends J2EEArtifactExportWizard implements IExportWizard { - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public AppClientComponentExportWizard() { - super(); - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public AppClientComponentExportWizard(IDataModel model) { - super(model); - } - protected IDataModelProvider getDefaultProvider() { - return new AppClientComponentExportDataModelProvider(); - } - - /** - * <p> - * Adds the following pages: - * <ul> - * <li>{@link AppClientExportPage}as the main wizard page ({@link #MAIN_PG}) - * </ul> - * </p> - */ - public void doAddPages() { - addPage(new AppClientExportPage(getDataModel(), MAIN_PG, getSelection())); - } - - /** - * {@inheritDoc} - * - * <p> - * Sets up the default wizard page image. - * </p> - */ - protected void doInit() { - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.APP_CLIENT_EXPORT_WIZARD_BANNER)); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportPage.java deleted file mode 100644 index e0c12c951..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportPage.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class AppClientComponentImportPage extends J2EEModuleImportPage { - /** - * @param model - * @param pageName - */ - public AppClientComponentImportPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_IMPORT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_IMPORT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.APP_CLIENT_IMPORT_WIZARD_BANNER)); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFileImportLabel() - */ - protected String getFileImportLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_IMPORT_FILE_LABEL); - } - - protected String getFileNamesStoreID() { - return "APP_CLIENT"; //$NON-NLS-1$; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFilterExpression() - */ - protected String[] getFilterExpression() { - return new String[]{"*.jar"}; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getProjectImportLabel() - */ - protected String getProjectImportLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_IMPORT_PROJECT_LABEL); - } - - // protected J2EEComponentCreationDataModel getNewProjectCreationDataModel() { - // return getAppClientDataModel().getJ2eeArtifactCreationDataModel(); - // } - // - // private AppClientModuleImportDataModel getAppClientDataModel() { - // return (AppClientModuleImportDataModel) model; - // } - - protected Composite createTopLevelComposite(Composite parent) { - setInfopopID(IJ2EEUIContextIds.IMPORT_APPCLIENT_WIZARD_P1); - return super.createTopLevelComposite(parent); - } - - protected String getModuleFacetID(){ - return J2EEProjectUtilities.APPLICATION_CLIENT; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportWizard.java deleted file mode 100644 index 8ef52ce2b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientComponentImportWizard.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; - -/** - * <p> - * Wizard used to import J2EE Application Client module structures into the Eclipse Workbench from - * an existing Application Client *.jar file. - * </p> - */ -public final class AppClientComponentImportWizard extends J2EEComponentImportWizard { - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public AppClientComponentImportWizard() { - super(); - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public AppClientComponentImportWizard(IDataModel model) { - super(model); - } - - /** - * <p> - * Adds an {@link AppClientImportPage}as the main wizard page ({@link #MAIN_PG}). - * </p> - */ - public void doAddPages() { - addPage(new AppClientComponentImportPage(getDataModel(), MAIN_PG)); - } - - /** - * {@inheritDoc} - * - * <p> - * Sets up the dialog window title and default wizard page image. - * </p> - */ - public final void doInit() { - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.IMPORT_WIZ_TITLE)); - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.APP_CLIENT_IMPORT_WIZARD_BANNER)); - } - - protected String[] getModuleValidatorStrings() { - return new String[]{"org.eclipse.jst.j2ee.internal.validation.UIApplicationClientValidator"}; //$NON-NLS-1$ - } - - protected IDataModelProvider getDefaultProvider() { - return new AppClientComponentImportDataModelProvider(); - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_APPCLIENT); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientExportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientExportPage.java deleted file mode 100644 index bfc6a0ead..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AppClientExportPage.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.client.ApplicationClient; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class AppClientExportPage extends J2EEModuleExportPage { - /** - * @param model - * @param pageName - */ - public AppClientExportPage(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName, selection); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_EXPORT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_EXPORT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.APP_CLIENT_EXPORT_WIZARD_BANNER)); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getProjectImportLabel() - */ - protected String getComponentLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_IMPORT_PROJECT_LABEL); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFilterExpression() - */ - protected String[] getFilterExpression() { - return new String[]{"*.jar"}; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEExportPage#isMetaTypeSupported(java.lang.Object) - */ - protected boolean isMetaTypeSupported(Object o) { - return o instanceof ApplicationClient; - } - - protected String getInfopopID() { - return IJ2EEUIContextIds.EXPORT_APPCLIENT_WIZARD_P1; - } - - protected String getCompnentID() { - return "JST_APPCLIENT"; //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableJarsProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableJarsProvider.java deleted file mode 100644 index 3bad7b063..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableJarsProvider.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.wizard; - - - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection; -import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.common.frameworks.internal.ui.OverlayIcon; - - -public class AvailableJarsProvider implements org.eclipse.jface.viewers.IStructuredContentProvider, org.eclipse.jface.viewers.ITableLabelProvider { - protected static Image utilImage; - protected static Image invalidImage; - protected static Image ejbImage; - protected static Image ejbClientImage; - protected static Image classpathImage; - - /** - * AvailableJarsContentProvider constructor comment. - */ - public AvailableJarsProvider() { - super(); - } - - /** - * Adds a listener to this label provider. Has no effect if an identical listener is already - * registered. - * <p> - * Label provider listeners are informed about state changes that affect the rendering of the - * viewer that uses this label provider. - * </p> - * - * @param listener - * a label provider listener - */ - public void addListener(org.eclipse.jface.viewers.ILabelProviderListener listener) { - //do nothing - } - - /** - * Disposes of this label provider. When a label provider is attached to a viewer, the viewer - * will automatically call this method when the viewer is being closed. When label providers are - * used outside of the context of a viewer, it is the client's responsibility to ensure that - * this method is called when the provider is no longer needed. - */ - public void dispose() { - //dispose - } - - /** - * Returns the label image for the given column of the given element. - * - * @param element - * the object representing the entire row, or <code>null</code> indicating that no - * input object is set in the viewer - * @param columnIndex - * the zero-based index of the column in which the label appears - */ - public org.eclipse.swt.graphics.Image getColumnImage(Object element, int columnIndex) { - if (columnIndex > 0) - return null; - ClasspathElement cp = (ClasspathElement) element; - if (!cp.isValid()) - return getInvalidImage(); - - if (cp.isClasspathEntry()) { - return getClasspathDependencyImage(); - } - - switch (cp.getJarType()) { - case ClasspathElement.EJB_JAR : - return getEjbImage(); - case ClasspathElement.EJB_CLIENT_JAR : - return getEjbClientImage(); - default : - return getUtilImage(); - } - } - - /** - * Returns the label text for the given column of the given element. - * - * @param element - * the object representing the entire row, or <code>null</code> indicating that no - * input object is set in the viewer - * @param columnIndex - * the zero-based index of the column in which the label appears - */ - public String getColumnText(Object element, int columnIndex) { - String value = null; - switch (columnIndex) { - case 0 : { - value = ((ClasspathElement) element).getText(); - break; - } - case 1 : - value = ((ClasspathElement) element).getProjectName(); - } - return value == null ? "" : value;//$NON-NLS-1$ - } - - protected static Image getEjbImage() { - if (ejbImage == null) - ejbImage = getImageDescriptor("EJBJar").createImage();//$NON-NLS-1$ - return ejbImage; - } - - protected static Image getEjbClientImage() { - if (ejbClientImage == null) - ejbClientImage = getImageDescriptor("ejbclientjar_obj").createImage();//$NON-NLS-1$ - return ejbClientImage; - } - - protected static Image getClasspathDependencyImage() { - if (classpathImage == null) - classpathImage = getImageDescriptor("CPDep").createImage();//$NON-NLS-1$ - return classpathImage; - } - - /** - * Returns the elements to display in the viewer when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. The result is not - * modified by the viewer. - * - * @param inputElement - * the input element - * @return the array of elements to display in the viewer - */ - public java.lang.Object[] getElements(Object inputElement) { - ClassPathSelection selection = (ClassPathSelection) inputElement; - return filter(selection, selection.getFilterLevel()).toArray(); - } - - /** - * @param list - */ - private List filter(ClassPathSelection selection, int filterLevel) { - List list = selection.getClasspathElements(); - List result = new ArrayList(list.size()); - for (int i = 0; i < list.size(); i++) { - ClasspathElement element = (ClasspathElement) list.get(i); - if (!element.isSelected()) { - switch (filterLevel) { - case (ClassPathSelection.FILTER_EJB_CLIENT_JARS) : - if (element.isEJBClientJar()) - continue; - break; - case (ClassPathSelection.FILTER_EJB_SERVER_JARS) : - if (element.isEJBJar() && selection.getOppositeElement(element) != null) - continue; - } - } - result.add(element); - } - return result; - } - - /** - * This gets a .gif from the icons folder. - */ - protected static ImageDescriptor getImageDescriptor(String key) { - ImageDescriptor imageDescriptor = null; - - URL gifImageURL = (URL) J2EEPlugin.getPlugin().getImage(key); - imageDescriptor = ImageDescriptor.createFromURL(gifImageURL); - return imageDescriptor; - } - - protected static Image getInvalidImage() { - if (invalidImage == null) { - ImageDescriptor base = getImageDescriptor("jar_nonexist_obj");//$NON-NLS-1$ - ImageDescriptor overlay = getImageDescriptor("warning_co");//$NON-NLS-1$ - invalidImage = new OverlayIcon(base, new ImageDescriptor[][]{{overlay}}).createImage(); - } - return invalidImage; - } - - public static Image getUtilImage() { - if (utilImage == null) - utilImage = getImageDescriptor("jar_obj").createImage();//$NON-NLS-1$ - return utilImage; - } - - /** - * Notifies this content provider that the given viewer's input has been switched to a different - * element. - * <p> - * A typical use for this method is registering the content provider as a listener to changes on - * the new input (using model-specific means), and deregistering the viewer from the old input. - * In response to these change notifications, the content provider propagates the changes to the - * viewer. - * </p> - * - * @param viewer - * the viewer - * @param oldInput - * the old input element, or <code>null</code> if the viewer did not previously - * have an input - * @param newInput - * the new input element, or <code>null</code> if the viewer does not have an input - */ - public void inputChanged(org.eclipse.jface.viewers.Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } - - /** - * Returns whether the label would be affected by a change to the given property of the given - * element. This can be used to optimize a non-structural viewer update. If the property - * mentioned in the update does not affect the label, then the viewer need not update the label. - * - * @param element - * the element - * @param property - * the property - * @return <code>true</code> if the label would be affected, and <code>false</code> if it - * would be unaffected - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * Removes a listener to this label provider. Has no affect if an identical listener is not - * registered. - * - * @param listener - * a label provider listener - */ - public void removeListener(org.eclipse.jface.viewers.ILabelProviderListener listener) { - //do nothing - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilJarsAndWebLibProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilJarsAndWebLibProvider.java deleted file mode 100644 index e01a7d799..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilJarsAndWebLibProvider.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 22, 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.wizard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.swt.graphics.Image; - - -/** - * @author vijayb - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class AvailableUtilJarsAndWebLibProvider implements IStructuredContentProvider, ITableLabelProvider { - - public AvailableUtilJarsAndWebLibProvider() { - //Default constructor - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - if(inputElement instanceof ArchiveWrapper){ - ArchiveWrapper wrapper = (ArchiveWrapper)inputElement; - List <ArchiveWrapper> utilities = wrapper.getEARUtilitiesAndWebLibs(); - List filteredProjects = new ArrayList(); - if (utilities.size() > 0){ - filterEJBClientJars(utilities, wrapper); - Object [] array = utilities.toArray(); - Arrays.sort(array, new Comparator() { - public int compare(Object o1, Object o2) { - return getColumnText(o1, 0).compareTo(getColumnText(o2, 0)); - } - }); - return array; - } - else - return new Object[0]; - } - return new Object[0]; - } - - /** - * @param array - * @return - */ - private void filterEJBClientJars(List <ArchiveWrapper> utilities, ArchiveWrapper earWrapper) { - List <ArchiveWrapper> modules = earWrapper.getEarModules(); - for(ArchiveWrapper module : modules){ - if(module.isEJBJarFile()){ - ArchiveWrapper clientWrapper = earWrapper.getEJBClientArchiveWrapper(module); - if(null != clientWrapper){ - boolean removed = false; - for(int i=0;i<utilities.size() && !removed; i++){ - if(clientWrapper.getUnderLyingArchive() == utilities.get(i).getUnderLyingArchive()){ - utilities.remove(i); - removed = true; - } - } - } - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - return AvailableJarsProvider.getUtilImage(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - ArchiveWrapper wrapper = (ArchiveWrapper)element; - IPath path = wrapper.getPath(); - if(path.toString().startsWith(ArchiveConstants.WEBAPP_LIB_URI)){ - return wrapper.getParent().getName()+"#"+wrapper.getPath(); //$NON-NLS-1$ - } - return wrapper.getName(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - //Auto-generated method stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //Auto-generated method stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - //Auto-generated method stub - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, - * java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - //Auto-generated method stub - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilityJarsProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilityJarsProvider.java deleted file mode 100644 index 4629cc77b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/AvailableUtilityJarsProvider.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 - *******************************************************************************/ -/* - * Created on Apr 22, 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.wizard; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEUtilityJarListImportDataModelProperties; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author vijayb - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class AvailableUtilityJarsProvider implements IStructuredContentProvider, ITableLabelProvider { - - public AvailableUtilityJarsProvider() { - //default constructor - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - /* - * Object[] array = EARImportDataModel.getAllUtilities((EARFile) inputElement).toArray(); - */ - Object[] array = getJarFilesFromDirectory(inputElement); - Arrays.sort(array, new Comparator() { - - public int compare(Object o1, Object o2) { - return getColumnText(o1, 0).compareTo(getColumnText(o2, 0)); - } - - }); - return array; - } - - /** - * @param inputElement - * @return - */ - private Object[] getJarFilesFromDirectory(Object inputElement) { - - List collectedJars = new ArrayList(); - IDataModel model = null; - if (inputElement instanceof IDataModel) - model = (IDataModel) inputElement; - if (model != null) { - - String fileName = model.getStringProperty(IJ2EEUtilityJarListImportDataModelProperties.AVAILABLE_JARS_DIRECTORY); - File directory = new File(fileName); - if (directory.exists() && directory.canRead() && directory.isDirectory()) { - File[] availableFiles = directory.listFiles(); - - if (availableFiles == null) - return new File[0]; - - for (int i = 0; i < availableFiles.length; i++) - if (availableFiles[i] != null && availableFiles[i].getName().endsWith(".jar"))collectedJars.add(availableFiles[i]); //$NON-NLS-1$ - } - } - return collectedJars.toArray(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - return AvailableJarsProvider.getUtilImage(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - /* - * FileImpl file = (FileImpl) element; if - * (file.getURI().startsWith(ArchiveConstants.WEBAPP_LIB_URI)) { String parentWarFileName = - * ((WARFile) file.eContainer()).getName(); return parentWarFileName + "#" + file.getURI(); - * //$NON-NLS-1$ } else return file.getName(); - */ - return element.toString(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - //dispose - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - //do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, - * java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - //do nothing - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ClassesImportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ClassesImportWizard.java deleted file mode 100644 index ac07f233f..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ClassesImportWizard.java +++ /dev/null @@ -1,177 +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.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.ui.util.CoreUtility; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.ui.IImportWizard; -import org.eclipse.ui.IWorkbench; - -public class ClassesImportWizard extends Wizard implements IImportWizard { - - public WizardClassesImportMainPage mainPage = null; - - public WizardClassesImportPage1 page1 = null; - - private IWorkbench workbench; - - private IStructuredSelection selection; - - private IPath importedClassesPath; - - private IJavaProject javaProject = null; - - private IProject project = null; - - protected ArrayList fileNames = null; - - public ClassesImportWizard() { - super(); - } - - public ClassesImportWizard(IProject project) { - super(); - this.project = project; - - } - - public ClassesImportWizard(IProject project, String fileName, List otherFileNames) { - this(project); - this.fileNames = new ArrayList(); - this.fileNames.add(fileName); - int i = fileName.lastIndexOf(java.io.File.separatorChar); - String parentDir = fileName.substring(0, i); - if (otherFileNames != null) - for (int j = otherFileNames.size() - 1; j >= 0; j--) { - if (otherFileNames.get(j) != null) { - int k = ((String) otherFileNames.get(j)).lastIndexOf(java.io.File.separatorChar); - if (k == i && parentDir.equals(((String) otherFileNames.get(j)).substring(0, k))) { - fileNames.add(otherFileNames.remove(j)); - } - } - } - - } - - public void setFolderPath(IPath path) { - importedClassesPath = path; - } - - /** - * @see org.eclipse.jface.wizard.IWizard#performFinish() - */ - public boolean performFinish() { - return page1.finish(); - } - - public void createImportedClassesFolder(IProject aProject) { - //Create imported_classes folder selected project - IContainer container = aProject; - IFolder folder = container.getFolder(new Path("imported_classes")); //$NON-NLS-1$ - javaProject = getIJavaProject(aProject); - - IPath importedFoldersClass = folder.getFullPath(); - - CPListElement entry = newCPLibraryElement(folder); - IClasspathEntry newEntry = entry.getClasspathEntry(); - - IResource res = entry.getResource(); - if ((res instanceof IFolder) && !res.exists()) { - try { - CoreUtility.createFolder((IFolder) res, true, true, null); - - } catch (CoreException e) { - //Ignore - } - } - - try { - IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); - IClasspathEntry[] newClasspath = new IClasspathEntry[classpathEntries.length + 1]; - - for (int i = 0; i < classpathEntries.length; i++) { - newClasspath[i] = classpathEntries[i]; - } - newClasspath[classpathEntries.length] = newEntry; - - javaProject.setRawClasspath(newClasspath, null); - - } catch (JavaModelException e) { - //Ignore - } - - setFolderPath(importedFoldersClass); - } - - private IJavaProject getIJavaProject(IProject projectHandle) { - IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); - return javaModel.getJavaProject(projectHandle.getName()); - } - - private CPListElement newCPLibraryElement(IResource res) { - - return new CPListElement(javaProject, IClasspathEntry.CPE_LIBRARY, res.getFullPath(), res); - } - - /** - * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection) - */ - public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) { - setWindowTitle(J2EEUIMessages.getResourceString("Import_Class_Files_UI")); //$NON-NLS-1$ - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$ - - workbench = aWorkbench; - selection = aSelection; - if (!aSelection.isEmpty() && aSelection.getFirstElement() instanceof IProject) - project = (IProject) aSelection.getFirstElement(); - - if (project != null) - createImportedClassesFolder(project); - } - - public void addPages() { - try { - super.addPages(); - mainPage = new WizardClassesImportMainPage("id", fileNames); //$NON-NLS-1$ - mainPage.setWizard(this); - if (fileNames == null || fileNames.size() == 0) - addPage(mainPage); - page1 = new WizardClassesImportPage1(workbench, selection, importedClassesPath, fileNames); - page1.setWizard(this); - addPage(page1); - } catch (Throwable ex) { - ex.printStackTrace(); - } - - - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/DefaultJ2EEComponentCreationWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/DefaultJ2EEComponentCreationWizard.java deleted file mode 100644 index 1a31d8aea..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/DefaultJ2EEComponentCreationWizard.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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 23, 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.wizard; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.internal.earcreation.DefaultJ2EEComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.earcreation.IDefaultJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; - -public class DefaultJ2EEComponentCreationWizard extends DataModelWizard { - private static final String SELECTION_PG = "selection"; //$NON-NLS-1$ - - /** - * @param model - */ - public DefaultJ2EEComponentCreationWizard(IDataModel model) { - super(model); - initialize(); - } - - /** - * - */ - public DefaultJ2EEComponentCreationWizard() { - super(); - initialize(); - } - - /** - * - */ - private void initialize() { - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_WIZ_TITLE)); - String iconPath = "icons/full/"; //$NON-NLS-1$ - try { - URL installURL = IDEWorkbenchPlugin.getDefault().getDescriptor().getInstallURL(); - URL url = new URL(installURL, iconPath + "wizban/new_wiz.png"); //$NON-NLS-1$ - ImageDescriptor desc = ImageDescriptor.createFromURL(url); - setDefaultPageImageDescriptor(desc); - } catch (MalformedURLException e) { - // Should not happen. Ignore. - } - setNeedsProgressMonitor(true); - setForcePreviousAndNextButtons(true); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - public void doAddPages() { - addPage(new NewJ2EEComponentSelectionPage(getDataModel(), SELECTION_PG)); - } - - public boolean canFinish() { - if (!super.canFinish()) { - return false; - } - return getDataModel().getBooleanProperty(IDefaultJ2EEComponentCreationDataModelProperties.ENABLED); - } - - protected IDataModelProvider getDefaultProvider() { - return new DefaultJ2EEComponentCreationDataModelProvider(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportPage.java deleted file mode 100644 index e6e2e7fa8..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportPage.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class EARComponentExportPage extends J2EEExportPage { - /** - * @param model - * @param pageName - */ - public EARComponentExportPage(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName, selection); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_EXPORT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_EXPORT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_EXPORT_WIZARD_BANNER)); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getProjectImportLabel() - */ - protected String getComponentLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_PROJECT_FOR_MODULE_CREATION); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFilterExpression() - */ - protected String[] getFilterExpression() { - return new String[]{"*.ear"}; //$NON-NLS-1$ - } - - /** - * @return - */ - protected boolean shouldShowProjectFilesCheckbox() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEExportPage#isMetaTypeSupported(java.lang.Object) - */ - protected boolean isMetaTypeSupported(Object o) { - return o instanceof Application; - } - - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEComponentExportDataModelProperties.PROJECT_NAME, IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, IJ2EEComponentExportDataModelProperties.OVERWRITE_EXISTING}; - } - - protected String getInfopopID() { - return IJ2EEUIContextIds.EXPORT_EAR_WIZARD_P1; - } - - protected String getCompnentID() { - return "JST_EAR"; //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportWizard.java deleted file mode 100644 index a9b261117..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentExportWizard.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 - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.wizard; - -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentExportDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.ui.IExportWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * <p> - * Wizard used to export J2EE Enterprise Application structures from the Eclipse Workbench to a - * deployable Enterprise Application Archive *.ear file. - * </p> - */ -public final class EARComponentExportWizard extends J2EEArtifactExportWizard implements IExportWizard { - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public EARComponentExportWizard() { - super(); - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public EARComponentExportWizard(IDataModel model) { - super(model); - } - - protected IDataModelProvider getDefaultProvider() { - return new EARComponentExportDataModelProvider(); - } - - /** - * <p> - * Adds the following pages: - * <ul> - * <li>{@link EARComponentExportPage}as the main wizard page ({@link #MAIN_PG}) - * </ul> - * </p> - */ - public void doAddPages() { - addPage(new EARComponentExportPage(getDataModel(), MAIN_PG, getSelection())); - } - - /** - * {@inheritDoc} - * - * <p> - * Sets up the default wizard page image. - * </p> - */ - protected void doInit() { - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_EXPORT_WIZARD_BANNER)); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportOptionsPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportOptionsPage.java deleted file mode 100644 index 57311d230..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportOptionsPage.java +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 8, 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.wizard; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.j2ee.datamodel.properties.IEARComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class EARComponentImportOptionsPage extends DataModelWizardPage { - private Button deselectAllButton; - private Button selectAllButton; - private Label moduleProjectLocationLabel; - protected Button browseButton; - protected Button useAlternateRootBtn; - protected Text systemDefaultText; - protected ArchiveWrapper aWrapper; - public CheckboxTableViewer availableJARsViewer; - public boolean utilJarSelectionChanged = false; - - /** - * @param model - * @param pageName - */ - public EARComponentImportOptionsPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - setInfopopID(IJ2EEUIContextIds.IMPORT_EAR_WIZARD_P2); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - createJARsComposite(composite); - createProjectRootComposite(composite); - - return composite; - } - - /* - * Updates the enable state of the all buttons - */ - protected void updateButtonEnablements() { - utilJarSelectionChanged = true; - } - - protected void createAvailableJarsList(Composite listGroup) { - availableJARsViewer = CheckboxTableViewer.newCheckList(listGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridData gData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); - gData.widthHint = 200; - gData.heightHint = 80; - availableJARsViewer.getControl().setLayoutData(gData); - AvailableUtilJarsAndWebLibProvider availableUtilJARsProvider = new AvailableUtilJarsAndWebLibProvider(); - availableJARsViewer.setContentProvider(availableUtilJARsProvider); - availableJARsViewer.setLabelProvider(availableUtilJARsProvider); - availableJARsViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - availableJARCheckStateChanged(event); - } - }); - availableJARsViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - updateButtonEnablements(); - } - }); - TableLayout tableLayout = new TableLayout(); - availableJARsViewer.getTable().setLayout(tableLayout); - availableJARsViewer.getTable().setHeaderVisible(false); - availableJARsViewer.getTable().setLinesVisible(false); - - model.addListener(new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if (event.getPropertyName().equals(IEARComponentImportDataModelProperties.UTILITY_LIST)) { - availableJARsViewer.setCheckedElements(((List) model.getProperty(IEARComponentImportDataModelProperties.UTILITY_LIST)).toArray()); - } - } - }); - } - - private void handleDeselectAllButtonPressed() { - ArrayList emptySelection = new ArrayList(2); - model.setProperty(IEARComponentImportDataModelProperties.UTILITY_LIST, emptySelection); - validatePage(); - } - - private void handleSelectAllButtonPressed() { - ArrayList allSelection = new ArrayList(2); - Object selection = null; - for (int i = 0; (null != (selection = availableJARsViewer.getElementAt(i))); i++) { - allSelection.add(selection); - } - model.setProperty(IEARComponentImportDataModelProperties.UTILITY_LIST, allSelection); - validatePage(); - } - - /** - * Open an appropriate directory browser - */ - protected void handleBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(browseButton.getShell()); - dialog.setMessage(J2EEUIMessages.getResourceString(J2EEUIMessages.SELECT_DIRECTORY_DLG)); - - String dirName = getBrowseStartLocation(); - - if (!isNullOrEmpty(dirName)) { - File path = new File(dirName); - if (path.exists()) - dialog.setFilterPath(dirName); - } - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) - systemDefaultText.setText(selectedDirectory); - - } - - protected String getBrowseStartLocation() { - String text = systemDefaultText.getText(); - return text; - } - - protected void createButtonsGroup(Composite parent) { - Composite buttonGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - buttonGroup.setLayout(layout); - buttonGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - selectAllButton = new Button(buttonGroup, SWT.PUSH); - selectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_SELECT_ALL_UTIL_BUTTON)); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - gd.widthHint = 140; - selectAllButton.setLayoutData(gd); - selectAllButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleSelectAllButtonPressed(); - } - }); - - deselectAllButton = new Button(buttonGroup, SWT.PUSH); - deselectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_DESELECT_ALL_UTIL_BUTTON)); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - gd.widthHint = 140; - deselectAllButton.setLayoutData(gd); - deselectAllButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleDeselectAllButtonPressed(); - } - }); - } - - protected void createJARsComposite(Composite parent) { - Group group = new Group(parent, SWT.NULL); - group.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_JARS_GROUP)); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label description = new Label(group, SWT.NULL); - description.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_SELECT_UTIL_JARS_TO_BE_PROJECTS)); - GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd2.horizontalSpan = 3; - description.setLayoutData(gd2); - - // create jars check box viewer - createAvailableJarsList(group); - createButtonsGroup(group); - } - - protected void createProjectRootComposite(Composite parent) { - Group group = new Group(parent, SWT.NULL); - group.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.PROJECT_LOCATIONS_GROUP)); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label description = new Label(group, SWT.NULL); - description.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_PROJECT_GROUP_DESCRIPTION)); - GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd2.horizontalSpan = 3; - description.setLayoutData(gd2); - - moduleProjectLocationLabel = new Label(group, SWT.NULL); - moduleProjectLocationLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.USE_DEFAULT_ROOT_RADIO)); - moduleProjectLocationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - systemDefaultText = new Text(group, SWT.READ_ONLY | SWT.WRAP | SWT.BORDER); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - systemDefaultText.setLayoutData(gd); - synchHelper.synchText(systemDefaultText, IEARComponentImportDataModelProperties.NESTED_MODULE_ROOT, null); - - browseButton = new Button(group, SWT.PUSH); - browseButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.BROWSE_LABEL)); - gd = new GridData(GridData.HORIZONTAL_ALIGN_END); - browseButton.setLayoutData(gd); - browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleBrowseButtonPressed(); - } - }); - } - - private void refreshEARFileIfNecessary() { - if (isEARFileChanged()) { - aWrapper = (ArchiveWrapper) model.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - refresh(); - } - } - - protected void setJARsCompositeEnabled(boolean enabled) { - availableJARsViewer.getTable().setEnabled(enabled); - availableJARsViewer.setAllChecked(false); - availableJARsViewer.setAllGrayed(!enabled); - selectAllButton.setEnabled(enabled); - deselectAllButton.setEnabled(enabled); - } - - private void refresh() { - availableJARsViewer.setInput(aWrapper); - } - - public boolean isEARFileChanged() { - return aWrapper != model.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - } - - protected void enter() { - super.enter(); - refreshEARFileIfNecessary(); - } - - public void availableJARCheckStateChanged(CheckStateChangedEvent event) { - model.setProperty(IEARComponentImportDataModelProperties.UTILITY_LIST, getJARsForProjects()); - validatePage(); - } - - public List getJARsForProjects() { - refreshEARFileIfNecessary(); - List result = new ArrayList(); - result.addAll(Arrays.asList(availableJARsViewer.getCheckedElements())); - return result; - } - - protected boolean isNullOrEmpty(String aString) { - return aString == null || aString.length() == 0; - } - - protected String[] getValidationPropertyNames() { - return new String[]{}; - } - - protected void restoreWidgetValues() { - // This page doesn't implement... - } - - public void storeDefaultSettings() { - // This page doesn't implement... - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportPage.java deleted file mode 100644 index a13d1b157..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportPage.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * Created on Dec 8, 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.wizard; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel; -import org.eclipse.jst.j2ee.application.internal.operations.J2EEArtifactImportDataModelProvider; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class EARComponentImportPage extends J2EEImportPage { - protected Combo serverTargetCombo; - - /** - * @param model - * @param pageName - */ - public EARComponentImportPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - setInfopopID(IJ2EEUIContextIds.IMPORT_EAR_WIZARD_P1); - GridLayout layout = new GridLayout(3, false); - composite.setLayout(layout); - createFileNameComposite(composite); - createProjectNameComposite(composite); - createAnnotationsStandaloneGroup(composite); - restoreWidgetValues(); - Dialog.applyDialogFont(parent); - return composite; - } - - protected String getProjectImportLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_PROJECT_LABEL); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFileImportLabel() - */ - protected String getFileImportLabel() { - return J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_FILE_LABEL); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFilterExpression() - */ - protected String[] getFilterExpression() { - return new String[]{"*.ear"}; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEModuleImportPage#createAnnotationsStandaloneGroup(org.eclipse.swt.widgets.Composite) - */ - protected void createAnnotationsStandaloneGroup(Composite composite) { - // new AnnotationsStandaloneGroup(composite, model, false); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEComponentImportDataModelProperties.FILE_NAME, - IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, - EARComponentImportDataModelProvider.EAR_NAME_VALIDATION, - IFacetProjectCreationDataModelProperties.FACET_RUNTIME, - IAnnotationsDataModel.USE_ANNOTATIONS, - J2EEArtifactImportDataModelProvider.FACET_RUNTIME}; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFileNamesStoreID() - */ - protected String getFileNamesStoreID() { - return "EAR";//$NON-NLS-1$ - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportWizard.java deleted file mode 100644 index ee5c89671..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentImportWizard.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.ui.IImportWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; - -/** - * <p> - * Wizard used to import J2EE Application structures into the Eclipse Workbench from an existing - * Enterprise Application Archive *.ear file. - * </p> - */ -public final class EARComponentImportWizard extends J2EEArtifactImportWizard implements IExecutableExtension, IImportWizard { - - /** - * <p> - * Constant used to identify the key of the Projects page of the Wizard. - * </p> - */ - protected static final String PROJECT_PG = "projects"; //$NON-NLS-1$ - - /** - * <p> - * Constant used to identify the key of the Options page of the Wizard. - * </p> - */ - protected static final String OPTIONS_PG = "options"; //$NON-NLS-1$ - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public EARComponentImportWizard() { - super(); - setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$ - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public EARComponentImportWizard(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$ - } - - /** - * <p> - * Adds the following pages: - * <ul> - * <li>{@link EARComponentImportPage}as the main wizard page ({@link #MAIN_PG}) - * <li>{@link EARComponentImportOptionsPage}as the options wizard page ({@link #OPTIONS_PG}) - * <li>{@link EARComponentProjectsPage}as the project wizard page ({@link #PROJECT_PG}) - * </ul> - * - * </p> - */ - public void doAddPages() { - addPage(new EARComponentImportPage(getDataModel(), MAIN_PG)); - addPage(new EARComponentImportOptionsPage(getDataModel(), OPTIONS_PG)); - addPage(new EARComponentProjectsPage(getDataModel(), PROJECT_PG)); - } - - - - /** - * {@inheritDoc} - * - * <p> - * Sets up the dialog window title and default wizard page image. - * </p> - */ - protected void doInit() { - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.IMPORT_WIZ_TITLE)); - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - - } - - protected IDataModelProvider getDefaultProvider() { - return new EARComponentImportDataModelProvider(); - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_EAR); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentProjectsPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentProjectsPage.java deleted file mode 100644 index 880a0bd04..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARComponentProjectsPage.java +++ /dev/null @@ -1,298 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 8, 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.wizard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jst.j2ee.application.internal.operations.EARComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.datamodel.properties.IEARComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class EARComponentProjectsPage extends DataModelWizardPage { - - private CheckboxTableViewer earFileListViewer; - - public static final String INCLUDE_COLUMN = J2EEUIMessages.getResourceString("EARImportProjectsPage_UI_0"); //$NON-NLS-1$ - public static final String FILE_COLUMN = J2EEUIMessages.getResourceString("EARImportProjectsPage_UI_1"); //$NON-NLS-1$ - public static final String PROJECT_COLUMN = J2EEUIMessages.getResourceString("EARImportProjectsPage_UI_2"); //$NON-NLS-1$ - - /** - * @param model - * @param pageName - */ - public EARComponentProjectsPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_PROJECT_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_PROJECT_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - } - - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - setInfopopID(IJ2EEUIContextIds.IMPORT_EAR_WIZARD_P3); - GridLayout layout = new GridLayout(); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - createListGroup(composite); - createButtonsGroup(composite); - - return composite; - } - - protected void setColumnEditors() { - Table t = earFileListViewer.getTable(); - CellEditor[] columnEditors = new CellEditor[t.getColumnCount()]; - columnEditors[1] = new TextCellEditor(t); - - earFileListViewer.setCellEditors(columnEditors); - } - - protected void createButtonsGroup(Composite parent) { - Composite buttonGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - buttonGroup.setLayout(layout); - buttonGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Button selectNotInWorkspace = new Button(buttonGroup, SWT.PUSH); - selectNotInWorkspace.setText(J2EEUIMessages.getResourceString("EARImportProjectsPage_UI_3")); //$NON-NLS-1$ - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - //gd.horizontalSpan = 1; - //gd.heightHint = 22; - gd.widthHint = 140; - selectNotInWorkspace.setLayoutData(gd); - selectNotInWorkspace.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - List list = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST); - List selectedList = (List) model.getProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST); - List newList = new ArrayList(); - newList.addAll(selectedList); - IDataModel importDM = null; - for (int i = 0; i < list.size(); i++) { - importDM = (IDataModel) list.get(i); - if (!newList.contains(importDM)) { - IVirtualComponent tempComponent = (IVirtualComponent) importDM.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT); - if(tempComponent == null || !tempComponent.exists()){ - newList.add(importDM); - } - } - } - model.setProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST, newList); - } - }); - - Button selectAllButton = new Button(buttonGroup, SWT.PUSH); - selectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_SELECT_ALL_UTIL_BUTTON)); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - //gd.horizontalSpan = 1; - //gd.heightHint = 22; - gd.widthHint = 140; - selectAllButton.setLayoutData(gd); - selectAllButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - List list = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST); - List newList = new ArrayList(); - newList.addAll(list); - model.setProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST, newList); - } - }); - - Button deselectAllButton = new Button(buttonGroup, SWT.PUSH); - deselectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_DESELECT_ALL_UTIL_BUTTON)); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - ////gd.horizontalSpan = 1; - //gd.heightHint = 22; - gd.widthHint = 140; - deselectAllButton.setLayoutData(gd); - deselectAllButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - List newList = new ArrayList(); - model.setProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST, newList); - } - }); - } - - public void propertyChanged(DataModelEvent event) { - if (event.getPropertyName().equals(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST)) { - if(earFileListViewer != null){ - updateGUICheckSelection(); - } - } - super.propertyChanged(event); - } - - public void setFileListViewerInput() { - TableObjects files = new TableObjects(); - Iterator iterator = ((List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST)).iterator(); - while (iterator.hasNext()) { - files.tableObjectsList.add(iterator.next()); - } - earFileListViewer.setInput(files); - updateGUICheckSelection(); - } - - private void updateGUICheckSelection() { - List selectedList = (List) model.getProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST); - List projectList = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST); - Object currentElement = null; - for (int i = 0; i < projectList.size(); i++) { - currentElement = projectList.get(i); - earFileListViewer.setChecked(currentElement, selectedList.contains(currentElement)); - } - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.internal.wizard.J2EEWizardPage#enter() - */ - protected void enter() { - super.enter(); - setFileListViewerInput(); - validatePage(); - } - - /** - * Creates the import source specification widgets. <b>Subclasses </b> must override this hook - * method. - * - * @param parent - * a <code>Composite</code> that is to be used as the parent of this group's - * collection of visual components - * @see org.eclipse.swt.widgets.Composite - */ - protected void createListGroup(org.eclipse.swt.widgets.Composite parent) { - Composite listGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - listGroup.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - listGroup.setLayoutData(gd); - - earFileListViewer = CheckboxTableViewer.newCheckList(listGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); - EARImportListContentProvider provider = new EARImportListContentProvider(); - earFileListViewer.setContentProvider(provider); - earFileListViewer.setLabelProvider(provider); - earFileListViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - IDataModel matchingModel = null;// getEARImportDataModel().getMatchingEJBJarOrClient(aModel); - if (null != matchingModel) { - earFileListViewer.setChecked(matchingModel, event.getChecked()); - } - List result = new ArrayList(); - result.addAll(Arrays.asList(earFileListViewer.getCheckedElements())); - model.setProperty(IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST, result); - - } - }); - - Table earFileListTable = (Table) earFileListViewer.getControl(); - earFileListTable.setHeaderVisible(true); - earFileListTable.setLinesVisible(true); - // set up table layout - TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout(); - tableLayout.addColumnData(new ColumnWeightData(100, true)); - tableLayout.addColumnData(new ColumnWeightData(200, true)); - earFileListTable.setLayout(tableLayout); - - gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); - gd.widthHint = 400; - earFileListTable.setLayoutData(gd); - - - TableColumn fileNameColumns = new TableColumn(earFileListTable, SWT.NONE); - fileNameColumns.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_Modules_in_EAR)); - fileNameColumns.setResizable(true); - - TableColumn importNameColumn = new TableColumn(earFileListTable, SWT.NONE); - importNameColumn.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_New_Project_Name)); - importNameColumn.setResizable(true); - - String[] columnProperties = new String[2]; - columnProperties[0] = FILE_COLUMN; - columnProperties[1] = PROJECT_COLUMN; - earFileListViewer.setColumnProperties(columnProperties); - - setColumnEditors(); - earFileListViewer.setCellModifier(new ICellModifier() { - public boolean canModify(Object element, String property) { - return PROJECT_COLUMN.equals(property); - } - - public Object getValue(Object element, String property) { - TableItem[] items = earFileListViewer.getTable().getSelection(); - TableItem item = items[0]; - return item.getText(1); - } - - public void modify(Object element, String property, Object value) { - TableItem elementHolder = (TableItem) element; - if (property.equals(PROJECT_COLUMN)) { - elementHolder.setText(1, (String) value); - ((IDataModel) elementHolder.getData()).setProperty(IJ2EEComponentImportDataModelProperties.PROJECT_NAME, value); - } - } - }); - } - - - protected void restoreWidgetValues() { - // This page doesn't implement... - } - - public void storeDefaultSettings() { - // This page doesn't implement... - } - - protected String[] getValidationPropertyNames() { - return new String[]{IEARComponentImportDataModelProperties.SELECTED_MODELS_LIST, EARComponentImportDataModelProvider.NESTED_PROJECTS_VALIDATION}; - } - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARImportListContentProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARImportListContentProvider.java deleted file mode 100644 index ae65f5c61..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARImportListContentProvider.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.wizard; - -import java.util.Arrays; -import java.util.Comparator; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - - -/** - * Insert the type's description here. Creation date: (5/7/2001 11:39:11 AM) - * - * @author: Administrator - */ -public class EARImportListContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider { - /** - * EARImportListContentProvider constructor comment. - */ - public EARImportListContentProvider() { - super(); - } - - /** - * Returns the elements to display in the viewer when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. The result is not - * modified by the viewer. - * - * @param inputElement - * the input element - * @return the array of elements to display in the viewer - */ - public java.lang.Object[] getElements(Object inputElement) { - if (inputElement instanceof TableObjects) { - Object[] array = ((TableObjects) inputElement).getTableObjects().toArray(); - Arrays.sort(array, new Comparator() { - public int compare(Object o1, Object o2) { - return getColumnText(o1, 0).compareTo(getColumnText(o2, 0)); - } - }); - return array; - } - return new Object[0]; // should throw exception instead - } - - /** - * Returns the label image for the given column of the given element. - * - * @param element - * the object representing the entire row, or <code>null</code> indicating that no - * input object is set in the viewer - * @param columnIndex - * the zero-based index of the column in which the label appears - */ - public org.eclipse.swt.graphics.Image getColumnImage(Object element, int columnIndex) { - return null; - } - - /** - * Returns the label text for the given column of the given element. - * - * @param element - * the object representing the entire row, or <code>null</code> indicating that no - * input object is set in the viewer - * @param columnIndex - * the zero-based index of the column in which the label appears - */ - public String getColumnText(Object element, int columnIndex) { - IDataModel dataModel = (IDataModel) element; - if (columnIndex == 0) { - ArchiveWrapper wrapper = (ArchiveWrapper) dataModel.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - if (wrapper.getPath().toString().startsWith(ArchiveConstants.WEBAPP_LIB_URI)) { - String parentWarFileName = wrapper.getParent().getName(); - return parentWarFileName + "#" + wrapper.getName(); //$NON-NLS-1$ - } - return wrapper.getPath().toString(); - } else if (columnIndex == 1) { - return dataModel.getStringProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME); - } - return ""; //$NON-NLS-1$ - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // do nothing - } - - public void dispose() { - // dispose - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARLibrariesContainerPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARLibrariesContainerPage.java deleted file mode 100644 index f45daeb20..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARLibrariesContainerPage.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.eclipse.jst.j2ee.internal.wizard; - -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; -import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension; -import org.eclipse.jdt.ui.wizards.NewElementWizardPage; -import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; - -public class EARLibrariesContainerPage extends NewElementWizardPage implements IClasspathContainerPage, IClasspathContainerPageExtension { - - protected IClasspathEntry entry = null; - - public EARLibrariesContainerPage() { - super("EARLibrariesContainerPage"); //$NON-NLS-1$ - setTitle(EARLibrariesMessages.EARLibrariesContainerPage_0); - setDescription(EARLibrariesMessages.EARLibrariesContainerPage_1); - } - - public boolean finish() { - return true; - } - - public IClasspathEntry getSelection() { - return JavaCore.newContainerEntry(J2EEComponentClasspathContainer.CONTAINER_PATH); - } - - public void setSelection(IClasspathEntry containerEntry) { - } - - public void createControl(Composite parent) { - final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - - final Text text = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP); - text.setText(getDescription()); - text.setLayoutData(new GridData(GridData.FILL_BOTH)); - setControl(composite); - } - - public void initialize(IJavaProject project, IClasspathEntry[] currentEntries) { - } - - - public static class EARLibrariesMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.j2ee.internal.wizard.earlibraries"; //$NON-NLS-1$ - - public static String EARLibrariesContainerPage_0; - - public static String EARLibrariesContainerPage_1; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, EARLibrariesMessages.class); - } - - private EARLibrariesMessages() { - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARValidationHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARValidationHelper.java deleted file mode 100644 index 7b3772c15..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/EARValidationHelper.java +++ /dev/null @@ -1,92 +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.wizard; - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.validation.UIEarValidator; -import org.eclipse.wst.common.frameworks.internal.ui.RunnableWithProgressWrapper; -import org.eclipse.wst.validation.internal.operations.OneValidatorOperation; -import org.eclipse.wst.validation.internal.operations.ValidatorManager; - -public class EARValidationHelper { - - /** - * Constructor for EARValidationHelper. - */ - private EARValidationHelper() { - super(); - } - - /** - * Return a list of runnable validation operations for all EAR projects which have auto validate - * enabled, and are impacted by the list of projects; If the ear project itself is in the list, - * then it is skipped. - */ - public static IRunnableWithProgress[] getEARValidationOperations(List modifiedProjects) { - List earProjects = Arrays.asList(J2EEProjectUtilities.getAllProjectsInWorkspaceOfType(J2EEProjectUtilities.ENTERPRISE_APPLICATION)); - List result = new ArrayList(earProjects.size()); - for (int i = 0; i < earProjects.size(); i++) { - IProject earProj = (IProject) earProjects.get(i); - if (willEARProjectNeedValidation(earProj, modifiedProjects)) { - result.add(createValidationRunnable(earProj)); - } - } - return (IRunnableWithProgress[]) result.toArray(new IRunnableWithProgress[result.size()]); - } - - /** - * Return a list of runnable validation operations for all EAR projects which have auto validate - * enabled, and are impacted by the j2ee project - */ - public static IRunnableWithProgress[] getEARValidationOperations(IProject modifiedJ2EEProject) { - return getEARValidationOperations(Collections.singletonList(modifiedJ2EEProject)); - } - - public static boolean isEARValidationAutoEnabled(IProject earProj) { - return ValidatorManager.getManager().isAutoValidate(earProj) && ValidatorManager.getManager().isEnabled(earProj, UIEarValidator.VALIDATOR_ID); - } - - private static boolean willEARProjectNeedValidation(IProject earProj, List modifiedProjects) { - if (modifiedProjects.contains(earProj) || !isEARValidationAutoEnabled(earProj)) - return false; - //TODO migrate to use artifact edits and components -// Object accessorKey = new Object(); -// EAREditModel editModel = runtime.getEarEditModelForRead(accessorKey); -// try { -// for (int i = 0; i < modifiedProjects.size(); i++) { -// if (editModel.hasMappingToProject((IProject) modifiedProjects.get(i))) -// return true; -// } -// } finally { -// if (editModel != null) -// editModel.releaseAccess(accessorKey); -// } - return false; - } - - /** - * Creates a new IRunnableWithProgress which runs a one validator operation on the EAR project - */ - public static IRunnableWithProgress createValidationRunnable(IProject earProj) { - OneValidatorOperation op = new OneValidatorOperation(earProj, UIEarValidator.VALIDATOR_ID, true, false); - - return new RunnableWithProgressWrapper(op); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ImportUtil.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ImportUtil.java deleted file mode 100644 index afa712e5e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ImportUtil.java +++ /dev/null @@ -1,216 +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.wizard; - -import java.io.File; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.client.ApplicationClient; -import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile; -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.WARFile; -import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl; -import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; - - - -/** - * @author Sachin - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class ImportUtil { - - public static final int UNKNOWN = 0; - public static final int EARFILE = 1; - public static final int EJBJARFILE = 2; - public static final int WARFILE = 3; - public static final int CLIENTJARFILE = 4; - public static final int RARFILE = 5; - public static final int IMPORTCLASSTYPE = 6; - public static final int J2EE14 = 256; - public static final int J2EE13 = 128; - public static final int J2EE12 = 64; - public static final int J2EESpec = J2EE12 + J2EE13 + J2EE14; - public static final String EAR = "EAR"; //$NON-NLS-1$ - public static final String EJB = "EJB"; //$NON-NLS-1$ - public static final String WAR = "WEB"; //$NON-NLS-1$ - public static final String JAR = "CLIENT"; //$NON-NLS-1$ - public static final String RAR = "RAR"; //$NON-NLS-1$ - public static final String[] SUFFIXES = {"", EAR, EJB, WAR, JAR, RAR, ""}; //$NON-NLS-1$ //$NON-NLS-2$ - - public static int getFileType(String fileName) { - Archive anArchive = null; - try { - try { - anArchive = CommonarchiveFactoryImpl.getActiveFactory().openArchive(fileName); - int archiveType = getArchiveType(anArchive); - if (archiveType == UNKNOWN && isImportClassType(fileName)) - return IMPORTCLASSTYPE; - return archiveType; - } catch (Exception e) { - if (isImportClassType(fileName)) - return IMPORTCLASSTYPE; - return UNKNOWN; - } - } finally { - if (anArchive != null && anArchive.isOpen()) - anArchive.close(); - } - } - - //TODO: use new getJ2EEVerions switch statements - public static int getVersionedFileType(String fileName) { - Archive anArchive = null; - try { - int archiveType = UNKNOWN; - try { - anArchive = CommonarchiveFactoryImpl.getActiveFactory().openArchive(fileName); - try { - if (anArchive.isEJBJarFile()) { - archiveType = EJBJARFILE; - EJBJar ejbJar = ((EJBJarFile) anArchive).getDeploymentDescriptor(); - if (ejbJar.getVersionID() == J2EEVersionConstants.EJB_1_1_ID) - archiveType |= J2EE12; - else if (ejbJar.getVersionID() == J2EEVersionConstants.EJB_2_0_ID) - archiveType |= J2EE13; - else if (ejbJar.getVersionID() == J2EEVersionConstants.EJB_2_1_ID) - archiveType |= J2EE14; - } else if (anArchive.isWARFile()) { - archiveType = WARFILE; - WebApp war = ((WARFile) anArchive).getDeploymentDescriptor(); - if (war.getVersionID() == J2EEVersionConstants.WEB_2_2_ID) - archiveType |= J2EE12; - else if (war.getVersionID() == J2EEVersionConstants.WEB_2_3_ID) - archiveType |= J2EE13; - else if (war.getVersionID() == J2EEVersionConstants.WEB_2_4_ID) - archiveType |= J2EE14; - } else if (anArchive.isApplicationClientFile()) { - archiveType = CLIENTJARFILE; - ApplicationClient appClient = ((ApplicationClientFile) anArchive).getDeploymentDescriptor(); - if (appClient.getVersionID() == J2EEVersionConstants.J2EE_1_2_ID) - archiveType |= J2EE12; - else if (appClient.getVersionID() == J2EEVersionConstants.J2EE_1_3_ID) - archiveType |= J2EE13; - else if (appClient.getVersionID() == J2EEVersionConstants.J2EE_1_4_ID) - archiveType |= J2EE14; - } else if (anArchive.isRARFile()) { - archiveType = RARFILE | J2EE13; - } else if (anArchive.isEARFile()) { - archiveType = EARFILE; - Application app = ((EARFile) anArchive).getDeploymentDescriptor(); - if (app.getVersionID() == J2EEVersionConstants.J2EE_1_2_ID) - archiveType |= J2EE12; - else if (app.getVersionID() == J2EEVersionConstants.J2EE_1_3_ID) - archiveType |= J2EE13; - else if (app.getVersionID() == J2EEVersionConstants.J2EE_1_4_ID) - archiveType |= J2EE14; - } - } catch (Exception e) { - //Ignore - } - - } catch (Exception e) { - //Ignore - } - if (archiveType == UNKNOWN && isImportClassType(fileName)) - archiveType = IMPORTCLASSTYPE; - return archiveType; - } finally { - if (anArchive != null && anArchive.isOpen()) - anArchive.close(); - } - } - - public static int getArchiveType(Archive anArchive) { - int type = UNKNOWN; - try { - if (anArchive.isEJBJarFile()) - type = EJBJARFILE; - else if (anArchive.isWARFile()) - type = WARFILE; - else if (anArchive.isApplicationClientFile()) - type = CLIENTJARFILE; - else if (anArchive.isRARFile()) - type = RARFILE; - else if (anArchive.isEARFile()) - type = EARFILE; - } catch (Exception e) { - //Ignore - } - return type; - } - - public static boolean isImportClassType(String fileName) { - File file = new File(fileName); - String fileExtension = getExtension(file); - if (file.isFile()) { - if (fileExtension.equalsIgnoreCase("jar") || //$NON-NLS-1$ - fileExtension.equalsIgnoreCase("zip") || //$NON-NLS-1$ - fileExtension.equalsIgnoreCase("class")) //$NON-NLS-1$ - return true; - } else if (file.isDirectory()) { //disable/enable drag/drop directories - return false; - } - return false; - } - - public static String getExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); - - if (i > 0 && i < s.length() - 1) { - ext = s.substring(i + 1).toLowerCase(); - } - return ext; - } - - - public static String findMatchingProjectName(String projectName) { - if (projectName.trim().length() > 0) { - IWorkspaceRoot root = J2EEPlugin.getWorkspace().getRoot(); - IProject[] projects = root.getProjects(); - String lowerCaseName = projectName.toLowerCase(); - // iterate through all projects a compare lowercase names - if (projectName == null || projectName.length() == 0) { - if (projects.length == 1) - return projects[0].getName(); - return null; - } - for (int i = 0; i < projects.length; i++) { - if (projects[i].exists()) { - if (WTPPlugin.isPlatformCaseSensitive()) { - if (projects[i].getName().equals(projectName)) - return projects[i].getName(); - } else { - if (projects[i].getName().toLowerCase().equals(lowerCaseName)) - return projects[i].getName(); - } - } - } - } - return projectName; - } - - - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactExportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactExportWizard.java deleted file mode 100644 index f1190ead5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactExportWizard.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ui.IWorkbench; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; - -/** - * <p> - * Serves as a base class for Wizards which export J2EE artifact structures from Eclipse projects - * into a deployable form. - * </p> - * <p> - * Subclasses must provide the methods that are required by - * {@link com.ibm.etools.j2ee.common.wizard.datamodel.WTPWizard}. - * </p> - * <p> - * Optionally, subclasses may also override the following methods: - * <ul> - * <li>{@link #doInit()()} - * <li>{@link #doDispose()()} - * </ul> - * </p> - * <p> - * The base class will ensure that the Wizard is not spawned unless all open editors are in a - * non-dirty state. Additionally, the selection from the active view which spanwed the wizard will - * be made available to subclasses via {@link #getSelection()}. - * </p> - */ -public abstract class J2EEArtifactExportWizard extends DataModelWizard { - - /** - * <p> - * Constant used to identify the key of the main page of the Wizard. - * </p> - */ - protected static final String MAIN_PG = "main"; //$NON-NLS-1$ - - private IStructuredSelection currentSelection; - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public J2EEArtifactExportWizard() { - super(); - setWindowTitle(J2EEUIMessages.getResourceString("67"));//$NON-NLS-1$ - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public J2EEArtifactExportWizard(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString("67"));//$NON-NLS-1$ - } - - /** - * <p> - * Invoked from init(IWorkbench, IStructuredSelection) once the workbench and selection have - * been safely stored away. - * </p> - * <p> - * No-op by default. - * </p> - */ - protected void doInit() { - //init - } - - /** - * <p> - * Invoked from {@link #dispose()}. Should be used to handle any specific Wizard disposal. - * </p> - */ - private void doDispose() { - //dispose - } - - /** - * <p> - * The selection is used to pre-populate values in the Wizard dialog controls. - * </p> - * - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, - * org.eclipse.jface.viewers.IStructuredSelection) - * - * @param workbench - * the current workbench parent of the wizard - * @param aSelection - * the selection from the view used to start the wizard (if any) - */ - public final void init(IWorkbench workbench, IStructuredSelection selection) { - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EXPORT_WIZ_TITLE)); - this.currentSelection = selection; - -//TODO: enable selection defaults -// if (this.currentSelection.size() > 0) { -// Object element = this.currentSelection.getFirstElement(); -// IProject project = ProjectUtilities.getProject(element); -// if (project != null) { -// IDataModel m = getDataModel(); -// Object originalProjectName = m.getProperty(IJ2EEComponentExportDataModelProperties.COMPONENT_NAME); -// m.setProperty(IJ2EEComponentExportDataModelProperties.COMPONENT_NAME, project.getName()); -// if (!m.validateProperty(IJ2EEComponentExportDataModelProperties.COMPONENT_NAME).isOK()) { -// m.setProperty(IJ2EEComponentExportDataModelProperties.COMPONENT_NAME, originalProjectName); -// } -// } -// } - setNeedsProgressMonitor(true); - doInit(); - } - - /** - * <p> - * Calls {@link #doDispose()}and then nulls out fields that are no longer needed once the - * wizard completes. - * </p> - * - * @see com.ibm.etools.j2ee.common.wizard.datamodel.WTPWizard#dispose() - */ - public final void dispose() { - super.dispose(); - doDispose(); - this.currentSelection = null; - } - - protected final boolean prePerformFinish() { - if (!CommonEditorUtility.promptToSaveAllDirtyEditors()) { - return false; - } - if (CommonEditorUtility.getDirtyEditors().length != 0) { // all checkboxes were not selected - return false; - } - return super.prePerformFinish(); - } - - /** - * @return Returns the currentSelection. - */ - protected final IStructuredSelection getSelection() { - return currentSelection; - } - - /** - * @return - */ - protected final J2EEExportPage getMainPage() { - return (J2EEExportPage) getPage(MAIN_PG); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactImportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactImportWizard.java deleted file mode 100644 index 6812078b5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEArtifactImportWizard.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.CommonEditorUtility; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IImportWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; -import org.eclipse.wst.web.internal.DelegateConfigurationElement; - -/** - * <p> - * Serves as a base class for Wizards which import J2EE artifact structures into Eclipse projects. - * </p> - * <p> - * Subclasses must provide the methods that are required by - * {@see org.eclipse.wst.common.frameworks.internal.ui.WTPWizard}. - * </p> - * <p> - * Optionally, subclasses may also override the following methods: - * <ul> - * <li>{@link #getFinalPerspectiveID()} - * <li>{@link #doInit()()} - * <li>{@link #doDispose()()} - * </ul> - * </p> - * <p> - * The base class will ensure that the Wizard is not spawned unless all open editors are in a - * non-dirty state. Additionally, the selection from the active view which spanwed the wizard will - * be made available to subclasses via {@link #getCurrentSelection()}. - * </p> - */ -public abstract class J2EEArtifactImportWizard extends DataModelWizard implements IImportWizard, IExecutableExtension { - - /** - * <p> - * Constant used to identify the key of the main page of the Wizard. - * </p> - */ - protected static final String MAIN_PG = "main"; //$NON-NLS-1$ - - private IConfigurationElement configurationElement; - private IStructuredSelection selection; - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public J2EEArtifactImportWizard() { - super(); - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public J2EEArtifactImportWizard(IDataModel model) { - super(model); - } - - /** - * <p> - * The selection is used to pre-populate values in the Wizard dialog controls. - * </p> - * - * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, - * org.eclipse.jface.viewers.IStructuredSelection) - * - * @param workbench - * the current workbench parent of the wizard - * @param aSelection - * the selection from the view used to start the wizard (if any) - */ - public final void init(IWorkbench workbench, IStructuredSelection aSelection) { - this.selection = aSelection; - setNeedsProgressMonitor(true); - doInit(); - } - - /** - * <p> - * Calls {@link #doDispose()}and then nulls out fields that are no longer needed once the - * wizard completes. - * </p> - * - * @see com.ibm.etools.j2ee.common.wizard.datamodel.WTPWizard#dispose() - */ - public final void dispose() { - super.dispose(); - doDispose(); - this.selection = null; - this.configurationElement = null; - } - - /** - * <p> - * Invoked after the selection has been saved off in - * {@link #init(IWorkbench, IStructuredSelection)}. Should be used to handle any specific - * Wizard initialization. - * </p> - */ - protected void doInit() { - // init - } - - /** - * <p> - * Invoked from {@link #dispose()}. Should be used to handle any specific Wizard disposal. - * </p> - */ - protected void doDispose() { - // dispose - } - - /** - * <p> - * The return value of this method will be used to suggest a final perspective to the user once - * the wizard completes. - * </p> - * - * @return Returns the J2EE Perpsective ID by default - */ - protected String getFinalPerspectiveID() { - return null; - } - - /** - * <p> - * Prompts the user to save open, dirty editors. - * </p> - * - * @return true only if all editors are saved - */ - protected final boolean prePerformFinish() { - if (!CommonEditorUtility.promptToSaveAllDirtyEditors()) { - return false; - } - //Must have selected to not save, but should close all remaining - CommonEditorUtility.closeAllEditors(); - return super.prePerformFinish(); - } - - /** - * <p> - * Invoked after the user has clicked the "Finish" button of the wizard. The default - * implementation will attempt to update the final perspective to the value specified by - * {@link #getFinalPerspectiveID() } - * </p> - * - * @throws InvocationTargetException - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizard#postPerformFinish() - */ - protected final void postPerformFinish() throws InvocationTargetException { - super.postPerformFinish(); - if (getFinalPerspectiveID() != null && getFinalPerspectiveID().length() > 0) { - final IConfigurationElement element = new DelegateConfigurationElement(configurationElement) { - public String getAttribute(String aName) { - if (aName.equals("finalPerspective")) { //$NON-NLS-1$ - return getFinalPerspectiveID(); - } - return super.getAttribute(aName); - } - }; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - BasicNewProjectResourceWizard.updatePerspective(element); - } - }); - } else { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - BasicNewProjectResourceWizard.updatePerspective(configurationElement); - } - }); - } - } - - /** - * {@inheritDoc} - * - * <p> - * The configuration element is saved to use when the wizard completes in order to change the - * current perspective using either (1) the value specified by {@see #getFinalPerspectiveID()} - * or (2) the value specified by the finalPerspective attribute in the Wizard's configuration - * element. - * </p> - * - * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, - * java.lang.String, java.lang.Object) - */ - public final void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { - this.configurationElement = config; - } - - /** - * @return Returns the selection. - */ - protected final IStructuredSelection getSelection() { - return selection; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentFacetCreationWizardPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentFacetCreationWizardPage.java deleted file mode 100644 index 204fd1444..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentFacetCreationWizardPage.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 Nov 10, 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.wizard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.ui.project.facet.EarSelectionPanel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage; - -public abstract class J2EEComponentFacetCreationWizardPage extends DataModelFacetCreationWizardPage implements IFacetProjectCreationDataModelProperties { - - private static final String STORE_LABEL = "LASTEARNAME_"; //$NON-NLS-1$ - - protected EarSelectionPanel earPanel; - - public J2EEComponentFacetCreationWizardPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - final Composite top = super.createTopLevelComposite(parent); - createEarComposite(top); - createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET, JAVA_WORKING_SET }); - return top; - } - - private void createEarComposite(Composite top) - { - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - final String moduleFacetId = getModuleFacetID(); - final IProjectFacet moduleFacet = ProjectFacetsManager.getProjectFacet( moduleFacetId ); - final IFacetedProject.Action action = fpjwc.getProjectFacetAction( moduleFacet ); - - earPanel = new EarSelectionPanel( (IDataModel) action.getConfig(), top ); - } - - protected abstract String getModuleFacetID(); - - protected String getModuleTypeID() { - return getModuleFacetID(); - } - - public void dispose() { - super.dispose(); - if (earPanel != null) - earPanel.dispose(); - } - - public void storeDefaultSettings() { - super.storeDefaultSettings(); - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - String facetID = getModuleFacetID(); - IDataModel j2eeModel = map.getFacetDataModel(facetID); - if(j2eeModel.getBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR)){ - String lastEARName = j2eeModel.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME); - settings.put(STORE_LABEL, lastEARName); - } - } - } - - public void restoreDefaultSettings() { - super.restoreDefaultSettings(); - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String lastEARName = settings.get(STORE_LABEL); - if (lastEARName != null){ - FacetDataModelMap map = (FacetDataModelMap)model.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - String facetID = getModuleFacetID(); - IDataModel j2eeModel = map.getFacetDataModel(facetID); - j2eeModel.setProperty(IJ2EEModuleFacetInstallDataModelProperties.LAST_EAR_NAME, lastEARName); - } - } - } - - protected IDialogSettings getDialogSettings() { - return J2EEUIPlugin.getDefault().getDialogSettings(); - } - - protected String[] getValidationPropertyNames() { - String[] superProperties = super.getValidationPropertyNames(); - List list = Arrays.asList(superProperties); - ArrayList arrayList = new ArrayList(); - arrayList.addAll( list ); - arrayList.add( IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME ); - arrayList.add( IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR ); - return (String[])arrayList.toArray( new String[0] ); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentImportWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentImportWizard.java deleted file mode 100644 index acd195984..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentImportWizard.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ui.IImportWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * <p> - * Serves as a base class for Wizards which import J2EE module structures into Eclipse projects. - * </p> - * <p> - * Import wizards must define the following methods: - * <ul> - * <li>{@link #getImportOperation()} - * <li>{@link #getModuleValidatorStrings()} - * </ul> - * </p> - * <p> - * And optionally, they may override the following methods from - * {@see org.eclipse.jst.j2ee.internal.wizard.J2EEArtifactImportWizard}: - * <ul> - * <li>{@link #getFinalPerspectiveID()} - * <li>{@link #doInit()()} - * <li>{@link #doDispose()()} - * </ul> - */ -public abstract class J2EEComponentImportWizard extends J2EEArtifactImportWizard implements IImportWizard, IExecutableExtension { - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public J2EEComponentImportWizard() { - super(); - setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$ - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public J2EEComponentImportWizard(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString("38"));//$NON-NLS-1$ - } - - /** - * <p> - * The Import Wizards can run arbitrary validators once the module has been created. These - * validators ensure that the structure created by the Import operation and the contents of that - * structure are valid. Any errors will be announced to the Problems view in Eclipse. - * </p> - * - * @return An array of validator IDs that should be used for this module type - */ - protected abstract String[] getModuleValidatorStrings(); - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentLabelProvider.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentLabelProvider.java deleted file mode 100644 index 1bb172e0a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEComponentLabelProvider.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.wizard; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; - - - -/** - * @author jialin - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates - */ -public class J2EEComponentLabelProvider implements ILabelProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - if(element instanceof IVirtualComponent){ - IVirtualComponent comp = (IVirtualComponent)element; - return comp.getProject().getName(); - } - - if (element instanceof IProject) { - IProject handle = (IProject)element; - return handle.getName(); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub - - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEExportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEExportPage.java deleted file mode 100644 index b58f006b9..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEExportPage.java +++ /dev/null @@ -1,556 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * 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.wizard; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties.IArchiveExportParticipantData; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.ui.archive.IArchiveExportParticipantPanelFactory; -import org.eclipse.jst.j2ee.ui.archive.internal.ArchiveExportParticipantPanelsExtensionPoint; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public abstract class J2EEExportPage extends DataModelWizardPage { - - public static boolean isWindows = SWT.getPlatform().toLowerCase().startsWith("win"); //$NON-NLS-1$ - - protected IStructuredSelection currentResourceSelection; - private static final int SIZING_TEXT_FIELD_WIDTH = 305; - protected static final String STORE_LABEL = "J2EE_EXPORT_"; //$NON-NLS-1$ - protected static final String OVERWRITE_LABEL = "OVERWRITE"; //$NON-NLS-1$ - protected static final String SOURCE_LABEL = "SOURCE"; //$NON-NLS-1$ - protected static final String defBrowseButtonLabel = J2EEUIMessages.getResourceString(J2EEUIMessages.BROWSE_LABEL); - protected String LABEL_DESTINATION = J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_EXPORT_DESTINATION); - protected String LABEL_RUNTIME = J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_EXPORT_RUNTIME); - private Combo resourceNameCombo; - private Combo destinationNameCombo; - private Button optimizeForRuntimeCheckbox; - private Combo runtimeNameCombo; - private Button destinationBrowseButton; - protected Button overwriteExistingFilesCheckbox; - private Button sourceFilesCheckbox; - - /** - * @param model - * @param pageName - */ - public J2EEExportPage(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName); - currentResourceSelection = selection; - Object element = currentResourceSelection.getFirstElement(); - IProject project = ProjectUtilities.getProject(element); - if (project != null) { - String projectName = project.getName(); - DataModelPropertyDescriptor [] validProjectNames = model.getValidPropertyDescriptors(IJ2EEComponentExportDataModelProperties.PROJECT_NAME); - boolean projectNameSet = false; - for(int i=0;i<validProjectNames.length && !projectNameSet; i++){ - if(projectName.equals(validProjectNames[i].getPropertyDescription())){ - projectNameSet = true; - model.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, projectName); - } - } - if(!projectNameSet && validProjectNames.length > 0){ - //if export dialog is invoked by selecting a non EAR project, get the corresponding EAR - IProject[] earProjects = J2EEProjectUtilities.getReferencingEARProjects(project); - if( earProjects.length > 0 ){ - model.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, earProjects[0].getName()); - }else - model.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, validProjectNames[0].getPropertyDescription()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - - Composite composite = new Composite(parent, SWT.NULL); - //WorkbenchHelp.setHelp(composite, getInfopopID()); - GridLayout layout = new GridLayout(1, false); - composite.setLayout(layout); - - createSourceAndDestinationGroup(composite); - createRuntimeGroup(composite); - createOptionsGroup(composite); - - //setupBasedOnInitialSelections(); - setupInfopop(composite); - restoreWidgetValues(); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * @param composite - */ - private void createSourceAndDestinationGroup(Composite parent) { - - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(3, false); - composite.setLayout(layout); - createExportComponentGroup(composite); - createDestinationGroup(composite); - - } - /** - * Creates the export source resource specification widgets. - * - * @param parent - * a <code>Composite</code> that is to be used as the parent of this group's - * collection of visual components - * @see org.eclipse.swt.widgets.Composite - */ - protected void createExportComponentGroup(Composite parent) { - - //Project label - Label projectLabel = new Label(parent, SWT.NONE); - projectLabel.setText(getComponentLabel()); - //Project combo - resourceNameCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - resourceNameCombo.setLayoutData(data); - synchHelper.synchCombo(resourceNameCombo, IJ2EEComponentExportDataModelProperties.PROJECT_NAME, null); - - - new Label(parent, SWT.NONE);//Pad label - } - - /** - * @return - */ - protected abstract String getComponentLabel(); - - protected void createDestinationGroup(org.eclipse.swt.widgets.Composite parent) { - - //Destination label - Label destinationLabel = new Label(parent, SWT.NONE); - destinationLabel.setText(LABEL_DESTINATION); - // destination name combo field - destinationNameCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER); - destinationNameCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchCombo(destinationNameCombo, IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, null); - - // destination browse button - destinationBrowseButton = new Button(parent, SWT.PUSH); - destinationBrowseButton.setText(defBrowseButtonLabel); //$NON-NLS-1$ - destinationBrowseButton.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - destinationBrowseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleDestinationBrowseButtonPressed(); - } - }); - destinationBrowseButton.setEnabled(true); - - } - - protected void createRuntimeGroup( final Composite parent ) - { - final Group group = new Group( parent, SWT.NONE ); - group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); - group.setLayout( new GridLayout( 1, false ) ); - group.setText( LABEL_RUNTIME ); - - this.optimizeForRuntimeCheckbox = new Button( group, SWT.CHECK ); - this.optimizeForRuntimeCheckbox.setText( "Optimize for a specific server runtime" ); - this.synchHelper.synchCheckbox( this.optimizeForRuntimeCheckbox, IJ2EEComponentExportDataModelProperties.OPTIMIZE_FOR_SPECIFIC_RUNTIME, null ); - - final GridData gd = new GridData(); - gd.verticalIndent = 2; - - this.optimizeForRuntimeCheckbox.setLayoutData( gd ); - - this.runtimeNameCombo = new Combo( group, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER ); - this.runtimeNameCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); - this.synchHelper.synchCombo( this.runtimeNameCombo, IJ2EEComponentExportDataModelProperties.RUNTIME, null ); - - final Composite extComposite = new EnhancedComposite( group, SWT.NONE ); - extComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); - - final GridLayout layout = new GridLayout( 1, false ); - layout.marginWidth = 10; - layout.marginHeight = 1; - - extComposite.setLayout( layout ); - - getDataModel().addListener - ( - new IDataModelListener() - { - public void propertyChanged( final DataModelEvent event ) - { - if( event.getPropertyName().equals( IJ2EEComponentExportDataModelProperties.RUNTIME ) && - event.getFlag() == IDataModel.VALUE_CHG ) - { - refreshExtensionsComposite( extComposite ); - } - else if( event.getPropertyName().equals( IJ2EEComponentExportDataModelProperties.OPTIMIZE_FOR_SPECIFIC_RUNTIME ) && - event.getFlag() == IDataModel.VALUE_CHG ) - { - final boolean optimize = ( (Boolean) event.getProperty() ).booleanValue(); - extComposite.setEnabled( optimize ); - } - } - } - ); - - refreshExtensionsComposite( extComposite ); - } - - private void refreshExtensionsComposite( final Composite extComposite ) - { - for( Control child : extComposite.getChildren() ) - { - child.dispose(); - } - - final List<IArchiveExportParticipantData> extensions - = (List<IArchiveExportParticipantData>) getDataModel().getProperty( IJ2EEComponentExportDataModelProperties.RUNTIME_SPECIFIC_PARTICIPANTS ); - - if( extensions != null ) - { - Composite innerComposite = null; - - for( IArchiveExportParticipantData extension : extensions ) - { - final String id = extension.getId(); - - final ArchiveExportParticipantPanelsExtensionPoint.PanelFactoryInfo panelExtInfo - = ArchiveExportParticipantPanelsExtensionPoint.getExtension( id ); - - if( panelExtInfo != null ) - { - final IArchiveExportParticipantPanelFactory panelFactory = panelExtInfo.loadPanelFactory(); - - if( panelFactory != null ) - { - if( innerComposite == null ) - { - innerComposite = new EnhancedComposite( extComposite, SWT.NONE ); - innerComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - - final GridLayout innerCompositeLayout = new GridLayout( 1, false ); - innerCompositeLayout.marginWidth = 0; - innerCompositeLayout.marginHeight = 0; - - innerComposite.setLayout( innerCompositeLayout ); - } - - try - { - panelFactory.createPanel( innerComposite, extension.getDataModel() ); - } - catch( Exception e ) - { - J2EEUIPlugin.logError( -1, e.getMessage(), e ); - } - } - } - } - } - - extComposite.getShell().layout( true, true ); - } - - /** - * Create the export options specification widgets. - * - * @param parent - * org.eclipse.swt.widgets.Composite - */ - protected void createOptionsGroup(Composite parent) { - - // options group - Composite optionsGroup = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(1, false); - optionsGroup.setLayout(layout); - - - // source files... checkbox - createSourceFilesCheckbox(optionsGroup); - - // overwrite... checkbox - createOverwriteExistingFilesCheckbox(optionsGroup); - - // advanced button - if (shouldShowProjectFilesCheckbox()) { - createProjectFilesCheckbox(optionsGroup); - } - } - - protected void createOverwriteExistingFilesCheckbox(Composite optionsGroup) { - //Overwrite checkbox - overwriteExistingFilesCheckbox = new Button(optionsGroup, SWT.CHECK | SWT.LEFT); - overwriteExistingFilesCheckbox.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_EXPORT_OVERWRITE_CHECKBOX)); //$NON-NLS-1$ = "Overwrite existing files without warning" - overwriteExistingFilesCheckbox.setEnabled(true); - synchHelper.synchCheckbox(overwriteExistingFilesCheckbox, IJ2EEComponentExportDataModelProperties.OVERWRITE_EXISTING, null); - } - - protected void createSourceFilesCheckbox(Composite optionsGroup) { - sourceFilesCheckbox = new Button(optionsGroup, SWT.CHECK | SWT.LEFT); - sourceFilesCheckbox.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_EXPORT_SOURCE_CHECKBOX)); //$NON-NLS-1$ - synchHelper.synchCheckbox(sourceFilesCheckbox, IJ2EEComponentExportDataModelProperties.EXPORT_SOURCE_FILES, null); - } - - /** - * @return - */ - protected boolean shouldShowProjectFilesCheckbox() { - return false; - } - - protected void createProjectFilesCheckbox(Composite composite) { - //do nothing - } - - /** - * Populates the resource name field based upon the currently-selected resources. - */ - protected void setupBasedOnInitialSelections() { - - if (currentResourceSelection.isEmpty() || setupBasedOnRefObjectSelection()) - return; // no setup needed - - java.util.List selections = new ArrayList(); - Iterator aenum = currentResourceSelection.iterator(); - while (aenum.hasNext()) { - IResource currentResource = (IResource) aenum.next(); - // do not add inaccessible elements - if (currentResource.isAccessible()) - selections.add(currentResource); - } - if (selections.isEmpty()) - return; // setup not needed anymore - -// int selectedResourceCount = selections.size(); -//TODO: find a way to select an existing component -// if (selectedResourceCount == 1) { -// IResource resource = (IResource) selections.get(0); -// if ((resource instanceof IProject) && checkForNature((IProject) resource)) { -// resourceNameCombo.setText(resource.getName().toString()); -// } -// } - } - - /** - * @return - */ - protected String getProjectImportLabel() { - return null; - } - - /** - * - */ - protected void handleDestinationBrowseButtonPressed() { - - FileDialog dialog = new FileDialog(destinationNameCombo.getShell(), SWT.SAVE); - String fileName = getDataModel().getStringProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME); - String[] filters = getFilterExpression(); - if (!isWindows) { - if (filters.length != 0 && filters[0] != null && filters[0].indexOf('.') != -1) { - fileName += filters[0].substring(filters[0].indexOf('.')); - } - } - dialog.setFileName(fileName); - if (isWindows) { - dialog.setFilterExtensions(filters); - } - String filename = dialog.open(); - if (filename != null) - destinationNameCombo.setText(filename); - } - - protected void restoreWidgetValues() { - - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) - return; // ie.- no settings stored - for (int i = 0; i < sourceNames.length; i++) { - if (sourceNames[i] == null) - sourceNames[i] = ""; //$NON-NLS-1$ - } - destinationNameCombo.setItems(sourceNames); - boolean overwrite = settings.getBoolean(STORE_LABEL + OVERWRITE_LABEL); - model.setBooleanProperty(IJ2EEComponentExportDataModelProperties.OVERWRITE_EXISTING, overwrite); - boolean includeSource = settings.getBoolean(STORE_LABEL + SOURCE_LABEL); - model.setBooleanProperty(IJ2EEComponentExportDataModelProperties.EXPORT_SOURCE_FILES, includeSource); - } - } - - public void storeDefaultSettings() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // update source names history - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) { - sourceNames = new String[0]; - } - - String newName = destinationNameCombo.getText(); - - //rip out any empty filenames and trim length to 5 - ArrayList newNames = new ArrayList(); - for (int i = 0; i < sourceNames.length && i < 5; i++) { - if (sourceNames[i].trim().length() > 0 && !newName.equals(sourceNames[i])) { - newNames.add(sourceNames[i]); - } - } - newNames.add(0, destinationNameCombo.getText()); - sourceNames = new String[newNames.size()]; - newNames.toArray(sourceNames); - - settings.put(STORE_LABEL + getFileNamesStoreID(), sourceNames); - settings.put(STORE_LABEL + OVERWRITE_LABEL, model.getBooleanProperty(IJ2EEComponentExportDataModelProperties.OVERWRITE_EXISTING)); - settings.put(STORE_LABEL + SOURCE_LABEL, model.getBooleanProperty(IJ2EEComponentExportDataModelProperties.EXPORT_SOURCE_FILES)); - } - } - - /** - * @return - */ - protected String getFileNamesStoreID() { - return getCompnentID(); - } - protected abstract String getCompnentID(); - - /** - * @return - */ - protected String[] getFilterExpression() { - return new String[0]; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#enter() - */ - protected void enter() { - super.enter(); - restoreWidgetValues(); - } - - /** - * @return - */ - //protected abstract String getNatureID(); - - protected abstract boolean isMetaTypeSupported(Object o); - - /** - * Populates the resource name field based upon the currently-selected resources. - */ - protected boolean setupBasedOnRefObjectSelection() { - - if (currentResourceSelection.size() != 1) - return false; - - Object o = currentResourceSelection.getFirstElement(); - if (!isMetaTypeSupported(o)) - return false; - - EObject ref = (EObject) o; - IResource resource = ProjectUtilities.getProject(ref); - if (resource != null) { - resourceNameCombo.setText(resource.getName().toString()); - } - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.WizardPage#getDialogSettings() - */ - protected IDialogSettings getDialogSettings() { - return J2EEUIPlugin.getDefault().getDialogSettings(); - } - - private static class EnhancedComposite - - extends Composite - - { - public EnhancedComposite( final Composite parent, - final int style ) - { - super( parent, style ); - } - - @Override - public void setEnabled( boolean enabled ) - { - super.setEnabled( enabled ); - - for( Control child : getChildren() ) - { - child.setEnabled( enabled ); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEImportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEImportPage.java deleted file mode 100644 index d41368eeb..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEImportPage.java +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.wizard; - -import java.util.ArrayList; - -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; -import org.eclipse.wst.server.ui.ServerUIUtil; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage; - -public abstract class J2EEImportPage extends DataModelWizardPage { - - private Combo componentCombo; - private Combo fileNameCombo; - private static final String STORE_LABEL = "J2EE_IMPORT_"; //$NON-NLS-1$ - private static final int SIZING_TEXT_FIELD_WIDTH = 305; - protected static final String defBrowseButtonLabel = J2EEUIMessages.getResourceString(J2EEUIMessages.BROWSE_LABEL); - - /** - * @param model - * @param pageName - */ - public J2EEImportPage(IDataModel model, String pageName) { - super(model, pageName); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(3, false); - composite.setLayout(layout); - createFileNameComposite(composite); - createProjectNameComposite(composite); - restoreWidgetValues(); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * @param composite - */ - protected void createProjectNameComposite(Composite parent) { -// if (FlexibleJavaProjectPreferenceUtil.getMultipleModulesPerProjectProp()) { -// new NewModuleDataModelGroup(parent, getDataModel(), synchHelper); -// } else { - Label componentLabel = new Label(parent, SWT.NONE); - - componentLabel.setText(getProjectImportLabel()); - componentLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - // setting up combo - componentCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - componentCombo.setLayoutData(data); - - // // setting up button - // Button newProjectButton = new Button(parent, SWT.PUSH); - // newProjectButton.setText(defNewButtonLabel); //$NON-NLS-1$ - // newProjectButton.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - // newProjectButton.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // // handleNewProjectButtonPressed(); - // } - // }); - // newProjectButton.setEnabled(true); - synchHelper.synchCombo(componentCombo, IJ2EEComponentImportDataModelProperties.PROJECT_NAME, new Control[]{componentLabel}); - new Label(parent, SWT.NULL); - createServerTargetComposite(parent); - //} - } - - - - protected void createServerTargetComposite(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.TARGET_RUNTIME_LBL)); - Combo serverTargetCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - serverTargetCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Button newServerTargetButton = new Button(parent, SWT.NONE); - newServerTargetButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_THREE_DOTS_E)); - newServerTargetButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - newServerTargetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - //FlexibleProjectCreationWizardPage.launchNewRuntimeWizard(getShell(), model); - launchNewRuntimeWizard(getShell(), model); - } - }); - Control[] deps = new Control[]{label, newServerTargetButton}; - synchHelper.synchCombo(serverTargetCombo, IFacetProjectCreationDataModelProperties.FACET_RUNTIME, deps); - } - - protected IDialogSettings getDialogSettings() { - return J2EEUIPlugin.getDefault().getDialogSettings(); - } - - protected String getProjectImportLabel() { - return null; - } - - /** - * @param composite - */ - protected void createFileNameComposite(Composite parent) { - Label fileLabel = new Label(parent, SWT.NONE); - fileLabel.setText(getFileImportLabel()); - - // setup combo - fileNameCombo = new Combo(parent, SWT.SINGLE | SWT.BORDER); - fileNameCombo.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - - // setup browse button - Button browseButton = new Button(parent, SWT.PUSH); - browseButton.setText(defBrowseButtonLabel); - browseButton.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleFileBrowseButtonPressed(); - } - }); - browseButton.setEnabled(true); - - synchHelper.synchCombo(fileNameCombo, IJ2EEComponentImportDataModelProperties.FILE_NAME, new Control[]{fileLabel, browseButton}); - } - - /** - * - */ - protected void handleFileBrowseButtonPressed() { - - FileDialog dialog = new FileDialog(fileNameCombo.getShell()); - dialog.setFilterExtensions(getFilterExpression()); - String filename = dialog.open(); - if (filename != null) - model.setProperty(IJ2EEComponentImportDataModelProperties.FILE_NAME, filename); - } - - /** - * @return - */ - protected String[] getFilterExpression() { - return new String[0]; - } - - protected void restoreWidgetValues() { - - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) - return; // ie.- no settings stored - for (int i = 0; i < sourceNames.length; i++) { - if (sourceNames[i] == null) - sourceNames[i] = ""; //$NON-NLS-1$ - } - fileNameCombo.setItems(sourceNames); - } - } - - public void storeDefaultSettings() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // update source names history - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) { - sourceNames = new String[0]; - } - // rip out any empty filenames and trim length to 5 - ArrayList newNames = new ArrayList(); - for (int i = 0; i < sourceNames.length && i < 5; i++) { - if (sourceNames[i].trim().length() > 0) { - newNames.add(sourceNames[i]); - } - } - String text = fileNameCombo.getText(); - newNames.remove(text); - newNames.add(0, text); - sourceNames = new String[newNames.size()]; - newNames.toArray(sourceNames); - - // sourceNames = addToHistory(sourceNames, - // getJ2EEImportDataModel().getStringProperty(J2EEImportDataModel.FILE_NAME)); - settings.put(STORE_LABEL + getFileNamesStoreID(), sourceNames); - - DataModelFacetCreationWizardPage.saveRuntimeSettings(settings, model); - } - } - - public void restoreDefaultSettings() { - IDialogSettings settings = getDialogSettings(); - DataModelFacetCreationWizardPage.restoreRuntimeSettings(settings, model); - } - - /** - * @return - */ - protected String getFileNamesStoreID() { - return null; - } - - /** - * Must override - */ - protected String getFileImportLabel() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#enter() - */ - protected void enter() { - super.enter(); - } - - private boolean launchNewRuntimeWizard(Shell shell, IDataModel model) { - DataModelPropertyDescriptor[] preAdditionDescriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME); - boolean isOK = ServerUIUtil.showNewRuntimeWizard(shell, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ - if (isOK && model != null) { - DataModelPropertyDescriptor[] postAdditionDescriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME); - Object[] preAddition = new Object[preAdditionDescriptors.length]; - for (int i = 0; i < preAddition.length; i++) { - preAddition[i] = preAdditionDescriptors[i].getPropertyValue(); - } - Object[] postAddition = new Object[postAdditionDescriptors.length]; - for (int i = 0; i < postAddition.length; i++) { - postAddition[i] = postAdditionDescriptors[i].getPropertyValue(); - } - Object newAddition = ProjectUtilities.getNewObject(preAddition, postAddition); - - model.notifyPropertyChange(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, IDataModel.VALID_VALUES_CHG); - if (newAddition != null) - model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, newAddition); - } - return isOK; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleExportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleExportPage.java deleted file mode 100644 index fa95ee718..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleExportPage.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 4, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public abstract class J2EEModuleExportPage extends J2EEExportPage { - /** - * @param model - * @param pageName - */ - public J2EEModuleExportPage(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName, selection); - } - - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEComponentExportDataModelProperties.PROJECT_NAME, IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, IJ2EEComponentExportDataModelProperties.OVERWRITE_EXISTING}; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.java deleted file mode 100644 index f21db8f50..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.java +++ /dev/null @@ -1,118 +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.wizard; - - -import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.ui.project.facet.EarSelectionPanel; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage; - -public abstract class J2EEModuleFacetInstallPage extends DataModelFacetInstallPage implements IJ2EEModuleFacetInstallDataModelProperties { - - private IDataModelListener facetVersionListener = null; - protected Button addDD; - - public J2EEModuleFacetInstallPage(String pageName) { - super(pageName); - } - - protected EarSelectionPanel earPanel; - - public void dispose() { - if (null != earPanel) { - earPanel.dispose(); - } - this.model.removeListener( this.facetVersionListener ); - super.dispose(); - } - - protected void setupEarControl(final Composite parent) { - Composite c = new Composite(parent, SWT.NONE); - c.setLayoutData(gdhfill()); - final GridLayout layout = new GridLayout(3, false); - layout.marginWidth = 0; - layout.marginHeight = 0; - c.setLayout(layout); - this.earPanel = new EarSelectionPanel(model, c); - } - - protected void createGenerateDescriptorControl( final Composite parent ) - { - this.addDD = new Button(parent, SWT.CHECK); - this.addDD.setText(Resources.generateDeploymentDescriptor); - //synchHelper.synchCheckbox(addDD, GENERATE_DD, null); bug 215284 - see enter() - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - this.addDD.setLayoutData(gd); - } - - protected void registerFacetVersionChangeListener() - { - this.facetVersionListener = new IDataModelListener() - { - public void propertyChanged( final DataModelEvent event ) - { - if( event.getFlag() == DataModelEvent.VALUE_CHG && - event.getPropertyName().equals( FACET_VERSION ) ) - { - final Runnable runnable = new Runnable() - { - public void run() - { - handleFacetVersionChangedEvent(); - } - }; - if(Thread.currentThread() == Display.getDefault().getThread()){ - runnable.run(); - } else { - Display.getDefault().asyncExec( runnable ); - } - } - } - }; - - this.model.addListener( facetVersionListener ); - handleFacetVersionChangedEvent(); - } - - protected void handleFacetVersionChangedEvent() - { - // The default implementation doesn't do anything. The subclass should override - // to handle this event. - } - - private static final class Resources extends NLS { - public static String generateDeploymentDescriptor; - - - static { - initializeMessages(J2EEModuleFacetInstallPage.class.getName(), Resources.class); - } - } - - protected void enter() { - if (isFirstTimeToPage() && addDD != null) - { - synchHelper.synchCheckbox(addDD, GENERATE_DD, null); - } - super.enter(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.properties deleted file mode 100644 index a30b8e8a0..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleFacetInstallPage.properties +++ /dev/null @@ -1 +0,0 @@ -generateDeploymentDescriptor = Generate deployment descriptor diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleImportPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleImportPage.java deleted file mode 100644 index 87f44302b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEModuleImportPage.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on Dec 4, 2003 - * - * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.jst.j2ee.internal.wizard; - -import org.eclipse.jst.j2ee.application.internal.operations.J2EEArtifactImportDataModelProvider; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties; -import org.eclipse.jst.j2ee.ui.project.facet.EarSelectionPanel; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public abstract class J2EEModuleImportPage extends J2EEImportPage { - /** - * @param model - * @param pageName - */ - - protected EarSelectionPanel earPanel; - - public J2EEModuleImportPage(IDataModel model, String pageName) { - super(model, pageName); - } - - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID()); - createServerEarAndStandaloneGroup(composite); - createAnnotationsStandaloneGroup(composite); - return composite; - } - - /** - * @param composite - */ - protected void createAnnotationsStandaloneGroup(Composite composite) { - } - - protected abstract String getModuleFacetID(); - /** - * @param composite - */ - - private void createServerEarAndStandaloneGroup(Composite composite) { - IDataModel creationDM = getDataModel().getNestedModel(IJ2EEComponentImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION); - FacetDataModelMap map = (FacetDataModelMap) creationDM.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP); - IDataModel facetModel = (IDataModel) map.get(getModuleFacetID()); - - Composite c = new Composite(composite, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - c.setLayoutData(data); - final GridLayout layout = new GridLayout(3, false); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.horizontalSpacing = 0; - c.setLayout(layout); - earPanel = new EarSelectionPanel(facetModel, c); - } - - - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEComponentImportDataModelProperties.FILE_NAME, - IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, - IFacetProjectCreationDataModelProperties.FACET_RUNTIME, - IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, - IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, - J2EEArtifactImportDataModelProvider.FACET_RUNTIME}; - } - - public void dispose() { - super.dispose(); - if (earPanel != null) - earPanel.dispose(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportPageNew.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportPageNew.java deleted file mode 100644 index 5090464ca..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportPageNew.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * Created on Dec 8, 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.wizard; - -import java.io.File; -import java.util.ArrayList; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEUtilityJarListImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; - -/** - * @author mdelder - */ -public class J2EEUtilityJarImportPageNew extends J2EEImportPage { - - private static final String STORE_LABEL = "J2EE_UTILITY_JAR_LIST_IMPORT_"; //$NON-NLS-1$ - // private static final int SIZING_TEXT_FIELD_WIDTH = 305; - - private Button deselectAllButton; - - private Button selectAllButton; - - protected Button browseButton; - - protected Button useAlternateRootBtn; - - private Button overwriteProjectCheckbox; - - protected CheckboxTableViewer availableJARsViewer; - - protected boolean utilJarSelectionChanged = false; - - private Combo availableJarsCombo; - - protected Button linkedPathCheckbox; - - - /** - * @param model - * @param pageName - */ - public J2EEUtilityJarImportPageNew(IDataModel model, String pageName) { - super(model, pageName); - setTitle(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_0")); //$NON-NLS-1$ - setDescription(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_1")); //$NON-NLS-1$ - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - setInfopopID(IJ2EEUIContextIds.IMPORT_UTILITY_JAR_WIZARD_P1); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createUtilityJarFileNameComposite(composite); - createLinkedPathVariable(composite); - createJARsComposite(composite); - createOverwriteCheckbox(composite); - - restoreWidgetValues(); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * @param composite - */ - protected void createUtilityJarFileNameComposite(Composite parent) { - Group fileNameGroup = new Group(parent, SWT.NULL); - fileNameGroup.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_2")); //$NON-NLS-1$ - GridLayout layout = new GridLayout(3, false); - fileNameGroup.setLayout(layout); - fileNameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label fileLabel = new Label(fileNameGroup, SWT.NONE); - fileLabel.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_3")); //$NON-NLS-1$ - fileLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - // setup combo - availableJarsCombo = new Combo(fileNameGroup, SWT.SINGLE | SWT.BORDER); - availableJarsCombo.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - - // setup browse button - browseButton = new Button(fileNameGroup, SWT.PUSH); - browseButton.setText(defBrowseButtonLabel); - browseButton.setLayoutData((new GridData(GridData.HORIZONTAL_ALIGN_END))); - browseButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - handleBrowseButtonPressed(); - } - }); - browseButton.setEnabled(true); - - synchHelper.synchCombo(availableJarsCombo, IJ2EEUtilityJarListImportDataModelProperties.AVAILABLE_JARS_DIRECTORY, new Control[]{fileLabel, browseButton}); - } - - protected void createLinkedPathVariable(Composite parent) { - - - Group linkedPathGroup = new Group(parent, SWT.NULL); - linkedPathGroup.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_4")); //$NON-NLS-1$ - - GridLayout layout = new GridLayout(1, true); - linkedPathGroup.setLayout(layout); - linkedPathGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite checkboxGroup = new Composite(linkedPathGroup, SWT.NULL); - GridLayout checkboxLayout = new GridLayout(2, false); - checkboxGroup.setLayout(checkboxLayout); - checkboxGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - linkedPathCheckbox = new Button(checkboxGroup, SWT.CHECK); - linkedPathCheckbox.setText(" "); //$NON-NLS-1$ - final Text linkedPathText = new Text(checkboxGroup, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - linkedPathText.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_5")); //$NON-NLS-1$ - linkedPathText.setEnabled(getDataModel().isPropertyEnabled(IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PATH_VARIABLE)); - - getDataModel().addListener(new IDataModelListener() { - public void propertyChanged(DataModelEvent event) { - if(IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PATH_VARIABLE.equals(event.getPropertyName())) { - linkedPathText.setEnabled(getDataModel().isPropertyEnabled(IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PATH_VARIABLE)); - } - - } - }); - - GridData textGridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); - textGridData.heightHint = 50; - textGridData.widthHint = 350; - linkedPathText.setLayoutData(textGridData); - linkedPathText.setBackground(checkboxGroup.getBackground()); - - // setup combo - Combo availableLinkedPathsCombo = new Combo(linkedPathGroup, SWT.SINGLE | SWT.BORDER); - availableLinkedPathsCombo.setLayoutData((new GridData(GridData.FILL_HORIZONTAL))); - - synchHelper.synchCombo(availableLinkedPathsCombo, IJ2EEUtilityJarListImportDataModelProperties.LINKED_PATH_VARIABLE, new Control[]{availableLinkedPathsCombo}); - - synchHelper.synchCheckbox(linkedPathCheckbox, IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PATH_VARIABLE, new Control[]{availableLinkedPathsCombo}); - - } - - /** - * Open an appropriate directory browser - */ - protected void handleBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(browseButton.getShell()); - dialog.setMessage(J2EEUIMessages.getResourceString(J2EEUIMessages.SELECT_DIRECTORY_DLG)); - - String dirName = getBrowseStartLocation(); - - if (!isNullOrEmpty(dirName)) { - File path = new File(dirName); - if (path.exists()) - dialog.setFilterPath(dirName); - } - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) - availableJarsCombo.setText(selectedDirectory); - } - - /** - * @return - */ - protected String getBrowseStartLocation() { - if (availableJarsCombo.getText() != null && availableJarsCombo.getText().length() > 0) - return availableJarsCombo.getText(); - return null; - } - - protected boolean isNullOrEmpty(String aString) { - return aString == null || aString.length() == 0; - } - - /* - * Updates the enable state of the all buttons - */ - protected void updateButtonEnablements() { - - utilJarSelectionChanged = true; - } - - protected void createAvailableJarsList(Composite listGroup) { - availableJARsViewer = CheckboxTableViewer.newCheckList(listGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - - GridData gData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); - gData.widthHint = 200; - gData.heightHint = 80; - availableJARsViewer.getControl().setLayoutData(gData); - AvailableUtilityJarsProvider availableUtilJARsProvider = new AvailableUtilityJarsProvider(); - availableJARsViewer.setContentProvider(availableUtilJARsProvider); - availableJARsViewer.setLabelProvider(availableUtilJARsProvider); - - availableJARsViewer.getTable().setHeaderVisible(false); - availableJARsViewer.getTable().setLinesVisible(false); - - availableJARsViewer.setInput(model); - - /* getModel().addListener(getOperationDataModelListener()); */ - synchHelper.synchCheckBoxTableViewer(availableJARsViewer, IJ2EEUtilityJarListImportDataModelProperties.UTILITY_JAR_LIST, null); - - - model.addListener(new IDataModelListener() { - - public void propertyChanged(DataModelEvent event) { - if (IJ2EEUtilityJarListImportDataModelProperties.AVAILABLE_JARS_DIRECTORY.equals(event.getPropertyName())) - availableJARsViewer.setInput(model); - } - }); - } - - private void handleDeselectAllButtonPressed() { - model.setProperty(IJ2EEUtilityJarListImportDataModelProperties.UTILITY_JAR_LIST, new Object[0]); - } - - private void handleSelectAllButtonPressed() { - Object[] selection = new Object[availableJARsViewer.getTable().getItemCount()]; - for (int i = 0; i < selection.length; i++) { - selection[i] = availableJARsViewer.getElementAt(i); - } - model.setProperty(IJ2EEUtilityJarListImportDataModelProperties.UTILITY_JAR_LIST, selection); - } - - protected void createButtonsGroup(org.eclipse.swt.widgets.Composite parent) { - Composite buttonGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - buttonGroup.setLayout(layout); - buttonGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - - selectAllButton = new Button(buttonGroup, SWT.PUSH); - selectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_SELECT_ALL_UTIL_BUTTON)); //$NON-NLS-1$ = "Select All" - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan = 1; - gd.heightHint = 22; - gd.widthHint = 120; - selectAllButton.setLayoutData(gd); - selectAllButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - handleSelectAllButtonPressed(); - } - }); - - deselectAllButton = new Button(buttonGroup, SWT.PUSH); - deselectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_DESELECT_ALL_UTIL_BUTTON)); //$NON-NLS-1$ = "Deselect All" - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan = 2; - gd.heightHint = 22; - gd.widthHint = 120; - deselectAllButton.setLayoutData(gd); - deselectAllButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - handleDeselectAllButtonPressed(); - } - }); - } - - protected void createJARsComposite(Composite parent) { - Group group = new Group(parent, SWT.NULL); - group.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_IMPORT_JARS_GROUP)); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label description = new Label(group, SWT.NULL); - description.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_UTILITY_JAR_LISTEAR_IMPORT_SELECT_UTIL_JARS_TO_BE_PROJECTS)); - GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd2.horizontalSpan = 2; - description.setLayoutData(gd2); - - // create jars check box viewer - createAvailableJarsList(group); - createButtonsGroup(group); - } - - /** - * @param projectOptionsGroup - */ - protected void createOverwriteCheckbox(Composite parent) { - - overwriteProjectCheckbox = new Button(parent, SWT.CHECK); - overwriteProjectCheckbox.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_6")); //$NON-NLS-1$ - synchHelper.synchCheckbox(overwriteProjectCheckbox, IJ2EEUtilityJarListImportDataModelProperties.OVERWRITE_IF_NECESSARY, null); - } - - protected void setJARsCompositeEnabled(boolean enabled) { - availableJARsViewer.getTable().setEnabled(enabled); - availableJARsViewer.setAllChecked(false); - availableJARsViewer.setAllGrayed(!enabled); - selectAllButton.setEnabled(enabled); - deselectAllButton.setEnabled(enabled); - } - - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEUtilityJarListImportDataModelProperties.UTILITY_JAR_LIST, IJ2EEUtilityJarListImportDataModelProperties.OVERWRITE_IF_NECESSARY, IJ2EEUtilityJarListImportDataModelProperties.LINKED_PATH_VARIABLE}; - } - - protected void restoreWidgetValues() { - - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) - return; // ie.- no settings stored - for (int i = 0; i < sourceNames.length; i++) { - if (sourceNames[i] == null) - sourceNames[i] = ""; //$NON-NLS-1$ - } - availableJarsCombo.setItems(sourceNames); - } - } - - public void storeDefaultSettings() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // update source names history - String[] sourceNames = settings.getArray(STORE_LABEL + getFileNamesStoreID()); - if (sourceNames == null) { - sourceNames = new String[0]; - } - - String newName = availableJarsCombo.getText(); - - // rip out any empty filenames and trim length to 5 - ArrayList newNames = new ArrayList(); - for (int i = 0; i < sourceNames.length && i < 5; i++) { - if (sourceNames[i].trim().length() > 0 && !newName.equals(sourceNames[i])) { - newNames.add(sourceNames[i]); - } - } - newNames.add(0, availableJarsCombo.getText()); - sourceNames = new String[newNames.size()]; - newNames.toArray(sourceNames); - - settings.put(STORE_LABEL + getFileNamesStoreID(), sourceNames); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFileNamesStoreID() - */ - protected String getFileNamesStoreID() { - return "UTIL";//$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFileImportLabel() - */ - protected String getFileImportLabel() { - return J2EEUIMessages.getResourceString("J2EEUtilityJarImportPage_UI_7"); //$NON-NLS-1$ - } - - - public void restoreDefaultSettings() { - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportTypePageNew.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportTypePageNew.java deleted file mode 100644 index 59d1045fa..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportTypePageNew.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * Created on May 13, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.eclipse.jst.j2ee.internal.wizard; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile; -import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEUtilityJarListImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -/** - * @author mdelder - * - * TODO To change the template for this generated type comment go to Window - Preferences - Java - - * Code Generation - Code and Comments - */ -public class J2EEUtilityJarImportTypePageNew extends DataModelWizardPage { - - protected static final String defBrowseButtonLabel = J2EEUIMessages.getResourceString(J2EEUIMessages.BROWSE_LABEL); //$NON-NLS-1$ - - private static final int SIZING_TEXT_FIELD_WIDTH = 305; - - protected IStructuredSelection currentResourceSelection; - - private Combo resourceNameCombo; - - private Button copyJarIntoEAR; - - private Button linkJarIntoEAR; - - private Button createLinkedProjects; - - private Button createProjects; - - protected Button browseButton; - - private Button overrideProjectRootCheckbox; - - - protected Text projectRootLocationText; - - private Label moduleProjectLocationLabel; - - protected boolean synching; - - public static final String TITLE = J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_0"); //$NON-NLS-1$ - public static final String DESCRIPTION = J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_1"); //$NON-NLS-1$ - - private Group projectRootComposite; - - - /** - * @param model - * @param pageName - * @param title - * @param titleImage - */ - public J2EEUtilityJarImportTypePageNew(IDataModel model, String pageName, String title, ImageDescriptor titleImage) { - super(model, pageName, title, titleImage); - setTitle(""); //$NON-NLS-1$ - setDescription(""); //$NON-NLS-1$ - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - setInfopopID(IJ2EEUIContextIds.IMPORT_UTILITY_JAR_WIZARD_P2); - } - - public J2EEUtilityJarImportTypePageNew(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName); - this.currentResourceSelection = selection; - setTitle(TITLE); - setDescription(DESCRIPTION); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - } - - public J2EEUtilityJarImportTypePageNew(IDataModel model, String pageName) { - super(model, pageName); - setTitle(TITLE); - setDescription(DESCRIPTION); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_IMPORT_WIZARD_BANNER)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() { - return new String[]{IJ2EEUtilityJarListImportDataModelProperties.EAR_PROJECT_NAME, IJ2EEUtilityJarListImportDataModelProperties.PROJECT_ROOT}; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(1, false); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createEARProjectGroup(composite); - createUtilityJarImportTypes(composite); - // TODO The binary / project location options are not yet (re-) supported by the import operations. - createProjectCreationOptions(composite); - - setupBasedOnInitialSelections(); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * @param composite - */ - protected void createUtilityJarImportTypes(Composite parent) { - Group typesGroup = new Group(parent, SWT.NULL); - typesGroup.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_2")); //$NON-NLS-1$ - - GridLayout layout = new GridLayout(1, false); - typesGroup.setLayout(layout); - typesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createProjects = new Button(typesGroup, SWT.RADIO); - createProjects.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_3")); //$NON-NLS-1$ - synchHelper.synchRadio(createProjects, IJ2EEUtilityJarListImportDataModelProperties.CREATE_PROJECT, null); - - createLinkedProjects = new Button(typesGroup, SWT.RADIO); - createLinkedProjects.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_4")); //$NON-NLS-1$ - synchHelper.synchRadio(createLinkedProjects, IJ2EEUtilityJarListImportDataModelProperties.CREATE_LINKED_PROJECT, null); - - copyJarIntoEAR = new Button(typesGroup, SWT.RADIO); - copyJarIntoEAR.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_5")); //$NON-NLS-1$ - synchHelper.synchRadio(copyJarIntoEAR, IJ2EEUtilityJarListImportDataModelProperties.COPY, null); - - linkJarIntoEAR = new Button(typesGroup, SWT.RADIO); - linkJarIntoEAR.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_6")); //$NON-NLS-1$ - /* linkJarIntoEAR.addSelectionListener(getTypeSelectionListener()); */ - synchHelper.synchRadio(linkJarIntoEAR, IJ2EEUtilityJarListImportDataModelProperties.LINK_IMPORT, null); - - } - - protected void createProjectCreationOptions(Composite parent) { - - Group projectOptionsGroup = new Group(parent, SWT.NULL); - projectOptionsGroup.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_7")); //$NON-NLS-1$ - - GridLayout layout = new GridLayout(1, false); - projectOptionsGroup.setLayout(layout); - projectOptionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - overrideProjectRootCheckbox = new Button(projectOptionsGroup, SWT.CHECK); - overrideProjectRootCheckbox.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_11")); //$NON-NLS-1$ - createProjectRootComposite(projectOptionsGroup); - - synchHelper.synchCheckbox(overrideProjectRootCheckbox, IJ2EEUtilityJarListImportDataModelProperties.OVERRIDE_PROJECT_ROOT, new Control[]{/* - * moduleProjectLocationLabel, - * projectRootLocationText, - * browseButton - */}); - } - - /** - * - * @param parent - * a <code>Composite</code> that is to be used as the parent of this group's - * collection of visual components - * @see org.eclipse.swt.widgets.Composite - */ - protected void createEARProjectGroup(Composite parent) { - - Group earGroup = new Group(parent, SWT.NULL); - earGroup.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_8")); //$NON-NLS-1$ - - GridLayout layout = new GridLayout(2, false); - earGroup.setLayout(layout); - earGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // Project label - Label projectLabel = new Label(earGroup, SWT.NONE); - projectLabel.setText(J2EEUIMessages.getResourceString("J2EEUtilityJarImportTypePage_UI_9")); //$NON-NLS-1$ - // Project combo - resourceNameCombo = new Combo(earGroup, SWT.SINGLE | SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - resourceNameCombo.setLayoutData(data); - synchHelper.synchCombo(resourceNameCombo, IJ2EEUtilityJarListImportDataModelProperties.EAR_PROJECT_NAME, null); - - } - - protected void createProjectRootComposite(Composite parent) { - projectRootComposite = new Group(parent, SWT.NULL); - projectRootComposite.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.PROJECT_LOCATIONS_GROUP)); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - projectRootComposite.setLayout(layout); - projectRootComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label description = new Label(projectRootComposite, SWT.NULL); - description.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_PROJECT_GROUP_DESCRIPTION)); - GridData gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd2.horizontalSpan = 3; - description.setLayoutData(gd2); - - moduleProjectLocationLabel = new Label(projectRootComposite, SWT.NULL); - moduleProjectLocationLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.USE_DEFAULT_ROOT_RADIO)); - moduleProjectLocationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - projectRootLocationText = new Text(projectRootComposite, SWT.BORDER); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - projectRootLocationText.setLayoutData(gd); - projectRootLocationText.setText(ResourcesPlugin.getWorkspace().getRoot().getFullPath().toOSString()); - projectRootLocationText.setEnabled(false); /* disabled by default */ - - browseButton = new Button(projectRootComposite, SWT.PUSH); - browseButton.setText(defBrowseButtonLabel); - gd = new GridData(GridData.HORIZONTAL_ALIGN_END); - browseButton.setLayoutData(gd); - browseButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - handleRootProjectBrowseButtonPressed(); - } - }); - - synchHelper.synchText(projectRootLocationText, IJ2EEUtilityJarListImportDataModelProperties.PROJECT_ROOT, new Control[]{moduleProjectLocationLabel, projectRootLocationText, browseButton}); - } - - - /** - * Open an appropriate directory browser - */ - protected void handleRootProjectBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(browseButton.getShell()); - dialog.setMessage(J2EEUIMessages.getResourceString(J2EEUIMessages.SELECT_DIRECTORY_DLG)); - - String dirName = getBrowseStartLocation(); - - if (!isNullOrEmpty(dirName)) { - File path = new File(dirName); - if (path.exists()) - dialog.setFilterPath(dirName); - } - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) - projectRootLocationText.setText(selectedDirectory); - - } - - protected String getBrowseStartLocation() { - String text = projectRootLocationText.getText(); - return text; - } - - - protected boolean isNullOrEmpty(String aString) { - return aString == null || aString.length() == 0; - } - - /** - * Populates the resource name field based upon the currently-selected resources. - */ - protected void setupBasedOnInitialSelections() { - - if (null == currentResourceSelection || currentResourceSelection.isEmpty() || setupBasedOnRefObjectSelection()) - return; // no - // setup - // needed - - java.util.List selections = new ArrayList(); - Iterator aenum = currentResourceSelection.iterator(); - while (aenum.hasNext()) { - IResource currentResource = (IResource) aenum.next(); - // do not add inaccessible elements - if (currentResource.isAccessible()) - selections.add(currentResource); - } - if (selections.isEmpty()) - return; // setup not needed anymore - - int selectedResourceCount = selections.size(); - if (selectedResourceCount == 1) { - IResource resource = (IResource) selections.get(0); - if (resource instanceof IProject ) { - resourceNameCombo.setText(resource.getName().toString()); - } - } - } - - /** - * Populates the resource name field based upon the currently-selected resources. - */ - protected boolean setupBasedOnRefObjectSelection() { - - if (currentResourceSelection.size() != 1) - return false; - - Object o = currentResourceSelection.getFirstElement(); - if (!isMetaTypeSupported(o)) - return false; - - EObject ref = (EObject) o; - IResource resource = ProjectUtilities.getProject(ref); - if (resource != null) - resourceNameCombo.setText(resource.getName().toString()); - return true; - } - - protected boolean isMetaTypeSupported(Object o) { - return o instanceof EARFile || o instanceof Application; - } - - protected void enableProjectOptions(boolean enabled) { - overrideProjectRootCheckbox.setEnabled(enabled); - - if (overrideProjectRootCheckbox.getSelection() && enabled) - projectRootLocationText.setEnabled(true); - else - projectRootLocationText.setEnabled(false); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.WizardPage#isPageComplete() - */ - public boolean isPageComplete() { - return model.validateProperty(IJ2EEUtilityJarListImportDataModelProperties.EAR_PROJECT_NAME).isOK(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportWizardNew.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportWizardNew.java deleted file mode 100644 index d16a57a94..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/J2EEUtilityJarImportWizardNew.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import org.eclipse.jst.j2ee.application.internal.operations.J2EEUtilityJarListImportDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.ui.IImportWizard; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; - - -/** - * <p> - * Used to import Utility Jars into several Eclipse workbench configurations. These can be extracted - * as editable projects, binary projects, linked resources in the EAR module or actual resources in - * the EAR module. - * </p> - */ -public final class J2EEUtilityJarImportWizardNew extends J2EEArtifactImportWizard implements IImportWizard { - - /** - * <p> - * Constant used to identify the key of the page of the Wizard which allows users to define the - * type of import they would like to carry out. - * </p> - */ - private static final String IMPORT_TYPE = "IMPORT_TYPE"; //$NON-NLS-1$ - - /** - * <p> - * Constant used to identify the key of the page of the Wizard that allows users to select jar - * files for import - * </p> - */ - private static final String SELECT_JARS = "SELECT_JARS"; //$NON-NLS-1$ - - - /** - * <p> - * The default constructor. Creates a wizard with no selection, no model instance, and no - * operation instance. The model and operation will be created as needed. - * </p> - */ - public J2EEUtilityJarImportWizardNew() { - super(); - setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$ - } - - /** - * <p> - * The model is used to prepopulate the wizard controls and interface with the operation. - * </p> - * - * @param model - * The model parameter is used to pre-populate wizard controls and interface with the - * operation - */ - public J2EEUtilityJarImportWizardNew(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString("38")); //$NON-NLS-1$ - } - - /** - * <p> - * Adds the following pages: - * <ul> - * <li>{@link J2EEUtilityJarImportTypePageNew}as the main wizard page ({@link #IMPORT_TYPE}) - * <li>{@link J2EEUtilityJarImportPageNew}as the main wizard page ({@link #SELECT_JARS}) - * </ul> - * </p> - */ - public void doAddPages() { - this.addPage(new J2EEUtilityJarImportTypePageNew(getDataModel(), IMPORT_TYPE, getSelection())); - this.addPage(new J2EEUtilityJarImportPageNew(getDataModel(), SELECT_JARS)); - } - - protected IDataModelProvider getDefaultProvider() { - return new J2EEUtilityJarListImportDataModelProvider(); - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_UTILITY); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/MinimizedFileSystemElement.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/MinimizedFileSystemElement.java deleted file mode 100644 index eb878c0bf..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/MinimizedFileSystemElement.java +++ /dev/null @@ -1,131 +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.wizard; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.ui.dialogs.FileSystemElement; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider; - -/** - * The <code>MinimizedFileSystemElement</code> is a <code>FileSystemElement</code> that knows if - * it has been populated or not. - */ -class MinimizedFileSystemElement extends FileSystemElement { - private boolean populated = false; - private String packageBaseDirName = null; - - - /** - * Create a <code>MinimizedFileSystemElement</code> with the supplied name and parent. - * - * @param name - * the name of the file element this represents - * @param parent - * the containing parent - * @param isDirectory - * indicated if this could have children or not - */ - MinimizedFileSystemElement(String name, org.eclipse.ui.dialogs.FileSystemElement parent, boolean isDirectory) { - super(name, parent, isDirectory); - } - - public void setPackageBaseDirName(String s) { - packageBaseDirName = s; - } - - public void addChild(FileSystemElement child) { - if (child.isDirectory()) { - super.addChild(child); - } else { - if (child.getFileNameExtension().equals("class")) { //$NON-NLS-1$ - super.addChild(child); - } - } - } - - /** - * Returns a list of the files that are immediate children. Use the supplied provider if it - * needs to be populated. of this folder. - */ - public AdaptableList getFiles(IImportStructureProvider provider) { - if (!populated) - populate(provider); - - return super.getFiles(); - - } - - /** - * Returns a list of the folders that are immediate children. Use the supplied provider if it - * needs to be populated. of this folder. - */ - public AdaptableList getFolders(IImportStructureProvider provider) { - if (!populated) - populate(provider); - - return super.getFolders(); - - } - - /** - * Return whether or not population has happened for the receiver. - */ - boolean isPopulated() { - return this.populated; - } - - /** - * Return whether or not population has not happened for the receiver. - */ - boolean notPopulated() { - return !this.populated; - } - - /** - * Populate the files and folders of the receiver using the suppliec structure provider. - * - * @param provider - * org.eclipse.ui.wizards.datatransfer.IImportStructureProvider - */ - private void populate(IImportStructureProvider provider) { - - Object fileSystemObject = getFileSystemObject(); - - List children = provider.getChildren(fileSystemObject); - if (children == null) - children = new ArrayList(1); - Iterator childrenEnum = children.iterator(); - while (childrenEnum.hasNext()) { - Object child = childrenEnum.next(); - - String elementLabel = provider.getLabel(child); - if (elementLabel.equals(packageBaseDirName) || packageBaseDirName == null) { - //Create one level below - - MinimizedFileSystemElement result = new MinimizedFileSystemElement(elementLabel, this, provider.isFolder(child)); - result.setFileSystemObject(child); - } - } - setPopulated(); - - } - - /** - * Set whether or not population has happened for the receiver to true. - */ - void setPopulated() { - this.populated = true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJ2EEComponentSelectionPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJ2EEComponentSelectionPage.java deleted file mode 100644 index 9c32549b5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJ2EEComponentSelectionPage.java +++ /dev/null @@ -1,524 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -/* - * Created on Mar 23, 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.wizard; - -import java.util.Iterator; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.earcreation.IDefaultJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IPluginContribution; -import org.eclipse.ui.activities.WorkbenchActivityHelper; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.wizards.IWizardDescriptor; -import org.eclipse.ui.wizards.IWizardRegistry; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; -import org.eclipse.wst.common.frameworks.internal.ui.GenericWizardNode; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy; -import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; - -public class NewJ2EEComponentSelectionPage extends DataModelWizardPage implements IDefaultJ2EEComponentCreationDataModelProperties { - private Button defaultModulesButton; - - private Composite defaultModulesComposite; - - private Composite newModulesComposite; - - private Button appClientRadioButton; - - private Button ejbRadioButton; - - private Button webRadioButton; - - private Button connectorRadioButton; - - private GenericWizardNode appClientNode; - - private GenericWizardNode ejbNode; - - private GenericWizardNode webNode; - - private GenericWizardNode connectorNode; - - private GenericWizardNode selectedNode; - - private StackLayout stackLayout; - - /** - * @param model - * @param pageName - */ - protected NewJ2EEComponentSelectionPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_DESC)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.J2EEWizardPage#getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() { - return new String[] { CREATE_APPCLIENT, APPCLIENT_COMPONENT_NAME, CREATE_CONNECTOR, CONNECTOR_COMPONENT_NAME, CREATE_EJB, EJB_COMPONENT_NAME, CREATE_WEB, WEB_COMPONENT_NAME, MODULE_NAME_COLLISIONS_VALIDATION, ENABLED }; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.J2EEWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - setInfopopID(IJ2EEUIContextIds.EAR_NEW_MODULE_PROJECTS_PAGE); - createDefaultCheckBox(composite); - Composite forStackComposite = new Composite(composite, SWT.NULL); - layout = new GridLayout(); - forStackComposite.setLayout(layout); - forStackComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - Composite stackComposite = createStackLayoutComposite(forStackComposite); - createDefaultModulesComposite(stackComposite); - createModuleSelectionComposite(stackComposite); - stackLayout.topControl = defaultModulesComposite; - setButtonEnablement(); - Dialog.applyDialogFont(parent); - return composite; - } - - protected Composite createStackLayoutComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - stackLayout = new StackLayout(); - composite.setLayout(stackLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - return composite; - } - - private void createDefaultModulesComposite(Composite parent) { - defaultModulesComposite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - defaultModulesComposite.setLayout(layout); - defaultModulesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // Default Module Controls creation - createAppClientDefaultModuleControl(); - if (J2EEPlugin.isEJBSupportAvailable()) - createEJBDefaultModuleControl(); - createWebDefaultModuleControl(); - if (J2EEPlugin.isEJBSupportAvailable()) - createConnectorDefaultModuleControl(); - } - - /** - * @param parent - */ - private void createModuleSelectionComposite(Composite parent) { - newModulesComposite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - newModulesComposite.setLayout(layout); - newModulesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - appClientRadioButton = new Button(newModulesComposite, SWT.RADIO); - - appClientRadioButton.setText(J2EEUIMessages.getResourceString("NewModuleSelectionPage.appClient")); //$NON-NLS-1$ - appClientRadioButton.addListener(SWT.Selection, this); - if (EarModuleManager.getEJBModuleExtension() != null) { - ejbRadioButton = new Button(newModulesComposite, SWT.RADIO); - ejbRadioButton.setText(J2EEUIMessages.getResourceString("NewModuleSelectionPage.ejb")); //$NON-NLS-1$ - ejbRadioButton.addListener(SWT.Selection, this); - } - if (EarModuleManager.getWebModuleExtension() != null) { - webRadioButton = new Button(newModulesComposite, SWT.RADIO); - webRadioButton.setText(J2EEUIMessages.getResourceString("NewModuleSelectionPage.web")); //$NON-NLS-1$ - webRadioButton.addListener(SWT.Selection, this); - } - if (EarModuleManager.getJCAModuleExtension() != null) { - connectorRadioButton = new Button(newModulesComposite, SWT.RADIO); - connectorRadioButton.setText(J2EEUIMessages.getResourceString("NewModuleSelectionPage.jca")); //$NON-NLS-1$ - connectorRadioButton.addListener(SWT.Selection, this); - } - } - - /** - * - */ - private void createConnectorDefaultModuleControl() { - if (EarModuleManager.getJCAModuleExtension() != null) { - String label = J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_JCA_MODULE_LBL); - createJ2EEComponentControl(label, CREATE_CONNECTOR, CONNECTOR_COMPONENT_NAME); - } - } - - /** - * - */ - private void createWebDefaultModuleControl() { - if (EarModuleManager.getWebModuleExtension() != null) { - String label = J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_WEB_MODULE_LBL); - createJ2EEComponentControl(label, CREATE_WEB, WEB_COMPONENT_NAME); - } - } - - /** - * - */ - private void createEJBDefaultModuleControl() { - if (EarModuleManager.getEJBModuleExtension() != null) { - String label = J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_EJB_MODULE_LBL); - createJ2EEComponentControl(label, CREATE_EJB, EJB_COMPONENT_NAME); - } - } - - private void createAppClientDefaultModuleControl() { - String label = J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_APPCLIENT_MODULE_LBL); - createJ2EEComponentControl(label, CREATE_APPCLIENT, APPCLIENT_COMPONENT_NAME); - } - - private void createJ2EEComponentControl(String label, String createProperty, String projectProperty) { - final Button checkBox = new Button(defaultModulesComposite, SWT.CHECK); - checkBox.setSelection(true); - checkBox.setText(label); - - final Text textField = new Text(defaultModulesComposite, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - textField.setLayoutData(data); - synchHelper.synchCheckbox(checkBox, createProperty, null); - synchHelper.synchText(textField, projectProperty, null); - } - - private void createDefaultCheckBox(Composite composite) { - Composite checkBoxComposite = new Composite(composite, SWT.NULL); - GridLayout layout = new GridLayout(); - checkBoxComposite.setLayout(layout); - checkBoxComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - defaultModulesButton = new Button(checkBoxComposite, SWT.CHECK); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalIndent = 0; - defaultModulesButton.setLayoutData(data); - defaultModulesButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.DEFAULT_COMPONENT_PAGE_NEW_MOD_SEL_PG_DEF_BTN)); - defaultModulesButton.setSelection(true); - defaultModulesButton.addListener(SWT.Selection, this); - synchHelper.synchCheckbox(defaultModulesButton, ENABLED, null); - createControlsSeparatorLine(checkBoxComposite); - } - - protected void createControlsSeparatorLine(Composite parent) { - // add a horizontal line - Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); - separator.setLayoutData(data); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) - */ - public void handleEvent(Event evt) { - if (evt.widget == defaultModulesButton) - handleDefaultModulesButtonPressed(); - else if (!defaultModulesButton.getSelection()) { - if (evt.widget == appClientRadioButton && appClientRadioButton.getSelection()) - setSelectedNode(getAppClientNode()); - else if (evt.widget == ejbRadioButton && ejbRadioButton.getSelection()) - setSelectedNode(getEjbNode()); - else if (evt.widget == webRadioButton && webRadioButton.getSelection()) - setSelectedNode(getWebNode()); - else if (evt.widget == connectorRadioButton && connectorRadioButton.getSelection()) - setSelectedNode(getConnectorNode()); - validatePage(); - } - super.handleEvent(evt); - } - - /** - * - */ - private void handleDefaultModulesButtonPressed() { - if (defaultModulesButton.getSelection()) { - setSelectedNode(null); - showDefaultModulesComposite(); - setDefaultModulesSelection(true); - } else { - setDefaultModulesSelection(false); - showNewModulesCompsite(); - } - setButtonEnablement(); - validatePage(); - } - - private void setDefaultModulesSelection(boolean selection) { - getDataModel().setBooleanProperty(CREATE_APPCLIENT, selection); - getDataModel().setBooleanProperty(CREATE_CONNECTOR, selection); - getDataModel().setBooleanProperty(CREATE_EJB, selection); - getDataModel().setBooleanProperty(CREATE_WEB, selection); - } - - private void showDefaultModulesComposite() { - defaultModulesComposite.setVisible(true); - newModulesComposite.setVisible(false); - stackLayout.topControl = defaultModulesComposite; - } - - /** - * This is done based on the J2EE version. We need to disable Connectors if - * not j2ee 1.3 or higher. - */ - private void setButtonEnablement() { - if (!defaultModulesButton.getSelection() && connectorRadioButton != null) { - int version = getDataModel().getIntProperty(J2EE_VERSION); - connectorRadioButton.setEnabled(version > J2EEVersionConstants.J2EE_1_2_ID); - } - } - - /** - * - */ - private void showNewModulesCompsite() { - defaultModulesComposite.setVisible(false); - newModulesComposite.setVisible(true); - if (!isAnyModuleRadioSelected()) - appClientRadioButton.setSelection(true); - setSelectedNode(getWizardNodeFromSelection()); - stackLayout.topControl = newModulesComposite; - } - - /** - * @return - */ - private GenericWizardNode getWizardNodeFromSelection() { - if (appClientRadioButton.getSelection()) - return getAppClientNode(); - if (connectorRadioButton != null && connectorRadioButton.getSelection()) - return getConnectorNode(); - if (ejbRadioButton != null && ejbRadioButton.getSelection()) - return getEjbNode(); - if (webRadioButton != null && webRadioButton.getSelection()) - return getWebNode(); - return null; - } - - /** - * @return - */ - private boolean isAnyModuleRadioSelected() { - return appClientRadioButton.getSelection() || (connectorRadioButton != null && connectorRadioButton.getSelection()) || (ejbRadioButton != null && ejbRadioButton.getSelection()) || (webRadioButton != null && webRadioButton.getSelection()); - } - - /** - * @return Returns the appClientNode. - */ - private GenericWizardNode getAppClientNode() { - if (appClientNode == null) { - appClientNode = new GenericWizardNode() { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.GenericWizardNode#createWizard() - */ - protected IWizard createWizard() { - return createChildWizard("org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard", NESTED_MODEL_CLIENT); //$NON-NLS-1$ - } - }; - } - return appClientNode; - } - - /** - * @return Returns the connectorNode. - */ - private GenericWizardNode getConnectorNode() { - if (connectorNode == null) { - connectorNode = new GenericWizardNode() { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.GenericWizardNode#createWizard() - */ - protected IWizard createWizard() { - return createChildWizard("org.eclipse.jst.j2ee.jca.ui.internal.wizard.ConnectorProjectWizard", NESTED_MODEL_JCA); //$NON-NLS-1$ - } - }; - } - return connectorNode; - } - - /** - * @return Returns the ejbNode. - */ - private GenericWizardNode getEjbNode() { - if (ejbNode == null) { - ejbNode = new GenericWizardNode() { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.GenericWizardNode#createWizard() - */ - protected IWizard createWizard() { - return createChildWizard("org.eclipse.jst.ejb.ui.project.facet.EjbProjectWizard", NESTED_MODEL_EJB); //$NON-NLS-1$ - } - }; - } - return ejbNode; - } - - /** - * @return Returns the webNode. - */ - private GenericWizardNode getWebNode() { - if (webNode == null) { - webNode = new GenericWizardNode() { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.GenericWizardNode#createWizard() - */ - protected IWizard createWizard() { - return createChildWizard("org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard", NESTED_MODEL_WEB); //$NON-NLS-1$ - } - }; - } - return webNode; - } - - private IWizard createChildWizard(String id, String parentWizModelName) { - NewProjectDataModelFacetWizard wizard = null; - IWizardRegistry newWizardRegistry = WorkbenchPlugin.getDefault().getNewWizardRegistry(); - IWizardDescriptor wizardDescriptor = newWizardRegistry.findWizard(id); - try { - // retrieve the model of the parent wizard - IDataModel parentWizModel = getDataModel().getNestedModel(parentWizModelName); - - // create the child wizard and retrieve its model - wizard = (NewProjectDataModelFacetWizard) wizardDescriptor.createWizard(); - IDataModel childWizModel = wizard.getDataModel(); - - // copy the properties of the parent wizard's model to the child wizard's model - Iterator props = parentWizModel.getBaseProperties().iterator(); - while (props.hasNext()) { - String prop = (String) props.next(); - childWizModel.setProperty(prop, parentWizModel.getProperty(prop)); - } - //[Bug 243226] after updating the model the FactedProjectWorkingCopy needs to be updated. - wizard.setFacetedProjectWorkingCopy((IFacetedProjectWorkingCopy)childWizModel.getProperty(IFacetProjectCreationDataModelProperties.FACETED_PROJECT_WORKING_COPY)); - } catch (CoreException ce) { - Logger.getLogger().log(ce); - } - return wizard; - } - - /** - * @param selectedNode - * The selectedNode to set. - */ - private void setSelectedNode(GenericWizardNode selectedNode) { - this.selectedNode = selectedNode; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage() - */ - public boolean canFlipToNextPage() { - if (!defaultModulesButton.getSelection()) - return selectedNode != null; - return false; - } - - /** - * The <code>WizardSelectionPage</code> implementation of this - * <code>IWizardPage</code> method returns the first page of the currently - * selected wizard if there is one. - */ - public IWizardPage getNextPage() { - if (selectedNode == null) - return null; - IPluginContribution pluginContribution = new IPluginContribution() { - public String getLocalId() { - String id = null; - if (selectedNode == appClientNode) { - id = "org.eclipse.jst.j2ee.internal.internal.internal.appclientProjectWizard"; //$NON-NLS-1$ - } else if (selectedNode == ejbNode) { - id = "org.eclipse.jst.j2ee.internal.internal.internal.ejb.ui.util.ejbProjectWizard"; //$NON-NLS-1$ - } else if (selectedNode == connectorNode) { - id = "org.eclipse.jst.j2ee.internal.internal.internal.jcaProjectWizard"; //$NON-NLS-1$ - } else if (selectedNode == webNode) { - id = "org.eclipse.jst.j2ee.internal.internal.internal.webProjectWizard"; //$NON-NLS-1$ - } - return id; - } - - public String getPluginId() { - return "org.eclipse.jst.j2ee.internal.internal.internal.ui"; //$NON-NLS-1$ - } - }; - - if (!WorkbenchActivityHelper.allowUseOf(null,pluginContribution)) { - return null; - } - - boolean isCreated = selectedNode.isContentCreated(); - IWizard wizard = selectedNode.getWizard(); - if (wizard == null) { - setSelectedNode(null); - return null; - } - if (!isCreated) // Allow the wizard to create its pages - wizard.addPages(); - - return wizard.getStartingPage(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.J2EEWizardPage#validatePage() - */ - protected void validatePage() { - if (!defaultModulesButton.getSelection()) { - setPageComplete(false); - setErrorMessage(null); - } else - super.validatePage(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassOptionsWizardPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassOptionsWizardPage.java deleted file mode 100644 index 35ef53c49..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassOptionsWizardPage.java +++ /dev/null @@ -1,401 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.internal.ui.JavaPluginImages; -import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog; -import org.eclipse.jem.workbench.utility.JemProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.dialogs.TypeSearchEngine; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; - -/** - * @author jialin - * - * To change the template for this generated type comment go to Window - - * Preferences - Java - Code Generation - Code and Comments - */ -public class NewJavaClassOptionsWizardPage extends DataModelWizardPage { - - protected Button publicButton; - protected Button abstractButton; - protected Button finalButton; - protected TableViewer interfaceViewer; - protected Button addButton; - protected Button removeButton; - protected Button inheritButton; - protected Button constructorButton; - protected Button mainMethodButton; - - /** - * @param model - * @param pageName - */ - public NewJavaClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) { - super(model, pageName); - setDescription(pageDesc); - this.setTitle(pageTitle); - setInfopopID(IJ2EEUIContextIds.NEW_JAVA_CLASS_OPTION_WIZARD_P1); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - protected String[] getValidationPropertyNames() { - return new String[]{INewJavaClassDataModelProperties.MODIFIER_ABSTRACT, INewJavaClassDataModelProperties.MODIFIER_FINAL}; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 300; - composite.setLayoutData(data); - - createModifierControls(composite); - createInterfaceControls(composite); - - // Separator label - Label seperator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - seperator.setLayoutData(data); - - createStubsComposite(composite); - - publicButton.setFocus(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID()); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Create controls for the modifiers - */ - protected void createModifierControls(Composite parent) { - Label modifiersLabel = new Label(parent, SWT.NONE); - modifiersLabel.setText(J2EEUIMessages.JAVA_CLASS_MODIFIERS_LABEL); - modifiersLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.makeColumnsEqualWidth = true; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - publicButton = new Button(composite, SWT.CHECK); - publicButton.setText(J2EEUIMessages.JAVA_CLASS_PUBLIC_CHECKBOX_LABEL); - synchHelper.synchCheckbox(publicButton, INewJavaClassDataModelProperties.MODIFIER_PUBLIC, null); - - abstractButton = new Button(composite, SWT.CHECK); - abstractButton.setText(J2EEUIMessages.JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL); - synchHelper.synchCheckbox(abstractButton, INewJavaClassDataModelProperties.MODIFIER_ABSTRACT, null); - - finalButton = new Button(composite, SWT.CHECK); - finalButton.setText(J2EEUIMessages.JAVA_CLASS_FINAL_CHECKBOX_LABEL); - synchHelper.synchCheckbox(finalButton, INewJavaClassDataModelProperties.MODIFIER_FINAL, null); - } - - protected void createInterfaceControls(Composite parent) { - Label interfaceLabel = new Label(parent, SWT.NONE); - interfaceLabel.setText(J2EEUIMessages.JAVA_CLASS_INTERFACES_LABEL); - interfaceLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - interfaceViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI); - interfaceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - interfaceViewer.setContentProvider(getInterfaceContentProvider()); - interfaceViewer.setLabelProvider(getInterfaceLabelProvider()); - interfaceViewer.getControl().addKeyListener(getInterfaceKeyListener()); - interfaceViewer.setInput(model.getProperty(INewJavaClassDataModelProperties.INTERFACES)); - - Composite buttonCompo = new Composite(composite, SWT.NULL); - layout = new GridLayout(); - layout.marginHeight = 0; - buttonCompo.setLayout(layout); - buttonCompo.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING)); - - addButton = new Button(buttonCompo, SWT.PUSH); - addButton.setText(J2EEUIMessages.ADD_BUTTON_LABEL); - addButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - addButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleInterfaceAddButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - - removeButton = new Button(buttonCompo, SWT.PUSH); - removeButton.setText(J2EEUIMessages.REMOVE_BUTTON); - removeButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - removeButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleInterfaceRemoveButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - removeButton.setEnabled(false); - - interfaceViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - removeButton.setEnabled(!selection.isEmpty()); - } - }); - - } - - /** - * Create the composite with all the stubs - */ - protected void createStubsComposite(Composite parent) { - Label stubLabel = new Label(parent, SWT.NONE); - stubLabel.setText(J2EEUIMessages.JAVA_CLASS_METHOD_STUBS_LABEL); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - stubLabel.setLayoutData(data); - - Composite buttonCompo = new Composite(parent, SWT.NULL); - buttonCompo.setLayout(new GridLayout()); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.horizontalIndent = 15; - buttonCompo.setLayoutData(data); - - mainMethodButton = new Button(buttonCompo, SWT.CHECK); - mainMethodButton.setText(J2EEUIMessages.JAVA_CLASS_MAIN_CHECKBOX_LABEL); - synchHelper.synchCheckbox(mainMethodButton, INewJavaClassDataModelProperties.MAIN_METHOD, null); - - inheritButton = new Button(buttonCompo, SWT.CHECK); - inheritButton.setText(J2EEUIMessages.JAVA_CLASS_INHERIT_CHECKBOX_LABEL); - synchHelper.synchCheckbox(inheritButton, INewJavaClassDataModelProperties.ABSTRACT_METHODS, null); - - constructorButton = new Button(buttonCompo, SWT.CHECK); - constructorButton.setText(J2EEUIMessages.JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL); - synchHelper.synchCheckbox(constructorButton, INewJavaClassDataModelProperties.CONSTRUCTOR, null); - } - - protected void enter() { - super.enter(); - //set the intefaces on every page enter (not only on viewer creation) - interfaceViewer.setInput(model.getProperty(INewJavaClassDataModelProperties.INTERFACES)); - } - - /** - * @see IStatefulWizardPage#saveWidgetValues() - */ - // public void saveWidgetValues() { - // // TODO: do we want to do this here or in the concrete subclasses??? - // IDialogSettings store = getDialogSettings(); - // if (store != null) - // store.put(getUniqueKey(""), getUniqueKey("")); //$NON-NLS-1$ - // //$NON-NLS-2$ - // DialogSettingsHelper.saveButton(inheritButton, - // getUniqueKey(idInheritedAbstractButton), store); - // DialogSettingsHelper.saveButton(constructorButton, - // getUniqueKey(idSuperClassConstructorsButton), store); - // DialogSettingsHelper.saveButton(publicButton, - // getUniqueKey(idPublicButton), store); - // DialogSettingsHelper.saveButton(abstractButton, - // getUniqueKey(idAbstractButton), store); - // DialogSettingsHelper.saveButton(finalButton, getUniqueKey(idFinalButton), - // store); - // - // } - /** - * @see IStatefulWizardPage#restoreWidgetValues() - */ - // public void restoreWidgetValues() { - // IDialogSettings store = super.getDialogSettings(); - // if (store != null && store.get(getUniqueKey("")) != null) { //$NON-NLS-1$ - // DialogSettingsHelper.restoreButton(inheritButton, - // getUniqueKey(idInheritedAbstractButton), store); - // DialogSettingsHelper.restoreButton(constructorButton, - // getUniqueKey(idSuperClassConstructorsButton), store); - // DialogSettingsHelper.restoreButton(publicButton, - // getUniqueKey(idPublicButton), store); - // DialogSettingsHelper.restoreButton(abstractButton, - // getUniqueKey(idAbstractButton), store); - // DialogSettingsHelper.restoreButton(finalButton, - // getUniqueKey(idFinalButton), store); - // } - // } - /** - * Returns the Super Interface Content Provider - */ - protected IStructuredContentProvider getInterfaceContentProvider() { - return new IStructuredContentProvider() { - public Object[] getElements(Object inputElement) { - Object[] ret = new Object[0]; - if (inputElement instanceof List) { - ret = ((List) inputElement).toArray(); - } - return ret; - } - public void dispose() { - //Do nothing - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - //Default is nothing - } - }; - } - - /** - * Returns the Super Interface Label Provider - */ - protected ILabelProvider getInterfaceLabelProvider() { - return new ILabelProvider() { - public Image getImage(Object element) { - return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INTERFACE); - } - - public String getText(Object element) { - String ret = J2EEUIMessages.EMPTY_STRING; - if (element instanceof String) - ret = (String) element; - return ret; - } - - public void addListener(ILabelProviderListener listener) { - //Do nothing - } - public void dispose() { - //Do nothing - } - public boolean isLabelProperty(Object element, String property) { - return true; - } - public void removeListener(ILabelProviderListener listener) { - //Do nothing - } - }; - } - - protected KeyListener getInterfaceKeyListener() { - return new KeyListener() { - - public void keyPressed(KeyEvent e) { - } - - public void keyReleased(KeyEvent e) { - if (e.keyCode == SWT.DEL) { - handleInterfaceRemoveButtonSelected(); - } - } - - }; - } - - /** - * Browse for a new Super Interface Class - */ - protected void handleInterfaceAddButtonSelected() { - IProject project = (IProject) model.getProperty(INewJavaClassDataModelProperties.PROJECT); - IRunnableContext context = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - IJavaProject javaProject = JemProjectUtilities.getJavaProject(project); - // this eliminates the non-exported classpath entries - final IJavaSearchScope scope = TypeSearchEngine.createJavaSearchScopeForAProject(javaProject, true, true); - FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(getShell(),false, context, scope,IJavaSearchConstants.INTERFACE); - dialog.setTitle(J2EEUIMessages.INTERFACE_SELECTION_DIALOG_TITLE); - if (dialog.open() == Window.OK) { - IType type = (IType) dialog.getFirstResult(); - String newInterface = ""; //$NON-NLS-1$ - if (type != null) { - newInterface = type.getFullyQualifiedName(); - List valueList = getInterfaceViewerItems(); - if (!valueList.contains(newInterface)) { - interfaceViewer.add(newInterface); - model.setProperty(INewJavaClassDataModelProperties.INTERFACES, getInterfaceViewerItems()); - } - } - } - } - - /** - * Remove an interface from the SuperInterface List - */ - protected void handleInterfaceRemoveButtonSelected() { - IStructuredSelection selection = (IStructuredSelection) interfaceViewer.getSelection(); - List items = selection.toList(); - if (!items.isEmpty()) { - List valueList = getInterfaceViewerItems(); - for (int i = 0; i < items.size(); i++) { - valueList.remove(items.get(i)); - } - interfaceViewer.setInput(valueList); - model.setProperty(INewJavaClassDataModelProperties.INTERFACES, valueList); - } - } - - private List getInterfaceViewerItems() { - ArrayList<String> list = new ArrayList<String>(); - TableItem[] items = interfaceViewer.getTable().getItems(); - for (TableItem item : items) { - list.add(item.getText()); - } - return list; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassWizardPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassWizardPage.java deleted file mode 100644 index e190ac750..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/NewJavaClassWizardPage.java +++ /dev/null @@ -1,700 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ - -package org.eclipse.jst.j2ee.internal.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -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.IStatus; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -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.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.IJavaSearchScope; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog; -import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.dialogs.TypeSearchEngine; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * - */ -public class NewJavaClassWizardPage extends DataModelWizardPage { - - private Text folderText; - private Button folderButton; - protected Text packageText; - protected Button packageButton; - protected Label packageLabel; - protected Text classText; - protected Label classLabel; - protected Text superText; - protected Button superButton; - protected Label superLabel; - protected Label projectNameLabel; - private Combo projectNameCombo; - protected String projectType; - private String projectName; - - /** - * @param model - * @param pageName - */ - public NewJavaClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, - String moduleType) { - super(model, pageName); - setDescription(pageDesc); - this.setTitle(pageTitle); - setPageComplete(false); - this.projectType = moduleType; - this.projectName = null; - } - - /** - * - */ - protected String[] getValidationPropertyNames() { - return new String[]{IArtifactEditOperationDataModelProperties.PROJECT_NAME, - IArtifactEditOperationDataModelProperties.COMPONENT_NAME, - INewJavaClassDataModelProperties.SOURCE_FOLDER, - INewJavaClassDataModelProperties.JAVA_PACKAGE, - INewJavaClassDataModelProperties.CLASS_NAME, - INewJavaClassDataModelProperties.SUPERCLASS}; - } - - /** - * - */ - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - composite.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - composite.setLayoutData(data); - - addProjectNameGroup(composite); - addFolderGroup(composite); - addSeperator(composite, 3); - addPackageGroup(composite); - addClassnameGroup(composite); - addSuperclassGroup(composite); - - classText.setFocus(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID()); - Dialog.applyDialogFont(parent); - return composite; - } - - /** - * Add project group - */ - private void addProjectNameGroup(Composite parent) { - // set up project name label - projectNameLabel = new Label(parent, SWT.NONE); - projectNameLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.MODULES_DEPENDENCY_PAGE_TABLE_PROJECT)); //$NON-NLS-1$ - GridData data = new GridData(); - projectNameLabel.setLayoutData(data); - // set up project name entry field - projectNameCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 300; - data.horizontalSpan = 1; - projectNameCombo.setLayoutData(data); - projectNameCombo.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - IProject project = ProjectUtilities.getProject(projectNameCombo.getText()); - validateProjectRequirements(project); - } - }); - synchHelper.synchCombo(projectNameCombo, IArtifactEditOperationDataModelProperties.PROJECT_NAME, null); - initializeProjectList(); - new Label(parent, SWT.NONE); - } - - /** - * - **/ - private IFolder getDefaultJavaSourceFolder(IProject project) { - - 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; - } - - /** - * This method is used by the project list initializer. The method checks - * if the specified project is valid to include it in the project list. - * - * <p>Subclasses of this wizard page should override this method to - * adjust filtering of the projects to their needs. </p> - * - * @param project reference to the project to be checked - * - * @return <code>true</code> if the project is valid to be included in - * the project list, <code>false</code> - otherwise. - */ - protected boolean isProjectValid(IProject project) { - boolean result; - try { - result = project.isAccessible() && - project.hasNature(IModuleConstants.MODULE_NATURE_ID) && - J2EEProjectUtilities.getJ2EEProjectType(project).equals(projectType); - } catch (CoreException ce) { - result = false; - } - return result; - } - - /** - * - */ - private void initializeProjectList() { - IProject[] workspaceProjects = ProjectUtilities.getAllProjects(); - List items = new ArrayList(); - for (int i = 0; i < workspaceProjects.length; i++) { - IProject project = workspaceProjects[i]; - if (isProjectValid(project)) - items.add(project.getName()); - } - if (items.isEmpty()) return; - String[] names = new String[items.size()]; - for (int i = 0; i < items.size(); i++) { - names[i] = (String) items.get(i); - } - projectNameCombo.setItems(names); - IProject selectedProject = null; - try { - if (model !=null) { - String projectNameFromModel = model.getStringProperty(IArtifactEditOperationDataModelProperties.COMPONENT_NAME); - if (projectNameFromModel!=null && projectNameFromModel.length()>0) - selectedProject = ProjectUtilities.getProject(projectNameFromModel); - } - } catch (Exception e) {}; - try { - if (selectedProject == null) - selectedProject = getSelectedProject(); - if (selectedProject != null && selectedProject.isAccessible() - && selectedProject.hasNature(IModuleConstants.MODULE_NATURE_ID)) { - projectNameCombo.setText(selectedProject.getName()); - validateProjectRequirements(selectedProject); - model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME, selectedProject.getName()); - } - } catch (CoreException ce) { - // Ignore - } - if (projectName == null && names.length > 0) - projectName = names[0]; - - if ((projectNameCombo.getText() == null || projectNameCombo.getText().length() == 0) && projectName != null) { - projectNameCombo.setText(projectName); - validateProjectRequirements(ProjectUtilities.getProject(projectName)); - model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME, projectName); - } - - } - - /** - * Add folder group to composite - */ - private void addFolderGroup(Composite composite) { - // folder - Label folderLabel = new Label(composite, SWT.LEFT); - folderLabel.setText(J2EEUIMessages.FOLDER_LABEL); - folderLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - folderText = new Text(composite, SWT.SINGLE | SWT.BORDER); - folderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(folderText, INewJavaClassDataModelProperties.SOURCE_FOLDER, null); - - IPackageFragmentRoot root = getSelectedPackageFragmentRoot(); - String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - if (projectName != null && projectName.length() > 0) { - IProject targetProject = ProjectUtilities.getProject(projectName); - if (root == null || !root.getJavaProject().getProject().equals(targetProject)) { - IFolder folder = getDefaultJavaSourceFolder(targetProject); - if (folder != null) - folderText.setText(folder.getFullPath().toOSString()); - } else { - folderText.setText(root.getPath().toString()); - } - } - - folderButton = new Button(composite, SWT.PUSH); - folderButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL); - folderButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - folderButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handleFolderButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - }); - } - - /** - * Add package group to composite - */ - private void addPackageGroup(Composite composite) { - // package - packageLabel = new Label(composite, SWT.LEFT); - packageLabel.setText(J2EEUIMessages.JAVA_PACKAGE_LABEL); - packageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - packageText = new Text(composite, SWT.SINGLE | SWT.BORDER); - packageText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(packageText, INewJavaClassDataModelProperties.JAVA_PACKAGE, null); - - IPackageFragment packageFragment = getSelectedPackageFragment(); - String targetProject = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - if (packageFragment != null && packageFragment.exists() && - packageFragment.getJavaProject().getElementName().equals(targetProject)) { - IPackageFragmentRoot root = getPackageFragmentRoot(packageFragment); - if (root != null) - folderText.setText(root.getPath().toString()); - model.setProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE, packageFragment.getElementName()); - } - - packageButton = new Button(composite, SWT.PUSH); - packageButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL); - packageButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - packageButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handlePackageButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - }); - } - - protected IPackageFragmentRoot getPackageFragmentRoot(IPackageFragment packageFragment) { - if (packageFragment == null) - return null; - else if (packageFragment.getParent() instanceof IPackageFragment) - return getPackageFragmentRoot((IPackageFragment) packageFragment.getParent()); - else if (packageFragment.getParent() instanceof IPackageFragmentRoot) - return (IPackageFragmentRoot) packageFragment.getParent(); - else - return null; - } - - /** - * Add classname group to composite - */ - private void addClassnameGroup(Composite composite) { - // class name - classLabel = new Label(composite, SWT.LEFT); - classLabel.setText(J2EEUIMessages.CLASS_NAME_LABEL); - classLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - classText = new Text(composite, SWT.SINGLE | SWT.BORDER); - classText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(classText, INewJavaClassDataModelProperties.CLASS_NAME, null); - - new Label(composite, SWT.LEFT); - } - - /** - * Add seperator to composite - */ - protected void addSeperator(Composite composite, int horSpan) { - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - // Separator label - Label seperator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = horSpan; - seperator.setLayoutData(data); - } - - /** - * Add superclass group to the composite - */ - private void addSuperclassGroup(Composite composite) { - // superclass - superLabel = new Label(composite, SWT.LEFT); - superLabel.setText(J2EEUIMessages.SUPERCLASS_LABEL); - superLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - superText = new Text(composite, SWT.SINGLE | SWT.BORDER); - superText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(superText, INewJavaClassDataModelProperties.SUPERCLASS, null); - - superButton = new Button(composite, SWT.PUSH); - superButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL); - superButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - superButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handleSuperButtonPressed(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - }); - } - - /** - * Browse for a new Destination Folder - */ - protected void handleFolderButtonPressed() { - ISelectionStatusValidator validator = getContainerDialogSelectionValidator(); - ViewerFilter filter = getContainerDialogViewerFilter(); - ITreeContentProvider contentProvider = new WorkbenchContentProvider(); - ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench() - .getDecoratorManager().getLabelDecorator()); - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider); - dialog.setValidator(validator); - dialog.setTitle(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_TITLE); - dialog.setMessage(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_DESC); - dialog.addFilter(filter); - String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME); - if (projectName==null || projectName.length()==0) - return; - IProject project = ProjectUtilities.getProject(projectName); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - - if (project != null) - dialog.setInitialSelection(project); - if (dialog.open() == Window.OK) { - Object element = dialog.getFirstResult(); - try { - if (element instanceof IContainer) { - IContainer container = (IContainer) element; - folderText.setText(container.getFullPath().toString()); - // dealWithSelectedContainerResource(container); - } - } catch (Exception ex) { - // Do nothing - } - - } - } - - protected void handlePackageButtonPressed() { - IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); - if (packRoot == null) - return; - IJavaElement[] packages = null; - try { - packages = packRoot.getChildren(); - } catch (JavaModelException e) { - // Do nothing - } - if (packages == null) - packages = new IJavaElement[0]; - - ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider( - JavaElementLabelProvider.SHOW_DEFAULT)); - dialog.setTitle(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_TITLE); - dialog.setMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_DESC); - dialog.setEmptyListMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_MSG_NONE); - dialog.setElements(packages); - if (dialog.open() == Window.OK) { - IPackageFragment fragment = (IPackageFragment) dialog.getFirstResult(); - if (fragment != null) { - packageText.setText(fragment.getElementName()); - } else { - packageText.setText(J2EEUIMessages.EMPTY_STRING); - } - } - } - - protected void handleSuperButtonPressed() { - getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); - if (packRoot == null) - return; - - // this eliminates the non-exported classpath entries - final IJavaSearchScope scope = TypeSearchEngine.createJavaSearchScopeForAProject(packRoot.getJavaProject(), true, true); - - // This includes all entries on the classpath. This behavior is - // identical - // to the Super Class Browse Button on the Create new Java Class Wizard - // final IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new - // IJavaElement[] {root.getJavaProject()} ); - FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(getShell(),false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS); - dialog.setTitle(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE); - dialog.setMessage(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC); - - if (dialog.open() == Window.OK) { - IType type = (IType) dialog.getFirstResult(); - String superclassFullPath = J2EEUIMessages.EMPTY_STRING; - if (type != null) { - superclassFullPath = type.getFullyQualifiedName(); - } - superText.setText(superclassFullPath); - getControl().setCursor(null); - return; - } - getControl().setCursor(null); - } - - /** - * Returns a new instance of the Selection validator for the Container - * Selection Dialog This method can be extended by subclasses, as it does - * some basic validation. - */ - protected ISelectionStatusValidator getContainerDialogSelectionValidator() { - return new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if (selection != null && selection[0] != null && !(selection[0] instanceof IProject)) - return WTPCommonPlugin.OK_STATUS; - return WTPCommonPlugin.createErrorStatus(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG); - } - }; - } - - /** - * Returns a new instance of the Selection Listner for the Container - * Selection Dialog - */ - protected ViewerFilter getContainerDialogViewerFilter() { - return new ViewerFilter() { - public boolean select(Viewer viewer, Object parent, Object element) { - if (element instanceof IProject) { - IProject project = (IProject) element; - return project.getName().equals(model.getProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME)); - } else if (element instanceof IFolder) { - IFolder folder = (IFolder) element; - // only show source folders - IProject project = ProjectUtilities.getProject(model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME)); - IPackageFragmentRoot[] sourceFolders = J2EEProjectUtilities.getSourceContainers(project); - for (int i = 0; i < sourceFolders.length; i++) { - if (sourceFolders[i].getResource()!= null && sourceFolders[i].getResource().equals(folder)) - return true; - } - } - return false; - } - }; - } - - - - /** - * @return - */ - private IProject getSelectedProject() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - ISelection selection = window.getSelectionService().getSelection(); - if (selection == null) - return null; - if (!(selection instanceof IStructuredSelection)) - return null; - IStructuredSelection stucturedSelection = (IStructuredSelection) selection; - if (stucturedSelection.getFirstElement() instanceof EObject) - return ProjectUtilities.getProject(stucturedSelection.getFirstElement()); - IJavaElement element = getInitialJavaElement(selection); - if (element != null && element.getJavaProject() != null) - return element.getJavaProject().getProject(); - return getExtendedSelectedProject(stucturedSelection.getFirstElement()); - } - - protected IProject getExtendedSelectedProject(Object selection) { - return null; - } - - /** - * @return - */ - private IPackageFragment getSelectedPackageFragment() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - ISelection selection = window.getSelectionService().getSelection(); - if (selection == null) - return null; - IJavaElement element = getInitialJavaElement(selection); - if (element != null) { - if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { - return (IPackageFragment) element; - } else if (element.getElementType() == IJavaElement.COMPILATION_UNIT) { - IJavaElement parent = ((ICompilationUnit) element).getParent(); - if (parent.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { - return (IPackageFragment) parent; - } - } else if (element.getElementType() == IJavaElement.TYPE) { - return ((IType) element).getPackageFragment(); - } - } - return null; - } - - private IPackageFragmentRoot getSelectedPackageFragmentRoot() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - ISelection selection = window.getSelectionService().getSelection(); - if (selection == null) - return null; - // StructuredSelection stucturedSelection = (StructuredSelection) - // selection; - IJavaElement element = getInitialJavaElement(selection); - if (element != null) { - if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT) - return (IPackageFragmentRoot) element; - } - return null; - } - - /** - * Utility method to inspect a selection to find a Java element. - * - * @param selection - * the selection to be inspected - * @return a Java element to be used as the initial selection, or - * <code>null</code>, if no Java element exists in the given - * selection - */ - protected IJavaElement getInitialJavaElement(ISelection selection) { - IJavaElement jelem = null; - if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { - Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); - if (selectedElement instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) selectedElement; - - jelem = (IJavaElement) adaptable.getAdapter(IJavaElement.class); - if (jelem == null) { - IResource resource = (IResource) adaptable.getAdapter(IResource.class); - if (resource != null && resource.getType() != IResource.ROOT) { - while (jelem == null && resource.getType() != IResource.PROJECT) { - resource = resource.getParent(); - jelem = (IJavaElement) resource.getAdapter(IJavaElement.class); - } - if (jelem == null) { - jelem = JavaCore.create(resource); // java project - } - } - } - } - } - if (jelem == null) { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - IWorkbenchPart part = window.getActivePage().getActivePart(); - if (part instanceof ContentOutline) { - part = window.getActivePage().getActiveEditor(); - } - - if (part instanceof IViewPartInputProvider) { - Object elem = ((IViewPartInputProvider) part).getViewPartInput(); - if (elem instanceof IJavaElement) { - jelem = (IJavaElement) elem; - } - } - } - - if (jelem == null || jelem.getElementType() == IJavaElement.JAVA_MODEL) { - try { - IJavaProject[] projects = JavaCore.create(getWorkspaceRoot()).getJavaProjects(); - if (projects.length == 1) { - jelem = projects[0]; - } - } catch (JavaModelException e) { - JavaPlugin.log(e); - } - } - return jelem; - } - - protected IWorkspaceRoot getWorkspaceRoot() { - return ResourcesPlugin.getWorkspace().getRoot(); - } - - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - protected void validateProjectRequirements(IProject project) - { - // nothing to do in most cases - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/PackageNameResolver.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/PackageNameResolver.java deleted file mode 100644 index 46ec179fc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/PackageNameResolver.java +++ /dev/null @@ -1,70 +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.wizard; - -import java.io.File; -import java.io.FileInputStream; - -/** - * @author Sachin - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class PackageNameResolver extends ClassLoader { - - public PackageNameResolver() { - super(); - } - - public String getClassName(final String classFile) { - File file = new File(classFile); - byte[] classbuf = new byte[(int) file.length()]; - try { - FileInputStream instream = new FileInputStream(file); - instream.read(classbuf); - instream.close(); - } catch (Throwable e) { - return null; - } - boolean badclassname = true; - String classname = classFile.replace(java.io.File.separatorChar, '.'); - int endi; - if (classname.endsWith(".class")) //$NON-NLS-1$ - endi = classname.lastIndexOf('.'); - else - endi = classname.length(); - int i = classname.indexOf('.'); - while (i < endi && badclassname == true) { - badclassname = false; - try { - defineClass(classname.substring(i + 1, endi), classbuf, 0, classbuf.length); - } catch (java.lang.NoClassDefFoundError e) { - String msg = e.getMessage(); - if (msg == null || msg.indexOf(' ') > 0) { - badclassname = true; - } - } catch (Throwable e) { - badclassname = true; - } - if (badclassname) { - i = classname.indexOf('.', i + 1); - if (i == -1) - i = endi; - } - } - if (badclassname) - return null; - return classname.substring(i + 1, endi); - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetComboHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetComboHelper.java deleted file mode 100644 index d0e6af58a..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetComboHelper.java +++ /dev/null @@ -1,76 +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 Aug 27, 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.wizard; - -import java.util.List; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.internal.ResourceManager; - - -public class ServerTargetComboHelper { - private List targets; - public String[] items; - public static final String defaultId = "com.ibm.etools.websphere.serverTarget.base.v51"; //$NON-NLS-1$ - public static final String defaultExpressId = "com.ibm.etools.websphere.serverTarget.express.v51"; //$NON-NLS-1$ - - ServerTargetComboHelper(List targets, String[] items) { - this.targets = targets; - this.items = items; - } - - public IRuntime getSelectedTarget(int itemIndex) { - return (IRuntime) targets.get(itemIndex); - } - - /** - * @param target - * @return - */ - public boolean isCompatible(IRuntime target) { - return targets.contains(target); - } - - public int getDefaultServerTargetIndex() { - IRuntime v51TargetServer = null; - if (J2EEPlugin.isEJBSupportAvailable()) - v51TargetServer = ResourceManager.getInstance().getRuntime(defaultId); - else - v51TargetServer = ResourceManager.getInstance().getRuntime(defaultExpressId); - if (v51TargetServer != null && targets.contains(v51TargetServer)) - return targets.indexOf(v51TargetServer) + 1; - return -1; - } - - public int getServerTargetIndexFromItems(IRuntime serverTarget) { - if (items != null && items.length > 0) { - String serverTargetLabel = serverTarget.getName() + " (" + serverTarget.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - for (int i = 0; i < items.length; i++) { - String label = items[i]; - if (label.equals(serverTargetLabel)) { - return i; - } - } - } - return -1; - } - - public List getValidTargets() { - return targets; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetUIHelper.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetUIHelper.java deleted file mode 100644 index bef30d4d1..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/ServerTargetUIHelper.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 Aug 17, 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.wizard; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerUtil; - -/** - * @author vijayb - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class ServerTargetUIHelper { - /** - * - */ - public ServerTargetUIHelper() { - super(); - } - - public static String getSelectedServerTargetString(Combo serverTargetCombo) { - if (serverTargetCombo.getSelectionIndex() != -1) - return serverTargetCombo.getItem(serverTargetCombo.getSelectionIndex()); - return null; - } - - /** - * @return - */ - public static int getSelectedServerTargetStringIndex(Combo serverTargetCombo) { - return serverTargetCombo.getSelectionIndex(); - } - -// private static void setServerTargetForProject(Shell shell, IProject project, IRuntime runtime) { -// //ServerTargetHelper.cleanUpNonServerTargetClasspath(project); -// setServerTarget(shell, project, runtime, null); -// } - - /** - * @param earProject - * @param moduleProject - * @return - */ - public static boolean setModuleServerTargetIfNecessary(IProject earProject, IProject moduleProject, Shell shell) { - return true; - } - - // private static String getEARJ2EELevel(IProject earProject) { - // EARNatureRuntime nature = EARNatureRuntime.getRuntime(earProject); - // String j2eeLevel = null; - // int natureID = nature.getJ2EEVersion(); - // switch (natureID) { - // case (J2EEVersionConstants.J2EE_1_2_ID) : - // j2eeLevel = J2EEVersionConstants.VERSION_1_2_TEXT; - // break; - // case (J2EEVersionConstants.J2EE_1_3_ID) : - // j2eeLevel = J2EEVersionConstants.VERSION_1_3_TEXT; - // break; - // case (J2EEVersionConstants.J2EE_1_4_ID) : - // j2eeLevel = J2EEVersionConstants.VERSION_1_4_TEXT; - // break; - // default : - // j2eeLevel = J2EEVersionConstants.VERSION_1_4_TEXT; - // break; - // } - // return j2eeLevel; - // } - - public static void setServerTarget(Shell shell, IProject project, IRuntime runtime, IProgressMonitor monitor) { -// try { -// ServerCore.getProjectProperties(project).setRuntimeTarget(runtime, monitor); -// } catch (CoreException e) { -// Logger.getLogger().logError(e); -// } - } - - - public static ServerTargetComboHelper getValidServerTargetComboItems(String j2eeType, String selectedVersion) { - IRuntime[] validServerTargets = ServerUtil.getRuntimes(j2eeType, selectedVersion); - String[] serverTargetList = null; - if (validServerTargets.length>0) { - int serverTargetListSize = validServerTargets.length; - serverTargetList = new String[serverTargetListSize]; - for (int i = 0; i < validServerTargets.length; i++) { - IRuntime runtime = validServerTargets[i]; - serverTargetList[i] = runtime.getName() + " (" + runtime.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return new ServerTargetComboHelper(Arrays.asList(validServerTargets), serverTargetList); - } - - /** - * @param project - */ - public static void runEarValidation(IProject project) { - try { - IRunnableWithProgress runnable = EARValidationHelper.createValidationRunnable(project); - runnable.run(null); - } catch (InterruptedException ie) { - Logger.getLogger().logError(ie); - } catch (InvocationTargetException ite) { - Logger.getLogger().logError(ite); - } - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/StringArrayTableWizardSection.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/StringArrayTableWizardSection.java deleted file mode 100644 index 6e9882621..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/StringArrayTableWizardSection.java +++ /dev/null @@ -1,543 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.jst.j2ee.internal.wizard; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * @author jialin - * - * To change the template for this generated type comment go to Window - - * Preferences - Java - Code Generation - Code and Comments - */ -public class StringArrayTableWizardSection extends Composite { - - protected class StringArrayListContentProvider implements IStructuredContentProvider { - public boolean isDeleted(Object element) { - return false; - } - public Object[] getElements(Object element) { - if (element instanceof List) { - return ((List) element).toArray(); - } - return new Object[0]; - } - public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) { - //Default nothing - } - public void dispose() { - //Default nothing - } - } - - protected class StringArrayListLabelProvider extends LabelProvider implements ITableLabelProvider { - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - return labelProviderImage; - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - String[] array = (String[]) element; - return array[columnIndex]; - } - - @Override - public Image getImage(Object element) { - return labelProviderImage; - } - - @Override - public String getText(Object element) { - String[] array = (String[]) element; - if (array.length > 0) { - return array[0]; - } else { - return super.getText(element); - } - } - } - - protected class AddStringArrayDialog extends Dialog implements ModifyListener { - protected String windowTitle; - protected String[] labelsForTextField; - protected Text[] texts; - protected String[] stringArray; - /** - * CMPFieldDialog constructor comment. - */ - public AddStringArrayDialog(Shell shell, String windowTitle, String[] labelsForTextField) { - super(shell); - this.windowTitle = windowTitle; - this.labelsForTextField = labelsForTextField; - } - /** - * CMPFieldDialog constructor comment. - */ - public Control createDialogArea(Composite parent) { - - Composite composite = (Composite) super.createDialogArea(parent); - getShell().setText(windowTitle); - - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - data.widthHint = 300; - composite.setLayoutData(data); - - int n = labelsForTextField.length; - texts = new Text[n]; - for (int i = 0; i < n; i++) { - Label label = new Label(composite, SWT.LEFT); - label.setText(labelsForTextField[i]); - label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - texts[i] = new Text(composite, SWT.SINGLE | SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 100; - texts[i].setLayoutData(data); - } - - // set focus - texts[0].setFocus(); - Dialog.applyDialogFont(parent); - return composite; - } - - protected Control createContents(Composite parent) { - Composite composite = (Composite) super.createContents(parent); - - for (int i = 0; i < texts.length; i++) { - texts[i].addModifyListener(this); - } - - updateOKButton(); - - return composite; - } - - protected void okPressed() { - stringArray = callback.retrieveResultStrings(texts); - super.okPressed(); - } - - public String[] getStringArray() { - return stringArray; - } - - public void modifyText(ModifyEvent e) { - updateOKButton(); - } - - private void updateOKButton() { - getButton(IDialogConstants.OK_ID).setEnabled(callback.validate(texts)); - } - } - - protected class EditStringArrayDialog extends AddStringArrayDialog { - protected String[] valuesForTextField; - /** - * CMPFieldDialog constructor comment. - */ - public EditStringArrayDialog(Shell shell, String windowTitle, String[] labelsForTextField, String[] valuesForTextField) { - super(shell, windowTitle, labelsForTextField); - this.valuesForTextField = valuesForTextField; - } - /** - * CMPFieldDialog constructor comment. - */ - public Control createDialogArea(Composite parent) { - - Composite composite = (Composite) super.createDialogArea(parent); - - int n = valuesForTextField.length; - for (int i = 0; i < n; i++) { - texts[i].setText(valuesForTextField[i]); - } - - return composite; - } - } - - /** - * Callback interface used by the Add/Edit-StringArrayDialog classes. - */ - public interface StringArrayDialogCallback { - - /** - * Validates the text fields. - * <p>Used to decide wheather to enable the OK button of the dialog. - * If the method returns <code>true</code> the OK button is enabled, - * otherwise the OK button is disabled.</p> - * - * @param reference to the text fields in the dialog - * - * @return <code>true</code> if the values in the text fields are - * valid, <code>false</code> otherwise. - */ - public boolean validate(Text[] texts); - - /** - * Retrieves the strings from the text fields of the dialog. - * <p>Implementers of the callback can use these method to do some - * preprocessing (like trimming) of the data in the text fields before - * using it. The returned values will be the actual data that will be - * put in the table viewer.</p> - * - * @param texts reference to the text fields in the dialog - * - * @return the values retreived from the text fields - */ - public String[] retrieveResultStrings(Text[] texts); - - } - - /** - * Default adapter with basic implementation of the - * <code>StringArrayDialogCallback</code> interface. - */ - protected class StringArrayDialogCallbackAdapter implements StringArrayDialogCallback { - - /** - * Returns always <code>true</code>. - */ - public boolean validate(Text[] texts) { - return true; - } - - /** - * Just retreives the unmodified values of the text fields as a - * string array. - */ - public String[] retrieveResultStrings(Text[] texts) { - int n = texts.length; - String[] result = new String[n]; - for (int i = 0; i < n; i++) { - result[i] = texts[i].getText(); - } - return result; - } - - } - - private TableViewer viewer; - private Button addButton; - private Button editButton; - private Button removeButton; - private String dialogTitle; - private String[] fieldLabels; - private IDataModel model; - private String propertyName; - private Image labelProviderImage; - private StringArrayDialogCallback callback; - - public StringArrayTableWizardSection(Composite parent, String title, String addButtonLabel, String removeButtonLabel, - String[] labelsForText, Image labelProviderImage, IDataModel model, String propertyName) { - this(parent, title, addButtonLabel, null, removeButtonLabel, labelsForText, labelProviderImage, model, propertyName); - } - - public StringArrayTableWizardSection(Composite parent, String title, String addButtonLabel, String editButtonLabel, String removeButtonLabel, - String[] labelsForText, Image labelProviderImage, IDataModel model, String propertyName) { - this(parent, title, title, addButtonLabel, editButtonLabel, removeButtonLabel, labelsForText, labelsForText, labelProviderImage, model, propertyName); - } - - public StringArrayTableWizardSection(Composite parent, String componentLabel, String dialogTitle, String addButtonLabel, String editButtonLabel, String removeButtonLabel, - String[] columnTitles, String[] fieldLabels, Image labelProviderImage, IDataModel model, String propertyName) { - super(parent, SWT.NONE); - this.dialogTitle = dialogTitle; - this.fieldLabels = fieldLabels; - this.labelProviderImage = labelProviderImage; - this.model = model; - this.propertyName = propertyName; - - GridLayout layout = new GridLayout(2, false); - layout.marginHeight = 4; - layout.marginWidth = 0; - this.setLayout(layout); - this.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label titleLabel = new Label(this, SWT.LEFT); - titleLabel.setText(componentLabel); - GridData data = new GridData(); - data.horizontalSpan = 2; - titleLabel.setLayoutData(data); - - Table table = new Table(this, SWT.FULL_SELECTION | SWT.BORDER); - viewer = new TableViewer(table); - table.setLayoutData(new GridData(GridData.FILL_BOTH)); - viewer.setContentProvider(new StringArrayListContentProvider()); - viewer.setLabelProvider(new StringArrayListLabelProvider()); - - final Composite buttonCompo = new Composite(this, SWT.NULL); - layout = new GridLayout(); - layout.marginHeight = 0; - buttonCompo.setLayout(layout); - buttonCompo.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING)); - - addButton = new Button(buttonCompo, SWT.PUSH); - addButton.setText(addButtonLabel); - addButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - addButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleAddButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - - if (editButtonLabel != null) { - editButton = new Button(buttonCompo, SWT.PUSH); - editButton.setText(editButtonLabel); - editButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - editButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleEditButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - editButton.setEnabled(false); - } - - removeButton = new Button(buttonCompo, SWT.PUSH); - removeButton.setText(removeButtonLabel); - removeButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - removeButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - handleRemoveButtonSelected(); - } - public void widgetDefaultSelected(SelectionEvent event) { - //Do nothing - } - }); - removeButton.setEnabled(false); - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - if (editButton != null) { - boolean enabled = ((IStructuredSelection) selection).size() == 1; - editButton.setEnabled(enabled); - } - removeButton.setEnabled(!selection.isEmpty()); - } - }); - - if (editButton != null) { - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - handleEditButtonSelected(); - } - }); - } - - if (columnTitles.length > 1) { - for (int i = 0; i < columnTitles.length; i++) { - TableColumn tableColumn = new TableColumn(table, SWT.NONE); - tableColumn.setText(columnTitles[i]); - } - table.setHeaderVisible(true); - this.addControlListener(new ControlAdapter() { - public void controlResized(ControlEvent e) { - Table table = viewer.getTable(); - TableColumn[] columns = table.getColumns(); - Point buttonArea = buttonCompo.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle area = table.getParent().getClientArea(); - Point preferredSize = viewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT); - int width = area.width - 2 * table.getBorderWidth() - buttonArea.x - columns.length * 2; - if (preferredSize.y > area.height + table.getHeaderHeight()) { - // Subtract the scrollbar width from the total column width - // if a vertical scrollbar will be required - Point vBarSize = table.getVerticalBar().getSize(); - width -= vBarSize.x; - } - Point oldSize = table.getSize(); - int consumeWidth = 0; - for (int i = 0; i < columns.length; i++) { - if (oldSize.x > area.width) { - // table is getting smaller so make the columns - // smaller first and then resize the table to - // match the client area width - consumeWidth = setColumntWidth(width, columns, consumeWidth, i); - table.setSize(area.width - buttonArea.x - columns.length * 2, area.height); - } else { - // table is getting bigger so make the table - // bigger first and then make the columns wider - // to match the client area width - table.setSize(area.width - buttonArea.x - columns.length * 2, area.height); - consumeWidth = setColumntWidth(width, columns, consumeWidth, i); - } - } - } - - private int setColumntWidth(int width, TableColumn[] columns, int consumeWidth, int i) { - if (i < columns.length - 1) { - columns[i].setWidth(width / columns.length); - consumeWidth += columns[i].getWidth(); - } else { - columns[i].setWidth(width - consumeWidth); - } - return consumeWidth; - } - }); - } - - callback = new StringArrayDialogCallbackAdapter(); - } - - private void handleAddButtonSelected() { - AddStringArrayDialog dialog = new AddStringArrayDialog(getShell(), dialogTitle, fieldLabels); - dialog.open(); - String[] stringArray = dialog.getStringArray(); - addStringArray(stringArray); - } - - private void handleEditButtonSelected() { - ISelection s = viewer.getSelection(); - if (!(s instanceof IStructuredSelection)) - return; - IStructuredSelection selection = (IStructuredSelection) s; - if (selection.size() != 1) - return; - - Object selectedObj = selection.getFirstElement(); - String[] valuesForText = (String[]) selectedObj; - - EditStringArrayDialog dialog = new EditStringArrayDialog(getShell(), dialogTitle, fieldLabels, valuesForText); - dialog.open(); - String[] stringArray = dialog.getStringArray(); - editStringArray(valuesForText, stringArray); - } - - private void handleRemoveButtonSelected() { - ISelection selection = viewer.getSelection(); - if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) - return; - List selectedObj = ((IStructuredSelection) selection).toList(); - removeStringArrays(selectedObj); - } - - public void addStringArray(String[] stringArray) { - if (stringArray == null) - return; - List valueList = (List) viewer.getInput(); - if (valueList == null) - valueList = new ArrayList(); - valueList.add(stringArray); - setInput(valueList); - } - - public void editStringArray(String[] oldStringArray, String[] newStringArray) { - if (newStringArray == null) - return; - - List valueList = (List) viewer.getInput(); - if (valueList == null) - valueList = new ArrayList(); - - int index = valueList.indexOf(oldStringArray); - if (index == -1) { - valueList.add(newStringArray); - } else { - valueList.set(index, newStringArray); - } - - setInput(valueList); - } - - public void removeStringArray(Object selectedStringArray) { - List valueList = (List) viewer.getInput(); - valueList.remove(selectedStringArray); - setInput(valueList); - } - - public void removeStringArrays(Collection selectedStringArrays) { - List valueList = (List) viewer.getInput(); - valueList.removeAll(selectedStringArrays); - setInput(valueList); - } - - public void setInput(List input) { - viewer.setInput(input); - // Create a new list to trigger property change - List newInput = new ArrayList(); - newInput.addAll(input); - model.setProperty(propertyName, newInput); - } - - public TableViewer getTableViewer() { - return viewer; - } - - public Button getAddButton() { - return addButton; - } - - public Button getEditButton() { - return editButton; - } - - public Button getRemoveButton() { - return removeButton; - } - - /** - * Set callback for customizing the preprocessing of the user input. - * - * @param callback an implementation of the callback interface. - */ - public void setCallback(StringArrayDialogCallback callback) { - this.callback = callback; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/TableObjects.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/TableObjects.java deleted file mode 100644 index c480d0bd4..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/TableObjects.java +++ /dev/null @@ -1,42 +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.wizard; - - -import java.util.ArrayList; -import java.util.List; - -/** - * Insert the type's description here. Creation date: (3/19/2001 5:10:14 PM) - * - * @author: Administrator - */ -public class TableObjects { - public List tableObjectsList; - - /** - * EJBs constructor comment. - */ - public TableObjects() { - super(); - tableObjectsList = new ArrayList(); - } - - public List getTableObjects() { - return tableObjectsList; - } - - protected void initList() { - if (tableObjectsList == null) - tableObjectsList = new ArrayList(); - - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportMainPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportMainPage.java deleted file mode 100644 index 235f0130b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportMainPage.java +++ /dev/null @@ -1,135 +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 May 1, 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.wizard; - -import java.util.List; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; - - -/** - * @author Sachin - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class WizardClassesImportMainPage extends WizardPage { - Composite composite; - - protected Button importFromDir; - protected Button importFromZip; - - private List dragAndDropFileNames = null; - - /** - * @param pageName - */ - public WizardClassesImportMainPage(String pageName) { - super(pageName); - setTitle(J2EEUIMessages.getResourceString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$ - setDescription(J2EEUIMessages.getResourceString("FileImport.importFileSystem")); //$NON-NLS-1$ - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$ - } - - public WizardClassesImportMainPage(String pageName, List fileNames) { - super(pageName); - setTitle(J2EEUIMessages.getResourceString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$ - setDescription(J2EEUIMessages.getResourceString("FileImport.importFileSystem")); //$NON-NLS-1$ - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$ - dragAndDropFileNames = fileNames; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.IMPORT_CLASS_WIZARD_P1); - initializeDialogUnits(parent); - Composite aComposite = new Composite(parent, SWT.NULL); - aComposite.setLayout(new GridLayout()); - aComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - aComposite.setSize(aComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - aComposite.setFont(parent.getFont()); - createImportTypeGroup(aComposite); - setControl(aComposite); - } - - protected void createImportTypeGroup(Composite parent) { - Composite importTypeGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - importTypeGroup.setLayout(layout); - importTypeGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - //importTypeGroup.setText(WorkbenchMessages.getString("WizardExportPage.options")); - // //$NON-NLS-1$ - - SelectionListener selectionListener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IWizard wiz = getWizard(); - if (((ClassesImportWizard) wiz).page1 != null) { - ((ClassesImportWizard) wiz).page1.blankPage(); - } - } - }; - importFromDir = new Button(importTypeGroup, SWT.RADIO); - importFromDir.setText(J2EEUIMessages.getResourceString("ClassesImport.fromDir")); //$NON-NLS-1$ - importFromDir.addSelectionListener(selectionListener); - - importFromZip = new Button(importTypeGroup, SWT.RADIO); - importFromZip.setText(J2EEUIMessages.getResourceString("ClassesImport.fromZip")); //$NON-NLS-1$ - importFromZip.addSelectionListener(selectionListener); - - IWizard wiz = getWizard(); - String fileName = null; - if (((ClassesImportWizard) wiz).fileNames != null) - fileName = ((ClassesImportWizard) wiz).fileNames.get(0).toString(); - if (fileName != null && (fileName.endsWith(".zip") || fileName.endsWith(".jar"))) { //$NON-NLS-1$ //$NON-NLS-2$ - importFromDir.setSelection(false); - importFromZip.setSelection(true); - } else { - importFromDir.setSelection(true); - importFromZip.setSelection(false); - } - } - - protected boolean isSetImportFromDir() { - if (importFromDir != null) - return importFromDir.getSelection(); - - String fileName = dragAndDropFileNames.get(0).toString(); - if (fileName != null && (fileName.endsWith(".zip") || fileName.endsWith(".jar"))) { //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - return true; - } -} - - diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportPage1.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportPage1.java deleted file mode 100644 index 5665db17d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/WizardClassesImportPage1.java +++ /dev/null @@ -1,1418 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.wizard; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.jee.archive.internal.ArchiveUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.FileSystemElement; -import org.eclipse.ui.dialogs.WizardResourceImportPage; -import org.eclipse.ui.internal.ide.dialogs.IElementFilter; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; -import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider; -import org.eclipse.ui.wizards.datatransfer.ImportOperation; -import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; - - -/** - * Page 1 of the base resource import-from-file-system Wizard - */ -/* package */ -class WizardClassesImportPage1 extends WizardResourceImportPage implements Listener { - - // widgets - protected Combo sourceNameField; - protected Button overwriteExistingResourcesCheckbox; - protected Button createContainerStructureButton; - protected Button createOnlySelectedButton; - protected Button sourceBrowseButton; - //protected Button selectTypesButton; - protected Button selectAllButton; - protected Button deselectAllButton; - //A boolean to indicate if the user has typed anything - private boolean entryChanged = false; - - // dialog store id constants - private final static String STORE_SOURCE_NAMES_ID = "WizardFileSystemResourceImportPage1.STORE_SOURCE_NAMES_ID"; //$NON-NLS-1$ - //$NON-NLS-1$ - //private final static String STORE_OVERWRITE_EXISTING_RESOURCES_ID = - // "WizardFileSystemResourceImportPage1.STORE_OVERWRITE_EXISTING_RESOURCES_ID"; //$NON-NLS-1$ - //$NON-NLS-1$ - //private final static String STORE_CREATE_CONTAINER_STRUCTURE_ID = - // "WizardFileSystemResourceImportPage1.STORE_CREATE_CONTAINER_STRUCTURE_ID"; //$NON-NLS-1$ - //$NON-NLS-1$ - - //private static final String SELECT_TYPES_TITLE = "DataTransfer.selectTypes"; //$NON-NLS-1$ - private static final String SELECT_ALL_TITLE = J2EEUIMessages.getResourceString("DataTransfer.selectAll"); //$NON-NLS-1$ - private static final String DESELECT_ALL_TITLE = J2EEUIMessages.getResourceString("DataTransfer.deselectAll"); //$NON-NLS-1$ - private static final String SELECT_SOURCE_MESSAGE = J2EEUIMessages.getResourceString("FileImport.selectSource"); //$NON-NLS-1$ - protected static final String SOURCE_EMPTY_MESSAGE = J2EEUIMessages.getResourceString("FileImport.sourceEmpty"); //$NON-NLS-1$ - - private IPath importedClassesPath; - //protected Button importFromDir; - //protected Button importFromZip; - - - private ZipFileStructureProvider providerCache; - ZipFileStructureProvider currentProvider; - - private static final String FILE_IMPORT_MASK = "*.jar;*.zip"; //$NON-NLS-1$ - - private List dragAndDropFileNames = null; - - boolean createFullStructure = false; - private String packageBaseDirName = null; - - //private MinimizedFileSystemElement test = null; - - //private Composite dummyParent = null; - - //private final static int SIZING_SELECTION_WIDGET_WIDTH = 400; - //private final static int SIZING_SELECTION_WIDGET_HEIGHT = 150; - - private String packageDirStruc = null; - - /** - * Creates an instance of this class - */ - protected WizardClassesImportPage1(String name, IWorkbench aWorkbench, IStructuredSelection selection) { - super(name, selection); - } - - /** - * Creates an instance of this class - * - * @param aWorkbench - * IWorkbench - * @param selection - * IStructuredSelection - */ - public WizardClassesImportPage1(IWorkbench aWorkbench, IStructuredSelection selection, IPath importedClassesPath, List fileNames) { - this("fileSystemImportPage1", aWorkbench, selection); //$NON-NLS-1$ - setTitle(J2EEUIMessages.getResourceString("DataTransfer.fileSystemTitle")); //$NON-NLS-1$ - setDescription(J2EEUIMessages.getResourceString("FileImport.importFileSystem")); //$NON-NLS-1$ - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor("import_class_file_wiz_ban")); //$NON-NLS-1$ - this.importedClassesPath = importedClassesPath; - if (fileNames != null && fileNames.size() != 0) { - dragAndDropFileNames = fileNames; - } - } - - public void blankPage() { - if (this.selectionGroup != null) - this.selectionGroup.setRoot(null); - if (sourceNameField != null) - sourceNameField.setText(""); //$NON-NLS-1$ - } - - - /** - * Creates a new button with the given id. - * <p> - * The <code>Dialog</code> implementation of this framework method creates a standard push - * button, registers for selection events including button presses and registers default buttons - * with its shell. The button id is stored as the buttons client data. Note that the parent's - * layout is assumed to be a GridLayout and the number of columns in this layout is incremented. - * Subclasses may override. - * </p> - * - * @param parent - * the parent composite - * @param id - * the id of the button (see <code>IDialogConstants.*_ID</code> constants for - * standard dialog button ids) - * @param label - * the label from the button - * @param defaultButton - * <code>true</code> if the button is to be the default button, and - * <code>false</code> otherwise - */ - protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { - // increment the number of columns in the button bar - ((GridLayout) parent.getLayout()).numColumns++; - - Button button = new Button(parent, SWT.PUSH); - - GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); - button.setLayoutData(buttonData); - - button.setData(new Integer(id)); - button.setText(label); - - if (defaultButton) { - Shell shell = parent.getShell(); - if (shell != null) { - shell.setDefaultButton(button); - } - button.setFocus(); - } - return button; - } - - /** - * Creates the buttons for selecting specific types or selecting all or none of the elements. - * - * @param parent - * the parent control - */ - protected final void createButtonsGroup(Composite parent) { - // top level group - Composite buttonComposite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - - layout.makeColumnsEqualWidth = true; - buttonComposite.setLayout(layout); - buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - - // types edit button - // selectTypesButton = createButton(buttonComposite, IDialogConstants.SELECT_TYPES_ID, - // SELECT_TYPES_TITLE, false); - - SelectionListener listener = new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // handleTypesEditButtonPressed(); - // } - }; - // selectTypesButton.addSelectionListener(listener); - - selectAllButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, SELECT_ALL_TITLE, false); - - listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setAllSelections(true); - } - }; - selectAllButton.addSelectionListener(listener); - - deselectAllButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, DESELECT_ALL_TITLE, false); - - listener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setAllSelections(false); - } - }; - deselectAllButton.addSelectionListener(listener); - - } - - /** - * (non-Javadoc) Method declared on IDialogPage. - */ - public void createControl(Composite parent) { - //super.createControl(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJ2EEUIContextIds.IMPORT_CLASS_WIZARD_P2); - initializeDialogUnits(parent); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); - composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - composite.setFont(parent.getFont()); - - //dummyParent = composite; - - createSourceGroup(composite); - - //createSpacer(composite); - - //createPlainLabel(composite, - // WorkbenchMessages.getString("WizardImportPage.destinationLabel")); //$NON-NLS-1$ - //createDestinationGroup(composite); - - createOptionsGroup(composite); - - restoreWidgetValues(); - updateWidgetEnablements(); - setPageComplete(determinePageCompletion()); - - setControl(composite); - - validateSourceGroup(); - //WorkbenchHelp.setHelp(getControl(), - // IDataTransferHelpContextIds.FILE_SYSTEM_IMPORT_WIZARD_PAGE); - } - - protected void createOptionsGroup(Composite parent) { - Composite optionsGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - optionsGroup.setLayout(layout); - optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - - createOptionsGroupButtons(optionsGroup); - - } - - /** - * Create the import options specification widgets. - */ - protected void createOptionsGroupButtons(Composite optionsGroup) { - - // overwrite... checkbox - overwriteExistingResourcesCheckbox = new Button(optionsGroup, SWT.CHECK); - overwriteExistingResourcesCheckbox.setText(J2EEUIMessages.getResourceString("FileImport.overwriteExisting")); //$NON-NLS-1$ - } - - protected boolean isSetImportFromDir() { - ClassesImportWizard ciw = (ClassesImportWizard) getWizard(); - return ciw.mainPage.isSetImportFromDir(); - } - - public String getClassFileDirectory(String s) { - int index = s.lastIndexOf(File.separatorChar); - return s.substring(0, index + 1); - } - - /** - * Create the group for creating the root directory - */ - protected void createRootDirectoryGroup(Composite parent) { - Composite sourceContainerGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - sourceContainerGroup.setLayout(layout); - sourceContainerGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - - new Label(sourceContainerGroup, SWT.NONE).setText(getSourceLabel()); - - // source name entry field - sourceNameField = new Combo(sourceContainerGroup, SWT.BORDER); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); - data.widthHint = SIZING_TEXT_FIELD_WIDTH; - sourceNameField.setLayoutData(data); - - setSourceNameFieldForDragAndDrop(); - - sourceNameField.addListener(SWT.Modify, this); - - sourceNameField.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateFromSourceField(); - - } - }); - - sourceNameField.addKeyListener(new KeyListener() { - /* - * @see KeyListener.keyPressed - */ - public void keyPressed(KeyEvent e) { - //If there has been a key pressed then mark as dirty - entryChanged = true; - - } - - /* - * @see KeyListener.keyReleased - */ - public void keyReleased(KeyEvent e) { - //do nothing - } - }); - - sourceNameField.addFocusListener(new FocusListener() { - /* - * @see FocusListener.focusGained(FocusEvent) - */ - public void focusGained(FocusEvent e) { - //Do nothing when getting focus - if (dragAndDropFileNames != null) { - sourceNameField.setEnabled(false); - } - - } - - /* - * @see FocusListener.focusLost(FocusEvent) - */ - public void focusLost(FocusEvent e) { - //Clear the flag to prevent constant update - if (entryChanged) { - - entryChanged = false; - updateFromSourceField(); - } - - } - }); - - // source browse button - sourceBrowseButton = new Button(sourceContainerGroup, SWT.PUSH); - sourceBrowseButton.setText(J2EEUIMessages.getResourceString("DataTransfer.browse")); //$NON-NLS-1$ - sourceBrowseButton.addListener(SWT.Selection, this); - sourceBrowseButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - if (dragAndDropFileNames != null) { - sourceBrowseButton.setEnabled(false); - } - - } - - private void setSourceNameFieldForDragAndDrop() { - if (dragAndDropFileNames != null) { - String fileName = (String) (dragAndDropFileNames.get(0)); - sourceNameField.setText(fileName); - File f = new File(fileName); - if (f.isFile()) { - if (ImportUtil.getExtension(f).equals("zip") || ImportUtil.getExtension(f).equals("jar")) { //$NON-NLS-1$ //$NON-NLS-2$ - //importFromZip.setSelection(true); - //importFromDir.setSelection(false); - } else if (ImportUtil.getExtension(f).equals("class")) { //$NON-NLS-1$ - sourceNameField.setText(getClassFileDirectory(fileName)); - - //get com.ibm.abc.ClassName - PackageNameResolver nameResolver = new PackageNameResolver(); - String qualifiedClassName = nameResolver.getClassName(fileName); - if (qualifiedClassName != null) { - - //get com - int index = qualifiedClassName.indexOf('.'); - if (index == -1) { - String textToSet = fileName.substring(0, 1 + fileName.lastIndexOf(File.separatorChar)); - sourceNameField.setText(textToSet); - return; - } - String baseDir = qualifiedClassName.substring(0, index); - - //get com.ibm.abc - index = qualifiedClassName.lastIndexOf('.'); - String packageName = qualifiedClassName.substring(0, index); - //get com/ibm/abc - packageDirStruc = packageName.replace('.', File.separatorChar); - - //get C:\com - index = fileName.indexOf(baseDir); - //if packageDirStuc exists then set the sourceDir to com, else - //set the directory to the parent directory of the class - if (fileName.indexOf(packageDirStruc) != -1) { - int baseDirLength = baseDir.length(); - String textToSet = fileName.substring(0, index + baseDirLength); - index = packageName.indexOf('.'); - if (index == -1) - packageBaseDirName = packageName; - else - packageBaseDirName = packageName.substring(0, index); - - f = new File(textToSet); - if (f.getParent() != null) - f = new File(f.getParent()); - textToSet = f.getAbsolutePath(); //want to set the root directory to - // com's parent - sourceNameField.setText(textToSet); - } - } - - } - } - } - } - - /** - * Update the receiver from the source name field. - */ - - private void updateFromSourceField() { - - setSourceName(sourceNameField.getText()); - //Update enablements when this is selected - updateWidgetEnablements(); - } - - /** - * Creates and returns a <code>FileSystemElement</code> if the specified file system object - * merits one. The criteria for this are: Also create the children. - */ - protected MinimizedFileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) { - boolean isContainer = provider.isFolder(fileSystemObject); - String elementLabel = provider.getLabel(fileSystemObject); - - // Use an empty label so that display of the element's full name - // doesn't include a confusing label - MinimizedFileSystemElement dummyParent = new MinimizedFileSystemElement("", null, true); //$NON-NLS-1$ - dummyParent.setPopulated(); - MinimizedFileSystemElement result = new MinimizedFileSystemElement(elementLabel, dummyParent, isContainer); - - result.setPackageBaseDirName(packageBaseDirName); - result.setFileSystemObject(fileSystemObject); - - //Get the files for the element so as to build the first level - result.getFiles(provider); - - return dummyParent; - } - - /** - * Create the import source specification widgets - */ - protected void createSourceGroup(Composite parent) { - //createImportTypeGroup(parent); - createRootDirectoryGroup(parent); - createFileSelectionGroup(parent); - - createButtonsGroup(parent); - } - - /** - * Enable or disable the button group. - */ - protected void enableButtonGroup(boolean enable) { - // selectTypesButton.setEnabled(enable); - selectAllButton.setEnabled(enable); - deselectAllButton.setEnabled(enable); - } - - /** - * Answer a boolean indicating whether the specified source currently exists and is valid - */ - protected boolean ensureSourceIsValid() { - if (isSetImportFromDir()) { - if (getSourceDirectory() != null && new File(getSourceDirectoryName()).isDirectory()) - return true; - displayErrorDialog(getString("FileImport.invalidSource")); //$NON-NLS-1$ - sourceNameField.setFocus(); - return false; - } - ZipFile specifiedFile = getSpecifiedSourceFile(); - - if (specifiedFile == null) { - displayErrorDialog(getString("FileImport.invalidSource")); //$NON-NLS-1$ - sourceNameField.setFocus(); - return false; - } - return closeZipFile(specifiedFile); - } - - /** - * Execute the passed import operation. Answer a boolean indicating success. - */ - protected boolean executeImportOperation(ImportOperation op) { - initializeOperation(op); - if (createFullStructure) { - op.setCreateContainerStructure(true); - } else { - op.setCreateContainerStructure(false); - } - - try { - getContainer().run(true, true, op); - } catch (InterruptedException e) { - return false; - } catch (InvocationTargetException e) { - displayErrorDialog(e.getTargetException()); - return false; - } - - IStatus status = op.getStatus(); - if (!status.isOK()) { - ErrorDialog.openError(getContainer().getShell(), getString("FileImport.importProblems"), //$NON-NLS-1$ - null, // no special message - status); - return false; - } - - return true; - } - - // need the following private stuff just because the DataTransferMessages class is not public! - //private static final String RESOURCE_BUNDLE = "org.eclipse.ui.wizards.datatransfer.messages"; - // //$NON-NLS-1$ - //private static ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private static String getString(String key) { - try { - return J2EEUIMessages.getResourceString(key); - } catch (MissingResourceException e) { - return key; - } - } - - /** - * The Finish button was pressed. Try to do the required work now and answer a boolean - * indicating success. If false is returned then the wizard will not close. - * - * @return boolean - */ - public boolean finish() { - if (!ensureSourceIsValid()) - return false; - - clearProviderCache(); - - saveWidgetValues(); - - Iterator resourcesEnum = getSelectedResources().iterator(); - List fileSystemObjects = new ArrayList(); - while (resourcesEnum.hasNext()) { - fileSystemObjects.add(((FileSystemElement) resourcesEnum.next()).getFileSystemObject()); - } - - if (fileSystemObjects.size() > 0) { - if (getSourceDirectory() != null) { - return importResources(fileSystemObjects); - } - return importResourcesFromZip(fileSystemObjects); - } - - MessageDialog.openInformation(getContainer().getShell(), getString("DataTransfer.information"), //$NON-NLS-1$ - getString("FileImport.noneSelected")); //$NON-NLS-1$ - - return false; - } - - /** - * Returns a content provider for <code>FileSystemElement</code> s that returns only files as - * children. - */ - - protected ITreeContentProvider getFileProvider() { - return new WorkbenchContentProvider() { - public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; - if (currentProvider != null) { - return element.getFiles(currentProvider).getChildren(element); - } - return element.getFiles(FileSystemStructureProvider.INSTANCE).getChildren(element); - } - return new Object[0]; - } - - public Object[] getElements(Object element) { - Object[] superObjects = super.getElements(element); - if (dragAndDropFileNames != null && getSourceDirectory() != null) { - MinimizedFileSystemElement anElement = null; - int newObjectsIndex = 0; - for (int i = 0; i < superObjects.length; i++) { - anElement = (MinimizedFileSystemElement) superObjects[i]; - - File file = (File) anElement.getFileSystemObject(); - - for (int k = 0; k < dragAndDropFileNames.size(); k++) { - if (file.getAbsolutePath().equals(dragAndDropFileNames.get(k))) { - newObjectsIndex++; - } - } - } - if (newObjectsIndex > 0) { - Object[] newObjects = new Object[newObjectsIndex]; - newObjectsIndex = 0; - - for (int i = 0; i < superObjects.length; i++) { - anElement = (MinimizedFileSystemElement) superObjects[i]; - - File file = (File) anElement.getFileSystemObject(); - - for (int k = 0; k < dragAndDropFileNames.size(); k++) { - if (file.getAbsolutePath().equals(dragAndDropFileNames.get(k))) { - - newObjects[newObjectsIndex++] = anElement; - - } - } - - } - return newObjects; - } - } - return superObjects; - } - }; - } - - /** - * Answer the root FileSystemElement that represents the contents of the currently-specified - * source. If this FileSystemElement is not currently defined then create and return it. - */ - protected MinimizedFileSystemElement getFileSystemTree() { - if (isSetImportFromDir()) { - File sourceDirectory = getSourceDirectory(); - if (sourceDirectory != null) { - return selectFiles(sourceDirectory, FileSystemStructureProvider.INSTANCE); - } - if (sourceNameField.getText().length() > 0) { - displayErrorDialog(getString("FileImport.invalidSource")); //$NON-NLS-1$ - sourceNameField.setFocus(); - } - return null; - } - ZipFile sourceFile = getSpecifiedSourceFile(); - if (sourceFile == null) { - //Clear out the provider as well - this.currentProvider = null; - if (sourceNameField.getText().length() > 0) { - displayErrorDialog(getString("FileImport.invalidSource")); //$NON-NLS-1$ - sourceNameField.setFocus(); - } - return null; - } - - ZipFileStructureProvider provider = getStructureProvider(sourceFile); - this.currentProvider = provider; - return selectFiles(provider.getRoot(), provider); - } - - /** - * Returns a content provider for <code>FileSystemElement</code> s that returns only folders - * as children. - */ - protected ITreeContentProvider getFolderProvider() { - return new WorkbenchContentProvider() { - public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; - if (currentProvider != null) { - return element.getFolders(currentProvider).getChildren(element); - } - return element.getFolders(FileSystemStructureProvider.INSTANCE).getChildren(element); - } - return new Object[0]; - } - - public boolean hasChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; - if (element.isPopulated()) - return getChildren(element).length > 0; - //If we have not populated then wait until asked - return true; - } - return false; - } - - }; - } - - /** - * Returns a File object representing the currently-named source directory iff it exists as a - * valid directory, or <code>null</code> otherwise. - */ - protected File getSourceDirectory() { - return getSourceDirectory(this.sourceNameField.getText()); - } - - /** - * Returns a File object representing the currently-named source directory iff it exists as a - * valid directory, or <code>null</code> otherwise. - * - * @param path - * a String not yet formatted for java.io.File compatability - */ - private File getSourceDirectory(String path) { - if (isSetImportFromDir()) { - File sourceDirectory = new File(getSourceDirectoryName(path)); - if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) { - return null; - } - - return sourceDirectory; - } - return null; - } - - /** - * Answer the directory name specified as being the import source. Note that if it ends with a - * separator then the separator is first removed so that java treats it as a proper directory - */ - private String getSourceDirectoryName() { - return getSourceDirectoryName(this.sourceNameField.getText()); - } - - /** - * Answer the directory name specified as being the import source. Note that if it ends with a - * separator then the separator is first removed so that java treats it as a proper directory - */ - private String getSourceDirectoryName(String sourceName) { - IPath result = new Path(sourceName.trim()); - - if (result.getDevice() != null && result.segmentCount() == 0) // something like "c:" - result = result.addTrailingSeparator(); - else - result = result.removeTrailingSeparator(); - - return result.toOSString(); - } - - /** - * Answer the string to display as the label for the source specification field - */ - protected String getSourceLabel() { - return J2EEUIMessages.getResourceString("DataTransfer.directory"); //$NON-NLS-1$ - } - - /** - * Handle all events and enablements for widgets in this dialog - * - * @param event - * Event - */ - public void handleEvent(Event event) { - if (event.widget == sourceBrowseButton) { - if (isSetImportFromDir()) { - handleSourceBrowseButtonPressed(); - } else { - handleSourceBrowseButtonPressedForZip(); - } - } - - super.handleEvent(event); - - } - - /** - * Open an appropriate source browser so that the user can specify a source to import from - */ - protected void handleSourceBrowseButtonPressed() { - String currentSource = this.sourceNameField.getText(); - DirectoryDialog dialog = new DirectoryDialog(sourceNameField.getShell(), SWT.SAVE); - dialog.setMessage(SELECT_SOURCE_MESSAGE); - dialog.setFilterPath(getSourceDirectoryName(currentSource)); - - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - //Just quit if the directory is not valid - if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) - return; - //If it is valid then proceed to populate - setErrorMessage(null); - setSourceName(selectedDirectory); - selectionGroup.setFocus(); - } - } - - /** - * Open a registered type selection dialog and note the selections in the receivers - * types-to-export field., Added here so that inner classes can have access - */ - protected void handleTypesEditButtonPressed() { - - super.handleTypesEditButtonPressed(); - } - - /** - * Import the resources with extensions as specified by the user - */ - protected boolean importResources(List fileSystemObjects) { - Iterator i = fileSystemObjects.iterator(); - while (i.hasNext()) { - File f = (File) i.next(); - List singleItemList = new ArrayList(); - singleItemList.add(f); - String textToSet = getPackageName(f); - if (textToSet != null) { - File newSource = new File(textToSet); - executeImportOperation(new ImportOperation(getContainerFullPath(), newSource, FileSystemStructureProvider.INSTANCE, this, singleItemList)); - } else { - executeImportOperation(new ImportOperation(getContainerFullPath(), getSourceDirectory(), FileSystemStructureProvider.INSTANCE, this, singleItemList)); - - } - } - return true; - - } - - protected String getPackageName(File f) { - if (ImportUtil.getExtension(f).equals("class")) { //$NON-NLS-1$ - String fileName = f.getAbsolutePath(); - //get com.ibm.abc.ClassName - PackageNameResolver nameResolver = new PackageNameResolver(); - String qualifiedClassName = nameResolver.getClassName(fileName); - if (qualifiedClassName != null) { - - //get com - int index = qualifiedClassName.indexOf('.'); - if (index == -1) { - return fileName.substring(0, 1 + fileName.lastIndexOf(File.separatorChar)); - } - String baseDir = qualifiedClassName.substring(0, index); - - //get com.ibm.abc - index = qualifiedClassName.lastIndexOf('.'); - String packageName = qualifiedClassName.substring(0, index); - - //get com/ibm/abc - packageDirStruc = packageName.replace('.', File.separatorChar); - - //get C:\com - index = fileName.indexOf(baseDir); - //if packageDirStuc exists then set the sourceDir to com, else - //set the directory to the parent directory of the class - if (fileName.indexOf(packageDirStruc) != -1) { - int baseDirLength = baseDir.length(); - String textToSet = fileName.substring(0, index + baseDirLength); - index = packageName.indexOf('.'); - if (index == -1) - packageBaseDirName = packageName; - else - packageBaseDirName = packageName.substring(0, index); - - f = new File(textToSet); - if (f.getParent() != null) - f = new File(f.getParent()); - textToSet = f.getAbsolutePath(); //want to set the root directory to com's - // parent - //sourceNameField.setText(textToSet); - return textToSet; - } - } - } - return null; - } - - /** - * Initializes the specified operation appropriately. - */ - protected void initializeOperation(ImportOperation op) { - - /* - * op.setCreateContainerStructure( createContainerStructureButton.getSelection()); - */ - op.setOverwriteResources(overwriteExistingResourcesCheckbox.getSelection()); - } - - /** - * Returns whether the extension provided is an extension that has been specified for export by - * the user. - * - * @param extension - * the resource name - * @return <code>true</code> if the resource name is suitable for export based upon its - * extension - */ - protected boolean isExportableExtension(String extension) { - if (selectedTypes == null) // ie.- all extensions are acceptable - return true; - - Iterator aenum = selectedTypes.iterator(); - while (aenum.hasNext()) { - if (extension.equalsIgnoreCase((String) aenum.next())) - return true; - } - - return false; - } - - /** - * Repopulate the view based on the currently entered directory. - */ - protected void resetSelection() { - - MinimizedFileSystemElement currentRoot = getFileSystemTree(); - this.selectionGroup.setRoot(currentRoot); - if (dragAndDropFileNames != null) { - - if (dragAndDropFileNames.get(0).toString().endsWith(".zip") == false && dragAndDropFileNames.get(0).toString().endsWith(".jar") == false) { //$NON-NLS-1$ //$NON-NLS-2$ - this.selectionGroup.expandAll(); - } - - MinimizedFileSystemElement temp = (MinimizedFileSystemElement) currentRoot.getFolders().getChildren()[0]; - - List dirList = pathToArray(); - - for (int i = 0; i < dirList.size(); i++) { - String s = (String) dirList.get(i); - Object[] folders = temp.getFolders().getChildren(); - for (int k = 0; k < folders.length; k++) { - if (((File) ((MinimizedFileSystemElement) folders[k]).getFileSystemObject()).getName().equals(s)) { - temp = (MinimizedFileSystemElement) temp.getFolders().getChildren()[k]; - break; - } - } - - } - - if (dragAndDropFileNames.get(0).toString().endsWith(".zip") == false && dragAndDropFileNames.get(0).toString().endsWith(".jar") == false) { //$NON-NLS-1$ //$NON-NLS-2$ - this.selectionGroup.initialCheckTreeItem(temp); - } - - //If can figure out how to pre-highlight dir, then use following code - //to check dragged files only. Also need to show all files in tree. - /* - * String fileName = null; MinimizedFileSystemElement name = null; int numFiles = - * temp.getFiles().getChildren().length; Object[] files = temp.getFiles().getChildren(); - * for(int i = 0; i < dragAndDropFileNames.size(); i++) { fileName = (new - * File((String)dragAndDropFileNames.get(i))).getName(); for(int k = 0; k < numFiles; - * k++) { if(fileName.equals(((File) ((MinimizedFileSystemElement) - * files[0]).getFileSystemObject()).getName())) { - * this.selectionGroup.initialCheckTreeItem(temp); break; } } } - */ - - //this.selectionGroup.setAllSelections(true); - } - } - - private List pathToArray() { - String s = (String) dragAndDropFileNames.get(0); - - PackageNameResolver nameResolver = new PackageNameResolver(); - String qualifiedClassName = nameResolver.getClassName(s); - - int slashCounts = 0; - if (qualifiedClassName != null) { - int index = qualifiedClassName.indexOf('.'); - if (index == -1) { - return Collections.EMPTY_LIST; - } - String baseDir = qualifiedClassName.substring(0, index); - for (int i = s.indexOf(baseDir); i < s.lastIndexOf(File.separatorChar); i++) { - if (s.charAt(i) == File.separatorChar) - slashCounts++; - } - } - - List dirNamesArray = new ArrayList(slashCounts); - if (s.endsWith(".zip") || s.endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$ - return dirNamesArray; - } - int startIndex = 0; - int endIndex; - for (int i = 0; i <= slashCounts; i++) { - endIndex = qualifiedClassName.indexOf('.', startIndex); - dirNamesArray.add(qualifiedClassName.substring(startIndex, endIndex)); - startIndex = endIndex + 1; - } - return dirNamesArray; - } - - /** - * Use the dialog store to restore widget values to the values that they held last time this - * wizard was used to completion - */ - protected void restoreWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] sourceNames = settings.getArray(STORE_SOURCE_NAMES_ID); - if (sourceNames == null) - return; // ie.- no values stored, so stop - - // set filenames history - for (int i = 0; i < sourceNames.length; i++) - sourceNameField.add(sourceNames[i]); - } - } - - /** - * Since Finish was pressed, write widget values to the dialog store so that they will persist - * into the next invocation of this wizard page - */ - protected void saveWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // update source names history - String[] sourceNames = settings.getArray(STORE_SOURCE_NAMES_ID); - if (sourceNames == null) - sourceNames = new String[0]; - - sourceNames = addToHistory(sourceNames, getSourceDirectoryName()); - settings.put(STORE_SOURCE_NAMES_ID, sourceNames); - - } - } - - /** - * Invokes a file selection operation using the specified file system and structure provider. If - * the user specifies files to be imported then this selection is cached for later retrieval and - * is returned. - */ - protected MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) { - - final MinimizedFileSystemElement[] results = new MinimizedFileSystemElement[1]; - - BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { - public void run() { - //Create the root element from the supplied file system object - results[0] = createRootElement(rootFileSystemObject, structureProvider); - } - }); - - return results[0]; - } - - /** - * Set all of the selections in the selection group to value. Implemented here to provide access - * for inner classes. - * - * @param value - * boolean - */ - protected void setAllSelections(boolean value) { - super.setAllSelections(value); - } - - /** - * Sets the source name of the import to be the supplied path. Adds the name of the path to the - * list of items in the source combo and selects it. - * - * @param path - * the path to be added - */ - protected void setSourceName(String path) { - - if (path.length() > 0) { - - String[] currentItems = this.sourceNameField.getItems(); - int selectionIndex = -1; - for (int i = 0; i < currentItems.length; i++) { - if (currentItems[i].equals(path)) - selectionIndex = i; - } - if (selectionIndex < 0) { - int oldLength = currentItems.length; - String[] newItems = new String[oldLength + 1]; - System.arraycopy(currentItems, 0, newItems, 0, oldLength); - newItems[oldLength] = path; - this.sourceNameField.setItems(newItems); - selectionIndex = oldLength; - } - this.sourceNameField.select(selectionIndex); - - resetSelection(); - } - } - - /** - * Update the tree to only select those elements that match the selected types - */ - protected void setupSelectionsBasedOnSelectedTypes() { - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getContainer().getShell()); - final Map selectionMap = new Hashtable(); - - final IElementFilter filter = new IElementFilter() { - - public void filterElements(Collection files, IProgressMonitor monitor) throws InterruptedException { - if (files == null) { - throw new InterruptedException(); - } - Iterator filesList = files.iterator(); - while (filesList.hasNext()) { - if (monitor.isCanceled()) - throw new InterruptedException(); - checkFile(filesList.next()); - } - } - - public void filterElements(Object[] files, IProgressMonitor monitor) throws InterruptedException { - if (files == null) { - throw new InterruptedException(); - } - for (int i = 0; i < files.length; i++) { - if (monitor.isCanceled()) - throw new InterruptedException(); - checkFile(files[i]); - } - } - - private void checkFile(Object fileElement) { - MinimizedFileSystemElement file = (MinimizedFileSystemElement) fileElement; - if (isExportableExtension(file.getFileNameExtension())) { - List elements = new ArrayList(); - FileSystemElement parent = file.getParent(); - if (selectionMap.containsKey(parent)) - elements = (List) selectionMap.get(parent); - elements.add(file); - selectionMap.put(parent, elements); - } - } - - }; - - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(final IProgressMonitor monitor) throws InterruptedException { - monitor.beginTask("ImportPage.filterSelections", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - getSelectedResources(filter, monitor); - } - }; - - try { - dialog.run(true, true, runnable); - } catch (InvocationTargetException exception) { - //Couldn't start. Do nothing. - return; - } catch (InterruptedException exception) { - //Got interrupted. Do nothing. - return; - } - // make sure that all paint operations caused by closing the progress - // dialog get flushed, otherwise extra pixels will remain on the screen until - // updateSelections is completed - getShell().update(); - // The updateSelections method accesses SWT widgets so cannot be executed - // as part of the above progress dialog operation since the operation forks - // a new process. - if (selectionMap != null) { - updateSelections(selectionMap); - } - } - - /* - * (non-Javadoc) Method declared on IDialogPage. Set the selection up when it becomes visible. - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - resetSelection(); - if (visible) - this.sourceNameField.setFocus(); - } - - /** - * Update the selections with those in map . Implemented here to give inner class visibility - * - * @param map - * Map - key tree elements, values Lists of list elements - */ - protected void updateSelections(Map map) { - super.updateSelections(map); - } - - /** - * Check if widgets are enabled or disabled by a change in the dialog. Provided here to give - * access to inner classes. - * - * @param event - * Event - */ - protected void updateWidgetEnablements() { - - super.updateWidgetEnablements(); - } - - /** - * Answer a boolean indicating whether self's source specification widgets currently all contain - * valid values. - */ - protected boolean validateSourceGroup() { - if (getSourceDirectory() != null) { - File sourceDirectory = getSourceDirectory(); - if (sourceDirectory == null) { - setMessage(SOURCE_EMPTY_MESSAGE); - enableButtonGroup(false); - return false; - } - - if (sourceConflictsWithDestination(new Path(sourceDirectory.getPath()))) { - setErrorMessage(getSourceConflictMessage()); //$NON-NLS-1$ - enableButtonGroup(false); - return false; - } - - enableButtonGroup(true); - return true; - } - //If there is nothing being provided to the input then there is a problem - if (this.currentProvider == null) { - setMessage(SOURCE_EMPTY_MESSAGE); - enableButtonGroup(false); - return false; - } - enableButtonGroup(true); - return true; - } - - /** - * Returns whether the source location conflicts with the destination resource. This will occur - * if the source is already under the destination. - * - * @param sourcePath - * the path to check - * @return <code>true</code> if there is a conflict, <code>false</code> if not - */ - protected boolean sourceConflictsWithDestination(IPath sourcePath) { - - IContainer container = getSpecifiedContainer(); - if (container == null) - return false; - return getSpecifiedContainer().getLocation().isPrefixOf(sourcePath); - } - - protected IPath getResourcePath() { - return importedClassesPath; - } - - //------------------------------------------------------------------------------------- - - //makesure to call mainpage.cancel() - public boolean cancel() { - clearProviderCache(); - return true; - } - - /** - * Clears the cached structure provider after first finalizing it properly. - */ - protected void clearProviderCache() { - if (providerCache != null) { - closeZipFile(providerCache.getZipFile()); - providerCache = null; - } - } - - /** - * Attempts to close the passed zip file, and answers a boolean indicating success. - */ - protected boolean closeZipFile(ZipFile file) { - try { - file.close(); - } catch (IOException e) { - //displayErrorDialog(DataTransferMessages.format("ZipImport.couldNotClose", new - // Object[] { file.getName()})); //$NON-NLS-1$ - return false; - } - - return true; - } - - /** - * Answer a handle to the zip file currently specified as being the source. Return null if this - * file does not exist or is not of valid format. - */ - - protected ZipFile getSpecifiedSourceFile() { - return getSpecifiedSourceFile(sourceNameField.getText()); - } - - /** - * Answer a handle to the zip file currently specified as being the source. Return null if this - * file does not exist or is not of valid format. - */ - - private ZipFile getSpecifiedSourceFile(String fileName) { - if (fileName.length() == 0) - return null; - - try { - return ArchiveUtil.newZipFile(fileName); - } catch (ZipException e) { - //displayErrorDialog(DataTransferMessages.getString("ZipImport.badFormat")); - // //$NON-NLS-1$ - } catch (IOException e) { - //displayErrorDialog(DataTransferMessages.getString("ZipImport.couldNotRead")); - // //$NON-NLS-1$ - } - - sourceNameField.setFocus(); - return null; - } - - /** - * Returns a structure provider for the specified zip file. - */ - protected ZipFileStructureProvider getStructureProvider(ZipFile targetZip) { - if (providerCache == null) - providerCache = new ZipFileStructureProvider(targetZip); - else if (!providerCache.getZipFile().getName().equals(targetZip.getName())) { - clearProviderCache(); // ie.- new value, so finalize&remove old value - providerCache = new ZipFileStructureProvider(targetZip); - } else if (!providerCache.getZipFile().equals(targetZip)) - closeZipFile(targetZip); // ie.- duplicate handle to same .zip - - return providerCache; - } - - /** - * Open a FileDialog so that the user can specify the source file to import from - */ - protected void handleSourceBrowseButtonPressedForZip() { - String selectedFile = queryZipFileToImport(); - if (selectedFile != null) { - if (!selectedFile.equals(sourceNameField.getText())) { - //Be sure it is valid before we go setting any names - ZipFile sourceFile = getSpecifiedSourceFile(selectedFile); - if (sourceFile != null) { - closeZipFile(sourceFile); - setSourceName(selectedFile); - selectionGroup.setFocus(); - } - } - } - } - - /** - * Import the resources with extensions as specified by the user - */ - protected boolean importResourcesFromZip(List fileSystemObjects) { - - ZipFile zipFile = getSpecifiedSourceFile(); - ZipFileStructureProvider structureProvider = getStructureProvider(zipFile); - - boolean result = executeImportOperation(new ImportOperation(getContainerFullPath(), structureProvider.getRoot(), structureProvider, this, fileSystemObjects)); - - closeZipFile(zipFile); - - return result; - } - - /** - * Opens a file selection dialog and returns a string representing the selected file, or - * <code>null</code> if the dialog was canceled. - */ - protected String queryZipFileToImport() { - FileDialog dialog = new FileDialog(sourceNameField.getShell(), SWT.OPEN); - dialog.setFilterExtensions(new String[]{FILE_IMPORT_MASK}); - - String currentSourceString = sourceNameField.getText(); - int lastSeparatorIndex = currentSourceString.lastIndexOf(File.separator); - if (lastSeparatorIndex != -1) - dialog.setFilterPath(currentSourceString.substring(0, lastSeparatorIndex)); - - return dialog.open(); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/earlibraries.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/earlibraries.properties deleted file mode 100644 index b815ca648..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/wizard/earlibraries.properties +++ /dev/null @@ -1,2 +0,0 @@ -EARLibrariesContainerPage_0=EAR Libraries -EARLibrariesContainerPage_1=The EAR Libraries classpath container dynamically computes the Java EE project's module classpath dependencies using the META-INF/MANIFEST.MF Class-Path entries. diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/IArchiveExportParticipantPanelFactory.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/IArchiveExportParticipantPanelFactory.java deleted file mode 100644 index 5a897177b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/IArchiveExportParticipantPanelFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.archive; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -/** - * Used in conjunction with the <code>org.eclipse.jst.j2ee.ui.archiveExportParticipantPanels</code> - * extension point in order to extend the UI of the base module archive export wizard. - * - * @since 3.0 - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public interface IArchiveExportParticipantPanelFactory -{ - /** - * Creates a composite containing the UI elements appropriate for the export participant - * that this panel factory is registered with. - * - * @param parent the parent composite - * @param dataModel the data model of the export participant - * @return the created composite - */ - - Composite createPanel( Composite parent, - IDataModel dataModel ); -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/internal/ArchiveExportParticipantPanelsExtensionPoint.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/internal/ArchiveExportParticipantPanelsExtensionPoint.java deleted file mode 100644 index 38b1307b7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/archive/internal/ArchiveExportParticipantPanelsExtensionPoint.java +++ /dev/null @@ -1,119 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.archive.internal; - -import static org.eclipse.jst.j2ee.internal.archive.ArchiveExportParticipantsExtensionPoint.PluginUtil.findExtensions; -import static org.eclipse.jst.j2ee.internal.archive.ArchiveExportParticipantsExtensionPoint.PluginUtil.findRequiredAttribute; -import static org.eclipse.jst.j2ee.internal.archive.ArchiveExportParticipantsExtensionPoint.PluginUtil.getTopLevelElements; -import static org.eclipse.jst.j2ee.internal.archive.ArchiveExportParticipantsExtensionPoint.PluginUtil.instantiate; -import static org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin.PLUGIN_ID; -import static org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin.log; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jst.j2ee.internal.archive.ArchiveExportParticipantsExtensionPoint.PluginUtil.InvalidExtensionException; -import org.eclipse.jst.j2ee.ui.archive.IArchiveExportParticipantPanelFactory; - -/** - * Contains the logic for processing the <code>org.eclipse.jst.j2ee.ui.archiveExportParticipantPanels</code> - * extension point. - * - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class ArchiveExportParticipantPanelsExtensionPoint -{ - public static final String EXTENSION_POINT_ID = "archiveExportParticipantPanels"; //$NON-NLS-1$ - - private static final String EL_PANEL_FACTORY = "panel-factory"; //$NON-NLS-1$ - private static final String ATTR_ARCHIVE_EXPORT_PARTICIPANT_ID = "archiveExportParticipantId"; //$NON-NLS-1$ - private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ - - private static Map<String,PanelFactoryInfo> extensions = null; - - public static class PanelFactoryInfo - { - private String archiveExportParticipantId; - private String pluginId = null; - private String className = null; - - public String getArchiveExportExtensionId() - { - return this.archiveExportParticipantId; - } - - public IArchiveExportParticipantPanelFactory loadPanelFactory() - { - try - { - return instantiate( this.pluginId, this.className, - IArchiveExportParticipantPanelFactory.class ); - } - catch( CoreException e ) - { - log( e.getStatus() ); - return null; - } - } - } - - public static PanelFactoryInfo getExtension( final String archiveExportParticipantId ) - { - readExtensions(); - - return extensions.get( archiveExportParticipantId ); - } - - private static synchronized void readExtensions() - { - if( extensions != null ) - { - return; - } - - extensions = new HashMap<String,PanelFactoryInfo>(); - - for( IConfigurationElement element - : getTopLevelElements( findExtensions( PLUGIN_ID, EXTENSION_POINT_ID ) ) ) - { - if( element.getName().equals( EL_PANEL_FACTORY ) ) - { - try - { - readExtension( element ); - } - catch( InvalidExtensionException e ) - { - // Continue. The problem has been reported to the user via the log. - } - } - } - } - - private static void readExtension( final IConfigurationElement config ) - - throws InvalidExtensionException - - { - final PanelFactoryInfo ext = new PanelFactoryInfo(); - - ext.archiveExportParticipantId = findRequiredAttribute( config, ATTR_ARCHIVE_EXPORT_PARTICIPANT_ID ); - ext.pluginId = config.getContributor().getName(); - ext.className = findRequiredAttribute( config, ATTR_CLASS ); - - extensions.put( ext.archiveExportParticipantId, ext ); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.java deleted file mode 100644 index d26ede2cd..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.java +++ /dev/null @@ -1,381 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2006 BEA Systems, Inc. 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: - * Konstantin Komissarchik - initial API and implementation - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.project.facet; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.internal.AvailableJ2EEComponentsForEARContentProvider; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.earcreation.DefaultJ2EEComponentCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.earcreation.IDefaultJ2EEComponentCreationDataModelProperties; -import org.eclipse.jst.j2ee.internal.earcreation.IEarFacetInstallDataModelProperties; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.wizard.DefaultJ2EEComponentCreationWizard; -import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentLabelProvider; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public class EarFacetInstallPage extends DataModelFacetInstallPage implements IEarFacetInstallDataModelProperties { - - private Button selectAllButton; - private Button deselectAllButton; - private Button newModuleButton; - - private Label moduleProjectsLabel; - private CheckboxTableViewer moduleProjectsViewer; - - private boolean ignoreCheckedState = false; - - private Label contentDirLabel; - private Text contentDir; - - public EarFacetInstallPage() { - super("ear.facet.install.page"); //$NON-NLS-1$ - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_SECOND_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_SECOND_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_WIZ_BANNER)); - } - - protected String[] getValidationPropertyNames() { - return new String[]{CONTENT_DIR, J2EE_PROJECTS_LIST}; - } - - protected Composite createTopLevelComposite(Composite parent) { - Composite modulesGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - modulesGroup.setLayout(layout); - setInfopopID(IJ2EEUIContextIds.NEW_EAR_ADD_MODULES_PAGE); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - modulesGroup.setLayoutData(gridData); - createModuleProjectOptions(modulesGroup); - createButtonsGroup(modulesGroup); - - final Composite composite = new Composite(modulesGroup, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - - this.contentDirLabel = new Label(composite, SWT.NONE); - this.contentDirLabel.setText(Resources.contentDirLabel); - this.contentDirLabel.setLayoutData(gdhfill()); - - this.contentDir = new Text(composite, SWT.BORDER); - this.contentDir.setLayoutData(gdhfill()); - synchHelper.synchText(contentDir, CONTENT_DIR, null); - Dialog.applyDialogFont(parent); - return modulesGroup; - } - - protected int getJ2EEVersion() { - IProjectFacetVersion version = (IProjectFacetVersion)getDataModel().getProperty(FACET_VERSION); - return J2EEVersionUtil.convertVersionStringToInt(version.getVersionString()); - } - - /** - * @param modulesGroup - */ - private void createModuleProjectOptions(Composite modulesGroup) { - moduleProjectsLabel = new Label(modulesGroup, SWT.NONE); - moduleProjectsLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.J2EE_MODULE_DEPENDENCIES_LABEL)); - moduleProjectsLabel.setLayoutData(gdhfill()); - - moduleProjectsViewer = CheckboxTableViewer.newCheckList(modulesGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - GridData gData = new GridData(GridData.FILL_BOTH); - gData.widthHint = 200; - gData.heightHint = 80; - moduleProjectsViewer.getControl().setLayoutData(gData); - int j2eeVersion = getJ2EEVersion(); - AvailableJ2EEComponentsForEARContentProvider provider = new AvailableJ2EEComponentsForEARContentProvider(null, j2eeVersion); - moduleProjectsViewer.setContentProvider(provider); - moduleProjectsViewer.setLabelProvider(new J2EEComponentLabelProvider()); - setCheckedItemsFromModel(); - - moduleProjectsViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - if (!ignoreCheckedState) { - getDataModel().setProperty(J2EE_PROJECTS_LIST, getCheckedJ2EEElementsAsList()); - getDataModel().setProperty(JAVA_PROJECT_LIST, getCheckedJavaProjectsAsList()); - } - } - }); - TableLayout tableLayout = new TableLayout(); - moduleProjectsViewer.getTable().setLayout(tableLayout); - moduleProjectsViewer.getTable().setHeaderVisible(false); - moduleProjectsViewer.getTable().setLinesVisible(false); - moduleProjectsViewer.setSorter(null); - } - - /** - * - */ - private void setCheckedItemsFromModel() { - List components = (List) getDataModel().getProperty(J2EE_PROJECTS_LIST); - - TableItem [] items = moduleProjectsViewer.getTable().getItems(); - - List list = new ArrayList(); - - for( int i=0; i< items.length; i++ ){ - Object element = items[i].getData(); - if( element instanceof IVirtualComponent){ - IVirtualComponent comp = (IVirtualComponent)element; - Iterator it = components.iterator(); - while( it.hasNext() ){ - IProject project = (IProject)it.next(); - if( comp.getProject().getName().equals(project.getName()) ){ - list.add(comp); - } - } - } - } - moduleProjectsViewer.setCheckedElements(list.toArray()); - } - - private void refreshModules() { - moduleProjectsViewer.refresh(); - setCheckedItemsFromModel(); - } - - protected List getCheckedJ2EEElementsAsList() { - Object[] elements = moduleProjectsViewer.getCheckedElements(); - List list; - if (elements == null || elements.length == 0) - list = Collections.EMPTY_LIST; - else{ - list = new ArrayList(); - for( int i=0; i< elements.length; i++){ - if( elements[i] instanceof IVirtualComponent ) { - list.add(((IVirtualComponent)elements[i]).getProject()); - } - } - } - return list; - } - - protected List getCheckedJavaProjectsAsList() { - Object[] elements = moduleProjectsViewer.getCheckedElements(); - List list; - if (elements == null || elements.length == 0) - list = Collections.EMPTY_LIST; - else{ - list = new ArrayList(); - for( int i=0; i< elements.length; i++){ - if( elements[i] instanceof IProject ) { - list.add(elements[i]); - } - } - } - return list; - } - - - protected void createButtonsGroup(org.eclipse.swt.widgets.Composite parent) { - Composite buttonGroup = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - buttonGroup.setLayout(layout); - buttonGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); - selectAllButton = new Button(buttonGroup, SWT.PUSH); - selectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_PROJECT_MODULES_PG_SELECT)); - selectAllButton.addListener(SWT.Selection, this); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.widthHint = SWT.DEFAULT; - selectAllButton.setLayoutData(gd); - deselectAllButton = new Button(buttonGroup, SWT.PUSH); - deselectAllButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_PROJECT_MODULES_PG_DESELECT)); - deselectAllButton.addListener(SWT.Selection, this); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.widthHint = SWT.DEFAULT; - deselectAllButton.setLayoutData(gd); - newModuleButton = new Button(buttonGroup, SWT.PUSH); - newModuleButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_PROJECT_MODULES_PG_NEW)); - newModuleButton.addListener(SWT.Selection, this); - gd = new GridData(GridData.GRAB_HORIZONTAL); - gd.minimumWidth = SWT.DEFAULT; - newModuleButton.setLayoutData(gd); - } - - /** - * @see org.eclipse.swt.widgets.Listener#handleEvent(Event) - */ - public void handleEvent(Event evt) { - if (evt.widget == selectAllButton) - handleSelectAllButtonPressed(); - else if (evt.widget == deselectAllButton) - handleDeselectAllButtonPressed(); - else if (evt.widget == newModuleButton) - handleNewModuleButtonPressed(); - else - super.handleEvent(evt); - } - - /** - * - */ - private void handleNewModuleButtonPressed() { - IDataModel aModel = createNewModuleModel(); - DefaultJ2EEComponentCreationWizard wizard = new DefaultJ2EEComponentCreationWizard(aModel); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.create(); - if (dialog.open() != IDialogConstants.CANCEL_ID) { - IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot(); - moduleProjectsViewer.setInput(input); - setNewModules(aModel); - refreshModules(); - } - } - /** - * @param model - */ - private void setNewModules(IDataModel defaultModel) { - List newComponents = new ArrayList(); - collectNewComponents(defaultModel, newComponents); - List oldComponents = (List) getDataModel().getProperty(J2EE_PROJECTS_LIST); - newComponents.addAll(oldComponents); - getDataModel().setProperty(J2EE_PROJECTS_LIST, newComponents); - } - - private void collectNewComponents(IDataModel defaultModel, List newProjects) { - collectComponents(defaultModel.getNestedModel(IDefaultJ2EEComponentCreationDataModelProperties.NESTED_MODEL_EJB), newProjects); - collectComponents(defaultModel.getNestedModel(IDefaultJ2EEComponentCreationDataModelProperties.NESTED_MODEL_WEB), newProjects); - collectComponents(defaultModel.getNestedModel(IDefaultJ2EEComponentCreationDataModelProperties.NESTED_MODEL_CLIENT), newProjects); - collectComponents(defaultModel.getNestedModel(IDefaultJ2EEComponentCreationDataModelProperties.NESTED_MODEL_JCA), newProjects); - } - private void collectComponents(IDataModel compDM, List newProjects) { - if (compDM != null) { - String projectName = compDM.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME); - if(projectName == null) return; - IProject project = ProjectUtilities.getProject(projectName); - if (project != null && project.exists()) - newProjects.add(project); - } - } - - private IDataModel createNewModuleModel() { - IDataModel defaultModel = DataModelFactory.createDataModel(new DefaultJ2EEComponentCreationDataModelProvider()); - // transfer properties, project name - String projectName = model.getStringProperty(FACET_PROJECT_NAME); - defaultModel.setProperty(IDefaultJ2EEComponentCreationDataModelProperties.PROJECT_NAME, projectName); - // ear component name - String earName = model.getStringProperty(FACET_PROJECT_NAME); - defaultModel.setProperty(IDefaultJ2EEComponentCreationDataModelProperties.EAR_COMPONENT_NAME, earName); - // ear j2ee version - int j2eeVersion = getJ2EEVersion(); - defaultModel.setProperty(IDefaultJ2EEComponentCreationDataModelProperties.J2EE_VERSION, new Integer(j2eeVersion)); - - FacetedProjectWorkingCopy fpwc = (FacetedProjectWorkingCopy)model.getProperty(FACETED_PROJECT_WORKING_COPY); - IRuntime rt = fpwc.getPrimaryRuntime(); - defaultModel.setProperty(IDefaultJ2EEComponentCreationDataModelProperties.FACET_RUNTIME, rt); - - return defaultModel; - } - - /** - * - */ - private void handleDeselectAllButtonPressed() { - ignoreCheckedState = true; - try { - moduleProjectsViewer.setAllChecked(false); - //getDataModel().setProperty(J2EE_COMPONENT_LIST, null); - //IDataModel nestedModel = (IDataModel)getDataModel().getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - //(nestedModel).setProperty(AddComponentToEnterpriseApplicationDataModelProvider., getCheckedJ2EEElementsAsList()); - getDataModel().setProperty(J2EE_PROJECTS_LIST, null); - getDataModel().setProperty(JAVA_PROJECT_LIST, null); - } finally { - ignoreCheckedState = false; - } - } - - /** - * - */ - private void handleSelectAllButtonPressed() { - ignoreCheckedState = true; - try { - moduleProjectsViewer.setAllChecked(true); - //getDataModel().setProperty(J2EE_COMPONENT_LIST, getCheckedElementsAsList()); - //IDataModel nestedModel = (IDataModel)getDataModel().getProperty(NESTED_ADD_COMPONENT_TO_EAR_DM); - //(nestedModel).setProperty(AddComponentToEnterpriseApplicationDataModelProvider., getCheckedJ2EEElementsAsList()); - - getDataModel().setProperty(J2EE_PROJECTS_LIST, getCheckedJ2EEElementsAsList()); - getDataModel().setProperty(JAVA_PROJECT_LIST, getCheckedJavaProjectsAsList()); - - } finally { - ignoreCheckedState = false; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.J2EEWizardPage#enter() - */ - protected void enter() { - IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot(); - moduleProjectsViewer.setInput(input); - super.enter(); - } - - - private static final class Resources - - extends NLS - - { - public static String pageTitle; - public static String pageDescription; - public static String contentDirLabel; - public static String contentDirLabelInvalid; - - static { - initializeMessages(EarFacetInstallPage.class.getName(), Resources.class); - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.properties deleted file mode 100644 index 504feff8e..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarFacetInstallPage.properties +++ /dev/null @@ -1,14 +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 -############################################################################### -pageTitle = EAR Module -pageDescription = Configure EAR module settings. -contentDirLabel = Content directory: -contentDirLabelInvalid = Content directory (invalid): diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectFirstPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectFirstPage.java deleted file mode 100644 index afb1158df..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectFirstPage.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.ui.project.facet; - -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage; - -public class EarProjectFirstPage extends DataModelFacetCreationWizardPage { - - public EarProjectFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.EAR_WIZ_BANNER)); - setInfopopID(IJ2EEUIContextIds.NEW_EAR_WIZARD_P1); - } - - protected IDialogSettings getDialogSettings() { - return J2EEUIPlugin.getDefault().getDialogSettings(); - } - - protected String getModuleTypeID() { - return IModuleConstants.JST_EAR_MODULE; - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - final Composite top = super.createTopLevelComposite(parent); - createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET }); - return top; - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectWizard.java deleted file mode 100644 index 1d44e9a11..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarProjectWizard.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.ui.project.facet; - -import java.net.URL; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.project.facet.EARFacetProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; -import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; -import org.osgi.framework.Bundle; - -public class EarProjectWizard extends NewProjectDataModelFacetWizard { - - public EarProjectWizard(IDataModel model){ - super(model); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_WIZ_TITLE)); - } - - public EarProjectWizard(){ - super(); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.EAR_COMPONENT_WIZ_TITLE)); - } - - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new EARFacetProjectCreationDataModelProvider()); - } - - public void setRuntimeInDataModel(IRuntime runtime){ - model.setProperty(FACET_RUNTIME, runtime); - } - - protected ImageDescriptor getDefaultPageImageDescriptor() { - final Bundle bundle = Platform.getBundle("org.eclipse.jst.j2ee.ui"); - final URL url = bundle.getEntry("icons/ear-wiz-banner.gif"); - - return ImageDescriptor.createFromURL(url); - } - - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("template.jst.ear"); - } - - protected IWizardPage createFirstPage() { - return new EarProjectFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_EAR); - } - - public void setEARName( String earName ){ - model.setProperty(FACET_PROJECT_NAME, earName); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.java deleted file mode 100644 index f1ae976f5..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.java +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2006 BEA Systems, Inc. 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: - * Konstantin Komissarchik - initial API and implementation - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.project.facet; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider; -import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class EarSelectionPanel implements IWebFacetInstallDataModelProperties - -{ - private final Button addToEar; - private final Combo combo; - private final Button newButton; - private final Label label; - - private final IDataModel model; - private DataModelSynchHelper synchhelper; - - public EarSelectionPanel( final IDataModel model, final Composite parent) - { - this.model = model; - this.synchhelper = new DataModelSynchHelper(model); - - final Group group = new Group( parent, SWT.NONE ); - group.setLayoutData( gdhfill() ); - group.setLayout( new GridLayout( 3, false ) ); - group.setText( Resources.earMemberShip ); - - this.addToEar = new Button( group, SWT.CHECK ); - this.addToEar.setText( Resources.addToEarLabel ); - this.addToEar.setLayoutData( gdhspan( new GridData(), 3 ) ); - synchhelper.synchCheckbox(addToEar, ADD_TO_EAR, null); - - label = new Label(group, SWT.NULL); - label.setText(Resources.earProjectLabel); - this.combo = new Combo(group, SWT.NONE); - this.combo.setLayoutData( gdhfill() ); - - this.newButton = new Button( group, SWT.PUSH ); - this.newButton.setText( Resources.newButtonLabel ); - - this.newButton.addSelectionListener( new SelectionAdapter() - { - public void widgetSelected( final SelectionEvent event ) - { - handleAddButton(); - } - } ); - - synchhelper.synchCombo(combo, EAR_PROJECT_NAME, new Control[]{label, newButton}); - Dialog.applyDialogFont(parent); - } - - private void handleAddButton() - { - final EarProjectWizard wizard = new EarProjectWizard(); - - final WizardDialog dialog - = new WizardDialog( newButton.getShell(), wizard ); - - IRuntime runtime = (IRuntime)model.getProperty(FACET_RUNTIME); - String earName = model.getStringProperty( J2EEModuleFacetInstallDataModelProvider.EAR_PROJECT_NAME ); - wizard.setRuntimeInDataModel(runtime); - wizard.setEARName( earName ); - if( dialog.open() != SWT.CANCEL ) - { - model.notifyPropertyChange(EAR_PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - final String earproj = wizard.getProjectName(); - model.setProperty(EAR_PROJECT_NAME, earproj); - } - } - - private static GridData gdhfill() - { - return new GridData( GridData.FILL_HORIZONTAL ); - } - - public static final GridData gdhspan( final GridData gd, - final int span ) - { - gd.horizontalSpan = span; - return gd; - } - - private static final class Resources - - extends NLS - - { - public static String addToEarLabel; - public static String newButtonLabel; - public static String earProjectLabel; - public static String earMemberShip; - - static - { - initializeMessages( EarSelectionPanel.class.getName(), - Resources.class ); - } - } - - public void dispose() { - if(synchhelper != null){ - synchhelper.dispose(); - synchhelper = null; - } - } - - public String getComboText(){ - return combo.getText(); - } -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.properties deleted file mode 100644 index fb23380ff..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/EarSelectionPanel.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2006 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 -# SAP AG - adding keyboard shortcuts -############################################################################### -addToEarLabel = Add &project to an EAR -newButtonLabel = Ne&w... -earProjectLabel=EAR p&roject name: -earMemberShip=EAR membership diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.java deleted file mode 100644 index cf3d2628d..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.java +++ /dev/null @@ -1,188 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005-2007 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.project.facet; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.IMarkerResolution; -import org.eclipse.ui.IMarkerResolutionGenerator; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; -import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class RuntimeMismatchMarkerResolutions - - implements IMarkerResolutionGenerator - -{ - private static final String ATTR_RUNTIME1 = "runtime1"; //$NON-NLS-1$ - private static final String ATTR_RUNTIME2 = "runtime2"; //$NON-NLS-1$ - private static final String ATTR_MODULE_PROJECT = "moduleProject"; //$NON-NLS-1$ - - public IMarkerResolution[] getResolutions( final IMarker marker ) - { - final List resolutions = new ArrayList( 2 ); - - try - { - final IProject earProject = marker.getResource().getProject(); - final IFacetedProject earFacetedProject = ProjectFacetsManager.create( earProject ); - final IProject modProject = getModuleProject( marker ); - final IFacetedProject modFacetedProject = ProjectFacetsManager.create( modProject ); - - for( Iterator itr = getRuntimes( marker ).iterator(); itr.hasNext(); ) - { - final IRuntime runtime = (IRuntime) itr.next(); - - if( earFacetedProject.isTargetable( runtime ) && - modFacetedProject.isTargetable( runtime ) ) - { - final Resolution resolution - = new Resolution( earFacetedProject, modFacetedProject, runtime ); - - resolutions.add( resolution ); - } - } - } - catch( CoreException e ) - { - J2EEUIPlugin.logError( -1, null, e ); - } - - IMarkerResolution[] array = new IMarkerResolution[ resolutions.size() ]; - resolutions.toArray( array ); - - return array; - } - - private static IProject getModuleProject( final IMarker marker ) - { - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - final String moduleProjectName = marker.getAttribute( ATTR_MODULE_PROJECT, null ); - return ws.getRoot().getProject( moduleProjectName ); - } - - private static List getRuntimes( final IMarker marker ) - { - final List runtimes = new ArrayList(); - - IRuntime r = getRuntimeByName( marker.getAttribute( ATTR_RUNTIME1, null ) ); - if( r != null ) runtimes.add( r ); - - r = getRuntimeByName( marker.getAttribute( ATTR_RUNTIME2, null ) ); - if( r != null ) runtimes.add( r ); - - return runtimes; - } - - private static IRuntime getRuntimeByName( final String name ) - { - if( RuntimeManager.isRuntimeDefined( name ) ) - { - return RuntimeManager.getRuntime( name ); - } - else - { - return null; - } - } - - private static final class Resolution - - implements IMarkerResolution - - { - private final IFacetedProject earProject; - private final IFacetedProject moduleProject; - private final IRuntime runtime; - - public Resolution( final IFacetedProject earProject, - final IFacetedProject moduleProject, - final IRuntime runtime ) - { - this.earProject = earProject; - this.moduleProject = moduleProject; - this.runtime = runtime; - } - - public String getLabel() - { - return NLS.bind( Resources.useSameRuntime, this.runtime.getLocalizedName() ); - } - - public void run( final IMarker marker ) - { - try - { - setRuntime( this.earProject, this.runtime ); - setRuntime( this.moduleProject, this.runtime ); - } - catch( CoreException e ) - { - ErrorDialog.openError( null, Resources.errorDialogTitle, - Resources.errorDialogMessage, e.getStatus() ); - } - } - - private void setRuntime( final IFacetedProject fproj, - final IRuntime runtime ) - - throws CoreException - - { - final IRuntime currentPrimaryRuntime = fproj.getPrimaryRuntime(); - - if( currentPrimaryRuntime != null && - ! currentPrimaryRuntime.getName().equals( runtime.getName() ) ) - { - if( ! fproj.isTargeted( runtime ) ) - { - fproj.addTargetedRuntime( runtime, null ); - } - - fproj.setPrimaryRuntime( runtime, null ); - } - } - } - - private static final class Resources - - extends NLS - - { - public static String useSameRuntime; - public static String errorDialogTitle; - public static String errorDialogMessage; - - static - { - initializeMessages( RuntimeMismatchMarkerResolutions.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.properties deleted file mode 100644 index f8b03d64b..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/RuntimeMismatchMarkerResolutions.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2007 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 -############################################################################### -useSameRuntime = Switch both projects to {0} -errorDialogTitle = Error -errorDialogMessage = Failed while applying the quick fix.
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.java deleted file mode 100644 index 1bd587775..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 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.ui.project.facet; - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentFacetCreationWizardPage; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class UtilityProjectFirstPage extends J2EEComponentFacetCreationWizardPage { - - public UtilityProjectFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(Resources.pageTitle); - setDescription(Resources.pageDescription); - setInfopopID(IJ2EEUIContextIds.NEW_UTILITY_WIZARD_P1); - } - - private static final class Resources extends NLS { - public static String pageTitle; - public static String pageDescription; - - static { - initializeMessages(UtilityProjectFirstPage.class.getName(), Resources.class); - } - } - - protected String getModuleFacetID() { - return J2EEProjectUtilities.UTILITY; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.properties b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.properties deleted file mode 100644 index 0a6de07aa..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectFirstPage.properties +++ /dev/null @@ -1,12 +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 -############################################################################### -pageTitle = Utility Module -pageDescription = Configure utility module settings.
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectWizard.java deleted file mode 100644 index 5ab42cdf7..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/UtilityProjectWizard.java +++ /dev/null @@ -1,68 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.j2ee.ui.project.facet; - -import java.net.URL; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.project.facet.UtilityProjectCreationDataModelProvider; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; -import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; -import org.osgi.framework.Bundle; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public class UtilityProjectWizard extends NewProjectDataModelFacetWizard { - - public UtilityProjectWizard(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVAUTIL_COMPONENT_WIZ_TITLE)); - } - - public UtilityProjectWizard(){ - super(); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.JAVAUTIL_COMPONENT_WIZ_TITLE)); - } - - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new UtilityProjectCreationDataModelProvider()); - } - - protected ImageDescriptor getDefaultPageImageDescriptor() { - final Bundle bundle = Platform.getBundle("org.eclipse.jst.j2ee.ui"); - final URL url = bundle.getEntry("icons/util-wiz-banner.gif"); - return ImageDescriptor.createFromURL(url); - } - - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("template.jst.utility"); - } - - protected IWizardPage createFirstPage() { - return new UtilityProjectFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_UTILITY); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientFacetInstallPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientFacetInstallPage.java deleted file mode 100644 index 84b58ab5c..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientFacetInstallPage.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.jst.j2ee.ui.project.facet.appclient; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.wizard.J2EEModuleFacetInstallPage; -import org.eclipse.jst.j2ee.project.facet.IAppClientFacetInstallDataModelProperties; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public class AppClientFacetInstallPage extends J2EEModuleFacetInstallPage implements IAppClientFacetInstallDataModelProperties { - - private Button createMainClass; - - public AppClientFacetInstallPage() { - super("appclient.facet.install.page"); //$NON-NLS-1$ - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_PROJECT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_SETTINGS)); - } - - protected String[] getValidationPropertyNames() { - return new String[]{EAR_PROJECT_NAME, CONFIG_FOLDER, CREATE_DEFAULT_MAIN_CLASS}; - } - - protected Composite createTopLevelComposite(Composite parent) { - setInfopopID(IJ2EEUIContextIds.NEW_APPCLIENT_WIZARD_P3); - final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - - createMainClass = new Button(composite, SWT.CHECK); - createMainClass.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_CREATE_MAIN)); - synchHelper.synchCheckbox(createMainClass, CREATE_DEFAULT_MAIN_CLASS, null); - - createGenerateDescriptorControl( composite ); - registerFacetVersionChangeListener(); - - Dialog.applyDialogFont(parent); - return composite; - } - - protected void handleFacetVersionChangedEvent() - { - final IProjectFacetVersion fv = (IProjectFacetVersion) this.model.getProperty( FACET_VERSION ); - this.addDD.setVisible( fv == APPLICATION_CLIENT_50 ); - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectFirstPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectFirstPage.java deleted file mode 100644 index 5375bd996..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectFirstPage.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.ui.project.facet.appclient; - -import org.eclipse.jst.j2ee.internal.actions.IJ2EEUIContextIds; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentFacetCreationWizardPage; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class AppClientProjectFirstPage extends J2EEComponentFacetCreationWizardPage { - - public AppClientProjectFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_PROJECT_MAIN_PG_TITLE)); - setDescription(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_PROJECT_MAIN_PG_DESC)); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.APP_CLIENT_PROJECT_WIZARD_BANNER)); - setInfopopID(IJ2EEUIContextIds.NEW_APPCLIENT_WIZARD_P1); - } - - protected String getModuleFacetID() { - return J2EEProjectUtilities.APPLICATION_CLIENT; - } - -} diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectWizard.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectWizard.java deleted file mode 100644 index cd2fa74cc..000000000 --- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/ui/project/facet/appclient/AppClientProjectWizard.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.ui.project.facet.appclient; - -import java.net.URL; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientFacetProjectCreationDataModelProvider; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.project.facet.IProductConstants; -import org.eclipse.wst.project.facet.ProductManager; -import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard; -import org.osgi.framework.Bundle; - -public class AppClientProjectWizard extends NewProjectDataModelFacetWizard { - - public AppClientProjectWizard(IDataModel model) { - super(model); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_PROJECT_WIZ_TITLE)); - } - - public AppClientProjectWizard() { - super(); - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.APP_CLIENT_PROJECT_WIZ_TITLE)); - } - - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new AppClientFacetProjectCreationDataModelProvider()); - } - - protected ImageDescriptor getDefaultPageImageDescriptor() { - final Bundle bundle = Platform.getBundle(J2EEUIPlugin.PLUGIN_ID); - final URL url = bundle.getEntry("icons/full/wizban/appclient_wiz.gif"); //$NON-NLS-1$ - return ImageDescriptor.createFromURL(url); - } - - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("template.jst.appclient"); //$NON-NLS-1$ - } - - protected IWizardPage createFirstPage() { - return new AppClientProjectFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_APPCLIENT); - } - -} |