Ejemplo n.º 1
0
 void updateUI() {
   for (int i = 0; i < controllers.size(); i++) {
     SwingController controller = controllers.get(i);
     JFrame frame = controller.getViewerFrame();
     if (frame != null) SwingUtilities.updateComponentTreeUI(frame);
   }
 }
Ejemplo n.º 2
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);
   }
 }
Ejemplo n.º 3
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();
     }
   }
 }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
0
 /**
  * As long as no windows have openned or closed, then the indexes in the returned list should
  * still be valid for doing operations on the respective Controller objects
  *
  * @param giveIndex Give this SwingControllers index in the list as an Integer appended to the
  *     List
  * @return List of String objects, each representing an open Document's origin. The last element
  *     may be an Integer
  */
 @SuppressWarnings({"rawtypes", "unchecked"})
 public List getWindowDocumentOriginList(SwingController giveIndex) {
   Integer foundIndex = null;
   int count = controllers.size();
   List list = new ArrayList(count + 1);
   for (int i = 0; i < count; i++) {
     Object toAdd = null;
     SwingController controller = controllers.get(i);
     if (giveIndex == controller) foundIndex = new Integer(i);
     Document document = controller.getDocument();
     if (document != null) toAdd = document.getDocumentOrigin();
     list.add(toAdd);
   }
   if (foundIndex != null) list.add(foundIndex);
   return list;
 }
Ejemplo n.º 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();
   }
 }
Ejemplo n.º 7
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();
    }
  }
Ejemplo n.º 8
0
 public void newWindow(URL location) {
   SwingController controller = commonWindowCreation();
   controller.openDocument(location);
 }