diff options
Diffstat (limited to 'plugins/org.eclipse.jst.servlet.ui/servlet_ui/org')
63 files changed, 0 insertions, 8583 deletions
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/IWebUIContextIds.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/IWebUIContextIds.java deleted file mode 100644 index caba8168d..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/IWebUIContextIds.java +++ /dev/null @@ -1,37 +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.servlet.ui; - -public interface IWebUIContextIds { - -public static final String PLUGIN_SERVLET_UI = "org.eclipse.jst.servlet.ui."; //$NON-NLS-1$ - - public static final String NEW_DYNAMIC_WEB_PROJECT_PAGE1 = PLUGIN_SERVLET_UI + "webw1000"; //$NON-NLS-1$ - public static final String NEW_DYNAMIC_WEB_PROJECT_PAGE2 = PLUGIN_SERVLET_UI + "webw1100"; //$NON-NLS-1$ - public static final String NEW_DYNAMIC_WEB_PROJECT_PAGE3 = PLUGIN_SERVLET_UI + "webw1200"; //$NON-NLS-1$ - - public static final String WAR_IMPORT_PAGE1 = PLUGIN_SERVLET_UI + "webi1000"; //$NON-NLS-1$ - public static final String WAR_IMPORT_PAGE2 = PLUGIN_SERVLET_UI + "webi1100"; //$NON-NLS-1$ - - public static final String WAR_EXPORT_PAGE1 = PLUGIN_SERVLET_UI + "webe1000"; //$NON-NLS-1$ - - public static final String WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_1 = PLUGIN_SERVLET_UI + "srvw1050"; //$NON-NLS-1$ - public static final String WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_2 = PLUGIN_SERVLET_UI + "srvw1100"; //$NON-NLS-1$ - public static final String WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_3 = PLUGIN_SERVLET_UI + "srvw1200"; //$NON-NLS-1$ - - public static final String WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_1 = PLUGIN_SERVLET_UI + "lstw1050"; //$NON-NLS-1$ - public static final String WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_2 = PLUGIN_SERVLET_UI + "lstw1100"; //$NON-NLS-1$ - public static final String WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_3 = PLUGIN_SERVLET_UI + "lstw1200"; //$NON-NLS-1$ - - public static final String WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_1 = PLUGIN_SERVLET_UI + "fltw1050"; //$NON-NLS-1$ - public static final String WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_2 = PLUGIN_SERVLET_UI + "fltw1100"; //$NON-NLS-1$ - public static final String WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_3 = PLUGIN_SERVLET_UI + "fltw1200"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java deleted file mode 100644 index c91a2c8a2..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java +++ /dev/null @@ -1,153 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2009 Red Hat, IBM - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Rob Stryker - initial implementation and ongoing maintenance - * Chuck Bridgham - Ongoing improvements - ******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.swt.SWT; -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.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.ui.internal.propertypage.ProjectReferenceWizardFragment; -import org.eclipse.wst.common.componentcore.ui.internal.taskwizard.IWizardHandle; - -public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWizardFragment { - - public CustomWebProjectReferenceWizardFragment() { - super(); - // TODO Auto-generated constructor stub - } - - private boolean isWebLib; - private Button button; - private Composite tableColumnComposite; - - @Override - public Composite createComposite(Composite parent, IWizardHandle handle) { - - handle.setTitle(org.eclipse.wst.common.componentcore.ui.Messages.ProjectReferenceTitle); - handle.setDescription(Messages.getString("WebProjectReferenceDescription")); //$NON-NLS-1$ - Composite c = newComposite(parent); - - createTable(c); - createButtonColumn(c); - return c; - } - private void createTable(Composite c) { - - tableColumnComposite = createTableColumnComposite(c); - - viewer = new TreeViewer(tableColumnComposite, SWT.MULTI | SWT.BORDER); - viewer.setContentProvider(getContentProvider()); - viewer.setLabelProvider(getLabelProvider()); - - - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - selChanged(); - } - }); - viewer.setInput(ResourcesPlugin.getWorkspace()); - } - - protected void createButtonColumn(Composite parent) { - - - button = new Button(parent, SWT.CHECK); - button.setText(Messages.getString("CustomWebProjectReferenceWizardFragment.0")); //$NON-NLS-1$ - button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - button.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - handleEdit(); - } - }); - } -// 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_FILL); -// aButtonColumn.setLayoutData(data); -// return aButtonColumn; -// } - public Composite createTableColumnComposite(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.FILL_BOTH); - //data.minimumHeight = 500; - //data.minimumWidth = 400; - aButtonColumn.setLayoutData(data); - return aButtonColumn; - } - - protected void handleEdit() { - isWebLib = button.getSelection(); - } - private Composite newComposite(Composite parent) { - Composite c = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 0; - c.setLayout(layout); - c.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); - return c; - } - - - @Override - protected String getArchiveName(IProject proj, IVirtualComponent comp) { - // TODO Auto-generated method stub - String name = super.getArchiveName(proj, comp); - if (isWebLib) - name = new Path(J2EEConstants.WEB_INF_LIB).append(name).makeAbsolute().toString(); - - return name; - } - - @Override - public void performFinish(IProgressMonitor monitor) throws CoreException { - for (int i = 0; i < selected.length; i++) { - IProject proj = selected[i]; - if(!JavaEEProjectUtilities.isUtilityProject(proj)) - { - J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(proj).execute(monitor, null); - } - } - super.performFinish(monitor); - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java deleted file mode 100644 index 4682d9fa7..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.eclipse.jst.servlet.ui.internal; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.servlet.ui.internal.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java deleted file mode 100644 index 2ccb4b609..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java +++ /dev/null @@ -1,201 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2009 Red Hat - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Rob Stryker - initial implementation and ongoing maintenance - ******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage; -import org.eclipse.jst.j2ee.internal.ui.preferences.Messages; -import org.eclipse.jst.j2ee.project.EarUtilities; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties; -import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.ui.ModuleCoreUIPlugin; -import org.eclipse.wst.common.componentcore.ui.internal.propertypage.DependencyPageExtensionManager; -import org.eclipse.wst.common.componentcore.ui.internal.propertypage.DependencyPageExtensionManager.ReferenceExtension; -import org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPage { - -// protected Button addWebLibRefButton; -// private boolean addingWebLib = true; - public WebDependencyPropertyPage(IProject project, - ModuleAssemblyRootPage page) { - super(project, page); - } - - - @Override - protected void createPushButtons() { - - addMappingButton = createPushButton(getAddFolderLabel()); - addReferenceButton = createPushButton(getAddReferenceLabel()); - //addWebLibRefButton = createPushButton(getAddWebLibRefLabel()); - editReferenceButton = createPushButton(getEditReferenceLabel()); - removeButton = createPushButton(getRemoveSelectedLabel()); - - } - - protected String getAddWebLibRefLabel() { - - return Messages.WebDependencyPropertyPage_0; - } - - @Override - protected String getModuleAssemblyRootPageDescription() { - - return Messages.WebDependencyPropertyPage_1; - } - - - @Override - protected StringBuffer getCompsForManifest(ArrayList<IVirtualComponent> components) { - StringBuffer newComps = new StringBuffer(); - for (Iterator iterator = components.iterator(); iterator.hasNext();) { - IVirtualComponent comp = (IVirtualComponent) iterator.next(); - String runtimePath = objectToRuntimePath.get(comp); - if (runtimePath == null) - runtimePath = derivedRefsObjectToRuntimePath.get(comp); - if (runtimePath.indexOf(J2EEConstants.WEB_INF_LIB) == -1) { - String archiveName = new Path(runtimePath).lastSegment(); - newComps.append(archiveName); - newComps.append(' '); - } - } - return newComps; - } - - @Override - protected ReferenceExtension[] filterReferenceTypes(ReferenceExtension[] defaults) { - // Replace the default one with our own custom one, in class CustomWebProjectReferenceWizardFragment - for( int i = 0; i < defaults.length; i++ ) { - if( defaults[i].getId().equals("org.eclipse.wst.common.componentcore.ui.newProjectReference")) { //$NON-NLS-1$ - defaults[i] = DependencyPageExtensionManager.getManager().findReferenceExtension("org.eclipse.jst.servlet.ui.internal.CustomWebProjectReferenceWizardFragment"); //$NON-NLS-1$ - } - } - return defaults; - } - protected IDataModelProvider getAddWebReferenceDataModelProvider(IVirtualComponent component) { - return new CreateReferenceComponentsDataModelProvider(); - } - - - @Override - protected void insertIntoTable(boolean consumed, IVirtualComponent[] compArr, String[] pathArr) { - - for( int i = 0; i < compArr.length; i++ ) { - if (pathArr[i].indexOf(J2EEConstants.WEB_INF_LIB) == -1) - derivedRefsObjectToRuntimePath.put(compArr[i],getRuntimePath(compArr[i], pathArr[i])); - else - objectToRuntimePath.put(compArr[i],getRuntimePath(compArr[i], pathArr[i])); - if( consumed ) - consumedReferences.add(compArr[i]); - } - } - @Override - protected void removeComponents(ArrayList<IVirtualComponent> removed) { - Iterator<IVirtualComponent> i = removed.iterator(); - while(i.hasNext()) { - removeOneComponent(i.next()); - } - } - - - @Override - protected void addOneComponent(IVirtualComponent component) throws CoreException { - - - String runtimePath = objectToRuntimePath.get(component); - if (runtimePath == null) - runtimePath = derivedRefsObjectToRuntimePath.get(component); - if (runtimePath.indexOf(J2EEConstants.WEB_INF_LIB) != -1) { - addWebRef(component); - return; - } - - - String path, archiveName; - path = new Path(derivedRefsObjectToRuntimePath.get(component)).removeLastSegments(1).toString(); - archiveName = new Path(derivedRefsObjectToRuntimePath.get(component)).lastSegment(); - - - //Find the Ear's that contain this component - IProject[] earProjects = EarUtilities.getReferencingEARProjects(rootComponent.getProject()); - for (int i = 0; i < earProjects.length; i++) { - IProject project = earProjects[i]; - - IDataModelProvider provider = getAddReferenceDataModelProvider(component); - IDataModel dm = DataModelFactory.createDataModel(provider); - - dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, ComponentCore.createComponent(project)); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component)); - - //[Bug 238264] the uri map needs to be manually set correctly - Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>(); - uriMap.put(component, archiveName); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap); - 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(new NullProgressMonitor(), null); - } catch (ExecutionException e) { - ModuleCoreUIPlugin.logError(e); - } - } - - } - - - private void addWebRef(IVirtualComponent component) throws CoreException { - String path, archiveName; - path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString(); - archiveName = new Path(objectToRuntimePath.get(component)).lastSegment(); - - IDataModelProvider provider = getAddWebReferenceDataModelProvider(component); - IDataModel dm = DataModelFactory.createDataModel(provider); - - dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component)); - - //[Bug 238264] the uri map needs to be manually set correctly - Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>(); - uriMap.put(component, archiveName); - dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap); - 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(new NullProgressMonitor(), null); - } catch (ExecutionException e) { - ModuleCoreUIPlugin.logError(e); - } - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java deleted file mode 100644 index 38c91b827..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2009 Red Hat, IBM - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Rob Stryker - initial implementation and ongoing maintenance - * Chuck Bridgham - Additional support - ******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.internal.ui.Messages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider; -import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl; -import org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -public class WebModuleDependencyPageProvider implements IDependencyPageProvider { - - public boolean canHandle(IFacetedProject project) { - boolean isWeb = project.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE)); - return isWeb; - } - - public IModuleDependenciesControl[] createPages(IFacetedProject project, - ModuleAssemblyRootPage parent) { - return new IModuleDependenciesControl[] { - new WebDependencyPropertyPage(project.getProject(), parent) - }; - } - - public Composite createRootControl(IFacetedProject project,IModuleDependenciesControl[] pages, - Composite parent) { - if( pages.length == 1 && pages[0] != null) - return pages[0].createContents(parent); - return null; - } - -public String getPageTitle(IProject project) { - return Messages.J2EEDependencyPageProvider_0; - } - - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/ConvertToWebModuleTypeAction.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/ConvertToWebModuleTypeAction.java deleted file mode 100644 index fdf1f5141..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/ConvertToWebModuleTypeAction.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.eclipse.jst.servlet.ui.internal.actions; - -/******************************************************************************* - * 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 - *******************************************************************************/ - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.NullProgressMonitor; -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.jface.window.Window; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.j2ee.web.datamodel.properties.IConvertStaticWebToDyamnicDataModelProperties; -import org.eclipse.jst.servlet.ui.internal.wizard.ConvertToWebModuleTypeDialog; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.web.ui.internal.Logger; - -/** - * Convert a simple static web project to a J2EE Dynamic Web Project - */ -public class ConvertToWebModuleTypeAction extends Action implements IWorkbenchWindowActionDelegate { - - IStructuredSelection fSelection = null; - IProject project = null; - IWorkbenchWindow fWindow; - - /** - * ConvertLinksDialog constructor comment. - */ - public ConvertToWebModuleTypeAction() { - super(); - } - - /** - * make sure a web project is selected. - */ - protected boolean isValidProject(IProject aProject) { - return JavaEEProjectUtilities.isStaticWebProject(aProject); - } - - /** - * selectionChanged method comment. - */ - public void selectionChanged(IAction action, ISelection selection) { - boolean bEnable = false; - if (selection instanceof IStructuredSelection) { - fSelection = (IStructuredSelection) selection; - bEnable = validateSelected(fSelection); - } - ((Action) action).setEnabled(bEnable); - } - - /** - * selectionChanged method comment. - */ - protected boolean validateSelected(ISelection selection) { - if (!(selection instanceof IStructuredSelection)) - return false; - - fSelection = (IStructuredSelection) selection; - - Object selectedProject = fSelection.getFirstElement(); - if (!(selectedProject instanceof IProject)) - return false; - - project = (IProject) selectedProject; - return isValidProject(project); - } - - public void dispose() { - // Default - } - - public void init(IWorkbenchWindow window) { - // Default - } - - public void run(IAction action) { - try { - IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; - ConvertToWebModuleTypeDialog dialog = new ConvertToWebModuleTypeDialog(window.getShell()); - dialog.open(); - if (dialog.getReturnCode() == Window.CANCEL) - return; - - doConvert(ConvertToWebModuleTypeDialog.getSelectedVersion()); - - } catch (Exception e) { - Logger.logException(e); - } - } - - protected void doConvert(String selectedVersion) throws Exception { - - IDataModel model = DataModelFactory.createDataModel(IConvertStaticWebToDyamnicDataModelProperties.class); - model.setProperty(IConvertStaticWebToDyamnicDataModelProperties.PROJECT, project); - model.setStringProperty(IConvertStaticWebToDyamnicDataModelProperties.CONVERT_TO_WEB_VERSION, ConvertToWebModuleTypeDialog.getSelectedVersion()); - model.getDefaultOperation().execute(new NullProgressMonitor(), null); - - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/NewWebComponentAction.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/NewWebComponentAction.java deleted file mode 100644 index 61d934a33..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/actions/NewWebComponentAction.java +++ /dev/null @@ -1,54 +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.servlet.ui.internal.actions; - -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.j2ee.internal.actions.AbstractOpenWizardWorkbenchAction; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard; -import org.eclipse.ui.IWorkbench; - -public class NewWebComponentAction extends AbstractOpenWizardWorkbenchAction { - - public static String LABEL = WEBUIMessages.WEB_MODULE_WIZ_TITLE; - private static final String ICON = "war_wiz"; //$NON-NLS-1$ - - public NewWebComponentAction() { - super(); - setText(LABEL); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewWebComponentAction(IWorkbench workbench, String label, Class[] activatedOnTypes, boolean acceptEmptySelection) { - super(workbench, label, activatedOnTypes, acceptEmptySelection); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - public NewWebComponentAction(IWorkbench workbench, String label, boolean acceptEmptySelection) { - super(workbench, label, acceptEmptySelection); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(ICON)); - } - - @Override - protected Wizard createWizard() { - return new WebProjectWizard(); - } - - @Override - protected boolean shouldAcceptElement(Object obj) { - return true; /* NewGroup.isOnBuildPath(obj) && !NewGroup.isInArchive(obj); */ - } - @Override - protected String getDialogText() { - return null; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/deployables/WebDeployableArtifactAdapterFactory.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/deployables/WebDeployableArtifactAdapterFactory.java deleted file mode 100644 index cccad87e5..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/deployables/WebDeployableArtifactAdapterFactory.java +++ /dev/null @@ -1,35 +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.servlet.ui.internal.deployables; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.ui.actions.ILaunchable; -import org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactUtil; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; - -public class WebDeployableArtifactAdapterFactory extends ModuleArtifactAdapterDelegate implements IAdapterFactory { - - public Object getAdapter(Object adaptableObject, Class adapterType) { - return null; - } - - public Class[] getAdapterList() { - return new Class[]{ILaunchable.class}; - } - - - @Override - public IModuleArtifact getModuleArtifact(Object obj) { - return WebDeployableArtifactUtil.getModuleObject(obj); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties deleted file mode 100644 index 62b854c70..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -CustomWebProjectReferenceWizardFragment.0=Web Library Reference -WebProjectReferenceDescription=Here you can make a project into a reference.\nIf the project is not already a flexible project, it will be converted into one. References are added to the MANIFEST.MF diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaLibraries.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaLibraries.java deleted file mode 100644 index 53638030c..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaLibraries.java +++ /dev/null @@ -1,79 +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.servlet.ui.internal.navigator; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.swt.graphics.Image; - -public class CompressedJavaLibraries implements ICompressedNode { - - - private CompressedJavaProject compressedProject; - private Image image; - - public CompressedJavaLibraries(CompressedJavaProject compressedProject) { - this.compressedProject = compressedProject; - } - - public Image getImage() { - if(image == null) { - image = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY); - } - return image; - } - - public String getLabel() { - return WEBUIMessages.Compressed_Libraries; - } - - public Object[] getChildren(ITreeContentProvider delegateContentProvider) { - - List classpathContainers = new ArrayList(); - Object[] delegateChildren = delegateContentProvider.getChildren(compressedProject.getProject()); - for (int i = 0; i < delegateChildren.length; i++) { - if (delegateChildren[i] instanceof IPackageFragmentRoot) { - try { - IClasspathEntry rawClasspathEntry = ((IPackageFragmentRoot) delegateChildren[i]).getRawClasspathEntry(); - if (rawClasspathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && - rawClasspathEntry.getEntryKind() != IClasspathEntry.CPE_SOURCE) - classpathContainers.add(delegateChildren[i]); - } catch (JavaModelException e) { - - } - } else if (!(delegateChildren[i] instanceof IJavaElement) && !(delegateChildren[i] instanceof IResource)) { - classpathContainers.add(delegateChildren[i]); - } - } - return classpathContainers.toArray(); - } - - public CompressedJavaProject getCompressedProject() { - return compressedProject; - } - - public IJavaElement getJavaElement() { - return null; - } - - - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaProject.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaProject.java deleted file mode 100644 index 94f025d8b..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaProject.java +++ /dev/null @@ -1,124 +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.servlet.ui.internal.navigator; - -import java.util.ArrayList; -import java.util.Arrays; -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.core.runtime.Platform; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.graphics.Image; - -public class CompressedJavaProject implements ICompressedNode, IAdaptable { - - private IProject project; - private CompressedJavaLibraries compressedLibraries; - private Image image; - - public CompressedJavaProject(StructuredViewer viewer, IProject project) { - this.project = project; - - } - - public Image getImage() { - if(image == null) - image = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKFRAG_ROOT); - return image; - } - - public String getLabel() { - return determineLabel(); - - } - - public boolean isFlatteningSourceFolder() { - return getNonExternalSourceFolders().size() == 1; - } - - private String determineLabel() { - List nonextSourceFolders = getNonExternalSourceFolders(); - IPackageFragmentRoot singleRoot = null; - if (nonextSourceFolders.size() == 1) { - singleRoot = (IPackageFragmentRoot) nonextSourceFolders.get(0); - } - return NLS.bind(WEBUIMessages.Compressed_JavaResources, ((singleRoot != null) ? ": " + singleRoot.getElementName() : "")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public IProject getProject() { - return project; - } - - public Object[] getChildren(ITreeContentProvider delegateContentProvider) { - - List nonExternalSourceFolders = getNonExternalSourceFolders(); - if (nonExternalSourceFolders.size() == 1) { - Object[] sourceFolderChildren = delegateContentProvider.getChildren(nonExternalSourceFolders.get(0)); - nonExternalSourceFolders.clear(); - nonExternalSourceFolders.addAll(Arrays.asList(sourceFolderChildren)); - } - nonExternalSourceFolders.add(getCompressedJavaLibraries()); - return nonExternalSourceFolders.toArray(); - } - - public List getNonExternalSourceFolders() { - List nonExternalSourceFolders = null; - IPackageFragmentRoot[] sourceFolders; - try { - IJavaProject jProject = JavaCore.create(project); - sourceFolders = jProject.getPackageFragmentRoots(); - nonExternalSourceFolders = new ArrayList(Arrays.asList(sourceFolders)); - for (Iterator iter = nonExternalSourceFolders.iterator(); iter.hasNext();) { - IPackageFragmentRoot root = (IPackageFragmentRoot) iter.next(); - if (root.isExternal() || root.isArchive() || root.getKind()==IPackageFragmentRoot.K_BINARY) - iter.remove(); - } - } catch (JavaModelException e) { - ServletUIPlugin.log(e); - } - return nonExternalSourceFolders != null ? nonExternalSourceFolders : Collections.EMPTY_LIST; - } - - public CompressedJavaLibraries getCompressedJavaLibraries() { - if(compressedLibraries == null) - compressedLibraries = new CompressedJavaLibraries(this); - return compressedLibraries; - - } - - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - public IJavaElement getJavaElement() { - List nonExternalSourceFolders = getNonExternalSourceFolders(); - if (nonExternalSourceFolders.size() == 1) { - return (IJavaElement) nonExternalSourceFolders.get(0); - } - return JavaCore.create(project); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaSorter.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaSorter.java deleted file mode 100644 index 4ee9c12fe..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedJavaSorter.java +++ /dev/null @@ -1,38 +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.servlet.ui.internal.navigator; - -import org.eclipse.jdt.ui.JavaElementSorter; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; - -public class CompressedJavaSorter extends ViewerSorter { - - private JavaElementSorter sorter = new JavaElementSorter(); - - @Override - public int category(Object element) { - if(element instanceof CompressedJavaLibraries) - return 1; - return 0; - } - - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - if(e1 instanceof CompressedJavaLibraries) - return 1; - else if(e2 instanceof CompressedJavaLibraries) - return -1; - - return sorter.compare(viewer, e1, e2); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedNodeAdapterFactory.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedNodeAdapterFactory.java deleted file mode 100644 index a73b08564..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/CompressedNodeAdapterFactory.java +++ /dev/null @@ -1,40 +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.servlet.ui.internal.navigator; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; - -// -public class CompressedNodeAdapterFactory implements IAdapterFactory { - - private static final Class IJAVA_PROJECT_CLASS = IJavaProject.class; - private static final Class IJAVA_ELEMENT_CLASS = IJavaElement.class; - - private static final Class[] ADAPTER_LIST = new Class[] { IJAVA_PROJECT_CLASS }; - - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(adaptableObject instanceof CompressedJavaProject) { - if(adapterType == IJAVA_PROJECT_CLASS) { - return ((CompressedJavaProject)adaptableObject).getProject(); - } else if (adapterType == IJAVA_ELEMENT_CLASS) { - return ((CompressedJavaProject)adaptableObject).getJavaElement(); - } - } - return null; - } - - public Class[] getAdapterList() { - return ADAPTER_LIST; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/ICompressedNode.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/ICompressedNode.java deleted file mode 100644 index 7d1bb736a..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/ICompressedNode.java +++ /dev/null @@ -1,50 +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.servlet.ui.internal.navigator; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.swt.graphics.Image; - -/** - * - * Provides a simple interface that is used to manipulate the rendering of Java elements to a format - * that is friendlier for Web Projects. - * - */ -public interface ICompressedNode { - /** - * - * @return The image to display for this node. - */ - public Image getImage(); - - /** - * - * @return The text label to display for this node. - */ - public String getLabel(); - - /** - * - * @param delegateContentProvider - * The content provider that should used for any children that I cannot provide - * children for. - * @return The children either from me or the delegateContentProvider. - */ - public Object[] getChildren(ITreeContentProvider delegateContentProvider); - - /** - * - * @return The Java element associated with this node, if any. - */ - public IJavaElement getJavaElement(); -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaContentProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaContentProvider.java deleted file mode 100644 index 5a76c8542..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaContentProvider.java +++ /dev/null @@ -1,299 +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.servlet.ui.internal.navigator; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.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.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.navigator.CommonViewer; -import org.eclipse.ui.navigator.ICommonContentExtensionSite; -import org.eclipse.ui.navigator.INavigatorContentExtension; -import org.eclipse.ui.navigator.INavigatorContentService; -import org.eclipse.ui.navigator.IPipelinedTreeContentProvider; -import org.eclipse.ui.navigator.PipelinedShapeModification; -import org.eclipse.ui.navigator.PipelinedViewerUpdate; - -public class WebJavaContentProvider implements IPipelinedTreeContentProvider { - - private static final Object[] NO_CHILDREN = new Object[0]; - private static final String JAVA_EXTENSION_ID = "org.eclipse.jdt.java.ui.javaContent"; //$NON-NLS-1$ - - /* - * JDT likes to make it interesting so just one of their viewer types is made internal To avoid - * the dependency, we use some reflection here to filter the type. - */ - - private static Class INTERNAL_CONTAINER_CLASS; - static { - try { - INTERNAL_CONTAINER_CLASS = Class.forName("org.eclipse.jdt.internal.ui.packageview.ClassPathContainer"); //$NON-NLS-1$ - } catch (Throwable t) { - // ignore if the class has been removed or renamed. - INTERNAL_CONTAINER_CLASS = null; - } - } - - - private CommonViewer commonViewer; - private ITreeContentProvider delegateContentProvider; - private final Map compressedNodes = new HashMap(); - - public void getPipelinedChildren(Object aParent, Set theCurrentChildren) { - try { - if (aParent instanceof IProject && ((IProject)aParent).hasNature(JavaCore.NATURE_ID) && JavaEEProjectUtilities.isDynamicWebProject((IProject)aParent)) { - cleanJavaContribution(theCurrentChildren); - theCurrentChildren.add(getCompressedNode((IProject)aParent)); - } - } catch (CoreException e) { - ServletUIPlugin.log(e); - } - } - - private void cleanJavaContribution(Set theCurrentChildren) { - IJavaElement element = null; - for (Iterator iter = theCurrentChildren.iterator(); iter.hasNext();) { - Object child = iter.next(); - if (child instanceof IResource && ((element = JavaCore.create((IResource) child)) != null) && element.exists()) - iter.remove(); - else if (child instanceof IJavaElement) - iter.remove(); - else if (INTERNAL_CONTAINER_CLASS != null && INTERNAL_CONTAINER_CLASS.isInstance(child)) - iter.remove(); - } - } - - private CompressedJavaProject getCompressedNode(IProject project) { - if (!JavaEEProjectUtilities.isDynamicWebProject(project)) - return null; - CompressedJavaProject result = (CompressedJavaProject) compressedNodes.get(project); - if (result == null) { - compressedNodes.put(project, result = new CompressedJavaProject(commonViewer, project)); - } - return result; - } - - public void getPipelinedElements(Object anInput, Set theCurrentElements) { - - } - - public Object getPipelinedParent(Object anObject, Object aSuggestedParent) { - - try { - if (anObject instanceof IPackageFragmentRoot) { - IPackageFragmentRoot root = (IPackageFragmentRoot) anObject; - if (!root.isExternal()) { - if( aSuggestedParent instanceof IJavaProject ) { - return getCompressedNode( ((IJavaProject) aSuggestedParent).getProject() ); - } else if ( aSuggestedParent instanceof IProject && ((IProject)aSuggestedParent).hasNature(JavaCore.NATURE_ID) && JavaEEProjectUtilities.isDynamicWebProject((IProject)aSuggestedParent) ){ - return getCompressedNode( ((IProject) aSuggestedParent) ); - } - } - } else if(INTERNAL_CONTAINER_CLASS.isInstance(anObject)) { - if( aSuggestedParent instanceof IJavaProject ) { - return getCompressedNode( ((IJavaProject) aSuggestedParent).getProject() ).getCompressedJavaLibraries(); - } else if ( aSuggestedParent instanceof IProject && ((IProject)aSuggestedParent).hasNature(JavaCore.NATURE_ID) && JavaEEProjectUtilities.isDynamicWebProject((IProject)aSuggestedParent)){ - return getCompressedNode( ((IProject) aSuggestedParent) ).getCompressedJavaLibraries(); - } - } - } catch (CoreException e) { - ServletUIPlugin.log(e); - } - - return null; - } - - public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) { - Object parent = anAddModification.getParent(); - - if (parent instanceof IPackageFragmentRoot) { - IPackageFragmentRoot sourceFolder = (IPackageFragmentRoot) parent; - if (JavaEEProjectUtilities.isDynamicWebProject(sourceFolder.getJavaProject().getProject())) { - CompressedJavaProject compressedNode = getCompressedNode(sourceFolder.getJavaProject().getProject()); - if(compressedNode.isFlatteningSourceFolder()) { - anAddModification.setParent(compressedNode); - } - } - } - - return anAddModification; - } - - - public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) { - - Object parent = aRemoveModification.getParent(); - - Set children = aRemoveModification.getChildren(); - - for (Object child : children) { - if (child instanceof IFolder){ - try { - IPackageFragment locatePackageFragment = locatePackageFragment((IFolder)child); - if(locatePackageFragment != null){ - aRemoveModification.getChildren().remove(child); - aRemoveModification.getChildren().add(locatePackageFragment); - - return aRemoveModification; - } - } catch (JavaModelException e) { - } - } - } - - if (parent instanceof IPackageFragmentRoot) { - IPackageFragmentRoot sourceFolder = (IPackageFragmentRoot) parent; - if (JavaEEProjectUtilities.isDynamicWebProject(sourceFolder.getJavaProject().getProject())) { - CompressedJavaProject compressedNode = getCompressedNode(sourceFolder.getJavaProject().getProject()); - if(compressedNode.isFlatteningSourceFolder()) { - aRemoveModification.setParent(compressedNode); - } - } - - } - - return aRemoveModification; - } - - private IPackageFragment locatePackageFragment(IFolder child) throws JavaModelException { - IJavaElement elem = JavaCore.create(child); - if (elem instanceof IPackageFragment) { - IPackageFragment packageFragment = (IPackageFragment)elem; - for (IJavaElement javaElem = packageFragment ; javaElem != null ; javaElem = javaElem.getParent()) { - if (javaElem instanceof IPackageFragmentRoot) { - IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot)javaElem; - if (!fragmentRoot.isReadOnly() && !fragmentRoot.isExternal()) { - return packageFragment; - } - } - } - } - return null; - } - - public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) { - - Set refreshTargets = aRefreshSynchronization.getRefreshTargets(); - for (Iterator iter = refreshTargets.iterator(); iter.hasNext();) { - Object refreshTarget = iter.next(); - if (refreshTarget instanceof IPackageFragmentRoot) { - IPackageFragmentRoot sourceFolder = (IPackageFragmentRoot) refreshTarget; - if (JavaEEProjectUtilities.isDynamicWebProject(sourceFolder.getJavaProject().getProject())) { - CompressedJavaProject compressedNode = getCompressedNode(sourceFolder.getJavaProject().getProject()); - if(compressedNode.isFlatteningSourceFolder()) { - iter.remove(); // voids the iter but is okay because we're done with it - refreshTargets.add(compressedNode); - return true; - } - } - - } - } - - return false; - } - - - public boolean interceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) { - Set refreshTargets = anUpdateSynchronization.getRefreshTargets(); - for (Iterator iter = refreshTargets.iterator(); iter.hasNext();) { - Object refreshTarget = iter.next(); - if (refreshTarget instanceof IPackageFragmentRoot) { - IPackageFragmentRoot sourceFolder = (IPackageFragmentRoot) refreshTarget; - if (sourceFolder.getJavaProject()!=null && sourceFolder.getJavaProject().exists() && sourceFolder.getJavaProject().isOpen() && JavaEEProjectUtilities.isDynamicWebProject(sourceFolder.getJavaProject().getProject())) { - CompressedJavaProject compressedNode = getCompressedNode(sourceFolder.getJavaProject().getProject()); - if(compressedNode.isFlatteningSourceFolder()) { - iter.remove(); // voids the iterator; but is okay because we're done with it - refreshTargets.add(compressedNode); - return true; - } - } - } - } - - return false; - } - - public void init(ICommonContentExtensionSite aSite) { - } - - public Object[] getChildren(Object parentElement) { - if (delegateContentProvider != null) { - if (parentElement instanceof CompressedJavaProject) { - return ((CompressedJavaProject)parentElement).getChildren(delegateContentProvider); - } else if (parentElement instanceof CompressedJavaLibraries) { - return ((CompressedJavaLibraries)parentElement).getChildren(delegateContentProvider); - } - } - return NO_CHILDREN; - } - - public Object getParent(Object element) { - if (element instanceof CompressedJavaProject) - return ((CompressedJavaProject) element).getProject(); - if (element instanceof CompressedJavaLibraries) - return ((CompressedJavaLibraries) element).getCompressedProject(); - return null; - } - - public boolean hasChildren(Object element) { - return (element instanceof CompressedJavaProject || element instanceof CompressedJavaLibraries); - } - - public Object[] getElements(Object inputElement) { - return NO_CHILDREN; - } - - public void dispose() { - compressedNodes.clear(); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (viewer instanceof CommonViewer) { - commonViewer = (CommonViewer) viewer; - INavigatorContentService service = commonViewer.getNavigatorContentService(); - INavigatorContentExtension javaext = service.getContentExtensionById(JAVA_EXTENSION_ID); - if (javaext != null) - delegateContentProvider = javaext.getContentProvider(); - compressedNodes.clear(); - } - - } - - public void restoreState(IMemento aMemento) { - - } - - public void saveState(IMemento aMemento) { - - } - - public boolean isClasspathContainer(Object o) { - return INTERNAL_CONTAINER_CLASS != null && INTERNAL_CONTAINER_CLASS.isInstance(o); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaLabelProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaLabelProvider.java deleted file mode 100644 index f87ed5de5..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/WebJavaLabelProvider.java +++ /dev/null @@ -1,64 +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.servlet.ui.internal.navigator; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.ui.ProblemsLabelDecorator; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.swt.graphics.Image; - -public class WebJavaLabelProvider implements ILabelProvider { - - private ILabelDecorator decorator = new ProblemsLabelDecorator(); - - public Image getImage(Object element) { - Image image = null; - if(element instanceof ICompressedNode) - image = ((ICompressedNode)element).getImage(); - - IJavaElement javaElement = null; - if(image != null && ( javaElement = ((ICompressedNode)element).getJavaElement()) != null ) { - image = decorator.decorateImage(image, javaElement); - } - return image; - } - - public String getText(Object element) { - String text = null; - if(element instanceof ICompressedNode) - text = ((ICompressedNode)element).getLabel(); - - IJavaElement javaElement = null; - if(text != null && ( javaElement = ((ICompressedNode)element).getJavaElement()) != null ) { - text = decorator.decorateText(text, javaElement); - } - return text; - } - - public void addListener(ILabelProviderListener listener) { - - } - - public void dispose() { - decorator.dispose(); - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/ServletUIPlugin.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/ServletUIPlugin.java deleted file mode 100644 index bae297076..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/ServletUIPlugin.java +++ /dev/null @@ -1,86 +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.servlet.ui.internal.plugin; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.core.runtime.Platform; -import java.lang.Throwable; -import org.eclipse.core.runtime.CoreException; - -/** - * @author jlanuti - * - */ -public class ServletUIPlugin extends AbstractUIPlugin { - - public static final String PLUGIN_ID = "org.eclipse.jst.servlet.ui"; //$NON-NLS-1$ - // The shared instance. - private static ServletUIPlugin plugin; - - /** - * The constructor. - */ - public ServletUIPlugin() { - super(); - plugin = this; - } - - - /** - * Returns the shared instance. - */ - public static ServletUIPlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - public static void log( final Exception e ) - { - final String msg = e.getMessage() + ""; //$NON-NLS-1$ - log( new Status( IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e ) ); - } - - public static void log( final IStatus status ) - { - getDefault().getLog().log( status ); - } - - - public static IStatus createStatus(int severity, String message, Throwable exception) { - return new Status(severity, PLUGIN_ID, message, exception); - } - - - public static IStatus createStatus(int severity, String message) { - return createStatus(severity, message, null); - } - - - public static void logError(Throwable exception) { - Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception)); - } - - - public static void logError(CoreException exception) { - Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() ); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java deleted file mode 100644 index 11626e39f..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java +++ /dev/null @@ -1,184 +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.servlet.ui.internal.plugin; - -import org.eclipse.osgi.util.NLS; - - -public class WEBUIMessages extends NLS { - - private static final String BUNDLE_NAME = "web_ui";//$NON-NLS-1$ - - private WEBUIMessages() { - // Do not instantiate - } - - public static String NEW_SERVLET_WIZARD_PAGE_TITLE; - public static String FOLDER_LABEL; - public static String URL_MAPPINGS_TITLE; - public static String URL_MAPPINGS_LABEL; - public static String SERVLET_MAPPINGS_LABEL; - public static String FILTER_MAPPINGS_LABEL; - public static String URL_SERVLET_LABEL; - public static String DISPATCHERS_LABEL; - public static String JAVA_CLASS_MODIFIERS_LABEL; - public static String SUPERCLASS_LABEL; - public static String WEB_CONT_PAGE_TITLE; - public static String SERVLET_PACKAGE_LABEL; - public static String PACKAGE_SELECTION_DIALOG_MSG_NONE; - public static String JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL; - public static String ADD_SERVLET_WIZARD_WINDOW_TITLE; - public static String ADD_SERVLET_WIZARD_PAGE_TITLE; - public static String ADD_FILTER_WIZARD_WINDOW_TITLE; - public static String ADD_FILTER_WIZARD_PAGE_TITLE; - public static String JAVA_CLASS_MAIN_CHECKBOX_LABEL; - public static String EMPTY_LIST_MSG; - public static String ExportWARAction_UI_; - public static String NO_WEB_PROJECTS; - public static String INTERFACE_SELECTION_DIALOG_MSG_NONE; - public static String SUPERCLASS_SELECTION_DIALOG_TITLE; - public static String PACKAGE_SELECTION_DIALOG_DESC; - public static String JAVA_CLASS_BROWER_DIALOG_TITLE; - public static String CONTAINER_SELECTION_DIALOG_DESC; - public static String NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC; - public static String JAVA_CLASS_PUBLIC_CHECKBOX_LABEL; - public static String URL_PATTERN_LABEL; - public static String CONTAINER_SELECTION_DIALOG_TITLE; - public static String WEB_CONT_NAME; - public static String URL_PATTERN_TITLE; - public static String CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG; - public static String DESCRIPTION_TITLE; - public static String DESCRIPTION_LABEL; - public static String USE_EXISTING_SERVLET_CLASS; - public static String USE_EXISTING_FILTER_CLASS; - public static String USE_EXISTING_LISTENER_CLASS; - public static String JAVA_CLASS_FINAL_CHECKBOX_LABEL; - public static String INTERFACE_SELECTION_DIALOG_DESC; - public static String ADD_LABEL; - public static String ADD_SERVLET_WIZARD_PAGE_DESC; - public static String ADD_FILTER_WIZARD_PAGE_DESC; - public static String SELECT_CLASS_TITLE; - public static String JAVA_CLASS_BROWER_DIALOG_MESSAGE; - public static String ImportWARAction_UI_; - public static String _9; - public static String JAVA_CLASS_METHOD_STUBS_LABEL; - public static String _8; - public static String JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL; - public static String _7; - public static String SERVLETS; - public static String _6; - public static String DEFAULT_PACKAGE; - public static String _5; - public static String MAP_CLASS_NAME_TO_CLASS_ERROR_MSG; - public static String BROWSE_BUTTON_LABEL; - public static String _4; - public static String REMOVE_BUTTON; - public static String _3; - public static String _2; - public static String _1; - public static String INIT_PARAM_TITLE; - public static String INIT_PARAM_LABEL; - public static String SERVLET_NAME_LABEL; - public static String _0; - public static String CLASS_NAME_LABEL; - public static String _17; - public static String _16; - public static String JAVA_PACKAGE_LABEL; - public static String _15; - public static String _14; - public static String _13; - public static String PACKAGE_SELECTION_DIALOG_TITLE; - public static String _12; - public static String ADD_BUTTON_LABEL; - public static String ADD_BUTTON_LABEL_A; - public static String ADD_BUTTON_LABEL_D; - public static String EDIT_BUTTON_LABEL; - public static String EDIT_BUTTON_LABEL_E; - public static String EDIT_BUTTON_LABEL_T; - public static String _11; - public static String _10; - public static String SUPERCLASS_SELECTION_DIALOG_DESC; - public static String NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC; - public static String REMOVE_BUTTON_LABEL; - public static String REMOVE_BUTTON_LABEL_R; - public static String REMOVE_BUTTON_LABEL_V; - public static String NEW_SERVLET_WIZARD_WINDOW_TITLE; - public static String NEW_FILTER_WIZARD_WINDOW_TITLE; - public static String INTERFACE_SELECTION_DIALOG_TITLE; - public static String NAME_TITLE; - public static String NAME_LABEL; - public static String VALUE_TITLE; - public static String VALUE_LABEL; - public static String WEB_CONT_PAGE_COMP_LABEL; - public static String CHOOSE_SERVLET_CLASS; - public static String CHOOSE_FILTER_CLASS; - public static String NEW_SERVLET_WIZARD_PAGE_DESC; - public static String JAVA_CLASS_INHERIT_CHECKBOX_LABEL; - public static String WEB_CONT_PAGE_DESCRIPTION; - public static String JAVA_CLASS_INTERFACES_LABEL; - public static String WEBCONTENT; - public static String SELECT_ALL_BUTTON; - public static String CLEAR_BUTTON; - - public static String Compressed_Libraries; - public static String Compressed_JavaResources; - - public static String ConvertToWebTitle; - public static String SelectWebVersion; - - public static String ADD_LISTENER_WIZARD_WINDOW_TITLE; - public static String ADD_LISTENER_WIZARD_PAGE_TITLE; - public static String ADD_LISTENER_WIZARD_PAGE_DESC; - public static String ADD_LISTENER_WIZARD_SERVLET_CONTEXT_EVENTS; - public static String ADD_LISTENER_WIZARD_HTTP_SESSION_EVENTS; - public static String ADD_LISTENER_WIZARD_SERVLET_REQUEST_EVENTS; - public static String ADD_LISTENER_WIZARD_LIFECYCLE; - public static String ADD_LISTENER_WIZARD_LIFECYCLE_L; - public static String ADD_LISTENER_WIZARD_LIFECYCLE_I; - public static String ADD_LISTENER_WIZARD_LIFECYCLE_Y; - public static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES; - public static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_C; - public static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H; - public static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G; - public static String ADD_LISTENER_WIZARD_SESSION_MIGRATION; - public static String ADD_LISTENER_WIZARD_OBJECT_BINDING; - - public static String DISPATCHER_REQUEST; - public static String DISPATCHER_FORWARD; - public static String DISPATCHER_INCLUDE; - public static String DISPATCHER_ERROR; - public static String _18; - - static { - NLS.initializeMessages(BUNDLE_NAME, WEBUIMessages.class); - } - - public static final String IMAGE_LOAD_ERROR = _0; - public static final String WEB_MODULE_WIZ_TITLE = _1; - public static final String WEB_VERSION_LBL = _2; - public static final String WEB_PROJECT_MAIN_PG_TITLE = _3; - public static final String WEB_PROJECT_MAIN_PG_DESC = _4; - public static final String WEB_PROJECT_LBL = _5; - public static final String WEB_FILE_LBL = _6; - public static final String WEB_IMPORT_MAIN_PG_DESC = _7; - public static final String WEB_IMPORT_MAIN_PG_TITLE = _8; - public static final String WEB_EXPORT_MAIN_PG_TITLE = _9; - public static final String WEB_EXPORT_MAIN_PG_DESC = _10; - public static final String WEB_IMPORT_CONTEXT_ROOT = _11; - public static final String WEB_CONVERT_MAIN_PG_DESC = _12; - public static final String WEB_CONVERT_MAIN_PG_TITLE = _13; - public static final String WEB_IMPORT_WEB_LIB_PG_TITLE = _14; - public static final String WEB_IMPORT_WEB_LIB_PG_DESC = _15; - public static final String WAR_IMPORT_SELECT_ALL_LIBS_BUTTON = _16; - public static final String WAR_IMPORT_DESELECT_ALL_LIBS_BUTTON = _17; - public static final String WEBFRAGMENT_MODULE_WIZ_TITLE = _18; - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddEditFilterMappingDialog.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddEditFilterMappingDialog.java deleted file mode 100644 index 327ca0180..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddEditFilterMappingDialog.java +++ /dev/null @@ -1,616 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ERROR; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.FORWARD; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INCLUDE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REQUEST; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.URL_PATTERN_LABEL; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.j2ee.internal.dialogs.TwoArrayQuickSorter; -import org.eclipse.jst.j2ee.internal.web.operations.FilterMappingItem; -import org.eclipse.jst.j2ee.internal.web.operations.IFilterMappingItem; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -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.Control; -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.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionStatusDialog; -import org.eclipse.ui.internal.layout.CellLayout; -import org.eclipse.ui.part.PageBook; - -/** - * Insert the type's description here. - * Creation date: (7/30/2001 11:16:36 AM) - */ -public class AddEditFilterMappingDialog extends SelectionStatusDialog implements SelectionListener { - - private static class TypeRenderer extends LabelProvider { - private final Image SERVLET_ICON = - ImageDescriptor.createFromURL((URL) WebPlugin.getDefault().getImage("servlet")).createImage(); //$NON-NLS-1$ - - @Override - public String getText(Object element) { - return ((String) element); - } - - @Override - public Image getImage(Object element) { - return SERVLET_ICON; - } - - } - - public final static int SERVLET = 0; - public final static int URL_PATTERN = 1; - protected Button fServletButton; - protected Button fURLPatternButton; - protected int fSelection = -1; - protected PageBook fPageBook = null; - protected Control fURLPatternControl = null; - protected Control fServletControl = null; - protected Composite fChild = null; - // construction parameters - protected IRunnableContext fRunnableContext; - protected ILabelProvider fElementRenderer; - private Object[] fElements; - private boolean fIgnoreCase = true; - private String fUpperListLabel; - - // SWT widgets - private Table fUpperList; - protected Text fURLText; - private String[] fServletNames; - private String[] fRenderedStrings; - private int dispatchers; - private Button fRequest; - private Button fForward; - private Button fInclude; - private Button fErorr; - private IFilterMappingItem selectedItem; - - /** - * MultiSelectFilteredFileSelectionDialog constructor comment. - * @param parent Shell - * @param title String - * @param message String - * @parent extensions String[] - * @param allowMultiple boolean - */ - public AddEditFilterMappingDialog(Shell parent, String title, IProject project, - List<IFilterMappingItem> elements, IFilterMappingItem item) { - super(parent); - selectedItem = item; - setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); - - if (title == null) - setTitle(WebAppEditResourceHandler.getString("File_Selection_UI_")); //$NON-NLS-1$ - else setTitle(title); - - Status currStatus = new Status(Status.OK, ServletUIPlugin.PLUGIN_ID, Status.OK, "", null); //$NON-NLS-1$ - - updateStatus(currStatus); - fElementRenderer = new TypeRenderer(); - fRunnableContext = ServletUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - try { - IModelProvider provider = ModelProviderManager.getModelProvider(project); - Object mObj = provider.getModelObject(); - ArrayList<String> servletsList = new ArrayList<String>(); - if (mObj instanceof org.eclipse.jst.j2ee.webapplication.WebApp) { - org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp) mObj; - List<Servlet> servlets = webApp.getServlets(); - for (Servlet servlet : servlets) { - String servletName = servlet.getServletName(); - if (!servletName.equals(item != null ? item.getName() : null) && - isAlreadyAdded(servletName, elements)) continue; - servletsList.add(servletName); - } - } else if (mObj instanceof org.eclipse.jst.javaee.web.WebApp) { - org.eclipse.jst.javaee.web.WebApp webApp= (org.eclipse.jst.javaee.web.WebApp) mObj; - List<org.eclipse.jst.javaee.web.Servlet> servlets = webApp.getServlets(); - for (org.eclipse.jst.javaee.web.Servlet servlet : servlets) { - String servletName = servlet.getServletName(); - if (!servletName.equals(item != null ? item.getName() : null) && - isAlreadyAdded(servletName, elements)) continue; - servletsList.add(servletName); - } - } - - fServletNames = servletsList.toArray(new String[servletsList.size()]); - servletsList = null; - } catch (Exception e) { - ServletUIPlugin.log(e); - } - } - - private boolean isAlreadyAdded(String servlet, List<IFilterMappingItem> elements) { - for (Iterator iterator = elements.iterator(); iterator.hasNext();) { - IFilterMappingItem item = (IFilterMappingItem) iterator.next(); - if (item.isServletNameType() && item.getName().equals(servlet)) - return true; - } - return false; - } - - /** - * @private - */ - @Override - protected void computeResult() { - if (fSelection == URL_PATTERN) { - java.util.List result = new ArrayList(1); - dispatchers = getDispatchers(); - FilterMappingItem mappingItem = - new FilterMappingItem(FilterMappingItem.URL_PATTERN, fURLText.getText().trim(), - dispatchers); - result.add(mappingItem); - setResult(result); - } else { - String servletName = (String) getWidgetSelection(); - if (servletName == null) { -// String title = WebAppEditResourceHandler.getString("Select_Class_UI_"); //$NON-NLS-1$ = "Select Class" -// String message = WebAppEditResourceHandler.getString("Could_not_uniquely_map_the_ERROR_"); //$NON-NLS-1$ = "Could not uniquely map the class name to a class." -// MessageDialog.openError(getShell(), title, message); - setResult(null); - } else { - dispatchers = getDispatchers(); - java.util.List result = new ArrayList(1); - FilterMappingItem mappingItem = - new FilterMappingItem(FilterMappingItem.SERVLET_NAME, servletName, dispatchers); - result.add(mappingItem); - setResult(result); - } - } - } - - private int getDispatchers() { - int dispatchers = 0; - if (fRequest.getSelection()) { - dispatchers |= IFilterMappingItem.REQUEST; - } - if (fForward.getSelection()) { - dispatchers |= IFilterMappingItem.FORWARD; - } - if (fInclude.getSelection()) { - dispatchers |= IFilterMappingItem.INCLUDE; - } - if (fErorr.getSelection()) { - dispatchers |= IFilterMappingItem.ERROR; - } - return dispatchers; - } - - @Override - public void create() { - super.create(); - if (selectedItem == null && (fServletNames != null && fServletNames.length > 0)) fSelection = SERVLET; - updateOkState(); - } - - /** - * Creates and returns the contents of this dialog's - * button bar. - * <p> - * The <code>Dialog</code> implementation of this framework method - * lays out a button bar and calls the <code>createButtonsForButtonBar</code> - * framework method to populate it. Subclasses may override. - * </p> - * - * @param parent the parent composite to contain the button bar - * @return the button bar control - */ - @Override - protected Control createButtonBar(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - - layout.numColumns = 2; - - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite composite2 = new Composite(composite, SWT.NONE); - - // create a layout with spacing and margins appropriate for the font size. - layout = new GridLayout(); - layout.numColumns = 0; // this is incremented by createButton - layout.makeColumnsEqualWidth = true; - layout.marginWidth = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_MARGIN); - layout.marginHeight = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_MARGIN); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_SPACING); - layout.verticalSpacing = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_SPACING); - - composite2.setLayout(layout); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); - composite2.setLayoutData(data); - - composite2.setFont(parent.getFont()); - - // Add the buttons to the button bar. - super.createButtonsForButtonBar(composite2); - - return composite; - } - - /* - * @private - */ - @Override - protected Control createDialogArea(Composite parent) { - GridData gd = new GridData(); - - fChild = new Composite(parent, SWT.NONE); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild, "com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$ - GridLayout gl = new GridLayout(); - gl.numColumns = 2; - gl.marginHeight = 0; - fChild.setLayout(gl); - - gd.verticalAlignment = GridData.FILL; - gd.grabExcessVerticalSpace = true; - fChild.setLayoutData(gd); - - // Create the Web Type radio buttons and text fields. - fServletButton = new Button(fChild, SWT.RADIO); - fServletButton.setText(WebAppEditResourceHandler.getString("Servlet_UI_")); //$NON-NLS-1$ = Servlet - gd = new GridData(); - fServletButton.setLayoutData(gd); - fServletButton.addSelectionListener(this); - - fURLPatternButton = new Button(fChild, SWT.RADIO); - fURLPatternButton.setText(WebAppEditResourceHandler.getString("URL_pattern_UI_")); //$NON-NLS-1$ - gd = new GridData(); - fURLPatternButton.setLayoutData(gd); - fURLPatternButton.addSelectionListener(this); - - //Create URL Pattern page - fPageBook = new PageBook(fChild, SWT.NONE); - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.grabExcessVerticalSpace = true; - gd.horizontalSpan = 2; - fPageBook.setLayoutData(gd); - - Composite composite = new Composite(fPageBook, 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()); - - Label messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(URL_PATTERN_LABEL); - - fURLText = new Text(composite, SWT.BORDER); - GridData spec = new GridData(); - spec.grabExcessVerticalSpace = false; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.BEGINNING; - fURLText.setLayoutData(spec); - Listener l = new Listener() { - public void handleEvent(Event evt) { - updateOkState(); - } - }; - fURLText.addListener(SWT.Modify, l); - fURLPatternControl = composite; - - //Create Servlet page - composite = new Composite(fPageBook, SWT.NONE); - 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()); - - messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_servlet__1")); //$NON-NLS-1$ - - fUpperList = createUpperList(composite); - - fServletControl = composite; - - //Create Dispatchers control - Group dispatchers = new Group(fChild, SWT.SHADOW_IN); - dispatchers.setText(WebAppEditResourceHandler.getString("Select_Dispatchers_UI_")); //$NON-NLS-1$ - dispatchers.setLayout(new CellLayout(2).setMargins(10,10).setSpacing(5,5)); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 2; - dispatchers.setLayoutData(gridData); - fRequest = new Button(dispatchers, SWT.CHECK); - fRequest.setText(REQUEST); - fForward = new Button(dispatchers, SWT.CHECK); - fForward.setText(FORWARD); - fInclude = new Button(dispatchers, SWT.CHECK); - fInclude.setText(INCLUDE); - fErorr = new Button(dispatchers, SWT.CHECK); - fErorr.setText(ERROR); - - if (selectedItem != null) { - if (selectedItem.isUrlPatternType()) { - fSelection = URL_PATTERN; - } else { - fSelection = SERVLET; - } - } else { - if (fServletNames == null || fServletNames.length == 0) { - fSelection = URL_PATTERN; - } - } - updateUpperListWidget(); - - fServletButton.setEnabled(true); - if (fSelection == URL_PATTERN) { - fURLPatternButton.setSelection(true); - fPageBook.showPage(fURLPatternControl); - fServletButton.setSelection(false); - if (fServletNames == null || fServletNames.length == 0) { - fServletButton.setEnabled(false); - } - if (selectedItem != null) { - fURLText.setText(selectedItem.getName()); - setDispatchers(selectedItem.getDispatchers()); - } - } else { - fServletButton.setSelection(true); - fPageBook.showPage(fServletControl); - if (selectedItem != null) { - fUpperList.setSelection(getServletIndex(fUpperList, selectedItem.getName())); - setDispatchers(selectedItem.getDispatchers()); - } - } - updateOkState(); - return parent; - } - - private int getServletIndex(Table list, String name) { - TableItem[] items = list.getItems(); - for (int i = 0; i < items.length; i++) { - TableItem tableItem = items[i]; - if (tableItem.getText().equals(name)) return i; - } - return -1; - } - - private void setDispatchers(int dispatchers) { - if ((dispatchers & IFilterMappingItem.REQUEST) > 0) { - fRequest.setSelection(true); - } - if ((dispatchers & IFilterMappingItem.FORWARD) > 0) { - fForward.setSelection(true); - } - if ((dispatchers & IFilterMappingItem.INCLUDE) > 0) { - fInclude.setSelection(true); - } - if ((dispatchers & IFilterMappingItem.ERROR) > 0) { - fErorr.setSelection(true); - } - } - - /** - * Creates the list widget and sets layout data. - * @return org.eclipse.swt.widgets.List - */ - private Table createUpperList(Composite parent) { - if (fUpperListLabel != null) - (new Label(parent, SWT.NONE)).setText(fUpperListLabel); - - Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); -// list.addListener(SWT.Selection, new Listener() { -// public void handleEvent(Event evt) { -// handleUpperSelectionChanged(); -// } -// }); - list.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event evt) { - handleUpperDoubleClick(); - } - }); - list.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fElementRenderer.dispose(); - } - }); - GridData spec = new GridData(); - spec.widthHint = convertWidthInCharsToPixels(50); - spec.heightHint = convertHeightInCharsToPixels(4); - spec.grabExcessVerticalSpace = true; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.FILL; - list.setLayoutData(spec); - return list; - } - - /** - * @return the ID of the button that is 'pressed' on doubleClick in the lists. - * By default it is the OK button. - * Override to change this setting. - */ - protected int getDefaultButtonID() { - return IDialogConstants.OK_ID; - } - - public int getSelectedItem() { - return fSelection; - } - - protected Object getWidgetSelection() { - int index = fUpperList.getSelectionIndex(); - return index >= 0 ? fElements[index] : null; - } - - protected final void handleLowerDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - protected final void handleLowerSelectionChanged() { - updateOkState(); - } - - protected final void handleUpperDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - @Override - public int open() { - if (fServletNames == null || fServletNames.length == 0) { - fSelection = URL_PATTERN; - } - - setElements(fServletNames); - setInitialSelections(new Object[] { "" }); //$NON-NLS-1$ - return super.open(); - } - - /** - * - * @return java.lang.String[] - * @param p org.eclipse.jface.elements.IIndexedProperty - */ - private String[] renderStrings(Object[] p) { - String[] strings = new String[p.length]; - int size = strings.length; - for (int i = 0; i < size; i++) { - strings[i] = fElementRenderer.getText(p[i]); - } - new TwoArrayQuickSorter(fIgnoreCase).sort(strings, p); - return strings; - } - - public void setElements(Object[] elements) { - Object [] innerElements = elements; - if (innerElements == null){ - innerElements = new Object[0]; - } - fElements = innerElements; - fRenderedStrings = renderStrings(fElements); - } - - public void setSelectedItem(int newSelection) { - fSelection = newSelection; - } - - private void updateOkState() { - Button okButton = getOkButton(); - if (okButton != null) - if (fSelection == SERVLET) { - okButton.setEnabled(getWidgetSelection() != null); - } else { - String result = fURLText.getText().trim(); - okButton.setEnabled(result.length() > 0); - } - } - - private void updateUpperListWidget() { - fUpperList.setRedraw(false); - fUpperList.clearAll(); - for (int i = 0; i < fRenderedStrings.length; i++) { - TableItem ti = new TableItem(fUpperList, SWT.NONE); - ti.setText(fRenderedStrings[i]); - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - Image img = fElementRenderer.getImage(fRenderedStrings[i]); - ti.setImage(img); - } - if (fUpperList.getItemCount() > 0) { - fUpperList.setSelection(0); - } - fUpperList.setRedraw(true); - } - - /** - * Sent when default selection occurs in the control. - * <p> - * For example, on some platforms default selection occurs - * in a List when the user double-clicks an item or types - * return in a Text. - * </p> - * - * @param e an event containing information about the default selection - */ - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - - /** - * Sent when selection occurs in the control. - * <p> - * For example, on some platforms selection occurs in - * a List when the user selects an item or items. - * </p> - * - * @param e an event containing information about the selection - */ - public void widgetSelected(SelectionEvent e) { - if (e.widget == fURLPatternButton) { - fSelection = URL_PATTERN; - fPageBook.showPage(fURLPatternControl); - updateOkState(); - } else if (e.widget == fServletButton) { - fSelection = SERVLET; - fPageBook.showPage(fServletControl); - getShell().pack(); - } else - fSelection = -1; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizard.java deleted file mode 100644 index d87fed908..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizard.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_FILTER_WIZARD_PAGE_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_FILTER_WIZARD_WINDOW_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.web.operations.NewFilterClassDataModelProvider; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * New servlet filter wizard - */ -public class AddFilterWizard extends NewWebArtifactWizard { - - public AddFilterWizard() { - this(null); - } - - public AddFilterWizard(IDataModel model) { - super(model); - } - - @Override - protected String getTitle() { - return ADD_FILTER_WIZARD_WINDOW_TITLE; - } - - @Override - protected ImageDescriptor getImage() { - return getImageFromJ2EEPlugin("newfilter_wiz"); //$NON-NLS-1$ - } - - @Override - public void doAddPages() { - NewFilterClassWizardPage page1 = new NewFilterClassWizardPage( - getDataModel(), - PAGE_ONE, - NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC, - ADD_FILTER_WIZARD_PAGE_TITLE, - J2EEProjectUtilities.DYNAMIC_WEB); - page1.setInfopopID(IWebUIContextIds.WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_1); - addPage(page1); - - AddFilterWizardPage page2 = new AddFilterWizardPage(getDataModel(), PAGE_TWO); - page2.setInfopopID(IWebUIContextIds.WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_2); - addPage(page2); - - NewFilterClassOptionsWizardPage page3 = new NewFilterClassOptionsWizardPage( - getDataModel(), - PAGE_THREE, - NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC, - ADD_FILTER_WIZARD_PAGE_TITLE); - page3.setInfopopID(IWebUIContextIds.WEBEDITOR_FILTER_PAGE_ADD_FILTER_WIZARD_3); - addPage(page3); - } - - @Override - protected IDataModelProvider getDefaultProvider() { - return new NewFilterClassDataModelProvider(); - } - - @Override - protected void postPerformFinish() throws InvocationTargetException { - //open new filter class in java editor - openJavaClass(); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizardPage.java deleted file mode 100644 index 79ca1aea6..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizardPage.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.FILTER_MAPPINGS; -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.INIT_PARAM; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_BUTTON_LABEL_A; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_FILTER_WIZARD_PAGE_DESC; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_FILTER_WIZARD_PAGE_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.EDIT_BUTTON_LABEL_E; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NO_WEB_PROJECTS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REMOVE_BUTTON_LABEL_R; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_TITLE; -import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.wizard.StringArrayTableWizardSection; -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.Text; -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; - -/** - * Filter Wizard Setting Page - */ -public class AddFilterWizardPage extends DataModelWizardPage { - - final static String[] FILTEREXTENSIONS = {"java"}; //$NON-NLS-1$ - - private Text displayNameText; - - FilterMappingsArrayTableWizardSection mappingSection; - - public AddFilterWizardPage(IDataModel model, String pageName) { - super(model, pageName); - setDescription(ADD_FILTER_WIZARD_PAGE_DESC); - setTitle(ADD_FILTER_WIZARD_PAGE_TITLE); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - @Override - protected String[] getValidationPropertyNames() { - return new String[] { DISPLAY_NAME, - INIT_PARAM, - FILTER_MAPPINGS }; - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 300; - composite.setLayoutData(data); - - createNameDescription(composite); - - StringArrayTableWizardSectionCallback callback = new StringArrayTableWizardSectionCallback(); - StringArrayTableWizardSection initSection = new StringArrayTableWizardSection( - composite, - INIT_PARAM_LABEL, - INIT_PARAM_TITLE, - ADD_BUTTON_LABEL_A, - EDIT_BUTTON_LABEL_E, - REMOVE_BUTTON_LABEL_R, - new String[] { NAME_TITLE, VALUE_TITLE, DESCRIPTION_TITLE }, - new String[] { NAME_LABEL, VALUE_LABEL, DESCRIPTION_LABEL }, - null,// WebPlugin.getDefault().getImage("initializ_parameter"), - model, - INIT_PARAM); - initSection.setCallback(callback); - - mappingSection = new FilterMappingsArrayTableWizardSection(composite, - model, FILTER_MAPPINGS); - - displayNameText.setFocus(); - - IStatus projectStatus = validateProjectName(); - if (!projectStatus.isOK()) { - setErrorMessage(projectStatus.getMessage()); - composite.setEnabled(false); - } - Dialog.applyDialogFont(parent); - return composite; - } - - protected IStatus validateProjectName() { - // check for empty - if (model.getStringProperty(PROJECT_NAME) == null || model.getStringProperty(PROJECT_NAME).trim().length() == 0) { - return WTPCommonPlugin.createErrorStatus(NO_WEB_PROJECTS); - } - return WTPCommonPlugin.OK_STATUS; - } - - protected void createNameDescription(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - // display name - Label displayNameLabel = new Label(composite, SWT.LEFT); - displayNameLabel.setText(NAME_LABEL); - displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - displayNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); - displayNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(displayNameText, DISPLAY_NAME, null); - - // description - Label descLabel = new Label(composite, SWT.LEFT); - descLabel.setText(DESCRIPTION_LABEL); - descLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - Text descText = new Text(composite, SWT.SINGLE | SWT.BORDER); - descText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(descText, DESCRIPTION, null); - } - - public String getDisplayName() { - return displayNameText.getText(); - } - - @Override - public boolean canFlipToNextPage() { - if (model.getBooleanProperty(USE_EXISTING_CLASS)) - return false; - return super.canFlipToNextPage(); - } - - @Override - protected boolean showValidationErrorsOnEnter() { - return true; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizard.java deleted file mode 100644 index 1b90021d8..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizard.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_LISTENER_WIZARD_PAGE_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_LISTENER_WIZARD_WINDOW_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.web.operations.NewListenerClassDataModelProvider; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * New application lifecycle listener wizard - */ -public class AddListenerWizard extends NewWebArtifactWizard { - - public AddListenerWizard() { - this(null); - } - - public AddListenerWizard(IDataModel model) { - super(model); - } - - @Override - protected String getTitle() { - return ADD_LISTENER_WIZARD_WINDOW_TITLE; - } - - @Override - protected ImageDescriptor getImage() { - return getImageFromJ2EEPlugin("newlistener_wiz"); //$NON-NLS-1$ - } - - @Override - public void doAddPages() { - NewListenerClassWizardPage page1 = new NewListenerClassWizardPage( - getDataModel(), - PAGE_ONE, - NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC, - ADD_LISTENER_WIZARD_PAGE_TITLE, J2EEProjectUtilities.DYNAMIC_WEB); - page1.setInfopopID(IWebUIContextIds.WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_1); - addPage(page1); - AddListenerWizardPage page2 = new AddListenerWizardPage(getDataModel(), PAGE_TWO); - page2.setInfopopID(IWebUIContextIds.WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_2); - addPage(page2); - NewListenerClassOptionsWizardPage page3 = new NewListenerClassOptionsWizardPage( - getDataModel(), - PAGE_THREE, - NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC, - ADD_LISTENER_WIZARD_PAGE_TITLE); - page3.setInfopopID(IWebUIContextIds.WEBEDITOR_LISTENER_PAGE_ADD_LISTENER_WIZARD_3); - addPage(page3); - } - - @Override - protected void postPerformFinish() throws InvocationTargetException { - // open new listener class in java editor - openJavaClass(); - } - - @Override - protected IDataModelProvider getDefaultProvider() { - return new NewListenerClassDataModelProvider(); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java deleted file mode 100644 index 8b1d3c3f1..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java +++ /dev/null @@ -1,245 +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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.INTERFACES; -import static org.eclipse.jst.j2ee.internal.web.operations.NewListenerClassDataModelProvider.LISTENER_INTERFACES; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ACTIVATION_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ATTRIBUTE_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_BINDING_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTEXT_ATTRIBUTE_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTEXT_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_LISTENER; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jdt.internal.ui.JavaPluginImages; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -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.Group; -import org.eclipse.swt.widgets.Label; -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; - -public class AddListenerWizardPage extends DataModelWizardPage { - - private static final Image IMG_INTERFACE = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INTERFACE); - - protected ServletDataModelSyncHelper synchHelper; - - public AddListenerWizardPage(IDataModel model, String pageName) { - super(model, pageName); - setDescription(ADD_LISTENER_WIZARD_PAGE_DESC); - setTitle(ADD_LISTENER_WIZARD_PAGE_TITLE); - synchHelper = initializeSynchHelper(model); - } - - @Override - public ServletDataModelSyncHelper initializeSynchHelper(IDataModel dm) { - return new ServletDataModelSyncHelper(dm); - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 300; - composite.setLayoutData(data); - - createServletContextEvents(composite); - createHttpSessionEvents(composite); - createServletRequestEvents(composite); - createSelectAllGroup(composite); - - Dialog.applyDialogFont(composite); - - return composite; - } - - @Override - protected String[] getValidationPropertyNames() { - return new String[] { - INTERFACES - }; - } - - @Override - protected void enter() { - super.enter(); - synchHelper.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG); - } - - private void createServletContextEvents(Composite parent) { - Group group = createGroup(parent, ADD_LISTENER_WIZARD_SERVLET_CONTEXT_EVENTS); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_LIFECYCLE_L, - QUALIFIED_SERVLET_CONTEXT_LISTENER, - INTERFACES); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_C, - QUALIFIED_SERVLET_CONTEXT_ATTRIBUTE_LISTENER, - INTERFACES); - } - - private void createHttpSessionEvents(Composite parent) { - Group group = createGroup(parent, ADD_LISTENER_WIZARD_HTTP_SESSION_EVENTS); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_LIFECYCLE_I, - QUALIFIED_HTTP_SESSION_LISTENER, - INTERFACES); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H, - QUALIFIED_HTTP_SESSION_ATTRIBUTE_LISTENER, - INTERFACES); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_SESSION_MIGRATION, - QUALIFIED_HTTP_SESSION_ACTIVATION_LISTENER, - INTERFACES); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_OBJECT_BINDING, - QUALIFIED_HTTP_SESSION_BINDING_LISTENER, - INTERFACES); - } - - private void createServletRequestEvents(Composite parent) { - Group group = createGroup(parent, ADD_LISTENER_WIZARD_SERVLET_REQUEST_EVENTS); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_LIFECYCLE_Y, - QUALIFIED_SERVLET_REQUEST_LISTENER, - INTERFACES); - - createEventListenerRow(group, - ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G, - QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER, - INTERFACES); - } - - private Group createGroup(Composite parent, String text) { - Group group = new Group(parent, SWT.NONE); - - group.setLayout(new GridLayout(3, false)); - group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - group.setText(text); - - return group; - } - - private void createEventListenerRow(Composite parent, String event, String listener, String property) { - createCheckbox(parent, event, listener, property); - createInterfaceIcon(parent); - createInterfaceLabel(parent, listener); - } - - private Button createCheckbox(Composite parent, String text, String value, String property) { - Button button = new Button(parent, SWT.CHECK); - - button.setText(text); - button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); - synchHelper.synchCheckbox(button, value, property, null); - - return button; - } - - private Label createInterfaceIcon(Composite parent) { - GridData data = new GridData(); - data.horizontalIndent = 50; - - Label label = new Label(parent, SWT.RIGHT); - label.setImage(IMG_INTERFACE); - label.setLayoutData(data); - - return label; - } - - private Label createInterfaceLabel(Composite parent, String text) { - Label label = new Label(parent, SWT.LEFT); - - label.setText(text); - - return label; - } - - private void createSelectAllGroup(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - Button selectAll = new Button(composite, SWT.PUSH); - selectAll.setText(SELECT_ALL_BUTTON); - selectAll.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleSelectAll(); - } - }); - - Button clear = new Button(composite, SWT.PUSH); - clear.setText(CLEAR_BUTTON); - clear.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleSelectNone(); - } - }); - } - - private void handleSelectAll() { - List interfaces = (List) model.getProperty(INTERFACES); - if (interfaces == null) { - interfaces = new ArrayList(); - model.setProperty(INTERFACES, interfaces); - } - - for (String iface : LISTENER_INTERFACES) { - if (!interfaces.contains(iface)) { - interfaces.add(iface); - } - } - - synchHelper.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG); - model.notifyPropertyChange(INTERFACES, DataModelEvent.VALUE_CHG); - } - - private void handleSelectNone() { - List interfaces = (List) model.getProperty(INTERFACES); - if (interfaces == null) { - interfaces = new ArrayList(); - model.setProperty(INTERFACES, interfaces); - } - - interfaces.removeAll(Arrays.asList(LISTENER_INTERFACES)); - - synchHelper.synchUIWithModel(INTERFACES, DataModelEvent.VALUE_CHG); - model.notifyPropertyChange(INTERFACES, DataModelEvent.VALUE_CHG); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizard.java deleted file mode 100644 index b3a35d657..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizard.java +++ /dev/null @@ -1,91 +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 - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.IS_SERVLET_TYPE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_SERVLET_WIZARD_PAGE_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_SERVLET_WIZARD_WINDOW_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassDataModelProvider; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; - -/** - * New servlet wizard - */ -public class AddServletWizard extends NewWebArtifactWizard { - - public AddServletWizard() { - this(null); - } - - public AddServletWizard(IDataModel model) { - super(model); - } - - @Override - protected String getTitle() { - return ADD_SERVLET_WIZARD_WINDOW_TITLE; - } - - @Override - protected ImageDescriptor getImage() { - return J2EEUIPlugin.getDefault().getImageDescriptor("newservlet_wiz"); //$NON-NLS-1$ - } - - @Override - public void doAddPages() { - NewServletClassWizardPage page1 = new NewServletClassWizardPage( - getDataModel(), - PAGE_ONE, - NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC, - ADD_SERVLET_WIZARD_PAGE_TITLE, J2EEProjectUtilities.DYNAMIC_WEB); - page1.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_1); - addPage(page1); - AddServletWizardPage page2 = new AddServletWizardPage(getDataModel(), PAGE_TWO); - page2.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_2); - addPage(page2); - NewServletClassOptionsWizardPage page3 = new NewServletClassOptionsWizardPage( - getDataModel(), - PAGE_THREE, - NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC, - ADD_SERVLET_WIZARD_PAGE_TITLE); - page3.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_3); - addPage(page3); - } - - @Override - protected void postPerformFinish() throws InvocationTargetException { - boolean isServlet = getDataModel().getBooleanProperty(IS_SERVLET_TYPE); - if (isServlet) { - // open new servlet class in java editor - openJavaClass(); - } else { - // open new jsp file in jsp editor - openWebFile(); - } - } - - @Override - protected IDataModelProvider getDefaultProvider() { - return new NewServletClassDataModelProvider(); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizardPage.java deleted file mode 100644 index 83fdc45ae..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddServletWizardPage.java +++ /dev/null @@ -1,198 +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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.INIT_PARAM; -import static org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.URL_MAPPINGS; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_BUTTON_LABEL_A; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_BUTTON_LABEL_D; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_SERVLET_WIZARD_PAGE_DESC; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_SERVLET_WIZARD_PAGE_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.EDIT_BUTTON_LABEL_E; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.EDIT_BUTTON_LABEL_T; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NO_WEB_PROJECTS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REMOVE_BUTTON_LABEL_R; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REMOVE_BUTTON_LABEL_V; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.URL_MAPPINGS_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.URL_MAPPINGS_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.URL_PATTERN_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.URL_PATTERN_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_TITLE; -import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.wizard.StringArrayTableWizardSection; -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.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -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; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * Servlet Wizard Setting Page - */ -public class AddServletWizardPage extends DataModelWizardPage { - final static String[] JSPEXTENSIONS = {"jsp"}; //$NON-NLS-1$ - - private Text displayNameText; - - private StringArrayTableWizardSection urlSection; - - public AddServletWizardPage(IDataModel model, String pageName) { - super(model, pageName); - setDescription(ADD_SERVLET_WIZARD_PAGE_DESC); - this.setTitle(ADD_SERVLET_WIZARD_PAGE_TITLE); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames() - */ - @Override - protected String[] getValidationPropertyNames() { - return new String[] { DISPLAY_NAME, INIT_PARAM, URL_MAPPINGS }; - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 300; - composite.setLayoutData(data); - - createNameDescription(composite); - - StringArrayTableWizardSectionCallback callback = new StringArrayTableWizardSectionCallback(); - StringArrayTableWizardSection initSection = new StringArrayTableWizardSection( - composite, - INIT_PARAM_LABEL, - INIT_PARAM_TITLE, - ADD_BUTTON_LABEL_A, - EDIT_BUTTON_LABEL_E, - REMOVE_BUTTON_LABEL_R, - new String[] { NAME_TITLE, VALUE_TITLE, DESCRIPTION_TITLE }, - new String[] { NAME_LABEL, VALUE_LABEL, DESCRIPTION_LABEL }, - null,// WebPlugin.getDefault().getImage("initializ_parameter"), - model, - INIT_PARAM); - initSection.setCallback(callback); - urlSection = new StringArrayTableWizardSection( - composite, - URL_MAPPINGS_LABEL, - URL_MAPPINGS_TITLE, - ADD_BUTTON_LABEL_D, - EDIT_BUTTON_LABEL_T, - REMOVE_BUTTON_LABEL_V, - new String[] { URL_PATTERN_TITLE }, - new String[] { URL_PATTERN_LABEL }, - null,// WebPlugin.getDefault().getImage("url_type"), - model, - URL_MAPPINGS); - urlSection.setCallback(callback); - - String text = displayNameText.getText(); - // Set default URL Pattern - List input = new ArrayList(); - input.add(new String[]{"/" + text}); //$NON-NLS-1$ - if (urlSection != null) - urlSection.setInput(input); - displayNameText.setFocus(); - - IStatus projectStatus = validateProjectName(); - if (!projectStatus.isOK()) { - setErrorMessage(projectStatus.getMessage()); - composite.setEnabled(false); - } - Dialog.applyDialogFont(parent); - return composite; - } - - protected IStatus validateProjectName() { - // check for empty - if (model.getStringProperty(PROJECT_NAME) == null || model.getStringProperty(PROJECT_NAME).trim().length() == 0) { - return WTPCommonPlugin.createErrorStatus(NO_WEB_PROJECTS); - } - return WTPCommonPlugin.OK_STATUS; - } - - protected void createNameDescription(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - // display name - Label displayNameLabel = new Label(composite, SWT.LEFT); - displayNameLabel.setText(NAME_LABEL); - displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - displayNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); - displayNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - displayNameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - String text = displayNameText.getText(); - // Set default URL Pattern - List input = new ArrayList(); - input.add(new String[]{"/" + text}); //$NON-NLS-1$ - if (urlSection != null) - urlSection.setInput(input); - } - - }); - synchHelper.synchText(displayNameText, DISPLAY_NAME, null); - - // description - Label descLabel = new Label(composite, SWT.LEFT); - descLabel.setText(DESCRIPTION_LABEL); - descLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - Text descText = new Text(composite, SWT.SINGLE | SWT.BORDER); - descText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - synchHelper.synchText(descText, DESCRIPTION, null); - } - - public String getDisplayName() { - return displayNameText.getText(); - } - - @Override - public boolean canFlipToNextPage() { - if (model.getBooleanProperty(USE_EXISTING_CLASS)) - return false; - return super.canFlipToNextPage(); - } - - @Override - protected boolean showValidationErrorsOnEnter() { - return true; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AvailableWebLibProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AvailableWebLibProvider.java deleted file mode 100644 index 8ce5e4a85..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AvailableWebLibProvider.java +++ /dev/null @@ -1,67 +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.servlet.ui.internal.wizard; - -import java.util.Arrays; -import java.util.Comparator; - -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.internal.archive.ArchiveWrapper; -import org.eclipse.jst.j2ee.internal.wizard.AvailableJarsProvider; -import org.eclipse.swt.graphics.Image; - -public class AvailableWebLibProvider implements IStructuredContentProvider, ITableLabelProvider { - - public AvailableWebLibProvider() { - } - - public Object[] getElements(Object inputElement) { - if (inputElement instanceof ArchiveWrapper) { - Object[] array = ((ArchiveWrapper) inputElement).getWebLibs().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]; - } - - public Image getColumnImage(Object element, int columnIndex) { - return AvailableJarsProvider.getUtilImage(); - } - - public String getColumnText(Object element, int columnIndex) { - ArchiveWrapper wrapper = (ArchiveWrapper)element; - return wrapper.getName(); - } - - public void dispose() { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public void addListener(ILabelProviderListener listener) { - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ConvertToWebModuleTypeDialog.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ConvertToWebModuleTypeDialog.java deleted file mode 100644 index a6409d08f..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ConvertToWebModuleTypeDialog.java +++ /dev/null @@ -1,80 +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.servlet.ui.internal.wizard; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.window.IShellProvider; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -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.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -public class ConvertToWebModuleTypeDialog extends Dialog { - - private String fShellTitle = IWebWizardConstants.CONVERT_TO_WEB_TITLE; - private String fLabelText = IWebWizardConstants.SELECT_WEB_VERSION; - private static String fSelection= null; - private String[] fAllowedStrings = new String[] {J2EEVersionConstants.VERSION_2_2_TEXT, J2EEVersionConstants.VERSION_2_3_TEXT, J2EEVersionConstants.VERSION_2_4_TEXT, J2EEVersionConstants.VERSION_2_5_TEXT, J2EEVersionConstants.VERSION_3_0_TEXT}; - private int fInitialSelectionIndex = fAllowedStrings.length-1; - - public static String getSelectedVersion() { - return fSelection; - } - - public ConvertToWebModuleTypeDialog(IShellProvider parentShell) { - super(parentShell); - } - - public ConvertToWebModuleTypeDialog(Shell parentShell) { - super(parentShell); - } - - @Override - protected Control createDialogArea(Composite parent) { - getShell().setText(fShellTitle); - - Composite composite = (Composite)super.createDialogArea(parent); - Composite innerComposite = new Composite(composite, SWT.NONE); - innerComposite.setLayoutData(new GridData()); - GridLayout gl= new GridLayout(); - gl.numColumns= 2; - innerComposite.setLayout(gl); - - Label label= new Label(innerComposite, SWT.NONE); - label.setText(fLabelText); - label.setLayoutData(new GridData()); - - final Combo combo= new Combo(innerComposite, SWT.READ_ONLY); - for (int i = 0; i < fAllowedStrings.length; i++) { - combo.add(fAllowedStrings[i]); - } - combo.select(fInitialSelectionIndex); - fSelection= combo.getItem(combo.getSelectionIndex()); - GridData gd= new GridData(); - combo.setLayoutData(gd); - combo.addSelectionListener(new SelectionAdapter(){ - @Override - public void widgetSelected(SelectionEvent e) { - fSelection= combo.getItem(combo.getSelectionIndex()); - } - }); - return composite; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/FilterMappingsArrayTableWizardSection.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/FilterMappingsArrayTableWizardSection.java deleted file mode 100644 index 261d093da..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/FilterMappingsArrayTableWizardSection.java +++ /dev/null @@ -1,356 +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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.*; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.resource.ImageDescriptor; -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.jst.j2ee.internal.web.operations.FilterMappingItem; -import org.eclipse.jst.j2ee.internal.web.operations.IFilterMappingItem; -import org.eclipse.jst.j2ee.internal.web.plugin.WebPlugin; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -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.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; - -public class FilterMappingsArrayTableWizardSection extends Composite implements IDataModelListener { - - protected class StringArrayListContentProvider implements IStructuredContentProvider { - public boolean isDeleted(Object element) { - return false; - } - public Object[] getElements(Object element) { - if (element instanceof List) { - return ((List<FilterMappingItem>) 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 { - private final Image URL_PATTERN_ICON = - ImageDescriptor.createFromURL((URL) WebPlugin.getDefault().getImage("url_mapping")).createImage(); //$NON-NLS-1$ - private final Image SERVLET_ICON = - ImageDescriptor.createFromURL((URL) WebPlugin.getDefault().getImage("servlet")).createImage(); //$NON-NLS-1$ - - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - FilterMappingItem item = (FilterMappingItem) element; - if (item.isServletNameType()) { - return SERVLET_ICON; - } else if (item.isUrlPatternType()) { - return URL_PATTERN_ICON; - } - - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 1) { - return ((FilterMappingItem) element).getName(); - } else if (columnIndex == 2) { - return ((FilterMappingItem) element).getDispatchersAsString(); - } - return null; - } - - } - - final static int ICON_WIDTH = 25; - final static int DISPATCHERS_WIDTH = 100; - private final static String ICON_PROP = "ICON_PROP"; //$NON-NLS-1$ - private final static String NAME_PROP = "NAME_PROP"; //$NON-NLS-1$ - private final static String DISPATCHERS_PROP = "DISPATCHERS_PROP"; //$NON-NLS-1$ - - private TableViewer viewer; - private Button addButton; - private Button editButton; - private Button removeButton; - private IDataModel model; - private String propertyName; - - public FilterMappingsArrayTableWizardSection(Composite parent, IDataModel model, String propertyName) { - super(parent, SWT.NONE); - - this.model = model; - this.propertyName = propertyName; - model.addListener(this); - - 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(FILTER_MAPPINGS_LABEL); - 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(ADD_BUTTON_LABEL_D); - 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 - } - }); - - editButton = new Button(buttonCompo, SWT.PUSH); - editButton.setText(EDIT_BUTTON_LABEL_T); - 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(REMOVE_BUTTON_LABEL_V); - 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(); - } - }); - } - - TableColumn tableColumn = new TableColumn(table, SWT.NONE); - tableColumn.setWidth(ICON_WIDTH); - tableColumn.setResizable(false); - tableColumn = new TableColumn(table, SWT.NONE); - tableColumn.setText(URL_SERVLET_LABEL); - tableColumn.setResizable(true); - tableColumn = new TableColumn(table, SWT.NONE); - tableColumn.setText(DISPATCHERS_LABEL); - tableColumn.setWidth(DISPATCHERS_WIDTH); - tableColumn.setResizable(false); - viewer.setColumnProperties(new String[] {ICON_PROP, NAME_PROP, DISPATCHERS_PROP}); - table.setHeaderVisible(true); - this.addControlListener(new ControlAdapter() { - @Override - 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(); - 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 - if (i == 1) columns[i].setWidth(width - ICON_WIDTH - DISPATCHERS_WIDTH); - 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); - if (i == 1) columns[i].setWidth(width - ICON_WIDTH - DISPATCHERS_WIDTH); - } - } - } - }); - - viewer.setInput(model.getProperty(propertyName)); - } - - private void handleAddButtonSelected() { - String title = WebAppEditResourceHandler.getString("Add_Filter_Mapping_Title_UI_"); //$NON-NLS-1$ - IProject p = (IProject) model.getProperty(PROJECT); - List valueList = (List) viewer.getInput(); - AddEditFilterMappingDialog dialog = - new AddEditFilterMappingDialog(getShell(), title, p, valueList, null); - dialog.open(); - Object[] result = dialog.getResult(); - - addFilterMapping((result != null && result.length > 0) ? (IFilterMappingItem) result[0] : null); - } - - private void handleEditButtonSelected() { - String title = WebAppEditResourceHandler.getString("Edit_Filter_Mapping_Title_UI_"); //$NON-NLS-1$ - ISelection s = viewer.getSelection(); - if (!(s instanceof IStructuredSelection)) - return; - IStructuredSelection selection = (IStructuredSelection) s; - if (selection.size() != 1) - return; - List valueList = (List) viewer.getInput(); - Object selectedObj = selection.getFirstElement(); - FilterMappingItem value = (FilterMappingItem) selectedObj; - IProject p = (IProject) model.getProperty(PROJECT); - AddEditFilterMappingDialog dialog = - new AddEditFilterMappingDialog(getShell(), title, p, valueList, value); - dialog.open(); - Object[] result = dialog.getResult(); - if (result == null || result.length == 0) return; - editFilterMapping(value, (IFilterMappingItem) result[0]); - } - - private void handleRemoveButtonSelected() { - ISelection selection = viewer.getSelection(); - if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) - return; - List selectedObj = ((IStructuredSelection) selection).toList(); - removeFilterMappings(selectedObj); - } - - private void addFilterMapping(IFilterMappingItem filterMapping) { - if (filterMapping == null) return; - List valueList = (List) viewer.getInput(); - if (valueList == null) { - valueList = new ArrayList(); - } - valueList.add(filterMapping); - setInput(valueList); - } - - private void editFilterMapping(IFilterMappingItem oldFilterMapping, IFilterMappingItem newFilterMapping) { - if (newFilterMapping == null) return; - List valueList = (List) viewer.getInput(); - if (valueList == null) { - valueList = new ArrayList(); - } - int index = valueList.indexOf(oldFilterMapping); - if (index == -1) { - valueList.add(newFilterMapping); - } else { - valueList.set(index, newFilterMapping); - } - - setInput(valueList); - } - - private void removeFilterMappings(Collection selectedFilterMappings) { - List valueList = (List) viewer.getInput(); - valueList.removeAll(selectedFilterMappings); - 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 List getInput() { - List valueList = (List) viewer.getInput(); - if (valueList == null) { - valueList = new ArrayList(); - } - return valueList; - } - - public void propertyChanged(DataModelEvent event) { - if (this.propertyName.equals(event.getPropertyName())) { - viewer.setInput(event.getProperty()); - } - } - - @Override - public void dispose() { - model.removeListener(this); - super.dispose(); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java deleted file mode 100644 index 8b052af15..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java +++ /dev/null @@ -1,145 +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.servlet.ui.internal.wizard; - -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; - -public interface IWebWizardConstants { - - // AddServletWizard - public final static String ADD_SERVLET_WIZARD_WINDOW_TITLE = WEBUIMessages.ADD_SERVLET_WIZARD_WINDOW_TITLE; - public final static String ADD_SERVLET_WIZARD_PAGE_TITLE = WEBUIMessages.ADD_SERVLET_WIZARD_PAGE_TITLE; - public final static String ADD_SERVLET_WIZARD_PAGE_DESC = WEBUIMessages.ADD_SERVLET_WIZARD_PAGE_DESC; - - public final static String DEFAULT_PACKAGE = WEBUIMessages.DEFAULT_PACKAGE; - public final static String SELECT_CLASS_TITLE = WEBUIMessages.SELECT_CLASS_TITLE; - public final static String MAP_CLASS_NAME_TO_CLASS_ERROR_MSG = WEBUIMessages.MAP_CLASS_NAME_TO_CLASS_ERROR_MSG; - public final static String EMPTY_LIST_MSG = WEBUIMessages.EMPTY_LIST_MSG; - public final static String ADD_LABEL = WEBUIMessages.ADD_LABEL; - public final static String USE_EXISTING_SERVLET_CLASS = WEBUIMessages.USE_EXISTING_SERVLET_CLASS; - public final static String INIT_PARAM_TITLE = WEBUIMessages.INIT_PARAM_TITLE; - public final static String INIT_PARAM_LABEL = WEBUIMessages.INIT_PARAM_LABEL; - public final static String URL_MAPPINGS_TITLE = WEBUIMessages.URL_MAPPINGS_TITLE; - public final static String URL_MAPPINGS_LABEL = WEBUIMessages.URL_MAPPINGS_LABEL; - public final static String CHOOSE_SERVLET_CLASS = WEBUIMessages.CHOOSE_SERVLET_CLASS; - - // NewServletWizard - public final static String NEW_SERVLET_WIZARD_WINDOW_TITLE = WEBUIMessages.NEW_SERVLET_WIZARD_WINDOW_TITLE; - public final static String NEW_SERVLET_WIZARD_PAGE_TITLE = WEBUIMessages.NEW_SERVLET_WIZARD_PAGE_TITLE; - public final static String NEW_SERVLET_WIZARD_PAGE_DESC = WEBUIMessages.NEW_SERVLET_WIZARD_PAGE_DESC; - public final static String SERVLET_PACKAGE_LABEL = WEBUIMessages.SERVLET_PACKAGE_LABEL; - public final static String SERVLET_NAME_LABEL = WEBUIMessages.SERVLET_NAME_LABEL; - - // AddFilterWizard - public final static String ADD_FILTER_WIZARD_WINDOW_TITLE = WEBUIMessages.ADD_FILTER_WIZARD_WINDOW_TITLE; - public final static String ADD_FILTER_WIZARD_PAGE_TITLE = WEBUIMessages.ADD_FILTER_WIZARD_PAGE_TITLE; - public final static String ADD_FILTER_WIZARD_PAGE_DESC = WEBUIMessages.ADD_FILTER_WIZARD_PAGE_DESC; - - public final static String USE_EXISTING_FILTER_CLASS = WEBUIMessages.USE_EXISTING_FILTER_CLASS; - public final static String CHOOSE_FILTER_CLASS = WEBUIMessages.CHOOSE_FILTER_CLASS; - public final static String SERVLET_MAPPINGS_LABEL = WEBUIMessages.SERVLET_MAPPINGS_LABEL; - public final static String FILTER_MAPPINGS_LABEL = WEBUIMessages.FILTER_MAPPINGS_LABEL; - public final static String URL_SERVLET_LABEL = WEBUIMessages.URL_SERVLET_LABEL; - public final static String DISPATCHERS_LABEL = WEBUIMessages.DISPATCHERS_LABEL; - - public static String REQUEST = WEBUIMessages.DISPATCHER_REQUEST; - public static String FORWARD = WEBUIMessages.DISPATCHER_FORWARD; - public static String INCLUDE = WEBUIMessages.DISPATCHER_INCLUDE; - public static String ERROR = WEBUIMessages.DISPATCHER_ERROR; - - // NewFilterWizard - public final static String NEW_FILTER_WIZARD_WINDOW_TITLE = WEBUIMessages.NEW_FILTER_WIZARD_WINDOW_TITLE; - - // AddListenerWizard - public final static String ADD_LISTENER_WIZARD_WINDOW_TITLE = WEBUIMessages.ADD_LISTENER_WIZARD_WINDOW_TITLE; - public final static String ADD_LISTENER_WIZARD_PAGE_TITLE = WEBUIMessages.ADD_LISTENER_WIZARD_PAGE_TITLE; - public final static String ADD_LISTENER_WIZARD_PAGE_DESC = WEBUIMessages.ADD_LISTENER_WIZARD_PAGE_DESC; - - public final static String USE_EXISTING_LISTENER_CLASS = WEBUIMessages.USE_EXISTING_LISTENER_CLASS; - public final static String ADD_LISTENER_WIZARD_SERVLET_CONTEXT_EVENTS = WEBUIMessages.ADD_LISTENER_WIZARD_SERVLET_CONTEXT_EVENTS; - public final static String ADD_LISTENER_WIZARD_HTTP_SESSION_EVENTS = WEBUIMessages.ADD_LISTENER_WIZARD_HTTP_SESSION_EVENTS; - public final static String ADD_LISTENER_WIZARD_SERVLET_REQUEST_EVENTS = WEBUIMessages.ADD_LISTENER_WIZARD_SERVLET_REQUEST_EVENTS; - public final static String ADD_LISTENER_WIZARD_LIFECYCLE = WEBUIMessages.ADD_LISTENER_WIZARD_LIFECYCLE; - public final static String ADD_LISTENER_WIZARD_LIFECYCLE_L = WEBUIMessages.ADD_LISTENER_WIZARD_LIFECYCLE_L; - public final static String ADD_LISTENER_WIZARD_LIFECYCLE_I = WEBUIMessages.ADD_LISTENER_WIZARD_LIFECYCLE_I; - public final static String ADD_LISTENER_WIZARD_LIFECYCLE_Y = WEBUIMessages.ADD_LISTENER_WIZARD_LIFECYCLE_Y; - public final static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES = WEBUIMessages.ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES; - public final static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_C = WEBUIMessages.ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_C; - public final static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H = WEBUIMessages.ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H; - public final static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G = WEBUIMessages.ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G; - public final static String ADD_LISTENER_WIZARD_SESSION_MIGRATION = WEBUIMessages.ADD_LISTENER_WIZARD_SESSION_MIGRATION; - public final static String ADD_LISTENER_WIZARD_OBJECT_BINDING = WEBUIMessages.ADD_LISTENER_WIZARD_OBJECT_BINDING; - - // common - public final static String ADD_BUTTON_LABEL = WEBUIMessages.ADD_BUTTON_LABEL; - public final static String ADD_BUTTON_LABEL_A = WEBUIMessages.ADD_BUTTON_LABEL_A; - public final static String ADD_BUTTON_LABEL_D = WEBUIMessages.ADD_BUTTON_LABEL_D; - public final static String EDIT_BUTTON_LABEL = WEBUIMessages.EDIT_BUTTON_LABEL; - public final static String EDIT_BUTTON_LABEL_E = WEBUIMessages.EDIT_BUTTON_LABEL_E; - public final static String EDIT_BUTTON_LABEL_T = WEBUIMessages.EDIT_BUTTON_LABEL_T; - public final static String REMOVE_BUTTON_LABEL = WEBUIMessages.REMOVE_BUTTON_LABEL; - public final static String REMOVE_BUTTON_LABEL_R = WEBUIMessages.REMOVE_BUTTON_LABEL_R; - public final static String REMOVE_BUTTON_LABEL_V = WEBUIMessages.REMOVE_BUTTON_LABEL_V; - public final static String URL_PATTERN_TITLE = WEBUIMessages.URL_PATTERN_TITLE; - public final static String URL_PATTERN_LABEL = WEBUIMessages.URL_PATTERN_LABEL; - public final static String FOLDER_LABEL = WEBUIMessages.FOLDER_LABEL; - public final static String JAVA_PACKAGE_LABEL = WEBUIMessages.JAVA_PACKAGE_LABEL; - public final static String CLASS_NAME_LABEL = WEBUIMessages.CLASS_NAME_LABEL; - public final static String SUPERCLASS_LABEL = WEBUIMessages.SUPERCLASS_LABEL; - public final static String CONTAINER_SELECTION_DIALOG_TITLE = WEBUIMessages.CONTAINER_SELECTION_DIALOG_TITLE; - public final static String CONTAINER_SELECTION_DIALOG_DESC = WEBUIMessages.CONTAINER_SELECTION_DIALOG_DESC; - public final static String CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG = WEBUIMessages.CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG; - public final static String PACKAGE_SELECTION_DIALOG_TITLE = WEBUIMessages.PACKAGE_SELECTION_DIALOG_TITLE; - public final static String PACKAGE_SELECTION_DIALOG_DESC = WEBUIMessages.PACKAGE_SELECTION_DIALOG_DESC; - public final static String PACKAGE_SELECTION_DIALOG_MSG_NONE = WEBUIMessages.PACKAGE_SELECTION_DIALOG_MSG_NONE; - public final static String SUPERCLASS_SELECTION_DIALOG_TITLE = WEBUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE; - public final static String SUPERCLASS_SELECTION_DIALOG_DESC = WEBUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC; - public final static String INTERFACE_SELECTION_DIALOG_TITLE = WEBUIMessages.INTERFACE_SELECTION_DIALOG_TITLE; - public final static String INTERFACE_SELECTION_DIALOG_DESC = WEBUIMessages.INTERFACE_SELECTION_DIALOG_DESC; - public final static String INTERFACE_SELECTION_DIALOG_MSG_NONE = WEBUIMessages.INTERFACE_SELECTION_DIALOG_MSG_NONE; - public final static String JAVA_CLASS_MODIFIERS_LABEL = WEBUIMessages.JAVA_CLASS_MODIFIERS_LABEL; - public final static String JAVA_CLASS_INTERFACES_LABEL = WEBUIMessages.JAVA_CLASS_INTERFACES_LABEL; - public final static String JAVA_CLASS_METHOD_STUBS_LABEL = WEBUIMessages.JAVA_CLASS_METHOD_STUBS_LABEL; - public final static String JAVA_CLASS_PUBLIC_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_PUBLIC_CHECKBOX_LABEL; - public final static String JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_ABSTRACT_CHECKBOX_LABEL; - public final static String JAVA_CLASS_FINAL_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_FINAL_CHECKBOX_LABEL; - public final static String JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL; - public final static String JAVA_CLASS_MAIN_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_MAIN_CHECKBOX_LABEL; - public final static String JAVA_CLASS_INHERIT_CHECKBOX_LABEL = WEBUIMessages.JAVA_CLASS_INHERIT_CHECKBOX_LABEL; - public final static String JAVA_CLASS_BROWER_DIALOG_TITLE = WEBUIMessages.JAVA_CLASS_BROWER_DIALOG_TITLE; - public final static String JAVA_CLASS_BROWER_DIALOG_MESSAGE = WEBUIMessages.JAVA_CLASS_BROWER_DIALOG_MESSAGE; - - public final static String NAME_TITLE = WEBUIMessages.NAME_TITLE; - public final static String NAME_LABEL = WEBUIMessages.NAME_LABEL; - public final static String DESCRIPTION_TITLE = WEBUIMessages.DESCRIPTION_TITLE; - public final static String DESCRIPTION_LABEL = WEBUIMessages.DESCRIPTION_LABEL; - public final static String VALUE_TITLE = WEBUIMessages.VALUE_TITLE; - public final static String VALUE_LABEL = WEBUIMessages.VALUE_LABEL; - public final static String EMPTY_STRING = ""; //$NON-NLS-1$ - public final static String BROWSE_BUTTON_LABEL = WEBUIMessages.BROWSE_BUTTON_LABEL; - public static final String REMOVE_BUTTON = WEBUIMessages.REMOVE_BUTTON; - public final static String SELECT_ALL_BUTTON = WEBUIMessages.SELECT_ALL_BUTTON; - public final static String CLEAR_BUTTON = WEBUIMessages.CLEAR_BUTTON; - - - public final static String NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC = WEBUIMessages.NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC; - public final static String NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC = WEBUIMessages.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC; - - public final static String ImportWARAction_UI_ = WEBUIMessages.ImportWARAction_UI_; - public final static String ExportWARAction_UI_ = WEBUIMessages.ExportWARAction_UI_; - - public final static String NO_WEB_PROJECTS = WEBUIMessages.NO_WEB_PROJECTS; - - public static final String SERVLETS = WEBUIMessages.SERVLETS; - - public static final String CONVERT_TO_WEB_TITLE = WEBUIMessages.ConvertToWebTitle; - public static final String SELECT_WEB_VERSION = WEBUIMessages.SelectWebVersion; -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFileSelectionDialog.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFileSelectionDialog.java deleted file mode 100644 index 1c582c0e9..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFileSelectionDialog.java +++ /dev/null @@ -1,671 +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 - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DEFAULT_PACKAGE; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.j2ee.internal.dialogs.FilteredFileSelectionDialog; -import org.eclipse.jst.j2ee.internal.dialogs.TwoArrayQuickSorter; -import org.eclipse.jst.j2ee.internal.dialogs.TypedFileViewerFilter; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -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.Control; -import org.eclipse.swt.widgets.Event; -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.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.part.PageBook; - -/** - * Insert the type's description here. - * Creation date: (7/30/2001 11:16:36 AM) - */ -public class MultiSelectFilteredFileSelectionDialog extends - FilteredFileSelectionDialog implements SelectionListener { - - - private static class PackageRenderer extends LabelProvider { - private final Image PACKAGE_ICON = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKAGE); - - @Override - public String getText(Object element) { - IType type = (IType) element; - String p = type.getPackageFragment().getElementName(); - if ("".equals(p)) //$NON-NLS-1$ - p = DEFAULT_PACKAGE; - return (p + " - " + type.getPackageFragment().getParent().getPath().toString()); //$NON-NLS-1$ - } - @Override - public Image getImage(Object element) { - return PACKAGE_ICON; - } - } - - private static class TypeRenderer extends LabelProvider { - private final Image CLASS_ICON = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS); - - @Override - public String getText(Object element) { - IType e = ((IType) element); - return e.getElementName(); - } - - @Override - public Image getImage(Object element) { - return CLASS_ICON; - } - - } - public final static int JSP = 0; - public final static int SERVLET = 1; - protected Button fServletButton; - protected Button fJSPButton; - protected int fSelection = -1; - protected PageBook fPageBook = null; - protected Control fJspControl = null; - protected Control fServletControl = null; - protected Composite fChild = null; - // construction parameters - protected IRunnableContext fRunnableContext; - protected ILabelProvider fElementRenderer; - protected ILabelProvider fQualifierRenderer; - private Object[] fElements; - private boolean fIgnoreCase = true; - private String fUpperListLabel; - private String fLowerListLabel; - // SWT widgets - private Table fUpperList; - private Table fLowerList; - protected Text fText; - private IType[] fIT; - private String[] fRenderedStrings; - private int[] fElementMap; - private Integer[] fQualifierMap; - - private ISelectionStatusValidator fLocalValidator = null; - /** - * MultiSelectFilteredFileSelectionDialog constructor comment. - * @param parent Shell - * @param title String - * @param message String - * @parent extensions String[] - * @param allowMultiple boolean - */ - public MultiSelectFilteredFileSelectionDialog(Shell parent, String title, String message, String[] extensions, boolean allowMultiple, IProject project) { - super(parent, title, message, extensions, allowMultiple); - setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); - - if (title == null) - setTitle(WebAppEditResourceHandler.getString("File_Selection_UI_")); //$NON-NLS-1$ - String innerMessage = message; - if (innerMessage == null) - innerMessage = WebAppEditResourceHandler.getString("Select_a_file__UI_"); //$NON-NLS-1$ - setMessage(innerMessage); - setExtensions(extensions); - addFilter(new TypedFileViewerFilter(extensions)); - fLocalValidator = new SimpleTypedElementSelectionValidator(new Class[] { IFile.class }, allowMultiple); - setValidator(fLocalValidator); - - //StatusInfo currStatus = new StatusInfo(); - //currStatus.setOK(); - Status currStatus = new Status(Status.OK, ServletUIPlugin.PLUGIN_ID, Status.OK, "", null);//$NON-NLS-1$ - - updateStatus(currStatus); - fElementRenderer = new TypeRenderer(); - fQualifierRenderer = new PackageRenderer(); - fRunnableContext = ServletUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - try { - IJavaElement jelem = null; - IProject proj = null; - jelem = (IJavaElement) project.getAdapter(IJavaElement.class); - if (jelem == null) { - IResource resource = (IResource) project.getAdapter(IResource.class); - if (resource != null) { - proj = resource.getProject(); - if (proj != null) { - jelem = org.eclipse.jdt.core.JavaCore.create(proj); - } - } - } - if(jelem != null){ - IJavaProject jp = jelem.getJavaProject(); - - IType servletType = jp.findType(QUALIFIED_SERVLET); - // next 3 lines fix defect 177686 - if (servletType == null) { - return; - } - - ArrayList servletClasses = new ArrayList(); - ITypeHierarchy tH = servletType.newTypeHierarchy(jp, null); - IType[] types = tH.getAllSubtypes(servletType); - for (int i = 0; i < types.length; i++) { - if (types[i].isClass() && !servletClasses.contains(types[i])) - servletClasses.add(types[i]); - } - fIT = (IType[]) servletClasses.toArray(new IType[servletClasses.size()]); - servletClasses = null; - } - } catch (Exception e) { - ServletUIPlugin.log(e); - } - } - - /** - * @private - */ - @Override - protected void computeResult() { - if (fSelection == JSP) { - super.computeResult(); - } else { - IType type = (IType) getWidgetSelection(); - if (type != null) { - java.util.List result = new ArrayList(1); - result.add(type); - setResult(result); - } - } - } - - @Override - public void create() { - super.create(); - fText.setFocus(); - rematch(""); //$NON-NLS-1$ - updateOkState(); - } - - /** - * Creates and returns the contents of this dialog's - * button bar. - * <p> - * The <code>Dialog</code> implementation of this framework method - * lays out a button bar and calls the <code>createButtonsForButtonBar</code> - * framework method to populate it. Subclasses may override. - * </p> - * - * @param parent the parent composite to contain the button bar - * @return the button bar control - */ - @Override - protected Control createButtonBar(Composite parent) { - - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - - layout.numColumns = 2; - - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite composite2 = new Composite(composite, SWT.NONE); - - // create a layout with spacing and margins appropriate for the font size. - layout = new GridLayout(); - layout.numColumns = 0; // this is incremented by createButton - layout.makeColumnsEqualWidth = true; - layout.marginWidth = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_MARGIN); - layout.marginHeight = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_MARGIN); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_SPACING); - layout.verticalSpacing = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_SPACING); - - composite2.setLayout(layout); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); - composite2.setLayoutData(data); - - composite2.setFont(parent.getFont()); - - // Add the buttons to the button bar. - super.createButtonsForButtonBar(composite2); - - return composite; - } - - /* - * @private - */ - @Override - protected Control createDialogArea(Composite parent) { - GridData gd = new GridData(); - - fChild = new Composite(parent, SWT.NONE); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild, "com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$ - GridLayout gl = new GridLayout(); - gl.numColumns = 2; - gl.marginHeight = 0; - fChild.setLayout(gl); - - gd.verticalAlignment = GridData.FILL; - gd.grabExcessVerticalSpace = true; - fChild.setLayoutData(gd); - - // Create the Web Type radio buttons and text fields. - fServletButton = new Button(fChild, SWT.RADIO); - fServletButton.setText(WebAppEditResourceHandler.getString("Servlet_UI_")); //$NON-NLS-1$ = Servlet - gd = new GridData(); - fServletButton.setLayoutData(gd); - fServletButton.addSelectionListener(this); - - fJSPButton = new Button(fChild, SWT.RADIO); - fJSPButton.setText(WebAppEditResourceHandler.getString("JSP_UI_")); //$NON-NLS-1$ = JSP - gd = new GridData(); - fJSPButton.setLayoutData(gd); - fJSPButton.addSelectionListener(this); - - if (fSelection == JSP) - fJSPButton.setSelection(true); - else { - fServletButton.setSelection(true); - fSelection = SERVLET; - } - - fPageBook = new PageBook(fChild, SWT.NONE); - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.grabExcessVerticalSpace = true; - gd.horizontalSpan = 2; - fPageBook.setLayoutData(gd); - fJspControl = super.createDialogArea(fPageBook); - - Composite composite = new Composite(fPageBook, 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()); - - Label messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_servlet__1")); //$NON-NLS-1$ - - fText = createText(composite); - - messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Matching_servlets__2")); //$NON-NLS-1$ - - fUpperList = createUpperList(composite); - - messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Qualifier__3")); //$NON-NLS-1$ - - fLowerList = createLowerList(composite); - - fServletControl = composite; - - if (fSelection == JSP) - fPageBook.showPage(fJspControl); - else - fPageBook.showPage(fServletControl); - return parent; - } - - /** - * Creates the list widget and sets layout data. - * @return org.eclipse.swt.widgets.List - */ - private Table createLowerList(Composite parent) { - if (fLowerListLabel != null) - (new Label(parent, SWT.NONE)).setText(fLowerListLabel); - - Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - list.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - handleLowerSelectionChanged(); - } - }); - list.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event evt) { - handleLowerDoubleClick(); - } - }); - list.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fQualifierRenderer.dispose(); - } - }); - GridData spec = new GridData(); - spec.widthHint = convertWidthInCharsToPixels(50); - spec.heightHint = convertHeightInCharsToPixels(5); - spec.grabExcessVerticalSpace = true; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.FILL; - list.setLayoutData(spec); - return list; - } - - /** - * Creates the text widget and sets layout data. - * @return org.eclipse.swt.widgets.Text - */ - private Text createText(Composite parent) { - Text text = new Text(parent, SWT.BORDER); - GridData spec = new GridData(); - spec.grabExcessVerticalSpace = false; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.BEGINNING; - text.setLayoutData(spec); - Listener l = new Listener() { - public void handleEvent(Event evt) { - rematch(fText.getText()); - } - }; - text.addListener(SWT.Modify, l); - return text; - } - - /** - * Creates the list widget and sets layout data. - * @return org.eclipse.swt.widgets.List - */ - private Table createUpperList(Composite parent) { - if (fUpperListLabel != null) - (new Label(parent, SWT.NONE)).setText(fUpperListLabel); - - Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - list.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - handleUpperSelectionChanged(); - } - }); - list.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event evt) { - handleUpperDoubleClick(); - } - }); - list.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fElementRenderer.dispose(); - } - }); - GridData spec = new GridData(); - spec.widthHint = convertWidthInCharsToPixels(50); - spec.heightHint = convertHeightInCharsToPixels(15); - spec.grabExcessVerticalSpace = true; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.FILL; - list.setLayoutData(spec); - return list; - } - - /** - * @return the ID of the button that is 'pressed' on doubleClick in the lists. - * By default it is the OK button. - * Override to change this setting. - */ - protected int getDefaultButtonID() { - return IDialogConstants.OK_ID; - } - - public int getSelectedItem() { - return fSelection; - } - - protected Object getWidgetSelection() { - int i = fLowerList.getSelectionIndex(); - if (fQualifierMap != null) { - if (fQualifierMap.length == 1) - i = 0; - if (i < 0) { - return null; - } - Integer index = fQualifierMap[i]; - return fElements[index.intValue()]; - } - return null; - } - - protected final void handleLowerDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - protected final void handleLowerSelectionChanged() { - updateOkState(); - } - - protected final void handleUpperDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - protected final void handleUpperSelectionChanged() { - int selection = fUpperList.getSelectionIndex(); - if (selection >= 0) { - int i = fElementMap[selection]; - int k = i; - int length = fRenderedStrings.length; - while (k < length && fRenderedStrings[k].equals(fRenderedStrings[i])) { - k++; - } - updateLowerListWidget(i, k); - } else - updateLowerListWidget(0, 0); - } - - @Override - public int open() { - - if (fIT == null || fIT.length == 0) { - MessageDialog.openInformation(getShell(), WebAppEditResourceHandler.getString("Empty_List_1"), WebAppEditResourceHandler.getString("_INFO_No_servlets_exist_to_add._1")); //$NON-NLS-2$ //$NON-NLS-1$ - return CANCEL; - } - - setElements(fIT); - setInitialSelection(""); //$NON-NLS-1$ - return super.open(); - } - - /** - * update the list to reflect a new match string. - * @param matchString java.lang.String - */ - protected final void rematch(String matchString) { - int k = 0; - String text = fText.getText(); - StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false); //$NON-NLS-1$ - String lastString = null; - int length = fElements.length; - for (int i = 0; i < length; i++) { - while (i < length && fRenderedStrings[i].equals(lastString)) - i++; - if (i < length) { - lastString = fRenderedStrings[i]; - if (matcher.match(fRenderedStrings[i])) { - fElementMap[k] = i; - k++; - } - } - } - fElementMap[k] = -1; - - updateUpperListWidget(fElementMap, k); - } - - /** - * - * @return java.lang.String[] - * @param p org.eclipse.jface.elements.IIndexedProperty - */ - private String[] renderStrings(Object[] p) { - String[] strings = new String[p.length]; - int size = strings.length; - for (int i = 0; i < size; i++) { - strings[i] = fElementRenderer.getText(p[i]); - } - new TwoArrayQuickSorter(fIgnoreCase).sort(strings, p); - return strings; - } - - public void setElements(Object[] elements) { - fElements = elements; - fElementMap = new int[fElements.length + 1]; - fRenderedStrings = renderStrings(fElements); - } - - public void setSelectedItem(int newSelection) { - fSelection = newSelection; - } - - private void updateLowerListWidget(int from, int to) { - fLowerList.removeAll(); - fQualifierMap = new Integer[to - from]; - String[] qualifiers = new String[to - from]; - for (int i = from; i < to; i++) { - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - qualifiers[i - from] = fQualifierRenderer.getText(fElements[i]); - fQualifierMap[i - from] = new Integer(i); - } - - new TwoArrayQuickSorter(fIgnoreCase).sort(qualifiers, fQualifierMap); - - for (int i = 0; i < to - from; i++) { - TableItem ti = new TableItem(fLowerList, i); - ti.setText(qualifiers[i]); - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - Image img = fQualifierRenderer.getImage(fElements[from + i]); - if (img != null) - ti.setImage(img); - } - - if (fLowerList.getItemCount() > 0) - fLowerList.setSelection(0); - updateOkState(); - } - - private void updateOkState() { - Button okButton = getOkButton(); - if (okButton != null) - okButton.setEnabled(getWidgetSelection() != null); - } - - private void updateUpperListWidget(int[] indices, int size) { - fUpperList.setRedraw(false); - int itemCount = fUpperList.getItemCount(); - if (size < itemCount) - fUpperList.remove(0, itemCount - size - 1); - TableItem[] items = fUpperList.getItems(); - for (int i = 0; i < size; i++) { - TableItem ti = null; - if (i < itemCount) - ti = items[i]; - else - ti = new TableItem(fUpperList, i); - ti.setText(fRenderedStrings[indices[i]]); - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - Image img = fElementRenderer.getImage(fElements[indices[i]]); - if (img != null) - ti.setImage(img); - } - if (fUpperList.getItemCount() > 0) - fUpperList.setSelection(0); - fUpperList.setRedraw(true); - handleUpperSelectionChanged(); - } - - /** - * Sent when default selection occurs in the control. - * <p> - * For example, on some platforms default selection occurs - * in a List when the user double-clicks an item or types - * return in a Text. - * </p> - * - * @param e an event containing information about the default selection - */ - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - - /** - * Sent when selection occurs in the control. - * <p> - * For example, on some platforms selection occurs in - * a List when the user selects an item or items. - * </p> - * - * @param e an event containing information about the selection - */ - public void widgetSelected(SelectionEvent e) { - if (e.widget == fJSPButton) { - fSelection = JSP; - fPageBook.showPage(fJspControl); - updateOKStatus(); - } else if (e.widget == fServletButton) { - fSelection = SERVLET; - fPageBook.showPage(fServletControl); - } else - fSelection = -1; - } - - /** - * @see ElementTreeSelectionDialog#updateOKStatus() - */ - @Override - protected void updateOKStatus() { - super.updateOKStatus(); - Button okButton = getOkButton(); - if (okButton != null) - okButton.setEnabled(fLocalValidator.validate(getResult()).isOK()); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFilterFileSelectionDialog.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFilterFileSelectionDialog.java deleted file mode 100644 index 4b844655f..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/MultiSelectFilteredFilterFileSelectionDialog.java +++ /dev/null @@ -1,606 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_FILTER; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DEFAULT_PACKAGE; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.j2ee.internal.dialogs.FilteredFileSelectionDialog; -import org.eclipse.jst.j2ee.internal.dialogs.TwoArrayQuickSorter; -import org.eclipse.jst.j2ee.internal.dialogs.TypedFileViewerFilter; -import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionEvent; -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.Control; -import org.eclipse.swt.widgets.Event; -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.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.part.PageBook; - -/** - * Insert the type's description here. - * Creation date: (7/30/2001 11:16:36 AM) - */ -public class MultiSelectFilteredFilterFileSelectionDialog extends - FilteredFileSelectionDialog { - - - private static class PackageRenderer extends LabelProvider { - private final Image PACKAGE_ICON = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKAGE); - - @Override - public String getText(Object element) { - IType type = (IType) element; - String p = type.getPackageFragment().getElementName(); - if ("".equals(p)) //$NON-NLS-1$ - p = DEFAULT_PACKAGE; - return (p + " - " + type.getPackageFragment().getParent().getPath().toString()); //$NON-NLS-1$ - } - @Override - public Image getImage(Object element) { - return PACKAGE_ICON; - } - } - - private static class TypeRenderer extends LabelProvider { - private final Image CLASS_ICON = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS); - - @Override - public String getText(Object element) { - IType e = ((IType) element); - return e.getElementName(); - } - - @Override - public Image getImage(Object element) { - return CLASS_ICON; - } - - } - protected PageBook fPageBook = null; - protected Control fServletControl = null; - protected Composite fChild = null; - // construction parameters - protected IRunnableContext fRunnableContext; - protected ILabelProvider fElementRenderer; - protected ILabelProvider fQualifierRenderer; - private Object[] fElements; - private boolean fIgnoreCase = true; - private String fUpperListLabel; - private String fLowerListLabel; - // SWT widgets - private Table fUpperList; - private Table fLowerList; - protected Text fText; - private IType[] fIT; - private String[] fRenderedStrings; - private int[] fElementMap; - private Integer[] fQualifierMap; - - private ISelectionStatusValidator fLocalValidator = null; - /** - * This is a selection dialog for available servlet. - * @param parent Shell - * @param title String - * @param message String - * @parent extensions String[] - * @param allowMultiple boolean - */ - public MultiSelectFilteredFilterFileSelectionDialog(Shell parent, String title, String message, String[] extensions, boolean allowMultiple, IProject project) { - super(parent, title, message, extensions, allowMultiple); - setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); - - if (title == null) - setTitle(WebAppEditResourceHandler.getString("File_Selection_UI_")); //$NON-NLS-1$ - String innerMessage = message; - if (innerMessage == null) - innerMessage = WebAppEditResourceHandler.getString("Select_a_file__UI_"); //$NON-NLS-1$ - setMessage(innerMessage); - setExtensions(extensions); - addFilter(new TypedFileViewerFilter(extensions)); - fLocalValidator = new SimpleTypedElementSelectionValidator(new Class[] { IFile.class }, allowMultiple); - setValidator(fLocalValidator); - - //StatusInfo currStatus = new StatusInfo(); - //currStatus.setOK(); - Status currStatus = new Status(Status.OK, ServletUIPlugin.PLUGIN_ID, Status.OK, "", null);//$NON-NLS-1$ - - updateStatus(currStatus); - fElementRenderer = new TypeRenderer(); - fQualifierRenderer = new PackageRenderer(); - fRunnableContext = ServletUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - try { - IJavaElement jelem = null; - IProject proj = null; - jelem = (IJavaElement) project.getAdapter(IJavaElement.class); - if (jelem == null) { - IResource resource = (IResource) project.getAdapter(IResource.class); - if (resource != null) { - proj = resource.getProject(); - if (proj != null) { - jelem = org.eclipse.jdt.core.JavaCore.create(proj); - } - } - } - if(jelem != null){ - IJavaProject jp = jelem.getJavaProject(); - IType filterType = jp.findType(QUALIFIED_FILTER); - // next 3 lines fix defect 177686 - if (filterType == null) { - return; - } - ArrayList filterClasses = new ArrayList(); - ITypeHierarchy tH = filterType.newTypeHierarchy(jp, null); - IType[] types = tH.getAllSubtypes(filterType); - for (int i = 0; i < types.length; i++) { - if (types[i].isClass() && !filterClasses.contains(types[i])) - filterClasses.add(types[i]); - } - fIT = (IType[]) filterClasses.toArray(new IType[filterClasses.size()]); - filterClasses = null; - } - } catch (Exception e) { - ServletUIPlugin.log(e); - } - } - - /** - * @private - */ - @Override - protected void computeResult() { - IType type = (IType) getWidgetSelection(); - if (type != null) { - java.util.List result = new ArrayList(1); - result.add(type); - setResult(result); - } - } - - @Override - public void create() { - super.create(); - fText.setFocus(); - rematch(""); //$NON-NLS-1$ - updateOkState(); - } - - /** - * Creates and returns the contents of this dialog's - * button bar. - * <p> - * The <code>Dialog</code> implementation of this framework method - * lays out a button bar and calls the <code>createButtonsForButtonBar</code> - * framework method to populate it. Subclasses may override. - * </p> - * - * @param parent the parent composite to contain the button bar - * @return the button bar control - */ - @Override - protected Control createButtonBar(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - - layout.numColumns = 2; - - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite composite2 = new Composite(composite, SWT.NONE); - - // create a layout with spacing and margins appropriate for the font size. - layout = new GridLayout(); - layout.numColumns = 0; // this is incremented by createButton - layout.makeColumnsEqualWidth = true; - layout.marginWidth = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_MARGIN); - layout.marginHeight = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_MARGIN); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_SPACING); - layout.verticalSpacing = convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_SPACING); - - composite2.setLayout(layout); - - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); - composite2.setLayoutData(data); - - composite2.setFont(parent.getFont()); - - // Add the buttons to the button bar. - super.createButtonsForButtonBar(composite2); - - return composite; - } - - /* - * @private - */ - @Override - protected Control createDialogArea(Composite parent) { - GridData gd = new GridData(); - - fChild = new Composite(parent, SWT.NONE); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild, "com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$ - GridLayout gl = new GridLayout(); - gl.numColumns = 2; - gl.marginHeight = 5; - fChild.setLayout(gl); - - gd.verticalAlignment = GridData.FILL; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessVerticalSpace = true; - fChild.setLayoutData(gd); - - fPageBook = new PageBook(fChild, SWT.NONE); - gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.grabExcessVerticalSpace = true; - gd.horizontalSpan = 2; - fPageBook.setLayoutData(gd); - super.createDialogArea(fPageBook); - - Composite composite = new Composite(fPageBook, 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()); - - Label messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_filter__1")); //$NON-NLS-1$ - - fText = createText(composite); - - messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Matching_filters__2")); //$NON-NLS-1$ - - fUpperList = createUpperList(composite); - - messageLabel = new Label(composite, SWT.NONE); - gd = new GridData(); - messageLabel.setLayoutData(gd); - messageLabel.setText(WebAppEditResourceHandler.getString("Qualifier__3")); //$NON-NLS-1$ - - fLowerList = createLowerList(composite); - - fServletControl = composite; - - fPageBook.showPage(fServletControl); - return parent; - } - - /** - * Creates the list widget and sets layout data. - * @return org.eclipse.swt.widgets.List - */ - private Table createLowerList(Composite parent) { - if (fLowerListLabel != null) - (new Label(parent, SWT.NONE)).setText(fLowerListLabel); - - Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - list.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - handleLowerSelectionChanged(); - } - }); - list.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event evt) { - handleLowerDoubleClick(); - } - }); - list.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fQualifierRenderer.dispose(); - } - }); - GridData spec = new GridData(); - spec.widthHint = convertWidthInCharsToPixels(50); - spec.heightHint = convertHeightInCharsToPixels(5); - spec.grabExcessVerticalSpace = true; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.FILL; - list.setLayoutData(spec); - return list; - } - - /** - * Creates the text widget and sets layout data. - * @return org.eclipse.swt.widgets.Text - */ - private Text createText(Composite parent) { - Text text = new Text(parent, SWT.BORDER); - GridData spec = new GridData(); - spec.grabExcessVerticalSpace = false; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.BEGINNING; - text.setLayoutData(spec); - Listener l = new Listener() { - public void handleEvent(Event evt) { - rematch(fText.getText()); - } - }; - text.addListener(SWT.Modify, l); - return text; - } - - /** - * Creates the list widget and sets layout data. - * @return org.eclipse.swt.widgets.List - */ - private Table createUpperList(Composite parent) { - if (fUpperListLabel != null) - (new Label(parent, SWT.NONE)).setText(fUpperListLabel); - - Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - list.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event evt) { - handleUpperSelectionChanged(); - } - }); - list.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event evt) { - handleUpperDoubleClick(); - } - }); - list.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fElementRenderer.dispose(); - } - }); - GridData spec = new GridData(); - spec.widthHint = convertWidthInCharsToPixels(50); - spec.heightHint = convertHeightInCharsToPixels(15); - spec.grabExcessVerticalSpace = true; - spec.grabExcessHorizontalSpace = true; - spec.horizontalAlignment = GridData.FILL; - spec.verticalAlignment = GridData.FILL; - list.setLayoutData(spec); - return list; - } - - /** - * @return the ID of the button that is 'pressed' on doubleClick in the lists. - * By default it is the OK button. - * Override to change this setting. - */ - protected int getDefaultButtonID() { - return IDialogConstants.OK_ID; - } - - protected Object getWidgetSelection() { - int i = fLowerList.getSelectionIndex(); - if (fQualifierMap != null) { - if (fQualifierMap.length == 1) - i = 0; - if (i < 0) { - return null; - } - Integer index = fQualifierMap[i]; - return fElements[index.intValue()]; - } - return null; - } - - protected final void handleLowerDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - protected final void handleLowerSelectionChanged() { - updateOkState(); - } - - protected final void handleUpperDoubleClick() { - if (getWidgetSelection() != null) - buttonPressed(getDefaultButtonID()); - } - - protected final void handleUpperSelectionChanged() { - int selection = fUpperList.getSelectionIndex(); - if (selection >= 0) { - int i = fElementMap[selection]; - int k = i; - int length = fRenderedStrings.length; - while (k < length && fRenderedStrings[k].equals(fRenderedStrings[i])) { - k++; - } - updateLowerListWidget(i, k); - } else - updateLowerListWidget(0, 0); - } - - @Override - public int open() { - if (fIT == null || fIT.length == 0) { - MessageDialog.openInformation(getShell(), - WebAppEditResourceHandler.getString("Empty_List_1"), //$NON-NLS-1$ - WebAppEditResourceHandler.getString("_INFO_No_filters_exist_to_add._1")); //$NON-NLS-1$ - return CANCEL; - } - - setElements(fIT); - setInitialSelection(""); //$NON-NLS-1$ - return super.open(); - } - - /** - * update the list to reflect a new match string. - * @param matchString java.lang.String - */ - protected final void rematch(String matchString) { - int k = 0; - String text = fText.getText(); - StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false); //$NON-NLS-1$ - String lastString = null; - int length = fElements.length; - for (int i = 0; i < length; i++) { - while (i < length && fRenderedStrings[i].equals(lastString)) - i++; - if (i < length) { - lastString = fRenderedStrings[i]; - if (matcher.match(fRenderedStrings[i])) { - fElementMap[k] = i; - k++; - } - } - } - fElementMap[k] = -1; - - updateUpperListWidget(fElementMap, k); - } - - /** - * - * @return java.lang.String[] - * @param p org.eclipse.jface.elements.IIndexedProperty - */ - private String[] renderStrings(Object[] p) { - String[] strings = new String[p.length]; - int size = strings.length; - for (int i = 0; i < size; i++) { - strings[i] = fElementRenderer.getText(p[i]); - } - new TwoArrayQuickSorter(fIgnoreCase).sort(strings, p); - return strings; - } - - public void setElements(Object[] elements) { - fElements = elements; - fElementMap = new int[fElements.length + 1]; - fRenderedStrings = renderStrings(fElements); - } - - private void updateLowerListWidget(int from, int to) { - fLowerList.removeAll(); - fQualifierMap = new Integer[to - from]; - String[] qualifiers = new String[to - from]; - for (int i = from; i < to; i++) { - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - qualifiers[i - from] = fQualifierRenderer.getText(fElements[i]); - fQualifierMap[i - from] = new Integer(i); - } - - new TwoArrayQuickSorter(fIgnoreCase).sort(qualifiers, fQualifierMap); - - for (int i = 0; i < to - from; i++) { - TableItem ti = new TableItem(fLowerList, i); - ti.setText(qualifiers[i]); - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - Image img = fQualifierRenderer.getImage(fElements[from + i]); - if (img != null) - ti.setImage(img); - } - - if (fLowerList.getItemCount() > 0) - fLowerList.setSelection(0); - updateOkState(); - } - - private void updateOkState() { - Button okButton = getOkButton(); - if (okButton != null) - okButton.setEnabled(getWidgetSelection() != null); - } - - private void updateUpperListWidget(int[] indices, int size) { - fUpperList.setRedraw(false); - int itemCount = fUpperList.getItemCount(); - if (size < itemCount) - fUpperList.remove(0, itemCount - size - 1); - TableItem[] items = fUpperList.getItems(); - for (int i = 0; i < size; i++) { - TableItem ti = null; - if (i < itemCount) - ti = items[i]; - else - ti = new TableItem(fUpperList, i); - ti.setText(fRenderedStrings[indices[i]]); - // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer - Image img = fElementRenderer.getImage(fElements[indices[i]]); - if (img != null) - ti.setImage(img); - } - if (fUpperList.getItemCount() > 0) - fUpperList.setSelection(0); - fUpperList.setRedraw(true); - handleUpperSelectionChanged(); - } - - /** - * Sent when default selection occurs in the control. - * <p> - * For example, on some platforms default selection occurs - * in a List when the user double-clicks an item or types - * return in a Text. - * </p> - * - * @param e an event containing information about the default selection - */ - public void widgetDefaultSelected(SelectionEvent e) { - // Do nothing - } - - /** - * @see ElementTreeSelectionDialog#updateOKStatus() - */ - @Override - protected void updateOKStatus() { - super.updateOKStatus(); - Button okButton = getOkButton(); - if (okButton != null) - okButton.setEnabled(fLocalValidator.validate(getResult()).isOK()); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassOptionsWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassOptionsWizardPage.java deleted file mode 100644 index 94124e091..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassOptionsWizardPage.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.DESTROY; -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.DO_FILTER; -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.INIT; -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_FILTER; - -import java.util.Iterator; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.j2ee.internal.web.operations.FilterSupertypesValidator; -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.wst.common.frameworks.datamodel.IDataModel; - -public class NewFilterClassOptionsWizardPage extends - NewWebClassOptionsWizardPage implements ISelectionChangedListener { - - protected Button initButton; - protected Button destroyButton; - protected Button doFilterButton; - - public NewFilterClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) { - super(model, pageName, pageDesc, pageTitle); - } - - /** - * Create the composite with all the stubs - */ - @Override - protected void createStubsComposite(Composite parent) { - super.createStubsComposite(parent); - - Composite comp = new Composite(methodStubs, SWT.NULL); - GridLayout layout = new GridLayout(3, false); - layout.marginWidth = 0; - layout.makeColumnsEqualWidth = true; - comp.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - comp.setLayoutData(data); - - initButton = new Button(comp, SWT.CHECK); - initButton.setText("init"); //$NON-NLS-1$ - synchHelper.synchCheckbox(initButton, INIT, null); - - destroyButton = new Button(comp, SWT.CHECK); - destroyButton.setText("destroy"); //$NON-NLS-1$ - synchHelper.synchCheckbox(destroyButton, DESTROY, null); - - doFilterButton = new Button(comp, SWT.CHECK); - doFilterButton.setText("doFilter"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doFilterButton, DO_FILTER, null); - - interfaceViewer.addSelectionChangedListener(this); - - Dialog.applyDialogFont(parent); - } - - public void selectionChanged(SelectionChangedEvent event) { - StructuredSelection selection = (StructuredSelection) event.getSelection(); - - // if the selection is empty, then the remove button is disabled - if (selection.isEmpty()) { - removeButton.setEnabled(false); - return; - } - - // if the selection is non-empty and the filter extends a class which - // implements javax.servlet.Filter, then the remove button is enabled - if (FilterSupertypesValidator.isFilterSuperclass(model)) { - removeButton.setEnabled(true); - return; - } - - // if the selection is non-empty and the filter does not extend a class - // which implements javax.servlet.Filter, then the remove button is - // disabled only if the Filter interface is in the selection - Iterator iter = selection.iterator(); - while (iter.hasNext()) { - if (QUALIFIED_FILTER.equals(iter.next())) - removeButton.setEnabled(false); - return; - } - - // in all other cases the remove button is enabled - removeButton.setEnabled(true); - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassWizardPage.java deleted file mode 100644 index 01fec0e61..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassWizardPage.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT; -import static org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties.FILTER_MAPPINGS; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.CHOOSE_FILTER_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_FILTER_WIZARD_WINDOW_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.USE_EXISTING_FILTER_CLASS; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.internal.war.ui.util.WebFiltersGroupItemProvider; -import org.eclipse.jst.j2ee.internal.web.operations.FilterMappingItem; -import org.eclipse.jst.j2ee.internal.web.operations.IFilterMappingItem; -import org.eclipse.jst.j2ee.project.WebUtilities; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jee.ui.internal.navigator.web.GroupFiltersItemProvider; -import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewFilterClassWizardPage extends NewWebClassWizardPage { - - private final static String[] FILTEREXTENSIONS = { "java" }; //$NON-NLS-1$ - - public NewFilterClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, String moduleType) { - super(model, pageName, pageDesc, pageTitle, moduleType); - } - - @Override - protected String getUseExistingCheckboxText() { - return USE_EXISTING_FILTER_CLASS; - } - - @Override - protected String getUseExistingProperty() { - return USE_EXISTING_CLASS; - } - - @Override - protected IProject getExtendedSelectedProject(Object selection) { - if (selection instanceof WebFiltersGroupItemProvider) { - WebApp webApp = (WebApp)((WebFiltersGroupItemProvider) selection).getParent(); - return ProjectUtilities.getProject(webApp); - }else if(selection instanceof WebAppProvider){ - return ((WebAppProvider) selection).getProject(); - } if(selection instanceof GroupFiltersItemProvider){ - org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) ((GroupFiltersItemProvider) selection).getJavaEEObject(); - return ProjectUtilities.getProject(webApp); - } - - return super.getExtendedSelectedProject(selection); - } - - @Override - protected void handleClassButtonSelected() { - getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IProject project = (IProject) model.getProperty(PROJECT); - IVirtualComponent component = ComponentCore.createComponent(project); - MultiSelectFilteredFilterFileSelectionDialog ms = new MultiSelectFilteredFilterFileSelectionDialog( - getShell(), - NEW_FILTER_WIZARD_WINDOW_TITLE, - CHOOSE_FILTER_CLASS, - FILTEREXTENSIONS, - false, - project); - IContainer root = component.getRootFolder().getUnderlyingFolder(); - ms.setInput(root); - ms.open(); - if (ms.getReturnCode() == Window.OK) { - String qualifiedClassName = ""; //$NON-NLS-1$ - IType type = (IType) ms.getFirstResult(); - if (type != null) { - qualifiedClassName = type.getFullyQualifiedName(); - } - existingClassText.setText(qualifiedClassName); - } - getControl().setCursor(null); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.servlet.ui.internal.wizard.NewWebClassWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - - Object obj = getSelectedObject(); - if (isFilter(obj)) { - checkExistingButton(true); - existingClassText.setText(getFilterClass(obj)); - } else if (isServlet(obj)) { - String servletName = getServletName(obj); - // set the class name - classText.setText(makeFirstCharUppercase(servletName) + "Filter"); //$NON-NLS-1$ - // set the filter mapping - if (servletName != null) { - List<IFilterMappingItem> mappings = new ArrayList<IFilterMappingItem>(); - mappings.add(new FilterMappingItem(IFilterMappingItem.SERVLET_NAME, servletName)); - model.setProperty(FILTER_MAPPINGS, mappings); - } - } else if (isWebFolder(obj)) { - IFolder folder = (IFolder) obj; - // set the class name - String webFolderName = makeFirstCharUppercase(folder.getName()); - classText.setText(webFolderName + "Filter"); //$NON-NLS-1$ - // set the filter mapping - String webFolderPath = getWebResourcePath(folder); - List<IFilterMappingItem> mappings = new ArrayList<IFilterMappingItem>(); - mappings.add(new FilterMappingItem(IFilterMappingItem.URL_PATTERN, webFolderPath + "/*")); //$NON-NLS-1$ - model.setProperty(FILTER_MAPPINGS, mappings); - } else if (WebUtilities.isWebResource(obj)) { - IFile file = (IFile) obj; - // set the class name - String webResourceName = makeFirstCharUppercase(getFileNameWithouFileExtension(file)); - classText.setText(webResourceName + "Filter"); //$NON-NLS-1$ - // set the filter mapping - String webResourcePath = getWebResourcePath(file); - List<IFilterMappingItem> mappings = new ArrayList<IFilterMappingItem>(); - mappings.add(new FilterMappingItem(IFilterMappingItem.URL_PATTERN, webResourcePath)); - model.setProperty(FILTER_MAPPINGS, mappings); - } - - return composite; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassOptionsWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassOptionsWizardPage.java deleted file mode 100644 index 6d4d26558..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassOptionsWizardPage.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewListenerClassOptionsWizardPage extends NewWebClassOptionsWizardPage { - - public NewListenerClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) { - super(model, pageName, pageDesc, pageTitle); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassWizardPage.java deleted file mode 100644 index 5ffc33a88..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassWizardPage.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.USE_EXISTING_LISTENER_CLASS; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jst.j2ee.internal.war.ui.util.WebListenerGroupItemProvider; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jee.ui.internal.navigator.web.GroupListenerItemProvider; -import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewListenerClassWizardPage extends NewWebClassWizardPage { - - public NewListenerClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, String moduleType) { - super(model, pageName, pageDesc, pageTitle, moduleType); - } - - @Override - protected String getUseExistingCheckboxText() { - return USE_EXISTING_LISTENER_CLASS; - } - - @Override - protected String getUseExistingProperty() { - return USE_EXISTING_CLASS; - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - - existingButton.setEnabled(false); - - return composite; - } - - @Override - protected IProject getExtendedSelectedProject(Object selection) { - if (selection instanceof WebListenerGroupItemProvider) { - WebApp webApp = (WebApp)((WebListenerGroupItemProvider) selection).getParent(); - return ProjectUtilities.getProject(webApp); - }else if(selection instanceof WebAppProvider){ - return ((WebAppProvider) selection).getProject(); - } else if(selection instanceof GroupListenerItemProvider){ - org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) ((GroupListenerItemProvider) selection).getJavaEEObject(); - return ProjectUtilities.getProject(webApp); - } - - return super.getExtendedSelectedProject(selection); - } - - @Override - protected void handleClassButtonSelected() { - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassOptionsWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassOptionsWizardPage.java deleted file mode 100644 index d7d3779cc..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassOptionsWizardPage.java +++ /dev/null @@ -1,219 +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 - * David Schneider, david.schneider@unisys.com - bug 142500 - * Kiril Mitov, k.mitov@sap.com - bug 204160 - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET; - -import java.util.Iterator; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties; -import org.eclipse.jst.j2ee.internal.web.operations.ServletSupertypesValidator; -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.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewServletClassOptionsWizardPage extends - NewWebClassOptionsWizardPage implements ISelectionChangedListener { - - protected Button initButton; - protected Button destroyButton; - protected Button getConfigButton; - protected Button getInfoButton; - protected Button serviceButton; - protected Button doGetButton; - protected Button doPostButton; - protected Button doPutButton; - protected Button doDeleteButton; - protected Button doHeadButton; - protected Button doOptionsButton; - protected Button doTraceButton; - - public NewServletClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) { - super(model, pageName, pageDesc, pageTitle); - } - - @Override - protected void enter() { - super.enter(); - - boolean httpServlet = ServletSupertypesValidator.isHttpServletSuperclass(model); - doGetButton.setVisible(httpServlet); - doPostButton.setVisible(httpServlet); - doPutButton.setVisible(httpServlet); - doDeleteButton.setVisible(httpServlet); - doHeadButton.setVisible(httpServlet); - doOptionsButton.setVisible(httpServlet); - doTraceButton.setVisible(httpServlet); - } - - /** - * Create the composite with all the stubs - */ - @Override - protected void createStubsComposite(Composite parent) { - super.createStubsComposite(parent); - - inheritButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - boolean enable = inheritButton.getSelection(); - enableGenericServletButtons(enable); - enableHttpServletButtons(enable); - } - - public void widgetDefaultSelected(SelectionEvent e) { - //Do nothing - } - - private void enableGenericServletButtons(boolean enable) { - if (ServletSupertypesValidator.isGenericServletSuperclass(model)) { - initButton.setEnabled(enable); - destroyButton.setEnabled(enable); - getConfigButton.setEnabled(enable); - getInfoButton.setEnabled(enable); - serviceButton.setEnabled(enable); - } - } - - private void enableHttpServletButtons(boolean enable) { - doGetButton.setEnabled(enable); - doPostButton.setEnabled(enable); - doPutButton.setEnabled(enable); - doDeleteButton.setEnabled(enable); - doHeadButton.setEnabled(enable); - doOptionsButton.setEnabled(enable); - doTraceButton.setEnabled(enable); - } - }); - - Composite comp = new Composite(methodStubs, SWT.NULL); - GridLayout layout = new GridLayout(3, false); - layout.marginWidth = 0; - layout.makeColumnsEqualWidth = true; - comp.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - comp.setLayoutData(data); - - initButton = new Button(comp, SWT.CHECK); - initButton.setText("init"); //$NON-NLS-1$ - synchHelper.synchCheckbox(initButton, INewServletClassDataModelProperties.INIT, null); - - destroyButton = new Button(comp, SWT.CHECK); - destroyButton.setText("destroy"); //$NON-NLS-1$ - synchHelper.synchCheckbox(destroyButton, INewServletClassDataModelProperties.DESTROY, null); - - getConfigButton = new Button(comp, SWT.CHECK); - getConfigButton.setText("getServletConfig"); //$NON-NLS-1$ - synchHelper.synchCheckbox(getConfigButton, INewServletClassDataModelProperties.GET_SERVLET_CONFIG, null); - - getInfoButton = new Button(comp, SWT.CHECK); - getInfoButton.setText("getServletInfo"); //$NON-NLS-1$ - synchHelper.synchCheckbox(getInfoButton, INewServletClassDataModelProperties.GET_SERVLET_INFO, null); - - serviceButton = new Button(comp, SWT.CHECK); - serviceButton.setText("service"); //$NON-NLS-1$ - synchHelper.synchCheckbox(serviceButton, INewServletClassDataModelProperties.SERVICE, null); - - doGetButton = new Button(comp, SWT.CHECK); - doGetButton.setText("do&Get"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doGetButton, INewServletClassDataModelProperties.DO_GET, null); - - doPostButton = new Button(comp, SWT.CHECK); - doPostButton.setText("do&Post"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doPostButton, INewServletClassDataModelProperties.DO_POST, null); - - doPutButton = new Button(comp, SWT.CHECK); - doPutButton.setText("doP&ut"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doPutButton, INewServletClassDataModelProperties.DO_PUT, null); - - doDeleteButton = new Button(comp, SWT.CHECK); - doDeleteButton.setText("do&Delete"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doDeleteButton, INewServletClassDataModelProperties.DO_DELETE, null); - - doHeadButton = new Button(comp, SWT.CHECK); - doHeadButton.setText("doH&ead"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doHeadButton, INewServletClassDataModelProperties.DO_HEAD, null); - - doOptionsButton = new Button(comp, SWT.CHECK); - doOptionsButton.setText("do&Options"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doOptionsButton, INewServletClassDataModelProperties.DO_OPTIONS, null); - - doTraceButton = new Button(comp, SWT.CHECK); - doTraceButton.setText("do&Trace"); //$NON-NLS-1$ - synchHelper.synchCheckbox(doTraceButton, INewServletClassDataModelProperties.DO_TRACE, null); - - interfaceViewer.addSelectionChangedListener(this); - - Dialog.applyDialogFont(parent); - } - - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - removeButton.setEnabled(canRemoveSelectedInterfaces(selection)); - } - - @Override - protected KeyListener getInterfaceKeyListener() { - return new KeyListener() { - - public void keyPressed(KeyEvent e) { - } - - public void keyReleased(KeyEvent e) { - if (e.keyCode == SWT.DEL) { - IStructuredSelection selection = (IStructuredSelection) interfaceViewer.getSelection(); - if (canRemoveSelectedInterfaces(selection)) { - handleInterfaceRemoveButtonSelected(); - } - } - } - - }; - } - - private boolean canRemoveSelectedInterfaces(IStructuredSelection selection) { - // if the selection is empty, then remove is not possible - if (selection.isEmpty()) { - return false; - } - - // if the selection is non-empty and the servlet extends GenericServlet, then - // remove is possible - if (ServletSupertypesValidator.isGenericServletSuperclass(model)) { - return true; - } - - // if the selection is non-empty and the servlet does not extend GenericServlet, - // then remove is not possible only if the Servlet interface is in the selection - Iterator iter = selection.iterator(); - while (iter.hasNext()) { - if (QUALIFIED_SERVLET.equals(iter.next())) { - return false; - } - } - - // in all other cases remove is possible - return true; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java deleted file mode 100644 index daca4542d..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewServletClassWizardPage.java +++ /dev/null @@ -1,138 +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 - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT; -import static org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.IS_SERVLET_TYPE; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.CHOOSE_SERVLET_CLASS; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_SERVLET_WIZARD_WINDOW_TITLE; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.USE_EXISTING_SERVLET_CLASS; - -import org.eclipse.core.resources.IContainer; -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.jdt.core.IType; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.j2ee.internal.war.ui.util.WebServletGroupItemProvider; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jee.ui.internal.navigator.web.GroupServletItemProvider; -import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewServletClassWizardPage extends NewWebClassWizardPage { - - private final static String[] JSPEXTENSIONS = { "jsp" }; //$NON-NLS-1$ - - public NewServletClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, String moduleType) { - super(model, pageName, pageDesc, pageTitle, moduleType); - } - - @Override - protected String getUseExistingCheckboxText() { - return USE_EXISTING_SERVLET_CLASS; - } - - @Override - protected String getUseExistingProperty() { - return USE_EXISTING_CLASS; - } - - @Override - protected IProject getExtendedSelectedProject(Object selection) { - if (selection instanceof WebServletGroupItemProvider) { - WebApp webApp = (WebApp) ((WebServletGroupItemProvider) selection).getParent(); - return ProjectUtilities.getProject(webApp); - } else if(selection instanceof WebAppProvider){ - return ((WebAppProvider) selection).getProject(); - } else if(selection instanceof GroupServletItemProvider){ - org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) ((GroupServletItemProvider) selection).getJavaEEObject(); - return ProjectUtilities.getProject(webApp); - } - - return super.getExtendedSelectedProject(selection); - } - - @Override - protected void handleClassButtonSelected() { - getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IProject project = (IProject) model.getProperty(PROJECT); - IVirtualComponent component = ComponentCore.createComponent(project); - MultiSelectFilteredFileSelectionDialog ms = new MultiSelectFilteredFileSelectionDialog( - getShell(), - NEW_SERVLET_WIZARD_WINDOW_TITLE, - CHOOSE_SERVLET_CLASS, - JSPEXTENSIONS, - false, - project); - IContainer root = component.getRootFolder().getUnderlyingFolder(); - ms.setInput(root); - ms.open(); - if (ms.getReturnCode() == Window.OK) { - String qualifiedClassName = ""; //$NON-NLS-1$ - if (ms.getSelectedItem() == MultiSelectFilteredFileSelectionDialog.JSP) { - Object obj = ms.getFirstResult(); - if (obj != null) { - if (obj instanceof IFile) { - IFile file = (IFile) obj; - IPath pFull = file.getFullPath(); - IPath pBase = root.getFullPath(); - IPath path = pFull.removeFirstSegments(pBase.segmentCount()); - qualifiedClassName = path.makeAbsolute().toString(); - model.setProperty(IS_SERVLET_TYPE, new Boolean(false)); - } - } - } - else { - IType type = (IType) ms.getFirstResult(); - if (type != null) { - qualifiedClassName = type.getFullyQualifiedName(); - model.setProperty(IS_SERVLET_TYPE, new Boolean(true)); - } - } - existingClassText.setText(qualifiedClassName); - } - getControl().setCursor(null); - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - - Object obj = getSelectedObject(); - if (isServlet(obj)) { - checkExistingButton(true); - if (isServletJSP(obj)) { - existingClassText.setText(getServletJSPFile(obj)); - model.setBooleanProperty(IS_SERVLET_TYPE, false); - } else { - existingClassText.setText(getServletClass(obj)); - model.setBooleanProperty(IS_SERVLET_TYPE, true); - } - } else if (isJSP(obj)) { - checkExistingButton(true); - existingClassText.setText(getWebResourcePath((IResource) obj)); - model.setBooleanProperty(IS_SERVLET_TYPE, false); - } - - return composite; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebArtifactWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebArtifactWizard.java deleted file mode 100644 index d1fe45658..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebArtifactWizard.java +++ /dev/null @@ -1,117 +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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.OPEN_IN_EDITOR; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.QUALIFIED_CLASS_NAME; -import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS; - -import java.net.URL; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.j2ee.internal.plugin.J2EEEditorUtility; -import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public abstract class NewWebArtifactWizard extends NewWebWizard { - - protected static final String PAGE_ONE = "pageOne"; //$NON-NLS-1$ - protected static final String PAGE_TWO = "pageTwo"; //$NON-NLS-1$ - protected static final String PAGE_THREE = "pageThree"; //$NON-NLS-1$ - - public NewWebArtifactWizard(IDataModel model) { - super(model); - setWindowTitle(getTitle()); - setDefaultPageImageDescriptor(getImage()); - } - - @Override - protected boolean runForked() { - return false; - } - - @Override - public boolean canFinish() { - return getDataModel().isValid(); - } - - protected abstract String getTitle(); - - protected abstract ImageDescriptor getImage(); - - protected ImageDescriptor getImageFromJ2EEPlugin(String key) { - URL url = (URL) J2EEPlugin.getDefault().getImage(key); - return ImageDescriptor.createFromURL(url); - } - - protected void openJavaClass() { - try { - String className; - if (getDataModel().getBooleanProperty(USE_EXISTING_CLASS)) { - className = getDataModel().getStringProperty(CLASS_NAME); - } else { - className = getDataModel().getStringProperty(QUALIFIED_CLASS_NAME); - } - IProject p = (IProject) getDataModel().getProperty(PROJECT); - IJavaProject javaProject = J2EEEditorUtility.getJavaProject(p); - IFile file = (IFile) javaProject.findType(className).getResource(); - openEditor(file); - } catch (Exception cantOpen) { - ServletUIPlugin.log(cantOpen); - } - } - - protected void openWebFile() { - try { - String className = getDataModel().getStringProperty(CLASS_NAME); - IProject p = (IProject) getDataModel().getProperty(PROJECT); - IVirtualComponent component = ComponentCore.createComponent(p); - IContainer webContent = component.getRootFolder().getUnderlyingFolder(); - IFile file = webContent.getFile(new Path(className)); - openEditor(file); - } catch (Exception cantOpen) { - ServletUIPlugin.log(cantOpen); - } - } - - protected void openEditor(final IFile file) { - if (getDataModel().getBooleanProperty(OPEN_IN_EDITOR)) { - if (file != null) { - getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - try { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IDE.openEditor(page, file, true); - } - catch (PartInitException e) { - ServletUIPlugin.log(e); - } - } - }); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassOptionsWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassOptionsWizardPage.java deleted file mode 100644 index 5a55cca8e..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassOptionsWizardPage.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.ABSTRACT_METHODS; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CONSTRUCTOR; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.INTERFACES; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.JAVA_CLASS_INHERIT_CHECKBOX_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.JAVA_CLASS_METHOD_STUBS_LABEL; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.wizard.NewJavaClassOptionsWizardPage; -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.Label; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class NewWebClassOptionsWizardPage extends NewJavaClassOptionsWizardPage { - - protected Composite methodStubs; - - public NewWebClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) { - super(model, pageName, pageDesc, pageTitle); - } - - @Override - protected String[] getValidationPropertyNames() { - return new String[] { INTERFACES }; - } - - @Override - protected void createStubsComposite(Composite parent) { - Label stubLabel = new Label(parent, SWT.NONE); - stubLabel.setText(JAVA_CLASS_METHOD_STUBS_LABEL); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - stubLabel.setLayoutData(data); - - methodStubs = new Composite(parent, SWT.NULL); - methodStubs.setLayout(new GridLayout()); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.horizontalIndent = 15; - methodStubs.setLayoutData(data); - - constructorButton = new Button(methodStubs, SWT.CHECK); - constructorButton.setText(JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL); - synchHelper.synchCheckbox(constructorButton, CONSTRUCTOR, null); - - inheritButton = new Button(methodStubs, SWT.CHECK); - inheritButton.setText(JAVA_CLASS_INHERIT_CHECKBOX_LABEL); - synchHelper.synchCheckbox(inheritButton, ABSTRACT_METHODS, null); - - Dialog.applyDialogFont(parent); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassWizardPage.java deleted file mode 100644 index 07d996150..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebClassWizardPage.java +++ /dev/null @@ -1,450 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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: - * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import static org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel.USE_ANNOTATIONS; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME; -import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.GENERATE_DD; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.BROWSE_BUTTON_LABEL; -import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.CLASS_NAME_LABEL; -import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME; - -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.commonarchivecore.internal.util.J2EEFileUtil; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; -import org.eclipse.jst.j2ee.internal.wizard.AnnotationsStandaloneGroup; -import org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.j2ee.project.WebUtilities; -import org.eclipse.jst.j2ee.web.IServletConstants; -import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils; -import org.eclipse.jst.servlet.ui.internal.navigator.CompressedJavaProject; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -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.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.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -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.ProjectFacetsManager; - -public abstract class NewWebClassWizardPage extends NewJavaClassWizardPage { - - protected AnnotationsStandaloneGroup annotationsGroup; - - protected Button existingClassButton; - protected Label existingClassLabel; - protected Text existingClassText; - protected Button existingButton; - - public NewWebClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, String moduleType) { - super(model, pageName, pageDesc, pageTitle, moduleType); - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - Composite composite = super.createTopLevelComposite(parent); - - //bug 303931 - // projectNameLabel.setText(WEBUIMessages.WEB_PROJECT_LBL); - - addSeperator(composite, 3); - createUseExistingGroup(composite); - createAnnotationsGroup(composite); - - Dialog.applyDialogFont(composite); - - return composite; - } - - @Override - protected IProject getExtendedSelectedProject(Object selection) { - if (selection instanceof CompressedJavaProject) { - return ((CompressedJavaProject) selection).getProject().getProject(); - } - - return super.getExtendedSelectedProject(selection); - } - - protected abstract String getUseExistingCheckboxText(); - - protected abstract String getUseExistingProperty(); - - protected abstract void handleClassButtonSelected(); - - /** - * Create annotations group and set default enablement - */ - private void createAnnotationsGroup(Composite parent) { - if (isWebDocletProject()) { - annotationsGroup = new AnnotationsStandaloneGroup(parent, model, J2EEProjectUtilities.EJB.equals(projectType), - J2EEProjectUtilities.DYNAMIC_WEB.equals(projectType)); - if (!model.isPropertySet(PROJECT_NAME)) - return; - IProject project = ProjectUtilities.getProject(model.getStringProperty(PROJECT_NAME)); - annotationsGroup.setEnablement(project); - // annotationsGroup.setUseAnnotations(true); - } else { - // not a Web Doclet project - make sure that the USE_ANNOTATIONS property is off - model.setProperty(USE_ANNOTATIONS, false); - } - } - - private void createUseExistingGroup(Composite composite) { - existingButton = new Button(composite, SWT.CHECK); - existingButton.setText(getUseExistingCheckboxText()); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - existingButton.setLayoutData(data); - synchHelper.synchCheckbox(existingButton, getUseExistingProperty(), null); - existingButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleExistingButtonSelected(); - } - }); - - existingClassLabel = new Label(composite, SWT.LEFT); - existingClassLabel.setText(CLASS_NAME_LABEL); - existingClassLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - existingClassLabel.setEnabled(false); - - existingClassText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); - existingClassText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - existingClassText.setEnabled(false); - synchHelper.synchText(existingClassText, CLASS_NAME, null); - - existingClassButton = new Button(composite, SWT.PUSH); - existingClassButton.setText(BROWSE_BUTTON_LABEL); - existingClassButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - existingClassButton.setEnabled(false); - existingClassButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleClassButtonSelected(); - } - }); - } - - private void handleExistingButtonSelected() { - boolean enable = existingButton.getSelection(); - existingClassLabel.setEnabled(enable); - existingClassButton.setEnabled(enable); - packageText.setEnabled(!enable); - packageButton.setEnabled(!enable); - packageLabel.setEnabled(!enable); - classText.setEnabled(!enable); - classLabel.setEnabled(!enable); - superText.setEnabled(!enable); - superButton.setEnabled(!enable); - superLabel.setEnabled(!enable); - } - - private boolean isWebDocletProject() { - String projectName = model.getStringProperty(PROJECT_NAME); - if(projectName != null && !"".equals(projectName.trim())){ //$NON-NLS-1$ - IProject project = ProjectUtilities.getProject(projectName); - try { - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - return facetedProject.hasProjectFacet(WebFacetUtils.WEB_XDOCLET_FACET); - } catch (CoreException e) { - ServletUIPlugin.log(e); - } - } - return false; - } - - @Override - protected void validateProjectRequirements(IProject project) - { - if(JavaEEProjectUtilities.isWebFragmentProject(project)){ - // don't create a web DD, since web fragment project is created with one. - model.setBooleanProperty(GENERATE_DD, Boolean.FALSE); - return; - } - IVirtualComponent component = ComponentCore.createComponent(project); - if(component.getRootFolder() != null - && component.getRootFolder().getUnderlyingFolder() != null){ - IFile ddXmlFile = component.getRootFolder().getUnderlyingFolder().getFile(new Path(J2EEConstants.WEBAPP_DD_URI)); - if (!ddXmlFile.exists()) - { - // add a flag into the model to create the DD at the beginning of the operation - model.setBooleanProperty(GENERATE_DD, Boolean.TRUE); - } - else - { - // don't create a DD, since one already exists. - model.setBooleanProperty(GENERATE_DD, Boolean.FALSE); - } - } - } - - protected Object getSelectedObject() { - 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 ssel = (IStructuredSelection) selection; - if (ssel.size() != 1) - return null; - return ssel.getFirstElement(); - } - - private IType getPrimaryType(ICompilationUnit cu) { - return cu.getType(new Path(cu.getElementName()).removeFileExtension().toString()); - } - - private boolean isObjectSubclassOf(Object obj, String base) { - IJavaElement jelem = getJavaElement(obj); - - try { - if (jelem != null) { - if (jelem instanceof ICompilationUnit) { - ICompilationUnit cu = (ICompilationUnit) jelem; - jelem = getPrimaryType(cu); - } - - if (jelem instanceof IType && ((IType) jelem).isClass()) { - IType type = (IType) jelem; - ITypeHierarchy typeHierarchy = type.newTypeHierarchy(null); - for (IType superType : typeHierarchy.getAllSuperInterfaces(type)) { - if (base.equals(superType.getFullyQualifiedName())) - return true; - } - } - } - } catch (JavaModelException e) { - ServletUIPlugin.log(e); - } - - return false; - } - - protected boolean isServlet(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Servlet) - return true; - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Servlet) - return true; - - return isObjectSubclassOf(obj, IServletConstants.QUALIFIED_SERVLET); - } - - protected boolean isFilter(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Filter) - return true; - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Filter) - return true; - - return isObjectSubclassOf(obj, IServletConstants.QUALIFIED_FILTER); - } - - private String getJavaClass(Object obj) { - IJavaElement jelem = getJavaElement(obj); - - if (jelem == null) { - throw new IllegalArgumentException("the object parameter must be instance of IJavaElement"); //$NON-NLS-1$ - } - - if (jelem instanceof ICompilationUnit) { - ICompilationUnit cu = (ICompilationUnit) jelem; - jelem = getPrimaryType(cu); - } - return ((IType) jelem).getFullyQualifiedName(); - } - - protected String getServletClass(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Servlet) { - org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) obj; - return servlet.getServletClass(); - } - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Servlet) { - org.eclipse.jst.j2ee.webapplication.Servlet servlet = (org.eclipse.jst.j2ee.webapplication.Servlet) obj; - return servlet.getServletClass().getQualifiedName(); - } - - return getJavaClass(obj); - } - - protected String getFilterClass(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Filter) { - org.eclipse.jst.javaee.web.Filter filter = (org.eclipse.jst.javaee.web.Filter) obj; - return filter.getFilterClass(); - } - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Filter) { - org.eclipse.jst.j2ee.webapplication.Filter filter = (org.eclipse.jst.j2ee.webapplication.Filter) obj; - return filter.getFilterClass().getQualifiedName(); - } - - return getJavaClass(obj); - } - - protected String getServletName(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Servlet) { - org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) obj; - return servlet.getServletName(); - } - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Servlet) { - org.eclipse.jst.j2ee.webapplication.Servlet servlet = (org.eclipse.jst.j2ee.webapplication.Servlet) obj; - return servlet.getServletName(); - } - - String servletClass = getServletClass(obj); - IProject project = getJavaElement(obj).getJavaProject().getProject(); - IModelProvider provider = ModelProviderManager.getModelProvider(project); - Object modelObject = provider.getModelObject(); - if (modelObject instanceof org.eclipse.jst.javaee.web.WebApp) { - org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp) modelObject; - Iterator servlets = webApp.getServlets().iterator(); - while (servlets.hasNext()) { - org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) servlets.next(); - String qualified = servlet.getServletClass(); - if (qualified.equals(servletClass)) { - return servlet.getServletName(); - } - } - } else if (modelObject instanceof org.eclipse.jst.j2ee.webapplication.WebApp) { - org.eclipse.jst.j2ee.webapplication.WebApp webApp = (org.eclipse.jst.j2ee.webapplication.WebApp) modelObject; - Iterator servlets = webApp.getServlets().iterator(); - while (servlets.hasNext()) { - org.eclipse.jst.j2ee.webapplication.Servlet servlet = (org.eclipse.jst.j2ee.webapplication.Servlet) servlets.next(); - String qualified = servlet.getServletClass().getQualifiedName(); - if (qualified.equals(servletClass)) { - return servlet.getServletName(); - } - } - } - - return null; - } - - protected boolean isServletJSP(Object obj) { - return getServletJSPFile(obj) != null; - } - - protected String getServletJSPFile(Object obj) { - if (obj instanceof org.eclipse.jst.javaee.web.Servlet) { - org.eclipse.jst.javaee.web.Servlet servlet = (org.eclipse.jst.javaee.web.Servlet) obj; - return servlet.getJspFile(); - } - - if (obj instanceof org.eclipse.jst.j2ee.webapplication.Servlet) { - org.eclipse.jst.j2ee.webapplication.Servlet servlet = (org.eclipse.jst.j2ee.webapplication.Servlet) obj; - org.eclipse.jst.j2ee.webapplication.WebType webType = servlet.getWebType(); - if (webType.isJspType()) { - org.eclipse.jst.j2ee.webapplication.JSPType jspType = (org.eclipse.jst.j2ee.webapplication.JSPType) webType; - return jspType.getJspFile(); - } - } - - return null; - } - - protected boolean isWebFolder(Object obj) { - if (obj instanceof IFolder) { - return WebUtilities.isWebResource(obj); - } - return false; - } - - protected boolean isJSP(Object obj) { - if (obj instanceof IFile) { - IFile file = (IFile) obj; - return WebUtilities.isWebResource(file) && file.getName().endsWith(J2EEFileUtil.DOT_JSP); - } - return false; - } - - protected String getWebResourcePath(IResource resource) { - IVirtualComponent comp = ComponentCore.createComponent(resource.getProject()); - if (comp != null) { - IPath rootPath = comp.getRootFolder().getWorkspaceRelativePath(); - return "/" + resource.getFullPath().makeRelativeTo(rootPath).toString(); //$NON-NLS-1$ - } - return null; - } - - protected String makeFirstCharUppercase(String str) { - if (str == null || str.length() == 0) - return str; - - StringBuilder builder = new StringBuilder(str); - builder.setCharAt(0, Character.toUpperCase(builder.charAt(0))); - return builder.toString(); - } - - protected String getFileNameWithouFileExtension(IFile file) { - String name = file.getName(); - String ext = file.getFileExtension(); - - if (ext == null) - return name; - - return name.substring(0, name.length() - (ext.length() + 1)); - } - - protected void checkExistingButton(boolean state) { - existingButton.setSelection(state); - existingButton.notifyListeners(SWT.Selection, new Event()); - } - - @Override - protected boolean isProjectValid(IProject project) { - boolean result; - try { - result = project.isAccessible() && - project.hasNature(IModuleConstants.MODULE_NATURE_ID) && - (JavaEEProjectUtilities.isDynamicWebProject(project) || JavaEEProjectUtilities.isWebFragmentProject(project)); - } catch (CoreException ce) { - result = false; - } - return result; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebWizard.java deleted file mode 100644 index d1f6fb952..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewWebWizard.java +++ /dev/null @@ -1,57 +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 - * Kaloyan Raev, kaloyan.raev@sap.com - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; - -/** - * @author jlanuti - */ -public abstract class NewWebWizard extends DataModelWizard implements INewWizard { - - /** - * @param model - */ - public NewWebWizard(IDataModel model) { - super(model); - } - - /** - * Default constructor - */ - public NewWebWizard() { - super(); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - getDataModel(); - } - - protected IStructuredSelection getCurrentSelection() { - IWorkbenchWindow window = ServletUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - } - return null; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletDataModelSyncHelper.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletDataModelSyncHelper.java deleted file mode 100644 index ce69dac05..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletDataModelSyncHelper.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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.Combo; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.Widget; -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.DataModelSynchHelper; - -public class ServletDataModelSyncHelper extends DataModelSynchHelper { - protected Map widgetToValueHash; - protected MultipleCheckboxSelectionListener multipleCheckboxSelectionListener; - - public ServletDataModelSyncHelper(IDataModel model) { - super(model); - } - - /** - * Sets the UI to have the property value defined in the model - * - * @param propertyName - * @link IDataModelListener for the flag values. - */ - @Override - public void synchUIWithModel(final String propertyName, final int flag) { - if (null != propertyToWidgetHash && propertyToWidgetHash.containsKey(propertyName)) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - Object obj = propertyToWidgetHash.get(propertyName); - if (obj != null) { - if (obj instanceof List) { - List widgets = (List) obj; - for (int i = 0; i < widgets.size(); i++) { - currentWidget = (Widget) widgets.get(i); - synchUIWithModel(propertyName, flag, currentWidget); - } - } else { - currentWidget = (Widget) obj; - synchUIWithModel(propertyName, flag, currentWidget); - } - } - } finally { - currentWidget = null; - } - } - }); - } - } - - protected void synchUIWithModel(final String propertyName, final int flag, Widget currentWidget) { - if (currentWidget != null && currentWidget != currentWidgetFromEvent) { - //We must hold a copy in a temp variable because setting the widget value - //may trigger an event that will cause this method to be called again. - Widget widget = currentWidget; - try { - ignoreModifyEvent = true; - if (currentWidget instanceof Text) - setWidgetValue(propertyName, flag, (Text) currentWidget); - else if (currentWidget instanceof Combo) { - setWidgetValue(propertyName, flag, (Combo) currentWidget); - } else if (currentWidget instanceof Button) - setWidgetValue(propertyName, flag, (Button) currentWidget); - else if (currentWidget instanceof Label) - setWidgetValue(propertyName, flag, (Label) currentWidget); - else if (currentWidget instanceof List) - setWidgetValue(propertyName, flag, (org.eclipse.swt.widgets.List) currentWidget); - else if (currentWidget instanceof Table) - setWidgetValue(propertyName, flag, (Table) currentWidget); - else if (currentWidget instanceof Tree) - setWidgetValue(propertyName, flag, (Tree) currentWidget); - } finally { - ignoreModifyEvent = false; - } - //Pass the copy of the currentWidget - setEnablement((Control) widget, dataModel.isPropertyEnabled(propertyName)); - } - } - - @Override - protected void setWidgetValue(String propertyName, int flag, Button button) { - if ((button.getStyle() & SWT.CHECK) == SWT.CHECK) { - Object propertyValue = dataModel.getProperty(propertyName); - if (propertyValue instanceof java.util.List) { - List value = (List) propertyValue; - Object buttonValue = widgetToValueHash.get(button); - boolean exists = value.contains(buttonValue); - if (button.getSelection() != exists) { - button.setSelection(exists); - } - return; - } - } - } - - private class MultipleCheckboxSelectionListener implements SelectionListener { - public void widgetSelected(SelectionEvent e) { - Button button = (Button) e.getSource(); - if (currentWidget == button) - return; - try { - currentWidgetFromEvent = button; - String propertyName = (String) widgetToPropertyHash.get(button); - Object propertyValue = widgetToValueHash.get(button); - - Object contents = dataModel.getProperty(propertyName); - - if (contents == null) { - contents = new ArrayList(); - } - if (contents instanceof java.util.List) { - List list = (List) contents; - if (button.getSelection()) { - if (!list.contains(propertyValue)) - list.add(propertyValue); - } else { - list.remove(propertyValue); - } - setProperty(propertyName, list); - dataModel.notifyPropertyChange(propertyName, DataModelEvent.VALUE_CHG); - } - } finally { - currentWidgetFromEvent = null; - } - } - - - - public void widgetDefaultSelected(SelectionEvent e) { - } - } - - public void synchCheckbox(Button checkbox, String textValue, String propertyName, Control[] dependentControls) { - setCompositeValue(checkbox, textValue); - synchComposite(checkbox, propertyName, dependentControls); - if (multipleCheckboxSelectionListener == null) { - multipleCheckboxSelectionListener = new MultipleCheckboxSelectionListener(); - } - checkbox.addSelectionListener(multipleCheckboxSelectionListener); - } - - protected void setCompositeValue(Widget widget, Object value) { - if (widgetToValueHash == null) - widgetToValueHash = new HashMap(); - widgetToValueHash.put(widget, value); - } - - @Override - protected void synchComposite(Widget widget, String propertyName, Control[] depControls) { - if (null == widgetToPropertyHash) - widgetToPropertyHash = new HashMap(); - if (propertyToWidgetHash == null) - propertyToWidgetHash = new HashMap(); - widgetToPropertyHash.put(widget, propertyName); - Object value = propertyToWidgetHash.get(propertyName); - List widgets; - if (value == null || !(value instanceof List)) { - widgets = new ArrayList(); - } else { - widgets = (List) value; - } - widgets.add(widget); - propertyToWidgetHash.put(propertyName, widgets); - - if (depControls != null) { - if (widgetToDepControls == null) - widgetToDepControls = new HashMap(); - widgetToDepControls.put(widget, depControls); - } - synchUIWithModel(propertyName, DataModelEvent.VALUE_CHG); - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/SimpleTypedElementSelectionValidator.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/SimpleTypedElementSelectionValidator.java deleted file mode 100644 index a05cca457..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/SimpleTypedElementSelectionValidator.java +++ /dev/null @@ -1,79 +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.servlet.ui.internal.wizard; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; - -/** - * Implementation of a <code>ISelectionValidator</code> to validate the type - * of an element. Empty selections are not accepted. - */ -public class SimpleTypedElementSelectionValidator implements ISelectionStatusValidator { - - private IStatus fgErrorStatus = new Status(IStatus.ERROR, ServletUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ - private IStatus fgOKStatus = new Status(IStatus.OK, ServletUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ - - private Class[] fAcceptedTypes; - private boolean fAllowMultipleSelection; - - /** - * @param acceptedTypes - * The types accepted by the validator - * @param allowMultipleSelection - * If set to <code>true</code>, the validator allows - * multiple selection. - */ - public SimpleTypedElementSelectionValidator(Class[] acceptedTypes, boolean allowMultipleSelection) { - org.eclipse.core.runtime.Assert.isNotNull(acceptedTypes); - fAcceptedTypes = acceptedTypes; - fAllowMultipleSelection = allowMultipleSelection; - } - - /* - * @see org.eclipse.ui.dialogs.ISelectionValidator#isValid(java.lang.Object) - */ - public IStatus validate(Object[] elements) { - if (isValid(elements)) { - return fgOKStatus; - } - return fgErrorStatus; - } - - private boolean isOfAcceptedType(Object o) { - for (int i = 0; i < fAcceptedTypes.length; i++) { - if (fAcceptedTypes[i].isInstance(o)) { - return true; - } - } - return false; - } - - private boolean isValid(Object[] selection) { - if (selection.length == 0) { - return false; - } - - if (!fAllowMultipleSelection && selection.length != 1) { - return false; - } - - for (int i = 0; i < selection.length; i++) { - Object o = selection[i]; - if (!isOfAcceptedType(o)) { - return false; - } - } - return true; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringArrayTableWizardSectionCallback.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringArrayTableWizardSectionCallback.java deleted file mode 100644 index e75f6c1a9..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringArrayTableWizardSectionCallback.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import org.eclipse.jst.j2ee.internal.wizard.StringArrayTableWizardSection.StringArrayDialogCallback; -import org.eclipse.swt.widgets.Text; - -/** - * Implementation of the <code>StringArrayDialogCallback</code> interface for - * both "Initialization Parameters" and "URL Mappings" table views. - */ -public class StringArrayTableWizardSectionCallback implements - StringArrayDialogCallback { - - /** - * The first text field should not be empty. - */ - public boolean validate(Text[] texts) { - if (texts.length > 0) { - return texts[0].getText().trim().length() > 0; - } - return true; - } - - /** - * Trims the text values. - */ - 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().trim(); - } - return result; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringMatcher.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringMatcher.java deleted file mode 100644 index d148b9c21..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/StringMatcher.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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 - * - * - * Note: this class was copied from org.eclipse.jst.internal.ui.util - * It has much requested as an API since there are a dozen such copies throughout - * Eclipse and related projects. (Such as, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=12214) - * These requests have been rejected since, all users should eventually migrate to use javax.regx - * counterparts instead. - * - *******************************************************************************/ -package org.eclipse.jst.servlet.ui.internal.wizard; - -import java.util.*; - -/** - * A string pattern matcher. Supports '*' and '?' wildcards. - */ -public class StringMatcher { - protected String fPattern; - protected int fLength; // pattern length - protected boolean fIgnoreWildCards; - protected boolean fIgnoreCase; - protected boolean fHasLeadingStar; - protected boolean fHasTrailingStar; - protected String fSegments[]; //the given pattern is split into * separated segments - - /* boundary value beyond which we don't need to search in the text */ - protected int fBound= 0; - - - protected static final char fSingleWildCard= '\u0000'; - - public static class Position { - int start; //inclusive - int end; //exclusive - public Position(int start, int end) { - this.start= start; - this.end= end; - } - public int getStart() { - return start; - } - public int getEnd() { - return end; - } - } - /** - * StringMatcher constructor takes in a String object that is a simple - * pattern. The pattern may contain '*' for 0 and many characters and - * '?' for exactly one character. - * - * Literal '*' and '?' characters must be escaped in the pattern - * e.g., "\*" means literal "*", etc. - * - * Escaping any other character (including the escape character itself), - * just results in that character in the pattern. - * e.g., "\a" means "a" and "\\" means "\" - * - * If invoking the StringMatcher with string literals in Java, don't forget - * escape characters are represented by "\\". - * - * @param pattern the pattern to match text against - * @param ignoreCase if true, case is ignored - * @param ignoreWildCards if true, wild cards and their escape sequences are ignored - * (everything is taken literally). - */ - public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) { - if (pattern == null) - throw new IllegalArgumentException(); - fIgnoreCase= ignoreCase; - fIgnoreWildCards= ignoreWildCards; - fPattern= pattern; - fLength= pattern.length(); - - if (fIgnoreWildCards) { - parseNoWildCards(); - } else { - parseWildCards(); - } - } - /** - * Find the first occurrence of the pattern between <code>start</code)(inclusive) - * and <code>end</code>(exclusive). - * @param text the String object to search in - * @param start the starting index of the search range, inclusive - * @param end the ending index of the search range, exclusive - * @return an <code>StringMatcher.Position</code> object that keeps the starting - * (inclusive) and ending positions (exclusive) of the first occurrence of the - * pattern in the specified range of the text; return null if not found or subtext - * is empty (start==end). A pair of zeros is returned if pattern is empty string - * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc" - * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned - */ - public StringMatcher.Position find(String text, int start, int end) { - if (text == null) - throw new IllegalArgumentException(); - - int tlen= text.length(); - int innerStart = start; - int innerEnd = end; - if (innerStart < 0) - innerStart= 0; - if (innerEnd > tlen) - innerEnd= tlen; - if (innerEnd < 0 ||innerStart >= innerEnd ) - return null; - if (fLength == 0) - return new Position(innerStart, innerStart); - if (fIgnoreWildCards) { - int x= posIn(text, innerStart, innerEnd); - if (x < 0) - return null; - return new Position(x, x+fLength); - } - - int segCount= fSegments.length; - if (segCount == 0)//pattern contains only '*'(s) - return new Position (innerStart, innerEnd); - - int curPos= innerStart; - int matchStart= -1; - int i; - for (i= 0; i < segCount && curPos < innerEnd; ++i) { - String current= fSegments[i]; - int nextMatch= regExpPosIn(text, curPos, innerEnd, current); - if (nextMatch < 0 ) - return null; - if(i == 0) - matchStart= nextMatch; - curPos= nextMatch + current.length(); - } - if (i < segCount) - return null; - return new Position(matchStart, curPos); - } - /** - * match the given <code>text</code> with the pattern - * @return true if matched eitherwise false - * @param text a String object - */ - public boolean match(String text) { - return match(text, 0, text.length()); - } - /** - * Given the starting (inclusive) and the ending (exclusive) positions in the - * <code>text</code>, determine if the given substring matches with aPattern - * @return true if the specified portion of the text matches the pattern - * @param text a String object that contains the substring to match - * @param start marks the starting position (inclusive) of the substring - * @param end marks the ending index (exclusive) of the substring - */ - public boolean match(String text, int start, int end) { - if (null == text) - throw new IllegalArgumentException(); - - int innerStart = start; - int innerEnd = end; - - if (innerStart > innerEnd) - return false; - - if (fIgnoreWildCards) - return (innerEnd - innerStart == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, innerStart, fLength); - int segCount= fSegments.length; - if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s) - return true; - if (innerStart == innerEnd) - return fLength == 0; - if (fLength == 0) - return innerStart == innerEnd; - - int tlen= text.length(); - if (innerStart < 0) - innerStart= 0; - if (innerEnd > tlen) - innerEnd= tlen; - - int tCurPos= innerStart; - int bound= innerEnd - fBound; - if ( bound < 0) - return false; - int i=0; - String current= fSegments[i]; - int segLength= current.length(); - - /* process first segment */ - if (!fHasLeadingStar){ - if(!regExpRegionMatches(text, innerStart, current, 0, segLength)) { - return false; - } - ++i; - tCurPos= tCurPos + segLength; - } - if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) { - // only one segment to match, no wildcards specified - return tCurPos == innerEnd; - } - /* process middle segments */ - while (i < segCount) { - current= fSegments[i]; - int currentMatch; - int k= current.indexOf(fSingleWildCard); - if (k < 0) { - currentMatch= textPosIn(text, tCurPos, innerEnd, current); - if (currentMatch < 0) - return false; - } else { - currentMatch= regExpPosIn(text, tCurPos, innerEnd, current); - if (currentMatch < 0) - return false; - } - tCurPos= currentMatch + current.length(); - i++; - } - - /* process final segment */ - if (!fHasTrailingStar && tCurPos != innerEnd) { - int clen= current.length(); - return regExpRegionMatches(text, innerEnd - clen, current, 0, clen); - } - return i == segCount ; - } - - /** - * This method parses the given pattern into segments seperated by wildcard '*' characters. - * Since wildcards are not being used in this case, the pattern consists of a single segment. - */ - private void parseNoWildCards() { - fSegments= new String[1]; - fSegments[0]= fPattern; - fBound= fLength; - } - /** - * Parses the given pattern into segments seperated by wildcard '*' characters. - */ - private void parseWildCards() { - if(fPattern.startsWith("*"))//$NON-NLS-1$ - fHasLeadingStar= true; - if(fPattern.endsWith("*")) {//$NON-NLS-1$ - /* make sure it's not an escaped wildcard */ - if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') { - fHasTrailingStar= true; - } - } - - Vector temp= new Vector(); - - int pos= 0; - StringBuffer buf= new StringBuffer(); - while (pos < fLength) { - char c= fPattern.charAt(pos++); - switch (c) { - case '\\': - if (pos >= fLength) { - buf.append(c); - } else { - char next= fPattern.charAt(pos++); - /* if it's an escape sequence */ - if (next == '*' || next == '?' || next == '\\') { - buf.append(next); - } else { - /* not an escape sequence, just insert literally */ - buf.append(c); - buf.append(next); - } - } - break; - case '*': - if (buf.length() > 0) { - /* new segment */ - temp.addElement(buf.toString()); - fBound += buf.length(); - buf.setLength(0); - } - break; - case '?': - /* append special character representing single match wildcard */ - buf.append(fSingleWildCard); - break; - default: - buf.append(c); - } - } - - /* add last buffer to segment list */ - if (buf.length() > 0) { - temp.addElement(buf.toString()); - fBound += buf.length(); - } - - fSegments= new String[temp.size()]; - temp.copyInto(fSegments); - } - /** - * @param text a string which contains no wildcard - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int posIn(String text, int start, int end) {//no wild card in pattern - int max= end - fLength; - - if (!fIgnoreCase) { - int i= text.indexOf(fPattern, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i= start; i <= max; ++i) { - if (text.regionMatches(true, i, fPattern, 0, fLength)) - return i; - } - - return -1; - } - /** - * @param text a simple regular expression that may only contain '?'(s) - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @param p a simple regular expression that may contains '?' - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int regExpPosIn(String text, int start, int end, String p) { - int plen= p.length(); - - int max= end - plen; - for (int i= start; i <= max; ++i) { - if (regExpRegionMatches(text, i, p, 0, plen)) - return i; - } - return -1; - } - - - protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { - int innerPlen = plen; - int innerTStart = tStart; - int innerPStart = pStart; - while (innerPlen-- > 0) { - char tchar= text.charAt(innerTStart++); - char pchar= p.charAt(innerPStart++); - - /* process wild cards */ - if (!fIgnoreWildCards) { - /* skip single wild cards */ - if (pchar == fSingleWildCard) { - continue; - } - } - if (pchar == tchar) - continue; - if (fIgnoreCase) { - if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar)) - continue; - // comparing after converting to upper case doesn't handle all cases; - // also compare after converting to lower case - if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar)) - continue; - } - return false; - } - return true; - } - /** - * @param text the string to match - * @param start the starting index in the text for search, inclusive - * @param end the stopping point of search, exclusive - * @param p a string that has no wildcard - * @return the starting index in the text of the pattern , or -1 if not found - */ - protected int textPosIn(String text, int start, int end, String p) { - - int plen= p.length(); - int max= end - plen; - - if (!fIgnoreCase) { - int i= text.indexOf(p, start); - if (i == -1 || i > max) - return -1; - return i; - } - - for (int i= start; i <= max; ++i) { - if (text.regionMatches(true, i, p, 0, plen)) - return i; - } - - return -1; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.java deleted file mode 100644 index a498a9b04..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.java +++ /dev/null @@ -1,211 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006 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.servlet.ui.internal.wizard; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.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.web.classpath.WebAppLibrariesContainer; -import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -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.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public class WebAppLibrariesContainerPage - - extends NewElementWizardPage - implements IClasspathContainerPage, IClasspathContainerPageExtension - -{ - private IProject ownerProject; - private String libsProjectName; - private Combo projectsCombo; - - public WebAppLibrariesContainerPage() - { - super( "WebAppLibrariesContainerPage" ); //$NON-NLS-1$ - - setTitle( Resources.pageTitle ); - setDescription( Resources.pageDescription ); - } - - public IClasspathEntry getSelection() - { - IPath path = new Path( WebAppLibrariesContainer.CONTAINER_ID ); - - final int index = this.projectsCombo.getSelectionIndex(); - if(index != -1){ - final String selectedProjectName = this.projectsCombo.getItem( index ); - - if( this.ownerProject == null || - ! selectedProjectName.equals( this.ownerProject.getName() ) ) - { - path = path.append( selectedProjectName ); - } - } - - return JavaCore.newContainerEntry( path ); - } - - public void setSelection( final IClasspathEntry cpentry ) - { - final IPath path = cpentry == null ? null : cpentry.getPath(); - - if( path == null || path.segmentCount() == 1 ) - { - if( this.ownerProject != null ) - { - this.libsProjectName = this.ownerProject.getName(); - } - } - else - { - this.libsProjectName = path.segment( 1 ); - } - } - - public void createControl( final Composite parent ) - { - final Composite composite = new Composite( parent, SWT.NONE ); - composite.setLayout( new GridLayout( 2, false ) ); - - final Label label = new Label( composite, SWT.NONE ); - label.setText( Resources.projectsLabel ); - - final String[] webProjects = getWebProjects(); - - this.projectsCombo = new Combo( composite, SWT.READ_ONLY ); - this.projectsCombo.setItems( webProjects ); - - final int index; - - if( this.ownerProject != null ) - { - index = indexOf( webProjects, this.libsProjectName ); - } - else - { - if( this.projectsCombo.getItemCount() > 0 ) - { - index = 0; - } - else - { - index = -1; - } - } - - if( index != -1 ) - { - this.projectsCombo.select( index ); - } - - final GridData gd = new GridData(); - gd.grabExcessHorizontalSpace = true; - gd.minimumWidth = 100; - - this.projectsCombo.setLayoutData( gd ); - - setControl( composite ); - } - - public boolean finish() - { - return true; - } - - public void initialize( final IJavaProject project, - final IClasspathEntry[] currentEntries ) - { - this.ownerProject = ( project == null ? null : project.getProject() ); - } - - private static String[] getWebProjects() - { - try - { - final Set projects - = ProjectFacetsManager.getFacetedProjects( WebFacetUtils.WEB_FACET ); - - final String[] names = new String[ projects.size() ]; - int i = 0; - - for( Iterator itr = projects.iterator(); itr.hasNext(); i++ ) - { - final IFacetedProject fproj = (IFacetedProject) itr.next(); - names[ i ] = fproj.getProject().getName(); - } - - Arrays.sort( names ); - - return names; - } - catch( CoreException e ) - { - ServletUIPlugin.log( e.getStatus() ); - return new String[ 0 ]; - } - } - - private static int indexOf( final String[] array, - final String str ) - { - for( int i = 0; i < array.length; i++ ) - { - if( array[ i ].equals( str ) ) - { - return i; - } - } - - return -1; - } - - private static final class Resources - - extends NLS - - { - public static String pageTitle; - public static String pageDescription; - public static String projectsLabel; - - static - { - initializeMessages( WebAppLibrariesContainerPage.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.properties deleted file mode 100644 index 85621ab63..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebAppLibrariesContainerPage.properties +++ /dev/null @@ -1,13 +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 -############################################################################### -pageTitle = Web App Libraries -pageDescription = This container dynamically manages classpath entries for types in the WEB-INF/lib and WEB-INF/classes directories. -projectsLabel = Project:\ diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportPage.java deleted file mode 100644 index 66b76314b..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportPage.java +++ /dev/null @@ -1,69 +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.servlet.ui.internal.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.wizard.J2EEModuleExportPage; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; - -public class WebComponentExportPage extends J2EEModuleExportPage { - /** - * @param model - * @param pageName - */ - public WebComponentExportPage(IDataModel model, String pageName, IStructuredSelection selection) { - super(model, pageName, selection); - setTitle(WEBUIMessages.WEB_EXPORT_MAIN_PG_TITLE); - setDescription(WEBUIMessages.WEB_EXPORT_MAIN_PG_DESC); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_EXPORT_WIZARD_BANNER)); - setInfopopID(IWebUIContextIds.WAR_EXPORT_PAGE1); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getProjectImportLabel() - */ - @Override - protected String getComponentLabel() { - return WEBUIMessages.WEB_PROJECT_LBL; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEImportPage#getFilterExpression() - */ - @Override - protected String[] getFilterExpression() { - return new String[]{"*.war"}; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.internal.ui.wizard.J2EEExportPage#isMetaTypeSupported(java.lang.Object) - */ - @Override - protected boolean isMetaTypeSupported(Object o) { - return o instanceof org.eclipse.jst.j2ee.webapplication.WebApp; - } - - @Override - protected String getComponentID() { - return "JST_WEB"; //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportWizard.java deleted file mode 100644 index ccc4021da..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentExportWizard.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.servlet.ui.internal.wizard; - -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider; -import org.eclipse.jst.j2ee.internal.wizard.J2EEArtifactExportWizard; -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 Web Application module structures - * from the Eclipse Workbench to a deployable Web Application - * Archive *.war file. - * </p> - */ -public final class WebComponentExportWizard 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 WebComponentExportWizard() { - 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 WebComponentExportWizard(IDataModel model) { - super(model); - } - - @Override - protected IDataModelProvider getDefaultProvider() { - return new WebComponentExportDataModelProvider(); - } - /** - * <p> - * Adds the following pages: - * <ul> - * <li> {@link WebComponentExportPage} as the main wizard page ({@link #MAIN_PG}) - * </ul> - * </p> - */ - @Override - public void doAddPages() { - addPage(new WebComponentExportPage(getDataModel(), MAIN_PG, getSelection())); - } - - /** - * {@inheritDoc} - * - * <p> - * Sets up the default wizard page image. - * </p> - */ - @Override - protected void doInit() { - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_EXPORT_WIZARD_BANNER)); - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportPage.java deleted file mode 100644 index 12ed5a9ba..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportPage.java +++ /dev/null @@ -1,73 +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.servlet.ui.internal.wizard; - -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.J2EEModuleImportPage; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.swt.widgets.Composite; -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 WebComponentImportPage extends J2EEModuleImportPage { - /** - * @param model - * @param pageName - */ - public WebComponentImportPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(WEBUIMessages.WEB_IMPORT_MAIN_PG_TITLE); - setDescription(WEBUIMessages.WEB_IMPORT_MAIN_PG_DESC); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_IMPORT_WIZARD_BANNER)); - setInfopopID(IWebUIContextIds.WAR_IMPORT_PAGE1); - } - - @Override - protected String getFileImportLabel() { - return WEBUIMessages.WEB_FILE_LBL; - } - - @Override - protected String[] getFilterExpression() { - return new String[]{"*.war"}; //$NON-NLS-1$ - } - - @Override - protected String getProjectImportLabel() { - return WEBUIMessages.WEB_PROJECT_LBL; - } - - @Override - protected void createAnnotationsStandaloneGroup(Composite composite) { - // TODO: implement with new import wizards - // new AnnotationsStandaloneGroup(composite, getWebDataModel(), false); - } - - @Override - protected String getModuleFacetID(){ - return J2EEProjectUtilities.DYNAMIC_WEB; - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWebLibsPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWebLibsPage.java deleted file mode 100644 index 55d8e3e99..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWebLibsPage.java +++ /dev/null @@ -1,236 +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.servlet.ui.internal.wizard; - -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.IJ2EEComponentImportDataModelProperties; -import org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin; -import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPluginIcons; -import org.eclipse.jst.j2ee.internal.wizard.J2EEImportPage; -import org.eclipse.jst.j2ee.web.datamodel.properties.IWebComponentImportDataModelProperties; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -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.wst.common.frameworks.datamodel.DataModelEvent; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener; - -/** - * @author cbridgha - * - * To change the template for this generated type comment go to Window>Preferences>Java>Code - * Generation>Code and Comments - */ -public class WebComponentImportWebLibsPage extends J2EEImportPage { - private Button deselectAllButton; - private Button selectAllButton; - protected ArchiveWrapper archiveWrapper; - public CheckboxTableViewer availableJARsViewer; - public boolean utilJarSelectionChanged = false; - - /** - * @param model - * @param pageName - */ - public WebComponentImportWebLibsPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(WEBUIMessages.WEB_IMPORT_WEB_LIB_PG_TITLE); - setDescription(WEBUIMessages.WEB_IMPORT_WEB_LIB_PG_DESC); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_IMPORT_WIZARD_BANNER)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.frameworks.internal.ui.wizard.WTPWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Composite createTopLevelComposite(Composite parent) { - setInfopopID(IWebUIContextIds.WAR_IMPORT_PAGE2); - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - createAvailableJarsList(composite); - createButtonsGroup(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); - AvailableWebLibProvider libsProvider = new AvailableWebLibProvider(); - availableJARsViewer.setContentProvider(libsProvider); - availableJARsViewer.setLabelProvider(libsProvider); - 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(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED)) { - availableJARsViewer.setCheckedElements(((List) model.getProperty(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED)).toArray()); - } - } - }); - } - - private void handleDeselectAllButtonPressed() { - ArrayList emptySelection = new ArrayList(2); - model.setProperty(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED, emptySelection); - } - - 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(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED, allSelection); - } - - 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(WEBUIMessages.WAR_IMPORT_SELECT_ALL_LIBS_BUTTON); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan = 1; - gd.heightHint = SWT.DEFAULT; - gd.widthHint = SWT.DEFAULT; - selectAllButton.setLayoutData(gd); - selectAllButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleSelectAllButtonPressed(); - } - }); - - deselectAllButton = new Button(buttonGroup, SWT.PUSH); - deselectAllButton.setText(WEBUIMessages.WAR_IMPORT_DESELECT_ALL_LIBS_BUTTON); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan = 2; - gd.heightHint = SWT.DEFAULT; - gd.widthHint = SWT.DEFAULT; - deselectAllButton.setLayoutData(gd); - deselectAllButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - handleDeselectAllButtonPressed(); - } - }); - } - - private void refreshEARFileIfNecessary() { - if (isEARFileChanged()) { - archiveWrapper = (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(archiveWrapper); - } - - public boolean isEARFileChanged() { - return archiveWrapper != model.getProperty(IJ2EEComponentImportDataModelProperties.ARCHIVE_WRAPPER); - } - - @Override - protected void enter() { - super.enter(); - refreshEARFileIfNecessary(); - } - - public void availableJARCheckStateChanged(CheckStateChangedEvent event) { - model.setProperty(IWebComponentImportDataModelProperties.WEB_LIB_ARCHIVES_SELECTED, 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; - } - - @Override - protected String[] getValidationPropertyNames() { - return new String[]{}; - } - - @Override - protected void restoreWidgetValues() { - // This page doesn't implement... - } - - @Override - public void storeDefaultSettings() { - // This page doesn't implement... - } - - - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWizard.java deleted file mode 100644 index c840ec296..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/WebComponentImportWizard.java +++ /dev/null @@ -1,103 +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.servlet.ui.internal.wizard; - -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.web.archive.operations.WebComponentImportDataModelProvider; -import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentImportWizard; -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 Web Application module structures into the Eclipse Workbench from an - * existing Web Application *.war file. - * </p> - */ -public final class WebComponentImportWizard extends J2EEComponentImportWizard { - - protected static final String WEB_LIBS_PG = "WEB_LIBS_PG"; //$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 WebComponentImportWizard() { - 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 WebComponentImportWizard(IDataModel model) { - super(model); - } - - /** - * <p> - * Adds an {@link WARImportPage} as the main wizard page ({@link #MAIN_PG}). - * </p> - */ - @Override - public void doAddPages() { - addPage(new WebComponentImportPage(getDataModel(), MAIN_PG)); - addPage(new WebComponentImportWebLibsPage(getDataModel(), WEB_LIBS_PG)); - } - - /** - * {@inheritDoc} - * - * <p> - * Sets up the dialog window title and default wizard page image. - * </p> - */ - @Override - public final void doInit() { - setWindowTitle(J2EEUIMessages.getResourceString(J2EEUIMessages.IMPORT_WIZ_TITLE)); - setDefaultPageImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_IMPORT_WIZARD_BANNER)); - // updateEARToModelFromSelection(getSpecificDataModel()); - } - - @Override - protected String[] getModuleValidatorStrings() { - return new String[]{"org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator"}; //$NON-NLS-1$ - } - - - // protected String getFinalPerspectiveID() { - // // J2EEComponentCreationDataModel projCreationModel = - // // getSpecificDataModel().getJ2EEModuleCreationDataModel(); - // // return projCreationModel.getStringProperty(ComponentCreationDataModel.FINAL_PERSPECTIVE); - // return getDataModel().getStringProperty(ComponentCreationDataModel.FINAL_PERSPECTIVE); - // } - - @Override - protected IDataModelProvider getDefaultProvider() { - return new WebComponentImportDataModelProvider(); - } - - @Override - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_WEB); - } -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.java deleted file mode 100644 index 4f77de78c..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.servlet.ui.project.facet; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.j2ee.web.project.facet.IWebFragmentFacetInstallDataModelProperties; -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; - - -public final class WebAppSelectionPanel implements IWebFragmentFacetInstallDataModelProperties - -{ - private final Button addToWar; - private final Combo combo; - private final Button newButton; - private final Label label; - - private final IDataModel model; - private DataModelSynchHelper synchhelper; - - public WebAppSelectionPanel( 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.warMemberShip ); - - this.addToWar = new Button( group, SWT.CHECK ); - this.addToWar.setText( Resources.addToWarLabel ); - GridDataFactory.defaultsFor(this.addToWar).span(3, 1).applyTo(this.addToWar); - synchhelper.synchCheckbox(addToWar, ADD_TO_WAR, null); - - label = new Label(group, SWT.NULL); - label.setText(Resources.warProjectLabel); - this.combo = new Combo(group, SWT.NONE); - this.combo.setLayoutData( gdhfill() ); - - this.newButton = new Button( group, SWT.PUSH ); - this.newButton.setText( Resources.newButtonLabel ); - GridDataFactory.defaultsFor(this.newButton).applyTo(this.newButton); - - this.newButton.addSelectionListener( new SelectionAdapter() - { - @Override - public void widgetSelected( final SelectionEvent event ) - { - handleAddButton(); - } - } ); - - synchhelper.synchCombo(combo, WAR_PROJECT_NAME, new Control[]{label, newButton}); - Dialog.applyDialogFont(parent); - } - - private void handleAddButton() - { - final WebProjectWizard wizard = new WebProjectWizard(); - - final WizardDialog dialog - = new WizardDialog( newButton.getShell(), wizard ); - -/* IRuntime runtime = (IRuntime)model.getProperty(FACET_RUNTIME); - wizard.ssetRuntimeInDataModel(runtime); -*/ - if( dialog.open() != SWT.CANCEL ) - { - model.notifyPropertyChange(WAR_PROJECT_NAME, IDataModel.VALID_VALUES_CHG); - final String warproj = wizard.getProjectName(); - model.setProperty(WAR_PROJECT_NAME, warproj); - } - } - - 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 addToWarLabel; - public static String newButtonLabel; - public static String warProjectLabel; - public static String warMemberShip; - - static - { - initializeMessages( WebAppSelectionPanel.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.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.properties deleted file mode 100644 index ba4ea81fa..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebAppSelectionPanel.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2010 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 -############################################################################### -addToWarLabel = Add &project to a Dynamic Web project -newButtonLabel = Ne&w... -warProjectLabel=Dynamic Web p&roject name: -warMemberShip=Dynamic Web project membership diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.java deleted file mode 100644 index e9b6aa075..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.java +++ /dev/null @@ -1,105 +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.servlet.ui.project.facet; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; -import org.eclipse.jst.j2ee.internal.wizard.J2EEModuleFacetInstallPage; -import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -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.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ -public class WebFacetInstallPage extends J2EEModuleFacetInstallPage implements IWebFacetInstallDataModelProperties { - private Label contextRootLabel; - private Text contextRoot; - private Label contentDirLabel; - private Text contentDir; - - public WebFacetInstallPage() { - super("web.facet.install.page"); //$NON-NLS-1$ - setTitle(Resources.pageTitle); - setDescription(Resources.pageDescription); - } - - @Override - protected Composite createTopLevelComposite(final Composite parent) { - setInfopopID(IWebUIContextIds.NEW_DYNAMIC_WEB_PROJECT_PAGE3); - final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - - this.contextRootLabel = new Label(composite, SWT.NONE); - this.contextRootLabel.setText(Resources.contextRootLabel); - this.contextRootLabel.setLayoutData(new GridData()); - - this.contextRoot = new Text(composite, SWT.BORDER); - this.contextRoot.setLayoutData(gdhfill()); - this.contextRoot.setData("label", this.contextRootLabel); //$NON-NLS-1$ - synchHelper.synchText(contextRoot, CONTEXT_ROOT, new Control[]{contextRootLabel}); - - this.contentDirLabel = new Label(composite, SWT.NONE); - this.contentDirLabel.setText(Resources.contentDirLabel); - this.contentDirLabel.setLayoutData(new GridData()); - - this.contentDir = new Text(composite, SWT.BORDER); - this.contentDir.setLayoutData(gdhfill()); - this.contentDir.setData("label", this.contentDirLabel); //$NON-NLS-1$ - synchHelper.synchText(contentDir, CONFIG_FOLDER, null); - - new Label(composite, SWT.NONE); // pad - - createGenerateDescriptorControl(composite, J2EEConstants.WEBAPP_DD_SHORT_NAME); - registerFacetVersionChangeListener(); - - Dialog.applyDialogFont(parent); - - return composite; - } - - @Override - protected void handleFacetVersionChangedEvent() - { - String fv = model.getStringProperty(FACET_VERSION_STR); - boolean isWeb25OrGreater = J2EEVersionUtil.convertVersionStringToInt(fv) >= J2EEVersionConstants.WEB_2_5_ID; - this.addDD.setVisible(isWeb25OrGreater); - } - - @Override - protected String[] getValidationPropertyNames() { - return new String[]{EAR_PROJECT_NAME, CONTEXT_ROOT, CONFIG_FOLDER, SOURCE_FOLDER}; - } - - private static final class Resources extends NLS { - public static String pageTitle; - public static String pageDescription; - public static String contextRootLabel; - public static String contentDirLabel; - - static { - initializeMessages(WebFacetInstallPage.class.getName(), Resources.class); - } - } - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.properties deleted file mode 100644 index c40857709..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFacetInstallPage.properties +++ /dev/null @@ -1,4 +0,0 @@ -pageTitle = Web Module -pageDescription = Configure web module settings. -contextRootLabel = Context &root: -contentDirLabel = Content &directory: diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectContentProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectContentProvider.java deleted file mode 100644 index 0b0748b63..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectContentProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - - * Copyright (c) 2010 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.servlet.ui.project.facet; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework; - -public class WebFragmentProjectContentProvider implements IStructuredContentProvider { - - public void dispose() { - // Do nothing - } - - public void inputChanged(Viewer arg0, Object arg1, Object arg2) { - // Do nothing - } - - public Object[] getElements(Object arg0) { - if (arg0 instanceof IWorkspaceRoot) { - IProject[] projects = ((IWorkspaceRoot) arg0).getProjects(); - if (projects != null && projects.length != 0) { - List<IProject> theProjects = new ArrayList<IProject>(0); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - try { - if (FacetedProjectFramework.hasProjectFacet(project, IModuleConstants.JST_WEBFRAGMENT_MODULE)) { - theProjects.add(project); - } - } catch (CoreException e) { - ServletUIPlugin.log(e); - } - } - return theProjects.toArray(); - } - } - return new Object[0]; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.java deleted file mode 100644 index 9dee1b755..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - - * Copyright (c) 2010 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.servlet.ui.project.facet; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentFacetCreationWizardPage; -import org.eclipse.jst.j2ee.web.project.facet.IWebFragmentProjectCreationDataModelProperties; -import org.eclipse.osgi.util.NLS; -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.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; - -public class WebFragmentProjectFirstPage extends J2EEComponentFacetCreationWizardPage { - - protected WebAppSelectionPanel warPanel; - public WebFragmentProjectFirstPage(IDataModel dataModel, String pageName) { - super(dataModel, pageName); - setTitle(Resources.pageTitle); - setDescription(Resources.pageDescription); - } - - private static final class Resources extends NLS { - public static String pageTitle; - public static String pageDescription; - static { - initializeMessages(WebFragmentProjectFirstPage.class.getName(), Resources.class); - } - } - - @Override - protected Composite createTopLevelComposite(Composite parent) { - setShouldAddEARComposite(false); - final Composite top = super.createTopLevelComposite(parent); - createWarComposite(top); - createWorkingSetGroupPanel(top, new String[] { RESOURCE_WORKING_SET, JAVA_WORKING_SET }); - return top; - } - - private void createWarComposite(Composite top) - { - final IFacetedProjectWorkingCopy fpjwc - = (IFacetedProjectWorkingCopy) this.model.getProperty( FACETED_PROJECT_WORKING_COPY ); - - final String moduleFacetId = getModuleTypeID(); - final IProjectFacet moduleFacet = ProjectFacetsManager.getProjectFacet( moduleFacetId ); - final IFacetedProject.Action action = fpjwc.getProjectFacetAction( moduleFacet ); - - warPanel = new WebAppSelectionPanel( (IDataModel) action.getConfig(), top ); - } - - @Override - protected String[] getValidationPropertyNames() - { - String[] superProperties = super.getValidationPropertyNames(); - List list = Arrays.asList(superProperties); - ArrayList arrayList = new ArrayList(); - arrayList.addAll( list ); - arrayList.add( IWebFragmentProjectCreationDataModelProperties.WAR_PROJECT_NAME ); - arrayList.add( IWebFragmentProjectCreationDataModelProperties.ADD_TO_WAR ); - return (String[])arrayList.toArray( new String[0] ); - } - - @Override - protected String getModuleFacetID() { - return IModuleConstants.JST_WEBFRAGMENT_MODULE; - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.properties deleted file mode 100644 index 5233684d2..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectFirstPage.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2010 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 = Web Fragment -pageDescription = Configure web fragment module settings.
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectLabelProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectLabelProvider.java deleted file mode 100644 index 0b4c74f11..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectLabelProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - - * Copyright (c) 2010 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.servlet.ui.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -public class WebFragmentProjectLabelProvider extends LabelProvider { - private ILabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); - private ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); - - @Override - public Image getImage(Object o) { - Image image = workbenchLabelProvider.getImage(o); - - if (o instanceof IProject) { - Image decorated = decorator.decorateImage(image, o); - - if (decorated != null) { - return decorated; - }} - return image; - } - - @Override - public String getText(Object o) { - if (o instanceof IProject) { - return ((IProject) o).getName(); - } - return ""; //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectWizard.java deleted file mode 100644 index 7073e5684..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebFragmentProjectWizard.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - - * Copyright (c) 2010 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.servlet.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.web.project.facet.WebFragmentFacetProjectCreationDataModelProvider; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -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.web.ui.internal.wizards.NewProjectDataModelFacetWizard; -import org.osgi.framework.Bundle; - - -public class WebFragmentProjectWizard extends NewProjectDataModelFacetWizard { - - public WebFragmentProjectWizard(IDataModel modelid) { - super(modelid); - setWindowTitle(WEBUIMessages.WEBFRAGMENT_MODULE_WIZ_TITLE); - } - - public WebFragmentProjectWizard(){ - super(); - setWindowTitle(WEBUIMessages.WEBFRAGMENT_MODULE_WIZ_TITLE); - } - - @Override - protected IDataModel createDataModel() { - return DataModelFactory.createDataModel(new WebFragmentFacetProjectCreationDataModelProvider()); - } - - @Override - protected ImageDescriptor getDefaultPageImageDescriptor() { - final Bundle bundle = Platform.getBundle("org.eclipse.jst.servlet.ui"); //$NON-NLS-1$ - final URL url = bundle.getEntry("icons/newpprj_wiz.png"); //$NON-NLS-1$ - return ImageDescriptor.createFromURL(url); - } - - @Override - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("template.jst.webfragment"); //$NON-NLS-1$ - } - - @Override - protected IWizardPage createFirstPage() { - return new WebFragmentProjectFirstPage(model, "first.page"); //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectFirstPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectFirstPage.java deleted file mode 100644 index 70035479f..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectFirstPage.java +++ /dev/null @@ -1,69 +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.servlet.ui.project.facet; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.jst.common.project.facet.JavaFacetUtils; -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.jst.j2ee.web.project.facet.WebFacetUtils; -import org.eclipse.jst.servlet.ui.IWebUIContextIds; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -public class WebProjectFirstPage extends J2EEComponentFacetCreationWizardPage { - - public WebProjectFirstPage(IDataModel model, String pageName) { - super(model, pageName); - setTitle(WEBUIMessages.WEB_PROJECT_MAIN_PG_TITLE); - setDescription(WEBUIMessages.WEB_PROJECT_MAIN_PG_DESC); - setImageDescriptor(J2EEUIPlugin.getDefault().getImageDescriptor(J2EEUIPluginIcons.WEB_PROJECT_WIZARD_BANNER)); - setInfopopID(IWebUIContextIds.NEW_DYNAMIC_WEB_PROJECT_PAGE1); - } - - @Override - protected String getModuleFacetID() { - return J2EEProjectUtilities.DYNAMIC_WEB; - } - - @Override - protected Set<IProjectFacetVersion> getFacetConfiguration( final IProjectFacetVersion primaryFacetVersion ) - { - final Set<IProjectFacetVersion> facets = new HashSet<IProjectFacetVersion>( 2 ); - - facets.add( primaryFacetVersion ); - - if( primaryFacetVersion == WebFacetUtils.WEB_30 || - primaryFacetVersion == WebFacetUtils.WEB_25 ) - { - facets.add( JavaFacetUtils.JAVA_50 ); - } - else if( primaryFacetVersion == WebFacetUtils.WEB_24 ) - { - facets.add( JavaFacetUtils.JAVA_14 ); - } - else if( primaryFacetVersion == WebFacetUtils.WEB_23 || - primaryFacetVersion == WebFacetUtils.WEB_22 ) - { - facets.add( JavaFacetUtils.JAVA_13 ); - } - - return Collections.unmodifiableSet( facets ); - } - -} diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectWizard.java deleted file mode 100644 index 86ce7f825..000000000 --- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/project/facet/WebProjectWizard.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.servlet.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.web.archive.operations.WebFacetProjectCreationDataModelProvider; -import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages; -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; -import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin; - -public class WebProjectWizard extends NewProjectDataModelFacetWizard { - - public WebProjectWizard(IDataModel model) { - super(model); - setWindowTitle(WEBUIMessages.WEB_MODULE_WIZ_TITLE); - } - - public WebProjectWizard() { - super(); - setWindowTitle(WEBUIMessages.WEB_MODULE_WIZ_TITLE); - } - - @Override - protected IDataModel createDataModel() { - try - { - return DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider()); - } - catch( Exception e ) - { - ServletUIPlugin.logError(e); - return null; - } - } - - @Override - protected IFacetedProjectTemplate getTemplate() { - return ProjectFacetsManager.getTemplate("template.jst.web"); //$NON-NLS-1$ - } - - @Override - protected IWizardPage createFirstPage() { - return new WebProjectFirstPage(model, "first.page"); //$NON-NLS-1$ - } - - @Override - protected ImageDescriptor getDefaultPageImageDescriptor() { - final Bundle bundle = Platform.getBundle("org.eclipse.jst.servlet.ui"); //$NON-NLS-1$ - final URL url = bundle.getEntry("icons/full/ctool16/web-wiz-banner.gif"); //$NON-NLS-1$ - return ImageDescriptor.createFromURL(url); - } - - @Override - protected String getFinalPerspectiveID() { - return ProductManager.getProperty(IProductConstants.FINAL_PERSPECTIVE_WEB); - } -} |