use of com.biglybt.ui.swt.skin.SWTSkinToggleListener in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method skinObjectInitialShow.
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
image_loader = new ImageLoader(null, null);
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
initColumns(core);
}
});
SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
if (soFilterBox != null) {
txtFilter = soFilterBox.getTextControl();
}
if (vitality_images == null) {
ImageLoader loader = ImageLoader.getInstance();
vitality_images = loader.getImages("image.sidebar.vitality.dots");
ok_image = loader.getImage("tick_mark");
fail_image = loader.getImage("progress_cancel");
auth_image = loader.getImage("image.sidebar.vitality.auth");
}
final SWTSkinObject soFilterArea = getSkinObject("filterarea");
if (soFilterArea != null) {
SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
if (soFilterButton != null) {
boolean toggled = COConfigurationManager.getBooleanParameter("Search View Filter Options Expanded", false);
if (toggled) {
soFilterButton.setToggled(true);
soFilterArea.setVisible(true);
}
soFilterButton.addSelectionListener(new SWTSkinToggleListener() {
@Override
public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
COConfigurationManager.setParameter("Search View Filter Options Expanded", toggled);
soFilterArea.setVisible(toggled);
Utils.relayout(soFilterArea.getControl().getParent());
}
});
}
Composite parent = (Composite) soFilterArea.getControl();
Composite filter_area = new Composite(parent, SWT.NONE);
FormData fd = Utils.getFilledFormData();
filter_area.setLayoutData(fd);
GridLayout layout = new GridLayout();
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
filter_area.setLayout(layout);
Label label;
int sepHeight = 20;
Composite cRow = new Composite(filter_area, SWT.NONE);
cRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.spacing = 5;
rowLayout.marginBottom = rowLayout.marginTop = rowLayout.marginLeft = rowLayout.marginRight = 0;
rowLayout.center = true;
cRow.setLayout(rowLayout);
// with/without keywords
ImageLoader imageLoader = ImageLoader.getInstance();
for (int i = 0; i < 2; i++) {
final boolean with = i == 0;
if (!with) {
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
}
Composite cWithKW = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cWithKW.setLayout(layout);
// Label lblWithKW = new Label(cWithKW, SWT.NONE);
// lblWithKW.setText(MessageText.getString(with?"SubscriptionResults.filter.with.words":"SubscriptionResults.filter.without.words"));
Label lblWithKWImg = new Label(cWithKW, SWT.NONE);
lblWithKWImg.setImage(imageLoader.getImage(with ? "icon_filter_plus" : "icon_filter_minus"));
final Text textWidget = new Text(cWithKW, SWT.BORDER);
if (with) {
textWithKW = textWidget;
} else {
textWithoutKW = textWidget;
}
textWidget.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
GridData gd = new GridData();
gd.widthHint = Utils.adjustPXForDPI(100);
textWidget.setLayoutData(gd);
textWidget.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = textWidget.getText().toLowerCase(Locale.US);
String[] bits = text.split("\\s+");
Set<String> temp = new HashSet<>();
for (String bit : bits) {
bit = bit.trim();
if (bit.length() > 0) {
temp.add(bit);
}
}
String[] words = temp.toArray(new String[temp.size()]);
synchronized (filter_lock) {
if (with) {
with_keywords = words;
} else {
without_keywords = words;
}
}
refilter_dispatcher.dispatch();
}
});
}
// min size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMinSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMinSize.setLayout(layout);
Label lblMinSize = new Label(cMinSize, SWT.NONE);
lblMinSize.setText(MessageText.getString("SubscriptionResults.filter.min_size"));
spinMinSize = new Spinner(cMinSize, SWT.BORDER);
spinMinSize.setMinimum(0);
// 100 TB should do...
spinMinSize.setMaximum(100 * 1024 * 1024);
spinMinSize.setSelection(minSize);
spinMinSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
minSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
// max size
label = new Label(cRow, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMaxSize = new Composite(cRow, SWT.NONE);
layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
cMaxSize.setLayout(layout);
Label lblMaxSize = new Label(cMaxSize, SWT.NONE);
lblMaxSize.setText(MessageText.getString("SubscriptionResults.filter.max_size"));
spinMaxSize = new Spinner(cMaxSize, SWT.BORDER);
spinMaxSize.setMinimum(0);
// 100 TB should do...
spinMaxSize.setMaximum(100 * 1024 * 1024);
spinMaxSize.setSelection(maxSize);
spinMaxSize.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
maxSize = ((Spinner) event.widget).getSelection();
refilter();
}
});
engine_area = new Composite(filter_area, SWT.NONE);
engine_area.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
buildEngineArea(null);
parent.layout(true);
}
return null;
}
Aggregations