From: <ha...@us...> - 2008-08-12 23:17:10
|
Revision: 9716 http://jmol.svn.sourceforge.net/jmol/?rev=9716&view=rev Author: hansonr Date: 2008-08-12 23:17:06 +0000 (Tue, 12 Aug 2008) Log Message: ----------- version=11.6.RC6_dev # bug fix: language localization in webexport Modified Paths: -------------- trunk/Jmol/build.xml trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/openscience/jmol/app/HelpDialog.java trunk/Jmol/src/org/openscience/jmol/app/Jmol.java trunk/Jmol/src/org/openscience/jmol/app/webexport/JmolInstance.java trunk/Jmol/src/org/openscience/jmol/app/webexport/PopInJmol.java trunk/Jmol/src/org/openscience/jmol/app/webexport/ScriptButtons.java trunk/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java Property Changed: ---------------- trunk/Jmol/ Property changes on: trunk/Jmol ___________________________________________________________________ Modified: svn:ignore - applet-classes classes build bin dist javadoc Jmol*.zip packaging/rpm/dist *.bak *.deprecated *~ *.jar t.spt data + applet-classes classes build bin dist javadoc Jmol*.zip packaging/rpm/dist *.bak *.deprecated *~ *.jar t.spt data bobtest vrml scripts Modified: trunk/Jmol/build.xml =================================================================== --- trunk/Jmol/build.xml 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/build.xml 2008-08-12 23:17:06 UTC (rev 9716) @@ -13,7 +13,7 @@ <!-- for some reason, I can't get ant to use this ${java.version} property as the value of the source parameter --> <property name="java.version" value="1.4" /> - <property name="debug" value="off" /> + <property name="debug" value="on" /> <property name="deprecation" value="off" /> <property name="optimization" value="off" /> Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2008-08-12 23:17:06 UTC (rev 9716) @@ -3,6 +3,7 @@ version=11.6.RC6_dev +# bug fix: language localization in webexport # ----------------------------------------------------------------------------- #version=11.6.RC5 Modified: trunk/Jmol/src/org/openscience/jmol/app/HelpDialog.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/HelpDialog.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/HelpDialog.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -64,20 +64,16 @@ super(fr, GT._("Jmol Help"), false); try { - URL helpURL = url; - if (url == null) { - helpURL = this.getClass().getClassLoader() + URL helpURL = (url != null ? url : this.getClass().getClassLoader() .getResource(JmolResourceHandler - .getStringX("Help.helpURL")); - } - if (helpURL != null) { + .getStringX("Help.helpURL"))); + if (helpURL != null) html = new JEditorPane(helpURL); - } else { + else html = new JEditorPane("text/plain", GT._("Unable to find url \"{0}\".", JmolResourceHandler.getStringX("Help.helpURL") )); - } html.setEditable(false); html.addHyperlinkListener(this); } catch (MalformedURLException e) { Modified: trunk/Jmol/src/org/openscience/jmol/app/Jmol.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/Jmol.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/Jmol.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -1356,8 +1356,7 @@ } public void actionPerformed(ActionEvent e) { - HelpDialog hd = new HelpDialog(frame); - hd.show(); + (new HelpDialog(frame)).show(); } } Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/JmolInstance.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/JmolInstance.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/JmolInstance.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -119,17 +119,10 @@ return true; } boolean delete() throws IOException { - File scratchtoerase = new File(this.pictFile); - boolean scratchexists = scratchtoerase.exists(); - if (scratchexists){ - boolean deleteOK = scratchtoerase.delete(); - if (!(deleteOK)) { - IOException IOe = (new IOException(GT._("Failed to delete scratch file ") - + this.pictFile + ".")); - throw IOe; - } - //delete any other scratch files we create with an instance. - } + File scratchToErase = new File(pictFile); + if (scratchToErase.exists() && !scratchToErase.delete()) + throw new IOException(GT._("Failed to delete scratch file {0}.", pictFile)); + //delete any other scratch files we create with an instance. return true; } } Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/PopInJmol.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/PopInJmol.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/PopInJmol.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -35,12 +35,9 @@ PopInJmol(JmolViewer viewer, JFileChooser fc, WebPanel[] webPanels, int panelIndex) { super(viewer, fc, webPanels, panelIndex); - //description = "Create a web page with images that convert to live Jmol applets when a user clicks a link"; + panelName = "pop_in"; listLabel = GT._("These names will be used as filenames for the applets"); - infoFile = GT._("pop_in_instructions.html"); - templateName = "pop_in_template.html"; - appletTemplateName = "pop_in_template2.html"; - templateImage = "pop_in.png"; + //description = "Create a web page with images that convert to live Jmol applets when a user clicks a link"; } JPanel appletParamPanel() { Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/ScriptButtons.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/ScriptButtons.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/ScriptButtons.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -35,12 +35,9 @@ ScriptButtons(JmolViewer viewer, JFileChooser fc, WebPanel[] webPanels, int panelIndex) { super(viewer, fc, webPanels, panelIndex); - //description = "Create a web page containing a text and button pane that scrolls next to a resizable Jmol applet"; + panelName = "script_button"; listLabel = GT._("These names will be used for button labels"); - infoFile = GT._("script_button_instructions.html"); - templateName = "script_button_template.html"; - appletTemplateName = "script_button_template2.html"; - templateImage = "script_button.png"; + //description = "Create a web page containing a text and button pane that scrolls next to a resizable Jmol applet"; } JPanel appletParamPanel() { Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -70,16 +70,15 @@ private static JFrame webFrame; private static String windowName; - private WebExport(JmolViewer viewer, HistoryFile hFile) { super(new BorderLayout()); historyFile = hFile; remoteAppletPath = historyFile.getProperty("webMakerAppletPath", ".."); localAppletPath = historyFile.getProperty("webMakerLocalAppletPath", ".."); - pageAuthorName = historyFile.getProperty("webMakerPageAuthorName", "Jmol Web Export"); + pageAuthorName = historyFile.getProperty("webMakerPageAuthorName", + "Jmol Web Export"); - //Define the tabbed pane JTabbedPane mainTabs = new JTabbedPane(); @@ -92,7 +91,7 @@ //Add tabs to the tabbed pane JPanel introPanel = new JPanel(); - URL url = getResource(this, GT._("WebExportIntro.html")); + URL url = getHtmlResource(this, "WebExportIntro"); if (url == null) { System.err.println(GT._("Couldn't find file: WebExportIntro.html")); } @@ -106,14 +105,14 @@ } intro.setEditable(false); JScrollPane introPane = new JScrollPane(intro); - introPane.setMaximumSize(new Dimension(450,350)); - introPane.setPreferredSize(new Dimension(400,300)); + introPane.setMaximumSize(new Dimension(450, 350)); + introPane.setPreferredSize(new Dimension(400, 300)); introPanel.setLayout(new BorderLayout()); introPanel.add(introPane); - introPanel.setMaximumSize(new Dimension(450,350)); - introPanel.setPreferredSize(new Dimension(400,300)); + introPanel.setMaximumSize(new Dimension(450, 350)); + introPanel.setPreferredSize(new Dimension(400, 300)); - mainTabs.add(GT._("Introduction"),introPanel); + mainTabs.add(GT._("Introduction"), introPanel); webPanels[0] = new PopInJmol(viewer, fc, webPanels, 0); webPanels[1] = new ScriptButtons(viewer, fc, webPanels, 1); @@ -145,15 +144,13 @@ //Add the tabbed pane to this panel add(mainTabs); - + //Create the small log add(LogPanel.getMiniPanel(), BorderLayout.SOUTH); - //Uncomment the following line to use scrolling tabs. //tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - } @@ -173,9 +170,9 @@ * this method should be invoked from the * event-dispatching thread. */ - + public static WebExport createAndShowGUI(JmolViewer viewer, - HistoryFile historyFile, String wName) { + HistoryFile historyFile, String wName) { if (viewer == null) runStatus = STAND_ALONE; @@ -204,7 +201,6 @@ webFrame.setContentPane(webExport); webFrame.addWindowListener(webExport); - //Display the window. webFrame.pack(); webFrame.setVisible(true); @@ -219,12 +215,12 @@ public static void saveHistory() { historyFile.addWindowInfo(windowName, webFrame, null); -// prop.setProperty("webMakerInfoWidth", "" + webPanels[0].getInfoWidth()); -// prop.setProperty("webMakerInfoHeight", "" + webPanels[0].getInfoHeight()); + // prop.setProperty("webMakerInfoWidth", "" + webPanels[0].getInfoWidth()); + // prop.setProperty("webMakerInfoHeight", "" + webPanels[0].getInfoHeight()); prop.setProperty("webMakerAppletPath", remoteAppletPath); prop.setProperty("webMakerLocalAppletPath", localAppletPath); prop.setProperty("webMakerPageAuthorName", pageAuthorName); - historyFile.addProperties(prop); + historyFile.addProperties(prop); } static String remoteAppletPath, localAppletPath; @@ -245,16 +241,16 @@ } else { localAppletPath = path; prop.setProperty("webMakerLocalAppletPath", localAppletPath); - historyFile.addProperties(prop); + historyFile.addProperties(prop); } } - + static String pageAuthorName; - + static String getPageAuthorName() { return pageAuthorName; } - + static void setWebPageAuthor(String pageAuthor) { if (pageAuthor == null) pageAuthor = "Jmol Web Export"; @@ -262,15 +258,34 @@ prop.setProperty("webMakerPageAuthorName", pageAuthorName); historyFile.addProperties(prop); } - - static JFrame getFrame(){ + + static JFrame getFrame() { return webFrame; } - - static URL getResource(Object object, String fileName) { + + static URL getResource(Object object, String fileName) { + return getResource(object, fileName, true); + } + + static URL getHtmlResource(Object object, String root) { + String lang = GT.getLanguage(); + String fileName = root + "_" + lang + ".html"; + URL url = getResource(object, fileName, false); + if (url == null) { + fileName = root + "_" + lang.substring(0, 2) + ".html"; + url = getResource(object, fileName, false); + if (url == null) { + fileName = root + ".html"; + url = getResource(object, fileName, true); + } + } + return url; + } + + static URL getResource(Object object, String fileName, boolean flagError) { URL url = null; try { - if ((url = object.getClass().getResource("html/" + fileName)) == null) + if ((url = object.getClass().getResource("html/" + fileName)) == null && flagError) System.err.println("Couldn't find file: " + fileName); } catch (Exception e) { System.err.println("Exception " + e.getMessage() + " in getResource " @@ -279,7 +294,8 @@ return url; } - static String getResourceString(Object object, String name) throws IOException { + static String getResourceString(Object object, String name) + throws IOException { URL url = WebExport.getResource(object, name); if (url == null) { throw new FileNotFoundException("Error loading resource " + name); @@ -304,40 +320,40 @@ // + str.length() + " bytes)"); return str; } - + /* Window event code for cleanup*/ public void windowClosing(WindowEvent e) { -} + } -public void windowClosed(WindowEvent e) { + public void windowClosed(WindowEvent e) { //cleanUp(); Should do this, but then states during a session loose their .png files if window is closed. -} + } -public void windowOpened(WindowEvent e) { - } + public void windowOpened(WindowEvent e) { + } -public void windowIconified(WindowEvent e) { -} + public void windowIconified(WindowEvent e) { + } -public void windowDeiconified(WindowEvent e) { -} + public void windowDeiconified(WindowEvent e) { + } -public void windowActivated(WindowEvent e) { -} + public void windowActivated(WindowEvent e) { + } -public void windowDeactivated(WindowEvent e) { -} + public void windowDeactivated(WindowEvent e) { + } -public void windowGainedFocus(WindowEvent e) { -} + public void windowGainedFocus(WindowEvent e) { + } -public void windowLostFocus(WindowEvent e) { -} + public void windowLostFocus(WindowEvent e) { + } -public void windowStateChanged(WindowEvent e) { -} + public void windowStateChanged(WindowEvent e) { + } -public static void cleanUp(){ + public static void cleanUp() { //gets rid of scratch files. FileSystemView Directories = FileSystemView.getFileSystemView(); File homedir = Directories.getHomeDirectory(); @@ -347,11 +363,11 @@ if (scratchdir.exists()) { File[] dirListing = null; dirListing = scratchdir.listFiles(); - for (int i = 0; i < (dirListing.length);i++){ + for (int i = 0; i < (dirListing.length); i++) { dirListing[i].delete(); - } } + } saveHistory();//force save of history. System.gc();//force garbage collection. - } + } } Modified: trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java =================================================================== --- trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2008-08-12 22:45:24 UTC (rev 9715) +++ trunk/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2008-08-12 23:17:06 UTC (rev 9716) @@ -59,13 +59,21 @@ abstract JPanel appletParamPanel(); //should be defined in the code for the specific case e.g. ScriptButtons.java - protected String templateName; + protected String panelName; //pop_in or script_button + +// infoFile = "pop_in_instructions"; +// infoFileLocalized = "pop_in_instructions_" + lang + ".html"; +// templateName = "pop_in_template.html"; +// appletTemplateName = "pop_in_template2.html"; + + //protected String templateName; + //protected String infoFile; + //protected String appletTemplateName; + //protected String templateImage; + + protected String htmlAppletTemplate; protected String listLabel; - protected String infoFile; protected String appletInfoDivs; - protected String htmlAppletTemplate; - protected String appletTemplateName; - protected String templateImage; protected boolean useAppletJS; protected JSpinner appletSizeSpinnerW; @@ -188,52 +196,54 @@ helpButton = new JButton(GT._("Help/Instructions")); helpButton.addActionListener(this); - + + String templateImage = panelName + ".png"; URL pageCartoon = WebExport.getResource(this, templateImage); ImageIcon pageImage = null; - if (pageCartoon != null){ + if (pageCartoon != null) { pageImage = new ImageIcon(pageCartoon, GT._("Cartoon of Page")); } else { - System.err.println("Error Loading Page Cartoon Image "+templateImage); + System.err.println("Error Loading Page Cartoon Image " + templateImage); } JLabel pageCartoonLabel = new JLabel(pageImage); - JPanel pageCartoonPanel = new JPanel(); + JPanel pageCartoonPanel = new JPanel(); pageCartoonPanel.setLayout(new BorderLayout()); - pageCartoonPanel.setBorder(BorderFactory.createTitledBorder(GT._("Cartoon of Page:"))); + pageCartoonPanel.setBorder(BorderFactory.createTitledBorder(GT + ._("Cartoon of Page:"))); pageCartoonPanel.add(pageCartoonLabel); - // editorScrollPane = getInstructionPane(w, h); + // editorScrollPane = getInstructionPane(w, h); //Create the save button. saveButton = new JButton(GT._("Save HTML as...")); saveButton.addActionListener(this); JPanel savePanel = new JPanel(); savePanel.add(saveButton); - + //Path to applet panel JPanel pathPanel = new JPanel(); pathPanel.setLayout(new BorderLayout()); - pathPanel.setBorder(BorderFactory - .createTitledBorder(GT._("Relative server path to jar files:"))); + pathPanel.setBorder(BorderFactory.createTitledBorder(GT + ._("Relative server path to jar files:"))); pathPanel.add(remoteAppletPath, BorderLayout.NORTH); - + JPanel pathPanel2 = new JPanel(); pathPanel2.setLayout(new BorderLayout()); - pathPanel2.setBorder(BorderFactory - .createTitledBorder(GT._("Relative local path to jar files:"))); + pathPanel2.setBorder(BorderFactory.createTitledBorder(GT + ._("Relative local path to jar files:"))); pathPanel2.add(localAppletPath, BorderLayout.NORTH); - + //Page Author Panel JPanel authorPanel = new JPanel(); - authorPanel.setBorder(BorderFactory - .createTitledBorder(GT._("Author (your name):"))); + authorPanel.setBorder(BorderFactory.createTitledBorder(GT + ._("Author (your name):"))); authorPanel.add(pageAuthorName, BorderLayout.NORTH); - + //Page Title Panel JPanel titlePanel = new JPanel(); titlePanel.setLayout(new BorderLayout()); - titlePanel.setBorder(BorderFactory - .createTitledBorder(GT._("Browser window title for this web page:"))); + titlePanel.setBorder(BorderFactory.createTitledBorder(GT + ._("Browser window title for this web page:"))); titlePanel.add(webPageTitle, BorderLayout.NORTH); titlePanel.add(savePanel, BorderLayout.SOUTH); @@ -250,7 +260,7 @@ //Combine previous three panels into one JPanel leftpanel = new JPanel(); leftpanel.setLayout(new BorderLayout()); - // leftpanel.add(editorScrollPane, BorderLayout.CENTER); + // leftpanel.add(editorScrollPane, BorderLayout.CENTER); leftpanel.add(helpButton, BorderLayout.NORTH); leftpanel.add(pageCartoonPanel, BorderLayout.CENTER); leftpanel.add(settingsPanel, BorderLayout.SOUTH); @@ -412,7 +422,7 @@ } if (e.getSource() == helpButton){ HelpDialog webExportHelp = new HelpDialog(WebExport.getFrame(), - WebExport.getResource(this, infoFile)); + WebExport.getHtmlResource(this, panelName + "_instructions")); webExportHelp.setVisible(true); webExportHelp.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } @@ -483,12 +493,12 @@ LogPanel.log(" ...adding " + javaname + ".spt"); writeFile(datadirPath + "/" + javaname + ".spt", script); } - String html = getResourceString(templateName); + String html = getResourceString(panelName + "_template"); html = fixHtml(html); appletInfoDivs = ""; StringBuffer appletDefs = new StringBuffer(); if (!useAppletJS) - htmlAppletTemplate = getResourceString(appletTemplateName); + htmlAppletTemplate = getResourceString(panelName + "_template2"); for (int i = 0; i < listModel.getSize(); i++) html = getAppletDefs(i, html, appletDefs, (JmolInstance) listModel .getElementAt(i)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |