예제 #1
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);
          }
        });
  }