org.xwiki.gwt.wysiwyg.client.widget.wizard.util
Class AbstractListSelectorWizardStep<D,L>

java.lang.Object
  extended by org.xwiki.gwt.user.client.ui.wizard.AbstractNavigationAwareWizardStep
      extended by org.xwiki.gwt.user.client.ui.wizard.AbstractInteractiveWizardStep
          extended by org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AbstractSelectorWizardStep<D>
              extended by org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AbstractListSelectorWizardStep<D,L>
Type Parameters:
D - the type of data edited by this wizard step, i.e. expected on initialization and returned as result
L - the type of data to add in the list handled by this wizard step
All Implemented Interfaces:
com.google.gwt.event.dom.client.DoubleClickHandler, com.google.gwt.event.dom.client.KeyUpHandler, com.google.gwt.event.shared.EventHandler, SourcesNavigationEvents, WizardStep
Direct Known Subclasses:
AbstractEntityListSelectorWizardStep

public abstract class AbstractListSelectorWizardStep<D,L>
extends AbstractSelectorWizardStep<D>
implements com.google.gwt.event.dom.client.DoubleClickHandler, com.google.gwt.event.dom.client.KeyUpHandler, SourcesNavigationEvents

Generic wizard step for selecting from a list of items: it handles list creation and population along with item selection on double click and enter. Subclasses should only handle the operations specific to retrieving the items to put in the list and the UI of the list items.

Version:
$Id: 723a81eefad28e2a50696ea1794e622c434f4654 $

Constructor Summary
AbstractListSelectorWizardStep()
          Default constructor, creating the UI of this wizard step.
 
Method Summary
 void addNavigationListener(NavigationListener listener)
          
 VerticalResizePanel display()
          
protected  void displayError()
          Displays the specified error message and error markers for this wizard step.
protected abstract  void fetchData(com.google.gwt.user.client.rpc.AsyncCallback<List<L>> callback)
          Fetches the list of items to be displayed in this list from the server.
protected  ListItem<L> fillList(List<L> dataList, L selectedData)
          Fills the list with the given data and returns the item that matches the specified item.
protected  com.google.gwt.user.client.ui.Label getErrorLabel()
           
protected  ListBox<L> getList()
           
protected abstract  ListItem<L> getListItem(L data)
           
protected  ListItem<L> getNewOptionListItem()
           
protected  ListItem<L> getSelectedItem()
          Helper method to get the selected item in the list managed by this wizard step.
protected abstract  String getSelectErrorMessage()
           
protected abstract  String getSelectHelpLabel()
           
protected  void hideError()
          Hides the error markers for this wizard step.
 void init(Object data, com.google.gwt.user.client.rpc.AsyncCallback<?> cb)
          
protected  boolean isSelectedByDefault(L listItemData)
           
 void onCancel()
          
 void onDoubleClick(com.google.gwt.event.dom.client.DoubleClickEvent event)
          
 void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)
          
 void onSubmit(com.google.gwt.user.client.rpc.AsyncCallback<Boolean> async)
          
protected  void refreshList(com.google.gwt.user.client.rpc.AsyncCallback<?> cb)
          Reloads the list of image previews in asynchronous manner.
 void removeNavigationListener(NavigationListener listener)
          
protected abstract  void saveSelectedValue(com.google.gwt.user.client.rpc.AsyncCallback<Boolean> async)
          Saves the current selection in this panel in the data managed by this wizard step, if all validation goes well on the submit time.
 void setActive()
          Notifies this wizard step that it has been activated, when part of an aggregator for example.
 void setNewOptionOnTop(boolean newOptionOnTop)
           
 
Methods inherited from class org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AbstractSelectorWizardStep
getData, getResult, initializeSelection
 
Methods inherited from class org.xwiki.gwt.user.client.ui.wizard.AbstractInteractiveWizardStep
getStepTitle, isAutoSubmit, setStepTitle
 
Methods inherited from class org.xwiki.gwt.user.client.ui.wizard.AbstractNavigationAwareWizardStep
getDirectionName, getNextStep, getValidDirections, setDirectionName, setNextStep, setValidDirections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractListSelectorWizardStep

public AbstractListSelectorWizardStep()
Default constructor, creating the UI of this wizard step.

Method Detail

getSelectHelpLabel

protected abstract String getSelectHelpLabel()
Returns:
the help label for this selector step.

getSelectErrorMessage

protected abstract String getSelectErrorMessage()
Returns:
the error message to be displayed in case of an error in selection

