/** Used by open() and IJ.open() to open text URLs. */ void openTextURL(String url) { if (url.endsWith(".pdf") || url.endsWith(".zip")) return; String text = IJ.openUrlAsString(url); if (text != null && text.startsWith("<Error: ")) { IJ.error("Open Text URL", text); return; } String name = url.substring(7); int index = name.lastIndexOf("/"); int len = name.length(); if (index == len - 1) name = name.substring(0, len - 1); else if (index != -1 && index < len - 1) name = name.substring(index + 1); name = name.replaceAll("%20", " "); Editor ed = new Editor(); ed.setSize(600, 300); ed.create(name, text); IJ.showStatus(""); }
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(); }