use of com.biglybt.ui.swt.config.wizard.ConfigureWizard in project BiglyBT by BiglySoftware.
the class MainWindowImpl method showMainWindow.
private void showMainWindow() {
configShowDLBasketListener = new ParameterListener() {
@Override
public void parameterChanged(String parameterName) {
configureDownloadBasket();
}
};
COConfigurationManager.addAndFireParameterListener("Show Download Basket", configShowDLBasketListener);
boolean isOSX = com.biglybt.core.util.Constants.isOSX;
boolean bEnableTray = COConfigurationManager.getBooleanParameter("Enable System Tray");
boolean bPassworded = COConfigurationManager.getBooleanParameter("Password enabled");
boolean bStartMinimize = bEnableTray && (bPassworded || COConfigurationManager.getBooleanParameter("Start Minimized"));
SWTSkinObject soMain = skin.getSkinObject("main");
if (soMain != null) {
soMain.getControl().setVisible(true);
}
shell.addListener(SWT.Show, new Listener() {
@Override
public void handleEvent(Event event) {
System.out.println("---------SHOWN AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
if (statusBar != null) {
Utils.execSWTThreadLater(10, new Runnable() {
@Override
public void run() {
statusBar.relayout();
}
});
}
// bring back and stand-alone shells
ShellManager.sharedManager().performForShells(new Listener() {
@Override
public void handleEvent(Event event) {
Shell this_shell = (Shell) event.widget;
if (this_shell.getParent() == null && !this_shell.isVisible()) {
boolean minimize;
synchronized (minimized_on_hide) {
minimize = minimized_on_hide.remove(this_shell);
}
this_shell.setVisible(true);
if (minimize) {
this_shell.setMinimized(true);
} else {
this_shell.moveAbove(shell);
}
}
}
});
}
});
if (!bStartMinimize) {
shell.open();
if (!isOSX) {
shell.forceActive();
}
}
if (delayedCore) {
// max 5 seconds of dispatching. We don't display.sleep here because
// we only want to clear the backlog of SWT events, and sleep would
// add new ones
Display display = Utils.getDisplay();
if (display == null) {
return;
}
try {
long endSWTDispatchOn = SystemTime.getOffsetTime(5000);
while (SystemTime.getCurrentTime() < endSWTDispatchOn && !display.isDisposed() && display.readAndDispatch()) ;
} catch (Exception e) {
Debug.out(e);
}
System.out.println("---------DONE DISPATCH AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
if (display.isDisposed()) {
return;
}
}
if (bEnableTray) {
try {
systemTraySWT = SystemTraySWT.getTray();
} catch (Throwable e) {
e.printStackTrace();
Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "Upgrade to SWT3.0M8 or later for system tray support."));
}
if (bStartMinimize) {
minimizeToTray(null);
} else // Only show the password if not started minimized
// Correct bug #878227
{
if (bPassworded) {
minimizeToTray(null);
// invokes password
setVisible(true);
}
}
}
if (uiInitializer != null) {
uiInitializer.initializationComplete();
}
boolean run_speed_test = false;
if (!Utils.isAZ2UI() && !COConfigurationManager.getBooleanParameter("SpeedTest Completed")) {
if (ConfigurationChecker.isNewInstall()) {
run_speed_test = true;
} else if (FeatureAvailability.triggerSpeedTestV1()) {
long upload_limit = COConfigurationManager.getLongParameter("Max Upload Speed KBs");
boolean auto_up = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY);
if (auto_up) {
if (upload_limit <= 18) {
run_speed_test = true;
}
} else {
boolean up_seed_limit = COConfigurationManager.getBooleanParameter("enable.seedingonly.upload.rate");
if (upload_limit == 0 && !up_seed_limit) {
run_speed_test = true;
}
}
}
}
if (run_speed_test) {
SpeedTestSelector.runMLABTest(new AERunnable() {
@Override
public void runSupport() {
WelcomeView.setWaitLoadingURL(false);
}
});
} else {
WelcomeView.setWaitLoadingURL(false);
}
if (Utils.isAZ2UI()) {
if (!COConfigurationManager.getBooleanParameter("Wizard Completed")) {
CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
new ConfigureWizard(false, ConfigureWizard.WIZARD_MODE_FULL);
}
});
}
checkForWhatsNewWindow();
}
AssociationChecker.checkAssociations();
// Donation stuff
Map<?, ?> map = VersionCheckClient.getSingleton().getMostRecentVersionCheckData();
DonationWindow.setInitialAskHours(MapUtils.getMapInt(map, "donations.askhrs", DonationWindow.getInitialAskHours()));
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
core.triggerLifeCycleComponentCreated(uiFunctions);
}
});
System.out.println("---------READY AT " + SystemTime.getCurrentTime() + ";" + (SystemTime.getCurrentTime() - Initializer.startTime) + "ms");
isReady = true;
// SESecurityManagerImpl.getSingleton().exitVM(0);
}
use of com.biglybt.ui.swt.config.wizard.ConfigureWizard in project BiglyBT by BiglySoftware.
the class CocoaUIEnhancer method initialize.
private void initialize() throws Exception {
// Get the Mac OS X Application menu.
Object sharedApplication = invoke(nsapplicationCls, "sharedApplication");
Object mainMenu = invoke(sharedApplication, "mainMenu");
Object mainMenuItem = invoke(nsmenuCls, mainMenu, "itemAtIndex", new Object[] { wrapPointer(0) });
Object appMenu = invoke(mainMenuItem, "submenu");
// disable services menu
Object servicesMenuItem = invoke(nsmenuCls, appMenu, "itemAtIndex", new Object[] { wrapPointer(kServicesMenuItem) });
invoke(nsmenuitemCls, servicesMenuItem, "setEnabled", new Object[] { false });
Menu systemMenu = Display.getCurrent().getSystemMenu();
if (systemMenu != null) {
MenuItem sysItem = getItem(systemMenu, SWT.ID_ABOUT);
if (sysItem != null) {
sysItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
AboutWindow.show();
}
});
}
sysItem = getItem(systemMenu, SWT.ID_PREFERENCES);
if (sysItem != null) {
sysItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG);
}
}
});
}
int quitIndex = systemMenu.indexOf(getItem(systemMenu, SWT.ID_QUIT));
MenuItem restartItem = new MenuItem(systemMenu, SWT.CASCADE, quitIndex);
Messages.setLanguageText(restartItem, "MainWindow.menu.file.restart");
restartItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.dispose(true, false);
}
}
});
// Add other menus
boolean isAZ3 = "az3".equalsIgnoreCase(COConfigurationManager.getStringParameter("ui"));
if (!isAZ3) {
// add Wizard, NAT Test, Speed Test
int prefIndex = systemMenu.indexOf(getItem(systemMenu, SWT.ID_PREFERENCES)) + 1;
MenuItem wizItem = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
Messages.setLanguageText(wizItem, "MainWindow.menu.file.configure");
wizItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new ConfigureWizard(false, ConfigureWizard.WIZARD_MODE_FULL);
}
});
MenuItem natMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
Messages.setLanguageText(natMenu, "MainWindow.menu.tools.nattest");
natMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new NatTestWindow();
}
});
MenuItem netstatMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
Messages.setLanguageText(netstatMenu, "MainWindow.menu.tools.netstat");
netstatMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
PluginsMenuHelper.IViewInfo[] views = PluginsMenuHelper.getInstance().getPluginViewsInfo();
for (PluginsMenuHelper.IViewInfo view : views) {
String viewID = view.viewID;
if (viewID != null && viewID.equals("aznetstatus")) {
view.openView(uiFunctions);
}
}
}
}
});
MenuItem speedMenu = new MenuItem(systemMenu, SWT.CASCADE, prefIndex);
Messages.setLanguageText(speedMenu, "MainWindow.menu.tools.speedtest");
speedMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new SpeedTestWizard();
}
});
}
}
// Register names in objective-c.
if (sel_applicationShouldHandleReopen_ == 0) {
sel_applicationShouldHandleReopen_ = registerName(osCls, "applicationShouldHandleReopen:hasVisibleWindows:");
}
// Add the action callbacks for menu items.
invoke(osCls, "class_addMethod", new Object[] { wrapPointer(delegateIdSWTApplication), wrapPointer(sel_applicationShouldHandleReopen_), wrapPointer(callBack4Addr), "@:@c" });
initialized = true;
}
Aggregations