📄 actioncontext.java
字号:
/* * ActionContext.java - For code sharing between jEdit and VFSBrowser * :tabSize=8:indentSize=8:noTabs=false: * :folding=explicit:collapseFolds=1: * * Copyright (C) 1998, 2003 Slava Pestov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */package org.gjt.sp.jedit;import java.util.*;/** * Manages a collection of action sets. There are two instances of this class * in jEdit: * <ul> * <li>{@link org.gjt.sp.jedit.jEdit#getActionContext()} - editor actions * <li>{@link org.gjt.sp.jedit.browser.VFSBrowser#getActionContext()} - browser * actions * </ul> * * @since jEdit 4.2pre1 * @author Slava Pestov * @version $Id: ActionContext.java,v 1.4 2004/03/20 06:08:49 spestov Exp $ */public abstract class ActionContext{ //{{{ invokeAction() method /** * Invokes the given action in response to a user-generated event. * @param evt The event * @param action The action * @since jEdit 4.2pre1 */ public abstract void invokeAction(EventObject evt, EditAction action); //}}} //{{{ addActionSet() method /** * Adds a new action set to the context. * @since jEdit 4.2pre1 */ public void addActionSet(ActionSet actionSet) { actionNames = null; actionSets.addElement(actionSet); actionSet.context = this; String[] actions = actionSet.getActionNames(); for(int i = 0; i < actions.length; i++) { actionHash.put(actions[i],actionSet); } } //}}} //{{{ removeActionSet() method /** * Removes an action set from the context. * @since jEdit 4.2pre1 */ public void removeActionSet(ActionSet actionSet) { actionNames = null; actionSets.removeElement(actionSet); actionSet.context = null; String[] actions = actionSet.getActionNames(); for(int i = 0; i < actions.length; i++) { actionHash.remove(actions[i]); } } //}}} //{{{ getActionSets() method /** * Returns all registered action sets. * @since jEdit 4.2pre1 */ public ActionSet[] getActionSets() { ActionSet[] retVal = new ActionSet[actionSets.size()]; actionSets.copyInto(retVal); return retVal; } //}}} //{{{ getAction() method /** * Returns the specified action. * @param name The action name * @since jEdit 4.2pre1 */ public EditAction getAction(String name) { ActionSet set = (ActionSet)actionHash.get(name); if(set == null) return null; else return set.getAction(name); } //}}} //{{{ getActionSetForAction() method /** * Returns the action set that contains the specified action. * * @param action The action * @since jEdit 4.2pre1 */ public ActionSet getActionSetForAction(String action) { return (ActionSet)actionHash.get(action); } //}}} //{{{ getActionNames() method /** * Returns all registered action names. */ public String[] getActionNames() { if(actionNames == null) { List vec = new LinkedList(); for(int i = 0; i < actionSets.size(); i++) ((ActionSet)actionSets.elementAt(i)).getActionNames(vec); actionNames = (String[])vec.toArray( new String[vec.size()]); Arrays.sort(actionNames, new MiscUtilities.StringICaseCompare()); } return actionNames; } //}}} //{{{ Package-private members String[] actionNames; Hashtable actionHash = new Hashtable(); //}}} //{{{ Private members private Vector actionSets = new Vector(); //}}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -