Ejemplo n.º 1
0
 /**
  * Popup a dialog asking the user for the name of the saved ViewManager. If provided, add a new
  * TwoFacedObject to the list of saved ViewManagers and write the list to disk.
  *
  * @param vm The view manager to save
  */
 protected void saveViewManagerState(ViewManager vm) {
   try {
     String name = ((vm instanceof MapViewManager) ? "Map View" : "View");
     name = GuiUtils.getInput(null, "Name for saved view: ", name);
     if (name == null) {
       return;
     }
     ViewState viewState = vm.doMakeViewState();
     viewState.setName(name);
     getVMState().add(viewState);
     writeVMState();
   } catch (Exception exc) {
     logException("Saving view state", exc);
   }
 }
Ejemplo n.º 2
0
  /**
   * Instantiates (if needed) and returns the list of {@link TwoFacedObject}s that is the set of
   * saved viewpoints
   *
   * @return List that holds the viewpoints
   */
  public List getVMState() {
    if (viewpoints == null) {
      List tmp = new ArrayList();
      XmlResourceCollection rc =
          getResourceManager().getXmlResources(getResourceManager().RSC_VIEWPOINTS);

      for (int i = 0; i < rc.size(); i++) {
        String contents = rc.read(i);
        if (contents == null) {
          continue;
        }
        try {
          List resources = (List) getIdv().getEncoderForRead().toObject(contents);
          tmp.addAll(resources);
          boolean local = rc.isWritable(i);
          for (Object o : resources) {
            if (o instanceof ViewState) {
              ((ViewState) o).setIsLocal(local);
            }
          }
        } catch (Exception exc) {
          logException("Creating VM list", exc);
        }
      }
      viewpoints = tmp;
    }
    return viewpoints;
  }