PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. */
  22. package sidekick;
  23. import org.gjt.sp.jedit.Buffer;
  24. import org.gjt.sp.jedit.EditAction;
  25. import org.gjt.sp.jedit.View;
  26. import org.gjt.sp.jedit.gui.DockableWindowManager;
  27. /**
  28. * An action to switch the current SideKick parser.
  29. */
  30. public class ParserSwitchAction extends EditAction
  31. {
  32. String parserName ;
  33. public ParserSwitchAction(String parser)
  34. {
  35. super("sidekick.parser." + parser + "-switch");
  36. parserName = parser;
  37. }
  38. public String getLabel()
  39. {
  40. return parserName;
  41. }
  42. public String getCode()
  43. {
  44. return "new sidekick.ParserSwitchAction(\"" + parserName + "\").invoke(view)";
  45. }
  46. public void invoke(View view)
  47. {
  48. DockableWindowManager wm = view.getDockableWindowManager();
  49. wm.showDockableWindow("sidekick-tree");
  50. SideKick sk = SideKickPlugin.getSideKick(view);
  51. Buffer b = view.getBuffer();
  52. SideKickPlugin.setParserForBuffer(b, parserName);
  53. sk.parse(true);
  54. }
  55. }