📄 configview.java
字号:
public void perform(TimerEvent event)
{
filterDelayTimer.destroy();
filterDelayTimer = null;
Utils.execSWTThread(new AERunnable() {
final 7 this$1;
public void runSupport()
{
ArrayList foundItems;
TreeItem items[];
foundItems = new ArrayList();
items = tree.getItems();
tree.setRedraw(false);
for (int i = 0; i < items.length; i++)
items[i].setExpanded(false);
filterTree(items, filterText, foundItems);
tree.setRedraw(true);
break MISSING_BLOCK_LABEL_115;
Exception exception;
exception;
tree.setRedraw(true);
throw exception;
}
{
this$1 = 7.this;
super();
}
});
}
{
this$0 = ConfigView.this;
super();
}
});
}
protected void filterTree(TreeItem items[], String text, ArrayList foundItems)
{
text = text.toLowerCase();
for (int i = 0; i < items.length; i++)
{
ensureSectionBuilt(items[i]);
ScrolledComposite composite = (ScrolledComposite)items[i].getData("Panel");
if (text.length() > 0 && (items[i].getText().toLowerCase().indexOf(text) >= 0 || compositeHasText(composite, text)))
{
foundItems.add(items[i]);
ensureExpandedTo(items[i]);
items[i].setFont(filterFoundFont);
} else
{
items[i].setFont(null);
}
filterTree(items[i].getItems(), text, foundItems);
}
}
private void ensureExpandedTo(TreeItem item)
{
TreeItem itemParent = item.getParentItem();
if (itemParent != null)
{
itemParent.setExpanded(true);
ensureExpandedTo(itemParent);
}
}
private boolean compositeHasText(Composite composite, String text)
{
org.eclipse.swt.widgets.Control children[] = composite.getChildren();
for (int i = 0; i < children.length; i++)
{
org.eclipse.swt.widgets.Control child = children[i];
if (child instanceof Label)
{
if (((Label)child).getText().toLowerCase().indexOf(text) >= 0)
return true;
} else
if (child instanceof Group)
{
if (((Group)child).getText().toLowerCase().indexOf(text) >= 0)
return true;
} else
if ((child instanceof Button) && ((Button)child).getText().toLowerCase().indexOf(text) >= 0)
return true;
if ((child instanceof Composite) && compositeHasText((Composite)child, text))
return true;
}
return false;
}
private void showSection(TreeItem section)
{
ScrolledComposite item = (ScrolledComposite)section.getData("Panel");
if (item != null)
{
ensureSectionBuilt(section);
layoutConfigSection.topControl = item;
setupSC(item);
cConfigSection.layout();
updateHeader(section);
}
}
private void ensureSectionBuilt(TreeItem treeSection)
{
ScrolledComposite item = (ScrolledComposite)treeSection.getData("Panel");
if (item != null)
{
ConfigSection configSection = (ConfigSection)treeSection.getData("ConfigSectionSWT");
if (configSection != null)
{
org.eclipse.swt.widgets.Control previous = item.getContent();
if (previous instanceof Composite)
{
configSection.configSectionDelete();
sectionsCreated.remove(configSection);
Utils.disposeComposite((Composite)previous, true);
}
Composite c;
if (configSection instanceof ConfigSectionSWT)
c = ((ConfigSectionSWT)configSection).configSectionCreate(item);
else
c = ((UISWTConfigSection)configSection).configSectionCreate(item);
sectionsCreated.add(configSection);
item.setContent(c);
}
}
}
private void updateHeader(TreeItem section)
{
if (section == null)
return;
int userMode = COConfigurationManager.getIntParameter("User Mode");
int maxUsermode = 0;
try
{
ConfigSection sect = (ConfigSection)sections.get(section);
if (sect instanceof UISWTConfigSection)
maxUsermode = ((UISWTConfigSection)sect).maxUserMode();
}
catch (Error e) { }
if (userMode < maxUsermode)
Messages.setLanguageText(usermodeHint, "ConfigView.higher.mode.available");
else
usermodeHint.setText("");
String sHeader = section.getText();
for (section = section.getParentItem(); section != null; section = section.getParentItem())
sHeader = (new StringBuilder()).append(section.getText()).append(" : ").append(sHeader).toString();
lHeader.setText((new StringBuilder()).append(" ").append(sHeader.replaceAll("&", "&&")).toString());
lHeader.getParent().layout(true, true);
}
private Composite createConfigSection(String sNameID)
{
return createConfigSection(null, sNameID, -1, true);
}
private Composite createConfigSection(String sNameID, int position)
{
return createConfigSection(null, sNameID, position, true);
}
public Composite createConfigSection(TreeItem treeItemParent, String sNameID, int position, boolean bPrefix)
{
ScrolledComposite sc = new ScrolledComposite(this.cConfigSection, 768);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setLayoutData(new GridData(1808));
sc.getVerticalBar().setIncrement(16);
sc.addListener(11, scResizeListener);
Composite cConfigSection = new Composite(sc, 0);
String section_key = (new StringBuilder()).append(bPrefix ? "ConfigView.section." : "").append(sNameID).toString();
if (position == -2)
position = findInsertPointFor(MessageText.getString(section_key), treeItemParent != null ? ((Object) (treeItemParent)) : ((Object) (tree)));
TreeItem treeItem;
if (treeItemParent == null)
{
if (position >= 0)
treeItem = new TreeItem(tree, 0, position);
else
treeItem = new TreeItem(tree, 0);
} else
if (position >= 0)
treeItem = new TreeItem(treeItemParent, 0, position);
else
treeItem = new TreeItem(treeItemParent, 0);
Messages.setLanguageText(treeItem, section_key);
treeItem.setData("Panel", sc);
treeItem.setData("ID", sNameID);
sc.setContent(cConfigSection);
return cConfigSection;
}
public static int findInsertPointFor(String name, Object structure)
{
TreeItem children[] = null;
if (structure instanceof Tree)
children = ((Tree)structure).getItems();
else
children = ((TreeItem)structure).getItems();
if (children.length == 0)
return -1;
int result = Arrays.binarySearch(children, name, insert_point_comparator);
if (result > 0)
return result;
result = -(result + 1);
if (result == children.length)
result = -1;
return result;
}
public TreeItem findTreeItem(String ID)
{
return findTreeItem((Tree)null, ID);
}
private TreeItem findTreeItem(Tree tree, String ID)
{
if (tree == null)
tree = this.tree;
TreeItem items[] = tree.getItems();
for (int i = 0; i < items.length; i++)
{
String itemID = (String)items[i].getData("ID");
if (itemID != null && itemID.equalsIgnoreCase(ID))
return items[i];
TreeItem itemFound = findTreeItem(items[i], ID);
if (itemFound != null)
return itemFound;
}
return null;
}
private TreeItem findTreeItem(TreeItem item, String ID)
{
TreeItem subItems[] = item.getItems();
for (int i = 0; i < subItems.length; i++)
{
String itemID = (String)subItems[i].getData("ID");
if (itemID != null && itemID.equalsIgnoreCase(ID))
return subItems[i];
TreeItem itemFound = findTreeItem(subItems[i], ID);
if (itemFound != null)
return itemFound;
}
return null;
}
private void initSaveButton()
{
final Button save = new Button(cConfig, 8);
Messages.setLanguageText(save, "ConfigView.button.save");
GridData gridData = new GridData(32);
gridData.horizontalSpan = 2;
gridData.widthHint = 80;
save.setLayoutData(gridData);
save.addSelectionListener(new SelectionAdapter() {
final Button val$save;
final ConfigView this$0;
public void widgetSelected(SelectionEvent event)
{
save.setFocus();
ConfigView.this.save();
}
{
this$0 = ConfigView.this;
save = button;
super();
}
});
}
private void initApplyCloseButton()
{
Composite cButtons = new Composite(cConfig, 0);
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
gridLayout.numColumns = 2;
cButtons.setLayout(gridLayout);
cButtons.setLayoutData(new GridData(128));
final Button apply = new Button(cButtons, 8);
Messages.setLanguageText(apply, "Button.apply");
GridData gridData = new GridData(32);
gridData.widthHint = 80;
apply.setLayoutData(gridData);
apply.addSelectionListener(new SelectionAdapter() {
final Button val$apply;
final ConfigView this$0;
public void widgetSelected(SelectionEvent event)
{
apply.setFocus();
save();
}
{
this$0 = ConfigView.this;
apply = button;
super();
}
});
Button close = new Button(cButtons, 8);
Messages.setLanguageText(close, "Button.close");
gridData = new GridData(32);
gridData.widthHint = 80;
close.setLayoutData(gridData);
close.addSelectionListener(new SelectionAdapter() {
final Button val$apply;
final ConfigView this$0;
public void widgetSelected(SelectionEvent event)
{
apply.setFocus();
save();
apply.getShell().dispose();
}
{
this$0 = ConfigView.this;
apply = button;
super();
}
});
}
public Composite getComposite()
{
return cConfig;
}
public void updateLanguage()
{
super.updateLanguage();
updateHeader(tree.getSelection()[0]);
}
public void delete()
{
for (Iterator i$ = sectionsCreated.iterator(); i$.hasNext();)
{
ConfigSection section = (ConfigSection)i$.next();
try
{
section.configSectionDelete();
}
catch (Exception e)
{
Debug.out("Error while deleting config section", e);
}
}
sectionsCreated.clear();
pluginSections.clear();
if (!tree.isDisposed())
{
TreeItem items[] = tree.getItems();
for (int i = 0; i < items.length; i++)
{
Composite c = (Composite)items[i].getData("Panel");
Utils.disposeComposite(c);
items[i].setData("Panel", null);
items[i].setData("ConfigSectionSWT", null);
}
}
Utils.disposeComposite(cConfig);
Utils.disposeSWTObjects(new Object[] {
headerFont, filterFoundFont
});
headerFont = null;
filterFoundFont = null;
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.releaseImage("smallx-gray");
imageLoader.releaseImage("smallx");
}
public String getFullTitle()
{
return MessageText.getString(MessageText.resolveLocalizationKey("ConfigView.title.full"));
}
public boolean selectSection(String id)
{
TreeItem ti = findTreeItem(id);
if (ti == null)
{
return false;
} else
{
tree.setSelection(new TreeItem[] {
ti
});
showSection(ti);
return true;
}
}
public void selectSection(Class config_section_class)
{
TreeItem items[] = tree.getItems();
int i = 0;
do
{
if (i >= items.length)
break;
TreeItem item = items[i];
ConfigSection section = (ConfigSection)item.getData("ConfigSectionSWT");
if (section != null && section.getClass() == config_section_class)
{
tree.setSelection(new TreeItem[] {
item
});
showSection(item);
break;
}
i++;
} while (true);
}
public void save()
{
COConfigurationManager.setParameter("updated", 1);
COConfigurationManager.save();
if (null != pluginSections)
{
for (int i = 0; i < pluginSections.size(); i++)
((ConfigSection)pluginSections.get(i)).configSectionSave();
}
}
static
{
LOGID = LogIDs.GUI;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -