Extracts an EJS model (and its resource files) from the given source and then runs EJS with that model. The example is extracted in the source directory of the users' EJS. The user will be warned before overwriting any file. @return boolean
(String _model, java.util.Set<String> _resources, Class<?> _ejsClass, final String _password)
| 242 | * @return boolean |
| 243 | */ |
| 244 | static private boolean doRunEjs(String _model, java.util.Set<String> _resources, Class<?> _ejsClass, |
| 245 | final String _password) { |
| 246 | String ejsRootDirPath = null; |
| 247 | // String console_options = null; |
| 248 | String sourceDirPath = null; |
| 249 | String version = null; |
| 250 | File ejsRootDirectory = null; |
| 251 | java.awt.Component parentComponent = null; |
| 252 | try { |
| 253 | String filename = System.getProperty("user.home").replace('\\', '/'); //$NON-NLS-1$ |
| 254 | if (!filename.endsWith("/")) { //$NON-NLS-1$ |
| 255 | filename = filename + "/"; //$NON-NLS-1$ |
| 256 | } |
| 257 | Reader reader = new FileReader(filename + INFO_FILE); |
| 258 | LineNumberReader l = new LineNumberReader(reader); |
| 259 | String sl = l.readLine(); |
| 260 | while (sl != null) { |
| 261 | if (sl.startsWith("ejs_root_directory = ")) { //$NON-NLS-1$ |
| 262 | ejsRootDirPath = sl.substring("ejs_root_directory = ".length()).trim(); //$NON-NLS-1$ |
| 263 | // else if (sl.startsWith("console_options = ")) console_options = |
| 264 | // sl.substring("console_options = ".length()).trim(); |
| 265 | } else if (sl.startsWith("source_directory = ")) { //$NON-NLS-1$ |
| 266 | sourceDirPath = sl.substring("source_directory = ".length()).trim(); //$NON-NLS-1$ |
| 267 | } else if (sl.startsWith("version = ")) { //$NON-NLS-1$ |
| 268 | version = sl.substring("version = ".length()).trim(); //$NON-NLS-1$ |
| 269 | } |
| 270 | sl = l.readLine(); |
| 271 | } |
| 272 | reader.close(); |
| 273 | int major = 3; |
| 274 | if (version != null) { |
| 275 | int index = version.indexOf('.'); |
| 276 | if (index >= 0) { |
| 277 | major = Integer.parseInt(version.substring(0, index)); |
| 278 | } |
| 279 | } |
| 280 | if (major < 4) { // Incorrect version, update to 4.0 |
| 281 | JOptionPane.showMessageDialog(parentComponent, |
| 282 | version + " " + res.getString("EjsTool.IncorrectVersion"), //$NON-NLS-1$ //$NON-NLS-2$ |
| 283 | res.getString("EjsTool.Error"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$ |
| 284 | return false; |
| 285 | } |
| 286 | // See if EjsConsole.jar is there |
| 287 | ejsRootDirectory = new File(ejsRootDirPath); |
| 288 | if (!new File(ejsRootDirectory, "EjsConsole.jar").exists()) { //$NON-NLS-1$ |
| 289 | ejsRootDirectory = null; |
| 290 | } |
| 291 | } catch (Exception exc) { |
| 292 | exc.printStackTrace(); |
| 293 | ejsRootDirectory = null; |
| 294 | } |
| 295 | if (ejsRootDirectory == null) { |
| 296 | // Create a chooser |
| 297 | JFileChooser chooser = OSPRuntime.createChooser("", new String[] {}); //$NON-NLS-1$ |
| 298 | chooser.setDialogTitle(res.getString("EjsTool.EjsNotFound")); //$NON-NLS-1$ |
| 299 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 300 | chooser.setMultiSelectionEnabled(false); |
| 301 | // The message |
no test coverage detected