run()
{
for (int i = 0; i < items.length; i++) {
int index = items[i];
if (index >= 0 && index < pluginIFs.size()) {
PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
if (pluginIF.getPluginState().isOperational()) {
if (pluginIF.getPluginState().isUnloadable()) {
try {
pluginIF.getPluginState().unload();
} catch (PluginException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
Utils.execSWTThread(
new Runnable()
{
public void
run()
{
pluginIFs = rebuildPluginIFs();
table.setItemCount(pluginIFs.size());
Collections.sort(pluginIFs, comparator);
table.clearAll();
}
});
}
}
}
}.start();
}
});
btnUnload.setEnabled( false );
final Button btnLoad = new Button(cButtons, SWT.PUSH);
btnUnload.setLayoutData(new GridData());
Messages.setLanguageText(btnLoad, "ConfigView.pluginlist.loadSelected");
btnLoad.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final int[] items = table.getSelectionIndices();
new AEThread2( "load" ){
public void
run()
{
for (int i = 0; i < items.length; i++) {
int index = items[i];
if (index >= 0 && index < pluginIFs.size()) {
PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
if (pluginIF.getPluginState().isOperational()) {continue;} // Already loaded.
// Re-enable disabled plugins, as long as they haven't failed on
// initialise.
if (pluginIF.getPluginState().isDisabled()) {
if (pluginIF.getPluginState().hasFailed()) {continue;}
pluginIF.getPluginState().setDisabled(false);
}
try {
pluginIF.getPluginState().reload();
} catch (PluginException e1) {
// TODO Auto-generated catch block
Debug.printStackTrace(e1);
}
Utils.execSWTThread(
new Runnable()
{
public void
run()
{
pluginIFs = rebuildPluginIFs();
table.setItemCount(pluginIFs.size());
Collections.sort(pluginIFs, comparator);
table.clearAll();
}
});
}
}
}
}.start();
}
});
btnLoad.setEnabled( false );
final Button btnScan = new Button(cButtons, SWT.PUSH);
btnScan.setLayoutData(new GridData());
Messages.setLanguageText(btnScan, "ConfigView.pluginlist.scan");
btnScan.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
AzureusCoreFactory.getSingleton().getPluginManager().refreshPluginList(false);
pluginIFs = rebuildPluginIFs();
table.setItemCount(pluginIFs.size());
Collections.sort(pluginIFs, comparator);
table.clearAll();
}
});
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
int index = table.indexOf(item);
PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
for (int i = 0; i < COLUMN_HEADERS.length; i++) {
if (i == FilterComparator.FIELD_NAME)
item.setImage(i, pluginIF.getPluginState().isOperational()
? imgGreenLed : imgRedLed);
String sText = comparator.getFieldValue(i, pluginIF);
if (sText == null)
sText = "";
item.setText(i, sText);
}
item.setGrayed(pluginIF.getPluginState().isMandatory());
boolean bEnabled = pluginIF.getPluginState().isLoadedAtStartup();
Utils.setCheckedInSetData(item, bEnabled);
item.setData("PluginID", pluginIF.getPluginID());
Utils.alternateRowBackground(item);
}
});
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem item = (TableItem) e.item;
int index = table.indexOf(item);
PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
if (e.detail == SWT.CHECK){
if (item.getGrayed()) {
if (!item.getChecked())
item.setChecked(true);
return;
}
pluginIF.getPluginState().setDisabled(!item.getChecked());
pluginIF.getPluginState().setLoadedAtStartup(item.getChecked());
}
btnUnload.setEnabled(pluginIF.getPluginState().isOperational() && pluginIF.getPluginState().isUnloadable());
btnLoad.setEnabled(!pluginIF.getPluginState().isOperational() && !pluginIF.getPluginState().hasFailed());
}
});
table.setItemCount(pluginIFs.size());