You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ar...@locus.apache.org on 2000/04/04 11:46:57 UTC

cvs commit: xml-fop/src/org/apache/fop/apps AWTCommandLine.java

arved       00/04/04 02:46:57

  Modified:    src/org/apache/fop/apps AWTCommandLine.java
  Log:
  Fix: various, by the AWT Viewer team
  
  Revision  Changes    Path
  1.4       +21 -39    xml-fop/src/org/apache/fop/apps/AWTCommandLine.java
  
  Index: AWTCommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/AWTCommandLine.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AWTCommandLine.java	2000/01/25 13:51:17	1.3
  +++ AWTCommandLine.java	2000/04/04 09:46:57	1.4
  @@ -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.IOException;
   import java.io.FileNotFoundException;
   import java.io.FileInputStream;
  +import java.io.InputStream;
   import java.net.URL;
   import java.util.*;
   
  @@ -42,31 +43,23 @@
   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 @@
   // render: time
           frame.progress(resource.getString("Render") + " ...");
           driver.render();
  -        
  +
           frame.progress(resource.getString("Show"));
   
   	} catch (Exception e) {
  @@ -187,17 +180,18 @@
   
   
     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 @@
       }
   
       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