use of com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT in project BiglyBT by BiglySoftware.
the class UIFunctionsImpl method openPluginView.
// @see UIFunctionsSWT#openPluginView(java.lang.String, java.lang.String, com.biglybt.ui.swt.pif.UISWTViewEventListener, java.lang.Object, boolean)
@Override
public void openPluginView(String sParentID, String sViewID, UISWTViewEventListener l, Object dataSource, boolean bSetFocus) {
try {
MultipleDocumentInterfaceSWT mdi = getMDISWT();
if (mdi != null) {
String sidebarParentID = null;
if (UISWTInstance.VIEW_MYTORRENTS.equals(sParentID)) {
sidebarParentID = SideBar.SIDEBAR_HEADER_TRANSFERS;
} else if (UISWTInstance.VIEW_MAIN.equals(sParentID)) {
sidebarParentID = MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS;
} else {
System.err.println("Can't find parent " + sParentID + " for " + sViewID);
}
MdiEntry entry = mdi.createEntryFromEventListener(sidebarParentID, l, sViewID, true, dataSource, null);
if (bSetFocus) {
mdi.showEntryByID(sViewID);
} else if (entry instanceof BaseMdiEntry) {
// Some plugins (CVS Updater) want their view's composite initialized
// on OpenPluginView, otherwise they won't do logic users expect
// (like check for new snapshots). So, enforce loading entry.
((BaseMdiEntry) entry).build();
}
}
} catch (Exception e) {
Logger.log(new LogEvent(LOGID, "openPluginView", e));
}
}
use of com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT in project BiglyBT by BiglySoftware.
the class SearchResultsTabArea method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(final SWTSkinObject skinObject, Object params) {
skin = skinObject.getSkin();
SWTSkinObjectContainer controlArea = (SWTSkinObjectContainer) skin.getSkinObject("searchresultstop", skinObject);
if (controlArea != null) {
if (isViewSwitchHidden) {
controlArea.setVisible(false);
} else {
Composite control_area = controlArea.getComposite();
soButtonWeb = skin.getSkinObject("searchresults-button-web", controlArea);
soButtonMeta = skin.getSkinObject("searchresults-button-meta", controlArea);
SWTSkinButtonUtility btnWeb = new SWTSkinButtonUtility(soButtonWeb);
btnWeb.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
isBrowserView = true;
COConfigurationManager.setParameter("Search View Is Web View", isBrowserView);
selectView(skinObject);
}
});
SWTSkinButtonUtility btnMeta = new SWTSkinButtonUtility(soButtonMeta);
btnMeta.addSelectionListener(new ButtonListenerAdapter() {
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
isBrowserView = false;
COConfigurationManager.setParameter("Search View Is Web View", isBrowserView);
selectView(skinObject);
}
});
}
}
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
mdi_entry = mdi.getEntryBySkinView(this);
if (mdi_entry != null) {
mdi_entry.setViewTitleInfo(this);
vitalityImage = mdi_entry.addVitalityImage("image.sidebar.vitality.dots");
if (vitalityImage != null) {
vitalityImage.setVisible(false);
}
}
}
browserSkinObject = (SWTSkinObjectBrowser) skin.getSkinObject("web-search-results", skinObject);
browserImpl.init(browserSkinObject);
nativeSkinObject = (SWTSkinObjectContainer) skin.getSkinObject("meta-search-results", skinObject);
nativeImpl.skinObjectInitialShow(skinObject, params);
selectView(skinObject);
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(final Core core) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
initCoreStuff(core);
}
});
}
});
return null;
}
use of com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT in project BiglyBT by BiglySoftware.
the class SBC_SubscriptionResultsView method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
initColumns(core);
}
});
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null && ds != null) {
String mdi_key = "Subscription_" + ByteFormatter.encodeString(ds.getPublicKey());
mdi_entry = mdi.getEntry(mdi_key);
if (mdi_entry != null) {
mdi_entry.addToolbarEnabler(this);
}
}
if (ds != null) {
if ((ds.getViewOptions() & Subscription.VO_HIDE_HEADER) != 0) {
SWTSkinObject top_area = getSkinObject("toparea");
top_area.setVisible(false);
}
SWTSkinObjectText title = (SWTSkinObjectText) getSkinObject("title");
if (title != null) {
title.setText(MessageText.getString("subs.results.view.title", new String[] { ds.getName() }));
Control control = title.getControl();
final Menu menu = new Menu(control);
control.setMenu(menu);
final String menu_key = SubscriptionMDIEntry.setupMenus(ds, null);
menu.addMenuListener(new MenuListener() {
@Override
public void menuShown(MenuEvent e) {
for (MenuItem mi : menu.getItems()) {
mi.dispose();
}
com.biglybt.pif.ui.menus.MenuItem[] menu_items = MenuItemManager.getInstance().getAllAsArray(menu_key);
MenuBuildUtils.addPluginMenuItems(menu_items, menu, true, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl(new Object[] { ds }));
}
@Override
public void menuHidden(MenuEvent e) {
// TODO Auto-generated method stub
}
});
}
}
SWTSkinObjectTextbox soFilterBox = (SWTSkinObjectTextbox) getSkinObject("filterbox");
if (soFilterBox != null) {
txtFilter = soFilterBox.getTextControl();
}
final SWTSkinObject soFilterArea = getSkinObject("filterarea");
if (soFilterArea != null) {
SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
if (soFilterButton != null) {
boolean toggled = COConfigurationManager.getBooleanParameter("Subscription 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("Subscription View Filter Options Expanded", toggled);
soFilterArea.setVisible(toggled);
Utils.relayout(soFilterArea.getControl().getParent());
}
});
}
Composite parent = (Composite) soFilterArea.getControl();
Label label;
FormData fd;
GridLayout layout;
int sepHeight = 20;
Composite cFilters = new Composite(parent, SWT.NONE);
fd = Utils.getFilledFormData();
cFilters.setLayoutData(fd);
layout = new GridLayout(1, true);
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
layout.marginWidth = layout.marginHeight = 0;
cFilters.setLayout(layout);
SubscriptionResultFilter filters = null;
Runnable pFilterUpdater = null;
if (ds != null && ds.isUpdateable()) {
try {
filters = ds.getFilters();
Composite pFilters = new Composite(cFilters, SWT.NONE);
pFilters.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
layout = new GridLayout(1, false);
layout.marginBottom = layout.marginTop = layout.marginLeft = layout.marginRight = 0;
layout.marginWidth = layout.marginHeight = 0;
pFilters.setLayout(layout);
final Label pflabel = new Label(pFilters, SWT.NONE);
pflabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final SubscriptionResultFilter f_filters = filters;
pFilterUpdater = new Runnable() {
@Override
public void run() {
long kInB = DisplayFormatters.getKinB();
long mInB = kInB * kInB;
long min_size = f_filters.getMinSze() / mInB;
long max_size = f_filters.getMaxSize() / mInB;
pflabel.setText(MessageText.getString("subs.persistent.filters", new String[] { getString(f_filters.getWithWords()), getString(f_filters.getWithoutWords()), String.valueOf(min_size < 0 ? 0 : min_size), String.valueOf(max_size < 0 ? 0 : max_size) }));
}
};
pFilterUpdater.run();
} catch (Throwable e) {
Debug.out(e);
}
}
Composite vFilters = new Composite(cFilters, SWT.NONE);
vFilters.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;
vFilters.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(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
}
Composite cWithKW = new Composite(vFilters, 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 textWithKW = new Text(cWithKW, SWT.BORDER);
textWithKW.setMessage(MessageText.getString(with ? "SubscriptionResults.filter.with.words" : "SubscriptionResults.filter.without.words"));
GridData gd = new GridData();
gd.widthHint = Utils.adjustPXForDPI(100);
textWithKW.setLayoutData(gd);
textWithKW.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = textWithKW.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(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMinSize = new Composite(vFilters, 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"));
Spinner 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_dispatcher.dispatch();
}
});
// max size
label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
Composite cMaxSize = new Composite(vFilters, 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"));
Spinner 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_dispatcher.dispatch();
}
});
if (filters != null) {
label = new Label(vFilters, SWT.VERTICAL | SWT.SEPARATOR);
label.setLayoutData(new RowData(-1, sepHeight));
final SubscriptionResultFilter f_filters = filters;
final Runnable f_pFilterUpdater = pFilterUpdater;
Button save = new Button(vFilters, SWT.PUSH);
save.setText(MessageText.getString("ConfigView.button.save"));
save.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
try {
long kInB = DisplayFormatters.getKinB();
long mInB = kInB * kInB;
f_filters.update(with_keywords, without_keywords, minSize * mInB, maxSize * mInB);
f_pFilterUpdater.run();
} catch (Throwable e) {
Debug.out(e);
}
}
});
}
parent.layout(true);
}
return null;
}
use of com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT in project BiglyBT by BiglySoftware.
the class SBC_GenericBrowsePage method skinObjectInitialShow.
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
Object creationParams = skinObject.getData("CreationParams");
browserSkinObject = SWTSkinUtils.findBrowserSO(soMain);
final MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
entry = mdi.getEntryBySkinView(this);
if (entry != null) {
vitalityImage = entry.addVitalityImage("image.sidebar.vitality.dots");
vitalityImage.setVisible(false);
mdi.addListener(new MdiListener() {
long lastSelect = 0;
@Override
public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
if (entry == newEntry) {
if (entry == oldEntry) {
if (lastSelect < SystemTime.getOffsetTime(-1000)) {
if (browserSkinObject != null) {
browserSkinObject.restart();
}
}
} else {
lastSelect = SystemTime.getCurrentTime();
}
}
}
@Override
public void mdiDisposed(MultipleDocumentInterface mdi) {
}
});
}
}
browserSkinObject.addListener(new SWTSkinObjectListener() {
@Override
public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
if (eventType == EVENT_SHOW) {
browserSkinObject.removeListener(this);
browserSkinObject.addListener(new BrowserContext.loadingListener() {
@Override
public void browserLoadingChanged(boolean loading, String url) {
if (vitalityImage != null) {
vitalityImage.setVisible(loading);
}
}
});
} else if (eventType == EVENT_DATASOURCE_CHANGED) {
if (params instanceof String) {
browserSkinObject.setURL((String) params);
}
}
return null;
}
});
openURL();
return null;
}
use of com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT in project BiglyBT by BiglySoftware.
the class SBC_TagDiscovery method skinObjectInitialShow.
// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
mapConfig = FileUtil.readResilientConfigFile(CONFIG_FILE);
soTitle = (SWTSkinObjectText) getSkinObject("title");
SWTSkinObjectButton soScanButton = (SWTSkinObjectButton) getSkinObject("scan-button");
if (soScanButton != null) {
soScanButton.addSelectionListener(new SWTSkinButtonUtility.ButtonListenerAdapter() {
// @see SWTSkinButtonUtility.ButtonListenerAdapter#pressed(SWTSkinButtonUtility, SWTSkinObject, int)
@Override
public void pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
startScan();
}
});
}
final SWTSkinObject soFilterArea = getSkinObject("filterarea");
if (soFilterArea != null) {
SWTSkinObjectToggle soFilterButton = (SWTSkinObjectToggle) getSkinObject("filter-button");
if (soFilterButton != null) {
soFilterButton.addSelectionListener(new SWTSkinToggleListener() {
@Override
public void toggleChanged(SWTSkinObjectToggle so, boolean toggled) {
soFilterArea.setVisible(toggled);
Utils.relayout(soFilterArea.getControl().getParent());
}
});
}
}
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
entry = mdi.getEntry(MultipleDocumentInterface.SIDEBAR_SECTION_TAG_DISCOVERY);
if (entry != null) {
entry.setViewTitleInfo(this);
vitalityImage = entry.addVitalityImage(ID_VITALITY_ACTIVE);
if (vitalityImage != null) {
vitalityImage.setVisible(false);
}
}
}
initColumns();
return null;
}
Aggregations