Ejemplo n.º 1
0
  /** Opens the file. */
  private void openFile() {
    if (!(data instanceof FileAnnotationData)) return;

    FileAnnotationData fa = (FileAnnotationData) data;
    Registry reg = MetadataViewerAgent.getRegistry();
    UserNotifier un = reg.getUserNotifier();
    OriginalFile f = (OriginalFile) fa.getContent();
    Environment env = (Environment) reg.lookup(LookupNames.ENV);
    DownloadAndLaunchActivityParam activity;
    final long dataId = fa.getId();
    final File dir =
        new File(env.getOmeroFilesHome() + File.separatorChar + "file annotation " + dataId);
    if (!dir.exists()) {
      dir.mkdir();
    }
    if (f != null && f.isLoaded()) {
      activity = new DownloadAndLaunchActivityParam(f, dir, null);
    } else {
      activity =
          new DownloadAndLaunchActivityParam(
              dataId, DownloadAndLaunchActivityParam.FILE_ANNOTATION, dir, null);
    }
    un.notifyActivity(model.getSecurityContext(), activity);
    return;
  }
Ejemplo n.º 2
0
 /**
  * Downloads the file.
  *
  * @see EditorLoader#cancel()
  */
 public void load() {
   if (data != null) {
     OriginalFile f = ((FileAnnotation) data.asAnnotation()).getFile();
     if (f.isLoaded()) {
       handle = mhView.loadFile(file, f.getId().getValue(), f.getSize().getValue(), this);
     }
   } else {
     Entry entry;
     Iterator i = files.entrySet().iterator();
     FileAnnotationData fa;
     filesMap = new HashMap<FileAnnotationData, File>(files.size());
     File f;
     // int index = 0;
     String dir = MetadataViewerAgent.getTmpDir();
     while (i.hasNext()) {
       entry = (Entry) i.next();
       fa = (FileAnnotationData) entry.getKey();
       f = new File(dir + File.separator + fa.getFileID() + "_" + fa.getFileName());
       f.deleteOnExit();
       filesMap.put(fa, f);
     }
     handle = mhView.loadFiles(filesMap, this);
   }
 }