Example #1
0
 /**
  * Returns <code>true</code> if the description of the tag has been modified, <code>false</code>
  * otherwise.
  *
  * @return See above.
  */
 boolean hasBeenModified() {
   if (originalName == null) return false;
   if (data instanceof TagAnnotationData) {
     TagAnnotationData tag = (TagAnnotationData) data;
     if (!originalName.equals(tag.getTagValue())) return true;
     String txt = tag.getTagDescription();
     if (txt != null) return !(originalDescription.equals(txt));
     return false;
   }
   return false;
 }
Example #2
0
  /** Initializes the components composing the display. */
  private void initComponents() {
    isModulo = model.isModulo(data);
    imageToLoad = -1;
    initButtons();
    label = new JLabel();
    label.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    checkbox = new JCheckBox();
    if (data == null) {
      label.setText(AnnotationUI.DEFAULT_TEXT);
    } else {
      if (data instanceof FileAnnotationData) {
        FileAnnotationData f = (FileAnnotationData) data;
        String fileName = f.getFileName();
        String s = fileName;
        if (FileAnnotationData.MEASUREMENT_NS.equals(f.getNameSpace())) {
          String desc = f.getDescription();
          if (desc != null && desc.trim().length() > 0) label.setText(desc);
          else {
            label.setText(UIUtilities.formatPartialName(EditorUtil.getPartialName(fileName)));
          }
          s = label.getText();
        } else {
          label.setText(UIUtilities.formatPartialName(EditorUtil.getPartialName(fileName)));
        }

        label.setToolTipText(formatToolTip(f, s));
        Iterator<CustomizedFileFilter> i = FILTERS.iterator();
        CustomizedFileFilter filter;
        long id = f.getId();
        while (i.hasNext()) {
          filter = i.next();
          if (filter.accept(fileName)) {
            if (id > 0) imageToLoad = LOAD_FROM_SERVER;
            else imageToLoad = LOAD_FROM_LOCAL;
            break;
          }
        }
        if (id < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
        switch (imageToLoad) {
          case LOAD_FROM_LOCAL:
            if (thumbnail == null) setThumbnail(f.getFilePath());
            break;
            /*
            case LOAD_FROM_SERVER:
            	if (thumbnail == null) {
            		model.loadFile((FileAnnotationData) data, this);
            	}
            	*/
        }
      } else if (data instanceof File) {
        File f = (File) data;
        label.setText(EditorUtil.getPartialName(f.getName()));
        label.setForeground(Color.BLUE);
      } else if (data instanceof TagAnnotationData) {
        TagAnnotationData tag = (TagAnnotationData) data;
        label.setText(tag.getTagValue());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof XMLAnnotationData) {
        XMLAnnotationData tag = (XMLAnnotationData) data;
        label.setText(EditorUtil.truncate(tag.getText(), TEXT_LENGTH, false));
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof TermAnnotationData) {
        TermAnnotationData tag = (TermAnnotationData) data;
        label.setText(tag.getTerm());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof LongAnnotationData) {
        LongAnnotationData tag = (LongAnnotationData) data;
        label.setText(tag.getContentAsString());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof DoubleAnnotationData) {
        DoubleAnnotationData tag = (DoubleAnnotationData) data;
        label.setText(tag.getContentAsString());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof BooleanAnnotationData) {
        BooleanAnnotationData tag = (BooleanAnnotationData) data;
        label.setText(tag.getContentAsString());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      } else if (data instanceof TimeAnnotationData) {
        TimeAnnotationData tag = (TimeAnnotationData) data;
        label.setText(tag.getContentAsString());
        label.setToolTipText(formatToolTip(tag, null));
        if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR);
      }
    }

    label.addMouseListener(
        new MouseAdapter() {

          /**
           * Posts an event to edit the file.
           *
           * @see MouseAdapter#mouseReleased(MouseEvent)
           */
          public void mouseReleased(MouseEvent e) {
            if (e.getClickCount() == 1 && e.isPopupTrigger()) {
              showMenu(label, e.getPoint());
            }
          }

          /**
           * Shows menu
           *
           * @see MouseAdapter#mouseReleased(MouseEvent)
           */
          public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) showMenu(label, e.getPoint());
          }
        });
  }