Exemplo n.º 1
0
  /** Modifies the existing password. */
  private void changePassword() {
    UserNotifier un;
    if (!oldPassword.isVisible()) {
      StringBuffer buf = new StringBuffer();
      buf.append(passwordNew.getPassword());
      String newPass = buf.toString();
      if (newPass == null || newPass.length() == 0) {
        un = MetadataViewerAgent.getRegistry().getUserNotifier();
        un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter the new password.");
        passwordNew.requestFocus();
        return;
      }
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Password changed.");
      passwordNew.setText("");
      model.resetPassword(newPass);
      return;
    }
    StringBuffer buf = new StringBuffer();
    buf.append(passwordNew.getPassword());
    String newPass = buf.toString();

    String pass = buf.toString();
    buf = new StringBuffer();
    buf.append(passwordConfirm.getPassword());
    String confirm = buf.toString();

    buf = new StringBuffer();
    buf.append(oldPassword.getPassword());
    String old = buf.toString();
    if (old == null || old.trim().length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please specify your old password.");
      oldPassword.requestFocus();
      return;
    }
    if (newPass == null || newPass.length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter your new password.");
      passwordNew.requestFocus();
      return;
    }

    if (pass == null || confirm == null || confirm.length() == 0 || !pass.equals(confirm)) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(
          PASSWORD_CHANGE_TITLE, "The passwords entered do not match. " + "Please try again.");
      passwordNew.setText("");
      passwordConfirm.setText("");
      passwordNew.requestFocus();
      return;
    }
    model.changePassword(old, confirm);
  }
Exemplo n.º 2
0
 /**
  * Creates or recycles the existing figure dialog.
  *
  * @param name The name to display.
  * @param pixels The pixels object of reference.
  * @param index One of the constants defined by this class.
  * @return See above.
  */
 FigureDialog createFigureDialog(String name, PixelsData pixels, int index) {
   if (figureDialog != null) return figureDialog;
   UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();
   if (FigureDialog.needPixels(index) && pixels == null) {
     un.notifyInfo("Figure", "The image is not valid," + " cannot create the figure.");
     return null;
   }
   JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
   figureDialog = new FigureDialog(f, name, pixels, index, view.getRefObject().getClass());
   figureDialog.addPropertyChangeListener(this);
   return figureDialog;
 }
Exemplo n.º 3
0
  /** Brings up the folder chooser. */
  private void export() {
    DowngradeChooser chooser =
        new DowngradeChooser(
            new RefWindow(),
            FileChooser.SAVE,
            "Export",
            "Select where to export the image as OME-TIFF.",
            exportFilters);
    try {
      String path =
          MetadataViewerAgent.getRegistry()
              .getTaskBar()
              .getLibFileRelative(TransformsParser.SPECIFICATION + ".jar");
      chooser.parseData(path);
    } catch (Exception e) {
      LogMessage msg = new LogMessage();
      msg.print(e);
      MetadataViewerAgent.getRegistry().getLogger().debug(this, msg);
    }
    String s = UIUtilities.removeFileExtension(view.getRefObjectName());
    if (s != null && s.trim().length() > 0) chooser.setSelectedFile(s);
    chooser.setApproveButtonText("Export");
    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.EXPORT_AS_OMETIFF_48));
    chooser.addPropertyChangeListener(
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
              File[] files = (File[]) evt.getNewValue();
              File folder = files[0];
              if (folder == null) folder = UIUtilities.getDefaultFolder();
              Object src = evt.getSource();
              Target target = null;
              if (src instanceof DowngradeChooser) {
                ((FileChooser) src).setVisible(false);
                ((FileChooser) src).dispose();
                target = ((DowngradeChooser) src).getSelectedSchema();
              }
              model.exportImageAsOMETIFF(folder, target);
            } else if (DowngradeChooser.HELP_DOWNGRADE_PROPERTY.equals(name)) {
              Registry reg = MetadataViewerAgent.getRegistry();
              String url = (String) reg.lookup("HelpDowngrade");
              reg.getTaskBar().openURL(url);
            }
          }
        });
    chooser.centerDialog();
  }
Exemplo n.º 4
0
 /** Brings up the dialog to choose the photo to upload. */
 private void uploadPicture() {
   UploadPictureDialog d =
       new UploadPictureDialog(MetadataViewerAgent.getRegistry().getTaskBar().getFrame());
   d.addPropertyChangeListener(this);
   d.pack();
   UIUtilities.centerAndShow(d);
 }
