예제 #1
0
  protected void init() {
    super.init();

    java.util.List<Macro> macros = new ArrayList<Macro>(MacroManager.getInstance().getMacros());
    Collections.sort(
        macros,
        new Comparator<Macro>() {
          public int compare(Macro macro1, Macro macro2) {
            String name1 = macro1.getName();
            String name2 = macro2.getName();
            if (!StringUtil.startsWithChar(name1, '/')) {
              name1 = ZERO + name1;
            }
            if (!StringUtil.startsWithChar(name2, '/')) {
              name2 = ZERO + name2;
            }
            return name1.compareToIgnoreCase(name2);
          }

          private final String ZERO = new String(new char[] {0});
        });
    for (Macro macro : macros) {
      myMacrosModel.addElement(new MacroWrapper(macro));
    }

    addListeners();
    if (myMacrosModel.size() > 0) {
      myMacrosList.setSelectedIndex(0);
    } else {
      setOKActionEnabled(false);
    }
  }
예제 #2
0
 private static Tool findTool(String actionId, DataContext context) {
   MacroManager.getInstance().cacheMacrosPreview(context);
   for (Tool tool : getAllTools()) {
     if (actionId.equals(tool.getActionId())) {
       return tool;
     }
   }
   return null;
 }
예제 #3
0
  public MacrosDialog(Component parent) {
    super(parent, true);
    MacroManager.getInstance().cacheMacrosPreview(DataManager.getInstance().getDataContext(parent));
    setTitle(IdeBundle.message("title.macros"));
    setOKButtonText(IdeBundle.message("button.insert"));

    myMacrosModel = new DefaultListModel();
    myMacrosList = new JList(myMacrosModel);
    myPreviewTextarea = new JTextArea();

    init();
  }