1 22 23 package macos.menu; 24 25 import java.awt.event.*; 27 import java.io.File ; 28 import java.util.Vector ; 29 import javax.swing.*; 30 import javax.swing.event.*; 31 import org.gjt.sp.jedit.*; 32 import org.gjt.sp.jedit.browser.*; 33 import org.gjt.sp.jedit.gui.*; 34 import macos.*; 35 37 public class ShowRecentDirMenu extends JMenu implements MenuListener 38 { 39 public ShowRecentDirMenu() 41 { 42 super(jEdit.getProperty("MacOSPlugin.menu.recentDir.label")); 43 addMenuListener(this); 44 } 46 private void construct() 48 { 49 HistoryModel model = HistoryModel.getModel("vfs.browser.path"); 50 JMenuItem item; 51 File file; 52 int max = model.getSize(); 53 54 if (max == 0) 55 { 56 item = new JMenuItem(jEdit.getProperty("MacOSPlugin.menu.recentDir.none")); 57 item.setEnabled(false); 58 add(item); 59 return; 60 } 61 62 for (int i=0; i < max ; i++) 63 { 64 file = new File (model.getItem(i)); 65 item = new ShowRecentDirMenuItem(file.getName(),file.getPath()); 66 item.setIcon(FileCellRenderer.dirIcon); 67 add(item); 68 } 69 } 71 public void menuSelected(MenuEvent e) 73 { 74 construct(); 75 } 77 public void menuDeselected(MenuEvent e) 79 { 80 removeAll(); 81 } 83 public void menuCanceled(MenuEvent e) 85 { 86 } 88 class ShowRecentDirMenuItem extends JMenuItem 90 { 91 String path; 92 93 public ShowRecentDirMenuItem(String name, String path) 94 { 95 super(name); 96 this.path = path; 97 addActionListener(new ShowFileAction()); 98 } 99 100 class ShowFileAction implements ActionListener 101 { 102 public void actionPerformed(ActionEvent e) 103 { 104 MacOSActions.showInFinder(path); 105 } 106 } 107 } } 109 | Popular Tags |