Search in sources :

Example 41 with Tag

use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.

the class TagColorsItem method refresh.

@Override
public void refresh(TableCell cell) {
    String sTags = null;
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm != null) {
        List<Tag> tags = tag_manager.getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL, dm);
        if (tags.size() > 0) {
            for (Tag t : tags) {
                String str = t.getTagName(true);
                if (sTags == null) {
                    sTags = str;
                } else {
                    sTags += ", " + str;
                }
            }
        }
    }
    cell.setSortValue(sTags);
    cell.setToolTip((sTags == null) ? "" : sTags);
}
Also used : Tag(com.biglybt.core.tag.Tag) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 42 with Tag

use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.

the class TagsItem method refresh.

@Override
public void refresh(TableCell cell) {
    String sTags = null;
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm != null) {
        List<Tag> tags = tag_manager.getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL, dm);
        if (tags.size() > 0) {
            tags = TagUIUtils.sortTags(tags);
            for (Tag t : tags) {
                String str = t.getTagName(true);
                if (sTags == null) {
                    sTags = str;
                } else {
                    sTags += ", " + str;
                }
            }
        }
    }
    cell.setText((sTags == null) ? "" : sTags);
}
Also used : Tag(com.biglybt.core.tag.Tag) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 43 with Tag

use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.

the class TagButtonsUI method buildTagGroup.

public void buildTagGroup(List<Tag> tags, Composite cMainComposite, final TagButtonTrigger trigger) {
    this.cMainComposite = cMainComposite;
    cMainComposite.setLayout(new GridLayout(1, false));
    buttons = new ArrayList<>();
    SelectionListener selectionListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.widget;
            Tag tag = (Tag) button.getData("Tag");
            if (button.getGrayed()) {
                button.setGrayed(false);
                button.setSelection(!button.getSelection());
                button.getParent().redraw();
            }
            boolean doTag = button.getSelection();
            trigger.tagButtonTriggered(tag, doTag);
            button.getParent().redraw();
            button.getParent().update();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
    Listener menuDetectListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            final Button button = (Button) event.widget;
            Menu menu = new Menu(button);
            button.setMenu(menu);
            MenuBuildUtils.addMaintenanceListenerForMenu(menu, new MenuBuilder() {

                @Override
                public void buildMenu(final Menu menu, MenuEvent menuEvent) {
                    Tag tag = (Tag) button.getData("Tag");
                    TagUIUtils.createSideBarMenuItems(menu, tag);
                }
            });
        }
    };
    tags = TagUIUtils.sortTags(tags);
    Composite g = null;
    String group = null;
    for (Tag tag : tags) {
        String newGroup = tag.getGroup();
        if (g == null || (group != null && !group.equals(newGroup)) || (group == null && newGroup != null)) {
            group = newGroup;
            g = group == null ? new Composite(cMainComposite, SWT.DOUBLE_BUFFERED) : new Group(cMainComposite, SWT.DOUBLE_BUFFERED);
            if (group != null) {
                ((Group) g).setText(group);
            }
            g.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            RowLayout rowLayout = new RowLayout();
            rowLayout.pack = true;
            rowLayout.spacing = 5;
            Utils.setLayout(g, rowLayout);
        }
        Composite p = new Composite(g, SWT.DOUBLE_BUFFERED);
        GridLayout layout = new GridLayout(1, false);
        layout.marginHeight = 3;
        if (Constants.isWindows) {
            layout.marginWidth = 6;
            layout.marginLeft = 2;
            layout.marginTop = 1;
        } else {
            layout.marginWidth = 0;
            layout.marginLeft = 3;
            layout.marginRight = 11;
        }
        p.setLayout(layout);
        p.addPaintListener(this);
        Button button = new Button(p, SWT.CHECK);
        buttons.add(button);
        boolean[] auto = tag.isTagAuto();
        if (auto[0] && auto[1]) {
            button.setEnabled(false);
        } else {
            button.addSelectionListener(selectionListener);
        }
        button.setData("Tag", tag);
        button.addListener(SWT.MenuDetect, menuDetectListener);
        button.addPaintListener(this);
    }
}
Also used : MenuBuilder(com.biglybt.ui.swt.MenuBuildUtils.MenuBuilder) GridLayout(org.eclipse.swt.layout.GridLayout) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Tag(com.biglybt.core.tag.Tag)

