/**
  * Returns the text indicating what to save.
  *
  * @return See above.
  */
 String getInstanceToSave() {
   Object ref = getRefObject();
   String v = "";
   if (ref instanceof ImageData) {
     v = "Image's Data: ";
     v += EditorUtil.truncate(((ImageData) ref).getName());
   } else if (ref instanceof DatasetData) {
     v = "Dataset's Data: ";
     v += EditorUtil.truncate(((DatasetData) ref).getName());
   } else if (ref instanceof ProjectData) {
     v = "Project's Data: ";
     v += EditorUtil.truncate(((ProjectData) ref).getName());
   } else if (ref instanceof PlateData) {
     v = "Plate's Data: ";
     v += EditorUtil.truncate(((PlateData) ref).getName());
   } else if (ref instanceof PlateAcquisitionData) {
     v = "Run's Data: ";
     v += EditorUtil.truncate(((PlateAcquisitionData) ref).getLabel());
   } else if (ref instanceof ScreenData) {
     v = "Screen's Data: ";
     v += EditorUtil.truncate(((ScreenData) ref).getName());
   } else if (ref instanceof ExperimenterData) {
     v = EditorUtil.formatExperimenter((ExperimenterData) ref);
     v += "'s details";
   }
   if (ref instanceof GroupData) {
     v = ((GroupData) ref).getName();
     v += "'s details";
   }
   return v;
 }
 /**
  * Returns the name of the object if any.
  *
  * @return See above.
  */
 String getRefObjectName() {
   Object ref = getRefObject();
   if (ref instanceof ImageData) return ((ImageData) ref).getName();
   else if (ref instanceof DatasetData) return ((DatasetData) ref).getName();
   else if (ref instanceof ProjectData) return ((ProjectData) ref).getName();
   else if (ref instanceof PlateData) return ((PlateData) ref).getName();
   else if (ref instanceof ScreenData) return ((ScreenData) ref).getName();
   else if (ref instanceof ExperimenterData)
     return EditorUtil.formatExperimenter((ExperimenterData) ref);
   else if (ref instanceof GroupData) return ((GroupData) ref).getName();
   return "";
 }
 /**
  * Creates a new instance.
  *
  * @param data The data to host.
  * @param icon The icon to set.
  * @param canBeEnabled Flag indicating if the item can be enabled or not.
  */
 public DataMenuItem(Object data, Icon icon, boolean canBeEnabled) {
   super(false, data.toString(), canBeEnabled);
   if (data instanceof ExperimenterData)
     setText(EditorUtil.formatExperimenter((ExperimenterData) data));
   else if (data instanceof GroupData) setText(((GroupData) data).getName());
   else setText(data.toString());
   if (icon != null) setIcon(icon);
   this.canBeEnabled = canBeEnabled;
   this.data = data;
   setEnabled(true);
   addActionListener(this);
 }
 /**
  * Returns the name of the node.
  *
  * @return See above.
  */
 private String getNodeName() {
   Object obj = getUserObject();
   if (obj instanceof ProjectData) return ((ProjectData) obj).getName();
   else if (obj instanceof DatasetData) return ((DatasetData) obj).getName();
   else if (obj instanceof ImageData) return ((ImageData) obj).getName();
   else if (obj instanceof ExperimenterData) {
     ExperimenterData exp = (ExperimenterData) obj;
     return EditorUtil.formatExperimenter(exp);
   } else if (obj instanceof ScreenData) return ((ScreenData) obj).getName();
   else if (obj instanceof PlateData) return ((PlateData) obj).getName();
   else if (obj instanceof TagAnnotationData) return ((TagAnnotationData) obj).getTagValue();
   else if (obj instanceof String) return (String) obj;
   return "";
 }
Example #5
0
 /**
  * Adds the experimenters who use the annotation if any.
  *
  * @param tt The {@link ToolTipGenerator} to add the information on to
  * @param annotation The annotation to handle.
  */
 private void checkAnnotators(ToolTipGenerator tt, AnnotationData annotation) {
   List<ExperimenterData> annotators = model.getAnnotators(annotation);
   if (annotators.size() == 0) return;
   Iterator<ExperimenterData> i = annotators.iterator();
   ExperimenterData annotator;
   tt.addLine("Linked by:", true);
   while (i.hasNext()) {
     annotator = i.next();
     tt.addLine(EditorUtil.formatExperimenter(annotator));
   }
   if (annotators.size() > 1) {
     String text = label.getText();
     text += " [" + annotators.size() + "]";
     label.setText(text);
   }
 }
 /**
  * Returns the name of the node.
  *
  * @param obj The object to handle.
  * @return See above.
  */
 private String getNodeName(Object obj) {
   if (obj instanceof ProjectData) return ((ProjectData) obj).getName();
   else if (obj instanceof DatasetData) return ((DatasetData) obj).getName();
   else if (obj instanceof ImageData) return ((ImageData) obj).getName();
   else if (obj instanceof ExperimenterData) {
     return EditorUtil.formatExperimenter((ExperimenterData) obj);
   } else if (obj instanceof GroupData) {
     return ((GroupData) obj).getName();
   } else if (obj instanceof TagAnnotationData) return ((TagAnnotationData) obj).getTagValue();
   else if (obj instanceof ScreenData) return ((ScreenData) obj).getName();
   else if (obj instanceof PlateData) {
     return ((PlateData) obj).getName();
   } else if (obj instanceof FileAnnotationData) return ((FileAnnotationData) obj).getFileName();
   else if (obj instanceof File) return ((File) obj).getName();
   else if (obj instanceof FileData) return ((FileData) obj).getName();
   else if (obj instanceof PlateAcquisitionData) return ((PlateAcquisitionData) obj).getLabel();
   else if (obj instanceof MultiImageData) return ((MultiImageData) obj).getName();
   else if (obj instanceof String) return (String) obj;
   return "";
 }
