📄 progressreporterwindow.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: ProgressReporterWindow.java
package org.gudy.azureus2.ui.swt.progress;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.ui.swt.ITwistieListener;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
// Referenced classes of package org.gudy.azureus2.ui.swt.progress:
// IProgressReport, IProgressReportConstants, IProgressReporter, ProgressReporterPanel,
// ProgressReportingManager, IProgressReporterListener
public class ProgressReporterWindow
implements IProgressReportConstants, ITwistieListener, DisposeListener
{
private class AutoRemoveListener
implements IProgressReporterListener
{
private ProgressReporterPanel panel;
final ProgressReporterWindow this$0;
public int report(IProgressReport progressReport)
{
if (isAutoRemove && !progressReport.isActive())
{
if (null != panel && !panel.isDisposed())
{
ProgressReportingManager.getInstance().remove(panel.getProgressReporter());
Utils.execSWTThread(new AERunnable() {
final AutoRemoveListener this$1;
public void runSupport()
{
panel.dispose();
}
{
this$1 = AutoRemoveListener.this;
super();
}
});
}
return 1;
} else
{
return 0;
}
}
private AutoRemoveListener(ProgressReporterPanel panel)
{
this$0 = ProgressReporterWindow.this;
super();
this.panel = null;
this.panel = panel;
}
}
private Shell shell;
private ScrolledComposite scrollable;
private Composite scrollChild;
private IProgressReporter pReporters[];
private static final ArrayList reportersRegistry = new ArrayList();
private static boolean isShowingEmpty = false;
private int defaultShellWidth;
private int initialMaxNumberOfPanels;
private int style;
private boolean isAutoRemove;
private ProgressReporterWindow(IProgressReporter pReporter, int style)
{
defaultShellWidth = 500;
initialMaxNumberOfPanels = 3;
isAutoRemove = false;
this.style = style;
if (null != pReporter)
pReporters = (new IProgressReporter[] {
pReporter
});
else
pReporters = new IProgressReporter[0];
createControls();
}
private ProgressReporterWindow(IProgressReporter pReporters[], int style)
{
defaultShellWidth = 500;
initialMaxNumberOfPanels = 3;
isAutoRemove = false;
this.style = style;
if (null != pReporters)
this.pReporters = pReporters;
else
pReporters = new IProgressReporter[0];
createControls();
}
public static void open(IProgressReporter pReporter, int style)
{
(new ProgressReporterWindow(pReporter, style)).openWindow();
}
public static void open(IProgressReporter pReporters[], int style)
{
(new ProgressReporterWindow(pReporters, style)).openWindow();
}
public static boolean isShowingEmpty()
{
return isShowingEmpty;
}
public static boolean isOpened(IProgressReporter pReporter)
{
return reportersRegistry.contains(pReporter);
}
private void createControls()
{
int shellStyle = 2160;
if ((style & 4) != 0)
shellStyle |= 0x10000;
shell = ShellFactory.createMainShell(shellStyle);
shell.setText(MessageText.getString("progress.window.title"));
Utils.setShellIcon(shell);
GridLayout gLayout = new GridLayout();
gLayout.marginHeight = 0;
gLayout.marginWidth = 0;
shell.setLayout(gLayout);
scrollable = new ScrolledComposite(shell, 512);
scrollable.setLayoutData(new GridData(4, 4, true, true));
scrollChild = new Composite(scrollable, 0);
GridLayout gLayoutChild = new GridLayout();
gLayoutChild.marginHeight = 0;
gLayoutChild.marginWidth = 0;
gLayoutChild.verticalSpacing = 0;
scrollChild.setLayout(gLayoutChild);
scrollable.setContent(scrollChild);
scrollable.setExpandVertical(true);
scrollable.setExpandHorizontal(true);
scrollable.addControlListener(new ControlAdapter() {
final ProgressReporterWindow this$0;
public void controlResized(ControlEvent e)
{
Rectangle r = scrollable.getClientArea();
scrollable.setMinSize(scrollChild.computeSize(r.width, -1));
}
{
this$0 = ProgressReporterWindow.this;
super();
}
});
shell.addListener(21, new Listener() {
final ProgressReporterWindow this$0;
public void handleEvent(Event event)
{
Control controls[] = scrollChild.getChildren();
for (int i = 0; i < controls.length; i++)
if (controls[i] instanceof ProgressReporterPanel)
((ProgressReporterPanel)controls[i]).removeDisposeListener(ProgressReporterWindow.this);
for (int i = 0; i < pReporters.length; i++)
ProgressReporterWindow.reportersRegistry.remove(pReporters[i]);
ProgressReporterWindow.isShowingEmpty = false;
}
{
this$0 = ProgressReporterWindow.this;
super();
}
});
if (pReporters.length == 0)
createEmptyPanel();
else
createPanels();
if ((style & 0x20) != 0)
createToolbar();
isAutoRemove = COConfigurationManager.getBooleanParameter("auto_remove_inactive_items");
}
private void createToolbar()
{
Composite toolbarPanel = new Composite(shell, 0);
toolbarPanel.setLayoutData(new GridData(4, 4, false, false));
GridLayout gLayout = new GridLayout(3, false);
gLayout.marginWidth = 25;
gLayout.marginTop = 0;
gLayout.marginBottom = 0;
toolbarPanel.setLayout(gLayout);
final Button autoClearButton = new Button(toolbarPanel, 32);
autoClearButton.setText(MessageText.getString("Progress.reporting.window.remove.auto"));
autoClearButton.setToolTipText(MessageText.getString("Progress.reporting.window.remove.auto.tooltip"));
autoClearButton.setLayoutData(new GridData(1, 0x1000000, false, false));
autoClearButton.setSelection(COConfigurationManager.getBooleanParameter("auto_remove_inactive_items"));
Label dummy = new Label(toolbarPanel, 0);
dummy.setLayoutData(new GridData(4, 4, true, false));
final Button clearInActiveButton = new Button(toolbarPanel, 0);
clearInActiveButton.setText(MessageText.getString("Progress.reporting.window.remove.now"));
clearInActiveButton.setToolTipText(MessageText.getString("Progress.reporting.window.remove.now.tooltip"));
clearInActiveButton.setLayoutData(new GridData(0x1000008, 0x1000000, false, false));
clearInActiveButton.setEnabled(!COConfigurationManager.getBooleanParameter("auto_remove_inactive_items"));
autoClearButton.addSelectionListener(new SelectionListener() {
final Button val$autoClearButton;
final Button val$clearInActiveButton;
final ProgressReporterWindow this$0;
public void widgetSelected(SelectionEvent e)
{
COConfigurationManager.setParameter("auto_remove_inactive_items", autoClearButton.getSelection());
clearInActiveButton.setEnabled(!autoClearButton.getSelection());
isAutoRemove = autoClearButton.getSelection();
if (isAutoRemove)
removeInActivePanels();
}
public void widgetDefaultSelected(SelectionEvent e)
{
widgetSelected(e);
}
{
this$0 = ProgressReporterWindow.this;
autoClearButton = button;
clearInActiveButton = button1;
super();
}
});
clearInActiveButton.addSelectionListener(new SelectionListener() {
final ProgressReporterWindow this$0;
public void widgetSelected(SelectionEvent e)
{
removeInActivePanels();
}
public void widgetDefaultSelected(SelectionEvent e)
{
widgetSelected(e);
}
{
this$0 = ProgressReporterWindow.this;
super();
}
});
}
private void removeInActivePanels()
{
Control controls[] = scrollChild.getChildren();
for (int i = 0; i < controls.length; i++)
{
if (null == controls[i] || controls[i].isDisposed() || !(controls[i] instanceof ProgressReporterPanel))
continue;
IProgressReporter pReporter = ((ProgressReporterPanel)controls[i]).getProgressReporter();
if (!pReporter.getProgressReport().isActive())
{
ProgressReportingManager.getInstance().remove(pReporter);
controls[i].dispose();
}
}
}
private void createEmptyPanel()
{
Composite emptyPanel = new Composite(scrollChild, 2048);
GridData gData = new GridData(4, 4, true, true);
gData.heightHint = 100;
emptyPanel.setLayoutData(gData);
emptyPanel.setLayout(new GridLayout());
Label nothingToDisplay = new Label(emptyPanel, 0);
nothingToDisplay.setLayoutData(new GridData(4, 4, true, true));
nothingToDisplay.setText(MessageText.getString("Progress.reporting.no.reports.to.display"));
isShowingEmpty = true;
}
private void openWindow()
{
Control controls[] = scrollChild.getChildren();
for (int i = initialMaxNumberOfPanels; i < controls.length; i++)
((GridData)controls[i].getLayoutData()).exclude = true;
Point p = shell.computeSize(defaultShellWidth, -1);
for (int i = 0; i < controls.length; i++)
((GridData)controls[i].getLayoutData()).exclude = false;
formatLastPanel(null);
scrollChild.layout();
if (!shell.getSize().equals(p))
{
shell.setSize(p);
shell.layout(false);
}
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (null == uiFunctions)
Utils.centreWindow(shell);
else
Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());
shell.open();
}
private void createPanels()
{
int size = pReporters.length;
if (size < 2)
style |= 8;
for (int i = 0; i < size; i++)
if (null != pReporters[i])
{
reportersRegistry.add(pReporters[i]);
ProgressReporterPanel panel = new ProgressReporterPanel(scrollChild, pReporters[i], style | 0x10);
panel.setLayoutData(new GridData(4, 4, true, false));
panel.addTwistieListener(this);
panel.addDisposeListener(this);
pReporters[i].addListener(new AutoRemoveListener(panel));
}
formatLastPanel(null);
}
private void formatLastPanel(ProgressReporterPanel panelToIgnore)
{
Control controls[] = scrollChild.getChildren();
int i = controls.length - 1;
do
{
if (i < 0)
break;
if (!controls[i].equals(panelToIgnore))
{
((GridData)controls[i].getLayoutData()).grabExcessVerticalSpace = true;
break;
}
i--;
} while (true);
}
private void removeReporter(IProgressReporter reporter)
{
reportersRegistry.remove(reporter);
int IDX = Arrays.binarySearch(pReporters, reporter);
if (IDX >= 0)
{
IProgressReporter rps[] = new IProgressReporter[pReporters.length - 1];
for (int i = 0; i < rps.length; i++)
rps[i] = pReporters[i < IDX ? i : i + 1];
pReporters = rps;
}
}
public void isCollapsed(boolean value)
{
if (null != shell && !shell.isDisposed())
{
scrollable.setRedraw(false);
Rectangle r = scrollable.getClientArea();
scrollable.setMinSize(scrollChild.computeSize(r.width, -1));
if (pReporters.length == 1)
{
Point p = shell.computeSize(defaultShellWidth, -1);
if (shell.getSize().y != p.y)
{
p.x = shell.getSize().x;
shell.setSize(p);
}
}
scrollable.layout();
scrollable.setRedraw(true);
}
}
public void widgetDisposed(DisposeEvent e)
{
if (e.widget instanceof ProgressReporterPanel)
{
ProgressReporterPanel panel = (ProgressReporterPanel)e.widget;
removeReporter(panel.pReporter);
panel.removeTwistieListener(this);
((GridData)panel.getLayoutData()).exclude = true;
panel.setVisible(false);
if (pReporters.length == 0)
{
if ((style & 2) != 0)
{
if (null != shell && !shell.isDisposed())
shell.close();
} else
{
createEmptyPanel();
}
} else
{
formatLastPanel(panel);
}
if (null != shell && !shell.isDisposed())
shell.layout(true, true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -