1 19 20 package org.netbeans.i18n.test; 21 22 import java.io.File ; 23 import java.io.PrintWriter ; 24 25 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileStateInvalidException; 28 import org.openide.filesystems.FileSystem; 29 import org.openide.filesystems.Repository; 30 31 34 39 40 public class Utilities extends Object { 41 42 public static String formBundle = "org.netbeans.modules.form.Bundle"; 43 public static String formPaletteBundle = "org.netbeans.modules.form.palette.Bundle"; 44 public static String formActionsBundle = "org.netbeans.modules.form.actions.Bundle"; 45 46 47 public static String windowsCoreBundle = "org.netbeans.core.windows.Bundle"; 48 public static String statusCompile = "org.netbeans.core.compiler.Bundle"; 49 50 51 public static String openideActions = "org.openide.actions.Bundle"; 52 public static String openideText = "org.openide.text.Bundle"; 53 54 55 public static String jdbcPaletteBundle = "org.netbeans.modules.jdbc.resources.Bundle"; 56 57 60 61 public static String Resources = "Resources"; 62 public static String passCaption = " PASS - \n\t"; 63 public static String failCaption = " FAIL - \n\t"; 64 public static String errorCaption = "Test ERROR : "; 65 66 67 public static String TP_ComponentPalette = "org.netbeans.modules.form.palette.PaletteTopComponent"; 68 public static String TP_ComponentInspector = "org.netbeans.modules.form.ComponentInspector"; 69 public static String TP_FormDesigner = "org.netbeans.modules.form.FormDesigner"; 70 71 public static String separ="/"; 73 74 75 public Utilities() { 76 } 77 78 84 public static FileObject findFileObject(String _package, String _name, String _extension) { 85 String name=""; 87 if (_package != null && _package.length() > 0) { 89 name=_package.replaceAll("\\.",separ)+separ; 90 } 91 if (_name != null && _name.length() > 0) { 92 name+=_name; 93 } 94 if (_extension != null && _extension.length() > 0) { 95 name+="."+_extension; 96 } 97 FileObject f=Repository.getDefault().findResource(name); 99 return f; 100 } 101 102 108 public static String getFS(String _package, String fileName, String fileExtension) throws Exception { 109 FileObject f = findFileObject(_package, fileName, fileExtension); 110 111 if(f == null) 112 throw new Exception ("Unable find file " + fileName + "." + fileExtension + " in package " + _package); 113 114 String fs; 115 try { 116 fs = f.getFileSystem().getDisplayName(); 118 } catch(FileStateInvalidException exc){ 119 throw new Exception ("FileStateInvalidException during attempt get filesystem name for " + fileName + "." + fileExtension + " in package " + _package); 120 } 121 122 String fsName = fs.replaceAll("\\\\",separ); 125 127 return fsName; 128 } 129 130 public static String getPath(String packageName, String fileName, String fileExtension, String delim) throws Exception { 131 String FS_Name = getFS(packageName, fileName, fileExtension); 132 return FS_Name + delim + packageName.replace('.',delim.charAt(0)) + delim + fileName; 133 } 134 135 public static String getPath(String packageName, String delim) throws Exception { 136 String FS_Name = getFS(packageName, null, null); 137 return FS_Name + delim + packageName.replace('.',delim.charAt(0)); 138 } 139 140 public static String getSystemPath(String packageName, String fileName, String fileExtension) throws Exception { 141 return getPath(packageName, fileName, fileExtension, separ)+ "." + fileExtension; 142 } 143 144 public static void writeExc(Exception exc, PrintWriter err) { 145 err.println(errorCaption); 146 exc.printStackTrace(err); 147 } 148 149 public static void main(java.lang.String [] args) { 150 try { 151 String s; s=getPath("org.netbeans.test.gui.projects", "data", null, "|"); 154 System.out.println(s); 155 } catch (Exception ex) { 156 ex.printStackTrace(); 157 } 158 } 159 160 } 161 | Popular Tags |