Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkraev2007-12-04 17:51:43 +0000
committerkraev2007-12-04 17:51:43 +0000
commitfe636268e72432bd23afac1f2487a9a07bc0619e (patch)
tree2bc60014fbfd4f4d7a5196b7c3c19940da060433 /plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui
parentde91ddf407b023a0e7e8f02c3348ee0053d5997c (diff)
downloadwebtools.javaee-fe636268e72432bd23afac1f2487a9a07bc0619e.tar.gz
webtools.javaee-fe636268e72432bd23afac1f2487a9a07bc0619e.tar.xz
webtools.javaee-fe636268e72432bd23afac1f2487a9a07bc0619e.zip
[209329] Third page is added to the Filter wizard. The "Constructors from Superclass" option now works for Servlet, Filter and Listener wizards.
Diffstat (limited to 'plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui')
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddEditFilterMappingDialog.java368
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizard.java24
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java11
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassOptionsWizardPage.java163
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassOptionsWizardPage.java35
5 files changed, 353 insertions, 248 deletions
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
index 5968626b0..48982c36e 100644
--- 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
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jst.servlet.ui.internal.wizard;
/**
@@ -10,7 +20,6 @@ import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jem.util.logger.proxy.Logger;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.operation.IRunnableContext;
@@ -44,20 +53,21 @@ import org.eclipse.ui.part.PageBook;
* 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();
- public String getText(Object element) {
- return ((String) element);
- }
+ public String getText(Object element) {
+ return ((String) element);
+ }
- public Image getImage(Object element) {
- return SERVLET_ICON;
- }
+ public Image getImage(Object element) {
+ return SERVLET_ICON;
+ }
}
+
private ISelectionStatusValidator fValidator = null;
public final static int SERVLET = 0;
@@ -72,7 +82,6 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
// construction parameters
protected IRunnableContext fRunnableContext;
protected ILabelProvider fElementRenderer;
- //protected ILabelProvider fQualifierRenderer;
private Object[] fElements;
private boolean fIgnoreCase = true;
private String fUpperListLabel;
@@ -89,7 +98,6 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
private Button fErorr;
private IFilterMappingItem selectedItem;
- //private ISelectionStatusValidator fLocalValidator = null;
/**
* MultiSelectFilteredFileSelectionDialog constructor comment.
* @param parent Shell
@@ -114,41 +122,41 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
fElementRenderer = new TypeRenderer();
fRunnableContext = J2EEUIPlugin.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();
+ 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) &&
+ }
+ } 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 = (String[]) servletsList.toArray(new String[servletsList.size()]);
- servletsList = null;
- } catch (Exception exc) {
- Logger.getLogger().logError(exc);
- }
+ }
+ }
+
+ fServletNames = (String[]) servletsList.toArray(new String[servletsList.size()]);
+ servletsList = null;
+ } catch (Exception exc) {
+ Logger.getLogger().logError(exc);
+ }
}
- private boolean isAlreadyAdded(String servlet, List<IFilterMappingItem> elements) {
+ 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 true;
}
return false;
}
@@ -156,32 +164,32 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
/**
* @private
*/
- protected void computeResult() {
- if (fSelection == URL_PATTERN) {
- java.util.List result = new ArrayList(1);
- dispatchers = getDispatchers();
+ 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);
- }
- }
- }
+ } 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;
@@ -202,7 +210,7 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
public void create() {
super.create();
- if (selectedItem == null && (fServletNames != null && fServletNames.length > 0)) fSelection = SERVLET;
+ if (selectedItem == null && (fServletNames != null && fServletNames.length > 0)) fSelection = SERVLET;
updateOkState();
}
@@ -283,7 +291,7 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
fURLPatternButton.setLayoutData(gd);
fURLPatternButton.addSelectionListener(this);
- //Create URL Pattern page
+ //Create URL Pattern page
fPageBook = new PageBook(fChild, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
@@ -324,26 +332,26 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
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());
+ 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__2")); //$NON-NLS-1$
+ messageLabel = new Label(composite, SWT.NONE);
+ gd = new GridData();
+ messageLabel.setLayoutData(gd);
+ messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_servlet__2")); //$NON-NLS-1$
- fUpperList = createUpperList(composite);
+ fUpperList = createUpperList(composite);
- fServletControl = composite;
+ fServletControl = composite;
- //Create Dispatchers control
+ //Create Dispatchers control
Group dispatchers = new Group(fChild, SWT.SHADOW_IN);
dispatchers.setText(WebAppEditResourceHandler.getString("Select_Dispatchers_UI_"));
dispatchers.setLayout(new CellLayout(2).setMargins(10,10).setSpacing(5,5));
@@ -373,39 +381,39 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
updateUpperListWidget();
fServletButton.setEnabled(true);
- if (fSelection == URL_PATTERN) {
- fURLPatternButton.setSelection(true);
- fPageBook.showPage(fURLPatternControl);
+ if (fSelection == URL_PATTERN) {
+ fURLPatternButton.setSelection(true);
+ fPageBook.showPage(fURLPatternControl);
fServletButton.setSelection(false);
- if (fServletNames == null || fServletNames.length == 0) {
- fServletButton.setEnabled(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());
- }
- }
+ } 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++) {
+ 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) {
+ private void setDispatchers(int dispatchers) {
if ((dispatchers & IFilterMappingItem.REQUEST) > 0) {
fRequest.setSelection(true);
}
@@ -419,62 +427,6 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
fErorr.setSelection(true);
}
}
-
-// /**
-// * 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(2);
-// 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.
@@ -486,9 +438,9 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
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();
-// }
+// public void handleEvent(Event evt) {
+// handleUpperSelectionChanged();
+// }
// });
list.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event evt) {
@@ -525,8 +477,8 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
}
protected Object getWidgetSelection() {
- int index = fUpperList.getSelectionIndex();
- return index >= 0 ? fElements[index] : null;
+ int index = fUpperList.getSelectionIndex();
+ return index >= 0 ? fElements[index] : null;
}
protected final void handleLowerDoubleClick() {
@@ -543,54 +495,16 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
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++;
-// }
-// }
-// }
-
public int open() {
- if (fServletNames == null || fServletNames.length == 0) {
- fSelection = URL_PATTERN;
- }
+ if (fServletNames == null || fServletNames.length == 0) {
+ fSelection = URL_PATTERN;
+ }
- setElements(fServletNames);
- setInitialSelections(new Object[] { "" }); //$NON-NLS-1$
- return super.open();
+ setElements(fServletNames);
+ setInitialSelections(new Object[] { "" }); //$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[]
@@ -615,32 +529,6 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
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();
@@ -653,21 +541,21 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
}
}
- 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]);
+ 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);
- }
+ }
+ if (fUpperList.getItemCount() > 0) {
+ fUpperList.setSelection(0);
+ }
+ fUpperList.setRedraw(true);
+ }
/**
* Sent when default selection occurs in the control.
@@ -704,14 +592,4 @@ public class AddEditFilterMappingDialog extends SelectionStatusDialog implements
} else
fSelection = -1;
}
-
-// /**
-// * @see ElementTreeSelectionDialog#updateOKStatus()
-// */
-// protected void 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/AddFilterWizard.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddFilterWizard.java
index f631a54b3..34ee58b8f 100644
--- 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
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jst.servlet.ui.internal.wizard;
import java.lang.reflect.InvocationTargetException;
@@ -28,6 +38,7 @@ public class AddFilterWizard extends NewWebWizard {
private static final String PAGE_ONE = "pageOne"; //$NON-NLS-1$
private static final String PAGE_TWO = "pageTwo"; //$NON-NLS-1$
+ private static final String PAGE_THREE = "pageTree"; //$NON-NLS-1$
public AddFilterWizard(IDataModel model) {
super(model);
@@ -55,6 +66,14 @@ public class AddFilterWizard extends NewWebWizard {
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,
+ IWebWizardConstants.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC,
+ IWebWizardConstants.ADD_FILTER_WIZARD_PAGE_TITLE);
+// page3.setInfopopID(IWebUIContextIds.WEBEDITOR_FILTER_PAGE_ADD_SERVLET_WIZARD_3);
+ addPage(page3);
}
/* (non-Javadoc)
@@ -89,8 +108,9 @@ public class AddFilterWizard extends NewWebWizard {
//open new filter class in java editor
WebArtifactEdit artifactEdit = null;
try {
- String className = getDataModel().getStringProperty(INewJavaClassDataModelProperties.QUALIFIED_CLASS_NAME);
- IProject p = (IProject) getDataModel().getProperty(INewJavaClassDataModelProperties.PROJECT);
+ IDataModel dataModel = getDataModel();
+ String className = dataModel.getStringProperty(INewJavaClassDataModelProperties.QUALIFIED_CLASS_NAME);
+ IProject p = (IProject) dataModel.getProperty(INewJavaClassDataModelProperties.PROJECT);
// filter class
IJavaProject javaProject = J2EEEditorUtility.getJavaProject(p);
IFile file = (IFile) javaProject.findType(className).getResource();
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
index 27f51fe69..8edff753c 100644
--- 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
@@ -191,17 +191,28 @@ public class AddListenerWizardPage extends DataModelWizardPage {
private void handleSelectAll() {
List interfaces = (List) model.getProperty(INewJavaClassDataModelProperties.INTERFACES);
+ if (interfaces == null) {
+ interfaces = new ArrayList();
+ model.setProperty(INewJavaClassDataModelProperties.INTERFACES, interfaces);
+ }
+
for (String iface : NewListenerClassDataModelProvider.LISTENER_INTERFACES) {
if (!interfaces.contains(iface)) {
interfaces.add(iface);
}
}
+
synchHelper.synchUIWithModel(INewJavaClassDataModelProperties.INTERFACES, DataModelEvent.VALUE_CHG);
model.notifyPropertyChange(INewJavaClassDataModelProperties.INTERFACES, DataModelEvent.VALUE_CHG);
}
private void handleSelectNone() {
List interfaces = (List) model.getProperty(INewJavaClassDataModelProperties.INTERFACES);
+ if (interfaces == null) {
+ interfaces = new ArrayList();
+ model.setProperty(INewJavaClassDataModelProperties.INTERFACES, interfaces);
+ }
+
interfaces.removeAll(Arrays.asList(NewListenerClassDataModelProvider.LISTENER_INTERFACES));
synchHelper.synchUIWithModel(INewJavaClassDataModelProperties.INTERFACES, DataModelEvent.VALUE_CHG);
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
new file mode 100644
index 000000000..2c9f83651
--- /dev/null
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassOptionsWizardPage.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2007 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.servlet.ui.internal.wizard;
+
+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.common.operations.INewJavaClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.web.operations.FilterSupertypesValidator;
+import org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties;
+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 NewFilterClassOptionsWizardPage extends NewJavaClassOptionsWizardPage implements ISelectionChangedListener {
+
+ protected Button initButton;
+ protected Button destroyButton;
+ protected Button doFilterButton;
+
+ private FilterSupertypesValidator validator;
+
+ public NewFilterClassOptionsWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle) {
+ super(model, pageName, pageDesc, pageTitle);
+ validator = new FilterSupertypesValidator(model);
+ }
+
+ protected void enter() {
+ super.enter();
+
+ interfaceViewer.getList().deselectAll();
+ removeButton.setEnabled(false);
+ String superClass = getDataModel().getStringProperty(INewFilterClassDataModelProperties.SUPERCLASS);
+ boolean hasSuperClass = (superClass == null) ? false : superClass.trim().length() > 0;
+ constructorButton.setEnabled(hasSuperClass);
+ if (!hasSuperClass) constructorButton.setSelection(false);
+
+ inheritButton.setSelection(true);
+ inheritButton.setEnabled(false);
+
+ initButton.setSelection(true);
+ initButton.setEnabled(false);
+
+ destroyButton.setSelection(true);
+ destroyButton.setEnabled(false);
+
+ doFilterButton.setSelection(true);
+ doFilterButton.setEnabled(false);
+ }
+
+ protected void createModifierControls(Composite parent) {
+ super.createModifierControls(parent);
+
+ // The user should not be able to change the public and abstract modifiers.
+ // The filter class must be always public and non-abstract.
+ // Otherwise, the servlet container may not initialize it.
+ publicButton.setEnabled(false);
+ abstractButton.setEnabled(false);
+ }
+
+ /**
+ * Create the composite with all the stubs
+ */
+ protected void createStubsComposite(Composite parent) {
+ Label stubLabel = new Label(parent, SWT.NONE);
+ stubLabel.setText(IWebWizardConstants.JAVA_CLASS_METHOD_STUBS_LABEL);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ stubLabel.setLayoutData(data);
+
+ Composite buttonCompo = new Composite(parent, SWT.NULL);
+ buttonCompo.setLayout(new GridLayout());
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.horizontalIndent = 15;
+ buttonCompo.setLayoutData(data);
+
+ constructorButton = new Button(buttonCompo, SWT.CHECK);
+ constructorButton.setText(IWebWizardConstants.JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL);
+ synchHelper.synchCheckbox(constructorButton, INewJavaClassDataModelProperties.CONSTRUCTOR, null);
+
+ inheritButton = new Button(buttonCompo, SWT.CHECK);
+ inheritButton.setText(IWebWizardConstants.JAVA_CLASS_INHERIT_CHECKBOX_LABEL);
+ synchHelper.synchCheckbox(inheritButton, INewJavaClassDataModelProperties.ABSTRACT_METHODS, null);
+
+ Composite comp = new Composite(buttonCompo, SWT.NULL);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginWidth = 0;
+ layout.makeColumnsEqualWidth = true;
+ comp.setLayout(layout);
+ data = new GridData(GridData.FILL_BOTH);
+ comp.setLayoutData(data);
+
+ initButton = new Button(comp, SWT.CHECK);
+ initButton.setText("&init"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(initButton, INewFilterClassDataModelProperties.INIT, null);
+
+ destroyButton = new Button(comp, SWT.CHECK);
+ destroyButton.setText("destro&y"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(destroyButton, INewFilterClassDataModelProperties.DESTROY, null);
+
+ doFilterButton = new Button(comp, SWT.CHECK);
+ doFilterButton.setText("do&Filter"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doFilterButton, INewFilterClassDataModelProperties.DO_FILTER, null);
+
+ interfaceViewer.addSelectionChangedListener(this);
+
+ Dialog.applyDialogFont(parent);
+ }
+
+ protected String[] getValidationPropertyNames() {
+ return new String[] { INewJavaClassDataModelProperties.INTERFACES };
+ }
+
+ 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 (validator.isFilterSuperclass()) {
+ 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 (FilterSupertypesValidator.FILTER_INTERFACE_NAME.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/NewListenerClassOptionsWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassOptionsWizardPage.java
index bbb299282..6f475af5b 100644
--- 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
@@ -12,9 +12,16 @@
*******************************************************************************/
package org.eclipse.jst.servlet.ui.internal.wizard;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.web.operations.INewFilterClassDataModelProperties;
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;
@@ -27,6 +34,15 @@ public class NewListenerClassOptionsWizardPage extends NewJavaClassOptionsWizard
super(model, pageName, pageDesc, pageTitle);
}
+ protected void enter() {
+ super.enter();
+
+ String superClass = getDataModel().getStringProperty(INewFilterClassDataModelProperties.SUPERCLASS);
+ boolean hasSuperClass = (superClass == null) ? false : superClass.trim().length() > 0;
+ constructorButton.setEnabled(hasSuperClass);
+ if (!hasSuperClass) constructorButton.setSelection(false);
+ }
+
protected void createModifierControls(Composite parent) {
super.createModifierControls(parent);
@@ -43,7 +59,24 @@ public class NewListenerClassOptionsWizardPage extends NewJavaClassOptionsWizard
protected void createStubsComposite(Composite parent) {
- //do not create stubs
+ Label stubLabel = new Label(parent, SWT.NONE);
+ stubLabel.setText(IWebWizardConstants.JAVA_CLASS_METHOD_STUBS_LABEL);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ stubLabel.setLayoutData(data);
+
+ Composite buttonCompo = new Composite(parent, SWT.NULL);
+ buttonCompo.setLayout(new GridLayout());
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.horizontalIndent = 15;
+ buttonCompo.setLayoutData(data);
+
+ constructorButton = new Button(buttonCompo, SWT.CHECK);
+ constructorButton.setText(IWebWizardConstants.JAVA_CLASS_CONSTRUCTOR_CHECKBOX_LABEL);
+ synchHelper.synchCheckbox(constructorButton, INewJavaClassDataModelProperties.CONSTRUCTOR, null);
+
+ Dialog.applyDialogFont(parent);
}
}

Back to the top