PageRenderTime 92ms CodeModel.GetById 85ms app.highlight 2ms RepoModel.GetById 4ms 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
 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
22import javax.swing.JTree;
23
24import org.gjt.sp.jedit.View;
25import org.gjt.sp.jedit.gui.DockableWindowManager;
26
27/**
28 * XInsertActions: provides actions that can be bound to keyboard shortcuts
29 *
30 * @author     Martin Raspe
31 * @created    March 5, 2005
32 * @modified   $Date: 2005/05/11 12:27:51 $ by $Author: hertzhaft $
33 * @version    $Revision: 1.1 $
34 */
35public class XInsertActions {
36
37    public static void goToXInsert(View view) {
38	// toggle focus of XInsert tree (making it visible if necessary)
39        DockableWindowManager wm = view.getDockableWindowManager();
40        if (!wm.isDockableWindowVisible(XInsertPlugin.NAME)) 
41		wm.showDockableWindow(XInsertPlugin.NAME);
42        XTree xtree = (XTree) wm.getDockableWindow(XInsertPlugin.NAME);
43        if (xtree == null) return; // should never happen
44	JTree tree = xtree.getTree();
45	if (tree.hasFocus()) { // return to TextArea if tree is already focused
46		view.getTextArea().requestFocus();
47		return;
48		};
49	xtree.requestFocus();
50	tree.requestFocus();
51        }
52
53    public static void insertSelected(View view) {
54        // insert selected item from XInsert tree
55	DockableWindowManager wm = view.getDockableWindowManager();
56        //if (!wm.isDockableWindowVisible(XInsertPlugin.NAME)) return;
57        XTree xtree = (XTree) wm.getDockableWindow(XInsertPlugin.NAME);
58        if (xtree != null) xtree.treeAction();
59        }
60}
61