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);
 }
 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);
 }
 public boolean isModified() {
   final ActionMacro[] allMacros = ActionMacroManager.getInstance().getAllMacros();
   if (allMacros.length != myMacrosModel.getSize()) return true;
   for (int i = 0; i < allMacros.length; i++) {
     ActionMacro macro = allMacros[i];
     ActionMacro newMacro = (ActionMacro) myMacrosModel.get(i);
     if (!macro.equals(newMacro)) return true;
   }
   return false;
 }
 public void reset() {
   final ActionMacro[] allMacros = ActionMacroManager.getInstance().getAllMacros();
   for (ActionMacro macro : allMacros) {
     myMacrosModel.addElement(macro.clone());
   }
   myMacrosList.setModel(myMacrosModel);
   ListScrollingUtil.ensureSelectionExists(myMacrosList);
 }
  public void apply() {
    if (myRenamingList != null) {
      for (Pair<String, String> pair : myRenamingList) {
        Keymap[] allKeymaps = KeymapManagerEx.getInstanceEx().getAllKeymaps();
        for (Keymap keymap : allKeymaps) {
          keymap.removeAllActionShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getSecond());
          for (Shortcut shortcut :
              keymap.getShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getFirst())) {
            keymap.addShortcut(ActionMacro.MACRO_ACTION_PREFIX + pair.getSecond(), shortcut);
          }
          keymap.removeAllActionShortcuts(ActionMacro.MACRO_ACTION_PREFIX + pair.getFirst());
        }
      }
    }

    final ActionMacroManager manager = ActionMacroManager.getInstance();
    ActionMacro[] macros = manager.getAllMacros();
    HashSet<String> removedIds = new HashSet<String>();
    for (ActionMacro macro1 : macros) {
      removedIds.add(macro1.getActionId());
    }

    manager.removeAllMacros();

    final Enumeration newMacros = myMacrosModel.elements();
    while (newMacros.hasMoreElements()) {
      ActionMacro macro = (ActionMacro) newMacros.nextElement();
      manager.addMacro(macro);
      removedIds.remove(macro.getActionId());
    }
    manager.registerActions();

    for (String id : removedIds) {
      Keymap[] allKeymaps = KeymapManagerEx.getInstanceEx().getAllKeymaps();
      for (Keymap keymap : allKeymaps) {
        keymap.removeAllActionShortcuts(id);
      }
    }
  }