コード例 #1
0
  public void quit(SwingController controller, JFrame viewer, Properties properties) {
    if (controller != null && viewer != null) {
      // save width & height
      Rectangle sz = viewer.getBounds();
      getProperties().setInt("application.x", sz.x);
      getProperties().setInt("application.y", sz.y);
      getProperties().setInt("application.height", sz.height);
      getProperties().setInt("application.width", sz.width);
      if (properties != null) {
        getProperties()
            .set(
                PropertiesManager.PROPERTY_DEFAULT_PAGEFIT,
                properties.getProperty(PropertiesManager.PROPERTY_DEFAULT_PAGEFIT));
        getProperties().set("document.viewtype", properties.getProperty("document.viewtype"));
      }
      getProperties().setDefaultFilePath(ViewModel.getDefaultFilePath());
      getProperties().setDefaultURL(ViewModel.getDefaultURL());
    }

    // save all the rest, cookies, bookmarks, etc.
    getProperties().saveAndEnd();

    // make sure all the controllers have been disposed.
    for (int i = 0; i < controllers.size(); i++) {
      SwingController c = controllers.get(i);
      if (c == null) continue;
      c.dispose();
    }

    /* CUCFL : don't exit the program, just dispose the viewer and return to th emain program... */
    // System.exit(0);

    if (viewer != null) {
      viewer.setVisible(false);
      viewer.dispose();
    }
  }
コード例 #2
0
ファイル: Launcher.java プロジェクト: XPSCAVENGER/icepdf
  /**
   * Starts the viewe application.
   *
   * @param contentFile URI of a file which will be loaded at runtime, can be null.
   * @param contentURL URL of a file which will be loaded at runtime, can be null.
   * @param contentProperties URI of a properties file which will be used in place of the default
   *     path
   * @param messageBundle messageBundle to pull strings from
   */
  private static void run(
      String contentFile,
      String contentURL,
      String contentProperties,
      ResourceBundle messageBundle) {

    // initiate the properties manager.
    Properties sysProps = System.getProperties();
    propertiesManager = new PropertiesManager(sysProps, contentProperties, messageBundle);

    // initiate font Cache manager, reads system font data and stores summary
    // information in a properties file.  If new font are added to the OS
    // then the properties file can be deleted to initiate a re-read of the
    // font data.
    new FontPropertiesManager(propertiesManager, sysProps, messageBundle);

    // input new System properties
    System.setProperties(sysProps);

    // set look & feel
    setupLookAndFeel(messageBundle);

    ViewModel.setDefaultFilePath(propertiesManager.getDefaultFilePath());
    ViewModel.setDefaultURL(propertiesManager.getDefaultURL());

    // application instance
    windowManager = new WindowManager(propertiesManager, messageBundle);
    if (contentFile != null && contentFile.length() > 0) {
      windowManager.newWindow(contentFile);
      ViewModel.setDefaultFilePath(contentFile);
    }

    // load a url if specified
    if (contentURL != null && contentURL.length() > 0) {
      URLAccess urlAccess = URLAccess.doURLAccess(contentURL);
      urlAccess.closeConnection();
      if (urlAccess.errorMessage != null) {

        // setup a patterned message
        Object[] messageArguments = {urlAccess.errorMessage, urlAccess.urlLocation};
        MessageFormat formatter =
            new MessageFormat(messageBundle.getString("viewer.launcher.URLError.dialog.message"));

        JOptionPane.showMessageDialog(
            null,
            formatter.format(messageArguments),
            messageBundle.getString("viewer.launcher.URLError.dialog.title"),
            JOptionPane.INFORMATION_MESSAGE);
      } else {
        windowManager.newWindow(urlAccess.url);
      }
      ViewModel.setDefaultURL(urlAccess.urlLocation);
      urlAccess.dispose();
    }

    // Start an empy viewer if there was no command line parameters
    if (((contentFile == null || contentFile.length() == 0)
            && (contentURL == null || contentURL.length() == 0))
        || (windowManager.getNumberOfWindows() == 0)) {
      windowManager.newWindow("");
    }
  }