Exemplo n.º 1
0
        public void actionPerformed(ActionEvent e) {

          // Interpreter.abort();//17.9.2010 -checks for null instance etc removed 11.8.2013
          Editor ed = OJ.editor;

          String theText = ed.getText();
          theText = UtilsOJ.fixLineFeeds(theText); // 7.9.2010
          OJ.getData().setLinkedMacroText(theText);
          int caretPos = ed.getTextArea().getCaretPosition();
          ed.getTextArea().setText(theText);
          ed.getTextArea().setCaretPosition(caretPos);

          doInstall(theText);
          setEditorUnchanged(ed);
          ij.IJ.getInstance().setVisible(true);
        }
Exemplo n.º 2
0
  public void doInstall(String macros_text) { // Normal Load Project Macros  //20.9.2010

    Interpreter intp = Interpreter.getInstance();
    if (intp != null) {
      Interpreter.getInstance().abortMacro(); // 11.8.2013
    }

    // ImageJAccessOJ.InterpreterAccess.
    OJ.initMacroProcessor(); // 4.7.2013
    // OJ.getMacroProcessor().setTarget("exit");//4.7.2013

    macros_text = UtilsOJ.fixLineFeeds(macros_text);
    // }
    String clean_macro_text = UtilsOJ.maskComments(macros_text);
    clean_macro_text = clean_macro_text.replaceAll("macro\"", "macro \""); // 19.10.2010
    if ((clean_macro_text != null) && (!clean_macro_text.equals(""))) {
      boolean leadingPart = !clean_macro_text.startsWith("macro");
      String[] macros = clean_macro_text.split("macro "); //
      int numMacros = macros.length;
      if (leadingPart) {
        numMacros--;
      }
      String project_name = OJ.getData().getName();
      if (numMacros > 0) { // 7.9.2010
        MacroSetOJ macroSet = OJ.getData().getMacroSet();
        macroSet = new MacroSetOJ();
        macroSet.setName(project_name);
        macroSet.installText(macros_text);
        OJ.getData().setMacroSet(macroSet);
        OJ.getEventProcessor()
            .fireMacroChangedEvent(project_name, MacroChangedEventOJ.MACROSET_EDITED);
        ij.IJ.showStatus("" + numMacros + " embedded macros have been loaded");
      }
    }
    ToolManagerOJ.getInstance().reload();
  }