Class NodePickerController
- java.lang.Object
-
- org.hippoecm.frontend.plugins.standards.picker.NodePickerController
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.model.IDetachable
,org.apache.wicket.util.io.IClusterable
public abstract class NodePickerController extends Object implements org.apache.wicket.model.IDetachable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NodePickerController(IPluginContext context, NodePickerControllerSettings settings)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.apache.wicket.Component
create(String id)
void
detach()
protected org.apache.wicket.model.IModel<Node>
getBaseModel()
A hook that allows subclasses to specify a default location.org.apache.wicket.model.IModel<Node>
getFolderModel()
Helper method to retrieve the current folder modelprotected abstract org.apache.wicket.model.IModel<Node>
getInitialModel()
Return the initially selected modelprotected org.apache.wicket.model.IModel<Node>
getLastVisitedFromPreferences()
Check the IPreferencesStore for a last visited location (a node path) and if found, return it in a new JcrNodeModel, otherwise return null.IRenderService
getRenderer()
String
getRootPath()
String[]
getRootPaths()
org.apache.wicket.model.IModel<Node>
getSelectedModel()
NodePickerControllerSettings
getSettings()
void
initSelection()
Try to determine which model should be used as initial selection.protected boolean
isLinkable(Node node)
Determine if the provided node is of nodeType["mix:referenceable"] and if it's not a hippo:document below a hippo:handle.boolean
isStrictRootPath()
protected boolean
isValidNodeType(Node node)
Determine if the node type of the provided node is valid.protected boolean
isValidSelection(org.apache.wicket.model.IModel<Node> targetModel)
This method determines the validity of the selected node in context of this dialog.void
onClose()
protected void
onFolderSelected(org.apache.wicket.model.IModel<Node> model)
protected void
onSelect(boolean isValid)
This method is called when a new model is selected.void
setSelectedFolder(org.apache.wicket.model.IModel<Node> model)
-
-
-
Constructor Detail
-
NodePickerController
public NodePickerController(IPluginContext context, NodePickerControllerSettings settings)
-
-
Method Detail
-
create
public org.apache.wicket.Component create(String id)
-
setSelectedFolder
public void setSelectedFolder(org.apache.wicket.model.IModel<Node> model)
-
getSettings
public NodePickerControllerSettings getSettings()
-
onFolderSelected
protected void onFolderSelected(org.apache.wicket.model.IModel<Node> model)
-
initSelection
public void initSelection()
Try to determine which model should be used as initial selection. First, retrieve the model that represents the actual selected node and see if it is valid. If so, select it and return, if not, see if a last visited model is set and if so select it and return. If not, see if a default model is set, if so, select it and return. If not, fallback to the model currently in the selectionModelReference. TODO: We should try and see if the last-visited model is visible in the browser, if not, go on to default model
-
getBaseModel
protected org.apache.wicket.model.IModel<Node> getBaseModel()
A hook that allows subclasses to specify a default location.- Returns:
- An model used as default initial selection
-
getSelectedModel
public org.apache.wicket.model.IModel<Node> getSelectedModel()
-
getInitialModel
protected abstract org.apache.wicket.model.IModel<Node> getInitialModel()
Return the initially selected model- Returns:
- The model that is initially selected
-
onSelect
protected void onSelect(boolean isValid)
This method is called when a new model is selected.- Parameters:
isValid
- If the model is considered a valid selection model, value will be true, otherwise false.
-
isValidSelection
protected boolean isValidSelection(org.apache.wicket.model.IModel<Node> targetModel)
This method determines the validity of the selected node in context of this dialog. Null values are always considered invalid. Validity is based on whether the nodetype is allowed and if the node is linkable.- Parameters:
targetModel
- The model providing the node to be validated.- Returns:
- If the provided node is a valid dialog selection.
-
isLinkable
protected boolean isLinkable(Node node) throws RepositoryException
Determine if the provided node is of nodeType["mix:referenceable"] and if it's not a hippo:document below a hippo:handle.- Parameters:
node
- Node to test for linkability- Returns:
- If this node is linkable
- Throws:
RepositoryException
- Something went wrong in the repository
-
isValidNodeType
protected boolean isValidNodeType(Node node) throws RepositoryException
Determine if the node type of the provided node is valid. In case a handle is passed, it will use the nested hippo-document node, or, if none found (in case of a delete), return false.
By default, only documents are considered valid. To use more fine-grained validation, like for example, only allow document types "foo" & "bar", or allow folders as well, a list of allowedNodeTypes can be set during construction of the dialog.
- Parameters:
node
- The node to be validated. If it is of nodeType["hippo:handle"], the first childNode with the same name will be used instead.- Returns:
- If the node type is considered valid.
- Throws:
RepositoryException
- Something went wrong in the repository
-
getRenderer
public IRenderService getRenderer()
-
onClose
public final void onClose()
-
detach
public void detach()
- Specified by:
detach
in interfaceorg.apache.wicket.model.IDetachable
-
getLastVisitedFromPreferences
protected org.apache.wicket.model.IModel<Node> getLastVisitedFromPreferences()
Check the IPreferencesStore for a last visited location (a node path) and if found, return it in a new JcrNodeModel, otherwise return null.- Returns:
- A new JcrNodeModel pointing to the last visited location (a node path) or null
-
getFolderModel
public org.apache.wicket.model.IModel<Node> getFolderModel()
Helper method to retrieve the current folder model- Returns:
- The folder model
-
getRootPath
public String getRootPath()
-
getRootPaths
public String[] getRootPaths()
-
isStrictRootPath
public boolean isStrictRootPath()
-
-