com.atlassian.gadgets.dashboard.internal.impl
Class DashboardImpl

java.lang.Object
  extended by com.atlassian.gadgets.dashboard.internal.impl.DashboardImpl
All Implemented Interfaces:
Dashboard

public class DashboardImpl
extends Object
implements Dashboard

Implements methods for operating on a backing DashboardState object.


Constructor Summary
DashboardImpl(DashboardState state, StateConverter stateConverter, GadgetRequestContext gadgetRequestContext)
           
 
Method Summary
 void addGadget(DashboardState.ColumnIndex column, Gadget gadget)
          Add a gadget to the first position of the specified column
 void addGadget(Gadget gadget)
           
 void appendGadget(DashboardState.ColumnIndex columnIndex, Gadget gadget)
          Add a gadget to the end of the specified column
 void appendGadget(Gadget gadget)
          Add a gadget to the default tab.
 void assertGadgetLayoutIsValid(Layout layout, GadgetLayout gadgetLayout)
          Checks to make sure there are no gadgets in out of bounds columns.
 void changeGadgetColor(GadgetId gadgetId, Color color)
          Change the color of the gadgets chrome.
 void changeLayout(Layout layout, GadgetLayout gadgetLayout)
          Change the layout of the dashboard and use the gadget layout to update the gadget positioning.
 void clearChanges()
          Clears the stored list of changes that have been made to this Dashboard
 Gadget findGadget(GadgetId gadgetId)
          Lookup a Gadget in this Dashboard given the gadget's id.
 List<DashboardChange> getChanges()
          Returns an immutable list of changes that have been made to this Dashboard, in the order that they occurred.
 Iterable<Gadget> getGadgetsInColumn(DashboardState.ColumnIndex column)
           
 DashboardId getId()
           
 Layout getLayout()
           
 int getNumberOfGadgets()
          Get the total number of gadgets on this dashboard
 DashboardState getState()
           
 String getTitle()
           
 void rearrangeGadgets(GadgetLayout gadgetLayout)
          Rearrange and reposition the gadgets on the dashboard according to the specified layout.
 void removeGadget(GadgetId gadgetId)
          Remove the gadget with the provided id from the dashboard.
 void updateGadgetUserPrefs(GadgetId gadgetId, Map<String,String> prefValues)
          Save user prefs for a gadget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DashboardImpl

public DashboardImpl(DashboardState state,
                     StateConverter stateConverter,
                     GadgetRequestContext gadgetRequestContext)
Method Detail

getId

public DashboardId getId()
Specified by:
getId in interface Dashboard

getTitle

public String getTitle()
Specified by:
getTitle in interface Dashboard

getLayout

public Layout getLayout()
Specified by:
getLayout in interface Dashboard

getGadgetsInColumn

public Iterable<Gadget> getGadgetsInColumn(DashboardState.ColumnIndex column)
Specified by:
getGadgetsInColumn in interface Dashboard

appendGadget

public void appendGadget(Gadget gadget)
Description copied from interface: Dashboard
Add a gadget to the default tab. Let the dashboard pick which column it should go in.

Specified by:
appendGadget in interface Dashboard
Parameters:
gadget - the gadget being added

appendGadget

public void appendGadget(DashboardState.ColumnIndex columnIndex,
                         Gadget gadget)
Description copied from interface: Dashboard
Add a gadget to the end of the specified column

Specified by:
appendGadget in interface Dashboard
Parameters:
columnIndex - index of column to append the gadget to
gadget - the gadget being added

addGadget

public void addGadget(Gadget gadget)
Specified by:
addGadget in interface Dashboard

addGadget

public void addGadget(DashboardState.ColumnIndex column,
                      Gadget gadget)
Description copied from interface: Dashboard
Add a gadget to the first position of the specified column

Specified by:
addGadget in interface Dashboard
Parameters:
column - index of the column to add the gadget to
gadget - the gadget being added

changeLayout

public void changeLayout(Layout layout,
                         GadgetLayout gadgetLayout)
                  throws GadgetLayoutException
Description copied from interface: Dashboard
Change the layout of the dashboard and use the gadget layout to update the gadget positioning.

Specified by:
changeLayout in interface Dashboard
Parameters:
layout - New layout to use for the dashboard
gadgetLayout - New positioning of the gadgets
Throws:
GadgetLayoutException - thrown if the positioning of the gadgets is not valid for the new layout - e.g. threre are gadgets in columns that don't exist in the new layout

rearrangeGadgets

public void rearrangeGadgets(GadgetLayout gadgetLayout)
                      throws GadgetLayoutException
Description copied from interface: Dashboard
Rearrange and reposition the gadgets on the dashboard according to the specified layout.

Specified by:
rearrangeGadgets in interface Dashboard
Parameters:
gadgetLayout - Layout to match
Throws:
GadgetLayoutException - thrown if the layout is invalid

changeGadgetColor

public void changeGadgetColor(GadgetId gadgetId,
                              Color color)
Description copied from interface: Dashboard
Change the color of the gadgets chrome.

Specified by:
changeGadgetColor in interface Dashboard
Parameters:
gadgetId - Id of gadget to change the color of.
color - Color to change the chrome to

updateGadgetUserPrefs

public void updateGadgetUserPrefs(GadgetId gadgetId,
                                  Map<String,String> prefValues)
Description copied from interface: Dashboard
Save user prefs for a gadget

Specified by:
updateGadgetUserPrefs in interface Dashboard
Parameters:
gadgetId - Id of gadget to change the color of.
prefValues - preferences to save

removeGadget

public void removeGadget(GadgetId gadgetId)
Description copied from interface: Dashboard
Remove the gadget with the provided id from the dashboard.

Specified by:
removeGadget in interface Dashboard
Parameters:
gadgetId - id of the gadget to remove

getState

public DashboardState getState()
Specified by:
getState in interface Dashboard

findGadget

public Gadget findGadget(GadgetId gadgetId)
Description copied from interface: Dashboard
Lookup a Gadget in this Dashboard given the gadget's id.

Specified by:
findGadget in interface Dashboard
Parameters:
gadgetId - The gadgetId of the gadget to lookup
Returns:
The Gadget or null if none could be found matching the id

getChanges

public List<DashboardChange> getChanges()
Description copied from interface: Dashboard
Returns an immutable list of changes that have been made to this Dashboard, in the order that they occurred.

Specified by:
getChanges in interface Dashboard
Returns:
immutable list of changes that have been made to this Dashboard

clearChanges

public void clearChanges()
Description copied from interface: Dashboard
Clears the stored list of changes that have been made to this Dashboard

Specified by:
clearChanges in interface Dashboard

getNumberOfGadgets

public int getNumberOfGadgets()
Description copied from interface: Dashboard
Get the total number of gadgets on this dashboard

Specified by:
getNumberOfGadgets in interface Dashboard
Returns:
the total number of gadgets on the dashboard

assertGadgetLayoutIsValid

public void assertGadgetLayoutIsValid(Layout layout,
                                      GadgetLayout gadgetLayout)
                               throws GadgetLayoutException
Checks to make sure there are no gadgets in out of bounds columns.

Parameters:
layout - the layout to verify against
gadgetLayout - the gadget layout to verify
Throws:
GadgetLayoutException - if the gadgetLayout contains more columns than this layout allows


Copyright © 2010 Atlassian. All Rights Reserved.