PageRenderTime 202ms CodeModel.GetById 198ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/jars/MacOS/macos/menu/MacOSMenu.java

#
Java | 103 lines | 62 code | 12 blank | 29 comment | 0 complexity | 6aef6c368b34d5a08239548bee350066 MD5 | raw file
  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
 23package macos.menu;
 24
 25//{{{ Imports
 26import java.awt.*;
 27import java.awt.event.*;
 28import java.io.File;
 29import javax.swing.*;
 30import javax.swing.event.*;
 31import org.gjt.sp.jedit.*;
 32import org.gjt.sp.jedit.menu.*;
 33import org.gjt.sp.util.Log;
 34import macos.*;
 35//}}}
 36
 37public 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 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	} //}}}
 71	
 72	//{{{ ShowFileAction class
 73	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	} //}}}
 87	
 88	//{{{ ShowDirAction class
 89	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	} //}}}
103}