Exemplo n.º 5
0
  /** Brings up the folder chooser. */
  private void download() {
    JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
    FileChooser chooser =
        new FileChooser(
            f,
            FileChooser.FOLDER_CHOOSER,
            "Download",
            "Select where to download the file.",
            null,
            true);
    chooser.setSelectedFileFull(view.getRefObjectName());
    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
    chooser.setApproveButtonText("Download");
    chooser.addPropertyChangeListener(
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
              String path = (String) evt.getNewValue();
              if (path == null) {
                path = UIUtilities.getDefaultFolderAsString();
              }
              if (!path.endsWith(File.separator)) path += File.separator;
              model.download(new File(path));
            }
          }
        });
    chooser.centerDialog();
  }
Exemplo n.º 6
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;
  }
Exemplo n.º 7
0
 /** Launches a dialog to select the file to attach to the <code>DataObject</code>. */
 private void selectFileToAttach() {
   JFrame owner = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
   FileChooser chooser =
       new FileChooser(
           owner, FileChooser.LOAD, "Choose File", "Select the file to attach.", filters, true);
   chooser.setMultiSelectionEnabled(true);
   IconManager icons = IconManager.getInstance();
   chooser.setTitleIcon(icons.getIcon(IconManager.ATTACHMENT_48));
   chooser.setApproveButtonText("Attach");
   chooser.addPropertyChangeListener(FileChooser.APPROVE_SELECTION_PROPERTY, this);
   UIUtilities.centerAndShow(chooser);
 }
Exemplo n.º 8
0
 /** Adds or edits the description of the tag. */
 private void editDescription() {
   if (!(data instanceof AnnotationData)) return;
   String text = model.getAnnotationDescription((AnnotationData) data);
   originalDescription = text;
   SwingUtilities.convertPointToScreen(popupPoint, this);
   JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
   int type = EditorDialog.EDIT_TYPE;
   if (isModulo) type = EditorDialog.VIEW_TYPE;
   EditorDialog d = new EditorDialog(f, (AnnotationData) data, false, type);
   if (isModulo) d.allowEdit(false);
   d.addPropertyChangeListener(this);
   d.setOriginalDescription(originalDescription);
   d.setSize(300, 250);
   UIUtilities.showOnScreen(d, popupPoint);
 }
 /** Brings up a dialog so that the user can select where to download the file. */
 private void download() {
   String name = null;
   if (data instanceof FileAnnotationData) {
     name = ((FileAnnotationData) data).getFileName();
   }
   JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
   FileChooser chooser =
       new FileChooser(
           f, FileChooser.SAVE, "Download", "Select where to download the files.", null, true);
   if (name != null && name.trim().length() > 0) chooser.setSelectedFileFull(name);
   IconManager icons = IconManager.getInstance();
   chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48));
   chooser.setApproveButtonText("Download");
   chooser.addPropertyChangeListener(this);
   chooser.centerDialog();
 }
Exemplo n.º 10
0
  /**
   * Listens to property fired by the Editor dialog.
   *
   * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
   */
  public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
      File[] files = (File[]) evt.getNewValue();
      File folder = files[0];
      if (folder == null) folder = UIUtilities.getDefaultFolder();
      UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();

      if (attachments == null || attachments.size() == 0) return;
      IconManager icons = IconManager.getInstance();
      DownloadAndZipParam param =
          new DownloadAndZipParam(attachments, folder, icons.getIcon(IconManager.DOWNLOAD_22));
      // TODO: review
      // un.notifyActivity(param);
    }
  }
Exemplo n.º 11
0
  /** Brings up the folder chooser to select where to save the files. */
  private void saveAsJPEG() {
    JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame();
    FileChooser chooser =
        new FileChooser(
            f,
            FileChooser.FOLDER_CHOOSER,
            "Save As",
            "Select where to save locally the images as JPEG.",
            saveAsFilters);
    String s = UIUtilities.removeFileExtension(view.getRefObjectName());
    if (s != null && s.trim().length() > 0) chooser.setSelectedFile(s);
    chooser.setApproveButtonText("Save");
    IconManager icons = IconManager.getInstance();
    chooser.setTitleIcon(icons.getIcon(IconManager.SAVE_AS_48));
    chooser.addPropertyChangeListener(
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
              // File[] files = (File[]) evt.getNewValue();
              String value = (String) evt.getNewValue();
              File folder = null; // files[0];
              if (value == null || value.trim().length() == 0)
                folder = UIUtilities.getDefaultFolder();
              else folder = new File(value);
              Object src = evt.getSource();
              if (src instanceof FileChooser) {
                ((FileChooser) src).setVisible(false);
                ((FileChooser) src).dispose();
              }
              model.saveAs(folder);
            }
          }
        });
    chooser.centerDialog();
  }
