use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class MainStatusBar method updateUI.
@Override
public void updateUI(boolean is_visible) {
if (statusBar.isDisposed()) {
return;
}
// see if this fixes occasional issue with status bar vanishing when bringing back from taskbar/tray
boolean is_hidden = (!is_visible) || statusBar.getDisplay().getFocusControl() == null;
if (is_hidden) {
was_hidden = true;
} else {
if (was_hidden) {
statusBar.layout(true, true);
was_hidden = false;
}
}
if (!is_visible) {
return;
}
// Plugins.
Control[] plugin_elements = this.plugin_label_composite.getChildren();
for (int i = 0; i < plugin_elements.length; i++) {
if (plugin_elements[i] instanceof UpdateableCLabel) {
((UpdateableCLabel) plugin_elements[i]).checkForRefresh();
}
}
if (ipBlocked.isVisible()) {
updateIPBlocked();
}
if (srStatus.isVisible()) {
updateShareRatioStatus();
}
if (natStatus.isVisible()) {
updateNatStatus();
}
if (dhtStatus.isVisible()) {
updateDHTStatus();
}
// UL/DL Status Sections
if (CoreFactory.isCoreRunning()) {
Core core = CoreFactory.getSingleton();
GlobalManager gm = core.getGlobalManager();
GlobalManagerStats stats = gm.getStats();
int dl_limit = NetworkManager.getMaxDownloadRateBPS() / 1024;
long rec_data = stats.getDataReceiveRate();
long rec_prot = stats.getProtocolReceiveRate();
if (last_dl_limit != dl_limit || last_rec_data != rec_data || last_rec_prot != rec_prot) {
last_dl_limit = dl_limit;
last_rec_data = rec_data;
last_rec_prot = rec_prot;
statusDown.setText((dl_limit == 0 ? "" : "[" + dl_limit + "K] ") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(rec_data, rec_prot));
}
boolean auto_up = TransferSpeedValidator.isAutoSpeedActive(gm) && TransferSpeedValidator.isAutoUploadAvailable(core);
int ul_limit_norm = NetworkManager.getMaxUploadRateBPSNormal() / 1024;
String seeding_only;
if (NetworkManager.isSeedingOnlyUploadRate()) {
int ul_limit_seed = NetworkManager.getMaxUploadRateBPSSeedingOnly() / 1024;
if (ul_limit_seed == 0) {
seeding_only = "+" + Constants.INFINITY_STRING + "K";
} else {
int diff = ul_limit_seed - ul_limit_norm;
seeding_only = (diff >= 0 ? "+" : "") + diff + "K";
}
} else {
seeding_only = "";
}
int sent_data = stats.getDataSendRate();
if (imgRec != null && !imgRec.isDisposed()) {
updateGraph(statusDown, imgRec, rec_data, max_rec);
updateGraph(statusUp, imgSent, sent_data, max_sent);
}
statusUp.setText((ul_limit_norm == 0 ? "" : "[" + ul_limit_norm + "K" + seeding_only + "]") + (auto_up ? "* " : " ") + DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(sent_data, stats.getProtocolSendRate()));
}
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class OpenTorrentWindow method main.
public static void main(String[] args) {
Core core = CoreFactory.create();
core.start();
UIConfigDefaultsSWT.initialize();
// try {
// SWTThread.createInstance(null);
// } catch (SWTThreadAlreadyInstanciatedException e) {
// e.printStackTrace();
// }
Display display = Display.getDefault();
Colors.getInstance();
COConfigurationManager.setParameter("User Mode", 2);
UIFunctionsImpl uiFunctions = new UIFunctionsImpl(null);
UIFunctionsManager.setUIFunctions(uiFunctions);
// invoke(null, core.getGlobalManager());
OpenTorrentWindow window = new OpenTorrentWindow(null);
while (!window.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
core.stop();
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class RemotePairingWindow method open.
public static void open() {
if (DEBUG) {
if (testPairingClass == null) {
testPairingClass = new testPairingClass();
} else {
testPairingClass.inc();
}
}
final RemotePairingWindow inst;
synchronized (RemotePairingWindow.class) {
if (instance == null) {
instance = new RemotePairingWindow();
}
inst = instance;
}
CoreWaiterSWT.waitForCore(TriggerInThread.SWT_THREAD, new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
inst._open();
}
});
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class DebugMenuHelper method createDebugMenuItem.
/**
* Creates the Debug menu and its children
* NOTE: This is a development only menu and so it's not modularized into separate menu items
* because this menu is always rendered in its entirety
* @param menu
* @param mainWindow
* @return
*/
public static MenuItem createDebugMenuItem(final Menu menuDebug) {
MenuItem item;
final UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (null == uiFunctions) {
throw new IllegalStateException("UIFunctionsManagerSWT.getUIFunctionsSWT() is returning null");
}
item = new MenuItem(menuDebug, SWT.CASCADE);
item.setText("Run GC");
item.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
System.gc();
}
});
item = new MenuItem(menuDebug, SWT.PUSH);
item.setText("&CoreReq");
item.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
new MessageBoxShell(0, "Done", "Core Now Avail").open(null);
}
});
}
});
/*
item = new MenuItem(menuDebug, SWT.CASCADE);
item.setText("Subscriptions");
Menu menuSubscriptions = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
item.setMenu(menuSubscriptions);
item = new MenuItem(menuSubscriptions, SWT.NONE);
item.setText("Create RSS Feed");
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final Shell shell = new Shell(uiFunctions.getMainShell());
shell.setLayout(new FormLayout());
Label label = new Label(shell,SWT.NONE);
label.setText("RSS Feed URL :");
final Text urlText = new Text(shell,SWT.BORDER);
urlText.setText(Utils.getLinkFromClipboard(shell.getDisplay(),false));
Label separator = new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL);
Button cancel = new Button(shell,SWT.PUSH);
cancel.setText("Cancel");
Button ok = new Button(shell,SWT.PUSH);
ok.setText("Ok");
FormData data;
data = new FormData();
data.left = new FormAttachment(0,5);
data.right = new FormAttachment(100,-5);
data.top = new FormAttachment(0,5);
label.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0,5);
data.right = new FormAttachment(100,-5);
data.top = new FormAttachment(label);
data.width = 400;
urlText.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0,5);
data.right = new FormAttachment(100,-5);
data.top = new FormAttachment(urlText);
separator.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(ok);
data.width = 100;
data.top = new FormAttachment(separator);
cancel.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(100,-5);
data.width = 100;
data.top = new FormAttachment(separator);
ok.setLayoutData(data);
cancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
shell.dispose();
}
});
ok.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
String url_str = urlText.getText();
shell.dispose();
try{
URL url = new URL( url_str );
SubscriptionManagerFactory.getSingleton().createSingletonRSS( url_str, url, 120, true );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
});
shell.pack();
Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());
shell.open();
shell.setFocus();
urlText.setFocus();
}
});
*/
item = new MenuItem(menuDebug, SWT.CASCADE);
item.setText("DW");
Menu menuBrowserTB = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
item.setMenu(menuBrowserTB);
item = new MenuItem(menuBrowserTB, SWT.NONE);
item.setText("popup check");
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean oldDebug = DonationWindow.DEBUG;
DonationWindow.DEBUG = true;
DonationWindow.checkForDonationPopup();
DonationWindow.DEBUG = oldDebug;
}
});
item = new MenuItem(menuBrowserTB, SWT.NONE);
item.setText("show");
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean oldDebug = DonationWindow.DEBUG;
DonationWindow.DEBUG = true;
DonationWindow.open(true, "debug");
DonationWindow.DEBUG = oldDebug;
}
});
item = new MenuItem(menuDebug, SWT.NONE);
item.setText("Alerts");
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String text = "This is a long message with lots of information and " + "stuff you really should read. Are you still reading? Good, because " + "reading <a href=\"http://moo.com\">stimulates</a> the mind.\n\nYeah Baby.";
LogAlert logAlert = new LogAlert(true, LogAlert.AT_INFORMATION, "Simple");
Logger.log(logAlert);
logAlert = new LogAlert(true, LogAlert.AT_WARNING, text);
logAlert.details = "Details: \n\n" + text;
Logger.log(logAlert);
logAlert = new LogAlert(true, LogAlert.AT_ERROR, "ShortText");
logAlert.details = "Details";
Logger.log(logAlert);
}
});
item = new MenuItem(menuDebug, SWT.NONE);
item.setText("MsgBox");
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
VuzeMessageBox box = new VuzeMessageBox("Title", "Text", new String[] { "Ok", "Cancel" }, 0);
box.setListener(new VuzeMessageBoxListener() {
@Override
public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
SWTSkin skin = soExtra.getSkin();
skin.createSkinObject("dlg.generic.test", "dlg.generic.test", soExtra);
skin.layout(soExtra);
shell.layout(true, true);
}
});
box.open(null);
}
});
item = new MenuItem(menuDebug, SWT.CASCADE);
item.setText("Size");
Menu menuSize = new Menu(menuDebug.getParent(), SWT.DROP_DOWN);
item.setMenu(menuSize);
int[] sizes = { 640, 430, 800, 550, 1024, 718, 1280, 700, 1440, 850, 1600, 1050, 1920, 1150 };
for (int i = 0; i < sizes.length; i += 2) {
final int x = sizes[i];
final int y = sizes[i + 1];
item = new MenuItem(menuSize, SWT.NONE);
item.setText("" + x + "," + y);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell().setSize(x, y);
}
});
}
item = new MenuItem(menuDebug, SWT.NONE);
item.setText("Obfuscated Shell Image");
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
Display display = Display.getCurrent();
java.util.List<Image> shell_images = UIDebugGenerator.getShellImages();
Image biggest_image = null;
long biggest_area = 0;
for (Image image : shell_images) {
Shell shell2 = new Shell(display);
Rectangle bounds = image.getBounds();
long area = bounds.width * bounds.height;
if (area > biggest_area) {
biggest_image = image;
}
Point size = shell2.computeSize(bounds.width, bounds.height);
shell2.setSize(size);
shell2.setBackgroundImage(image);
shell2.open();
}
if (biggest_image != null) {
new Clipboard(display).setContents(new Object[] { biggest_image.getImageData() }, new Transfer[] { ImageTransfer.getInstance() });
}
}
});
return item;
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class SpeedTestSelector method runMLABTest.
public static void runMLABTest(final Runnable runWhenClosed) {
CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
UIFunctionsManager.getUIFunctions().installPlugin("mlab", "dlg.install.mlab", new UIFunctions.actionListener() {
@Override
public void actionComplete(Object result) {
if (result instanceof Boolean) {
_runMLABTest(runWhenClosed);
} else {
try {
Throwable error = (Throwable) result;
Debug.out(error);
} finally {
if (runWhenClosed != null) {
runWhenClosed.run();
}
}
}
}
});
}
});
}
Aggregations