01: /*
02: * :tabSize=8:indentSize=8:noTabs=false:
03: * :folding=explicit:collapseFolds=1:
04: *
05: * MacOSMenu.java - Menu providing features for Mac OS
06: * Copyright (C) 2002 Kris Kopicki
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: */
22:
23: package macos.menu;
24:
25: //{{{ Imports
26: 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:
36: //}}}
37:
38: public class MacOSMenu implements DynamicMenuProvider {
39: //{{{ Constructor
40: public MacOSMenu() {
41: //super();
42: } //}}}
43:
44: //{{{ updateEveryTime() method
45: public boolean updateEveryTime() {
46: return true;
47: } //}}}
48:
49: //{{{ update() method
50: public void update(JMenu menu) {
51: File buff = new File(jEdit.getActiveView().getBuffer()
52: .getPath());
53:
54: JMenuItem showCurrent = new JMenuItem(jEdit
55: .getProperty("MacOSPlugin.menu.showCurrent"));
56: showCurrent
57: .addActionListener(new ShowFileAction(buff.getPath()));
58: showCurrent.setEnabled(buff.exists());
59: JMenuItem showCurrentDir = new JMenuItem(jEdit
60: .getProperty("MacOSPlugin.menu.showCurrentDir"));
61: showCurrentDir.addActionListener(new ShowDirAction(buff
62: .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: } //}}}
71:
72: //{{{ ShowFileAction class
73: class ShowFileAction implements ActionListener {
74: private String path;
75:
76: public ShowFileAction(String path) {
77: this .path = path;
78: }
79:
80: public void actionPerformed(ActionEvent e) {
81: MacOSActions.showInFinder(path);
82: }
83: } //}}}
84:
85: //{{{ ShowDirAction class
86: class ShowDirAction implements ActionListener {
87: private String path;
88:
89: public ShowDirAction(String path) {
90: this .path = path;
91: }
92:
93: public void actionPerformed(ActionEvent e) {
94: MacOSActions.showInFinder(path);
95: }
96: } //}}}
97: }
|