Exemplo n.º 12
0
  /**
   * Listens to property fired by the Editor dialog.
   *
   * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
   */
  public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (EditorDialog.CREATE_NO_PARENT_PROPERTY.equals(name)) {
      // reset text and tooltip
      String text = "";
      String description = "";
      AnnotationData annotation = null;
      if (data instanceof TagAnnotationData
          || data instanceof TermAnnotationData
          || data instanceof XMLAnnotationData) {
        annotation = (AnnotationData) data;
        text = annotation.getContentAsString();
        text = EditorUtil.truncate(text, TEXT_LENGTH, false);
      }
      if (data instanceof DoubleAnnotationData) {
        annotation = (AnnotationData) data;
        text = "" + ((DoubleAnnotationData) data).getDataValue();
      }
      if (data instanceof LongAnnotationData) {
        annotation = (AnnotationData) data;
        text = "" + ((LongAnnotationData) data).getDataValue();
      }
      if (data instanceof BooleanAnnotationData) {
        annotation = (AnnotationData) data;
        text = "" + ((BooleanAnnotationData) data).getValue();
      }
      description = model.getAnnotationDescription(annotation);
      if (annotation == null) return;
      label.setText(text);
      label.setToolTipText(formatToolTip(annotation, null));
      originalName = text;
      originalDescription = description;
      firePropertyChange(AnnotationUI.EDIT_TAG_PROPERTY, null, this);
    } else if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
      if (data == null) return;
      FileAnnotationData fa = (FileAnnotationData) data;
      OriginalFile f = (OriginalFile) fa.getContent();
      File folder;
      Object o = evt.getNewValue();
      if (o instanceof String) {
        String path = (String) o;
        if (!path.endsWith(File.separator)) {
          path += File.separator;
        }
        path += fa.getFileName();
        folder = new File(path);
      } else {
        File[] files = (File[]) o;
        folder = files[0];
      }
      if (folder == null) folder = UIUtilities.getDefaultFolder();
      UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();

      IconManager icons = IconManager.getInstance();

      DownloadActivityParam activity =
          new DownloadActivityParam(f, folder, icons.getIcon(IconManager.DOWNLOAD_22));
      // Check Name space
      activity.setLegend(fa.getDescription());
      un.notifyActivity(model.getSecurityContext(), activity);
    }
  }
Exemplo n.º 13
0
 /**
  * Posts an event to view the protocol.
  *
  * @param protocolID The id of the protocol to view.
  */
 private void viewProtocol(long protocolID) {
   EventBus bus = MetadataViewerAgent.getRegistry().getEventBus();
   bus.post(new EditFileEvent(model.getSecurityContext(), protocolID));
 }
Exemplo n.º 14
0
 /**
  * Posts an event to view the image.
  *
  * @param imageID The id of the image to view.
  */
 private void viewImage(long imageID) {
   EventBus bus = MetadataViewerAgent.getRegistry().getEventBus();
   bus.post(new ViewImage(model.getSecurityContext(), new ViewImageObject(imageID), null));
 }
Exemplo n.º 15
0
 /** Launches RAPID. */
 private void openFLIM() {
   String url = (String) MetadataViewerAgent.getRegistry().lookup(LookupNames.RAPID);
   MetadataViewerAgent.getRegistry().getTaskBar().openURL(url);
 }
