srStatus = new CLabelPadding(statusBar, borderFlag);
srStatus.setText(MessageText.getString("SpeedView.stats.ratio"));
COConfigurationManager.addAndFireParameterListener("Status Area Show SR",
new ParameterListener() {
public void parameterChanged(String parameterName) {
srStatus.setVisible(COConfigurationManager.getBooleanParameter(parameterName));
statusBar.layout();
}
});
natStatus = new CLabelPadding(statusBar, borderFlag);
natStatus.setText("");
COConfigurationManager.addAndFireParameterListener("Status Area Show NAT",
new ParameterListener() {
public void parameterChanged(String parameterName) {
natStatus.setVisible(COConfigurationManager.getBooleanParameter(parameterName));
statusBar.layout();
}
});
dhtStatus = new CLabelPadding(statusBar, borderFlag);
dhtStatus.setText("");
dhtStatus.setToolTipText(MessageText.getString("MainWindow.dht.status.tooltip"));
COConfigurationManager.addAndFireParameterListener("Status Area Show DDB",
new ParameterListener() {
public void parameterChanged(String parameterName) {
dhtStatus.setVisible(COConfigurationManager.getBooleanParameter(parameterName));
statusBar.layout();
}
});
ipBlocked = new CLabelPadding(statusBar, borderFlag);
ipBlocked.setText("{} IPs:"); //$NON-NLS-1$
Messages.setLanguageText(ipBlocked, "MainWindow.IPs.tooltip");
ipBlocked.addListener(SWT.MouseDoubleClick, new ListenerNeedingCoreRunning() {
public void handleEvent(AzureusCore core, Event event) {
BlockedIpsWindow.showBlockedIps(core, parent.getShell());
}
});
COConfigurationManager.addAndFireParameterListener("Status Area Show IPF",
new ParameterListener() {
public void parameterChanged(String parameterName) {
ipBlocked.setVisible(COConfigurationManager.getBooleanParameter(parameterName));
statusBar.layout();
}
});
statusDown = new CLabelPadding(statusBar, borderFlag);
statusDown.setImage(imageLoader.getImage("down"));
//statusDown.setText(/*MessageText.getString("ConfigView.download.abbreviated") +*/"n/a");
Messages.setLanguageText(statusDown,
"MainWindow.status.updowndetails.tooltip");
Listener lStats = new Listener() {
public void handleEvent(Event e) {
uiFunctions.openView(UIFunctions.VIEW_STATS, null);
}
};
statusUp = new CLabelPadding(statusBar, borderFlag);
statusUp.setImage(imageLoader.getImage("up"));
//statusUp.setText(/*MessageText.getString("ConfigView.upload.abbreviated") +*/"n/a");
Messages.setLanguageText(statusUp,
"MainWindow.status.updowndetails.tooltip");
statusDown.addListener(SWT.MouseDoubleClick, lStats);
statusUp.addListener(SWT.MouseDoubleClick, lStats);
Listener lDHT = new Listener() {
public void handleEvent(Event e) {
uiFunctions.openView(UIFunctions.VIEW_STATS, "dht");
}
};
dhtStatus.addListener(SWT.MouseDoubleClick, lDHT);
Listener lSR = new Listener() {
public void handleEvent(Event e) {
uiFunctions.openView(UIFunctions.VIEW_STATS, "transfers");
OverallStats stats = StatsFactory.getStats();
if (stats == null) {
return;
}
long ratio = (1000 * stats.getUploadedBytes() / (stats.getDownloadedBytes() + 1));
if (ratio < 900) {
Utils.launch(Constants.AZUREUS_WIKI + "Share_Ratio");
}
}
};
srStatus.addListener(SWT.MouseDoubleClick, lSR);
Listener lNAT = new ListenerNeedingCoreRunning() {
public void handleEvent(AzureusCore core, Event e) {
uiFunctions.openView(UIFunctions.VIEW_CONFIG,
ConfigSection.SECTION_CONNECTION);
if (PluginInitializer.getDefaultInterface().getConnectionManager().getNATStatus() != ConnectionManager.NAT_OK) {
Utils.launch(Constants.AZUREUS_WIKI + "NAT_problem");
}
}
};
natStatus.addListener(SWT.MouseDoubleClick, lNAT);
boolean bSpeedMenu = COConfigurationManager.getBooleanParameter("GUI_SWT_bOldSpeedMenu");
if (bSpeedMenu) {
// Status Bar Menu construction
final Menu menuUpSpeed = new Menu(statusBar.getShell(), SWT.POP_UP);
menuUpSpeed.addListener(SWT.Show, new Listener() {
public void handleEvent(Event e) {
if (!AzureusCoreFactory.isCoreRunning()) {
return;
}
AzureusCore core = AzureusCoreFactory.getSingleton();
GlobalManager globalManager = core.getGlobalManager();
SelectableSpeedMenu.generateMenuItems(menuUpSpeed, core,
globalManager, true);
}
});
statusUp.setMenu(menuUpSpeed);
} else {
statusUp.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))) {
return;
}
Event event = new Event();
event.type = SWT.MouseUp;
event.widget = e.widget;
event.stateMask = e.stateMask;
event.button = e.button;
e.widget.getDisplay().post(event);
CoreWaiterSWT.waitForCoreRunning(new AzureusCoreRunningListener() {
public void azureusCoreRunning(AzureusCore core) {
SelectableSpeedMenu.invokeSlider(core, true);
}
});
}
});
}
if (bSpeedMenu) {
final Menu menuDownSpeed = new Menu(statusBar.getShell(), SWT.POP_UP);
menuDownSpeed.addListener(SWT.Show, new Listener() {
public void handleEvent(Event e) {
if (!AzureusCoreFactory.isCoreRunning()) {
return;
}
AzureusCore core = AzureusCoreFactory.getSingleton();
GlobalManager globalManager = core.getGlobalManager();
SelectableSpeedMenu.generateMenuItems(menuDownSpeed, core,
globalManager, false);
}
});
statusDown.setMenu(menuDownSpeed);
} else {
statusDown.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))) {
return;
}
Event event = new Event();
event.type = SWT.MouseUp;
event.widget = e.widget;
event.stateMask = e.stateMask;
event.button = e.button;
e.widget.getDisplay().post(event);
CoreWaiterSWT.waitForCoreRunning(new AzureusCoreRunningListener() {
public void azureusCoreRunning(AzureusCore core) {
SelectableSpeedMenu.invokeSlider(core, false);
}
});
}
});
}
statusWarnings = new CLabelPadding(statusBar, borderFlag);
warningIcon = imageLoader.getImage("image.sidebar.vitality.alert");
infoIcon = imageLoader.getImage("image.sidebar.vitality.info");
updateStatusWarnings();
Messages.setLanguageText(statusWarnings,
"MainWindow.status.warning.tooltip");
Alerts.addMessageHistoryListener(new AlertHistoryListener() {
public void alertHistoryAdded(LogAlert params) {
updateStatusWarnings();
}
public void alertHistoryRemoved(LogAlert alert) {
updateStatusWarnings();
}
});
statusWarnings.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
if (SystemWarningWindow.numWarningWindowsOpen > 0) {
return;
}
ArrayList<LogAlert> alerts = Alerts.getUnviewedLogAlerts();
if (alerts.size() == 0) {
return;
}
Shell shell = statusWarnings.getShell();
Rectangle bounds = statusWarnings.getClientArea();
Point ptBottomRight = statusWarnings.toDisplay(bounds.x + bounds.width, bounds.y);
new SystemWarningWindow(alerts.get(0), ptBottomRight, shell, 0);
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
COConfigurationManager.addAndFireParameterListener("status.rategraphs",
new ParameterListener() {
public void parameterChanged(String parameterName) {
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
boolean doRateGraphs = COConfigurationManager.getBooleanParameter("status.rategraphs");
if (doRateGraphs) {