From: arved Date: Tue, 4 Apr 2000 09:49:38 +0000 (+0000) Subject: Fix: various, by the AWT Viewer team X-Git-Tag: pre-columns~540 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3b1fe35125f1e5eecf053140f9ac443853573092;p=xmlgraphics-fop.git Fix: various, by the AWT Viewer team git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193324 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/apps/AWTCommandLine.java b/src/org/apache/fop/apps/AWTCommandLine.java index 372aa4adc..e9da9c501 100644 --- a/src/org/apache/fop/apps/AWTCommandLine.java +++ b/src/org/apache/fop/apps/AWTCommandLine.java @@ -2,9 +2,9 @@ package org.apache.fop.apps; /* originally contributed by - Juergen Verwohlt: Juergen.Verwohlt@af-software.de, - Rainer Steinkuhle: Rainer.Steinkuhle@af-software.de, - Stanislav Gorkhover: Stanislav.Gorkhover@af-software.de + Juergen Verwohlt: Juergen.Verwohlt@jcatalog.com, + Rainer Steinkuhle: Rainer.Steinkuhle@jcatalog.com, + Stanislav Gorkhover: Stanislav.Gorkhover@jcatalog.com */ @@ -30,6 +30,7 @@ import java.io.PrintWriter; import java.io.IOException; import java.io.FileNotFoundException; import java.io.FileInputStream; +import java.io.InputStream; import java.net.URL; import java.util.*; @@ -42,31 +43,23 @@ import java.util.*; public class AWTCommandLine { - public static String DEFAULT_TRANSLATION_PATH - = "../viewer/resources/resources." + - System.getProperty("user.language"); + public static String TRANSLATION_PATH = "/org/apache/fop/viewer/resources/"; private Translator resource; - public AWTCommandLine(String srcFile, String translationPath) { + public AWTCommandLine(String srcFile, String language) { - resource = getResourceBundle(translationPath); + if (language == null) + language = System.getProperty("user.language"); - String messPath = new File(translationPath).getAbsoluteFile().getParent(); - if (!messPath.endsWith(System.getProperty("file.separator"))) - messPath += System.getProperty("file.separator"); - messPath += "messages." + System.getProperty("user.language"); - System.out.println("Set messages resource: " + messPath); - UserMessage.setTranslator(getResourceBundle(messPath)); + resource = getResourceBundle(TRANSLATION_PATH + "resources." + language); - resource.setMissingEmphasized(false); + UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH + "messages." + language)); - if (!resource.isSourceFound()) - UserMessage.show("TRANSLATION_SOURCE_NOT_FOUND", - new File(translationPath).getAbsolutePath()); + resource.setMissingEmphasized(false); AWTRenderer renderer = new AWTRenderer(resource); PreviewDialog frame = createPreviewDialog(renderer, resource); @@ -105,7 +98,7 @@ public class AWTCommandLine { // render: time frame.progress(resource.getString("Render") + " ..."); driver.render(); - + frame.progress(resource.getString("Show")); } catch (Exception e) { @@ -187,17 +180,18 @@ public class AWTCommandLine { private SecureResourceBundle getResourceBundle(String path) { - FileInputStream in = null; + InputStream in = null; + try { - in = new FileInputStream(path); + URL url = getClass().getResource(path); + in = url.openStream(); } catch(Exception ex) { - System.out.println("Abgefangene Exception: " + ex.getMessage()); + System.out.println("Can't find URL to: <" + path + "> " + ex.getMessage()); } return new SecureResourceBundle(in); } - /* main */ public static void main(String[] args) { @@ -208,34 +202,22 @@ public class AWTCommandLine { } String srcPath = null; - String translationFile = null; + String language = null; String imageDir = null; System.err.println(Version.getVersion()); if (args.length < 1 || args.length > 3) { System.err.println("usage: java AWTCommandLine " + - "formatting-object-file [translation-file] " + - "[image-dir]"); + "formatting-object-file [language] "); System.exit(1); } srcPath = args[0]; if (args.length > 1) { - translationFile = args[1]; - } - if (args.length > 2) { - imageDir = args[2]; - if (!imageDir.endsWith(System.getProperty("file.separator"))) - imageDir += System.getProperty("file.separator"); - - Command.IMAGE_DIR = imageDir; + language = args[1]; } - if (translationFile == null) - translationFile = DEFAULT_TRANSLATION_PATH; - - - new AWTCommandLine(srcPath, translationFile); + new AWTCommandLine(srcPath, language); } // main } // AWTCommandLine diff --git a/src/org/apache/fop/viewer/Command.java b/src/org/apache/fop/viewer/Command.java index aa63e7876..ecfa9fbef 100644 --- a/src/org/apache/fop/viewer/Command.java +++ b/src/org/apache/fop/viewer/Command.java @@ -1,15 +1,14 @@ package org.apache.fop.viewer; /* - originally contributed by - Juergen Verwohlt: Juergen.Verwohlt@af-software.de, - Rainer Steinkuhle: Rainer.Steinkuhle@af-software.de, - Stanislav Gorkhover: Stanislav.Gorkhover@af-software.de + Juergen Verwohlt: Juergen.Verwohlt@jcatalog.com, + Rainer Steinkuhle: Rainer.Steinkuhle@jcatalog.com, + Stanislav Gorkhover: Stanislav.Gorkhover@jcatalog.com */ import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.ImageIcon; -import java.io.File; +import java.net.*; /** @@ -19,12 +18,12 @@ import java.io.File; * Durch überschreiben der Methode doit kann die Klasse customisiert werden. * Über die Methode undoit kann Undo-Funktionalität unterstützt werden.
* - * @author Juergen.Verwohlt@af-software.de + * @author Juergen.Verwohlt@jcatalog.com * @version 1.0 18.03.99 */ public class Command extends AbstractAction { - public static String IMAGE_DIR = "../viewer/images/"; + public static String IMAGE_DIR = "/org/apache/fop/viewer/Images/"; public Command(String name) { this(name, (ImageIcon)null); @@ -35,18 +34,17 @@ public class Command extends AbstractAction { } - public Command(String name, ImageIcon anIcon, String path) { - this(name, anIcon); - File f = new File (IMAGE_DIR + path + ".gif"); - if (!f.exists()) { - System.err.println("Icon not found: " + f.getAbsolutePath()); + public Command(String name, String iconName) { + super(name); + String path = IMAGE_DIR + iconName + ".gif"; + URL url = getClass().getResource(path); + if (url == null) { + System.err.println("Icon not found: " + path); } - + else + putValue(SMALL_ICON, new ImageIcon(url)); } - public Command(String name, String iconName) { - this(name, new ImageIcon(IMAGE_DIR + iconName + ".gif"), iconName); - } public void actionPerformed(ActionEvent e) { doit(); diff --git a/src/org/apache/fop/viewer/PreviewDialog.java b/src/org/apache/fop/viewer/PreviewDialog.java index 1757e5773..e46447b27 100644 --- a/src/org/apache/fop/viewer/PreviewDialog.java +++ b/src/org/apache/fop/viewer/PreviewDialog.java @@ -163,7 +163,9 @@ public class PreviewDialog extends JFrame implements ProgressListener { // menu.addSeparator(); menu.add(new Command(res.getString("Print")) {public void doit(){print();}}); menu.addSeparator(); - menu.add(new Command(res.getString("Exit")){ public void doit() {dispose();}} ); + menu.add(new Command(res.getString("Close")){ public void doit() {dispose();}} ); + menu.addSeparator(); + menu.add(new Command(res.getString("Exit")){ public void doit() {System.exit(0);}} ); menuBar.add(menu); menu = new JMenu(res.getString("View")); menu.add(new Command(res.getString("First page")) { public void doit() {goToFirstPage(null);}} ); @@ -192,10 +194,6 @@ public class PreviewDialog extends JFrame implements ProgressListener { return menuBar; } - public void dispose() { - System.exit(0); - } - //Aktion Hilfe | Info durchgeführt public void startHelpAbout(ActionEvent e) { diff --git a/src/org/apache/fop/viewer/resources/resources.de b/src/org/apache/fop/viewer/resources/resources.de index 2a0ffe465..0a513ff8f 100644 --- a/src/org/apache/fop/viewer/resources/resources.de +++ b/src/org/apache/fop/viewer/resources/resources.de @@ -19,3 +19,5 @@ Init mappings=Initializiere Abbildung Build FO tree=Baue FO-Baum Layout FO tree=Formatiere FO-Baum Render=Gebe aus +Close=Schließen + diff --git a/src/org/apache/fop/viewer/resources/resources.ru b/src/org/apache/fop/viewer/resources/resources.ru index 9f58dc012..e443d4621 100644 --- a/src/org/apache/fop/viewer/resources/resources.ru +++ b/src/org/apache/fop/viewer/resources/resources.ru @@ -2,16 +2,17 @@ File= Exit=Çàêîí÷èòü View=Âèä First page=Ïåðâàÿ ñòðàíèöà -Previous page=Ïðåëûëóùàÿ ñòðàíèöà +Previous page=Ïðåäûäóùàÿ ñòðàíèöà Next page=Ñëåäóþùàÿ ñòðàíèöà Last page=Ïîñëåäíÿÿ ñòðàíèöà Help=Ïîìîùü -Default zoom=Ñòàíäàîòíûé ìàñøòàá +Default zoom=Ñòàíäàðòíûé ìàñøòàá Introduction=Ââåäåíèå About=Î ïðîãðàììå Show=Ïîêàç Preview=Ïðîñìîòð Print=Ïå÷àòàòü -Page=Ñòîàíèöà +Page=Ñòðàíèöà of=èç Zoom=Ìàñøòàá +Close=Çàêðûòü