|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esri.arcgis.controls.CommandPool
public class CommandPool
A collection of commands used by the ToolbarControl.
The CommandPool is used for managing the collection of commands used by the ToolbarControl, a ToolbarMenu, a ToolbarPalette, or the commands shared between several ToolbarControl's. The ToolbarControl manages its CommandPool itself in order to maintain its command items. If a ToolbarMenu or ToolbarPalette are added to a ToolbarControl they will automatically share the same CommandPool as the ToolbarControl. If a ToolbarMenu or ToolbarPalette are used standalone they will mange their own CommandPool.
The CommandPool is used for managing the collection of Command objects (including Tool and ToolControl objects) objects used by the ToolbarControl. Normally, the CommandPool is entirely managed by the ToolbarControl, a ToolbarMenu or a ToolbarPalette in order to maintain to its command items.
The main job of the CommandPool is to create Command objects from valid UID's and prevent multiple instances of the same Command being created. This ensures that if the same Command is added to multiple ToolbarControl's, there will be only one actual instance of that Command in the CommandPool. When a Command is added by passing the ICommandPoolEdit::AddCommand method a valid UID, the first time that UID is supplied, a brand new Command is created and the CommandPool gives this a UsageCount of 1. If another ToolbarControl passes the ICommandPoolEdit::AddCommand the same UID the CommandPool will return the existing Command and will increment the UsageCount to 2.
By default each ToolbarControl has its own CommandPool. To ensure Commands are shared amongst multiple ToolbarControls the same CommandPool object must be set into each ToolbarControl. ToolbarMenu and ToolbarPalette objects also use a CommandPool. If a ToolbarMenu or ToolbarPalette is added to a ToolbarControl it will automatically share the same CommandPool as the ToolbarControl.
Other tasks performed by the CommandPool are:
Constructor Summary | |
---|---|
CommandPool()
Constructs a CommandPool using ArcGIS Engine. |
|
CommandPool(Object obj)
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts. CommandPool theCommandPool = (CommandPool) obj; |
Method Summary | |
---|---|
void |
addCommand(ICommand command,
IUID pUID)
Adds the specified command to the command pool. |
IArray |
addUID(IUID uID)
Adds the given UID to the command pool and returns an array of command objects. |
void |
callOnCreate(ICommand pCommand)
Calls the specified command OnCreate method if the Hook is set and OnCreate has not already been called. |
boolean |
created(ICommand command)
Indicates if the commands OnCreate method has been called. |
boolean |
equals(Object o)
Compare this object with another |
boolean |
exists(ICommand command)
Indicates if the given command exists in the command pool. |
ICommand |
findByUID(IUID uID)
Searches the command pool for the given UID. |
static String |
getClsid()
getClsid. |
ICommand |
getCommand(int index)
The command at the given index. |
int |
getCount()
The number of commands in the command pool. |
Object |
getHook()
The object that is passed as a hook to the OnCreate method on the command. |
IUID |
getUID(ICommand command)
The UID of the given command. |
int |
getUsageCount(ICommand command)
The number of items using the given command. |
int |
hashCode()
the hashcode for this object |
void |
interfaceSupportsErrorInfo(GUID riid)
interfaceSupportsErrorInfo |
void |
remove(ICommand command)
Decrements the usage count of the command. |
void |
removeAll()
Removes all commands from the command pool, regardless of each commands usage count. |
void |
setHook(Object pHook)
Sets the object that is passed as a hook to the OnCreate method on the command. |
boolean |
translateAcceleratorKey(int keyCode)
Translates the specified keyCode, if a corresponding accelerator exists. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef |
---|
getJintegraDispatch, release |
Constructor Detail |
---|
public CommandPool() throws IOException, UnknownHostException
IOException
- if there are interop problems
UnknownHostException
- if there are interop problemspublic CommandPool(Object obj) throws IOException
CommandPool theCommandPool = (CommandPool) obj;
obj
to CommandPool
.
obj
- an object returned from ArcGIS Engine or Server
IOException
- if there are interop problemsMethod Detail |
---|
public static String getClsid()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int getCount() throws IOException, AutomationException
Returns the number of commands in the CommandPool.
getCount
in interface ICommandPool
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public int getUsageCount(ICommand command) throws IOException, AutomationException
getUsageCount
in interface ICommandPool
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public boolean exists(ICommand command) throws IOException, AutomationException
Indicates whether the specified command exists in the CommandPool.
exists
in interface ICommandPool
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public ICommand findByUID(IUID uID) throws IOException, AutomationException
Searches the CommandPool for the specified UID, and returns the matching Command. Returns Nothing if the UID cannot be found. For commands that implement ICommandSubType, the IUID::SubType must be specified, otherwise Nothing will be returned.
findByUID
in interface ICommandPool
uID
- A reference to a com.esri.arcgis.system.IUID (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public IUID getUID(ICommand command) throws IOException, AutomationException
getUID
in interface ICommandPool
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public ICommand getCommand(int index) throws IOException, AutomationException
getCommand
in interface ICommandPool
index
- The index (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public boolean created(ICommand command) throws IOException, AutomationException
Indicates if the specified command's ICommand::OnCreate method has been called.
created
in interface ICommandPool
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public boolean translateAcceleratorKey(int keyCode) throws IOException, AutomationException
Returns whether the specified keyCode is a supported accelerator (shortcut) or access key, defined in an ICommand::Caption property of a Command in the CommandPool. To translate an accelerator key, the ICommand::OnClick method must be called.
For example, a 'Close' command with the caption "&Close\tAlt+F4" has the 'ALT+F4' key combination as its shortcut key, and the 'C' key as its access key.
When using the TranslateAcceleratorKey pass the keyCode of the none system key only. For example, if the accelerator is "Ctrl+K", pass the keyCode for "K" to TranslateAcceleratorKey. The system will automatically check for the system key "Ctrl".
translateAcceleratorKey
in interface ICommandPool2
keyCode
- The keyCode (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void addCommand(ICommand command, IUID pUID) throws IOException, AutomationException
If a UID object is specified and the command object is nothing, the method searches the CommandPool for the given UID. If the UID is found its UsageCount is incremented by 1. If the UID is not found a new command is created and added to the CommandPool with a UsageCount of 1.
If a command object is specified and the UID object is nothing, the command is added to the CommandPool with a UsageCount of 1.
If a UID object and a command object are specified, the method searches the CommandPool for the given UID. If the UID is found its UsageCount is incremented by 1. If the UID is not found the specified command is added to the CommandPool with a UsageCount of 1.
Typically the AddUID method should be used as the method to add commands that implement the ICommandSubType interface. If the AddCommand method is used the IUID::SubType property must be set.
addCommand
in interface ICommandPoolEdit
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)pUID
- A reference to a com.esri.arcgis.system.IUID (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public IArray addUID(IUID uID) throws IOException, AutomationException
Adds commands to the CommandPool using the specified UID. The method searches the CommandPool for the specified UID. If the UID is found then that commands UsageCount is incremented by 1. If the UID is not found a new command is created and added to the CommandPool with a UsageCount of 1. The command is returned in an array.
If the specified UID is a command that implements the ICommandSubType interface, the method will return an array of all the commands, and if necessary create the command in the CommandPool. Set the IUID::SubType property to a none zero value to add a specific command defined within the ICommandSubType object.
addUID
in interface ICommandPoolEdit
uID
- A reference to a com.esri.arcgis.system.IUID (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void remove(ICommand command) throws IOException, AutomationException
Decrements the supplied command UsageCount by 1. If the UsageCount reaches 0 the command is released from the CommandPool and the ICommandPool::Exists property will return false. If the UsageCount is 1 or more the command will remain in the CommandPool. The number of calls to the AddUID and AddCommand methods for a given UID must typically match the number of calls to Remove.
Typically the ToolbarControl will manage the commands in the CommandPool as part of IToolbarControl::AddItem and IToolbarControl::Remove methods.
remove
in interface ICommandPoolEdit
command
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void removeAll() throws IOException, AutomationException
Removes all of the commands from the CommandPool. The developer must ensure that any IToolbarItem objects using the commands are removed from the ToolbarControl.
removeAll
in interface ICommandPoolEdit
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void callOnCreate(ICommand pCommand) throws IOException, AutomationException
Calls the ICommand:OnCreate event for the specified command.
When a command is added to the CommandPool, the ICommandPool::Created property is set to false. If the ICommandPoolEdit::Hook property is set, the CallOnCreate method will pass the Hook into the command's ICommand:OnCreate method. The ICommandPool::Created property is then set to true.
To ensure that the ICommand:OnCreate method is called only once during the lifetime of the command object, subsquent calls to the CallOnCreate method will not do anything.
callOnCreate
in interface ICommandPoolEdit
pCommand
- A reference to a com.esri.arcgis.systemUI.ICommand (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void setHook(Object pHook) throws IOException, AutomationException
Pass the SetHook method an IDispatch object, typically the ToolbarControl, that is passed as a hook to the ICommand::OnCreate method of each command in the CommandPool.
setHook
in interface ICommandPoolEdit
pHook
- A reference to another Automation Object (IDispatch) (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public Object getHook() throws IOException, AutomationException
The Hook is an IDispatch object, typically the ToolbarControl, that is passed as a hook to the ICommand::OnCreate method of each command in the CommandPool.
getHook
in interface ICommandPoolEdit
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.public void interfaceSupportsErrorInfo(GUID riid) throws IOException, AutomationException
Indicates whether the interface supports IErrorInfo.
interfaceSupportsErrorInfo
in interface ISupportErrorInfo
riid
- A Structure: com.esri.arcgis.support.ms.stdole.GUID (in)
IOException
- If there are interop problems.
AutomationException
- If the ArcObject component throws an exception.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |