站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

CommandSupport (NetBeans VCS API) - NetBeans API Javadoc 4.1.0

 

org.netbeans.spi.vcs.commands
Class CommandSupport

java.lang.Object
  extended byorg.netbeans.spi.vcs.commands.CommandSupport
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
UserCommandSupport

public abstract class CommandSupport
extends Object
implements Cloneable


Constructor Summary
CommandSupport(Class commandClass)
          Creates a new instance of CommandSupport.
CommandSupport(Class[] commandClasses)
          Creates a new instance of CommandSupport.
 
Method Summary
protected  boolean canExecute(CommandTask task)
          Tell, whether the task can be executed now.
protected abstract  Object clone()
          Subclasses need to implement the clone() method in order the command creation work properly.
 Command createCommand()
          Use this method to actually create the command.
protected  CommandTaskSupport createTask(Command taskCommand)
          Create the CommandTask, that is supposed to execute the command.
protected abstract  int execute(CommandTask task)
          Perform the actual execution of the command from the provided info.
abstract  FileObject[] getApplicableFiles(FileObject[] files)
          Find, whether this command can act on a set of files.
protected  Command getCommand()
          Get the command associated with this command support.
protected  Command getCommand(CommandTask task)
          Get the command associated with the given task.
abstract  String getDisplayName()
          Get the display name of the command.
protected  EventListener[] getListeners(Class listenerType, Command command)
          Get the event listeners attached to the associated command, if any.
abstract  String getName()
          Get the name of the command.
abstract  boolean hasExpertMode()
          Whether the command supports an expert mode.
protected  void initializeCommand(Command cmd)
          Initialize the command after it's created.
protected  void stop(CommandTask task)
          Stop the command's execution.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandSupport

public CommandSupport(Class commandClass)
Creates a new instance of CommandSupport.

Parameters:
commandClass - The class of the command, that is implemented.

CommandSupport

public CommandSupport(Class[] commandClasses)
Creates a new instance of CommandSupport.

Method Detail

getName

public abstract String getName()
Get the name of the command.


getDisplayName

public abstract String getDisplayName()
Get the display name of the command. It will be visible on the popup menu under this name. When null, the command will not be visible on the popup menu.


getApplicableFiles

public abstract FileObject[] getApplicableFiles(FileObject[] files)
Find, whether this command can act on a set of files.

Parameters:
files - The array of files to inspect
Returns:
an array of files the command can act on or null when it can not act on any file listed.

hasExpertMode

public abstract boolean hasExpertMode()
Whether the command supports an expert mode. The command should provide a more complex customizer and/or output if in expert mode. If the command does not differentiate expert mode, it should declare, that it does not have an expert mode.

Returns:
true If the command differentiate expert mode, false otherwise

createCommand

public final Command createCommand()
Use this method to actually create the command. This method clones current CommandSupport instance, and create the Command associated with the clonned CommandSupport instance.

Returns:
The fresh instance of Command.

initializeCommand

protected void initializeCommand(Command cmd)
Initialize the command after it's created. This allows the implementator to preset some initial values to the command before it's customized. When sb. is just creates a command through VcsManager.createCommand(..) they will get this customized command. The default implementation just set an empty array of FileObjects to the command.

Parameters:
cmd - The command to be customized.

getCommand

protected final Command getCommand()
Get the command associated with this command support.

Returns:
The instance of Command or null if this support does not have any command associated.

getCommand

protected final Command getCommand(CommandTask task)
                            throws IllegalArgumentException
Get the command associated with the given task. This is a clon of the command returned in getCommand() method after the customization. This clon will not be customized any more, thus it's safe to use this command in execute() method to get the customized data.

Parameters:
task - The task to get the command for.
Returns:
The customized command associated with the given task.
Throws:
IllegalArgumentException - if the task is of an unknown instance.

canExecute

protected boolean canExecute(CommandTask task)
Tell, whether the task can be executed now. The task may wish to aviod parallel execution with other tasks or other events.

Returns:
true if the task is to be executed immediately. This is the default implementation. false if the task should not be executed at this time. In this case the method will be called later to check whether the task can be executed already.

execute

protected abstract int execute(CommandTask task)
Perform the actual execution of the command from the provided info. This method might be called multiple times and even concurrently for a single CommandSupport instance. It's recommended not to modify any variables from this instance object in this method.


createTask

protected CommandTaskSupport createTask(Command taskCommand)
Create the CommandTask, that is supposed to execute the command. This implementation must return an instance of CommandTaskSupport.

Parameters:
taskCommand - The copy of the customized command, that can be used by the task to get the customized information.
Returns:
The instance of CommandTaskSupport.

stop

protected void stop(CommandTask task)
Stop the command's execution. The default implementation kills the command's thread by hard.


getListeners

protected final EventListener[] getListeners(Class listenerType,
                                             Command command)
Get the event listeners attached to the associated command, if any.

Parameters:
listenerType - The type of listeners we're looking for.
command - The command, to get the listeners from.
Returns:
The array of listeners of given type or null.

clone

protected abstract Object clone()
                         throws CloneNotSupportedException
Subclasses need to implement the clone() method in order the command creation work properly.

Returns:
The clonned command support object.
Throws:
CloneNotSupportedException

 

Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.