Author: DartPeng
Date: 2008-11-06 03:33:10 -0500 (Thu, 06 Nov 2008)
New Revision: 11562
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
Log:
JBIDE-2995
Change the "sourceDataPath" and "targetDataPath" :
Workspace file path : "Workspace : //project/file.smooks"
File System file path : "File ://home/test.smooks"
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-11-06
08:31:19 UTC (rev 11561)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-11-06
08:33:10 UTC (rev 11562)
@@ -25,6 +25,7 @@
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.xml2java.analyzer.AbstractXMLModelAnalyzer;
/**
*
@@ -153,7 +154,8 @@
// dialog.setInitialSelections(selectedResources);
if (files.length > 0) {
IFile file = files[0];
- String s = file.getLocation().toOSString();
+ String s = file.getFullPath().toPortableString();
+ s = AbstractXMLModelAnalyzer.WORKSPACE_PRIX + s;
relationT.setText(s);
}
}
@@ -276,6 +278,7 @@
FileDialog dialog = new FileDialog(this.getShell());
String path = dialog.open();
if (path != null) {
+ path = AbstractXMLModelAnalyzer.FILE_PRIX + path;
relationText.setText(path);
}
}
@@ -286,10 +289,10 @@
if (text == null || "".equals(text))
error = "Please Select a file";
- File tempFile = new File(text);
- if(!tempFile.exists()){
- error = "Can't find the file , please select another one.";
- }
+// File tempFile = new File(text);
+// if(!tempFile.exists()){
+// error = "Can't find the file , please select another one.";
+// }
// if (!reasourceLoaded) {
// error = "Resource must be loaded";
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2008-11-06
08:31:19 UTC (rev 11561)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2008-11-06
08:33:10 UTC (rev 11562)
@@ -18,6 +18,8 @@
import org.dom4j.DocumentException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
import org.jboss.tools.smooks.graphical.GraphInformations;
@@ -31,11 +33,16 @@
* @author Dart Peng<br>
* Date : Sep 23, 2008
*/
-public class AbstractXMLModelAnalyzer implements ISourceModelAnalyzer ,
ITargetModelAnalyzer {
+public class AbstractXMLModelAnalyzer implements ISourceModelAnalyzer,
+ ITargetModelAnalyzer {
+ public static final String FILE_PRIX = "File:/";
+
+ public static final String WORKSPACE_PRIX = "Workspace:/";
+
private String parmaKey = "";
-
- public AbstractXMLModelAnalyzer(String paramKey){
+
+ public AbstractXMLModelAnalyzer(String paramKey) {
this.parmaKey = paramKey;
}
@@ -56,11 +63,30 @@
}
}
if (path == null) {
- // TODO tell user the filepath can't find or not ?
return null;
-// throw new InvocationTargetException(new Exception(
-// "xml file path can't find in the graphInfo file"));
+ // throw new InvocationTargetException(new Exception(
+ // "xml file can't be found in the .graph file."));
}
+ int index = path.indexOf(FILE_PRIX);
+ if (index != -1) {
+ path = path.substring(index + FILE_PRIX.length(), path.length());
+ } else {
+ index = path.indexOf(WORKSPACE_PRIX);
+ if (index != -1) {
+ path = path.substring(index + WORKSPACE_PRIX.length(), path
+ .length());
+ Path wpath = new Path(path);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ wpath);
+ if (file.exists()) {
+ path = file.getLocation().toOSString();
+ } else {
+ throw new InvocationTargetException(new Exception("file dosen't exist"
+ path + " on the workspace."));
+ }
+ }else{
+ throw new InvocationTargetException(new Exception("Illegal file path : " +
path + "."));
+ }
+ }
XMLObjectAnalyzer objectBuilder = new XMLObjectAnalyzer();
try {
FileInputStream stream = new FileInputStream(path);
@@ -76,6 +102,6 @@
public Object buildTargetInputObjects(GraphInformations graphInfo,
SmooksResourceListType listType, IFile sourceFile)
throws InvocationTargetException {
- return buildSourceInputObjects(graphInfo,listType,sourceFile);
+ return buildSourceInputObjects(graphInfo, listType, sourceFile);
}
}
Show replies by date