예제 #1
0
 public void minimiseAllWindows() {
   for (int i = 0; i < controllers.size(); i++) {
     SwingController controller = controllers.get(i);
     JFrame frame = controller.getViewerFrame();
     if (frame != null) frame.setState(Frame.ICONIFIED);
   }
 }
예제 #2
0
 public void bringWindowToFront(int index) {
   if (index >= 0 && index < controllers.size()) {
     SwingController controller = controllers.get(index);
     JFrame frame = controller.getViewerFrame();
     if (frame != null) {
       frame.setState(Frame.NORMAL);
       frame.toFront();
     }
   }
 }
예제 #3
0
  protected SwingController commonWindowCreation() {
    SwingController controller = new SwingController(messageBundle);
    controller.setWindowManagementCallback(this);

    // assign properties manager.
    controller.setPropertiesManager(properties);

    // add interactive mouse link annotation support
    controller
        .getDocumentViewController()
        .setAnnotationCallback(new MyAnnotationCallback(controller.getDocumentViewController()));

    controllers.add(controller);
    // guild a new swing viewer with remembered view settings.
    int viewType = DocumentViewControllerImpl.ONE_PAGE_VIEW;
    int pageFit = DocumentViewController.PAGE_FIT_WINDOW_WIDTH;
    try {
      viewType =
          getProperties().getInt("document.viewtype", DocumentViewControllerImpl.ONE_PAGE_VIEW);
      pageFit =
          getProperties()
              .getInt(
                  PropertiesManager.PROPERTY_DEFAULT_PAGEFIT,
                  DocumentViewController.PAGE_FIT_WINDOW_WIDTH);
    } catch (NumberFormatException e) {
      // eating error, as we can continue with out alarm
    }

    SwingViewBuilder factory = new SwingViewBuilder(controller, viewType, pageFit);

    JFrame frame = factory.buildViewerFrame();
    if (frame != null) {
      int width = getProperties().getInt("application.width", 800);
      int height = getProperties().getInt("application.height", 600);
      frame.setSize(width, height);

      int x = getProperties().getInt("application.x", 1);
      int y = getProperties().getInt("application.y", 1);

      frame.setLocation(
          (int) (x + (newWindowInvokationCounter * 10)),
          (int) (y + (newWindowInvokationCounter * 10)));
      ++newWindowInvokationCounter;
      frame.setVisible(true);
    }

    return controller;
  }
예제 #4
0
  public void disposeWindow(SwingController controller, JFrame viewer, Properties properties) {
    if (controllers.size() <= 1) {
      quit(controller, viewer, properties);
      return;
    }

    // gets the window to close from the list
    int index = controllers.indexOf(controller);
    if (index >= 0) {
      controllers.remove(index);
      newWindowInvokationCounter--;
      if (viewer != null) {
        viewer.setVisible(false);
        viewer.dispose();
      }
    }
  }
예제 #5
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();
    }
  }
예제 #6
0
 public void bringAllWindowsToFront(SwingController frontMost) {
   JFrame frontMostFrame = null;
   for (int i = 0; i < controllers.size(); i++) {
     SwingController controller = controllers.get(i);
     JFrame frame = controller.getViewerFrame();
     if (frame != null) {
       if (frontMost == controller) {
         frontMostFrame = frame;
         continue;
       }
       frame.setState(Frame.NORMAL);
       frame.toFront();
     }
   }
   if (frontMostFrame != null) {
     frontMostFrame.setState(Frame.NORMAL);
     frontMostFrame.toFront();
   }
 }