Methods Summary |
---|
public void | addListener(com.aelitis.azureus.ui.InitializerListener listener)
try{
listeners_mon.enter();
listeners.add(listener);
}finally{
listeners_mon.exit();
}
|
public static boolean | handleStopRestart(boolean restart)
UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (functionsSWT != null) {
return functionsSWT.dispose(restart, true);
}
return false;
|
public static void | main(java.lang.String[] args)
System.err.println("Shouldn't you be starting with org.gudy.azureus2.ui.swt.Main?");
AzureusCore core = AzureusCoreFactory.create();
new Initializer( core, null,args);
|
private void | nextTask()
currentTask++;
currentPercent = 100 * currentTask / (nbTasks) ;
//0% done of current task
reportPercent(0);
|
private int | overallPercent(int taskPercent)
//System.out.println("ST percent " + currentPercent + " / " + taskPercent + " : " + (currentPercent + (taskPercent / nbTasks)));
return currentPercent + taskPercent / nbTasks;
|
public void | removeListener(com.aelitis.azureus.ui.InitializerListener listener)
try{
listeners_mon.enter();
listeners.remove(listener);
}finally{
listeners_mon.exit();
}
|
public void | reportCurrentTask(AzureusCoreOperation operation, java.lang.String currentTask)
if ( operation.getOperationType() == AzureusCoreOperation.OP_INITIALISATION ){
reportCurrentTask( currentTask );
}
|
public void | reportCurrentTask(java.lang.String currentTaskString)
try{
listeners_mon.enter();
Iterator iter = listeners.iterator();
while(iter.hasNext()) {
try{
InitializerListener listener = (InitializerListener) iter.next();
listener.reportCurrentTask(currentTaskString);
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
}finally{
listeners_mon.exit();
}
|
private void | reportCurrentTaskByKey(java.lang.String key)
reportCurrentTask(MessageText.getString(key));
|
public void | reportPercent(AzureusCoreOperation operation, int percent)
if ( operation.getOperationType() == AzureusCoreOperation.OP_INITIALISATION ){
reportPercent( percent );
}
|
public void | reportPercent(int percent)
int overallPercent = overallPercent(percent);
try{
listeners_mon.enter();
Iterator iter = listeners.iterator();
while(iter.hasNext()) {
try{
InitializerListener listener = (InitializerListener) iter.next();
listener.reportPercent(overallPercent);
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
if (overallPercent > 100) {
listeners.clear();
}
}finally{
listeners_mon.exit();
}
|
public void | run()
try{
String uiMode = UISwitcherUtil.openSwitcherWindow(false);
if (uiMode.equals("az3")) {
try {
final Class az3Class = Class.forName("com.aelitis.azureus.ui.swt.Initializer");
final Constructor constructor = az3Class.getConstructor(new Class[] {
AzureusCore.class,
Boolean.TYPE,
String[].class
});
IUIIntializer initializer = (IUIIntializer) constructor.newInstance(new Object[] {
azureus_core,
new Boolean(false),
args
});
initializer.run();
return;
} catch (Throwable t) {
// use print stack trace because we don't want to introduce logger
t.printStackTrace();
// Ignore and use AZ2
}
}
// else AZ2UI
// initialise the SWT locale util
new LocaleUtilSWT( azureus_core );
Display display = SWTThread.getInstance().getDisplay();
UIConfigDefaultsSWT.initialize();
//The splash window, if displayed will need some images.
ImageRepository.loadImagesForSplashWindow(display);
//Splash Window is not always shown
if (COConfigurationManager.getBooleanParameter("Show Splash", true)) {
SplashWindow.create(display,this);
}
setNbTasks(6);
nextTask();
reportCurrentTaskByKey("splash.firstMessageNoI18N");
Alerts.init();
final ArrayList logEvents = new ArrayList();
ILogEventListener logListener = null;
if (COConfigurationManager.getBooleanParameter("Open Console", false)) {
logListener = new ILogEventListener() {
public void log(LogEvent event) {
logEvents.add(event);
}
};
Logger.addListener(logListener);
}
final ILogEventListener finalLogListener = logListener;
ProgressWindow.register( azureus_core );
new SWTNetworkSelection();
new AuthenticatorWindow();
new CertificateTrustWindow();
InstallPluginWizard.register( azureus_core, display );
nextTask();
reportCurrentTaskByKey("splash.loadingImages");
ImageRepository.loadImages(display);
nextTask();
reportCurrentTaskByKey("splash.initializeGM");
azureus_core.addListener( this );
azureus_core.addLifecycleListener(new AzureusCoreLifecycleAdapter() {
public void componentCreated(AzureusCore core, AzureusCoreComponent comp) {
if (comp instanceof GlobalManager) {
gm = (GlobalManager) comp;
nextTask();
reportCurrentTask(MessageText.getString("splash.initializePlugins"));
}
}
public void started(AzureusCore core) {
if (gm == null)
return;
new UserAlerts(gm);
nextTask();
IpFilterManager ipFilterManager = azureus_core.getIpFilterManager();
if (ipFilterManager != null) {
String s = MessageText.getString("splash.loadIpFilters");
do {
reportCurrentTask(s);
s += ".";
} while (!semFilterLoader.reserve(3000));
}
nextTask();
reportCurrentTaskByKey("splash.initializeGui");
new Colors();
Cursors.init();
new MainWindow(core, Initializer.this,
logEvents);
if (finalLogListener != null)
Logger.removeListener(finalLogListener);
nextTask();
reportCurrentTaskByKey("splash.openViews");
SWTUpdateChecker.initialize();
PreUpdateChecker.initialize( core, COConfigurationManager.getStringParameter("ui"));
UpdateMonitor.getSingleton(core); // setup the update monitor
//Tell listeners that all is initialized :
Alerts.initComplete();
// 7th task: just for triggering a > 100% completion
nextTask();
//Finally, open torrents if any.
for (int i = 0; i < args.length; i++) {
try {
TorrentOpener.openTorrent(args[i]);
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
}
public void stopping(AzureusCore core) {
Alerts.stopInitiated();
}
public void stopped(AzureusCore core) {
}
public boolean syncInvokeRequired() {
return (true);
}
public boolean stopRequested(AzureusCore _core)
throws AzureusCoreException {
return (handleStopRestart(false));
}
public boolean restartRequested(final AzureusCore core) {
return (handleStopRestart(true));
}
});
azureus_core.start();
}catch( Throwable e ){
Logger.log(new LogEvent(LOGID, "Initialization fails:", e));
}
|
private void | setNbTasks(int _nbTasks)
currentTask = 0;
nbTasks = _nbTasks;
|
public void | stopIt(boolean for_restart, boolean close_already_in_progress)
if ( azureus_core != null && !close_already_in_progress ){
if ( for_restart ){
azureus_core.checkRestartSupported();
}
}
try{
if ( startServer != null ){
startServer.stopIt();
}
Cursors.dispose();
SWTThread.getInstance().terminate();
}finally{
if ( azureus_core != null && !close_already_in_progress ){
try{
if ( for_restart ){
azureus_core.restart();
}else{
azureus_core.stop();
}
}catch( Throwable e ){
// don't let any failure here cause the stop operation to fail
Debug.out( e );
}
}
}
|