private void fillList(final HighlightSeverity severity) { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<SeverityBasedTextAttributes>(); infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); Collections.sort( infoTypes, new Comparator<SeverityBasedTextAttributes>() { @Override public int compare( SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) { return -mySeverityRegistrar.compare( attributes1.getSeverity(), attributes2.getSeverity()); } }); SeverityBasedTextAttributes preselection = null; for (SeverityBasedTextAttributes type : infoTypes) { model.addElement(type); if (type.getSeverity().equals(severity)) { preselection = type; } } myOptionsList.setModel(model); myOptionsList.setSelectedValue(preselection, true); }
public void reset() { final ActionMacro[] allMacros = ActionMacroManager.getInstance().getAllMacros(); for (ActionMacro macro : allMacros) { myMacrosModel.addElement(macro.clone()); } myMacrosList.setModel(myMacrosModel); ListScrollingUtil.ensureSelectionExists(myMacrosList); }
private void initActionList(ActionMacro macro) { DefaultListModel actionModel = new DefaultListModel(); final ActionMacro.ActionDescriptor[] actions = macro.getActions(); for (ActionMacro.ActionDescriptor action : actions) { actionModel.addElement(action); } myMacroActionsList.setModel(actionModel); ListScrollingUtil.ensureSelectionExists(myMacroActionsList); }