use of com.biglybt.ui.swt.UIFunctionsSWT in project BiglyBT by BiglySoftware.
the class ProgressReporterWindow method openWindow.
/**
* Set initial size and layout for the window then open it
*/
private void openWindow() {
/*
* Using initialMaxNumberOfPanels as a lower limit we exclude all other panels from the layout,
* compute the window size, then finally we include all panels back into the layout
*
* This ensures that the window will fit exactly the desired number of panels
*/
Control[] controls = scrollChild.getChildren();
for (int i = (initialMaxNumberOfPanels); i < controls.length; i++) {
((GridData) controls[i].getLayoutData()).exclude = true;
}
Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);
for (int i = 0; i < controls.length; i++) {
((GridData) controls[i].getLayoutData()).exclude = false;
}
formatLastPanel(null);
scrollChild.layout();
/*
* Set the shell size if it's different that the computed size
*/
if (!shell.getSize().equals(p)) {
shell.setSize(p);
shell.layout(false);
}
/*
* Centers the window
*/
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (null == uiFunctions) {
/*
* Centers on the active monitor
*/
Utils.centreWindow(shell);
} else {
/*
* Centers on the main application window
*/
Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());
}
shell.open();
}
use of com.biglybt.ui.swt.UIFunctionsSWT in project BiglyBT by BiglySoftware.
the class UIUpdaterSWT method makeDebugToolTip.
private void makeDebugToolTip(Map<UIUpdatable, Long> timeMap) {
final int IDX_AVG = 0;
final int IDX_SIZE = 1;
final int IDX_MAX = 2;
final int IDX_LAST = 3;
final int IDX_TIME = 4;
long ttl = 0;
for (Iterator<UIUpdatable> iter = timeMap.keySet().iterator(); iter.hasNext(); ) {
UIUpdatable key = iter.next();
if (!averageTimes.containsKey(key))
averageTimes.put(key, new Long[] { 0L, 0L, 0L, 0L, System.currentTimeMillis() });
Long[] average = averageTimes.get(key);
long diff = timeMap.get(key).longValue();
if (diff > 0) {
long count = average[IDX_SIZE];
// require storing all 20 values and averaging them each time
if (count >= 20)
count = 19;
long lNewAverage = (average[IDX_AVG] * count + diff) / (count + 1);
average[IDX_AVG] = lNewAverage;
average[IDX_SIZE] = count + 1;
if (diff > average[IDX_MAX])
average[IDX_MAX] = diff;
average[IDX_LAST] = diff;
average[IDX_TIME] = System.currentTimeMillis();
} else {
average[IDX_LAST] = diff;
}
ttl += diff;
averageTimes.put(key, average);
}
// System.out.println(SystemTime.getCurrentTime() + "] Refresh " + ttl + "ms");
UIFunctionsSWT uiFunctionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
IMainStatusBar mainStatusBar = uiFunctionsSWT == null ? null : uiFunctionsSWT.getMainStatusBar();
if (mainStatusBar != null && mainStatusBar.isMouseOver()) {
StringBuilder sb = new StringBuilder();
for (Iterator iter = averageTimes.keySet().iterator(); iter.hasNext(); ) {
Object key = iter.next();
Object[] average = (Object[]) averageTimes.get(key);
long lLastUpdated = ((Long) average[IDX_TIME]).longValue();
if (System.currentTimeMillis() - lLastUpdated > 10000) {
iter.remove();
continue;
}
long lTime = ((Long) average[IDX_AVG]).longValue();
if (lTime > 0) {
if (sb.length() > 0)
sb.append("\n");
sb.append(lTime * 100 / waitTimeMS);
sb.append("% ");
sb.append(lTime).append("ms avg: ");
sb.append("[").append(((UIUpdatable) key).getUpdateUIName()).append("]");
sb.append(average[IDX_SIZE]).append(" samples");
sb.append("; max:").append(average[IDX_MAX]);
sb.append("; last:").append(average[IDX_LAST]);
}
}
mainStatusBar.setDebugInfo(sb.toString());
}
}
use of com.biglybt.ui.swt.UIFunctionsSWT in project BiglyBT by BiglySoftware.
the class StatsView method initialize.
private void initialize(Composite composite) {
parent = composite;
// Call plugin listeners
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
tabbedMDI = uiFunctions.createTabbedMDI(composite, VIEW_ID);
CTabFolder folder = tabbedMDI.getTabFolder();
Label lblClose = new Label(folder, SWT.WRAP);
lblClose.setText("x");
lblClose.addListener(SWT.MouseUp, new Listener() {
@Override
public void handleEvent(Event event) {
delete();
}
});
folder.setTopRight(lblClose);
UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
registerPluginViews(pluginUI);
if (pluginUI != null) {
UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(UISWTInstance.VIEW_STATISTICS);
for (int i = 0; i < pluginViews.length; i++) {
UISWTViewEventListenerWrapper l = pluginViews[i];
String name = l.getViewID();
try {
MdiEntrySWT entry = (MdiEntrySWT) tabbedMDI.createEntryFromEventListener(UISWTInstance.VIEW_STATISTICS, l, name, false, null, null);
entry.setDestroyOnDeactivate(false);
if ((dataSource == null && i == 0) || name.equals(dataSource)) {
tabbedMDI.showEntry(entry);
}
} catch (Exception e) {
// skip
}
}
}
}
updateThread = new UpdateThread();
updateThread.setDaemon(true);
updateThread.start();
dataSourceChanged(dataSource);
}
Aggregations