File configFile = new File(getConfigPath(), "config2.xml"); try { if (configFile.exists()) { loadConfigFile("config2.xml"); } else { configFile = new File(getConfigPath(), "config.xml"); if (configFile.exists()) { loadConfigFile("config.xml"); for (Enumeration e = getDeviceEntries().elements(); e.hasMoreElements();) { DeviceEntry entry = (DeviceEntry) e.nextElement(); if (!entry.canRemove()) { removeDeviceEntry(entry); File src = new File(getConfigPath(), entry.getFileName()); File dst = File.createTempFile("dev", ".jar", getConfigPath()); IOUtils.copyFile(src, dst); entry.setFileName(dst.getName()); addDeviceEntry(entry); createDefaultConfigXml(); saveConfig(); createDefaultConfigXml(); } finally { createDefaultConfigXml();
public void actionPerformed(ActionEvent ev) { DeviceEntry entry = (DeviceEntry) lsDevices.getSelectedValue(); for (Enumeration en = lsDevicesModel.elements(); en.hasMoreElements();) { DeviceEntry tmp = (DeviceEntry) en.nextElement(); if (tmp == entry) { tmp.setDefaultDevice(true); } else { tmp.setDefaultDevice(false); } Config.changeDeviceEntry(tmp); } lsDevices.repaint(); btDefault.setEnabled(false); } };
public void actionPerformed(ActionEvent ev) { if (fileChooser == null) { ExtensionFileFilter fileFilter = new ExtensionFileFilter("MIDlet files"); fileFilter.addExtension("jad"); fileFilter.addExtension("jar"); fileChooser = new JFileChooser(); fileChooser.setFileFilter(fileFilter); fileChooser.setDialogTitle("Open MIDlet File..."); fileChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentJadDirectory"))); } int returnVal = fileChooser.showOpenDialog(Main.this); if (returnVal == JFileChooser.APPROVE_OPTION) { Config.setRecentDirectory("recentJadDirectory", fileChooser.getCurrentDirectory().getAbsolutePath()); String url = IOUtils.getCanonicalFileURL(fileChooser.getSelectedFile()); Common.openMIDletUrlSafe(url); if (recordStoreManagerDialog != null) { recordStoreManagerDialog.refresh(); } } } };
private static void loadConfigFile(String configFileName) throws IOException { File configFile = new File(getConfigPath(), configFileName); InputStream is = null; String xml = ""; try { InputStream dis = new BufferedInputStream(is = new FileInputStream(configFile)); while (dis.available() > 0) { byte[] b = new byte[dis.available()]; dis.read(b); xml += new String(b); } configXml = new XMLElement(); configXml.parseString(xml); } catch (XMLParseException e) { Logger.error(e); createDefaultConfigXml(); } finally { IOUtils.closeQuietly(is); } }
saveForWebChooser.setFileFilter(fileFilter); saveForWebChooser.setDialogTitle("Save for Web..."); saveForWebChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentSaveForWebDirectory"))); Config.setRecentDirectory("recentSaveForWebDirectory", saveForWebChooser.getCurrentDirectory() .getAbsolutePath()); File pathFile = saveForWebChooser.getSelectedFile().getParentFile(); appletChooser.setFileFilter(fileFilter); appletChooser.setDialogTitle("Select MicroEmulator applet jar package..."); appletChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentAppletJarDirectory"))); if (appletChooser.showOpenDialog(Main.this) == JFileChooser.APPROVE_OPTION) { Config.setRecentDirectory("recentAppletJarDirectory", appletChooser.getCurrentDirectory() .getAbsolutePath()); appletJarFile = appletChooser.getSelectedFile(); IOUtils.copyFile(appletJarFile, appletPackageOutputFile); if (deviceInput != null && deviceInput.getFileName() != null) { IOUtils.copyFile(new File(Config.getConfigPath(), deviceInput.getFileName()), deviceOutputFile);
public void actionPerformed(ActionEvent ev) { DeviceEntry entry = (DeviceEntry) lsDevices.getSelectedValue(); boolean canDeleteFile = true; for (Enumeration en = lsDevicesModel.elements(); en.hasMoreElements();) { DeviceEntry test = (DeviceEntry) en.nextElement(); if (test != entry && test.getFileName() != null && test.getFileName().equals(entry.getFileName())) { canDeleteFile = false; break; } } if (canDeleteFile) { File deviceFile = new File(Config.getConfigPath(), entry.getFileName()); deviceFile.delete(); } if (entry.isDefaultDevice()) { for (Enumeration en = lsDevicesModel.elements(); en.hasMoreElements();) { DeviceEntry tmp = (DeviceEntry) en.nextElement(); if (!tmp.canRemove()) { tmp.setDefaultDevice(true); break; } } } lsDevicesModel.removeElement(entry); Config.removeDeviceEntry(entry); } };
File deviceFile = new File(Config.getConfigPath(), fileChooser.getSelectedFile().getName()); if (deviceFile.exists()) { deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath()); Config.addDeviceEntry(entry);
Config.getUrlsMRU().setListener(urlsMRU); menuFile.add(urlsMRU); Config.loadConfig(defaultDevice, emulatorContext); Logger.setLocationEnabled(Config.isLogConsoleLocationEnabled()); Rectangle window = Config.getWindow("main", new Rectangle(0, 0, 160, 120)); this.setLocation(window.x, window.y);
protected File getSuiteFolder() { return new File(Config.getConfigPath(), "suite-" + emulator.getLauncher().getSuiteName()); }
System.exit(0); } else if (arg.equals("--id")) { Config.setEmulatorID((String) argsIterator.next()); argsIterator.remove(); } else if ((arg.equals("--appclasspath")) || (arg.equals("-appclasspath")) || (arg.equals("-appcp"))) { if (defaultDevice.getFileName() != null) { URL[] urls = new URL[1]; urls[0] = new File(Config.getConfigPath(), defaultDevice.getFileName()).toURI().toURL(); classLoader = createExtensionsClassLoader(urls); String className = Config.getRecordStoreManagerClassName(); if (className != null) { try {
public SwtSelectDeviceDialog(Shell parent, EmulatorContext emulatorContext) { super(parent); this.emulatorContext = emulatorContext; Vector devs = Config.getDeviceEntries(); for (int i = 0; i < devs.size(); i++) { DeviceEntry entry = (DeviceEntry) devs.elementAt(i); if (entry.isDefaultDevice()) { selectedEntry = entry; } } }
public static void addDeviceEntry(DeviceEntry entry) { for (Enumeration en = getDeviceEntries().elements(); en.hasMoreElements();) { DeviceEntry test = (DeviceEntry) en.nextElement(); if (test.getDescriptorLocation().equals(entry.getDescriptorLocation())) { return; } } XMLElement devicesXml = configXml.getChildOrNew("devices"); XMLElement deviceXml = devicesXml.addChild("device"); if (entry.isDefaultDevice()) { deviceXml.setAttribute("default", "true"); } deviceXml.addChild("name", entry.getName()); deviceXml.addChild("filename", entry.getFileName()); deviceXml.addChild("descriptor", entry.getDescriptorLocation()); saveConfig(); }
Point location = getLocation(); Dimension size = getSize(); Rectangle window = Config.getWindow("scaledDisplay", new Rectangle(location.x + size.width, location.y, 0, 0)); scaledDisplayFrame.setLocation(window.x, window.y); Config.setWindow("scaledDisplay", new Rectangle(scaledDisplayFrame.getX(), scaledDisplayFrame.getY(), 0, 0), false); scaledDisplayFrame.pack();
if (entry.getFileName() != null) { URL[] urls = new URL[1]; urls[0] = new File(Config.getConfigPath(), entry.getFileName()).toURI().toURL(); classLoader = Common.createExtensionsClassLoader(urls); Rectangle size = Config.getDeviceEntryDisplaySize(entry); if (size != null) { deviceDisplay.setDisplayRectangle(size);
Config.loadConfig(null, emulatorContext); Rectangle window = Config.getWindow("main", new Rectangle(0, 0, 160, 120)); shell.setLocation(window.x, window.y);
addDeviceEntry(resizableDevice);
public void actionPerformed(ActionEvent e) { if (recordStoreManagerDialog == null) { recordStoreManagerDialog = new RecordStoreManagerDialog(Main.this, common); recordStoreManagerDialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { menuRecordStoreManager.setState(false); } }); recordStoreManagerDialog.pack(); Rectangle window = Config.getWindow("recordStoreManager", new Rectangle(0, 0, 640, 320)); recordStoreManagerDialog.setBounds(window.x, window.y, window.width, window.height); } recordStoreManagerDialog.setVisible(!recordStoreManagerDialog.isVisible()); } };
private void openMIDletUrl(String urlString, MIDletClassLoader midletClassLoader) throws IOException { try { setStatusBar("Loading..."); jad.clear(); if (urlString.toLowerCase().endsWith(".jad")) { Logger.debug("openJad", urlString); jad = loadJadProperties(urlString); loadJar(urlString, jad.getJarURL(), midletClassLoader); } else { jad.setCorrectedJarURL(urlString); loadJar(null, urlString, midletClassLoader); } Config.getUrlsMRU().push(new MidletURLReference(jad.getSuiteName(), urlString)); } catch (MalformedURLException ex) { throw ex; } catch (ClassNotFoundException ex) { Logger.error(ex); throw new IOException(ex.getMessage()); } catch (FileNotFoundException ex) { Message.error("File Not found", urlString, ex); } catch (NullPointerException ex) { Logger.error("Cannot open jad", urlString, ex); } catch (IllegalArgumentException ex) { Logger.error("Cannot open jad", urlString, ex); } }
File deviceFile = new File(Config.getConfigPath(), entry.getFileName()); deviceFile.delete(); Config.removeDeviceEntry(entry);
File deviceFile = new File(Config.getConfigPath(), file.getName()); if (deviceFile.exists()) { deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath()); Config.addDeviceEntry(entry);