Exemplo n.º 16
0
  /**
   * Builds the UI component hosting the UI component used to modify the password.
   *
   * @return See above.
   */
  private JPanel buildPasswordPanel() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Registry reg = MetadataViewerAgent.getRegistry();
    String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION);
    if (ldap != null && ldap.length() > 0) {
      content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication"));
      content.setLayout(new FlowLayout(FlowLayout.LEFT));
      content.add(new JLabel(ldap));
      return content;
    }
    content.setBorder(BorderFactory.createTitledBorder("Change Password"));

    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    if (MetadataViewerAgent.isAdministrator()) {
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
    } else {
      content.add(UIUtilities.setTextFont(PASSWORD_OLD), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(oldPassword, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordConfirm, c);
      c.gridy++;
      c.gridx = 0;
    }

    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(content);
    JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton);
    buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(buttonPanel);
    return p;
  }
Exemplo n.º 17
0
 /**
  * Reacts to property change.
  *
  * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
  */
 public void propertyChange(PropertyChangeEvent evt) {
   String name = evt.getPropertyName();
   if (SAVE_PROPERTY.equals(name)
       || DataComponent.DATA_MODIFIED_PROPERTY.equals(name)
       || PreviewPanel.PREVIEW_EDITED_PROPERTY.equals(name)) {
     view.setDataToSave(view.hasDataToSave());
   } else if (MetadataViewer.SAVE_DATA_PROPERTY.equals(name)) {
     Boolean b = (Boolean) evt.getNewValue();
     view.saveData(b.booleanValue());
   } else if (MetadataViewer.CLEAR_SAVE_DATA_PROPERTY.equals(name)
       || MetadataViewer.ON_DATA_SAVE_PROPERTY.equals(name)
       || MetadataViewer.ADMIN_UPDATED_PROPERTY.equals(name)) {
     view.clearData();
   } else if (UIUtilities.COLLAPSED_PROPERTY_JXTASKPANE.equals(name)) {
     view.handleTaskPaneCollapsed((JXTaskPane) evt.getSource());
   } else if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) {
     File[] files = (File[]) evt.getNewValue();
     view.attachFiles(files);
   } else if (AnnotationUI.REMOVE_ANNOTATION_PROPERTY.equals(name)) {
     Object object = evt.getNewValue();
     if (object instanceof DocComponent) {
       DocComponent doc = (DocComponent) object;
       Object data = doc.getData();
       if (data instanceof File) view.removeAttachedFile(data);
       else if (data instanceof FileAnnotationData) view.removeAttachedFile(data);
       else if (data instanceof TagAnnotationData) view.removeObject((DataObject) data);
     }
   } else if (AnnotationUI.DELETE_ANNOTATION_PROPERTY.equals(name)) {
     Object object = evt.getNewValue();
     if (object instanceof DocComponent) {
       DocComponent doc = (DocComponent) object;
       Object data = doc.getData();
       if (data instanceof FileAnnotationData) {
         view.deleteAnnotation((FileAnnotationData) data);
         view.removeAttachedFile(data);
       }
     } else if (object instanceof TextualAnnotationComponent) {
       TextualAnnotationComponent doc = (TextualAnnotationComponent) object;
       TextualAnnotationData data = doc.getData();
       // view.deleteAnnotation((TextualAnnotationData) data);
       view.removeObject(data);
     }
   } else if (AnnotationUI.EDIT_TAG_PROPERTY.equals(name)) {
     Object object = evt.getNewValue();
     if (object instanceof DocComponent) {
       // Save the tag w/o update.
       DataObject d = (DataObject) ((DocComponent) object).getData();
       // Save the tag
       OmeroMetadataService svc = MetadataViewerAgent.getRegistry().getMetadataService();
       long id = MetadataViewerAgent.getUserDetails().getId();
       try {
         svc.saveData(model.getSecurityContext(), Arrays.asList(d), null, null, id);
       } catch (Exception e) {
         Logger l = MetadataViewerAgent.getRegistry().getLogger();
         LogMessage msg = new LogMessage();
         msg.print("Saving object");
         msg.print(e);
         l.error(this, msg);
       }
     }
   } else if (OMEWikiComponent.WIKI_DATA_OBJECT_PROPERTY.equals(name)) {
     WikiDataObject object = (WikiDataObject) evt.getNewValue();
     long id;
     switch (object.getIndex()) {
       case WikiDataObject.IMAGE:
         id = object.getId();
         if (id < 0) viewImage(object.getName());
         else viewImage(id);
         break;
       case WikiDataObject.PROTOCOL:
         viewProtocol(object.getId());
         break;
     }
   } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) {
     Map m = (Map) evt.getNewValue();
     if (m == null || m.size() != 1) return;
     Set set = m.entrySet();
     Entry entry;
     Iterator i = set.iterator();
     Class type;
     while (i.hasNext()) {
       entry = (Entry) i.next();
       type = (Class) entry.getKey();
       view.handleObjectsSelection(type, (Collection) entry.getValue());
     }
   } else if (PreviewPanel.OPEN_FILE_PROPERTY.equals(name)) {
     Long id = (Long) evt.getNewValue();
     if (id != null) viewProtocol(id.longValue());
   } else if (MetadataViewer.SETTINGS_APPLIED_PROPERTY.equals(name)) {
     model.loadRenderingControl(RenderingControlLoader.RELOAD);
     view.onSettingsApplied(true);
   } else if (MetadataViewer.ACTIVITY_OPTIONS_PROPERTY.equals(name)) {
     List l = (List) evt.getNewValue();
     view.activityOptions((Component) l.get(0), (Point) l.get(1), (Integer) l.get(2));
   } else if (FigureDialog.CREATE_FIGURE_PROPERTY.equals(name)) {
     view.createFigure(evt.getNewValue());
   } else if (FigureDialog.CLOSE_FIGURE_PROPERTY.equals(name)) {
     figureDialog = null;
   } else if (MetadataViewer.CLOSE_RENDERER_PROPERTY.equals(name)) {
     view.discardRenderer(evt.getNewValue());
   } else if (MetadataViewer.RELATED_NODES_PROPERTY.equals(name)) {
     view.onRelatedNodesSet();
   } else if (ScriptingDialog.RUN_SELECTED_SCRIPT_PROPERTY.equals(name)) {
     // view.manageScript((ScriptObject) evt.getNewValue(),
     //		MetadataViewer.RUN);
   } else if (ScriptingDialog.DOWNLOAD_SELECTED_SCRIPT_PROPERTY.equals(name)) {
     Object value = evt.getNewValue();
     if (value instanceof ScriptObject)
       view.manageScript((ScriptObject) value, MetadataViewer.DOWNLOAD);
     else if (value instanceof String) {
       ScriptObject script = view.getScriptFromName((String) value);
       if (script != null) view.manageScript(script, MetadataViewer.DOWNLOAD);
     }
   } else if (ScriptingDialog.VIEW_SELECTED_SCRIPT_PROPERTY.equals(name)) {
     Object value = evt.getNewValue();
     if (value instanceof ScriptObject)
       view.manageScript((ScriptObject) value, MetadataViewer.VIEW);
     else if (value instanceof String) {
       ScriptObject script = view.getScriptFromName((String) value);
       if (script != null) view.manageScript(script, MetadataViewer.VIEW);
     }
   } else if (AnalysisResultsItem.ANALYSIS_RESULTS_DELETE.equals(name)) {
     AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue();
     List<FileAnnotationData> list = item.getAttachments();
     view.fireAnnotationsDeletion(list);
   } else if (AnalysisResultsItem.ANALYSIS_RESULTS_VIEW.equals(name)) {
     AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue();
     if (view.getRndIndex() == MetadataViewer.RND_GENERAL) {
       model.displayAnalysisResults(item);
       /*
       ViewImage event = new ViewImage(item.getData(), null);
       event.setAnalysis(item);
       EventBus bus = MetadataViewerAgent.getRegistry().getEventBus();
       bus.post(event);
       */
     } else {
       model.displayAnalysisResults(item);
     }
   } else if (AnalysisResultsItem.ANALYSIS_RESULTS_CANCEL.equals(name)) {
     AnalysisResultsItem item = (AnalysisResultsItem) evt.getNewValue();
     view.cancelAnalysisResultsLoading(item);
   }
 }
