- Incorporated new sidebar which contains the shelf and navigator (tree) components

- Changed version number to 2.0.0 (dev)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4538 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-12-06 23:26:27 +00:00
parent 8f17798cde
commit 98c5a2071c
46 changed files with 3649 additions and 158 deletions

View File

@@ -0,0 +1,387 @@
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.ajax.NavigatorPluginBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.alfresco.web.ui.repo.component.UITree.TreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Navigator component that consists of 4 panels representing
* the main areas of the repository i.e. company home, my home,
* guest home and my alfresco.
* <p>
* Each panel (apart from my alfresco) uses the tree component
* to allow navigation around that area of the repository.
* </p>
*
* @author gavinc
*/
public class UINavigator extends SelfRenderingComponent
{
public static final String COMPONENT_TYPE = "org.alfresco.faces.Navigator";
protected String activeArea;
private static final Log logger = LogFactory.getLog(UINavigator.class);
private static final String NAVIGATION_BEAN = "NavigationBean";
private static final String BROWSE_BEAN = "BrowseBean";
private static final String AJAX_URL_START = "/ajax/invoke/" + NavigatorPluginBean.BEAN_NAME;
private static final String PANEL_ACTION = "panel:";
private static final int PANEL_SELECTED = 1;
private static final int NODE_SELECTED = 2;
// ------------------------------------------------------------------------------
// Component Impl
@Override
public String getFamily()
{
return COMPONENT_TYPE;
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.activeArea = (String)values[1];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[2];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.activeArea;
return values;
}
/**
* @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
*/
public void decode(FacesContext context)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getClientId(context);
String value = (String)requestMap.get(fieldId);
if (value != null && value.length() != 0)
{
if (logger.isDebugEnabled())
logger.debug("Received post back: " + value);
// work out whether a panel or a node was selected
int mode = NODE_SELECTED;
String item = value;
if (value.startsWith(PANEL_ACTION))
{
mode = PANEL_SELECTED;
item = value.substring(PANEL_ACTION.length());
}
// queue an event to be handled later
NavigatorEvent event = new NavigatorEvent(this, mode, item);
this.queueEvent(event);
}
}
/**
* @see javax.faces.component.UIInput#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException
{
if (event instanceof NavigatorEvent)
{
FacesContext context = FacesContext.getCurrentInstance();
NavigatorEvent navEvent = (NavigatorEvent)event;
// node or panel selected?
switch (navEvent.getMode())
{
case PANEL_SELECTED:
{
String panelSelected = navEvent.getItem();
// a panel was selected, setup the context to make the panel
// the focus
NavigationBean nb = (NavigationBean)FacesHelper.getManagedBean(
context, NAVIGATION_BEAN);
if (nb != null)
{
try
{
if (logger.isDebugEnabled())
logger.debug("Selecting panel: " + panelSelected);
nb.processToolbarLocation(panelSelected, true);
}
catch (InvalidNodeRefException refErr)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NOHOME),
Application.getCurrentUser(context).getHomeSpaceId()), refErr );
}
catch (Exception err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC),
err.getMessage()), err);
}
}
break;
}
case NODE_SELECTED:
{
// a node was clicked in the tree
NodeRef nodeClicked = new NodeRef(navEvent.getItem());
// setup the context to make the node the current node
BrowseBean bb = (BrowseBean)FacesHelper.getManagedBean(
context, BROWSE_BEAN);
if (bb != null)
{
if (logger.isDebugEnabled())
logger.debug("Selected node: " + nodeClicked);
bb.clickSpace(nodeClicked);
}
break;
}
}
}
else
{
super.broadcast(event);
}
}
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException
{
if (!isRendered()) return;
// TODO: pull width and height from user preferences and/or the main config,
// if present override below using the style attribute
ResponseWriter out = context.getResponseWriter();
NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean(
context, NAVIGATION_BEAN);
NavigatorPluginBean navPluginBean = (NavigatorPluginBean)FacesHelper.getManagedBean(
context, NavigatorPluginBean.BEAN_NAME);
List<TreeNode> rootNodesForArea = null;
String area = this.getActiveArea();
String areaTitle = null;
boolean treePanel = true;
if (NavigationBean.LOCATION_COMPANY.equals(area))
{
rootNodesForArea = navPluginBean.getCompanyHomeRootNodes();
areaTitle = Application.getMessage(context, "company_home");
}
else if (NavigationBean.LOCATION_HOME.equals(area))
{
rootNodesForArea = navPluginBean.getMyHomeRootNodes();
areaTitle = Application.getMessage(context, "my_home");
}
else if (NavigationBean.LOCATION_GUEST.equals(area))
{
rootNodesForArea = navPluginBean.getGuestHomeRootNodes();
areaTitle = Application.getMessage(context, "guest_home");
}
else
{
treePanel = false;
areaTitle = Application.getMessage(context, "my_alfresco");
}
// generate the active panel title
out.write("<div id=\"navigator\">");
out.write("<div class=\"navigatorPanelTitleSelected\">");
out.write(areaTitle);
out.write("</div>");
// generate the javascript method to capture the tree node click events
if (treePanel)
{
out.write("\n<script type=\"text/javascript\">\n");
out.write("function treeNodeSelected(nodeRef) {\n");
out.write(Utils.generateFormSubmit(context, this, getClientId(context),
"nodeRef", true, null));
out.write("\n}\n");
out.write("</script>\n");
// generate the active panel containing the tree
out.write("<div class=\"navigatorPanelBody\">");
UITree tree = (UITree)context.getApplication().createComponent(
UITree.COMPONENT_TYPE);
tree.setId("tree");
tree.setRootNodes(rootNodesForArea);
tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?area=" + area);
tree.setNodeCollapsedUrl(AJAX_URL_START + ".nodeCollapsed?area=" + area);
tree.setNodeSelectedCallback("treeNodeSelected");
tree.setNodeCollapsedCallback("informOfCollapse");
Utils.encodeRecursive(context, tree);
out.write("</div>");
}
// generate the closed panel title areas
if (NavigationBean.LOCATION_COMPANY.equals(area) == false &&
navBean.getCompanyHomeVisible())
{
out.write("<div class=\"navigatorPanelTitle\">");
out.write("<a onclick=\"");
out.write(Utils.generateFormSubmit(context, this, getClientId(context),
PANEL_ACTION + NavigationBean.LOCATION_COMPANY));
out.write("\" href=\"#\">");
out.write(Application.getMessage(context, "company_home"));
out.write("</a></div>");
}
if (NavigationBean.LOCATION_HOME.equals(area) == false)
{
out.write("<div class=\"navigatorPanelTitle\">");
out.write("<a onclick=\"");
out.write(Utils.generateFormSubmit(context, this, getClientId(context),
PANEL_ACTION + NavigationBean.LOCATION_HOME));
out.write("\" href=\"#\">");
out.write(Application.getMessage(context, "my_home"));
out.write("</a></div>");
}
if (NavigationBean.LOCATION_GUEST.equals(area) == false &&
navBean.getIsGuest() == false && navBean.getGuestHomeVisible())
{
out.write("<div class=\"navigatorPanelTitle\">");
out.write("<a onclick=\"");
out.write(Utils.generateFormSubmit(context, this, getClientId(context),
PANEL_ACTION + NavigationBean.LOCATION_GUEST));
out.write("\" href=\"#\">");
out.write(Application.getMessage(context, "guest_home"));
out.write("</a></div>");
}
if (NavigationBean.LOCATION_MYALFRESCO.equals(area) == false)
{
out.write("<div class=\"navigatorPanelTitle\">");
out.write("<a onclick=\"");
out.write(Utils.generateFormSubmit(context, this, getClientId(context),
PANEL_ACTION + NavigationBean.LOCATION_MYALFRESCO));
out.write("\" href=\"#\">");
out.write(Application.getMessage(context, "my_alfresco"));
out.write("</a></div>");
}
out.write("</div>");
}
@Override
public void encodeChildren(FacesContext context) throws IOException
{
if (!isRendered()) return;
for (Iterator i=this.getChildren().iterator(); i.hasNext(); /**/)
{
UIComponent child = (UIComponent)i.next();
Utils.encodeRecursive(context, child);
}
}
@Override
public boolean getRendersChildren()
{
return true;
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* Returns the active area the navigator component is showing
*
* @return The active area
*/
public String getActiveArea()
{
ValueBinding vb = getValueBinding("activeArea");
if (vb != null)
{
this.activeArea = (String)vb.getValue(getFacesContext());
}
if (this.activeArea == null)
{
this.activeArea = NavigationBean.LOCATION_HOME;
}
return this.activeArea;
}
/**
* Sets the active area for the navigator panel
*
* @param activeArea
*/
public void setActiveArea(String activeArea)
{
this.activeArea = activeArea;
}
// ------------------------------------------------------------------------------
// Helper methods
/**
* Class representing the clicking of a tree node.
*/
@SuppressWarnings("serial")
public static class NavigatorEvent extends ActionEvent
{
private int mode;
private String item;
public NavigatorEvent(UIComponent component, int mode, String item)
{
super(component);
this.mode = mode;
this.item = item;
}
public String getItem()
{
return item;
}
public int getMode()
{
return mode;
}
}
}

