PageRenderTime 221ms CodeModel.GetById 215ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Java | 106 lines | 65 code | 12 blank | 29 comment | 4 complexity | 7a301980168f8aedad069c07ec4224c2 MD5 | raw file
  1/* 
  2 * :tabSize=8:indentSize=8:noTabs=false:
  3 * :folding=explicit:collapseFolds=1:
  4 *
  5 * ShowBufferMenu.java
  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.event.*;
 27import java.io.File;
 28import javax.swing.*;
 29import javax.swing.event.*;
 30import org.gjt.sp.jedit.*;
 31import org.gjt.sp.jedit.browser.*;
 32import macos.*;
 33//}}}
 34
 35public class ShowBufferMenu extends JMenu implements MenuListener
 36{
 37	//{{{ Constructor
 38	public ShowBufferMenu()
 39	{
 40		super(jEdit.getProperty("MacOSPlugin.menu.buffers.label"));
 41		addMenuListener(this);
 42	} //}}}
 43	
 44	//{{{ construct() method
 45	private void construct()
 46	{
 47		JMenuItem item;
 48		removeAll();
 49		
 50		Buffer[] buffs = jEdit.getBuffers();
 51		for (int i=0; i < buffs.length; i++)
 52		{
 53			if (!buffs[i].isUntitled())
 54			{
 55				item = add(new ShowBufferMenuItem(
 56					buffs[i].getName(),buffs[i].getPath()));
 57				item.setIcon(FileCellRenderer.fileIcon);
 58				add(item);
 59			}
 60		}
 61		
 62		if (getItemCount() == 0)
 63		{
 64			item = new JMenuItem(jEdit.getProperty("MacOSPlugin.menu.buffers.none"));
 65			item.setEnabled(false);
 66			add(item);
 67		}
 68	} //}}}
 69	
 70	//{{{ menuSelected() method
 71	public void menuSelected(MenuEvent e)
 72	{
 73		construct();
 74	} //}}}
 75	
 76	//{{{ menuDeselected() method
 77	public void menuDeselected(MenuEvent e)
 78	{
 79	} //}}}
 80	
 81	//{{{ menuCanceled() method
 82	public void menuCanceled(MenuEvent e)
 83	{
 84	} //}}}
 85	
 86	//{{{ ShowBufferMenuItem class
 87	class ShowBufferMenuItem extends JMenuItem
 88	{
 89		String path;
 90		
 91		public ShowBufferMenuItem(String name, String path)
 92		{
 93			super(name);
 94			this.path = path;
 95			addActionListener(new ShowFileAction());
 96		}
 97		
 98		class ShowFileAction implements ActionListener
 99		{
100			public void actionPerformed(ActionEvent e)
101			{
102				MacOSActions.showInFinder(path);
103			}
104		}
105	} //}}}
106}