org.xwiki.rendering.internal.macro.dashboard
Class DefaultGadgetSource

java.lang.Object
  extended by org.xwiki.rendering.internal.macro.dashboard.DefaultGadgetSource
All Implemented Interfaces:
GadgetSource

@Component
public class DefaultGadgetSource
extends java.lang.Object
implements GadgetSource

Default gadget reader, reads the gadgets from XWiki Objects attached to the current document.

Since:
3.0M3
Version:
$Id$

Field Summary
protected  DocumentReferenceResolver<EntityReference> currentReferenceEntityResolver
          The current entity reference resolver, to resolve the gadgets class reference.
protected  DocumentReferenceResolver<java.lang.String> currentReferenceResolver
          The current string reference resolver, to resolve the current document reference in the metadata of the block of the current macro.
protected  org.xwiki.context.Execution execution
          The execution context, to grab XWiki context and access to documents.
 
Constructor Summary
DefaultGadgetSource()
           
 
Method Summary
 java.util.List<Block> getDashboardSourceMetadata(java.lang.String source, org.xwiki.rendering.transformation.MacroTransformationContext context)
          Get the metadata about this dashboard source, such as source document fullname, gadget add url, gadget remove url, etc, to pass to the client.
 java.util.List<Gadget> getGadgets(java.lang.String source, org.xwiki.rendering.transformation.MacroTransformationContext context)
          Reads the gadgets for the passed macro transformation context.
 boolean isEditing()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

execution

@Requirement
protected org.xwiki.context.Execution execution
The execution context, to grab XWiki context and access to documents.


currentReferenceResolver

@Requirement(value="current")
protected DocumentReferenceResolver<java.lang.String> currentReferenceResolver
The current string reference resolver, to resolve the current document reference in the metadata of the block of the current macro.


currentReferenceEntityResolver

@Requirement(value="current/reference")
protected DocumentReferenceResolver<EntityReference> currentReferenceEntityResolver
The current entity reference resolver, to resolve the gadgets class reference.

Constructor Detail

DefaultGadgetSource

public DefaultGadgetSource()
Method Detail

getGadgets

public java.util.List<Gadget> getGadgets(java.lang.String source,
                                         org.xwiki.rendering.transformation.MacroTransformationContext context)
                                  throws java.lang.Exception
Reads the gadgets for the passed macro transformation context.

Specified by:
getGadgets in interface GadgetSource
Parameters:
source - the source to read dashboard gadgets from (a document serialized reference)
context - the dashboard macro transformation context
Returns:
the list of gadgets for the currently executing macro
Throws:
java.lang.Exception - in case anything goes wrong reading data, the exception should be translated by the dashboard macro caller into a macro execution exception
See Also:
#getGadgets(String, MacroTransformationContext)

getDashboardSourceMetadata

public java.util.List<Block> getDashboardSourceMetadata(java.lang.String source,
                                                        org.xwiki.rendering.transformation.MacroTransformationContext context)
Get the metadata about this dashboard source, such as source document fullname, gadget add url, gadget remove url, etc, to pass to the client.
TODO: find a better place for this code, ftm it's here because this is the only class that knows about XWiki data model

Specified by:
getDashboardSourceMetadata in interface GadgetSource
Parameters:
source - the source to read dashboard gadgets from (a document serialized reference)
context - the dashboard macro transformation context
Returns:
a list of blocks that represent the XDOM with the metadata. TODO: might as well be a map of metadata and leave the rendering in XDOM to the dashboard macro, but ftm this does the job
See Also:
GadgetSource.getDashboardSourceMetadata(java.lang.String, org.xwiki.rendering.transformation.MacroTransformationContext)

isEditing

public boolean isEditing()

Specified by:
isEditing in interface GadgetSource
Returns:
true if the the current context is in edit mode (gadgets can be edited -- positions, parameters, adding gadgets etc), false otherwise
TODO: find a better place to put this function, but for now this is the only interface towards XWiki data model, and since the mode is set on the current context, this function needs to be here
See Also:
GadgetSource.isEditing()


Copyright © 2004-2011 XWiki. All Rights Reserved.