Example 44 with Tag

use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.

the class TagButtonsUI method paintControl.

@Override
public void paintControl(PaintEvent e) {
    Button button;
    Composite c = null;
    if (e.widget instanceof Composite) {
        c = (Composite) e.widget;
        button = (Button) c.getChildren()[0];
    } else {
        button = (Button) e.widget;
    }
    Tag tag = (Tag) button.getData("Tag");
    if (tag == null) {
        return;
    }
    if (c != null) {
        boolean checked = button.getSelection();
        Point size = c.getSize();
        Point sizeButton = button.getSize();
        e.gc.setAntialias(SWT.ON);
        e.gc.setForeground(ColorCache.getColor(e.display, tag.getColor()));
        int lineWidth = button.getSelection() ? 2 : 1;
        e.gc.setLineWidth(lineWidth);
        int curve = 20;
        int width = sizeButton.x + lineWidth + 1;
        width += Constants.isOSX ? 5 : curve / 2;
        if (checked) {
            e.gc.setAlpha(0x20);
            e.gc.setBackground(ColorCache.getColor(e.display, tag.getColor()));
            e.gc.fillRoundRectangle(-curve, lineWidth - 1, width + curve, size.y - lineWidth, curve, curve);
            e.gc.setAlpha(0xff);
        }
        if (!checked) {
            e.gc.setAlpha(0x80);
        }
        e.gc.drawRoundRectangle(-curve, lineWidth - 1, width + curve, size.y - lineWidth, curve, curve);
        e.gc.drawLine(lineWidth - 1, lineWidth, lineWidth - 1, size.y - lineWidth);
    } else {
        if (!Constants.isOSX && button.getSelection()) {
            Point size = button.getSize();
            e.gc.setBackground(ColorCache.getColor(e.display, tag.getColor()));
            e.gc.setAlpha(20);
            e.gc.fillRectangle(0, 0, size.x, size.y);
        }
    }
}
Also used : Tag(com.biglybt.core.tag.Tag) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 45 with Tag

use of com.biglybt.core.tag.Tag in project BiglyBT by BiglySoftware.

the class CategoryUIUtils method showCreateCategoryDialog.

public static void showCreateCategoryDialog(final UIFunctions.TagReturner tagReturner) {
    SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("CategoryAddWindow.title", "CategoryAddWindow.message");
    entryWindow.setParentShell(Utils.findAnyShell());
    entryWindow.prompt(new UIInputReceiverListener() {

        @Override
        public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
            if (entryWindow.hasSubmittedInput()) {
                TagUIUtils.checkTagSharing(false);
                Category newCategory = CategoryManager.createCategory(entryWindow.getSubmittedInput());
                if (tagReturner != null) {
                    tagReturner.returnedTags(new Tag[] { newCategory });
                }
            }
        }
    });
}
Also used : Category(com.biglybt.core.category.Category) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) Tag(com.biglybt.core.tag.Tag)

Aggregations

Tag (com.biglybt.core.tag.Tag)55 DownloadManager (com.biglybt.core.download.DownloadManager)15 TagFeatureRateLimit (com.biglybt.core.tag.TagFeatureRateLimit)12 File (java.io.File)9 TagManager (com.biglybt.core.tag.TagManager)8 TagType (com.biglybt.core.tag.TagType)8 ArrayList (java.util.ArrayList)8 List (java.util.List)5 Core (com.biglybt.core.Core)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 PEPeerManager (com.biglybt.core.peer.PEPeerManager)4 TagFeatureFileLocation (com.biglybt.core.tag.TagFeatureFileLocation)4 Point (org.eclipse.swt.graphics.Point)4 Category (com.biglybt.core.category.Category)3 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)3 DownloadManagerInitialisationAdapter (com.biglybt.core.download.DownloadManagerInitialisationAdapter)3 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)3 TOTorrent (com.biglybt.core.torrent.TOTorrent)3 Download (com.biglybt.pif.download.Download)3 GlobalManager (com.biglybt.core.global.GlobalManager)2