Esempio n. 1
0
 @Override
 public void mouseDown(MouseEvent e) {
   if (((e.stateMask & SWT.CTRL) == SWT.CTRL) || ((e.stateMask & SWT.COMMAND) == SWT.COMMAND)) {
     setSelected(!selected, true);
   } else if ((e.stateMask & SWT.SHIFT) == SWT.SHIFT) {
     parentTagPanel.multipleSelection(this);
   } else {
     if (TagPanel.isSelectionEmpty()) {
       setSelected(!selected, true);
     } else {
       TagPanel.clearSelection(false);
       setSelected(!selected, true);
     }
   }
 }
Esempio n. 2
0
 public void setSelected(boolean value, boolean enableNotification) {
   selected = value;
   if (selected) {
     setBackground(selectionBackground);
     textLabel.setForeground(white);
     parentTagPanel.addToSelection(this, enableNotification);
   } else {
     setBackground(unselectedBackground);
     int rgb[] = ColorMap.get().getRGB(tag.getColorName());
     if (rgb == null) {
       rgb = ColorMap.get().getRGB("Black");
     }
     textLabel.setForeground(new Color(getDisplay(), rgb[0], rgb[1], rgb[2]));
     parentTagPanel.removeFromSelection(this, false);
   }
 }
Esempio n. 3
0
  TagLabel(
      String s, int size, int roundedness, TagPanel tagPanel, boolean global, boolean deletable) {
    super();
    _tagText = s;
    _size = size;
    _roundedness = roundedness;
    _tagPanel = tagPanel;
    _global = global;
    _deletable = deletable;
    _tag = new JLabel(Writer.shortenText(_tagText));
    _tag.setBorder(BorderFactory.createEmptyBorder(1, 1, 3, 1));
    _tag.setFont(new Font("Sans Serif", Font.PLAIN, _size + 2));
    _tag.setForeground(GuiConstants.PRIMARY_FONT_COLOR);

    if (_deletable) {
      ImageIcon current = IconFactory.loadIcon(IconType.DELETE, _size, true);
      _delete = new JLabel(current);
      _delete.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
      _delete.addMouseListener(this);
      add(_delete);
    }
    add(_tag);
    setBackground(global ? GuiConstants.SET_TAG_COLOR : GuiConstants.CARD_TAG_COLOR);
    setOpaque(false);

    _tagPanel._tags.add(this);
    _tagPanel.add(this);
  }
Esempio n. 4
0
 @Override
 public void addMouseListener(MouseListener ml) {
   _tag.addMouseListener(ml);
   if (_deletable) _delete.addMouseListener(ml);
   _tagPanel.addMouseListener(ml);
 }
Esempio n. 5
0
 @Override
 public void mouseReleased(MouseEvent e) {
   if (_deletable) _tagPanel.deleteTag(this);
 }