PageRenderTime 241ms CodeModel.GetById 237ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 62 lines | 31 code | 7 blank | 24 comment | 0 complexity | 2705a8f2ee3f1f707f15486224b797ae MD5 | raw file
 1/*
 2 * ParserSwitchAction.java - Action to switch parsers in SideKick.
 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 */
22package sidekick;
23
24import org.gjt.sp.jedit.Buffer;
25import org.gjt.sp.jedit.EditAction;
26import org.gjt.sp.jedit.View;
27import org.gjt.sp.jedit.gui.DockableWindowManager;
28
29
30/**
31 * An action to switch the current SideKick parser.
32 */
33public class ParserSwitchAction extends EditAction
34{
35
36	String parserName ;
37	public ParserSwitchAction(String parser) 
38	{
39		super("sidekick.parser." + parser + "-switch");
40		parserName = parser;
41	}
42	public String getLabel() 
43	{
44		return parserName;
45	}
46	public String getCode()
47	{
48		return "new sidekick.ParserSwitchAction(\"" + parserName + "\").invoke(view)";
49	}
50	
51	public void invoke(View view)
52	{
53		DockableWindowManager wm = view.getDockableWindowManager();
54		wm.showDockableWindow("sidekick-tree");
55		SideKick sk = SideKickPlugin.getSideKick(view);
56		Buffer b = view.getBuffer();
57		SideKickPlugin.setParserForBuffer(b, parserName);
58		sk.parse(true);
59		
60	}
61
62}