PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/XInsert/src/XInsertActions.java

#
Java | 61 lines | 24 code | 6 blank | 31 comment | 6 complexity | d67398c38e4404d85e72b101fee1db74 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. * XInsertActions.java
  3. * Written (c) 2005 by Martin Raspe (raspe@biblhertz.it), using
  4. * ClipperActions.java
  5. * ( Copyright (c) 2001 John Gellene, Copyright (c) 2001, 2002 Andre Kaplan )
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. import javax.swing.JTree;
  22. import org.gjt.sp.jedit.View;
  23. import org.gjt.sp.jedit.gui.DockableWindowManager;
  24. /**
  25. * XInsertActions: provides actions that can be bound to keyboard shortcuts
  26. *
  27. * @author Martin Raspe
  28. * @created March 5, 2005
  29. * @modified $Date: 2005/05/11 12:27:51 $ by $Author: hertzhaft $
  30. * @version $Revision: 1.1 $
  31. */
  32. public class XInsertActions {
  33. public static void goToXInsert(View view) {
  34. // toggle focus of XInsert tree (making it visible if necessary)
  35. DockableWindowManager wm = view.getDockableWindowManager();
  36. if (!wm.isDockableWindowVisible(XInsertPlugin.NAME))
  37. wm.showDockableWindow(XInsertPlugin.NAME);
  38. XTree xtree = (XTree) wm.getDockableWindow(XInsertPlugin.NAME);
  39. if (xtree == null) return; // should never happen
  40. JTree tree = xtree.getTree();
  41. if (tree.hasFocus()) { // return to TextArea if tree is already focused
  42. view.getTextArea().requestFocus();
  43. return;
  44. };
  45. xtree.requestFocus();
  46. tree.requestFocus();
  47. }
  48. public static void insertSelected(View view) {
  49. // insert selected item from XInsert tree
  50. DockableWindowManager wm = view.getDockableWindowManager();
  51. //if (!wm.isDockableWindowVisible(XInsertPlugin.NAME)) return;
  52. XTree xtree = (XTree) wm.getDockableWindow(XInsertPlugin.NAME);
  53. if (xtree != null) xtree.treeAction();
  54. }
  55. }