From: <ha...@us...> - 2012-12-23 01:22:57
|
Revision: 17827 http://jmol.svn.sourceforge.net/jmol/?rev=17827&view=rev Author: hansonr Date: 2012-12-23 01:22:41 +0000 (Sun, 23 Dec 2012) Log Message: ----------- JavaScript popup menu Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/Interface.java trunk/Jmol/src/org/jmol/appletjs/Jmol.java trunk/Jmol/src/org/jmol/awtjs2d/JSModelKitPopup.java trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java trunk/Jmol/src/org/jmol/awtjs2d/JmolFileAdapter.java trunk/Jmol/src/org/jmol/exportjs/Exporter.java trunk/Jmol/src/org/jmol/i18n/GT.java trunk/Jmol/src/org/jmol/io2/ZipUtil.java trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java trunk/Jmol/src/org/jmol/jvxl/readers/VolumeDataReader.java trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldMMFF.java trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java trunk/Jmol/src/org/jmol/modelset/BondCollection.java trunk/Jmol/src/org/jmol/multitouch/sparshui/JmolSparshClientAdapter.java trunk/Jmol/src/org/jmol/popup/GenericPopup.java trunk/Jmol/src/org/jmol/popup/JmolAbstractMenu.java trunk/Jmol/src/org/jmol/popup/PopupResource.java trunk/Jmol/src/org/jmol/popup/SwingPopup.java trunk/Jmol/src/org/jmol/quantum/MepCalculation.java trunk/Jmol/src/org/jmol/renderspecial/DotsRenderer.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/smiles/InvalidSmilesException.java trunk/Jmol/src/org/jmol/smiles/SmilesGenerator.java trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java trunk/Jmol/src/org/jmol/thread/MinimizationThread.java trunk/Jmol/src/org/jmol/util/DefaultLogger.java trunk/Jmol/src/org/jmol/viewer/FileManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/api/Interface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/Interface.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/api/Interface.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -43,7 +43,7 @@ Class<?> x = Class.forName(name); return (x == null ? null : x.newInstance()); } catch (Exception e) { - Logger.error("Interface.java Error creating instance for " + name + ": \n" + e.getMessage()); + Logger.error("Interface.java Error creating instance for " + name + ": \n" + e); return null; } } Modified: trunk/Jmol/src/org/jmol/appletjs/Jmol.java =================================================================== --- trunk/Jmol/src/org/jmol/appletjs/Jmol.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/appletjs/Jmol.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -746,7 +746,7 @@ } } } catch (Exception e) { - Logger.error("Exception " + e.getMessage() + " with nX, nY: " + nX + Logger.error("Exception " + e + " with nX, nY: " + nX + " " + nY); } // for (int i = 0; i < nX; i++) @@ -769,7 +769,7 @@ { } } catch (Exception e) { - Logger.error("Exception " + e.getMessage() + " for " + functionName + " with nX, nY, nZ: " + nX + Logger.error("Exception " + e + " for " + functionName + " with nX, nY, nZ: " + nX + " " + nY + " " + nZ); } // for (int i = 0; i < nX; i++) Modified: trunk/Jmol/src/org/jmol/awtjs2d/JSModelKitPopup.java =================================================================== --- trunk/Jmol/src/org/jmol/awtjs2d/JSModelKitPopup.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/awtjs2d/JSModelKitPopup.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -23,6 +23,10 @@ */ package org.jmol.awtjs2d; +import java.net.URL; + +import javax.swing.ImageIcon; + import org.jmol.i18n.GT; import org.jmol.modelkit.ModelKitPopupResourceBundle; import org.jmol.popup.PopupResource; @@ -31,16 +35,12 @@ public class JSModelKitPopup extends JSPopup { - - private String imagePath; - public JSModelKitPopup() { // required by reflection } public void jpiInitialize(Viewer viewer, String menu) { updateMode = UPDATE_NEVER; - imagePath = "org/jmol/modelkit/images/"; boolean doTranslate = GT.getDoTranslate(); GT.setDoTranslate(true); PopupResource bundle = new ModelKitPopupResourceBundle(); @@ -96,4 +96,14 @@ // super.menuCheckClick(source, script); // } + @Override + protected Object getEntryIcon(String[] ret) { + String entry = ret[0]; + if (!entry.startsWith("<")) + return null; + int pt = entry.indexOf(">"); + ret[0] = entry.substring(pt + 1); + return "org/jmol/modelkit/images/" + entry.substring(1, pt); + } + } Modified: trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java =================================================================== --- trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -42,15 +42,11 @@ // (on exit) checkMenuFocus(item.getName(), item.getActionCommand(), false); // (on checkbox click) checkBoxStateChanged(e.getSource()); - //TODO: JavaScript objects: - // new Jmol.Menu.PopupMenu(name) - // new Jmol.Menu.SubMenu(entry) - // new Jmol.Menu.MenuItem(entry) - // new Jmol.Menu.ButtonGroup() - // new Jmol.Menu.CheckBoxMenuItem(entry) - // new Jmol.Menu.RadioButtonMenuItem(entry) + // new Jmol.Menu.PopupMenu(applet, name) + // new Jmol.Menu.SubMenu(applet, entry) + // new Jmol.Menu.MenuItem(applet, entry, isCheckBox, isRadio) + // new Jmol.Menu.ButtonGroup(applet) // - //TODO: Jmol given in j2sNative blocks, for example: setText, setActionCommand public JSPopup() { // required by reflection @@ -77,6 +73,7 @@ * b.setText(entry); * if (script != null) * b.setActionCommand(script); + * this.popupMenu.tainted = true; * */ { @@ -111,7 +108,7 @@ * @j2sNative * * if (this.buttonGroup == null) - * this.buttonGroup = new Jmol.Menu.ButtonGroup(); + * this.buttonGroup = new Jmol.Menu.ButtonGroup(this.popupMenu); * this.buttonGroup.add(newMenu); * */ @@ -123,6 +120,7 @@ * @j2sNative * * menu.add(item); + * this.popupMenu.tainted = true; * */ {} @@ -132,7 +130,8 @@ /** * @j2sNative * - * menu.addSeparator(); + * menu.add(new Jmol.Menu.MenuItem(this.popupMenu, null, false, false)); + * this.popupMenu.tainted = true; * */ {} @@ -155,13 +154,7 @@ /** * @j2sNative * - * if (isRadio) { - * item = new Jmol.Menu.RadioButtonMenuItem(entry); - * item.setArmed(state); - * } else { - * item = new Jmol.Menu.CheckBoxMenuItem(entry); - * item.setState(state); - * } + * item = new Jmol.Menu.MenuItem(this.popupMenu, entry, !isRadio, isRadio); * item.setSelected(state); * item.addItemListener(this); * @@ -177,7 +170,7 @@ /** * @j2sNative * - * item = new Jmol.Menu.MenuItem(entry); + * item = new Jmol.Menu.MenuItem(this.popupMenu, entry); * item.addActionListener(this); * */ @@ -189,7 +182,7 @@ /** * @j2sNative * - * return new Jmol.Menu.PopupMenu(name, this.viewer); + * return new Jmol.Menu.PopupMenu(this.viewer.applet, name); * */ { @@ -210,6 +203,7 @@ * } catch (e) { * // ignore * } + * this.popupMenu.tainted = true; * */ {} @@ -224,6 +218,7 @@ * } catch (e) { * // ignore * } + * this.popupMenu.tainted = true; * */ {} @@ -246,7 +241,7 @@ * this.menuGetAsText(sb, level + 1, m.getPopupMenu(), name); * } else if (m.isItem) { * flags = "enabled:" + m.isEnabled(); - * if (m.isCheckBoxItem) + * if (m.isCheckBox) * flags += ";checked:" + m.getState(); * var script = this.fixScript(m.getName(), m.getActionCommand()); * this.addItemText(sb, 'I', level, m.getName(), m.getText(), script, flags); @@ -313,17 +308,18 @@ * @j2sNative * * menu.insert(subMenu, index) + * this.popupMenu.tainted = true; * */ {} } - public Object menuNewEntry(String entry, String id) { + public Object menuNewSubMenu(String entry, String id) { /** * @j2sNative * - * var menu = new Jmol.Menu.SubMenu(entry); + * var menu = new Jmol.Menu.SubMenu(this.popupMenu, entry); * this.updateButton(menu, entry, null); * menu.setName(id); * menu.setAutoscrolls(true); @@ -339,6 +335,7 @@ * @j2sNative * * menu.remove(index); + * this.popupMenu.tainted = true; * */ {} @@ -349,6 +346,7 @@ * @j2sNative * * menu.removeAll(); + * this.popupMenu.tainted = true; * */ {} @@ -359,6 +357,7 @@ * @j2sNative * * menu.setAutoscrolls(true); + * this.popupMenu.tainted = true; * */ {} @@ -368,11 +367,8 @@ /** * @j2sNative * - * if (item.isCheckBox) - * item.setState(state); - * else - * item.setArmed(state); - * item.setSelected(state); + * item.setSelected(state); + * this.popupMenu.tainted = true; * */ {} @@ -387,6 +383,7 @@ * @j2sNative * * this.setCheckBoxValue(source, source.getActionCommand(), source.isSelected()); + * this.popupMenu.tainted = true; * */ {} @@ -397,6 +394,7 @@ * @j2sNative * * menu.setText(entry); + * this.popupMenu.tainted = true; * */ {} @@ -410,7 +408,7 @@ /** * @j2sNative * - * popup.show(x, y); + * popup.menuShowPopup(x, y); * */ {} Modified: trunk/Jmol/src/org/jmol/awtjs2d/JmolFileAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/awtjs2d/JmolFileAdapter.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/awtjs2d/JmolFileAdapter.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -13,7 +13,7 @@ try { throw new UnknownServiceException("No local file reading in JavaScript version of Jmol"); } catch (IOException e) { - return e.getMessage(); + return e.toString(); } } @@ -27,7 +27,7 @@ conn.outputString(post); return conn.getStringXBuilder(); } catch (IOException e) { - return e.getMessage(); + return e.toString(); } } Modified: trunk/Jmol/src/org/jmol/exportjs/Exporter.java =================================================================== --- trunk/Jmol/src/org/jmol/exportjs/Exporter.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/exportjs/Exporter.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -294,7 +294,7 @@ bw.close(); os = null; } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); return "ERROR EXPORTING FILE"; } return "OK " + nBytes + " " + jmolRenderer.getExportName() + " " + fileName ; Modified: trunk/Jmol/src/org/jmol/i18n/GT.java =================================================================== --- trunk/Jmol/src/org/jmol/i18n/GT.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/i18n/GT.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -263,9 +263,9 @@ Logger.debug("GT adding " + className); } } catch (IllegalAccessException e) { - Logger.warn("Illegal Access Exception: " + e.getMessage()); + Logger.warn("Illegal Access Exception: " + e.toString()); } catch (InstantiationException e) { - Logger.warn("Instantiation Exception: " + e.getMessage()); + Logger.warn("Instantiation Exception: " + e.toString()); } } Modified: trunk/Jmol/src/org/jmol/io2/ZipUtil.java =================================================================== --- trunk/Jmol/src/org/jmol/io2/ZipUtil.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/io2/ZipUtil.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -249,7 +249,7 @@ s = getZipDirectoryOrErrorAndClose(bis, false); bis.close(); } catch (Exception e) { - Logger.error(e.getMessage()); + Logger.error(e.toString()); } for (int i = 0; i < s.length; i++) sb.append(s[i]).appendC('\n'); @@ -263,7 +263,7 @@ s = getZipDirectoryOrErrorAndClose(bis, addManifest); bis.close(); } catch (Exception e) { - Logger.error(e.getMessage()); + Logger.error(e.toString()); } return s; } @@ -476,8 +476,8 @@ nBytes = f.length(); } } catch (IOException e) { - Logger.info(e.getMessage()); - return e.getMessage(); + Logger.info(e.toString()); + return e.toString(); } return msg + " " + nBytes + " " + fullFilePath; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/jvxl/readers/PmeshReader.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -170,7 +170,7 @@ nPolygons = binarydoc.readInt(); binarydoc.readByteArray(ignored, 0, 64); } catch (Exception e) { - pmeshError += " " + e.getMessage(); + pmeshError += " " + e.toString(); binarydoc.close(); return false; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceGenerator.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -1041,7 +1041,7 @@ Class<?> x = Class.forName("org.jmol.jvxl.readers." + name); return (x == null ? null : x.newInstance()); } catch (Exception e) { - Logger.error("Interface.java Error creating instance for " + name + ": \n" + e.getMessage()); + Logger.error("Interface.java Error creating instance for " + name + ": \n" + e.toString()); return null; } } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -559,9 +559,9 @@ try { readSurfaceData(false); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); Logger.error("Exception in SurfaceReader::readSurfaceData: " - + e.getMessage()); + + e.toString()); } return; } Modified: trunk/Jmol/src/org/jmol/jvxl/readers/VolumeDataReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/VolumeDataReader.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/jvxl/readers/VolumeDataReader.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -93,7 +93,7 @@ try { readSurfaceData(isMapData); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); return false; } return true; Modified: trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldMMFF.java =================================================================== --- trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldMMFF.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldMMFF.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -445,7 +445,7 @@ } br.close(); } catch (Exception e) { - System.err.println("Exception " + e.getMessage() + " in getResource " + System.err.println("Exception " + e.toString() + " in getResource " + fileName + " line=" + line); } } @@ -481,7 +481,7 @@ } br.close(); } catch (Exception e) { - System.err.println("Exception " + e.getMessage() + " in getResource " + System.err.println("Exception " + e.toString() + " in getResource " + fileName + " line=" + line); } Modified: trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java =================================================================== --- trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -242,7 +242,7 @@ } br.close(); } catch (Exception e) { - System.err.println("Exception " + e.getMessage() + " in getResource " + System.err.println("Exception " + e.toString() + " in getResource " + fileName); try{ br.close(); @@ -271,7 +271,7 @@ br.close(); } catch (Exception e) { - System.err.println("Exception " + e.getMessage() + " in getResource " + System.err.println("Exception " + e.toString() + " in getResource " + fileName); } Modified: trunk/Jmol/src/org/jmol/modelset/BondCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/BondCollection.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/modelset/BondCollection.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -792,7 +792,7 @@ bsAtoms.set(bond.getAtomIndex1()); bsAtoms.set(bond.getAtomIndex2()); } catch (Exception e) { - Logger.error("Exception in seBondOrder: " + e.getMessage()); + Logger.error("Exception in seBondOrder: " + e.toString()); } return bsAtoms; } Modified: trunk/Jmol/src/org/jmol/multitouch/sparshui/JmolSparshClientAdapter.java =================================================================== --- trunk/Jmol/src/org/jmol/multitouch/sparshui/JmolSparshClientAdapter.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/multitouch/sparshui/JmolSparshClientAdapter.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -134,7 +134,7 @@ //input.close(); Logger.info("JmolSparshClientAdapter successful starting driver process"); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); } } */ @@ -144,9 +144,9 @@ Logger.info("SparshUI connection established at 127.0.0.1 port " + port); return true; } catch (UnknownHostException e) { - err = e.getMessage(); + err = e.toString(); } catch (IOException e) { - err = e.getMessage(); + err = e.toString(); } actionManager = null; Logger.error("Cannot create SparshUI connection at 127.0.0.1 port " + port Modified: trunk/Jmol/src/org/jmol/popup/GenericPopup.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/GenericPopup.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/popup/GenericPopup.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -64,8 +64,8 @@ protected String strMenuStructure; protected int updateMode; - private String menuName; - private Object frankPopup; // JPopupMenu + protected String menuName; + private Object frankPopup; private Object popupMenu; private int nFrankList = 0; private int itemMax = 25; @@ -271,9 +271,9 @@ } protected void initialize(Viewer viewer, PopupResource bundle, String title) { + this.viewer = viewer; + menuName = title; popupMenu = menuCreatePopup(title); - menuName = title; - this.viewer = viewer; menuSetListeners(); htMenus.put(title, popupMenu); allowSignedFeatures = (!viewer.isApplet() || viewer @@ -425,7 +425,7 @@ } else if (item.indexOf("Menu") >= 0) { if (item.indexOf("more") < 0) buttonGroup = null; - Object subMenu = menuNewEntry(label, id + "." + item); + Object subMenu = menuNewSubMenu(label, id + "." + item); menuAddSubMenu(menu, subMenu); htMenus.put(item, subMenu); if (item.indexOf("Computed") < 0) @@ -712,7 +712,7 @@ if (pt == nmod + 1) nmod = itemMax; String id = "mo" + pt + "Menu"; - subMenu = menuNewEntry(Math.max(i + 2 - nmod, 1) + "..." + (i + 1), + subMenu = menuNewSubMenu(Math.max(i + 2 - nmod, 1) + "..." + (i + 1), menuGetId(menu) + "." + id); menuAddSubMenu(menu, subMenu); htMenus.put(id, subMenu); @@ -841,7 +841,7 @@ for (int i = 0; i < infolist.length; i++) { if (pt >= 0 && (pt++ % nmod) == 0) { String id = "drawsymop" + pt + "Menu"; - subMenu = menuNewEntry((i + 1) + "..." + subMenu = menuNewSubMenu((i + 1) + "..." + Math.min(i + itemMax, infolist.length), menuGetId(menu) + "." + id); menuAddSubMenu(menu, subMenu); @@ -875,7 +875,7 @@ for (int i = 0; i < list.length; i++) { if (pt >= 0 && (pt++ % nmod) == 0) { String id = "symop" + pt + "Menu"; - subMenu = menuNewEntry((i + 1) + "..." + subMenu = menuNewSubMenu((i + 1) + "..." + Math.min(i + itemMax, list.length), menuGetId(menu) + "." + id); menuAddSubMenu(menu, subMenu); htMenus.put(id, subMenu); @@ -909,7 +909,7 @@ for (int i = 0; i < modelCount; i++) { if (pt >= 0 && (pt++ % nmod) == 0) { String id = "model" + pt + "Menu"; - subMenu = menuNewEntry((i + 1) + "..." + subMenu = menuNewSubMenu((i + 1) + "..." + Math.min(i + itemMax, modelCount), menuGetId(menu) + "." + id); menuAddSubMenu(menu, subMenu); htMenus.put(id, subMenu); @@ -1007,7 +1007,7 @@ .getPolymerCountInModel(modelIndex))); Object submenu = htMenus.get("BiomoleculesMenu"); if (submenu == null) { - submenu = menuNewEntry(GT._(getMenuText("biomoleculesMenuText")), + submenu = menuNewSubMenu(GT._(getMenuText("biomoleculesMenuText")), menuGetId(menu) + ".biomolecules"); menuAddSubMenu(menu, submenu); } @@ -1052,13 +1052,13 @@ for (int i = menuGetItemCount(menu); --i >= aboutComputedMenuBaseCount;) menuRemoveItem(menu, i); - Object subMenu = menuNewEntry("About molecule", "modelSetMenu"); + Object subMenu = menuNewSubMenu("About molecule", "modelSetMenu"); // No need to localize this, as it will be overwritten with the model's name menuAddSubMenu(menu, subMenu); htMenus.put("modelSetMenu", subMenu); updateModelSetComputedMenu(); - subMenu = menuNewEntry("Jmol " + JmolConstants.version + subMenu = menuNewSubMenu("Jmol " + JmolConstants.version + (isSigned ? " (signed)" : ""), "aboutJmolMenu"); menuAddSubMenu(menu, subMenu); htMenus.put("aboutJmolMenu", subMenu); @@ -1071,35 +1071,44 @@ "show url \"http://wiki.jmol.org/index.php/Internationalisation\"", null); - subMenu = menuNewEntry(GT._("System"), "systemMenu"); + subMenu = menuNewSubMenu(GT._("System"), "systemMenu"); menuAddSubMenu(menu, subMenu); htMenus.put("systemMenu", subMenu); addMenuItem(subMenu, viewer.getOperatingSystemName()); - int availableProcessors = Runtime.getRuntime().availableProcessors(); - if (availableProcessors > 0) - addMenuItem(subMenu, (availableProcessors == 1) ? GT._("1 processor") - : GT._("{0} processors", availableProcessors)); - else - addMenuItem(subMenu, GT._("unknown processor count")); menuAddSeparator(subMenu); addMenuItem(subMenu, GT._("Java version:")); addMenuItem(subMenu, viewer.getJavaVendor()); addMenuItem(subMenu, viewer.getJavaVersion()); - menuAddSeparator(subMenu); - addMenuItem(subMenu, GT._("Java memory usage:")); - Runtime runtime = Runtime.getRuntime(); - //runtime.gc(); - long mbTotal = convertToMegabytes(runtime.totalMemory()); - long mbFree = convertToMegabytes(runtime.freeMemory()); - long mbMax = convertToMegabytes(maxMemoryForNewerJvm()); - addMenuItem(subMenu, GT._("{0} MB total", - new Object[] { new Long(mbTotal) })); - addMenuItem(subMenu, GT._("{0} MB free", new Object[] { new Long(mbFree) })); - if (mbMax > 0) - addMenuItem(subMenu, GT._("{0} MB maximum", - new Object[] { new Long(mbMax) })); - else - addMenuItem(subMenu, GT._("unknown maximum")); + Runtime runtime = null; + /** + * @j2sNative + * + */ + { + runtime = Runtime.getRuntime(); + } + if (runtime != null) { + int availableProcessors = runtime.availableProcessors(); + if (availableProcessors > 0) + addMenuItem(subMenu, (availableProcessors == 1) ? GT._("1 processor") + : GT._("{0} processors", availableProcessors)); + else + addMenuItem(subMenu, GT._("unknown processor count")); + addMenuItem(subMenu, GT._("Java memory usage:")); + //runtime.gc(); + long mbTotal = convertToMegabytes(runtime.totalMemory()); + long mbFree = convertToMegabytes(runtime.freeMemory()); + long mbMax = convertToMegabytes(runtime.maxMemory()); + addMenuItem(subMenu, GT._("{0} MB total", + new Object[] { new Long(mbTotal) })); + addMenuItem(subMenu, GT._("{0} MB free", + new Object[] { new Long(mbFree) })); + if (mbMax > 0) + addMenuItem(subMenu, GT._("{0} MB maximum", new Object[] { new Long( + mbMax) })); + else + addMenuItem(subMenu, GT._("unknown maximum")); + } } private void updateLanguageSubmenu() { @@ -1171,10 +1180,6 @@ } } - private long maxMemoryForNewerJvm() { - return Runtime.getRuntime().maxMemory(); - } - private void show(int x, int y, boolean doPopup) { thisx = x; thisy = y; Modified: trunk/Jmol/src/org/jmol/popup/JmolAbstractMenu.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/JmolAbstractMenu.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/popup/JmolAbstractMenu.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -24,7 +24,7 @@ int menuGetPosition(Object menu); void menuInsertSubMenu(Object menu, Object subMenu, int index); - Object menuNewEntry(String entry, String id); + Object menuNewSubMenu(String entry, String id); void menuRemoveAll(Object menu); void menuRemoveItem(Object menu, int index); void menuSetAutoscrolls(Object menu); Modified: trunk/Jmol/src/org/jmol/popup/PopupResource.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/PopupResource.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/popup/PopupResource.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -32,12 +32,16 @@ public abstract class PopupResource { // Properties to store menu structure and contents - protected Properties structure = new Properties(); - protected Properties words = new Properties(); + protected Properties structure, words; abstract public String getMenuName(); protected PopupResource(String menuStructure, Properties menuText) { + // when these were defined above, then they were overwritten by + // setFields operating a second time, probably because MainPopupResourceBundle does not + // have any fields of its own. + structure = new Properties(); + words = new Properties(); buildStructure(menuStructure); localize(menuStructure != null, menuText); } Modified: trunk/Jmol/src/org/jmol/popup/SwingPopup.java =================================================================== --- trunk/Jmol/src/org/jmol/popup/SwingPopup.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/popup/SwingPopup.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -217,8 +217,8 @@ return newMenuItem(jmi, menu, entry, script, id); } - public Object menuCreatePopup(String name) { - return new JPopupMenu(name); + public Object menuCreatePopup(String title) { + return new JPopupMenu(title); } public void menuEnable(Object menu, boolean enable) { @@ -301,7 +301,7 @@ ((JMenu) menu).insert((JMenu) subMenu, index); } - public Object menuNewEntry(String entry, String id) { + public Object menuNewSubMenu(String entry, String id) { JMenu jm = new JMenu(entry); updateButton(jm, entry, null); jm.setName(id); Modified: trunk/Jmol/src/org/jmol/quantum/MepCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/MepCalculation.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/quantum/MepCalculation.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -238,7 +238,7 @@ } br.close(); } catch (Exception e) { - Logger.error("Exception " + e.getMessage() + " in getResource " + Logger.error("Exception " + e.toString() + " in getResource " + resourceName); try { br.close(); Modified: trunk/Jmol/src/org/jmol/renderspecial/DotsRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/renderspecial/DotsRenderer.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/renderspecial/DotsRenderer.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -95,7 +95,7 @@ atom.getColix()), map, nPoints); } catch (Exception e) { System.out.println("Dots rendering error"); - System.out.println(e.getMessage()); + System.out.println(e.toString()); // ignore -- some sort of fluke } } Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -7310,7 +7310,7 @@ return lowestStdDev; } catch (Exception e) { //System.out.println(e.getMessage()); - evalError(e.getMessage(), null); + evalError(e.toString(), null); return 0; // unattainable } } @@ -8359,10 +8359,10 @@ runScript(sb.toString()); } catch (Exception e) { viewer.setSelectionSubset(bsSubset); - errorStr(-1, "Error: " + e.getMessage()); + errorStr(-1, "Error: " + e.toString()); } catch (Error er) { viewer.setSelectionSubset(bsSubset); - errorStr(-1, "Error: " + er.getMessage()); + errorStr(-1, "Error: " + er.toString()); } viewer.setSelectionSubset(bsSubset); } @@ -9288,7 +9288,7 @@ showString(viewer.getFilePath(localName, false) + " created"); os.close(); } catch (IOException e) { - Logger.error("error closing file " + e.getMessage()); + Logger.error("error closing file " + e.toString()); } if (tokType > 0) { // we are just loading an atom property Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -1442,7 +1442,7 @@ pattern = Pattern.compile(sFind, isCaseInsensitive ? Pattern.CASE_INSENSITIVE : 0); } catch (Exception e) { - eval.evalError(e.getMessage(), null); + eval.evalError(e.toString(), null); } String[] list = ScriptVariable.listValue(x1); if (Logger.debugging) @@ -2676,7 +2676,7 @@ viewer.getModelSet().atoms, viewer.getAtomCount(), bsSelected, tok != Token.smiles && tok != Token.substructure, false); } catch (Exception e) { - eval.evalError(e.getMessage(), null); + eval.evalError(e.toString(), null); } return addXBs(bs); } Modified: trunk/Jmol/src/org/jmol/smiles/InvalidSmilesException.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/InvalidSmilesException.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/smiles/InvalidSmilesException.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -66,7 +66,7 @@ */ public InvalidSmilesException(Throwable cause) { super(cause); - lastError = cause.getMessage(); + lastError = cause.toString(); } /** Modified: trunk/Jmol/src/org/jmol/smiles/SmilesGenerator.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesGenerator.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/smiles/SmilesGenerator.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -179,7 +179,7 @@ i = i2 - 1; } } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); return ""; } if (!allowUnmatchedRings && !htRingsSequence.isEmpty()) { Modified: trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java =================================================================== --- trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/smiles/SmilesMatcher.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -123,7 +123,7 @@ return search.getMolecularFormula(!isSmarts); } catch (InvalidSmilesException e) { if (InvalidSmilesException.getLastError() == null) - InvalidSmilesException.setLastError(e.getMessage()); + InvalidSmilesException.setLastError(e.toString()); return null; } } @@ -138,7 +138,7 @@ return (new SmilesGenerator()).getSmiles(atoms, atomCount, bsSelected); } catch (InvalidSmilesException e) { if (InvalidSmilesException.getLastError() == null) - InvalidSmilesException.setLastError(e.getMessage()); + InvalidSmilesException.setLastError(e.toString()); return null; } } @@ -182,8 +182,8 @@ return find(pattern, search, isSmarts, !isSmarts, firstMatchOnly); } catch (Exception e) { if (InvalidSmilesException.getLastError() == null) - InvalidSmilesException.setLastError(e.getMessage()); - System.out.println(e.getMessage()); + InvalidSmilesException.setLastError(e.toString()); + System.out.println(e.toString()); return null; } } @@ -295,8 +295,8 @@ //System.out.println(smarts[i] + " "+ ret[i]); } catch (Exception e) { if (InvalidSmilesException.getLastError() == null) - InvalidSmilesException.setLastError(e.getMessage()); - System.out.println(e.getMessage()); + InvalidSmilesException.setLastError(e.toString()); + System.out.println(e.toString()); // ret[i] will be null in that case } } @@ -393,8 +393,8 @@ } } catch (Exception e) { if (InvalidSmilesException.getLastError() == null) - InvalidSmilesException.setLastError(e.getMessage()); - System.out.println(e.getMessage()); + InvalidSmilesException.setLastError(e.toString()); + System.out.println(e.toString()); } return null; } Modified: trunk/Jmol/src/org/jmol/thread/MinimizationThread.java =================================================================== --- trunk/Jmol/src/org/jmol/thread/MinimizationThread.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/thread/MinimizationThread.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -77,7 +77,7 @@ @Override protected void oops(Exception e) { if (this.minimizer.minimizationOn()) - Logger.error(e.getMessage()); + Logger.error(e.toString()); } Modified: trunk/Jmol/src/org/jmol/util/DefaultLogger.java =================================================================== --- trunk/Jmol/src/org/jmol/util/DefaultLogger.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/util/DefaultLogger.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -49,7 +49,7 @@ out.println( (Logger.logLevel() ? "[" + Logger.getLevel(level) + "] " : "") + txt + - (e != null ? ": " + e.getMessage() : "")); + (e != null ? ": " + e.toString() : "")); if (e != null) { StackTraceElement[] elements = e.getStackTrace(); if (elements != null) { Modified: trunk/Jmol/src/org/jmol/viewer/FileManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/FileManager.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/viewer/FileManager.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -652,7 +652,7 @@ } return (asInputStream ? bis : JmolBinary.getInputStreamReader(bis)); } catch (Exception ioe) { - return ioe.getMessage(); + return ioe.toString(); } } @@ -762,7 +762,7 @@ fileData.put(name0, sb.toString()); } } catch (Exception ioe) { - fileData.put(name0, ioe.getMessage()); + fileData.put(name0, ioe.toString()); } if (bis != null) try { @@ -813,7 +813,7 @@ bis.close(); return bytes; } catch (Exception ioe) { - return ioe.getMessage(); + return ioe.toString(); } } @@ -867,7 +867,7 @@ data[1] = sb.toString(); return true; } catch (Exception ioe) { - data[1] = ioe.getMessage(); + data[1] = ioe.toString(); return false; } } @@ -921,8 +921,8 @@ at sun.awt.image.ImageFetcher.run(Unknown Source) */ } catch (Exception e) { - System.out.println(e.getMessage()); - retFileNameOrError[0] = e.getMessage() + " opening " + fullPathName; + System.out.println(e.toString()); + retFileNameOrError[0] = e.toString() + " opening " + fullPathName; return null; } if (apiPlatform.getImageWidth(image) < 1) { @@ -982,7 +982,7 @@ // name = "file:" + name; url = new URL(appletDocumentBaseURL, name, null); } catch (MalformedURLException e) { - return new String[] { isFullLoad ? e.getMessage() : null }; + return new String[] { isFullLoad ? e.toString() : null }; } } else { // This code is for the app -- no local file reading for headless @@ -993,7 +993,7 @@ try { url = new URL((URL) null, name, null); } catch (MalformedURLException e) { - return new String[] { isFullLoad ? e.getMessage() : null }; + return new String[] { isFullLoad ? e.toString() : null }; } } else { file = viewer.apiPlatform.newFile(name); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-12-22 16:45:50 UTC (rev 17826) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-12-23 01:22:41 UTC (rev 17827) @@ -3546,7 +3546,7 @@ null, null)); } catch (Throwable e) { // ignore if this uses too much memory - Logger.error("state could not be saved: " + e.getMessage()); + Logger.error("state could not be saved: " + e.toString()); s = "Jmol " + getJmolVersion(); } return s; @@ -5079,7 +5079,7 @@ bsB = (asScript ? modelSet.addHydrogens(vConnections, pts) : addHydrogensInline(bsAtoms, vConnections, pts)); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.toString()); // ignore } if (wasAppendNew) @@ -9385,7 +9385,7 @@ /* * void debugStack(String msg) { //what's the right way to do this? try { * Logger.error(msg); String t = null; t.substring(3); } catch (Exception e) { - * System.out.println(e.getMessage()); } } + * System.out.println(e.toString()); } } */ @Override @@ -9953,7 +9953,7 @@ getMinimizer(true).minimize(steps, crit, bsSelected, bsMotionFixed, haveFixed, isSilent, ff); } catch (Exception e) { - Logger.error("Minimization error: " + e.getMessage()); + Logger.error("Minimization error: " + e.toString()); } } @@ -10777,7 +10777,7 @@ showString(msg, false); nFiles += 2; } catch (Exception e) { - return "script error " + e.getMessage(); + return "script error " + e.toString(); } } try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |