Author: scabanovich
Date: 2007-10-16 09:50:27 -0400 (Tue, 16 Oct 2007)
New Revision: 4230
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/web.meta
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/NewWebProjectContext.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/ProjectTemplate.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/version/ProjectVersion.java
Log:
JBIDE-682
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/web.meta
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/web.meta 2007-10-16 13:49:41
UTC (rev 4229)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/resources/meta/web.meta 2007-10-16 13:50:27
UTC (rev 4230)
@@ -467,6 +467,7 @@
<value name="2.2"/>
<value name="2.3"/>
<value name="2.4"/>
+ <value name="2.5"/>
</Constraint>
<Editor name="List"/>
</XModelAttribute>
@@ -749,6 +750,7 @@
<Constraint loader="List">
<value name="2.3"/>
<value name="2.4"/>
+ <value name="2.5"/>
</Constraint>
<Editor name="List"/>
</XModelAttribute>
@@ -960,6 +962,7 @@
<Constraint loader="List">
<value name="2.3"/>
<value name="2.4"/>
+ <value name="2.5"/>
</Constraint>
<Editor name="List"/>
</XModelAttribute>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java 2007-10-16
13:49:41 UTC (rev 4229)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/context/RegisterServerContext.java 2007-10-16
13:50:27 UTC (rev 4230)
@@ -70,6 +70,10 @@
servletVersion = v;
}
+ public String getServletVersion() {
+ return servletVersion;
+ }
+
public void setProjectHandle(IProject p) {
project = p;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/NewWebProjectContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/NewWebProjectContext.java 2007-10-16
13:49:41 UTC (rev 4229)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/NewWebProjectContext.java 2007-10-16
13:50:27 UTC (rev 4230)
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
import org.jboss.tools.jst.web.context.RegisterServerContext;
+import org.jboss.tools.jst.web.project.version.ProjectVersion;
public abstract class NewWebProjectContext {
public static final String ATTR_NAME = "name";
@@ -94,6 +95,10 @@
servletVersion = value;
registry.setServletVersion(value);
}
+
+ public String getServletVersion() {
+ return servletVersion;
+ }
public RegisterServerContext getRegisterServerContext() {
return registry;
@@ -117,4 +122,30 @@
return projectTemplateEdit;
}
+ public String validateServletVersion() {
+ if(projectTemplateEdit == null) return null;
+ ProjectVersion v = projectTemplateEdit.getProjectVersion();
+ if(v == null) return null;
+ String pref = v.getPreferredServletVersion();
+ if(pref == null) return null;
+ int c = compareServletVersions(pref, servletVersion);
+ if(c > 0) {
+ return "Servlet version must be at least " + pref;
+ }
+ return null;
+ }
+
+ public int compareServletVersions(String sv1, String sv2) {
+ if(sv1.equals(sv2)) return 0;
+ if(sv1.length() == 0 || sv2.length() == 0) return 0;
+ int i1 = sv1.indexOf('.');
+ int i2 = sv2.indexOf('.');
+ if(i1 < 0 || i2 < 0) return sv1.compareTo(sv2);
+ String p1 = sv1.substring(0, i1);
+ String p2 = sv2.substring(0, i2);
+ int r = p1.compareTo(p2);
+ if(r != 0) return r;
+ return compareServletVersions(sv1.substring(i1 + 1), sv2.substring(i2 + 1));
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/ProjectTemplate.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/ProjectTemplate.java 2007-10-16
13:49:41 UTC (rev 4229)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/helpers/ProjectTemplate.java 2007-10-16
13:50:27 UTC (rev 4230)
@@ -39,6 +39,10 @@
this.projectVersion = version;
}
+ public ProjectVersion getProjectVersion() {
+ return projectVersion;
+ }
+
public void init(String name, String root) {
this.root = new File(root);
this.location = new File(root, name);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/version/ProjectVersion.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/version/ProjectVersion.java 2007-10-16
13:49:41 UTC (rev 4229)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/project/version/ProjectVersion.java 2007-10-16
13:50:27 UTC (rev 4230)
@@ -36,6 +36,8 @@
String projectTemplatesLocation;
String[] order = new String[0];
+ String preferredServletVersion = null;
+
ProjectVersion(ProjectVersions versions) {
this.versions = versions;
}
@@ -60,6 +62,10 @@
return projectTemplatesLocation;
}
+ public String getPreferredServletVersion() {
+ return preferredServletVersion;
+ }
+
public String getErrorMessage() {
LibraryReference core = null;
LibraryReference common = null;
@@ -94,6 +100,10 @@
void load(Element e) {
element = e;
name = e.getAttribute("displayName"); //$NON-NLS-1$
+ String sv = e.getAttribute("servlet-version");
+ if(sv != null && sv.trim().length() > 0) {
+ preferredServletVersion = sv.trim();
+ }
ArrayList<LibraryReference> ls = new ArrayList<LibraryReference>();
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Show replies by date