use of com.biglybt.ui.swt.views.utils.TagButtonsUI.TagButtonTrigger in project BiglyBT by BiglySoftware.
the class TaggingView method initialize.
private void initialize() {
if (cMainComposite == null || cMainComposite.isDisposed()) {
if (parent == null || parent.isDisposed()) {
return;
}
sc = new ScrolledComposite(parent, SWT.V_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.getVerticalBar().setIncrement(16);
Layout parentLayout = parent.getLayout();
if (parentLayout instanceof GridLayout) {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
sc.setLayoutData(gd);
} else if (parentLayout instanceof FormLayout) {
sc.setLayoutData(Utils.getFilledFormData());
}
cMainComposite = new Composite(sc, SWT.NONE);
sc.setContent(cMainComposite);
} else {
Utils.disposeComposite(cMainComposite, false);
}
cMainComposite.setLayout(new GridLayout(1, false));
TagManager tm = TagManagerFactory.getTagManager();
int[] tagTypesWanted = { TagType.TT_DOWNLOAD_MANUAL // TagType.TT_DOWNLOAD_CATEGORY
};
tagButtonsUI = new TagButtonsUI();
List<Tag> listAllTags = new ArrayList<>();
for (int tagType : tagTypesWanted) {
TagType tt = tm.getTagType(tagType);
List<Tag> tags = tt.getTags();
listAllTags.addAll(tags);
}
tagButtonsUI.buildTagGroup(listAllTags, cMainComposite, new TagButtonTrigger() {
@Override
public void tagButtonTriggered(Tag tag, boolean doTag) {
for (Taggable taggable : taggables) {
if (doTag) {
tag.addTaggable(taggable);
} else {
tag.removeTaggable(taggable);
}
swt_updateFields();
}
}
});
Button buttonAdd = new Button(cMainComposite, SWT.PUSH);
buttonAdd.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false));
Messages.setLanguageText(buttonAdd, "label.add.tag");
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
TagUIUtils.createManualTag(new TagReturner() {
@Override
public void returnedTags(Tag[] tags) {
if (taggables == null) {
return;
}
for (Tag tag : tags) {
for (Taggable taggable : taggables) {
tag.addTaggable(taggable);
}
}
}
});
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
sc.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = sc.getClientArea();
Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
sc.setMinSize(size);
}
});
swt_updateFields();
Rectangle r = sc.getClientArea();
Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
sc.setMinSize(size);
}
Aggregations