org.eclipse.emf.emfstore.internal.client.ui.util
Class EMFStoreHandlerUtil

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.ui.util.EMFStoreHandlerUtil

public final class EMFStoreHandlerUtil
extends Object

This class provides helper methods that can determine the currently selected element.

Author:
ovonwesen

Method Summary
static
<T> T
getSelection(org.eclipse.core.commands.ExecutionEvent event, Class<T> clazz)
          Extracts element from event.
static
<T> T
requireSelection(org.eclipse.core.commands.ExecutionEvent event, Class<T> clazz)
          Returns an object of the given clazz if it can be extracted from the current selection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSelection

public static <T> T getSelection(org.eclipse.core.commands.ExecutionEvent event,
                                 Class<T> clazz)
Extracts element from event.

Type Parameters:
T - the type of the object to extract
Parameters:
event - the event
clazz - class type of the object to extract
Returns:
the object

requireSelection

public static <T> T requireSelection(org.eclipse.core.commands.ExecutionEvent event,
                                     Class<T> clazz)
                          throws RequiredSelectionException
Returns an object of the given clazz if it can be extracted from the current selection.

Type Parameters:
T - the type of the object to be extracted from the current selection
Parameters:
event - the event from which to extract the selection
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


Copyright © 2015. All Rights Reserved.