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

CommandTask (NetBeans VCS API) - NetBeans API Javadoc 4.1.0

 

org.netbeans.api.vcs.commands
Class CommandTask

java.lang.Object
  extended byorg.openide.util.Task
      extended byorg.netbeans.api.vcs.commands.CommandTask
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
CommandTaskSupport

public abstract class CommandTask
extends Task

This class represents the actual command, that is executed to acually perform a VCS action.


Field Summary
static int STATUS_FAILED
           
static int STATUS_INTERRUPTED
           
static int STATUS_NOT_STARTED
           
static int STATUS_RUNNING
           
static int STATUS_SUCCEEDED
           
 
Fields inherited from class org.openide.util.Task
EMPTY
 
Constructor Summary
protected CommandTask()
           
 
Method Summary
protected  boolean canExecute()
          Tell, whether the task can be executed now.
protected abstract  int execute()
          Put the actual execution of this task here.
abstract  String getDisplayName()
          Get the display name of the command.
 int getExitStatus()
          Get the exit status of the command.
abstract  FileObject[] getFiles()
          Get files this task acts on.
abstract  String getName()
          Get the name of the command.
 int getPriority()
          Get the priority of this task.
 boolean isRunning()
          Say whether the command is running just now.
 void run()
          Schedules the command task for being executed.
 void stop()
          Stop the command's execution.
 void waitFinished(int timeout)
          Wait for the task to finish while allowing interruption.
 
Methods inherited from class org.openide.util.Task
addTaskListener, isFinished, notifyFinished, notifyRunning, removeTaskListener, toString, waitFinished, waitFinished
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_NOT_STARTED

public static final int STATUS_NOT_STARTED
See Also:
Constant Field Values

STATUS_RUNNING

public static final int STATUS_RUNNING
See Also:
Constant Field Values

STATUS_SUCCEEDED

public static final int STATUS_SUCCEEDED
See Also:
Constant Field Values

STATUS_FAILED

public static final int STATUS_FAILED
See Also:
Constant Field Values

STATUS_INTERRUPTED

public static final int STATUS_INTERRUPTED
See Also:
Constant Field Values
Constructor Detail

CommandTask

protected CommandTask()
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.


getFiles

public abstract FileObject[] getFiles()
Get files this task acts on.


getPriority

public int getPriority()
Get the priority of this task. This can be taken into account by the task processor.

Currently only binary priority is distinguished by the CommandProcessor: priority == 0 and priority != 0. When priority != 0, the task can be run sooner than other tasks with priority == 0. After the task is running, it's performance does not depend on the priority.

Returns:
The task's priority. The default implementation returns 0.

canExecute

protected boolean canExecute()
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.

run

public final void run()
Schedules the command task for being executed. The actual execution might be done asynchronously. In this case this method returns immediately.


execute

protected abstract int execute()
Put the actual execution of this task here. This method will be called automatically after process() call. Do NOT call this method.

Returns:
The exit status. One of STATUS_* constants.

isRunning

public final boolean isRunning()
Say whether the command is running just now.

Returns:
True if the command is running, false if not.

stop

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


getExitStatus

public final int getExitStatus()
Get the exit status of the command.


waitFinished

public void waitFinished(int timeout)
                  throws InterruptedException
Wait for the task to finish while allowing interruption. Because the method Task.waitFinished() ignores InterruptedException, this method was created. If the current thread is interrupted while waiting for the task to finish, the InterruptedException is thrown.

Parameters:
timeout - The maximum time to wait in milliseconds.
Throws:
InterruptedException - when the current thread is interrupted while waiting.

 

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