Author: DartPeng
Date: 2009-07-22 04:14:09 -0400 (Wed, 22 Jul 2009)
New Revision: 16732
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
Log:
JBIDE-4640
Change the "ClasspathFileProcessor" to caculate the correct file's path
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java 2009-07-22
06:38:03 UTC (rev 16731)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ClassPathFileProcessor.java 2009-07-22
08:14:09 UTC (rev 16732)
@@ -48,7 +48,7 @@
IPath filePath = file.getFullPath();
String sp = sourcePath.toPortableString();
String fp = filePath.toPortableString();
- path = fp.substring(0, sp.length());
+ path = fp.substring(sp.length(), fp.length());
break;
}
// }
@@ -61,7 +61,9 @@
if(path == null){
path = file.getFullPath().removeFirstSegments(1).toPortableString();
}
- if(path.charAt(0) != '\\' || path.charAt(0) != '/' ){
+ if(path.charAt(0) == '\\' || path.charAt(0) == '/' ){
+
+ }else{
path = "/" + path;
}
return path;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22
06:38:03 UTC (rev 16731)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/edi/EDIDataParser.java 2009-07-22
08:14:09 UTC (rev 16732)
@@ -25,6 +25,9 @@
import javax.xml.transform.stream.StreamSource;
import org.dom4j.DocumentException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.EObject;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.configuration.editors.xml.TagList;
import org.jboss.tools.smooks.configuration.editors.xml.XMLObjectAnalyzer;
@@ -93,26 +96,34 @@
}
}
- return parseEDIFile(stream, mappingModel, encoding);
+ return parseEDIFile(stream, mappingModel, encoding, resourceList);
}
public TagList parseEDIFile(InputStream ediInputStream, EDIReader reader) throws
IOException, DocumentException {
String encoding = reader.getEncoding();
String mappingModel = reader.getMappingModel();
- return parseEDIFile(ediInputStream, mappingModel, encoding);
+ return parseEDIFile(ediInputStream, mappingModel, encoding, reader);
}
- public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding)
+ public TagList parseEDIFile(InputStream ediInputStream, String mappingModel, String
ediFileEncoding, EObject emodel)
throws IOException, DocumentException {
Smooks smooks = new Smooks();
SmooksResourceConfiguration readerConfig = new
SmooksResourceConfiguration("org.xml.sax.driver",
SmooksEDIReader.class.getName());
- File f = new File(mappingModel);
- String modelPath = mappingModel;
- if(f.exists()){
- modelPath = f.toURI().toString();
- }
+ File f = new File(mappingModel);
+ String modelPath = mappingModel;
+ if (f.exists()) {
+ modelPath = f.toURI().toString();
+ } else {
+ IResource resource = SmooksUIUtils.getResource(emodel);
+ if (resource != null) {
+ IFile tf = SmooksUIUtils.getFile(mappingModel, resource.getProject());
+ if (tf != null) {
+ modelPath = tf.getLocation().toFile().toURI().toString();
+ }
+ }
+ }
readerConfig.setParameter("mapping-model", modelPath);
if (ediFileEncoding == null || ediFileEncoding.trim().length() == 0) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22
06:38:03 UTC (rev 16731)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-22
08:14:09 UTC (rev 16732)
@@ -1482,12 +1482,11 @@
openFile(uri, project, null);
}
- public static void openFile(String uri, IProject project, String editorID) throws
PartInitException {
+ public static IFile getFile(String uri, IProject project) {
if (uri.charAt(0) == '\\' || uri.charAt(0) == '/') {
uri = uri.substring(1);
}
IFile file = project.getFile(uri);
- IWorkbenchWindow window =
SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
// it's workspace resource
if (file.exists()) {
@@ -1514,6 +1513,15 @@
}
}
if (file.exists()) {
+ return file;
+ }
+ return null;
+ }
+
+ public static void openFile(String uri, IProject project, String editorID) throws
PartInitException {
+ IFile file = getFile(uri, project);
+ IWorkbenchWindow window =
SmooksConfigurationActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (file != null && window != null) {
FileEditorInput editorInput = new FileEditorInput(file);
if (editorID != null) {
window.getActivePage().openEditor(editorInput, editorID);
@@ -2276,7 +2284,8 @@
parentList = null;
continue;
}
- if(parentList.isEmpty()) continue;
+ if (parentList.isEmpty())
+ continue;
parentList.remove(parentList.size() - 1);
((TreeNodeEditPart) rootEditPart).expandNode();
for (int i = parentList.size() - 1; i >= 0; i--) {