org.eclipse.emf.mwe.internal.core.debug.processing
Class DebugMonitor

java.lang.Object
  extended by org.eclipse.emf.mwe.internal.core.debug.processing.DebugMonitor
All Implemented Interfaces:
ProgressMonitor

public class DebugMonitor
extends java.lang.Object
implements ProgressMonitor

The heart of the debug process on the runtime side. It has callback methods that are called by the syntax element implementations before and after a process step.
It works closely together with handlers and adapters that must be registered at startup.


Field Summary
 
Fields inherited from interface org.eclipse.emf.mwe.core.monitor.ProgressMonitor
UNKNOWN
 
Constructor Summary
DebugMonitor()
           
 
Method Summary
 void addAdapter(ElementAdapter adapter)
           
 void addEventHandler(EventHandler handler)
           
 void addProcessHandler(ProcessHandler handler)
           
 void beginTask(java.lang.String name, int totalWork)
          Notifies that the main task is beginning.
 void clearBlocked()
           
 void done()
          Notifies that the work is done; that is, either the main task is completed or the user canceled it.
 void finished(java.lang.Object element, java.lang.Object context)
          fire the finish events to the registered event handlers
 ElementAdapter getAdapter(java.lang.Object element)
           
 void init(int port)
           
 void init(java.lang.String[] args)
          open the connection to a debug server framework (e.g.
 void internalWorked(double work)
          Internal method to handle scaling correctly.
 boolean isCanceled()
          Returns whether cancelation of current operation has been requested.
 void postTask(java.lang.Object element, java.lang.Object context)
          inform the handlers about the finalization of a process step.
In case the process may suspend at the end of a syntax element it does so if requested.
 void preTask(java.lang.Object element, java.lang.Object context)
          the main method to manipulate the runtime process for debugging.
In case a suspension is requested it stops the process and waits for the next user command.
 void setBlocked(org.eclipse.emf.common.util.Diagnostic reason)
           
 void setCanceled(boolean value)
          Sets the cancel state to the given value.
 void setCommandListener(CommandListener commandListener)
           
 void setTaskName(java.lang.String name)
          Sets the task name to the given value.
 void started(java.lang.Object element, java.lang.Object context)
          fire the STARTED event to the registered event handlers
 void subTask(java.lang.String name)
          Notifies that a subtask of the main task is beginning.
 void uninit()
          Closes the connection.
 void worked(int work)
          Notifies that a given number of work unit of the main task has been completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugMonitor

public DebugMonitor()
Method Detail

init

public void init(java.lang.String[] args)
          throws java.io.IOException
open the connection to a debug server framework (e.g. eclipse) and instantiate and start the RuntimeHandlerManager listener.

Parameters:
args - arg[1] must be the port to be connected with
Throws:
java.io.IOException

init

public void init(int port)
          throws java.io.IOException
Throws:
java.io.IOException

uninit

public void uninit()
Closes the connection. This releases the threads used for debugging and execution and releases memory.


setCommandListener

public void setCommandListener(CommandListener commandListener)

addProcessHandler

public void addProcessHandler(ProcessHandler handler)

addEventHandler

public void addEventHandler(EventHandler handler)

addAdapter

public void addAdapter(ElementAdapter adapter)

getAdapter

public ElementAdapter getAdapter(java.lang.Object element)

started

public void started(java.lang.Object element,
                    java.lang.Object context)
fire the STARTED event to the registered event handlers

Specified by:
started in interface ProgressMonitor
Parameters:
element - The element that fired that notification
context - the context of execution
See Also:
ProgressMonitor.started(java.lang.Object, java.lang.Object)

preTask

public void preTask(java.lang.Object element,
                    java.lang.Object context)
the main method to manipulate the runtime process for debugging.
In case a suspension is requested it stops the process and waits for the next user command.

Specified by:
preTask in interface ProgressMonitor
Parameters:
element - The element that fired that notification
context - the context of execution
See Also:
ProgressMonitor.preTask(java.lang.Object, java.lang.Object)

postTask

public void postTask(java.lang.Object element,
                     java.lang.Object context)
inform the handlers about the finalization of a process step.
In case the process may suspend at the end of a syntax element it does so if requested.

Specified by:
postTask in interface ProgressMonitor
Parameters:
element - The element that fired that notification
context - the context of execution
See Also:
ProgressMonitor.postTask(java.lang.Object, java.lang.Object)

finished

public void finished(java.lang.Object element,
                     java.lang.Object context)
fire the finish events to the registered event handlers

Specified by:
finished in interface ProgressMonitor
Parameters:
element - The element that fired that notification
context - the context of execution
See Also:
ProgressMonitor.finished(java.lang.Object, java.lang.Object)

beginTask

public void beginTask(java.lang.String name,
                      int totalWork)
Description copied from interface: ProgressMonitor
Notifies that the main task is beginning. This must only be called once on a given progress monitor instance.

Specified by:
beginTask in interface ProgressMonitor
Parameters:
name - the name (or description) of the main task
totalWork - the total number of work units into which the main task is been subdivided. If the value is UNKNOWN the implemenation is free to indicate progress in a way which doesn't require the total number of work units in advance.

done

public void done()
Description copied from interface: ProgressMonitor
Notifies that the work is done; that is, either the main task is completed or the user canceled it. This method may be called more than once (implementations should be prepared to handle this case).

Specified by:
done in interface ProgressMonitor

internalWorked

public void internalWorked(double work)
Description copied from interface: ProgressMonitor
Internal method to handle scaling correctly. This method must not be called by a client. Clients should always use the method worked(int).

Specified by:
internalWorked in interface ProgressMonitor
Parameters:
work - the amount of work done

isCanceled

public boolean isCanceled()
Description copied from interface: ProgressMonitor
Returns whether cancelation of current operation has been requested. Long-running operations should poll to see if cancelation has been requested.

Specified by:
isCanceled in interface ProgressMonitor
Returns:
true if cancellation has been requested, and false otherwise
See Also:
ProgressMonitor.setCanceled(boolean)

setCanceled

public void setCanceled(boolean value)
Description copied from interface: ProgressMonitor
Sets the cancel state to the given value.

Specified by:
setCanceled in interface ProgressMonitor
Parameters:
value - true indicates that cancelation has been requested (but not necessarily acknowledged); false clears this flag
See Also:
ProgressMonitor.isCanceled()

setTaskName

public void setTaskName(java.lang.String name)
Description copied from interface: ProgressMonitor
Sets the task name to the given value. This method is used to restore the task label after a nested operation was executed. Normally there is no need for clients to call this method.

Specified by:
setTaskName in interface ProgressMonitor
Parameters:
name - the name (or description) of the main task
See Also:
ProgressMonitor.beginTask(java.lang.String, int)

subTask

public void subTask(java.lang.String name)
Description copied from interface: ProgressMonitor
Notifies that a subtask of the main task is beginning. Subtasks are optional; the main task might not have subtasks.

Specified by:
subTask in interface ProgressMonitor
Parameters:
name - the name (or description) of the subtask

worked

public void worked(int work)
Description copied from interface: ProgressMonitor
Notifies that a given number of work unit of the main task has been completed. Note that this amount represents an installment, as opposed to a cumulative amount of work done to date.

Specified by:
worked in interface ProgressMonitor
Parameters:
work - the number of work units just completed

clearBlocked

public void clearBlocked()

setBlocked

public void setBlocked(org.eclipse.emf.common.util.Diagnostic reason)