init

public void init(Object data,
                 com.google.gwt.user.client.rpc.AsyncCallback<?> cb)

Specified by:
init in interface WizardStep
Overrides:
init in class AbstractSelectorWizardStep<D>
See Also:
AbstractSelectorWizardStep.init(Object, AsyncCallback)

refreshList

protected void refreshList(com.google.gwt.user.client.rpc.AsyncCallback<?> cb)
Reloads the list of image previews in asynchronous manner.

Parameters:
cb - the callback to handle server call

fetchData

protected abstract void fetchData(com.google.gwt.user.client.rpc.AsyncCallback<List<L>> callback)
Fetches the list of items to be displayed in this list from the server.

Parameters:
callback - the callback to notify when the fetching is done.

fillList

protected ListItem<L> fillList(List<L> dataList,
                               L selectedData)
Fills the list with the given data and returns the item that matches the specified item.

Parameters:
dataList - the list of data to fill the list
selectedData - the data to be matched
Returns:
the list item that matches the given data

isSelectedByDefault

protected boolean isSelectedByDefault(L listItemData)
Parameters:
listItemData - a list item data
Returns:
true of the list item with the given data should be selected by default, false otherwise

getListItem

protected abstract ListItem<L> getListItem(L data)
Parameters:
data - the data to build a list item representation for.
Returns:
a list item for the passed data.

getNewOptionListItem

protected ListItem<L> getNewOptionListItem()
Returns:
an list item representation for a new item to add in the managed list, or null if no such item should be appended to the list.

onCancel

public void onCancel()

Specified by:
onCancel in interface WizardStep
See Also:
WizardStep.onCancel()

onSubmit

public void onSubmit(com.google.gwt.user.client.rpc.AsyncCallback<Boolean> async)

Specified by:
onSubmit in interface WizardStep
See Also:
WizardStep.onSubmit(AsyncCallback)

saveSelectedValue

protected abstract void saveSelectedValue(com.google.gwt.user.client.rpc.AsyncCallback<Boolean> async)
Saves the current selection in this panel in the data managed by this wizard step, if all validation goes well on the submit time.

Parameters:
async - the object to be notified after the selected value is saved
See Also:
onSubmit(AsyncCallback)

displayError

protected void displayError()
Displays the specified error message and error markers for this wizard step.


hideError

protected void hideError()
Hides the error markers for this wizard step.


onDoubleClick

public void onDoubleClick(com.google.gwt.event.dom.client.DoubleClickEvent event)

Specified by:
onDoubleClick in interface com.google.gwt.event.dom.client.DoubleClickHandler
See Also:
DoubleClickHandler.onDoubleClick(DoubleClickEvent)

onKeyUp

public void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)

Specified by:
onKeyUp in interface com.google.gwt.event.dom.client.KeyUpHandler

addNavigationListener

public void addNavigationListener(NavigationListener listener)

Specified by:
addNavigationListener in interface SourcesNavigationEvents

removeNavigationListener

public void removeNavigationListener(NavigationListener listener)

Specified by:
removeNavigationListener in interface SourcesNavigationEvents

getList

protected ListBox<L> getList()
Returns:
the underlying managed list, to allow subclasses to add extra elements or to style

getSelectedItem

protected ListItem<L> getSelectedItem()
Helper method to get the selected item in the list managed by this wizard step.

Returns:
the selected item in the list managed by this wizard step

display

public VerticalResizePanel display()

Specified by:
display in interface WizardStep
Overrides:
display in class AbstractInteractiveWizardStep
See Also:
AbstractInteractiveWizardStep.display()

setNewOptionOnTop

public void setNewOptionOnTop(boolean newOptionOnTop)
Parameters:
newOptionOnTop - set whether the option to add a new item to the list should be added at the top of the list or at its bottom.

setActive

public void setActive()
Notifies this wizard step that it has been activated, when part of an aggregator for example.
FIXME: this function should not be here but in it's own decorating interface for aggregated wizard steps or, cleaner, all wizard steps who need to be notified when they're activated should implement Focusable interface and all wizard step handlers (the dialog, the aggregator) should call setFocus(). This is a quick solution to handle tab change in the selector aggregator.

Overrides:
setActive in class AbstractSelectorWizardStep<D>

getErrorLabel

protected com.google.gwt.user.client.ui.Label getErrorLabel()
Returns:
the errorLabel


Copyright © 2004–2015 XWiki. All rights reserved.