Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.core.commands.operations
Class AbstractOperation


java.lang.Object
  extended by 
org.eclipse.core.commands.operations.AbstractOperation
All Implemented Interfaces:
IUndoableOperation
Direct Known Subclasses:
AbstractWorkspaceOperation, TriggeredOperations

public abstract class AbstractOperation
extends Object
implements IUndoableOperation

Abstract implementation for an undoable operation. At a minimum, subclasses should implement behavior for IUndoableOperation.execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable), IUndoableOperation.redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable), and IUndoableOperation.undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable).

Since:
3.1
See Also:
IUndoableOperation

Constructor Summary
AbstractOperation ( String label)
          Construct an operation that has the specified label.
 
Method Summary
 void addContext ( IUndoContext context)
           Add the specified context to the operation.
 boolean canExecute ()
           Returns whether the operation can be executed in its current state.
 boolean canRedo ()
           Returns whether the operation can be redone in its current state.
 boolean canUndo ()
           Returns whether the operation can be undone in its current state.
 void dispose ()
          Dispose of the operation.
abstract   IStatus execute ( IProgressMonitor monitor, IAdaptable info)
          Execute the operation.
  IUndoContext[] getContexts ()
           Returns the array of contexts that have been assigned to the operation.
  String getLabel ()
          Return the label that should be used to show the name of the operation to the user.
 boolean hasContext ( IUndoContext context)
           Returns whether the operation has a matching context for the specified context.
abstract   IStatus redo ( IProgressMonitor monitor, IAdaptable info)
          Redo the operation.
 void removeContext ( IUndoContext context)
          Remove the specified context from the operation.
 void setLabel ( String name)
          Set the label of the operation to the specified name.
  String toString ()
          The string representation of this operation.
abstract   IStatus undo ( IProgressMonitor monitor, IAdaptable info)
          Undo the operation.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractOperation

public AbstractOperation(
String label)
Construct an operation that has the specified label.

Parameters:
label - the label to be used for the operation. Should never be null.
Method Detail

addContext

public void addContext(
IUndoContext context)
Description copied from interface: IUndoableOperation

Add the specified context to the operation. If a context equal to the specified context is already present, do not add it again. Note that determining whether a context is already present is based on equality, not whether the context matches ( IUndoContext.matches(IUndoContext)) another context.

Specified by:
addContext in interface IUndoableOperation
Parameters:
context - the context to be added

canExecute

public boolean canExecute()
Description copied from interface: IUndoableOperation

Returns whether the operation can be executed in its current state.

Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual execution of the operation, returning the appropriate status if the operation cannot actually execute at that time.

Specified by:
canExecute in interface IUndoableOperation
Returns:
true if the operation can be executed; false otherwise.

canRedo

public boolean canRedo()
Description copied from interface: IUndoableOperation

Returns whether the operation can be redone in its current state.

Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual redo of the operation, returning the appropriate status if the operation cannot actually be redone at that time.

Specified by:
canRedo in interface IUndoableOperation
Returns:
true if the operation can be redone; false otherwise.

canUndo

public boolean canUndo()
Description copied from interface: IUndoableOperation

Returns whether the operation can be undone in its current state.

Note: The computation for this method must be fast, as it is called frequently. If necessary, this method can be optimistic in its computation (returning true) and later perform more time-consuming computations during the actual undo of the operation, returning the appropriate status if the operation cannot actually be undone at that time.

Specified by:
canUndo in interface IUndoableOperation
Returns:
true if the operation can be undone; false otherwise.

dispose

public void dispose()
Description copied from interface: IUndoableOperation
Dispose of the operation. This method is used when the operation is no longer kept in the history. Implementers of this method typically unregister any listeners.

Specified by:
dispose in interface IUndoableOperation

execute

public abstract 
IStatus execute(
IProgressMonitor monitor,
                                
IAdaptable info)
                         throws 
ExecutionException
Description copied from interface: IUndoableOperation
Execute the operation. This method should only be called the first time that an operation is executed.

Specified by:
execute in interface IUndoableOperation
Parameters:
monitor - the progress monitor (or null) to use for reporting progress to the user.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
the IStatus of the execution. The status severity should be set to OK if the operation was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the execution.
Throws:
ExecutionException - if an exception occurred during execution.

getContexts

public final 
IUndoContext[] getContexts()
Description copied from interface: IUndoableOperation

Returns the array of contexts that have been assigned to the operation.

This method may be called by the operation history from inside a synchronized block. To avoid deadlock conditions, implementers of this method must avoid dispatching and waiting on threads that modify the operation history during this method.

Specified by:
getContexts in interface IUndoableOperation
Returns:
the array of contexts

getLabel

public 
String getLabel()
Description copied from interface: IUndoableOperation
Return the label that should be used to show the name of the operation to the user. This label is typically combined with the command strings shown to the user in "Undo" and "Redo" user interfaces.

Specified by:
getLabel in interface IUndoableOperation
Returns:
the String label. Should never be null.

setLabel

public void setLabel(
String name)
Set the label of the operation to the specified name.

Parameters:
name - the string to be used for the label. Should never be null.

hasContext

public final boolean hasContext(
IUndoContext context)
Description copied from interface: IUndoableOperation

Returns whether the operation has a matching context for the specified context.

This method may be called by the operation history from inside a synchronized block. To avoid deadlock conditions, implementers of this method must avoid dispatching and waiting on threads that modify the operation history during this method.

Specified by:
hasContext in interface IUndoableOperation
Parameters:
context - the context in question
Returns:
true if the context is present, false if it is not.
See Also:
IUndoContext.matches(IUndoContext)

redo

public abstract 
IStatus redo(
IProgressMonitor monitor,
                             
IAdaptable info)
                      throws 
ExecutionException
Description copied from interface: IUndoableOperation
Redo the operation. This method should only be called after an operation has been undone.

Specified by:
redo in interface IUndoableOperation
Parameters:
monitor - the progress monitor (or null) to use for reporting progress to the user.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
the IStatus of the redo. The status severity should be set to OK if the redo was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the redo.
Throws:
ExecutionException - if an exception occurred during redo.

removeContext

public void removeContext(
IUndoContext context)
Description copied from interface: IUndoableOperation
Remove the specified context from the operation. This method has no effect if the context is not equal to another context in the context list. Note that determining whether a context is present when removing it is based on equality, not whether the context matches ( IUndoContext.matches(IUndoContext)) another context.

Specified by:
removeContext in interface IUndoableOperation
Parameters:
context - the context to be removed

undo

public abstract 
IStatus undo(
IProgressMonitor monitor,
                             
IAdaptable info)
                      throws 
ExecutionException
Description copied from interface: IUndoableOperation
Undo the operation. This method should only be called after an operation has been executed.

Specified by:
undo in interface IUndoableOperation
Parameters:
monitor - the progress monitor (or null) to use for reporting progress to the user.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
the IStatus of the undo. The status severity should be set to OK if the redo was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the undo.
Throws:
ExecutionException - if an exception occurred during undo.

toString

public 
String toString()
The string representation of this operation. Used for debugging purposes only. This string should not be shown to an end user.

Overrides:
toString in class Object
Returns:
The string representation.

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire