org.eclipse.emf.emfstore.internal.client.ui.handlers
Class AbstractEMFStoreHandlerWithResult<T>

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.core.commands.AbstractHandler
          extended by org.eclipse.emf.emfstore.internal.client.ui.handlers.AbstractEMFStoreHandlerWithResult<T>
Type Parameters:
T - the return type of the handler
All Implemented Interfaces:
org.eclipse.core.commands.IHandler, org.eclipse.core.commands.IHandler2
Direct Known Subclasses:
AbstractEMFStoreHandler

public abstract class AbstractEMFStoreHandlerWithResult<T>
extends org.eclipse.core.commands.AbstractHandler

Handlers are the top level abstraction that clients should use execute actions within the EMFStore workspace. They are responsible for calling the UI controllers and therefore provide helper methods that can determine the currently selected element, if needed. This handler is capable of returning a result.

Author:
ovonwesen, emueller
See Also:
AbstractEMFStoreHandler

Constructor Summary
AbstractEMFStoreHandlerWithResult()
           
 
Method Summary
 T execute(org.eclipse.core.commands.ExecutionEvent event)
          
 org.eclipse.swt.widgets.Shell getShell()
          Returns the currently active shell.
abstract  T handleWithResult()
          Executes the handler and returns a result.
<U> U
requireSelection(Class<U> clazz)
          Returns an object of the given clazz if it can be extracted from the current selection.
 
Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, dispose, isEnabled, isHandled, removeHandlerListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEMFStoreHandlerWithResult

public AbstractEMFStoreHandlerWithResult()
Method Detail

execute

public T execute(org.eclipse.core.commands.ExecutionEvent event)
          throws org.eclipse.core.commands.ExecutionException

Throws:
org.eclipse.core.commands.ExecutionException
See Also:
IHandler.execute(org.eclipse.core.commands.ExecutionEvent)

handleWithResult

public abstract T handleWithResult()
Executes the handler and returns a result.

Returns:
a return value of type T

requireSelection

public <U> U requireSelection(Class<U> clazz)
                   throws RequiredSelectionException
Returns an object of the given clazz if it can be extracted from the current selection.

Type Parameters:
U - the type of the object to be extracted from the current selection
Parameters:
clazz - the type of the object that is requested to be extracted from the current selection
Returns:
an object of type T that is contained within the current selection
Throws:
RequiredSelectionException - if the selection is invalid, i.e. if no object of the given type is contained in the selection or if the selection is null

getShell

public org.eclipse.swt.widgets.Shell getShell()
Returns the currently active shell.

Returns:
the active shell


Copyright © 2015. All Rights Reserved.