KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > macos > menu > MacOSMenu


1 /*
2  * :tabSize=8:indentSize=8:noTabs=false:
3  * :folding=explicit:collapseFolds=1:
4  *
5  * MacOSMenu.java - Menu providing features for Mac OS
6  * Copyright (C) 2002 Kris Kopicki
7  *
8  * This program is free software; you can redistribute it and/or
9  * 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 JavaDoc;
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 public class MacOSMenu implements DynamicMenuProvider
38 {
39     //{{{ Constructor
40
public MacOSMenu()
41     {
42         //super();
43
} //}}}
44

45     //{{{ updateEveryTime() method
46
public boolean updateEveryTime()
47     {
48         return true;
49     } //}}}
50

51     //{{{ update() method
52
public void update(JMenu menu)
53     {
54         File JavaDoc buff = new File JavaDoc(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     } //}}}
71

72     //{{{ ShowFileAction class
73
class ShowFileAction implements ActionListener
74     {
75         private String JavaDoc path;
76         
77         public ShowFileAction(String JavaDoc path)
78         {
79             this.path = path;
80         }
81         
82         public void actionPerformed(ActionEvent e)
83         {
84             MacOSActions.showInFinder(path);
85         }
86     } //}}}
87

88     //{{{ ShowDirAction class
89
class ShowDirAction implements ActionListener
90     {
91         private String JavaDoc path;
92         
93         public ShowDirAction(String JavaDoc path)
94         {
95             this.path = path;
96         }
97         
98         public void actionPerformed(ActionEvent e)
99         {
100             MacOSActions.showInFinder(path);
101         }
102     } //}}}
103
}
104
Popular Tags