Search in sources :

Example 6 with TagPainter

use of com.biglybt.ui.swt.widgets.TagPainter in project BiglyBT by BiglySoftware.

the class TagButtonsUI method updateTag.

public int updateTag(Tag tag, List<Taggable> taggables) {
    if (cMainComposite == null || cMainComposite.isDisposed()) {
        return UPDATETAG_NOCHANGE;
    }
    for (TagCanvas tagWidget : tagWidgets) {
        TagPainter painter = tagWidget.getTagPainter();
        if (tag.equals(painter.getTag())) {
            Composite parent = tagWidget.getParent();
            String oldGroup = (parent instanceof Group) ? ((Group) parent).getText() : "";
            String newGroup = painter.getTag().getGroup();
            if (newGroup == null) {
                newGroup = "";
            }
            if (!oldGroup.equals(newGroup)) {
                return UPDATETAG_REQUIRES_REBUILD;
            }
            painter.updateState(taggables);
            return UPDATETAG_SUCCESS;
        }
    }
    return UPDATETAG_SUCCESS;
}
Also used : ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TagCanvas(com.biglybt.ui.swt.widgets.TagCanvas) TagPainter(com.biglybt.ui.swt.widgets.TagPainter)

Example 7 with TagPainter

use of com.biglybt.ui.swt.widgets.TagPainter in project BiglyBT by BiglySoftware.

the class TagButtonsUI method setSelectedTags.

public void setSelectedTags(List<Tag> tags) {
    Set<Tag> tag_set = new HashSet<>(tags);
    for (TagCanvas widget : tagWidgets) {
        TagPainter painter = widget.getTagPainter();
        Tag tag = painter.getTag();
        if (tag == null) {
            continue;
        }
        boolean select = tag_set.contains(tag);
        painter.setSelected(select);
    }
}
Also used : TagCanvas(com.biglybt.ui.swt.widgets.TagCanvas) TagPainter(com.biglybt.ui.swt.widgets.TagPainter) Tag(com.biglybt.core.tag.Tag)

Aggregations

TagPainter (com.biglybt.ui.swt.widgets.TagPainter)7 TagCanvas (com.biglybt.ui.swt.widgets.TagCanvas)4 TagButtonsUI (com.biglybt.ui.swt.views.utils.TagButtonsUI)2 TagButtonTrigger (com.biglybt.ui.swt.widgets.TagCanvas.TagButtonTrigger)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Category (com.biglybt.core.category.Category)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 Tag (com.biglybt.core.tag.Tag)1 SkinnedDialog (com.biglybt.ui.swt.views.skin.SkinnedDialog)1 StandardButtonsArea (com.biglybt.ui.swt.views.skin.StandardButtonsArea)1 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 MenuAdapter (org.eclipse.swt.events.MenuAdapter)1 MenuDetectEvent (org.eclipse.swt.events.MenuDetectEvent)1