Author: scabanovich
Date: 2007-08-27 08:00:32 -0400 (Mon, 27 Aug 2007)
New Revision: 3340
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-850
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -13,15 +13,16 @@
import java.util.*;
public class XModelConstants {
- public static String HOME = "redhat.home";
- public static String WORKSPACE = "redhat.workspace";
- public static String WORKSPACE_NAME = "redhat.workspace.name";
-
- public static String MODEL_VERSION = "version";
+ public static String HOME = "product.home";
- private static String ECOM_HOME = "global.ECOM_HOME";
- private static String ECOM_DATA = "global.ECOM_DATA";
+ public static String WORKSPACE = "workspace.home";
+ public static String WORKSPACE_REF = "%" + WORKSPACE + "%";
+ public static String WORKSPACE_OLD = "redhat.workspace";
+ public static String WORKSPACE_OLD_REF = "%" + WORKSPACE_OLD + "%";
+
+ public static String MODEL_VERSION = "version";
+
private XModelConstants() {}
public static String getHome(XModel model) {
@@ -37,29 +38,6 @@
validate(model);
}
- public static String getWorkspaceName(XModel model) {
- return model.getProperties().getProperty(WORKSPACE_NAME);
- }
-
- public static void setWorkspaceName(XModel model, String name) {
- if(name == null)
- model.getProperties().remove(WORKSPACE_NAME);
- else
- model.getProperties().setProperty(WORKSPACE_NAME, name);
- }
-
- public static String getProjectName(XModel model) {
- String s = getWorkspaceName(model);
- if(s != null) return s;
- s = getWorkspace(model);
- return (s == null) ? null : new java.io.File(s).getName();
- }
-
- public static String getProjectPrefix(XModel model) {
- String s = getWorkspaceName(model);
- return (s == null) ? "" : s + "-";
- }
-
//
public static void validate(XModel model) {
@@ -67,12 +45,9 @@
}
public static void validate(Properties p) {
- String h1 = p.getProperty(HOME), h2 = p.getProperty(ECOM_HOME);
- if(h1 != null) p.setProperty(ECOM_HOME, h1);
- else if(h2 != null) p.setProperty(HOME, h2);
- String w1 = p.getProperty(WORKSPACE), w2 = p.getProperty(ECOM_DATA);
- if(w1 != null) p.setProperty(ECOM_DATA, w1);
- else if(w2 != null) p.setProperty(WORKSPACE, w2);
+ String h1 = p.getProperty(HOME);
+ String w1 = p.getProperty(WORKSPACE);
+ //
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/engines/impl/EnginesLoader.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -69,8 +69,7 @@
}
protected String fileName(XModelObject object) {
- return XModelConstants.getProjectPrefix(object.getModel()) +
- object.getModelEntity().getName().toLowerCase() + ".rex";
+ return object.getModelEntity().getName().toLowerCase() + ".rex";
}
public static void merge(XModelObject object, XModelObject update) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsImpl.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -155,7 +155,10 @@
public String get(String name) {
if("APPLICATION_NAME".equals(name)) {
String s = super.get(name);
- if(s == null || s.length() == 0) s =
XModelConstants.getWorkspaceName(getModel());
+ if(s == null || s.length() == 0) {
+ s = "";
+ // project name ?
+ }
return (s == null) ? "" : s;
} else {
return super.get(name);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -72,6 +72,16 @@
String f = getEclipseFileName(object, true);
if(f == null) super.load(object);
else util().load(new File(f), object);
+
+ XModelObject[] os = object.getChildren();
+ for (int i = 0; i < os.length; i++) {
+ String s = os[i].getAttributeValue("location");
+ if(s == null || !s.startsWith(XModelConstants.WORKSPACE_OLD_REF)) continue;
+ s = XModelConstants.WORKSPACE_REF +
s.substring(XModelConstants.WORKSPACE_OLD_REF.length());
+ os[i].setAttributeValue("location", s);
+ System.out.println("Corrected " + s);
+ }
+
removeMissingJarSystems(object);
}
@@ -92,7 +102,7 @@
}
protected String fileName(XModelObject object) {
- return XModelConstants.getProjectPrefix(object.getModel()) +
"workspace.pex";
+ return "workspace.pex";
}
private boolean saveEclipse(XModelObject object) {
@@ -242,7 +252,7 @@
private void saveWorkspaceHomeAttr(Element element, XModelObject o) {
Properties p = o.getModel().getProperties();
String project = p.getProperty(IModelNature.ECLIPSE_PROJECT);
- String workspace = p.getProperty("redhat.workspace");
+ String workspace = p.getProperty(XModelConstants.WORKSPACE);
if(project == null) return;
String relative = workspace.startsWith(project + "/") ?
"." + workspace.substring(project.length()) : workspace;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/MountFileSystemHandler.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -83,9 +83,9 @@
boolean isRelative = "true".equals(p.getProperty("set location
relative to project"));
if(!isRelative) return;
String location = canonize(p.getProperty("location"),
object.getModel());
- String project = canonize("%redhat.workspace%", object.getModel());
+ String project = canonize(XModelConstants.WORKSPACE_REF, object.getModel());
if(location.equals(project)) {
- p.setProperty("location", "%redhat.workspace%");
+ p.setProperty("location", XModelConstants.WORKSPACE_REF);
return;
}
boolean common = false;
@@ -105,7 +105,7 @@
common = true;
}
if(!common) return;
- String s = "%redhat.workspace%";
+ String s = XModelConstants.WORKSPACE_REF;
if(project.length() > 0) {
int q = new StringTokenizer(project, "/").countTokens();
for (int i = 0; i < q; i++) s += "/..";
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -395,7 +395,7 @@
private String getProjectName() {
String d = properties.getProperty(XModelConstants.WORKSPACE);
- String n = properties.getProperty(XModelConstants.WORKSPACE_NAME);
+ String n = null; //obsolete
if(d == null) return null;
d = reduceURLPath(d);
if(d.lastIndexOf(':') >= 2)
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -88,6 +88,7 @@
if(home == null || !home.equals(h)) {
ModelPlugin.getPluginLog().logInfo("WARNING:" + " workspace home
changed from " + h + " to " + home);
model.getProperties().setProperty(XModelConstants.WORKSPACE, home);
+ model.getProperties().setProperty(XModelConstants.WORKSPACE_OLD, home);
model.getProperties().setProperty("nature", getID());
model.load();
}
@@ -96,6 +97,7 @@
Properties p = new Properties();
p.putAll(System.getProperties());
p.setProperty(XModelConstants.WORKSPACE, getWorkspaceHome());
+ p.setProperty(XModelConstants.WORKSPACE_OLD, getWorkspaceHome());
p.setProperty(ECLIPSE_PROJECT, project.getLocation().toString());
p.setProperty(ECLIPSE_PROJECT_OLD, project.getLocation().toString());
p.put("project", project);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2007-08-27
11:19:21 UTC (rev 3339)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2007-08-27
12:00:32 UTC (rev 3340)
@@ -839,7 +839,7 @@
workspace = new File(workspace).getAbsolutePath().replace('\\', '/');
path = path.replace('\\', '/');
String relative = org.jboss.tools.common.util.FileUtil.getRelativePath(workspace,
path);
- return (relative == null) ? path : "%redhat.workspace%" + relative;
+ return (relative == null) ? path : XModelConstants.WORKSPACE_REF + relative;
}
}