View File

@@ -65,7 +65,7 @@ public class UINodeInfo extends SelfRenderingComponent
// output the scripts required by the component (checks are
// made to make sure the scripts are only written once)
Utils.writeAjaxScripts(context, out);
Utils.writeDojoScripts(context, out);
// write out the JavaScript specific to the NodeInfo component,
// again, make sure it's only done once

View File

@@ -0,0 +1,223 @@
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import org.alfresco.web.bean.SidebarBean;
import org.alfresco.web.config.SidebarConfigElement;
import org.alfresco.web.config.SidebarConfigElement.SidebarPluginConfig;
import org.alfresco.web.ui.common.PanelGenerator;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.alfresco.web.ui.common.component.UIListItems;
import org.alfresco.web.ui.common.component.UIModeList;
/**
* Component that represents the sidebar.
* <p>
* A sidebar consists of multiple plugins, of which only
* one is active at one time. All registered plugins are
* displayed in a drop down allowing the user to
* change the active plugin. An action group can also be
* associated with a plugin, which get rendered in the
* sidebar header.
* </p>
*
* @author gavinc
*/
public class UISidebar extends SelfRenderingComponent
{
public static final String COMPONENT_TYPE = "org.alfresco.faces.Sidebar";
protected String activePlugin;
@Override
public String getFamily()
{
return COMPONENT_TYPE;
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.activePlugin = (String)values[1];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[8];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.activePlugin;
return values;
}
@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext context) throws IOException
{
if (!isRendered()) return;
ResponseWriter out = context.getResponseWriter();
out.write("<div id=\"sidebar\">");
// render the start of the header panel
PanelGenerator.generatePanelStart(out,
context.getExternalContext().getRequestContextPath(),
"blue", "#D3E6FE");
// generate the required child components if not present
if (this.getChildCount() == 1)
{
// create the mode list component
UIModeList modeList = (UIModeList)context.getApplication().
createComponent("org.alfresco.faces.ModeList");
modeList.setId("sidebarPluginList");
modeList.setValue(this.getActivePlugin());
modeList.setIconColumnWidth(2);
modeList.setMenu(true);
modeList.setMenuImage("/images/icons/menu.gif");
modeList.getAttributes().put("itemSpacing", 4);
modeList.getAttributes().put("styleClass", "moreActionsMenu");
modeList.getAttributes().put("selectedStyleClass", "statusListHighlight");
MethodBinding listener = context.getApplication().createMethodBinding(
"#{SidebarBean.pluginChanged}", new Class[] {ActionEvent.class});
modeList.setActionListener(listener);
// create the child list items component
UIListItems items = (UIListItems)context.getApplication().
createComponent("org.alfresco.faces.ListItems");
ValueBinding binding = context.getApplication().createValueBinding(
"#{SidebarBean.plugins}");
items.setValueBinding("value", binding);
// add the list items to the mode list component
modeList.getChildren().add(items);
// create the actions component
UIActions actions = (UIActions)context.getApplication().
createComponent("org.alfresco.faces.Actions");
actions.setId("sidebarActions");
actions.setShowLink(false);
// TODO: we need to setup the context for the actions component
// but when the app first starts there is no context yet,
// also the tree will not update the context as it is
// navigated so what do we use? we may have to only support
// global non-context actions
String actionsGroupId = null;
SidebarConfigElement config = SidebarBean.getSidebarConfig(context);
if (config != null)
{
SidebarPluginConfig plugin = config.getPlugin(getActivePlugin());
if (plugin != null)
{
actionsGroupId = plugin.getActionsConfigId();
}
}
actions.setValue(actionsGroupId);
// add components to the sidebar
this.getChildren().add(0, modeList);
this.getChildren().add(1, actions);
}
}
@Override
public void encodeChildren(FacesContext context) throws IOException
{
if (!isRendered()) return;
// there should be 3 children, the modelist, the actions
// and the plugin, get them individually and render
if (getChildren().size() == 3)
{
ResponseWriter out = context.getResponseWriter();
out.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td>");
// render the list
UIModeList modeList = (UIModeList)getChildren().get(0);
Utils.encodeRecursive(context, modeList);
out.write("</td><td align='right'>");
// render the actions
UIActions actions = (UIActions)getChildren().get(1);
Utils.encodeRecursive(context, actions);
out.write("</td></tr></table>");
// render the end of the header panel
PanelGenerator.generateTitledPanelMiddle(out,
context.getExternalContext().getRequestContextPath(),
"blue", "white", "white");
// render the plugin
UIComponent plugin = (UIComponent)getChildren().get(2);
Utils.encodeRecursive(context, plugin);
}
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
if (!isRendered()) return;
// render the end of the panel
ResponseWriter out = context.getResponseWriter();
PanelGenerator.generatePanelEnd(out,
context.getExternalContext().getRequestContextPath(),
"white");
out.write("</div>");
}
@Override
public boolean getRendersChildren()
{
return true;
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* Returns the id of the plugin that is currently active
*
* @return The currently active plugin
*/
public String getActivePlugin()
{
ValueBinding vb = getValueBinding("activePlugin");
if (vb != null)
{
this.activePlugin = (String)vb.getValue(getFacesContext());
}
return this.activePlugin;
}
/**
* Sets the active plugin the sidebar should show
*
* @param activePlugin Id of the plugin to make active
*/
public void setActivePlugin(String activePlugin)
{
this.activePlugin = activePlugin;
}
}

