}
public void initUIComponents() {
final Display display = SWTThread.getDisplay();
final MainWindow instance = this;
display.asyncExec(new JMRunnable() {
public void JMRun() {
shell = new Shell(display);
shell.setSize(800, 500);
Utils.centreWindow(shell);
shell.setText(JMConstants.JMULE_FULL_NAME);
shell.setImage(SWTImageRepository.getImage("jmule.png"));
GridLayout gridLayout = new GridLayout(1,true);
gridLayout.marginHeight = 2;
gridLayout.marginWidth = 2;
shell.setLayout(gridLayout);
//Setup main_menu
main_menu = new MainMenu(shell,instance);
//Setup tool bar
toolbar = new Toolbar(shell,_core,instance);
window_content = new ScrolledComposite(shell,SWT.NONE);
window_content.setExpandHorizontal(true);
window_content.setExpandVertical(true);
window_content.setLayout(new FillLayout());
GridData gridData = new GridData(GridData.FILL_BOTH);
window_content.setLayoutData(gridData);
new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
status_bar = new StatusBar(shell,_core);
LogsTab logs_tab = new LogsTab(window_content);
logger = logs_tab;
tab_list.add(logs_tab);
tab_list.add(new ServerListTab(window_content,_core));
tab_list.add(new KadTab(window_content,_core));
tab_list.add(new TransfersTab(window_content,_core));
tab_list.add(new SearchTab(window_content,_core));
tab_list.add(new SharedTab(window_content,_core));
tab_list.add(new StatisticsTab(window_content));
setTab(AbstractTab.JMULE_TABS.SERVERLIST);
if (!SWTPreferences.getInstance().isStatusBarVisible())
statusBarToogleVisibility();
if (!SWTPreferences.getInstance().isToolBarVisible())
toolbarToogleVisibility();
shell.open ();
if (SWTPreferences.getInstance().isConnectAtStartup()) {
try {
_core.getServerManager().connect();
} catch (ServerManagerException e1) {
e1.printStackTrace();
}
}
if (JMConstants.IS_NIGHTLY_BUILD)
if (SWTPreferences.getInstance().isNightlyBuildWarning()){
NightlyBuildWarningWindow warning_window = new NightlyBuildWarningWindow(shell);
warning_window.getCoreComponents();
warning_window.initUIComponents();
}
// show log messages
new JMThread(new JMRunnable() {
public void JMRun() {
logger.fine(Localizer._("mainwindow.logtab.message_jmule_started", JMConstants.JMULE_FULL_NAME));
logger.fine(Localizer._("mainwindow.logtab.message_servers_loaded", _core.getServerManager().getServersCount() + ""));
logger.fine(Localizer._("mainwindow.logtab.message_shared_loaded", _core.getSharingManager().getFileCount() + ""));
logger.fine(Localizer._("mainwindow.logtab.message_partial_loaded", _core.getDownloadManager().getDownloadCount() + ""));
}}).start();
_core.addEventListener(new JMuleCoreEventListener() {
public void eventOccured(JMuleCoreEvent event, final EventDescriptor eventDescriptor) {
if( event == JMuleCoreEvent.NOT_ENOUGH_SPACE ) {
display.syncExec(new JMRunnable() {
NotEnoughSpaceDownloadingFile nes = (NotEnoughSpaceDownloadingFile)eventDescriptor;
public void JMRun() {
Utils.showErrorMessage(shell,
_._("mainwindow.not_enough_space_dialog.title"),
_._("mainwindow.not_enough_space_dialog.message",
nes.getFileName(),
FileFormatter.formatFileSize( nes.getTotalSpace() ),
FileFormatter.formatFileSize( nes.getFreeSpace() )));
}
});
}
}
});
// Update checker
if (SWTPreferences.getInstance().updateCheckAtStartup()) {
new JMThread(new JMRunnable() {
public void JMRun() {
try {
JMUpdater.getInstance().checkForUpdates();
if (JMUpdater.getInstance().isNewVersionAvailable())
SWTThread.getDisplay().asyncExec(new JMRunnable() {
public void JMRun() {
if (JMUpdater.getInstance().isNewVersionAvailable()) {
if (Utils.showConfirmMessage(shell, _._("mainwindow.new_version_available.title"), _._("mainwindow.new_version_available"))) {
UpdaterWindow window = new UpdaterWindow();
window.getCoreComponents();
window.initUIComponents();
} }
}});
} catch (JMUpdaterException e) {}
}
}).start();
}
shell.addListener(SWT.Close, new Listener() {
public void handleEvent(Event arg0) {
boolean exit = SWTPreferences.getInstance().promptOnExit() ?
Utils.showConfirmMessage(shell, _._("mainwindow.exit_prompt_title"), _._("mainwindow.exit_prompt")) : true;
arg0.doit = exit;
}
});
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
new JMThread(new JMRunnable() {
public void JMRun() {
try {
JMuleUIManager.getSingleton().shutdown();
} catch (JMuleUIManagerException e) {
e.printStackTrace();