Author: scabanovich
Date: 2008-06-05 10:44:36 -0400 (Thu, 05 Jun 2008)
New Revision: 8584
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPageRedirectImpl.java
Log:
JBIDE-2284
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-05
13:28:01 UTC (rev 8583)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-05
14:44:36 UTC (rev 8584)
@@ -208,18 +208,22 @@
if(path != null) path = path.trim();
if(path == null || path.length() == 0) return path;
if(!path.startsWith("/") && !path.startsWith("*")) path =
"/" + path;
- if(path.indexOf('*') >= 0) return path;
+ if(hasWildCard(path)) return path;
if(path.indexOf('.') < 0 && !path.endsWith("/")) {
path += getExtension();
}
return path;
}
+
+ static boolean hasWildCard(String path) {
+ return path.indexOf('*') >= 0 || path.indexOf("#{") >= 0;
+ }
String revalidatePath(String path, String template) {
if(path != null) path = path.trim();
if(path == null || path.length() == 0) return path;
if(!path.startsWith("/") && !path.startsWith("*")) path =
"/" + path;
- if(path.indexOf('*') >= 0) return path;
+ if(hasWildCard(path)) return path;
if(path.indexOf('.') < 0 && !path.endsWith("/")) {
path += getExtension(template);
}
@@ -230,7 +234,8 @@
XModelObject fs = getTarget().getModel().getByPath("FileSystems/WEB-ROOT");
if(fs == null) return false;
path = revalidatePath(path, getAttributeValue(0, "template"));
- if(path == null || path.length() == 0 || path.indexOf('*') >= 0) return
false;
+ if(path == null || path.length() == 0
+ || hasWildCard(path)) return false;
return isCorrectPath(path) && !fileExists(path);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java 2008-06-05
13:28:01 UTC (rev 8583)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/helpers/SeamPagesDiagramHelper.java 2008-06-05
14:44:36 UTC (rev 8584)
@@ -364,12 +364,12 @@
}
public static String toNavigationRulePathPart(String path) {
- return "" + path.replace('/', '#');
+ return "" + encode(path);
}
public static String toFromViewId(String pathpart) {
- if(!pathpart.startsWith("rules:")) return pathpart.replace('#',
'/');
- pathpart = pathpart.substring(6).replace('#', '/');
+ if(!pathpart.startsWith("rules:")) return decode(pathpart);
+ pathpart = decode(pathpart.substring(6));
int i = pathpart.lastIndexOf(':');
return (i < 0) ? pathpart : pathpart.substring(0, i);
}
@@ -378,4 +378,41 @@
return path != null && (path.length() == 0 || path.indexOf('*') >=
0);
}
+ static String encode(String s) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if(c == '/') {
+ result.append("#x");
+ } else if(c == '#') {
+ result.append("##");
+ } else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
+ static String decode(String s) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if(c == '#') {
+ char c1 = i + 1 < s.length() ? s.charAt(i + 1) : '\0';
+ if(c1 == 'x') {
+ result.append('/');
+ i++;
+ } else if(c1 == '#') {
+ result.append("#");
+ i++;
+ } else {
+ result.append("#");
+ }
+ } else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPageRedirectImpl.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPageRedirectImpl.java 2008-06-05
13:28:01 UTC (rev 8583)
+++
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/impl/SeamPageRedirectImpl.java 2008-06-05
14:44:36 UTC (rev 8584)
@@ -1,12 +1,17 @@
package org.jboss.tools.seam.pages.xml.model.impl;
import org.jboss.tools.common.model.impl.CustomizedObjectImpl;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
public class SeamPageRedirectImpl extends CustomizedObjectImpl {
private static final long serialVersionUID = 1L;
+ public String getPathPart() {
+ return super.getPathPart();
+ }
+
public String getPresentationString() {
- String v1 = getAttributeValue("view id");
+ String v1 = getAttributeValue(SeamPagesConstants.ATTR_VIEW_ID);
if(v1 != null && v1.length() > 0) return v1;
return getModelEntity().getXMLSubPath();
}
Show replies by date