예제 #1
0
  /**
   * Clears the data to save.
   *
   * @see AnnotationUI#clearData()
   */
  protected void clearData() {
    if (!init) {
      buildGUI();
      init = true;
    }
    tagNames.clear();
    existingTags.clear();
    selectedValue = 0;
    if (!model.isMultiSelection()) selectedValue = model.getUserRating();
    initialValue = 0;
    otherRating.setText("");
    rating.removePropertyChangeListener(RatingComponent.RATE_PROPERTY, this);
    rating.setValue(selectedValue);
    rating.addPropertyChangeListener(RatingComponent.RATE_PROPERTY, this);

    publishedBox.setSelected(false);
    tagsPane.removeAll();
    tagsDocList.clear();
    DocComponent doc = new DocComponent(null, model);
    tagsDocList.add(doc);
    tagsPane.add(doc);
    docPane.removeAll();
    filesDocList.clear();
    doc = new DocComponent(null, model);
    filesDocList.add(doc);
    docPane.add(doc);
    tagFlag = false;
    docFlag = false;
    // double h = TableLayout.PREFERRED;
    // TableLayout layout = (TableLayout) content.getLayout();
    // layout.setRow(tagRow, h);
    content.revalidate();
    content.repaint();
    revalidate();
    repaint();
  }
예제 #2
0
  /**
   * Overridden to lay out the rating.
   *
   * @see AnnotationUI#buildUI()
   */
  protected void buildUI() {
    selectedValue = 0;
    String text = "";
    if (!model.isMultiSelection()) {
      selectedValue = model.getUserRating();
      int n = model.getRatingCount();
      if (n > 0) {
        text += "(avg:" + model.getRatingAverage() + " | " + n + " vote";
        if (n > 1) text += "s";
        text += ")";
      }
    }
    otherRating.setText(text);

    initialValue = selectedValue;
    rating.setValue(selectedValue);
    publishedBox.setSelected(model.hasBeenPublished());
    // Add attachments
    Collection l = model.getAttachments();
    int count = 0;
    /*
    List v = null;
    if (l != null) {
    	v = new ArrayList();
    	Iterator k = l.iterator();
    	FileAnnotationData data;
    	boolean b = false;
    	while (k.hasNext()) {
    		data = (FileAnnotationData) k.next();
    		b = isEditorFile(data.getFileName());
    		if (!b) b = isEditorFile(data.getNameSpace());
    		if (!b) v.add(data);
    	}
    	count += v.size();
    }
    */

    // Viewed by
    if (!model.isMultiSelection()) {
      l = model.getTags();
      if (l != null) count += l.size();
      layoutTags(l);
      l = model.getAttachments();
      if (l != null) count += l.size();
      layoutAttachments(l);
    } else {
      layoutTags(null);
      layoutAttachments(null);
    }
    filterButton.setEnabled(count > 0);
    // Allow to handle annotation.
    boolean enabled = model.canAnnotate();
    if (enabled && model.isMultiSelection()) {
      enabled = !model.isAcrossGroups();
    }
    rating.setEnabled(enabled);
    addTagsButton.setEnabled(enabled);
    addDocsButton.setEnabled(enabled);

    enabled = model.canDeleteAnnotationLink();
    removeTagsButton.setEnabled(enabled);
    removeDocsButton.setEnabled(enabled);
    enabled = model.canDelete(); // to be reviewed
    unrateButton.setEnabled(enabled);
    buildGUI();
  }
예제 #3
0
  /** Initializes the components composing the display. */
  private void initComponents() {
    toReplace = new ArrayList<FileAnnotationData>();
    IconManager icons = IconManager.getInstance();
    filter = SHOW_ALL;
    filterButton = new JButton(NAMES[SHOW_ALL]);
    filterButton.setToolTipText("Filter tags and attachments.");
    UIUtilities.unifiedButtonLookAndFeel(filterButton);
    Font font = filterButton.getFont();
    filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));

    filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12));

    filterButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    filterButton.addMouseListener(
        new MouseAdapter() {

          /**
           * Brings up the menu.
           *
           * @see MouseListener#mouseReleased(MouseEvent)
           */
          public void mouseReleased(MouseEvent me) {
            Object source = me.getSource();
            if (source instanceof Component) displayMenu((Component) source, me.getPoint());
          }
        });

    otherRating = new JLabel();
    otherRating.setBackground(UIUtilities.BACKGROUND_COLOR);
    font = otherRating.getFont();
    otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2));
    content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tagFlag = false;
    docFlag = false;
    tagNames = new ArrayList<String>();
    tagsDocList = new ArrayList<DocComponent>();
    filesDocList = new ArrayList<DocComponent>();
    existingTags = new HashMap<String, TagAnnotationData>();

    addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    UIUtilities.unifiedButtonLookAndFeel(addTagsButton);
    addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addTagsButton.setToolTipText("Add Tags.");
    addTagsButton.addActionListener(controller);
    addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS);
    addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addDocsButton.setToolTipText("Attach a document.");
    addDocsButton.addMouseListener(
        new MouseAdapter() {

          public void mouseReleased(MouseEvent e) {
            if (addDocsButton.isEnabled()) {
              Point p = e.getPoint();
              createDocSelectionMenu().show(addDocsButton, p.x, p.y);
            }
          }
        });
    UIUtilities.unifiedButtonLookAndFeel(addDocsButton);

    removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeTagsButton);
    removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeTagsButton.setToolTipText("Unlink Tags.");
    removeTagsButton.addMouseListener(controller);
    removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS);
    removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeDocsButton);
    removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeDocsButton.setToolTipText("Unlink Attachments.");
    removeDocsButton.addMouseListener(controller);
    removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS);

    selectedValue = 0;
    initialValue = selectedValue;
    rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE);
    rating.setOpaque(false);
    rating.setBackground(UIUtilities.BACKGROUND_COLOR);
    rating.addPropertyChangeListener(this);
    unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(unrateButton);
    unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    unrateButton.setToolTipText("Unrate.");
    unrateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rating.setValue(0);
            view.saveData(true);
          }
        });
    tagsPane = new JPanel();
    tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS));
    tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    DocComponent doc = new DocComponent(null, model);
    tagsDocList.add(doc);
    tagsPane.add(doc);
    docPane = new JPanel();
    docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS));
    docPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    docRef = docPane;
    doc = new DocComponent(null, model);
    filesDocList.add(doc);
    docPane.add(doc);
    publishedBox = new JCheckBox();
    publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    publishedBox.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE);
          }
        });
  }