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
*/
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
+import java.io.InputStream;
import java.net.URL;
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);
// render: time
frame.progress(resource.getString("Render") + " ...");
driver.render();
-
+
frame.progress(resource.getString("Show"));
} catch (Exception e) {
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) {
}
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
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.*;
/**
* Durch überschreiben der Methode <code>doit<code> kann die Klasse customisiert werden.
* Über die Methode <code>undoit</code> kann Undo-Funktionalität unterstützt werden.<br>
*
- * @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);
}
- 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();