public Object push(Object item) { if (!(item instanceof XMLItem)) { throw new ClassCastException(item.getClass().getName()); } modified = true; if (items.size() > maxCapacity) { items.pop(); } items.remove(item); if (items.empty()) { items.add(item); } else { items.insertElementAt(item, 0); } fireListener(item); return item; }
public static void saveConfig() { urlsMRU.save(configXml.getChildOrNew("files").getChildOrNew("recent")); File configFile = new File(getConfigPath(), "config2.xml"); getConfigPath().mkdirs(); FileWriter fw = null; try { fw = new FileWriter(configFile); configXml.write(fw); fw.close(); } catch (IOException ex) { Logger.error(ex); } finally { IOUtils.closeQuietly(fw); } }
Config.getUrlsMRU().setListener(urlsMRU); menuFile.add(urlsMRU);
urlsMRU.read(configXml.getChildOrNew("files").getChildOrNew("recent")); initSystemProperties();
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); } }
public void read(XMLElement xml) { modified = false; items.removeAllElements(); this.maxCapacity = xml.getIntAttribute("maxCapacity", MAXCAPACITY_DEFAULT); for (Enumeration en = xml.enumerateChildren(); en.hasMoreElements();) { XMLElement xmlChild = (XMLElement) en.nextElement(); if (xmlChild.getName().equals(itemsName)) { try { XMLItem element = (XMLItem) classXMLItem.newInstance(); element.read(xmlChild); items.add(element); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } if (!items.empty()) { // Fire Listener in reverse order for (ListIterator iter = items.listIterator(items.size()); iter.hasPrevious();) { XMLItem element = (XMLItem) iter.previous(); fireListener(element); } } }