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 showEmbeddedMacros(int modifier) {

    showPopUp = ((modifier & KeyEvent.ALT_MASK) != 0);
    String macros_text = OJ.getData().getLinkedMacroText();
    if (macros_text == null) {
      macros_text = "";
    }
    Window theWindow = OJ.editorWindow;
    if (theWindow != null && theWindow.isShowing() && OJ.editor != null) {
      theWindow.setVisible(true);
      return;
    }

    String version = IJ.getFullVersion();
    Editor ed;
    if (version.compareToIgnoreCase("1.49i03") >= 0) {
      ed = new EditorOJ(16, 60, 0, Editor.MONOSPACED + Editor.MENU_BAR);
    } else {
      ed = new Editor(16, 60, 0, Editor.MONOSPACED + Editor.MENU_BAR);
    }
    ed.create("Embedded Macros", macros_text);
    JButton loadButton = new JButton("Install in ObjectJ menu");
    loadButton.addActionListener(LoadEmbeddedMacroAction);

    TextArea ta = ed.getTextArea();
    ed.remove(ta);
    ed.setLayout(new BorderLayout());
    JPanel panel1 = new JPanel();

    panel1.setLayout(new FlowLayout());
    loadButton.setFont(new Font("SansSerif", Font.PLAIN, 14));
    panel1.add(loadButton);

    JLabel myLabel = new JLabel("Macros Overview");

    if (showPopUp) {
      panel1.add(myLabel);
    }
    myLabel.setForeground(Color.blue);
    myLabel.setAutoscrolls(true);

    macrosPopup = new javax.swing.JPopupMenu();

    myLabel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseEntered(java.awt.event.MouseEvent evt) {

            refreshPopupItems();
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
              ij.IJ.showStatus("Right-Click to navigate through macros");
              //                            + "\n-"
              //                            + "\nYou also can enter bookmark tags into the macro
              // text:"
              //                            + "\n //<<   bookmarks left part of line"
              //                            + "\n //>>   bookmarks right part of line");
            }
          }
        });

    myLabel.setComponentPopupMenu(macrosPopup);

    ed.add(BorderLayout.NORTH, panel1);
    ed.add(BorderLayout.CENTER, ta);

    Font monoFont = new Font("Monospaced", Font.PLAIN, 14);
    ta.setFont(monoFont);
    OJ.editor = ed;
    Frame[] frames = WindowManager.getNonImageWindows();
    Frame frame = frames[frames.length - 1];
    // ij.IJ.log(WindowManager.getFrontWindow().getTitle());
    // ij.IJ.log(frame.getTitle());//"Embedded Macros"
    // ij.IJ.log("---");//"Embedded Macros"
    OJ.editorWindow = WindowManager.getFrontWindow();
    refreshPopupItems();
    loadButton.transferFocus();
  }