12345678910111213141516171819202122232425262728293031323334353637383940414243
package org.netbeans.modules.jphyswiz.utils; import java.io.File; import org.openide.filesystems.*; import org.openide.ErrorManager; import org.openide.loaders.DataObject; import org.netbeans.modules.jphyswiz.xode.*; /** * * @author levent */ public class Utilities { public static FileDataObject loadXODEFile(File xodeFile) { LocalFileSystem fileSystem = new LocalFileSystem(); FileObject fileObject = null; FileDataObject dataObject = null; System.out.println("I am opening file ... "+xodeFile.getAbsolutePath()); // Find xode file and open it in the explorer try { fileSystem.setRootDirectory(new File(xodeFile.getParent())); fileObject = fileSystem.findResource(xodeFile.getName()); dataObject = (FileDataObject)DataObject.find(fileObject); dataObject.setFileAbsolutePath(xodeFile.getAbsolutePath()); } catch(Exception e1) { ErrorManager.getDefault().notify( ErrorManager.ERROR, e1); } return dataObject; } }