public void reset() {
   final ActionMacro[] allMacros = ActionMacroManager.getInstance().getAllMacros();
   for (ActionMacro macro : allMacros) {
     myMacrosModel.addElement(macro.clone());
   }
   myMacrosList.setModel(myMacrosModel);
   ListScrollingUtil.ensureSelectionExists(myMacrosList);
 }
 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;
 }
 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 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);
      }
    }
  }