View File

@@ -0,0 +1,384 @@
package org.alfresco.web.ui.repo.component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
/**
* JSF component that renders an AJAX based tree for browsing the
* repository.
*
* @author gavinc
*/
public class UITree extends UIComponentBase
{
public static final String COMPONENT_TYPE = "org.alfresco.faces.Tree";
public static final String DEFAULT_RENDERER = "org.alfresco.faces.Yahoo";
protected List<TreeNode> rootNodes = null;
protected String retrieveChildrenUrl;
protected String nodeCollapsedUrl;
protected String nodeExpandedCallback;
protected String nodeCollapsedCallback;
protected String nodeSelectedCallback;
// ------------------------------------------------------------------------------
// Component Impl
public UITree()
{
setRendererType(DEFAULT_RENDERER);
}
@Override
public String getFamily()
{
return COMPONENT_TYPE;
}
@Override
@SuppressWarnings("unchecked")
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.rootNodes = (List<TreeNode>)values[1];
this.retrieveChildrenUrl = (String)values[2];
this.nodeCollapsedUrl = (String)values[3];
this.nodeExpandedCallback = (String)values[4];
this.nodeCollapsedCallback = (String)values[5];
this.nodeSelectedCallback = (String)values[6];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[7];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.rootNodes;
values[2] = this.retrieveChildrenUrl;
values[3] = this.nodeCollapsedUrl;
values[4] = this.nodeExpandedCallback;
values[5] = this.nodeCollapsedCallback;
values[6] = this.nodeSelectedCallback;
return values;
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* Get the root nodes for the tree
*
* @return the list of nodes representing the root nodes of the tree
*/
@SuppressWarnings("unchecked")
public List<TreeNode> getRootNodes()
{
ValueBinding vb = getValueBinding("rootNodes");
if (vb != null)
{
this.rootNodes = (List<TreeNode>)vb.getValue(getFacesContext());
}
return this.rootNodes;
}
/**
* Set the root nodes for the tree to show
*
* @param rootNodes The list of node for the tree
*/
public void setRootNodes(List<TreeNode> rootNodes)
{
this.rootNodes = rootNodes;
}
/**
* Returns the Javascript function name to be used for node collapsed event
*
* @return Javascript function name to be used for node collapsed event
*/
public String getNodeCollapsedCallback()
{
ValueBinding vb = getValueBinding("nodeCollapsedCallback");
if (vb != null)
{
this.nodeCollapsedCallback = (String)vb.getValue(getFacesContext());
}
return this.nodeCollapsedCallback;
}
/**
* Sets the name of the Javascript function to use for the node collapsed event
*
* @param nodeCollapsedCallback The Javascript function to use for the node collapsed event
*/
public void setNodeCollapsedCallback(String nodeCollapsedCallback)
{
this.nodeCollapsedCallback = nodeCollapsedCallback;
}
/**
* Returns the Javascript function name to be used for node expanded event
*
* @return Javascript function name to be used for node expanded event
*/
public String getNodeExpandedCallback()
{
ValueBinding vb = getValueBinding("nodeExpandedCallback");
if (vb != null)
{
this.nodeExpandedCallback = (String)vb.getValue(getFacesContext());
}
return this.nodeExpandedCallback;
}
/**
* Sets the name of the Javascript function to use for the expanded event
*
* @param nodeCollapsedCallback The Javascript function to use for the expanded event
*/
public void setNodeExpandedCallback(String nodeExpandedCallback)
{
this.nodeExpandedCallback = nodeExpandedCallback;
}
/**
* Returns the Javascript function name to be used for node selected event
*
* @return Javascript function name to be used for node selected event
*/
public String getNodeSelectedCallback()
{
ValueBinding vb = getValueBinding("nodeSelectedCallback");
if (vb != null)
{
this.nodeSelectedCallback = (String)vb.getValue(getFacesContext());
}
return this.nodeSelectedCallback;
}
/**
* Sets the name of the Javascript function to use for the node selected event
*
* @param nodeCollapsedCallback The Javascript function to use for the node selected event
*/
public void setNodeSelectedCallback(String nodeSelectedCallback)
{
this.nodeSelectedCallback = nodeSelectedCallback;
}
/**
* Returns the URL to use for the AJAX call to retrieve the child nodea
*
* @return AJAX URL to get children
*/
public String getRetrieveChildrenUrl()
{
ValueBinding vb = getValueBinding("retrieveChildrenUrl");
if (vb != null)
{
this.retrieveChildrenUrl = (String)vb.getValue(getFacesContext());
}
return this.retrieveChildrenUrl;
}
/**
* Sets the AJAX URL to use to retrive child nodes
*
* @param retrieveChildrenUrl The AJAX URL to use
*/
public void setRetrieveChildrenUrl(String retrieveChildrenUrl)
{
this.retrieveChildrenUrl = retrieveChildrenUrl;
}
/**
* Returns the URL to use for the AJAX call to inform the server
* that a node has been collapsed
*
* @return AJAX URL to inform of node collapse
*/
public String getNodeCollapsedUrl()
{
ValueBinding vb = getValueBinding("nodeCollapsedUrl");
if (vb != null)
{
this.nodeCollapsedUrl = (String)vb.getValue(getFacesContext());
}
return this.nodeCollapsedUrl;
}
/**
* Sets the AJAX URL to use to inform the server that a node
* has been collapsed
*
* @param nodeCollapsedUrl The AJAX URL to use
*/
public void setNodeCollapsedUrl(String nodeCollapsedUrl)
{
this.nodeCollapsedUrl = nodeCollapsedUrl;
}
/**
* Inner class representing a node in the tree
*
* @author gavinc
*/
public static class TreeNode
{
private String nodeRef;
private String name;
private String icon;
private boolean leafNode = false;
private boolean expanded = false;
private boolean selected = false;
private TreeNode parent;
private List<TreeNode> children = new ArrayList<TreeNode>();
/**
* Default constructor
*
* @param nodeRef The NodeRef of the item the node is representing
* @param name The name for the tree label
* @param icon The icon for the node
*/
public TreeNode(String nodeRef, String name, String icon)
{
this.nodeRef = nodeRef;
this.name = name;
this.icon = icon;
}
public String getIcon()
{
return this.icon;
}
public void setIcon(String icon)
{
this.icon = icon;
}
public boolean isLeafNode()
{
return this.leafNode;
}
public void setLeafNode(boolean leafNode)
{
this.leafNode = leafNode;
}
public boolean isExpanded()
{
return this.expanded;
}
public void setExpanded(boolean expanded)
{
this.expanded = expanded;
}
public boolean isSelected()
{
return this.selected;
}
public void setSelected(boolean selected)
{
this.selected = selected;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public String getNodeRef()
{
return this.nodeRef;
}
public void setNodeRef(String nodeRef)
{
this.nodeRef = nodeRef;
}
public TreeNode getParent()
{
return this.parent;
}
public void setParent(TreeNode parent)
{
this.parent = parent;
}
public List<TreeNode> getChildren()
{
return this.children;
}
public void addChild(TreeNode child)
{
child.setParent(this);
this.children.add(child);
}
public void removeChildren()
{
this.children = new ArrayList<TreeNode>();
}
public String toString()
{
StringBuilder buffer = new StringBuilder(super.toString());
buffer.append(" (nodeRef=").append(this.nodeRef);
buffer.append(", name=").append(this.name);
buffer.append(", icon=").append(this.icon);
buffer.append(", expanded=").append(this.expanded);
buffer.append(", selected=").append(this.selected);
if (this.parent != null)
{
buffer.append(", parent=").append(this.parent.getNodeRef());
}
else
{
buffer.append(", parent=null");
}
buffer.append(", leafNode=").append(this.leafNode).append(")");
return buffer.toString();
}
public String toXML()
{
StringBuilder xml = new StringBuilder();
xml.append("<node ref=\"");
xml.append(this.nodeRef);
xml.append("\" name=\"");
xml.append(this.name);
xml.append("\" icon=\"");
xml.append(this.icon);
xml.append("\"/>");
return xml.toString();
}
}
}