📄 configview.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: ConfigView.java
package org.gudy.azureus2.ui.swt.views;
import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.AzureusCoreFactory;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.util.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.ui.config.ConfigSection;
import org.gudy.azureus2.plugins.ui.config.ConfigSectionSWT;
import org.gudy.azureus2.pluginsimpl.local.ui.config.ConfigSectionRepository;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.plugins.UISWTConfigSection;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionConnection;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionConnectionAdvanced;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionConnectionEncryption;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionConnectionProxy;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionFile;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionFileMove;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionFilePerformance;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionFileTorrents;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionFileTorrentsDecoding;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionIPFilter;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterface;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceAlerts;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceColor;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceDisplay;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceLanguage;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceLegacy;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfacePassword;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionInterfaceStart;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionLogging;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionMode;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionPlugins;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionSecurity;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionSharing;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionStats;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTracker;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTrackerClient;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTrackerServer;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTransfer;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTransferAutoSpeed;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTransferAutoSpeedBeta;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTransferAutoSpeedSelect;
import org.gudy.azureus2.ui.swt.views.configsections.ConfigSectionTransferLAN;
// Referenced classes of package org.gudy.azureus2.ui.swt.views:
// AbstractIView
public class ConfigView extends AbstractIView
{
private static final LogIDs LOGID;
public static final String sSectionPrefix = "ConfigView.section.";
AzureusCore azureus_core;
Map sections;
List sectionsCreated;
Composite cConfig;
Composite cConfigSection;
StackLayout layoutConfigSection;
Label lHeader;
Label usermodeHint;
Font headerFont;
Font filterFoundFont;
Tree tree;
ArrayList pluginSections;
private Timer filterDelayTimer;
private String filterText;
private Label lblX;
private Listener scResizeListener;
private Image imgSmallX;
private Image imgSmallXGray;
private static Comparator insert_point_comparator = new Comparator() {
private String asString(Object o)
{
if (o instanceof String)
return (String)o;
if (o instanceof TreeItem)
return ((TreeItem)o).getText();
else
throw new ClassCastException((new StringBuilder()).append("object is not String or TreeItem: ").append(o.getClass().getName()).toString());
}
public int compare(Object o1, Object o2)
{
int result = String.CASE_INSENSITIVE_ORDER.compare(asString(o1), asString(o2));
return result;
}
};
public ConfigView()
{
this(AzureusCoreFactory.getSingleton());
}
public ConfigView(AzureusCore _azureus_core)
{
sections = new HashMap();
sectionsCreated = new ArrayList(1);
filterText = "";
azureus_core = _azureus_core;
}
public void initialize(Composite composite)
{
try
{
Display d = composite.getDisplay();
cConfig = new Composite(composite, 0);
GridLayout configLayout = new GridLayout();
configLayout.marginHeight = 0;
configLayout.marginWidth = 0;
cConfig.setLayout(configLayout);
GridData gridData = new GridData(1808);
cConfig.setLayoutData(gridData);
SashForm form = new SashForm(cConfig, 256);
gridData = new GridData(1808);
form.setLayoutData(gridData);
Composite cLeftSide = new Composite(form, 2048);
gridData = new GridData(1808);
cLeftSide.setLayoutData(gridData);
FormLayout layout = new FormLayout();
cLeftSide.setLayout(layout);
Composite cFilterArea = new Composite(cLeftSide, 0);
cFilterArea.setLayout(new FormLayout());
final Text txtFilter = new Text(cFilterArea, 2048);
final String sFilterText = MessageText.getString("ConfigView.filter");
txtFilter.setText(sFilterText);
txtFilter.selectAll();
txtFilter.addModifyListener(new ModifyListener() {
final Text val$txtFilter;
final ConfigView this$0;
public void modifyText(ModifyEvent e)
{
filterTree(txtFilter.getText());
}
{
this$0 = ConfigView.this;
txtFilter = text;
super();
}
});
txtFilter.addMouseListener(new MouseAdapter() {
final Text val$txtFilter;
final String val$sFilterText;
final ConfigView this$0;
public void mouseDown(MouseEvent e)
{
if (txtFilter.getText().equals(sFilterText))
txtFilter.selectAll();
}
{
this$0 = ConfigView.this;
txtFilter = text;
sFilterText = s;
super();
}
});
txtFilter.setFocus();
ImageLoader imageLoader = ImageLoader.getInstance();
imgSmallXGray = imageLoader.getImage("smallx-gray");
imgSmallX = imageLoader.getImage("smallx");
lblX = new Label(cFilterArea, 64);
Messages.setLanguageTooltip(lblX, "MyTorrentsView.clearFilter.tooltip");
lblX.setImage(imgSmallXGray);
lblX.addMouseListener(new MouseAdapter() {
final Text val$txtFilter;
final ConfigView this$0;
public void mouseUp(MouseEvent e)
{
txtFilter.setText("");
}
{
this$0 = ConfigView.this;
txtFilter = text;
super();
}
});
Label lblSearch = new Label(cFilterArea, 0);
imageLoader.setLabelImage(lblSearch, "search");
tree = new Tree(cLeftSide, 0);
FontData fontData[] = tree.getFont().getFontData();
fontData[0].setStyle(1);
filterFoundFont = new Font(d, fontData);
FormData formData = new FormData();
formData.bottom = new FormAttachment(100, -5);
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
cFilterArea.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0, 5);
formData.left = new FormAttachment(0, 5);
lblSearch.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0, 5);
formData.left = new FormAttachment(lblSearch, 5);
formData.right = new FormAttachment(lblX, -3);
txtFilter.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0, 5);
formData.right = new FormAttachment(100, -5);
lblX.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0, 0);
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.bottom = new FormAttachment(cFilterArea, -1);
tree.setLayoutData(formData);
Composite cRightSide = new Composite(form, 0);
configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
cRightSide.setLayout(configLayout);
Composite cHeader = new Composite(cRightSide, 2048);
configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
configLayout.numColumns = 2;
configLayout.marginRight = 5;
cHeader.setLayout(configLayout);
gridData = new GridData(772);
cHeader.setLayoutData(gridData);
cHeader.setBackground(d.getSystemColor(26));
cHeader.setForeground(d.getSystemColor(27));
lHeader = new Label(cHeader, 0);
lHeader.setBackground(d.getSystemColor(26));
lHeader.setForeground(d.getSystemColor(27));
fontData = lHeader.getFont().getFontData();
fontData[0].setStyle(1);
int fontHeight = (int)((double)fontData[0].getHeight() * 1.2D);
fontData[0].setHeight(fontHeight);
headerFont = new Font(d, fontData);
lHeader.setFont(headerFont);
gridData = new GridData(36);
lHeader.setLayoutData(gridData);
usermodeHint = new Label(cHeader, 0);
usermodeHint.setBackground(d.getSystemColor(26));
usermodeHint.setForeground(d.getSystemColor(27));
gridData = new GridData(644);
usermodeHint.setLayoutData(gridData);
cConfigSection = new Composite(cRightSide, 0);
layoutConfigSection = new StackLayout();
cConfigSection.setLayout(layoutConfigSection);
gridData = new GridData(1808);
gridData.horizontalIndent = 2;
cConfigSection.setLayoutData(gridData);
form.setWeights(new int[] {
20, 80
});
tree.addSelectionListener(new SelectionAdapter() {
final ConfigView this$0;
public void widgetSelected(SelectionEvent e)
{
Tree tree = (Tree)e.getSource();
if (tree.getSelection().length > 0)
showSection(tree.getSelection()[0]);
}
{
this$0 = ConfigView.this;
super();
}
});
tree.addListener(14, new Listener() {
final ConfigView this$0;
public void handleEvent(Event e)
{
TreeItem item = (TreeItem)e.item;
if (item != null)
item.setExpanded(!item.getExpanded());
}
{
this$0 = ConfigView.this;
super();
}
});
}
catch (Exception e)
{
Logger.log(new LogEvent(LOGID, "Error initializing ConfigView", e));
}
scResizeListener = new Listener() {
final ConfigView this$0;
public void handleEvent(Event event)
{
setupSC((ScrolledComposite)event.widget);
}
{
this$0 = ConfigView.this;
super();
}
};
pluginSections = ConfigSectionRepository.getInstance().getList();
ConfigSection internalSections[] = {
new ConfigSectionMode(), new ConfigSectionConnection(), new ConfigSectionConnectionProxy(), new ConfigSectionConnectionAdvanced(), new ConfigSectionConnectionEncryption(), new ConfigSectionTransfer(azureus_core), new ConfigSectionTransferAutoSpeedSelect(), new ConfigSectionTransferAutoSpeed(), new ConfigSectionTransferAutoSpeedBeta(), new ConfigSectionTransferLAN(),
new ConfigSectionFile(), new ConfigSectionFileMove(), new ConfigSectionFileTorrents(), new ConfigSectionFileTorrentsDecoding(), new ConfigSectionFilePerformance(), new ConfigSectionInterface(), new ConfigSectionInterfaceLanguage(), new ConfigSectionInterfaceStart(), new ConfigSectionInterfaceDisplay(), new ConfigSectionInterfaceColor(),
new ConfigSectionInterfaceAlerts(), new ConfigSectionInterfacePassword(), new ConfigSectionInterfaceLegacy(), new ConfigSectionIPFilter(azureus_core), new ConfigSectionPlugins(this, azureus_core), new ConfigSectionStats(), new ConfigSectionTracker(azureus_core), new ConfigSectionTrackerClient(), new ConfigSectionTrackerServer(azureus_core), new ConfigSectionSecurity(),
new ConfigSectionSharing(), new ConfigSectionLogging()
};
pluginSections.addAll(0, Arrays.asList(internalSections));
for (int i = 0; i < pluginSections.size(); i++)
{
boolean plugin_section = i >= internalSections.length;
ConfigSection section = (ConfigSection)pluginSections.get(i);
if (!(section instanceof ConfigSectionSWT) && !(section instanceof UISWTConfigSection))
continue;
String name;
try
{
name = section.configSectionGetName();
}
catch (Exception e)
{
Logger.log(new LogEvent(LOGID, "A ConfigSection plugin caused an error while trying to call its configSectionGetName function", e));
name = "Bad Plugin";
}
String section_key = name;
if (plugin_section)
{
if (!MessageText.keyExists(section_key))
section_key = (new StringBuilder()).append("ConfigView.section.").append(name).toString();
} else
{
section_key = (new StringBuilder()).append("ConfigView.section.").append(name).toString();
}
try
{
String location = section.configSectionGetParentSection();
TreeItem treeItem;
if (location.equalsIgnoreCase("root"))
treeItem = new TreeItem(tree, 0);
else
if (location != "")
{
TreeItem treeItemFound = findTreeItem(tree, location);
if (treeItemFound != null)
{
if (location.equalsIgnoreCase("plugins"))
{
int position = findInsertPointFor(MessageText.getString(section_key), treeItemFound);
if (position == -1)
treeItem = new TreeItem(treeItemFound, 0);
else
treeItem = new TreeItem(treeItemFound, 0, position);
} else
{
treeItem = new TreeItem(treeItemFound, 0);
}
} else
{
treeItem = new TreeItem(tree, 0);
}
} else
{
treeItem = new TreeItem(tree, 0);
}
ScrolledComposite sc = new ScrolledComposite(cConfigSection, 768);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setLayoutData(new GridData(1808));
sc.getVerticalBar().setIncrement(16);
sc.addListener(11, scResizeListener);
if (i == 0)
{
Composite c;
if (section instanceof ConfigSectionSWT)
c = ((ConfigSectionSWT)section).configSectionCreate(sc);
else
c = ((UISWTConfigSection)section).configSectionCreate(sc);
sectionsCreated.add(section);
sc.setContent(c);
}
Messages.setLanguageText(treeItem, section_key);
treeItem.setData("Panel", sc);
treeItem.setData("ID", name);
treeItem.setData("ConfigSectionSWT", section);
sections.put(treeItem, section);
if (section instanceof ConfigSectionPlugins)
((ConfigSectionPlugins)section).initPluginSubSections();
}
catch (Exception e)
{
Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("ConfigSection plugin '").append(name).append("' caused an error").toString(), e));
}
}
if (composite instanceof Shell)
initApplyCloseButton();
else
initSaveButton();
TreeItem items[] = {
tree.getItems()[0]
};
tree.setSelection(items);
showSection(items[0]);
}
public void setupSC(ScrolledComposite sc)
{
Composite c = (Composite)sc.getContent();
if (c != null)
{
Point size1 = c.computeSize(sc.getClientArea().width, -1);
Point size = c.computeSize(-1, size1.y);
sc.setMinSize(size);
}
sc.getVerticalBar().setPageIncrement(sc.getSize().y);
}
protected void filterTree(String text)
{
filterText = text;
if (filterDelayTimer != null)
filterDelayTimer.destroy();
if (lblX != null && !lblX.isDisposed())
{
Image img = filterText.length() <= 0 ? imgSmallXGray : imgSmallX;
lblX.setImage(img);
}
filterDelayTimer = new Timer("Filter");
filterDelayTimer.addEvent(SystemTime.getCurrentTime() + 300L, new TimerEventPerformer() {
final ConfigView this$0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -