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);
}
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);
}
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);
}
}
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);
}
}
}
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 });
}
}
}
});
}
Aggregations