コード例 #1
0
  /**
   * set new frame for this view We start listening for frame action/status and click events
   * instandly. If an event occurs, we use it to synchronize our controls with states of a (maybe)
   * new document view of this frame.
   *
   * @param xFrame the reference to the frame, which provides the possibility to get the required
   *     status information
   *     <p>Attention: We don't accept new frames here. We get one after startup and work with it.
   *     That's it!
   */
  public void setFrame(com.sun.star.frame.XFrame xFrame) {
    if (xFrame == null) return;

    // be listener for click events
    // They will toogle the UI controls.
    ClickListener aMenuBarHandler =
        new ClickListener(FEATUREURL_MENUBAR, FEATUREPROP_MENUBAR, xFrame);
    ClickListener aToolBarHandler =
        new ClickListener(FEATUREURL_TOOLBAR, FEATUREPROP_TOOLBAR, xFrame);
    ClickListener aObjectBarHandler =
        new ClickListener(FEATUREURL_OBJECTBAR, FEATUREPROP_OBJECTBAR, xFrame);

    m_cbMenuBar.addActionListener(aMenuBarHandler);
    m_cbToolBar.addActionListener(aToolBarHandler);
    m_cbObjectBar.addActionListener(aObjectBarHandler);

    // be frame action listener
    // The callback will update listener connections
    // for status updates automaticly!
    m_aMenuBarListener =
        new StatusListener(m_cbMenuBar, MENUBAR_ON, MENUBAR_OFF, xFrame, FEATUREURL_MENUBAR);
    m_aToolBarListener =
        new StatusListener(m_cbToolBar, TOOLBAR_ON, TOOLBAR_OFF, xFrame, FEATUREURL_TOOLBAR);
    m_aObjectBarListener =
        new StatusListener(
            m_cbObjectBar, OBJECTBAR_ON, OBJECTBAR_OFF, xFrame, FEATUREURL_OBJECTBAR);

    m_aMenuBarListener.startListening();
    m_aToolBarListener.startListening();
    m_aObjectBarListener.startListening();
  }
コード例 #2
0
  /**
   * If this java application shutdown - we must cancel all current existing listener connections.
   * Otherwhise the office will run into some DisposedExceptions if it tries to use these forgotten
   * listener references. And of course it can die doing that. We are registered at a central object
   * to be informed if the VM will exit. So we can react.
   */
  public void shutdown() {
    m_aMenuBarListener.shutdown();
    m_aToolBarListener.shutdown();
    m_aObjectBarListener.shutdown();

    m_aMenuBarListener = null;
    m_aToolBarListener = null;
    m_aObjectBarListener = null;
  }
コード例 #3
0
ファイル: FontData.java プロジェクト: cjboyden/ejSleek
  /**
   * Process a directory potentially full of fonts
   *
   * @param dir The directory of fonts to process
   * @param fonts The fonts list to add to
   */
  private static void processFontDirectory(File dir, ArrayList fonts) {
    if (!dir.exists()) {
      return;
    }
    if (processed.contains(dir)) {
      return;
    }
    processed.add(dir);

    File[] sources = dir.listFiles();
    if (sources == null) {
      return;
    }

    for (int j = 0; j < sources.length; j++) {
      File source = sources[j];

      if (source.getName().equals(".")) {
        continue;
      }
      if (source.getName().equals("..")) {
        continue;
      }
      if (source.isDirectory()) {
        processFontDirectory(source, fonts);
        continue;
      }
      if (source.getName().toLowerCase().endsWith(".ttf")) {
        try {
          if (statusListener != null) {
            statusListener.updateStatus("Processing " + source.getName());
          }
          FontData data = new FontData(new FileInputStream(source), 1);
          fonts.add(data);

          String famName = data.getFamilyName();
          if (!families.contains(famName)) {
            families.add(famName);
          }

          boolean bo = data.getJavaFont().isBold();
          boolean it = data.getJavaFont().isItalic();

          if ((bo) && (it)) {
            bolditalic.put(famName, data);
          } else if (bo) {
            bold.put(famName, data);
          } else if (it) {
            italic.put(famName, data);
          } else {
            plain.put(famName, data);
          }
        } catch (Exception e) {
          if (DEBUG) {
            System.err.println(
                "Unable to process: "
                    + source.getAbsolutePath()
                    + " ("
                    + e.getClass()
                    + ": "
                    + e.getMessage()
                    + ")");
          }
          if (statusListener != null) {
            statusListener.updateStatus("Unable to process: " + source.getName());
          }
        }
      }
    }
  }