PageRenderTime 52ms CodeModel.GetById 30ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/sidekick/SideKickMenuProvider.java

#
Java | 70 lines | 32 code | 7 blank | 31 comment | 4 complexity | ea4c645a2507397abd4503ca721c3770 MD5 | raw file
 1/*
 2 * SideKickMenuProvider.java - SideKick Parser Menu
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2006 Alan Ezust
 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 sidekick;
24
25//{{{ Imports
26import javax.swing.*;
27import org.gjt.sp.jedit.menu.DynamicMenuProvider;
28import org.gjt.sp.jedit.*;
29//}}}
30
31// {{{ SideKickMenuProvider class
32public class SideKickMenuProvider implements DynamicMenuProvider
33{
34	static ActionSet parserSwitchers = null;
35	
36	// {{{ getParserSwitchers() method
37	/**
38	  @return an ActionSet for switching the to each of 
39	  the currently available SideKick parsers via the
40	  combo box.  */
41	static public ActionSet getParserSwitchers() {
42		if (parserSwitchers == null) {
43			parserSwitchers = new ActionSet("Plugin: SideKick - Parsers");
44		}
45		parserSwitchers.removeAllActions();
46		String[] serviceNames = ServiceManager.getServiceNames(SideKickParser.SERVICE);
47		for (String svcName: serviceNames) {
48			EditAction ea = new ParserSwitchAction(svcName);
49			parserSwitchers.addAction(ea);
50		}
51		return parserSwitchers;
52	} // }}}
53
54	//{{{ update() method	
55	public void update(JMenu superMenu)
56	{
57		JMenu menu = new JMenu("Parsers");
58		for (EditAction ea: getParserSwitchers().getActions()) {
59			menu.add(GUIUtilities.loadMenuItem(ea, false));
60		}
61		superMenu.add(menu);
62	} //}}}
63		
64	//{{{ updateEveryTime() method
65	public boolean updateEveryTime()
66	{
67		return false;
68	} //}}}
69
70} // }}}