Exemplo n.º 18
0
 /** Message displayed when one of the required fields is left blank. */
 private void showRequiredField() {
   UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();
   un.notifyInfo("Edit Profile", "The required fields cannot be left " + "blank.");
   return;
 }
Exemplo n.º 19
0
  /**
   * Handles events.
   *
   * @see ActionListener#actionPerformed(ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof ScriptMenuItem) {
      ScriptMenuItem item = (ScriptMenuItem) e.getSource();
      if (item.isScriptWithUI()) {
        switch (item.getIndex()) {
          case ScriptMenuItem.MOVIE_FIGURE_SCRIPT:
            model.createFigure(FigureDialog.MOVIE);
            break;
          case ScriptMenuItem.ROI_FIGURE_SCRIPT:
            model.createFigure(FigureDialog.SPLIT_ROI);
            break;
          case ScriptMenuItem.THUMBNAIL_FIGURE_SCRIPT:
            model.createFigure(FigureDialog.THUMBNAILS);
            break;
          case ScriptMenuItem.SPLIT_VIEW_FIGURE_SCRIPT:
            model.createFigure(FigureDialog.SPLIT);
            break;
          case ScriptMenuItem.MOVIE_EXPORT_SCRIPT:
            view.makeMovie(-1, null);
            break;
          case ScriptMenuItem.FLIM_SCRIPT:
            openFLIM();
        }
      } else {
        ScriptObject object = item.getScript();
        if (!object.isParametersLoaded()) model.loadScript(object.getScriptID());
        else model.setScript(object);
      }
      return;
    }

    int index = Integer.parseInt(e.getActionCommand());

    switch (index) {
      case ADD_LOCAL_DOCS:
        selectFileToAttach();
        break;
      case ADD_UPLOADED_DOCS:
        model.loadExistingAttachments();
        break;
      case SAVE:
        view.saveData(true);
        break;
      case DOWNLOAD:
        download();
        break;
      case ADD_TAGS:
        loadExistingTags();
        break;
      case CREATE_NEW_EXPERIMENT:
        view.createNewExperiment();
        break;
      case CREATE_MOVIE:
        view.makeMovie(-1, null);
        break;
      case RENDERER:
        model.loadRenderingControl(RenderingControlLoader.LOAD);
        break;
      case ANALYSE_FLIM:
        view.analyse(AnalysisParam.FLIM);
        break;
      case ANALYSE_FRAP:
        view.analyse(AnalysisParam.FRAP);
        break;
      case REFRESH:
        model.refresh();
        break;
      case EXPORT_AS_OMETIFF:
        export();
        break;
      case SPLIT_VIEW_FIGURE:
        model.createFigure(FigureDialog.SPLIT);
        break;
      case SPLIT_VIEW_ROI_FIGURE:
        model.createFigure(FigureDialog.SPLIT_ROI);
        break;
      case THUMBNAILS_FIGURE:
        model.createFigure(FigureDialog.THUMBNAILS);
        break;
      case MOVIE_FIGURE:
        model.createFigure(FigureDialog.MOVIE);
        break;
      case UPLOAD_SCRIPT:
        view.uploadScript();
        break;
      case RELOAD_SCRIPT:
        view.reloadScript();
        break;
        /*
        case REMOVE_TAGS:
        	view.removeTags();
        	break;
        case REMOVE_DOCS:
        	view.removeAttachedFiles();
        	break;
        	*/
      case SAVE_AS:
        saveAsJPEG();
        break;
      case VIEW_IMAGE:
        Object refObject = view.getRefObject();
        ImageData img = null;
        if (refObject instanceof ImageData) {
          img = (ImageData) refObject;
        } else if (refObject instanceof WellSampleData) {
          img = ((WellSampleData) refObject).getImage();
        }
        if (img != null) {
          ViewImageObject vio = new ViewImageObject(img);
          MetadataViewerAgent.getRegistry()
              .getEventBus()
              .post(new ViewImage(model.getSecurityContext(), vio, null));
        }
        break;
      case VIEW_IMAGE_IN_IJ:
        Object object = view.getRefObject();
        ImageData image = null;
        if (object instanceof ImageData) {
          image = (ImageData) object;
        } else if (object instanceof WellSampleData) {
          image = ((WellSampleData) object).getImage();
        }
        if (image != null) {
          ViewInPluginEvent event =
              new ViewInPluginEvent(
                  model.getSecurityContext(), (DataObject) object, MetadataViewer.IMAGE_J);
          MetadataViewerAgent.getRegistry().getEventBus().post(event);
        }
    }
  }
Exemplo n.º 20
0
 /**
  * Posts an event to view the image.
  *
  * @param imageID The id of the image to view.
  */
 private void viewImage(long imageID) {
   EventBus bus = MetadataViewerAgent.getRegistry().getEventBus();
   ViewImage evt = new ViewImage(model.getSecurityContext(), new ViewImageObject(imageID), null);
   evt.setPlugin(MetadataViewerAgent.runAsPlugin());
   bus.post(evt);
 }