Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkraev2010-06-22 14:35:00 +0000
committerkraev2010-06-22 14:35:00 +0000
commitd89a00cb6d365c582de407b7aa0ef4a607a312a2 (patch)
tree350759bd7af310db7e6456b889e2d4fb04e8ce66 /plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse
parentfa91671d7d146044fb7b39d8d06723e60ea3949c (diff)
downloadwebtools.javaee-d89a00cb6d365c582de407b7aa0ef4a607a312a2.tar.gz
webtools.javaee-d89a00cb6d365c582de407b7aa0ef4a607a312a2.tar.xz
webtools.javaee-d89a00cb6d365c582de407b7aa0ef4a607a312a2.zip
[312288] Filter and Listener wizards should not be shown for Web 2.2 projects
Diffstat (limited to 'plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse')
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/FacetedProjectPropertyTester.java71
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewFilterClassWizardPage.java23
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/NewListenerClassWizardPage.java23
3 files changed, 117 insertions, 0 deletions
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/FacetedProjectPropertyTester.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/FacetedProjectPropertyTester.java
new file mode 100644
index 000000000..7acbd7385
--- /dev/null
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/navigator/FacetedProjectPropertyTester.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.navigator;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+
+public class FacetedProjectPropertyTester extends PropertyTester
+
+{
+ public boolean test( final Object receiver,
+ final String property,
+ final Object[] args,
+ final Object value )
+ {
+ try
+ {
+ if( ! ( receiver instanceof ICompressedNode ) )
+ {
+ return false;
+ }
+
+ IProject pj = null;
+ if (receiver instanceof CompressedJavaProject) {
+ pj = ((CompressedJavaProject) receiver).getProject();
+ } else if (receiver instanceof CompressedJavaLibraries) {
+ pj = ((CompressedJavaLibraries) receiver).getCompressedProject().getProject();
+ }
+
+ if( pj == null )
+ {
+ return false;
+ }
+
+ final String val = (String) value;
+ final int colon = val.indexOf( ':' );
+
+ final String fid;
+ final String vexpr;
+
+ if( colon == -1 || colon == val.length() - 1 )
+ {
+ fid = val;
+ vexpr = null;
+ }
+ else
+ {
+ fid = val.substring( 0, colon );
+ vexpr = val.substring( colon + 1 );
+ }
+
+ return FacetedProjectFramework.hasProjectFacet( pj, fid, vexpr );
+ }
+ catch( CoreException e )
+ {
+ //
+ }
+
+ return false;
+ }
+}
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
index 01fec0e61..1f6e59198 100644
--- 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
@@ -27,10 +27,14 @@ 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.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
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.JavaEEProjectUtilities;
import org.eclipse.jst.j2ee.project.WebUtilities;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
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;
@@ -40,6 +44,7 @@ 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;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
public class NewFilterClassWizardPage extends NewWebClassWizardPage {
@@ -145,5 +150,23 @@ public class NewFilterClassWizardPage extends NewWebClassWizardPage {
return composite;
}
+
+ @Override
+ protected boolean isProjectValid(IProject project) {
+ boolean result = super.isProjectValid(project);
+ if (!result)
+ return false;
+
+ // get the version of the web facet
+ IProjectFacetVersion facetVersion = JavaEEProjectUtilities.getProjectFacetVersion(project, IJ2EEFacetConstants.DYNAMIC_WEB);
+ if (facetVersion == null)
+ return false;
+
+ // convert the version to an integer
+ int version = J2EEVersionUtil.convertVersionStringToInt(facetVersion.getVersionString());
+
+ // only web 2.3 and greater projects are valid
+ return version > J2EEVersionConstants.SERVLET_2_2;
+ }
}
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
index 5ffc33a88..54e29399a 100644
--- 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
@@ -15,12 +15,17 @@ import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.USE
import org.eclipse.core.resources.IProject;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
import org.eclipse.jst.j2ee.internal.war.ui.util.WebListenerGroupItemProvider;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
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;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
public class NewListenerClassWizardPage extends NewWebClassWizardPage {
@@ -65,5 +70,23 @@ public class NewListenerClassWizardPage extends NewWebClassWizardPage {
@Override
protected void handleClassButtonSelected() {
}
+
+ @Override
+ protected boolean isProjectValid(IProject project) {
+ boolean result = super.isProjectValid(project);
+ if (!result)
+ return false;
+
+ // get the version of the web facet
+ IProjectFacetVersion facetVersion = JavaEEProjectUtilities.getProjectFacetVersion(project, IJ2EEFacetConstants.DYNAMIC_WEB);
+ if (facetVersion == null)
+ return false;
+
+ // convert the version to an integer
+ int version = J2EEVersionUtil.convertVersionStringToInt(facetVersion.getVersionString());
+
+ // only web 2.3 and greater projects are valid
+ return version > J2EEVersionConstants.SERVLET_2_2;
+ }
}

Back to the top