コード例 #1
0
  public void saveAs() {
    MostRecentFileDialog mrfd = new MostRecentFileDialog("org.concord.otviewer.saveotml");
    mrfd.setFilenameFilter("otml");

    if (currentUserFile != null) {
      mrfd.setCurrentDirectory(currentUserFile.getParentFile());
      mrfd.setSelectedFile(currentUserFile);
    }

    int retval = mrfd.showSaveDialog(getDialogParent());

    File file = null;
    if (retval == MostRecentFileDialog.APPROVE_OPTION) {
      file = mrfd.getSelectedFile();

      String fileName = file.getPath();
      currentUserFile = file;

      if (!fileName.toLowerCase().endsWith(".otml")) {
        currentUserFile = new File(currentUserFile.getAbsolutePath() + ".otml");
      }

      try {
        ExporterJDOM.export(currentUserFile, userDataDB.getRoot(), userDataDB);
        userDataDB.setDirty(false);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
コード例 #2
0
  public void save() {
    if (currentUserFile == null || !currentUserFile.exists()) {
      saveAs();
      return;
    }

    if (currentUserFile.exists()) {
      try {
        ExporterJDOM.export(currentUserFile, userDataDB.getRoot(), userDataDB);
        userDataDB.setDirty(false);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
コード例 #3
0
  protected void initUserDb(XMLDatabase userDataDb) throws Exception {
    this.userDataDB = userDataDb;
    otrunk.addDatabase(userDataDB);

    OTObjectService objService = otrunk.createObjectService(userDataDb);

    OTDataObject rootDO = userDataDb.getRoot();

    OTStateRoot stateRoot = (OTStateRoot) objService.getOTObject(rootDO.getGlobalId());

    OTObjectMap userMap = stateRoot.getUserMap();

    // find the user from this database.
    // this currently is the first user in the userMap
    Vector<String> keys = userMap.getObjectKeys();
    refMap = (OTReferenceMap) userMap.getObject(keys.get(0));
  }