Example #7
0
 /**
  * Returns the list of users who annotated that image only if the annotation cannot be unlinked.
  *
  * @param object The object the annotation is linked to.
  * @param annotation The annotation to handle.
  */
 private String formatAnnotators(DataObject object, AnnotationData annotation) {
   StringBuffer buffer = new StringBuffer();
   List<ExperimenterData> annotators = model.getAnnotators(object, annotation);
   if (annotators.size() == 0) return null;
   long userID = model.getCurrentUser().getId();
   Iterator<ExperimenterData> i = annotators.iterator();
   ExperimenterData annotator;
   int n = annotators.size() - 1;
   int index = 0;
   buffer.append(" (");
   while (i.hasNext()) {
     annotator = i.next();
     if (annotator.getId() != userID) {
       buffer.append(EditorUtil.formatExperimenter(annotator));
       if (index != n) buffer.append(", ");
       index++;
     }
   }
   if (index == 0) return null;
   buffer.append(")");
   return buffer.toString();
 }
Example #8
0
  /**
   * Formats the passed annotation.
   *
   * @param annotation The value to format.
   * @param name The full name.
   * @return See above.
   */
  private String formatToolTip(AnnotationData annotation, String name) {
    ToolTipGenerator tt = new ToolTipGenerator();
    if (model.isMultiSelection()) {
      Map<DataObject, Boolean> m = null;
      Entry<DataObject, Boolean> e;
      Iterator<Entry<DataObject, Boolean>> j;
      String text = "";
      if (annotation instanceof TagAnnotationData) {
        m = model.getTaggedObjects(annotation);
        text += "Can remove Tag from ";
      } else if (annotation instanceof FileAnnotationData) {
        m = model.getObjectsWith(annotation);
        text += "Can remove Attachment from ";
      } else if (annotation instanceof XMLAnnotationData) {
        m = model.getObjectsWith(annotation);
        text += "Can remove XML files from ";
      } else if (annotation instanceof TermAnnotationData) {
        m = model.getObjectsWith(annotation);
        text += "Can remove Term from ";
      }
      if (m == null) return "";
      j = m.entrySet().iterator();
      Collection<Boolean> l = m.values();
      int n = 0;
      Iterator<Boolean> k = l.iterator();
      while (k.hasNext()) {
        if (k.next().booleanValue()) n++;
      }
      tt.addLineNoBr(text + "" + n + " ");
      int index = 0;
      String s;
      while (j.hasNext()) {
        e = j.next();
        if (index == 0) {
          tt.addLine(model.getObjectTypeAsString(e.getKey()) + "s", true);
          index++;
        }
        tt.addLine(
            "ID " + e.getKey().getId(),
            UIUtilities.formatPartialName(model.getObjectName(e.getKey())),
            true);
        // Indicates who annotates the object if not the user
        // currently logged in.
        s = formatAnnotators(e.getKey(), annotation);
        if (s != null) tt.addLine(s);
      }
      return tt.toString();
    }

    if (name != null) {
      tt.addLine("Name", name, true);
    }

    ExperimenterData exp = null;

    if (annotation.getId() > 0) {
      exp = model.getOwner(annotation);
      tt.addLine("ID", "" + annotation.getId(), true);
    }

    String ns = annotation.getNameSpace();
    if (!CommonsLangUtils.isEmpty(ns) && !EditorUtil.isInternalNS(ns)) {
      tt.addLine("Namespace", ns, true);
    }

    String desc = annotation.getDescription();
    if (!CommonsLangUtils.isEmpty(desc)) {
      tt.addLine("Description", desc, true);
    }

    if (exp != null) {
      tt.addLine("Owner", EditorUtil.formatExperimenter(exp), true);
    }

    Timestamp created = annotation.getCreated();
    if (created != null) {
      tt.addLine("Date", UIUtilities.formatDefaultDate(created), true);
    }

    if (data instanceof FileAnnotationData) {
      FileAnnotationData fa = (FileAnnotationData) data;
      long size = ((FileAnnotationData) annotation).getFileSize();
      tt.addLine("File ID", "" + fa.getFileID(), true);
      tt.addLine("Size", UIUtilities.formatFileSize(size) + "kb", true);
      checkAnnotators(tt, annotation);
    } else if (data instanceof TagAnnotationData
        || data instanceof XMLAnnotationData
        || data instanceof TermAnnotationData
        || data instanceof LongAnnotationData
        || data instanceof DoubleAnnotationData
        || data instanceof BooleanAnnotationData) {
      checkAnnotators(tt, annotation);
    }
    return tt.toString();
  }