Пример #1
0
  /**
   * Tries to load a class or a property file with the specified name.
   *
   * @param localizedName the name
   * @param classloader the classloader
   * @return the resource bundle if it was loaded, otherwise the backup
   */
  private static ResourceBundle tryBundle(String localizedName, ClassLoader classloader) {
    ResourceBundle bundle = null;
    try {
      Class<?> rbClass;
      if (classloader == null) rbClass = Class.forName(localizedName);
      else rbClass = classloader.loadClass(localizedName);
      // Note that we do the check up front instead of catching
      // ClassCastException.  The reason for this is that some crazy
      // programs (Eclipse) have classes that do not extend
      // ResourceBundle but that have the same name as a property
      // bundle; in fact Eclipse relies on ResourceBundle not
      // instantiating these classes.
      if (ResourceBundle.class.isAssignableFrom(rbClass))
        bundle = (ResourceBundle) rbClass.newInstance();
    } catch (Exception ex) {
    }

    if (bundle == null) {
      try {
        InputStream is;
        String resourceName = localizedName.replace('.', '/') + ".properties";
        if (classloader == null) is = ClassLoader.getSystemResourceAsStream(resourceName);
        else is = classloader.getResourceAsStream(resourceName);
        if (is != null) bundle = new PropertyResourceBundle(is);
      } catch (IOException ex) {
        MissingResourceException mre =
            new MissingResourceException(
                "Failed to load bundle: " + localizedName, localizedName, "");
        mre.initCause(ex);
        throw mre;
      }
    }

    return bundle;
  }
Пример #2
0
 private String tr(String key) {
   String übersetzt;
   try {
     übersetzt = dialogRB.getString(key);
   } catch (MissingResourceException e) {
     System.err.println(
         "Schluesselwort + "
             + key
             + " nicht gefunden fuer "
             + locale.toString()
             + " ; "
             + e.toString());
     return key;
   }
   return übersetzt;
 }
Пример #3
0
  // ------------------------------------------------------------------------
  TextViewer(JFrame inParentFrame) {
    // super(true); //is double buffered - only for panels

    textViewerFrame = this;
    parentFrame = inParentFrame;
    lastViewedDirStr = "";
    lastViewedFileStr = "";

    setTitle(resources.getString("Title"));
    addWindowListener(new AppCloser());
    pack();
    setSize(500, 600);

    warningPopup = new WarningDialog(this);
    okCancelPopup = new WarningDialogOkCancel(this);
    messagePopup = new MessageDialog(this);
    okCancelMessagePopup = new MessageDialogOkCancel(this);

    // Force SwingSet to come up in the Cross Platform L&F
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      // If you want the System L&F instead, comment out the above line and
      // uncomment the following:
      // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
      String errstr = "TextViewer:Error loading L&F: " + exc;
      warningPopup.display(errstr);
    }

    Container cf = getContentPane();
    cf.setBackground(Color.lightGray);
    // Border etched=BorderFactory.createEtchedBorder();
    // Border title=BorderFactory.createTitledBorder(etched,"TextViewer");
    // cf.setBorder(title);
    cf.setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor1 = createEditor();
    editor1.setFont(new Font("monospaced", Font.PLAIN, 12));
    // aa -added next line
    setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1

    // install the command table
    commands = new Hashtable();
    Action[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      Action a = actions[i];
      commands.put(a.getValue(Action.NAME), a);
      // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME));
    }
    // editor1.setPreferredSize(new Dimension(,));
    // get setting from user preferences
    if (UserPref.keymapType.equals("Word")) {
      editor1 = updateKeymapForWord(editor1);
    } else {
      editor1 = updateKeymapForEmacs(editor1);
    }

    scroller1 = new JScrollPane();
    viewport1 = scroller1.getViewport();
    viewport1.add(editor1);
    scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    try {
      String vpFlag = resources.getString("ViewportBackingStore");
      Boolean bs = new Boolean(vpFlag);
      viewport1.setBackingStoreEnabled(bs.booleanValue());
    } catch (MissingResourceException mre) {
      System.err.println("TextViewer:missing resource:" + mre.getMessage());
      // just use the viewport1 default
    }

    menuItems = new Hashtable();

    menubar = createMenubar();

    lowerPanel = new JPanel(true); // moved double buffering to here
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add("North", createToolbar());
    lowerPanel.add("Center", scroller1);

    cf.add("North", menubar);
    cf.add("Center", lowerPanel);
    cf.add("South", createStatusbar());

    // for the find/search utilities
    mySearchDialog = new SearchDialog(this);

    // System.out.println("Debug:TextViewer: end of TextViewer constructor");

  }