Ejemplo n.º 1
0
 public String getSettingsPath(DocearUser user) {
   return URIUtils.getAbsoluteFile(WorkspaceController.getApplicationSettingsHome()).getPath()
       + File.separator
       + "users"
       + File.separator
       + user.getName();
 }
Ejemplo n.º 2
0
 public void refresh() {
   File folder;
   try {
     inRefresh = true;
     folder = URIUtils.getAbsoluteFile(getPath());
     if (folder.isDirectory()) {
       getModel().removeAllElements(this);
       loadDirectoryFiles(folder);
       getModel().reload(this);
     }
   } catch (Exception e) {
     LogUtils.severe(e);
   } finally {
     inRefresh = false;
   }
 }
  /**
   * ********************************************************************************* REQUIRED
   * METHODS FOR INTERFACES
   * ********************************************************************************
   */
  public void handleAction(WorkspaceActionEvent event) {
    if (event.getType() == WorkspaceActionEvent.MOUSE_LEFT_DBLCLICK) {
      try {
        AWorkspaceProject project = WorkspaceController.getSelectedProject(this);
        File f = URIUtils.getAbsoluteFile(getLinkURI());
        if (f == null) {
          return;
        }
        if (!f.exists()) {
          if (WorkspaceNewMapAction.createNewMap(project, f.toURI(), getName(), true) == null) {
            LogUtils.warn("could not create " + getLinkURI());
          }
        }

        Controller.getCurrentController().selectMode(MModeController.MODENAME);
        final MapIO mapIO = (MapIO) MModeController.getMModeController().getExtension(MapIO.class);

        try {
          if (mapIO.newMap(f.toURI().toURL())) {
            DocearEvent evnt =
                new DocearEvent(
                    this,
                    (DocearWorkspaceProject) project,
                    DocearEventType.NEW_MY_PUBLICATIONS,
                    Controller.getCurrentController().getMap());
            DocearController.getController().getEventQueue().dispatchEvent(evnt);
          }
        } catch (Exception e) {
          LogUtils.severe(e);
          return;
        }
      } catch (Exception e) {
        LogUtils.warn("could not open document (" + getLinkURI() + ")", e);
      }
    } else if (event.getType() == WorkspaceActionEvent.MOUSE_RIGHT_CLICK) {
      showPopup((Component) event.getBaggage(), event.getX(), event.getY());
    } else {
      // do nth for now
    }
  }
Ejemplo n.º 4
0
  public boolean changeName(String newName, boolean renameLink) {
    assert (newName != null);
    assert (newName.trim().length() > 0);

    if (renameLink) {
      File oldFile = URIUtils.getAbsoluteFile(getPath());
      try {
        if (oldFile == null) {
          throw new Exception("failed to resolve the file for" + getName());
        }
        File destFile = new File(oldFile.getParentFile(), newName);
        if (oldFile.exists() && oldFile.renameTo(destFile)) {
          // this.setName(newName);
          try {
            getModel().changeNodeName(this, newName);
            return true;
          } catch (Exception ex) {
            destFile.renameTo(oldFile);
            return false;
          }
        } else {
          LogUtils.warn("cannot rename " + oldFile.getName());
        }
      } catch (Exception e) {
        LogUtils.warn("cannot rename " + oldFile.getName(), e);
      }
    } else {
      // this.setName(newName);
      try {
        getModel().changeNodeName(this, newName);
        return true;
      } catch (Exception ex) {
        // do nth.
      }
    }
    return false;
  }
Ejemplo n.º 5
0
 private void createIfNeeded(URI uri) {
   File file = URIUtils.getAbsoluteFile(uri);
   if (file != null && !file.exists()) {
     file.mkdirs();
   }
 }
Ejemplo n.º 6
0
 public File getFile() {
   return URIUtils.getAbsoluteFile(this.getPath());
 }