info.magnolia.ui.framework.action
Class AbstractMultiItemAction<D extends ActionDefinition>

java.lang.Object
  extended by info.magnolia.ui.api.action.AbstractAction<D>
      extended by info.magnolia.ui.framework.action.AbstractMultiItemAction<D>
Type Parameters:
D - the action definition type
All Implemented Interfaces:
Action
Direct Known Subclasses:
AbstractCommandAction, DeleteItemAction, MoveNodeAction

public abstract class AbstractMultiItemAction<D extends ActionDefinition>
extends AbstractAction<D>

Abstract multi-item Action that defines the default behavior.


Constructor Summary
protected AbstractMultiItemAction(D definition, JcrItemAdapter item, UiContext uiContext)
           
protected AbstractMultiItemAction(D definition, List<JcrItemAdapter> items, UiContext uiContext)
           
 
Method Summary
 void execute()
          Executes the action.
protected abstract  void executeOnItem(JcrItemAdapter item)
          Executes the action on ONE item.
protected  JcrItemAdapter getCurrentItem()
          Returns the item that is currently being processed - i.e.
protected  String getErrorNotification()
           
protected  Map<JcrItemAdapter,Exception> getFailedItems()
           
protected abstract  String getFailureMessage()
          Returns the message to display, if the execution fails on at least ONE item.
protected  Comparator<JcrItemAdapter> getItemComparator()
          Create a Comparator used to sort JcrItemAdapter.
protected  List<JcrItemAdapter> getItems()
           
protected  List<JcrItemAdapter> getSortedItems(Comparator<JcrItemAdapter> comparator)
           
protected abstract  String getSuccessMessage()
          Returns the message to display, if the execution succeeds on ALL items.
protected  UiContext getUiContext()
           
protected  void setCurrentItem(JcrItemAdapter item)
          This method should be used only in tests (when the test does not call the execute() method but e.g.
 
Methods inherited from class info.magnolia.ui.api.action.AbstractAction
getDefinition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMultiItemAction

protected AbstractMultiItemAction(D definition,
                                  JcrItemAdapter item,
                                  UiContext uiContext)

AbstractMultiItemAction

protected AbstractMultiItemAction(D definition,
                                  List<JcrItemAdapter> items,
                                  UiContext uiContext)
Method Detail

executeOnItem

protected abstract void executeOnItem(JcrItemAdapter item)
                               throws Exception
Executes the action on ONE item.

Throws:
Exception

getSuccessMessage

protected abstract String getSuccessMessage()
Returns the message to display, if the execution succeeds on ALL items. May return null, if the implementing action handles the user notification on its own.


getFailureMessage

protected abstract String getFailureMessage()
Returns the message to display, if the execution fails on at least ONE item. May return null, if the implementing action handles the user notification on its own.


execute

public void execute()
             throws ActionExecutionException
Description copied from interface: Action
Executes the action.

Throws:
ActionExecutionException - if an error occurs performing the action

getErrorNotification

protected String getErrorNotification()

getItems

protected List<JcrItemAdapter> getItems()

getSortedItems

protected List<JcrItemAdapter> getSortedItems(Comparator<JcrItemAdapter> comparator)
Returns:
the sorted Items list based on the desired Comparator.

getUiContext

protected UiContext getUiContext()

getFailedItems

protected Map<JcrItemAdapter,Exception> getFailedItems()

getCurrentItem

protected JcrItemAdapter getCurrentItem()
Returns the item that is currently being processed - i.e. null if the execute() method is not running.


setCurrentItem

protected void setCurrentItem(JcrItemAdapter item)
This method should be used only in tests (when the test does not call the execute() method but e.g. only the AbstractCommandAction.onPreExecute() so the current item hasn't been set.


getItemComparator

protected Comparator<JcrItemAdapter> getItemComparator()
Create a Comparator used to sort JcrItemAdapter. First element of the list are child items: - /a/b.property - /a/b - /a - /



Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.