1 22 23 package macos.menu; 24 25 import java.awt.*; 27 import java.awt.event.*; 28 import java.io.File ; 29 import javax.swing.*; 30 import javax.swing.event.*; 31 import org.gjt.sp.jedit.*; 32 import org.gjt.sp.jedit.menu.*; 33 import org.gjt.sp.util.Log; 34 import macos.*; 35 37 public class MacOSMenu implements DynamicMenuProvider 38 { 39 public MacOSMenu() 41 { 42 } 45 public boolean updateEveryTime() 47 { 48 return true; 49 } 51 public void update(JMenu menu) 53 { 54 File buff = new File (jEdit.getActiveView().getBuffer().getPath()); 55 56 JMenuItem showCurrent = new JMenuItem( 57 jEdit.getProperty("MacOSPlugin.menu.showCurrent")); 58 showCurrent.addActionListener(new ShowFileAction(buff.getPath())); 59 showCurrent.setEnabled(buff.exists()); 60 JMenuItem showCurrentDir = new JMenuItem( 61 jEdit.getProperty("MacOSPlugin.menu.showCurrentDir")); 62 showCurrentDir.addActionListener(new ShowDirAction(buff.getParent())); 63 showCurrent.setEnabled(buff.getParentFile().exists()); 64 menu.add(showCurrent); 65 menu.add(showCurrentDir); 66 menu.addSeparator(); 67 menu.add(new ShowBufferMenu()); 68 menu.add(new ShowRecentMenu()); 69 menu.add(new ShowRecentDirMenu()); 70 } 72 class ShowFileAction implements ActionListener 74 { 75 private String path; 76 77 public ShowFileAction(String path) 78 { 79 this.path = path; 80 } 81 82 public void actionPerformed(ActionEvent e) 83 { 84 MacOSActions.showInFinder(path); 85 } 86 } 88 class ShowDirAction implements ActionListener 90 { 91 private String path; 92 93 public ShowDirAction(String path) 94 { 95 this.path = path; 96 } 97 98 public void actionPerformed(ActionEvent e) 99 { 100 MacOSActions.showInFinder(path); 101 } 102 } } 104 | Popular Tags |