}
}
public void loadModules() {
this.lastPosition = null;
ClickableItem selectedItem = target.getSelectedItem();
if (selectedItem != null) {
moduleButtons = new ArrayList<ClickableModule>();
categories = new HashMap<String, ModuleSelectionSubFrame>();
List<IPowerModule> workingModules = ModuleManager.getValidModulesForItem(null, selectedItem.getItem());
// Prune the list of disallowed modules, if not installed on this
// item.
for (Iterator<IPowerModule> it = workingModules.iterator(); it.hasNext(); ) {
IPowerModule module = it.next();
if (module.isAllowed() == false &&
ModuleManager.itemHasModule(selectedItem.getItem(), module.getDataName()) == false) {
it.remove();
}
}
if (workingModules.size() > 0) {
this.selectedModule = -1;
for (IPowerModule module : workingModules) {
ModuleSelectionSubFrame frame = getOrCreateCategory(module.getCategory());
ClickableModule moduleClickable = frame.addModule(module);
// Indicate installed modules
if (!module.isAllowed()) {
// If a disallowed module made it to the list, indicate
// it as disallowed
moduleClickable.setAllowed(false);
} else if (ModuleManager.itemHasModule(selectedItem.getItem(), module.getDataName())) {
moduleClickable.setInstalled(true);
}
if (moduleClickable.getModule().equals(this.prevSelection)) {
this.selectedModule = moduleButtons.size();
}