com.togethersoft.openapi.ide.command
Interface IdeCommandCheckListener

All Known Subinterfaces:
IdeCommandListener

public interface IdeCommandCheckListener

The listener for receiving command events from IdeCommandItems and IdeCommandGroups.

This listener contains the checkStatus method. When you create a command item (or command group) you provide this listener. The details about circumstances when this method is called are in the IdeCommandEvent interface.

In the checkStatus you can place some code which analyzes the underlying element and makes a decision whether this item or group should be made visible/invisible or enabled/disabled etc.

Consider this example:

You create a popup menu command item for RwiElements whose shape type property is CLASS (only RwiNodes representing classes and interfaces have this property):

 IdeCommandManager cman=IdeCommandManagerAccess.getCommandManager();
 IdeCommandItem myItem=cman.createItem("IDOfTheItem",new IdeCommandConstraints("context = element, shapeType=Class, location=popupMenu"),new IdeCommandAdapter(){
      public void checkStatus(IdeCommandEvent event){
       IdeContext context=event.getElementContext(); //getting the element(s) under the cursor
       RwiElement[] selectedRwiElements = context.getRwiElements();
       RwiElement theElement=selectedRwiElements[0];
       if ( theElement.hasProperty(RwiProperty.INTERFACE) ) {  //it is an interface
         myItem.setEnabled(false);
         //myItem.setVisible(true); //or, we can make it visible
       } else { //it is a class
         myItem.setEnabled(true);
         //myItem.setVisible(false); //or, we can make it invisible
       }
     }
 });
 
Now, for all the elements whose shape type is not "Class" Together will make this command item invisible. But for classes and interfaces (RwiNodes representing them have the "Class" shapetype) Together will invoke the checkStatus method where we analyze the element and can decide what do we want to do with this item (in our example, for classes we set the item to be enabled and for interfaces - disabled).

Author:
TogetherSoft
See Also: IdeCommandListener, IdeCommandEvent, IdeCommandManager.createItem(java.lang.String,com.togethersoft.openapi.ide.command.IdeCommandConstraints,com.togethersoft.openapi.ide.command.IdeCommandListener), IdeCommandManager.createGroup(java.lang.String,com.togethersoft.openapi.ide.command.IdeCommandConstraints,com.togethersoft.openapi.ide.command.IdeCommandCheckListener)

Method Summary
 voidcheckStatus(IdeCommandEvent event)
           checkStatus method is called to perform some kind of a check, for example, a check whether the command item should be set enabled/disabled, or visible/invisible.

Method Detail

checkStatus

public void checkStatus(IdeCommandEvent event)
checkStatus method is called to perform some kind of a check, for example, a check whether the command item should be set enabled/disabled, or visible/invisible.
Parameters:
event - the command event
See Also:
IdeCommandEvent