You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/08/12 16:36:58 UTC
svn commit: r984805 [3/3] - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/ta...
Copied: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java (from r954522, myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java?p2=myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java&p1=myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java&r1=954522&r2=984805&rev=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java Thu Aug 12 14:36:56 2010
@@ -17,31 +17,24 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.UITree;
-import org.apache.myfaces.tobago.component.UITreeListbox;
-import org.apache.myfaces.tobago.component.UITreeMenu;
import org.apache.myfaces.tobago.component.UITreeNode;
+import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
-import org.apache.myfaces.tobago.context.ResourceUtils;
-import org.apache.myfaces.tobago.event.TreeExpansionEvent;
+import org.apache.myfaces.tobago.context.UserAgent;
import org.apache.myfaces.tobago.internal.component.AbstractUITree;
-import org.apache.myfaces.tobago.internal.context.ResponseWriterDivider;
-import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterImpl;
+import org.apache.myfaces.tobago.internal.component.AbstractUITreeNode;
+import org.apache.myfaces.tobago.internal.util.TreeUtils;
import org.apache.myfaces.tobago.layout.Display;
-import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.model.TreeState;
-import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
+import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.css.Style;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.util.CommandRendererHelper;
+import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.VariableResolverUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,24 +43,16 @@ import javax.faces.component.NamingConta
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
-import java.util.List;
import java.util.Map;
-public class TreeNodeRenderer extends CommandRendererBase {
+public class TreeMenuNodeRenderer extends LayoutComponentRendererBase {
- private static final Logger LOG = LoggerFactory.getLogger(TreeNodeRenderer.class);
-
- protected static final String OPEN_FOLDER
- = ResourceUtils.createString("image", "treeNode", "icon", "open", ResourceUtils.GIF);
- protected static final String CLOSED_FOLDER
- = ResourceUtils.createString("image", "treeNode", "icon", ResourceUtils.GIF);
- protected static final String LEAF
- = ResourceUtils.createString("image", "treeNode", "icon", "leaf", ResourceUtils.GIF);
+ private static final Logger LOG = LoggerFactory.getLogger(TreeMenuNodeRenderer.class);
@Override
public void decode(FacesContext facesContext, UIComponent component) {
- UITreeNode node = (UITreeNode) component;
+ AbstractUITreeNode node = (AbstractUITreeNode) component;
super.decode(facesContext, node);
@@ -78,28 +63,17 @@ public class TreeNodeRenderer extends Co
AbstractUITree tree = node.findTree();
String treeId = tree.getClientId(facesContext);
String nodeStateId = node.nodeStateId(facesContext);
- Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
+ Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
String id = node.getClientId(facesContext);
// expand state
- boolean expanded = Boolean.parseBoolean((String) requestParameterMap.get(id + "-expanded"));
- setExpanded(node, tree, expanded);
-
- // select
- String searchString;
- if (TreeRenderer.isSelectable(tree)) { // selection
- String selected = (String) requestParameterMap.get(treeId + AbstractUITree.SELECT_STATE);
- searchString = ";" + nodeStateId + ";";
- if (StringUtils.contains(selected, searchString)) {
- // TODO: add selection to Component
- //state.addSelection((DefaultMutableTreeNode) node.getValue());
- }
- }
+ boolean expanded = Boolean.parseBoolean(requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + "expanded"));
+ TreeUtils.setExpanded(tree, node, expanded);
// marker
- String marked = (String) requestParameterMap.get(treeId + AbstractUITree.MARKER);
+ String marked = requestParameterMap.get(treeId + AbstractUITree.MARKED);
if (marked != null) {
- searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
+ String searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
node.setMarked(marked.equals(searchString));
} else {
LOG.warn("This log message is help clarifying the occurrence of this else case.");
@@ -107,419 +81,103 @@ public class TreeNodeRenderer extends Co
}
@Override
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- UITreeNode node = (UITreeNode) component;
- AbstractUITree tree = node.findTree();
- if (tree instanceof UITree || tree instanceof UITreeMenu) {
- encodeBeginMenuAndNormal(facesContext, node, tree, tree instanceof UITreeMenu);
- } else { // if (tree instanceof UITreeListbox)
- encodeBeginListbox(facesContext, node, (UITreeListbox) tree);
- }
- }
-
- public void encodeBeginListbox(FacesContext facesContext, UITreeNode node, UITreeListbox tree) throws IOException {
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
+ super.prepareRender(facesContext, component);
- boolean folder = node.isFolder();
- int level = node.getLevel();
- String id = node.getClientId(facesContext);
- boolean expanded = isExpanded(tree, node);
-
- if (level > 0) { // root will not rendered as an option
- writer.startElement(HtmlConstants.OPTION, null);
-// todo: define where to store the selection of a tree, node.getValue() seems not to be a god place.
-// writer.writeAttribute(HtmlAttributes.VALUE, node.getValue().toString(), true); // XXX converter?
- writer.writeIdAttribute(id);
- writer.writeAttribute(HtmlAttributes.SELECTED, expanded);
- writer.writeText("(" + level + ") " + node.getLabel());
- if (folder) {
- writer.writeText(" \u2192");
- }
- writer.endElement(HtmlConstants.OPTION);
- }
-
- if (folder) {
- boolean siblingMode = "siblingLeafOnly".equals(tree.getAttributes().get(Attributes.SELECTABLE));
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, TreeListboxRenderer.DIVIDER);
- boolean alreadyExists = divider.activateBranch(facesContext);
- writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- if (!alreadyExists) {
- writer.startElement(HtmlConstants.DIV, null);
- writer.writeClassAttribute(Classes.simple(tree, "level"));
- Style levelStyle = new Style();
- levelStyle.setLeft(Measure.valueOf(level * 160)); // xxx 160 should be configurable
- writer.writeStyleAttribute(levelStyle);
- // at the start of each div there is an empty and disabled select tag to show empty area.
- // this is not needed for the 1st level.
- if (level > 0) {
- writer.startElement(HtmlConstants.SELECT, null);
- writer.writeAttribute(HtmlAttributes.DISABLED, true);
- writer.writeAttribute(HtmlAttributes.SIZE, 2); // must be > 1, but the size comes from the layout
- writer.writeClassAttribute(Classes.simple(tree, "select"));
- writer.endElement(HtmlConstants.SELECT);
- }
- }
-
- writer.startElement(HtmlConstants.SELECT, node);
- writer.writeIdAttribute(id + ComponentUtils.SUB_SEPARATOR + "select");
- writer.writeClassAttribute(Classes.simple(tree, "select"));
- if (!expanded) {
- Style selectStyle = new Style();
- selectStyle.setDisplay(Display.NONE);
- }
- writer.writeAttribute(HtmlAttributes.SIZE, 2); // must be > 1, but the size comes from the layout
- writer.writeAttribute(HtmlAttributes.MULTIPLE, siblingMode);
-
-// XXX insert options here
- writer.startElement(HtmlConstants.OPTGROUP, null);
- writer.writeAttribute(HtmlAttributes.LABEL, node.getLabel(), true);
- writer.endElement(HtmlConstants.OPTGROUP);
+ final UITreeNode node = (UITreeNode) component;
+ if (node.isMarked()) {
+ node.setMarkup(Markup.MARKED.add(node.getMarkup()));
}
}
- public void encodeBeginMenuAndNormal(FacesContext facesContext, UITreeNode node, AbstractUITree tree, boolean isMenu)
- throws IOException {
+ @Override
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+
+ final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ final UITreeNode node = (UITreeNode) component;
+ final AbstractUITree tree = node.findTree();
- final String treeId = tree.getClientId(facesContext);
final boolean folder = node.isFolder();
- final boolean marked = node.isMarked();
final String id = node.getClientId(facesContext);
final int level = node.getLevel();
- final boolean hasNextSibling = node.isHasNextSibling();
- final List<Boolean> junctions = node.getJunctions();
+ final boolean expanded = TreeUtils.isExpanded(tree, node) || level == 0;
+ final boolean ie6
+ = VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().equals(UserAgent.MSIE_6_0);
+
+ writer.startElement(HtmlElements.DIV, null);
+ writer.writeIdAttribute(id);
+ writer.writeClassAttribute(Classes.create(node));
- final boolean showRoot = tree.isShowRoot();
- final boolean expanded = isExpanded(tree, node) || !showRoot && level == 0;
- final boolean showIcons;
- final boolean showJunctions;
- final boolean showRootJunction;
- if (tree instanceof UITree) {
- showIcons = ((UITree) tree).isShowIcons();
- showJunctions = ((UITree) tree).isShowJunctions();
- showRootJunction = ((UITree) tree).isShowRootJunction();
- } else { // UITreeMenu
- showIcons = false;
- showJunctions = false;
- showRootJunction = false;
+ if (folder) {
+ writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
}
- if (!showRoot && junctions.size() > 0) {
- junctions.remove(0);
+ if (folder) {
+ encodeExpandedHidden(writer, node, id, expanded);
}
- String source;
- final String openSource;
- final String closedSource;
-
- final String image = ComponentUtils.getStringAttribute(node, "image");
- if (image != null) { // application image
- closedSource = ResourceManagerUtils.getImageWithPath(facesContext, image);
- } else { // theme image
- closedSource = ResourceManagerUtils.getImageWithPath(facesContext, CLOSED_FOLDER);
- }
if (folder) {
- if (image != null) { // application image
- openSource = ResourceManagerUtils.getImageWithPath(facesContext,
- ResourceUtils.addPostfixToFilename(image, "open"), true);
- } else { // theme image
- openSource = ResourceManagerUtils.getImageWithPath(facesContext, OPEN_FOLDER);
- }
- source = expanded ? openSource : closedSource;
- } else {
- openSource = null;
- if (image != null) { // application image
- source = ResourceManagerUtils.getImageWithPath(facesContext,
- ResourceUtils.addPostfixToFilename(image, "leaf"), true);
- } else { // theme image
- source = ResourceManagerUtils.getImageWithPath(facesContext, LEAF);
- }
- if (source == null) {
- source = closedSource;
- }
+ encodeIcon(facesContext, writer, expanded, node);
}
- CommandRendererHelper helper = new CommandRendererHelper(facesContext, node, CommandRendererHelper.Tag.ANCHOR);
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
- if (showRoot || level != 0) {
- writer.startElement(HtmlConstants.DIV, null);
+ if (!folder && ie6) { // XXX IE6: without this hack, we can't click beside the label text. Why?
+ final String src = ResourceManagerUtils.getImageWithPath(facesContext, "image/1x1.gif");
+ writer.startElement(HtmlElements.IMG, null);
+ writer.writeClassAttribute(Classes.create(node, "icon"));
+ writer.writeAttribute(HtmlAttributes.SRC, src, false);
+ writer.writeAttribute(HtmlAttributes.ALT, "", false);
+ writer.writeStyleAttribute("width: 0px");
+ writer.endElement(HtmlElements.IMG);
+ }
- // div id
- writer.writeIdAttribute(id);
- if (!folder) {
- HtmlRendererUtils.renderDojoDndItem(node, writer, true);
- }
-
- // div class (css)
- final Classes classes;
- if (isMenu) {
- if (marked) {
- classes = Classes.full(node, new String[] {"menu", "marker"});
- } else {
- classes = Classes.full(node, "menu");
- }
- } else {
- classes = Classes.full(node);
- }
- writer.writeClassAttribute(classes);
-
- // div style (width)
- Style style = new Style(facesContext, tree);
- String widthString;
- if (style.getWidth() != null) {
- widthString = "width: " + Integer.toString(style.getWidth().getPixel() - 22); // fixme: 4 + 18 for scrollbar
- } else {
- widthString = "100%";
- }
- writer.writeStyleAttribute(widthString);
-
- if (folder) {
- encodeExpandedHidden(writer, node, id, expanded);
- }
-
- if (folder && isMenu) {
- encodeMenuIcon(facesContext, writer, treeId, id, expanded, node);
- }
-
- encodeIndent(facesContext, writer, node, isMenu, showJunctions, junctions);
-
- encodeTreeJunction(facesContext, writer, node, id, treeId, showJunctions, showRootJunction, showRoot, expanded,
- folder, level, hasNextSibling, openSource, closedSource);
-
- encodeTreeIcons(writer, node, id, treeId, showIcons, folder, source, openSource, closedSource);
-
- encodeLabel(writer, helper, node, marked, treeId);
-
- UIComponent facet = node.getFacet(Facets.ADDENDUM);
- if (facet != null) {
- RenderUtils.encode(facesContext, facet);
- }
+ RenderUtils.encodeChildrenWithoutLayout(facesContext, node);
- writer.endElement(HtmlConstants.DIV);
+ UIComponent facet = node.getFacet(Facets.ADDENDUM);
+ if (facet != null) {
+ RenderUtils.encode(facesContext, facet);
}
+ writer.endElement(HtmlElements.DIV);
+
if (folder) {
- String contentStyle = "display: " + (expanded ? "block" : "none") + ";";
- writer.startElement(HtmlConstants.DIV, null);
- writer.writeIdAttribute(id + "-cont");
+ writer.startElement(HtmlElements.DIV, null);
+ writer.writeIdAttribute(id + ComponentUtils.SUB_SEPARATOR + "content");
+ Style contentStyle = new Style();
+ contentStyle.setDisplay(expanded ? Display.BLOCK : Display.NONE);
writer.writeStyleAttribute(contentStyle);
}
}
- private void encodeExpandedHidden(TobagoResponseWriter writer, UITreeNode node, String clientId,
- boolean expanded) throws IOException {
- writer.startElement(HtmlConstants.INPUT, node);
+ private void encodeExpandedHidden(
+ TobagoResponseWriter writer, AbstractUITreeNode node, String clientId, boolean expanded) throws IOException {
+ writer.startElement(HtmlElements.INPUT, node);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId + "-expanded");
- writer.writeIdAttribute(clientId + "-expanded");
+ writer.writeClassAttribute(Classes.create(node, "expanded", Markup.NULL));
+ writer.writeNameAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "expanded");
writer.writeAttribute(HtmlAttributes.VALUE, Boolean.toString(expanded), false);
- writer.endElement(HtmlConstants.INPUT);
- }
-
- private void encodeMenuIcon(
- FacesContext facesContext, TobagoResponseWriter writer, String treeId, String id, boolean expanded,
- UIComponent node)
- throws IOException {
- String menuOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuOpen.gif");
- String menuClose = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuClose.gif");
- String onclick = "tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', null, null, '"
- + menuOpen + "', '" + menuClose + "')";
- Object objOnclick = node.getAttributes().get("onclick");
- if (null != objOnclick) {
- onclick += ";" + objOnclick;
- }
- String src = expanded ? menuOpen : menuClose;
- writer.startElement(HtmlConstants.IMG, null);
- writer.writeClassAttribute(Classes.simple(node, "menuIcon"));
- writer.writeIdAttribute(id + "-menuIcon");
- writer.writeAttribute("src", src, true);
- writer.writeAttribute("onclick", onclick, true);
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlConstants.IMG);
- }
-
- private void encodeIndent(
- final FacesContext facesContext, final TobagoResponseWriter writer, final UITreeNode node, final boolean menuMode,
- final boolean showJunctions, final List<Boolean> junctions)
- throws IOException {
-
- String blank = ResourceManagerUtils.getImageWithPath(facesContext, "image/blank.gif");
- String perpendicular = ResourceManagerUtils.getImageWithPath(facesContext, "image/I.gif");
-
- for (Boolean junction : junctions) {
- writer.startElement(HtmlConstants.IMG, null);
- writer.writeClassAttribute(Classes.simple(node, "junction"));
- if (junction && !menuMode && showJunctions) {
- writer.writeAttribute("src", perpendicular, true);
- } else {
- writer.writeAttribute("src", blank, true);
- }
- writer.endElement(HtmlConstants.IMG);
- }
- }
-
- private void encodeTreeJunction(
- FacesContext facesContext, TobagoResponseWriter writer, UITreeNode node, String id, String treeId,
- boolean showJunctions, boolean showRootJunction, boolean showRoot, boolean expanded, boolean folder,
- int level, boolean hasNextSibling, String openSource, String closedSource)
- throws IOException {
- if (!(!showJunctions
- || !showRootJunction && level == 0
- || !showRootJunction && !showRoot && level == 1)) {
- writer.startElement(HtmlConstants.IMG, null);
- writer.writeClassAttribute(Classes.simple(node, "junction"));
- writer.writeIdAttribute(id + "-junction");
-
- String gif = folder && expanded
- ? (level == 0
- ? "Rminus.gif"
- : (hasNextSibling ? "Tminus.gif" : "Lminus.gif"))
- : ((level == 0)
- ? "Rplus.gif"
- : (hasNextSibling)
- ? (folder ? "Tplus.gif" : "T.gif")
- : (folder ? "Lplus.gif" : "L.gif")
- );
-
- String src = ResourceManagerUtils.getImageWithPath(facesContext, "image/" + gif);
- writer.writeAttribute("src", src, true);
- if (folder) {
- writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
- }
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlConstants.IMG);
- }
- }
-
- private void encodeTreeIcons(
- TobagoResponseWriter writer, UITreeNode node, String id, String treeId,
- boolean showIcons, boolean folder, String source, String openSource, String closedSource)
- throws IOException {
-
- if (showIcons) {
- writer.startElement(HtmlConstants.IMG, null);
- writer.writeClassAttribute(Classes.simple(node, "icon"));
- writer.writeIdAttribute(id + "-icon"); //XXX may not okay with naming conventions
-
- writer.writeAttribute("src", source, true);
- if (folder) {
- writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
- }
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlConstants.IMG);
- }
- }
-
- private String createOnclickForToggle(String treeId, String openSouce, String closedSource) {
- if (openSouce == null) { // default
- openSouce = closedSource;
- }
- return "tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', '"
- + openSouce + "', '" + closedSource + "', null, null)";
- }
-
-/*
- if (this.isFolder) {
- str += '<img class="tree-icon" id="' + this.id + '-icon" '
- + 'src="' + (this.expanded ? this.openIcon : this.icon) + ' " '
- + 'onclick="toggle(this.parentNode, \'' + this.treeHiddenId
- + '\', \'' + this.treeResources.getImage("image/treeNode-icon-open.gif")
- + '\', \'' + this.treeResources.getImage("image/treeNode-icon.gif")
- + '\')"'
- + ' alt="">';
- } else {
- str += '<img class="tree-icon" id="' + this.id
- + '-icon" src="' + this.treeResources.getImage("image/treeNode-icon-leaf.gif") + '" alt="">';
+ writer.endElement(HtmlElements.INPUT);
}
-*/
- private void encodeLabel(
- TobagoResponseWriter writer, CommandRendererHelper helper, UITreeNode node, boolean marked, String treeId)
+ private void encodeIcon(FacesContext facesContext, TobagoResponseWriter writer, boolean expanded, UITreeNode node)
throws IOException {
-
- writer.startElement(HtmlConstants.A, null);
- if (!helper.isDisabled()) {
- writer.writeAttribute(HtmlAttributes.HREF, helper.getHref(), true);
- writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true); // xxx is escaping required?
- writer.writeAttribute(
- HtmlAttributes.ONFOCUS, "Tobago.Tree.storeMarker(this.parentNode, '" + treeId + "')", false);
- if (helper.getTarget() != null) {
- writer.writeAttribute(HtmlAttributes.TARGET, helper.getTarget(), true);
- }
- }
- if (marked) {
- writer.writeClassAttribute(Classes.simple(node, "marker"));
- }
- String tip = node.getTip();
- if (tip != null) {
- writer.writeAttribute(HtmlAttributes.TITLE, tip, true);
- }
- String label = node.getLabel();
- if (label == null) {
- label = "";
- }
- writer.writeText(label);
- writer.endElement(HtmlConstants.A);
+ final String srcOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuOpen.gif");
+ final String srcClose = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuClose.gif");
+ final String src = expanded ? srcOpen : srcClose;
+ writer.startElement(HtmlElements.IMG, null);
+ writer.writeClassAttribute(Classes.create(node, "toggle"));
+ writer.writeAttribute(HtmlAttributes.SRC, src, false);
+ writer.writeAttribute(HtmlAttributes.SRCOPEN, srcOpen, false);
+ writer.writeAttribute(HtmlAttributes.SRCCLOSE, srcClose, false);
+ writer.writeAttribute(HtmlAttributes.ALT, "", false);
+ writer.endElement(HtmlElements.IMG);
}
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UITreeNode node = (UITreeNode) component;
- AbstractUITree tree = node.findTree();
- if (tree instanceof UITree || tree instanceof UITreeMenu) {
- encodeEndMenuAndNormal(facesContext, node);
- } else { // if (tree instanceof UITreeListbox)
- encodeEndListbox(facesContext, node);
- }
- }
-
- protected void encodeEndListbox(FacesContext facesContext, UITreeNode node) throws IOException {
- boolean folder = node.isFolder();
- if (folder) {
- TobagoResponseWriterImpl writer
- = (TobagoResponseWriterImpl) HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- writer.endElement(HtmlConstants.SELECT);
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, TreeListboxRenderer.DIVIDER);
- divider.passivateBranch(facesContext);
- }
- }
-
- protected void encodeEndMenuAndNormal(FacesContext facesContext, UITreeNode node) throws IOException {
-
- boolean folder = node.isFolder();
- String id = node.getClientId(facesContext);
-
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
- if (folder) {
- writer.endElement(HtmlConstants.DIV);
- writer.writeComment("\nend of " + id + "-cont ");
- }
- }
-
- private boolean isExpanded(AbstractUITree tree, UITreeNode node) {
- TreeState state = (TreeState) tree.getState();
- if (state != null) {
- return state.getExpanded().contains(node.getPath());
- } else {
- return node.isExpanded();
- }
- }
-
- private void setExpanded(UITreeNode node, AbstractUITree tree, boolean expanded) {
- boolean oldExpanded = isExpanded(tree, node);
-
- if (tree.getState() != null) {
- if (expanded) {
- ((TreeState) tree.getState()).getExpanded().add(node.getPath());
- } else {
- ((TreeState) tree.getState()).getExpanded().remove(node.getPath());
- }
- } else {
- node.setExpanded(expanded);
- }
- if (oldExpanded != expanded) {
- new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
+ if (node.isFolder()) {
+ TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ writer.endElement(HtmlElements.DIV);
}
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuRenderer.java Thu Aug 12 14:36:56 2010
@@ -1,5 +1,14 @@
package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.component.UITreeCommand;
+import org.apache.myfaces.tobago.component.UITreeLabel;
+import org.apache.myfaces.tobago.component.UITreeNode;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,4 +28,25 @@ package org.apache.myfaces.tobago.render
public class TreeMenuRenderer extends TreeRenderer {
+ @Override
+ public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
+ super.prepareRender(facesContext, component);
+
+ setRendererTypeForCommandsAndNodes(component);
+ }
+
+ protected void setRendererTypeForCommandsAndNodes(UIComponent component) {
+ for (UIComponent child : component.getChildren()) {
+ if (child instanceof UITreeNode) {
+ child.setRendererType(RendererTypes.TREE_MENU_NODE);
+ }
+ if (child instanceof UITreeCommand) {
+ child.setRendererType(RendererTypes.TREE_MENU_COMMAND);
+ }
+ if (child instanceof UITreeLabel) {
+ child.setRendererType(RendererTypes.TREE_MENU_LABEL);
+ }
+ setRendererTypeForCommandsAndNodes(child);
+ }
+ }
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Thu Aug 12 14:36:56 2010
@@ -18,27 +18,21 @@ package org.apache.myfaces.tobago.render
*/
import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.UITree;
-import org.apache.myfaces.tobago.component.UITreeListbox;
-import org.apache.myfaces.tobago.component.UITreeMenu;
+import org.apache.myfaces.tobago.component.UITreeData;
import org.apache.myfaces.tobago.component.UITreeNode;
-import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.ResourceUtils;
-import org.apache.myfaces.tobago.event.TreeExpansionEvent;
import org.apache.myfaces.tobago.internal.component.AbstractUITree;
-import org.apache.myfaces.tobago.internal.context.ResponseWriterDivider;
-import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterImpl;
-import org.apache.myfaces.tobago.layout.Display;
-import org.apache.myfaces.tobago.layout.Measure;
-import org.apache.myfaces.tobago.model.TreeState;
+import org.apache.myfaces.tobago.internal.component.AbstractUITreeNode;
+import org.apache.myfaces.tobago.internal.util.TreeUtils;
+import org.apache.myfaces.tobago.model.TreeSelectable;
import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.css.Style;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
-import org.apache.myfaces.tobago.renderkit.html.util.CommandRendererHelper;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -82,12 +76,13 @@ public class TreeNodeRenderer extends Co
String id = node.getClientId(facesContext);
// expand state
- boolean expanded = Boolean.parseBoolean((String) requestParameterMap.get(id + "-expanded"));
- setExpanded(node, tree, expanded);
+ boolean expanded
+ = Boolean.parseBoolean((String) requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + "expanded"));
+ TreeUtils.setExpanded(tree, node, expanded);
// select
String searchString;
- if (TreeRenderer.isSelectable(tree)) { // selection
+ if (tree.getSelectableAsEnum() != TreeSelectable.OFF) { // selection
String selected = (String) requestParameterMap.get(treeId + AbstractUITree.SELECT_STATE);
searchString = ";" + nodeStateId + ";";
if (StringUtils.contains(selected, searchString)) {
@@ -96,8 +91,8 @@ public class TreeNodeRenderer extends Co
}
}
- // marker
- String marked = (String) requestParameterMap.get(treeId + AbstractUITree.MARKER);
+ // marked
+ String marked = (String) requestParameterMap.get(treeId + AbstractUITree.MARKED);
if (marked != null) {
searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
node.setMarked(marked.equals(searchString));
@@ -107,78 +102,19 @@ public class TreeNodeRenderer extends Co
}
@Override
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- UITreeNode node = (UITreeNode) component;
- AbstractUITree tree = node.findTree();
- if (tree instanceof UITree || tree instanceof UITreeMenu) {
- encodeBeginMenuAndNormal(facesContext, node, tree, tree instanceof UITreeMenu);
- } else { // if (tree instanceof UITreeListbox)
- encodeBeginListbox(facesContext, node, (UITreeListbox) tree);
- }
- }
-
- public void encodeBeginListbox(FacesContext facesContext, UITreeNode node, UITreeListbox tree) throws IOException {
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
+ super.prepareRender(facesContext, component);
- boolean folder = node.isFolder();
- int level = node.getLevel();
- String id = node.getClientId(facesContext);
- boolean expanded = isExpanded(tree, node);
-
- if (level > 0) { // root will not rendered as an option
- writer.startElement(HtmlElements.OPTION, null);
-// todo: define where to store the selection of a tree, node.getValue() seems not to be a god place.
-// writer.writeAttribute(HtmlAttributes.VALUE, node.getValue().toString(), true); // XXX converter?
- writer.writeIdAttribute(id);
- writer.writeAttribute(HtmlAttributes.SELECTED, expanded);
- writer.writeText("(" + level + ") " + node.getLabel());
- if (folder) {
- writer.writeText(" \u2192");
- }
- writer.endElement(HtmlElements.OPTION);
- }
-
- if (folder) {
- boolean siblingMode = "siblingLeafOnly".equals(tree.getAttributes().get(Attributes.SELECTABLE));
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, TreeListboxRenderer.DIVIDER);
- boolean alreadyExists = divider.activateBranch(facesContext);
- writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- if (!alreadyExists) {
- writer.startElement(HtmlElements.DIV, null);
- writer.writeClassAttribute(Classes.create(tree, "level"));
- Style levelStyle = new Style();
- levelStyle.setLeft(Measure.valueOf(level * 160)); // xxx 160 should be configurable
- writer.writeStyleAttribute(levelStyle);
- // at the start of each div there is an empty and disabled select tag to show empty area.
- // this is not needed for the 1st level.
- if (level > 0) {
- writer.startElement(HtmlElements.SELECT, null);
- writer.writeAttribute(HtmlAttributes.DISABLED, true);
- writer.writeAttribute(HtmlAttributes.SIZE, 2); // must be > 1, but the size comes from the layout
- writer.writeClassAttribute(Classes.create(tree, "select"));
- writer.endElement(HtmlElements.SELECT);
- }
- }
-
- writer.startElement(HtmlElements.SELECT, node);
- writer.writeIdAttribute(id + ComponentUtils.SUB_SEPARATOR + "select");
- writer.writeClassAttribute(Classes.create(tree, "select"));
- if (!expanded) {
- Style selectStyle = new Style();
- selectStyle.setDisplay(Display.NONE);
- }
- writer.writeAttribute(HtmlAttributes.SIZE, 2); // must be > 1, but the size comes from the layout
- writer.writeAttribute(HtmlAttributes.MULTIPLE, siblingMode);
-
-// XXX insert options here
- writer.startElement(HtmlElements.OPTGROUP, null);
- writer.writeAttribute(HtmlAttributes.LABEL, node.getLabel(), true);
- writer.endElement(HtmlElements.OPTGROUP);
+ final UITreeNode node = (UITreeNode) component;
+ if (node.isMarked()) {
+ node.setMarkup(Markup.MARKED.add(node.getMarkup()));
}
}
- public void encodeBeginMenuAndNormal(FacesContext facesContext, UITreeNode node, AbstractUITree tree, boolean isMenu)
- throws IOException {
+ @Override
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ UITreeNode node = (UITreeNode) component;
+ AbstractUITree tree = node.findTree();
final String treeId = tree.getClientId(facesContext);
final boolean folder = node.isFolder();
@@ -188,57 +124,13 @@ public class TreeNodeRenderer extends Co
final boolean hasNextSibling = node.isHasNextSibling();
final List<Boolean> junctions = node.getJunctions();
- final boolean showRoot = tree.isShowRoot();
- final boolean expanded = isExpanded(tree, node) || !showRoot && level == 0;
- final boolean showIcons;
- final boolean showJunctions;
- final boolean showRootJunction;
- if (tree instanceof UITree) {
- showIcons = ((UITree) tree).isShowIcons();
- showJunctions = ((UITree) tree).isShowJunctions();
- showRootJunction = ((UITree) tree).isShowRootJunction();
- } else { // UITreeMenu
- showIcons = false;
- showJunctions = false;
- showRootJunction = false;
- }
+ final boolean showRoot = ((UITree) tree).isShowRoot();
+ final boolean expanded = TreeUtils.isExpanded(tree, node) || !showRoot && level == 0;
if (!showRoot && junctions.size() > 0) {
junctions.remove(0);
}
- String source;
- final String openSource;
- final String closedSource;
-
- final String image = ComponentUtils.getStringAttribute(node, "image");
- if (image != null) { // application image
- closedSource = ResourceManagerUtils.getImageWithPath(facesContext, image);
- } else { // theme image
- closedSource = ResourceManagerUtils.getImageWithPath(facesContext, CLOSED_FOLDER);
- }
- if (folder) {
- if (image != null) { // application image
- openSource = ResourceManagerUtils.getImageWithPath(facesContext,
- ResourceUtils.addPostfixToFilename(image, "open"), true);
- } else { // theme image
- openSource = ResourceManagerUtils.getImageWithPath(facesContext, OPEN_FOLDER);
- }
- source = expanded ? openSource : closedSource;
- } else {
- openSource = null;
- if (image != null) { // application image
- source = ResourceManagerUtils.getImageWithPath(facesContext,
- ResourceUtils.addPostfixToFilename(image, "leaf"), true);
- } else { // theme image
- source = ResourceManagerUtils.getImageWithPath(facesContext, LEAF);
- }
- if (source == null) {
- source = closedSource;
- }
- }
-
- CommandRendererHelper helper = new CommandRendererHelper(facesContext, node, CommandRendererHelper.Tag.ANCHOR);
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (showRoot || level != 0) {
@@ -249,18 +141,7 @@ public class TreeNodeRenderer extends Co
if (!folder) {
HtmlRendererUtils.renderDojoDndItem(node, writer, true);
}
-
- // div class (css)
- String classes;
- classes = Classes.create(node).getStringValue(); // XXX: not nice, menu may use its own renderer
- if (isMenu) {
- classes = classes + " " + Classes.create(node, "menu").getStringValue();
- if (marked) {
- classes = classes + " " + Classes.create(node, "marker").getStringValue(); // TODO: marker as markup
- }
- }
- writer.writeClassAttribute(classes);
-
+ writer.writeClassAttribute(Classes.create(node));
// div style (width)
Style style = new Style(facesContext, tree);
String widthString;
@@ -272,21 +153,19 @@ public class TreeNodeRenderer extends Co
writer.writeStyleAttribute(widthString);
if (folder) {
- encodeExpandedHidden(writer, node, id, expanded);
+ writer.writeAttribute("onclick", "tobagoTreeNodeToggle(this)", false);
}
- if (folder && isMenu) {
- encodeMenuIcon(facesContext, writer, treeId, id, expanded, node);
+ if (folder) {
+ encodeExpandedHidden(writer, node, id, expanded);
}
- encodeIndent(facesContext, writer, node, isMenu, showJunctions, junctions);
-
- encodeTreeJunction(facesContext, writer, node, id, treeId, showJunctions, showRootJunction, showRoot, expanded,
- folder, level, hasNextSibling, openSource, closedSource);
-
- encodeTreeIcons(writer, node, id, treeId, showIcons, folder, source, openSource, closedSource);
-
- encodeLabel(writer, helper, node, marked, treeId);
+ for (UIComponent child : (List<UIComponent>) node.getChildren()) {
+ // encode all content but not the nodes and data.
+ if (!(child instanceof UITreeNode) && !(child instanceof UITreeData)) {
+ RenderUtils.encode(facesContext, child);
+ }
+ }
UIComponent facet = node.getFacet(Facets.ADDENDUM);
if (facet != null) {
@@ -299,190 +178,24 @@ public class TreeNodeRenderer extends Co
if (folder) {
String contentStyle = "display: " + (expanded ? "block" : "none") + ";";
writer.startElement(HtmlElements.DIV, null);
- writer.writeIdAttribute(id + "-cont");
+ writer.writeIdAttribute(id + ComponentUtils.SUB_SEPARATOR + "content");
writer.writeStyleAttribute(contentStyle);
}
}
- private void encodeExpandedHidden(TobagoResponseWriter writer, UITreeNode node, String clientId,
- boolean expanded) throws IOException {
+ private void encodeExpandedHidden(
+ TobagoResponseWriter writer, AbstractUITreeNode node, String clientId, boolean expanded) throws IOException {
writer.startElement(HtmlElements.INPUT, node);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId + "-expanded");
- writer.writeIdAttribute(clientId + "-expanded");
+ writer.writeClassAttribute(Classes.create(node, "expanded", Markup.NULL));
+ writer.writeNameAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "expanded");
writer.writeAttribute(HtmlAttributes.VALUE, Boolean.toString(expanded), false);
writer.endElement(HtmlElements.INPUT);
}
- private void encodeMenuIcon(
- FacesContext facesContext, TobagoResponseWriter writer, String treeId, String id, boolean expanded,
- UIComponent node)
- throws IOException {
- String menuOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuOpen.gif");
- String menuClose = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuClose.gif");
- String onclick = "tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', null, null, '"
- + menuOpen + "', '" + menuClose + "')";
- Object objOnclick = node.getAttributes().get("onclick");
- if (null != objOnclick) {
- onclick += ";" + objOnclick;
- }
- String src = expanded ? menuOpen : menuClose;
- writer.startElement(HtmlElements.IMG, null);
- writer.writeClassAttribute(Classes.create(node, "menuIcon"));
- writer.writeIdAttribute(id + "-menuIcon");
- writer.writeAttribute("src", src, true);
- writer.writeAttribute("onclick", onclick, true);
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlElements.IMG);
- }
-
- private void encodeIndent(
- final FacesContext facesContext, final TobagoResponseWriter writer, final UITreeNode node, final boolean menuMode,
- final boolean showJunctions, final List<Boolean> junctions)
- throws IOException {
-
- String blank = ResourceManagerUtils.getImageWithPath(facesContext, "image/blank.gif");
- String perpendicular = ResourceManagerUtils.getImageWithPath(facesContext, "image/I.gif");
-
- for (Boolean junction : junctions) {
- writer.startElement(HtmlElements.IMG, null);
- writer.writeClassAttribute(Classes.create(node, "junction"));
- if (junction && !menuMode && showJunctions) {
- writer.writeAttribute("src", perpendicular, true);
- } else {
- writer.writeAttribute("src", blank, true);
- }
- writer.endElement(HtmlElements.IMG);
- }
- }
-
- private void encodeTreeJunction(
- FacesContext facesContext, TobagoResponseWriter writer, UITreeNode node, String id, String treeId,
- boolean showJunctions, boolean showRootJunction, boolean showRoot, boolean expanded, boolean folder,
- int level, boolean hasNextSibling, String openSource, String closedSource)
- throws IOException {
- if (!(!showJunctions
- || !showRootJunction && level == 0
- || !showRootJunction && !showRoot && level == 1)) {
- writer.startElement(HtmlElements.IMG, null);
- writer.writeClassAttribute(Classes.create(node, "junction"));
- writer.writeIdAttribute(id + "-junction");
-
- String gif = folder && expanded
- ? (level == 0
- ? "Rminus.gif"
- : (hasNextSibling ? "Tminus.gif" : "Lminus.gif"))
- : ((level == 0)
- ? "Rplus.gif"
- : (hasNextSibling)
- ? (folder ? "Tplus.gif" : "T.gif")
- : (folder ? "Lplus.gif" : "L.gif")
- );
-
- String src = ResourceManagerUtils.getImageWithPath(facesContext, "image/" + gif);
- writer.writeAttribute("src", src, true);
- if (folder) {
- writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
- }
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlElements.IMG);
- }
- }
-
- private void encodeTreeIcons(
- TobagoResponseWriter writer, UITreeNode node, String id, String treeId,
- boolean showIcons, boolean folder, String source, String openSource, String closedSource)
- throws IOException {
-
- if (showIcons) {
- writer.startElement(HtmlElements.IMG, null);
- writer.writeClassAttribute(Classes.create(node, "icon"));
- writer.writeIdAttribute(id + "-icon"); //XXX may not okay with naming conventions
-
- writer.writeAttribute("src", source, true);
- if (folder) {
- writer.writeAttribute("onclick", createOnclickForToggle(treeId, openSource, closedSource), true);
- }
- writer.writeAttribute("alt", "", false);
- writer.endElement(HtmlElements.IMG);
- }
- }
-
- private String createOnclickForToggle(String treeId, String openSouce, String closedSource) {
- if (openSouce == null) { // default
- openSouce = closedSource;
- }
- return "tobagoTreeNodeToggle(this.parentNode, '" + treeId + "', '"
- + openSouce + "', '" + closedSource + "', null, null)";
- }
-
-/*
- if (this.isFolder) {
- str += '<img class="tree-icon" id="' + this.id + '-icon" '
- + 'src="' + (this.expanded ? this.openIcon : this.icon) + ' " '
- + 'onclick="toggle(this.parentNode, \'' + this.treeHiddenId
- + '\', \'' + this.treeResources.getImage("image/treeNode-icon-open.gif")
- + '\', \'' + this.treeResources.getImage("image/treeNode-icon.gif")
- + '\')"'
- + ' alt="">';
- } else {
- str += '<img class="tree-icon" id="' + this.id
- + '-icon" src="' + this.treeResources.getImage("image/treeNode-icon-leaf.gif") + '" alt="">';
- }
-*/
-
- private void encodeLabel(
- TobagoResponseWriter writer, CommandRendererHelper helper, UITreeNode node, boolean marked, String treeId)
- throws IOException {
-
- writer.startElement(HtmlElements.A, null);
- if (!helper.isDisabled()) {
- writer.writeAttribute(HtmlAttributes.HREF, helper.getHref(), true);
- writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true); // xxx is escaping required?
- writer.writeAttribute(
- HtmlAttributes.ONFOCUS, "Tobago.Tree.storeMarker(this.parentNode, '" + treeId + "')", false);
- if (helper.getTarget() != null) {
- writer.writeAttribute(HtmlAttributes.TARGET, helper.getTarget(), true);
- }
- }
- if (marked) {
- writer.writeClassAttribute(Classes.create(node, "marker"));
- }
- String tip = node.getTip();
- if (tip != null) {
- writer.writeAttribute(HtmlAttributes.TITLE, tip, true);
- }
- String label = node.getLabel();
- if (label == null) {
- label = "";
- }
- writer.writeText(label);
- writer.endElement(HtmlElements.A);
- }
-
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UITreeNode node = (UITreeNode) component;
- AbstractUITree tree = node.findTree();
- if (tree instanceof UITree || tree instanceof UITreeMenu) {
- encodeEndMenuAndNormal(facesContext, node);
- } else { // if (tree instanceof UITreeListbox)
- encodeEndListbox(facesContext, node);
- }
- }
-
- protected void encodeEndListbox(FacesContext facesContext, UITreeNode node) throws IOException {
- boolean folder = node.isFolder();
- if (folder) {
- TobagoResponseWriterImpl writer
- = (TobagoResponseWriterImpl) HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- writer.endElement(HtmlElements.SELECT);
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, TreeListboxRenderer.DIVIDER);
- divider.passivateBranch(facesContext);
- }
- }
-
- protected void encodeEndMenuAndNormal(FacesContext facesContext, UITreeNode node) throws IOException {
boolean folder = node.isFolder();
String id = node.getClientId(facesContext);
@@ -491,33 +204,6 @@ public class TreeNodeRenderer extends Co
if (folder) {
writer.endElement(HtmlElements.DIV);
- writer.writeComment("\nend of " + id + "-cont ");
- }
- }
-
- private boolean isExpanded(AbstractUITree tree, UITreeNode node) {
- TreeState state = (TreeState) tree.getState();
- if (state != null) {
- return state.getExpanded().contains(node.getPath());
- } else {
- return node.isExpanded();
- }
- }
-
- private void setExpanded(UITreeNode node, AbstractUITree tree, boolean expanded) {
- boolean oldExpanded = isExpanded(tree, node);
-
- if (tree.getState() != null) {
- if (expanded) {
- ((TreeState) tree.getState()).getExpanded().add(node.getPath());
- } else {
- ((TreeState) tree.getState()).getExpanded().remove(node.getPath());
- }
- } else {
- node.setExpanded(expanded);
- }
- if (oldExpanded != expanded) {
- new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
}
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java Thu Aug 12 14:36:56 2010
@@ -17,9 +17,10 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
+import org.apache.myfaces.tobago.component.UITreeData;
+import org.apache.myfaces.tobago.component.UITreeNode;
import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.internal.component.AbstractUITree;
-import org.apache.myfaces.tobago.internal.util.FastStringWriter;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -32,8 +33,8 @@ import org.apache.myfaces.tobago.webapp.
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import java.io.IOException;
+import java.util.Arrays;
public class TreeRenderer extends LayoutComponentRendererBase {
@@ -57,10 +58,6 @@ public class TreeRenderer extends Layout
tree.setValid(true);
}
- public static boolean isSelectable(AbstractUITree tree) {
- return tree.isSelectableTree();
- }
-
@Override
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
// will be rendered in encodeEnd()
@@ -90,12 +87,13 @@ public class TreeRenderer extends Layout
writer.startElement(HtmlElements.INPUT, tree);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId + AbstractUITree.MARKER);
- writer.writeIdAttribute(clientId + AbstractUITree.MARKER);
+ writer.writeNameAttribute(clientId + AbstractUITree.MARKED);
+ writer.writeIdAttribute(clientId + AbstractUITree.MARKED);
writer.writeAttribute(HtmlAttributes.VALUE, "", false);
writer.endElement(HtmlElements.INPUT);
- if (isSelectable(tree)) {
+/*
+ if (tree.getSelectableAsEnum().isSupportedByTree()) {
writer.startElement(HtmlElements.INPUT, tree);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
writer.writeNameAttribute(clientId + AbstractUITree.SELECT_STATE);
@@ -103,28 +101,12 @@ public class TreeRenderer extends Layout
writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
writer.endElement(HtmlElements.INPUT);
}
+*/
HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPT);
- RenderUtils.encode(facesContext, root);
+ RenderUtils.encode(facesContext, root, Arrays.asList(UITreeNode.class, UITreeData.class));
writer.endElement(HtmlElements.DIV);
}
-
- // XXX can be removed?
- protected String getNodesAsJavascript(FacesContext facesContext, UIComponent root) throws IOException {
- ResponseWriter writer = facesContext.getResponseWriter();
- FastStringWriter stringWriter = new FastStringWriter();
- facesContext.setResponseWriter(writer.cloneWithWriter(stringWriter));
- RenderUtils.encode(facesContext, root);
- facesContext.setResponseWriter(writer);
- return stringWriter.toString();
- }
-
- // XXX can be removed?
- protected String nodeStateId(FacesContext facesContext, UIComponent node) {
- String clientId = node.getClientId(facesContext);
- int last = clientId.lastIndexOf(':') + 1;
- return clientId.substring(last);
- }
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties Thu Aug 12 14:36:56 2010
@@ -259,3 +259,6 @@ TabGroupToolBar.custom.padding-left=0
TabGroupToolBar.custom.padding-center=0
TabGroupToolBar.custom.padding-right=0
TabGroupToolBar.custom.label-height=14
+
+TreeMenuCommand.custom.padding-left=20
+TreeMenuLabel.custom.padding-left=20
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Thu Aug 12 14:36:56 2010
@@ -510,7 +510,8 @@ iframe.tobago-menu-ie6bugfix {
.tobago-page {
background: #bbccdd;
- font-family: arial, helvetica, sans-serif; /* font-size: 14px;*/
+ font-family: arial, helvetica, sans-serif;
+ font-size: 14px;
padding: 0;
margin: 0;
width: 100%;
@@ -1245,13 +1246,12 @@ div.tobago-tabGroup-toolBar {
position: absolute;
}
-/* Tree ------------------------------------------------------------------- */
+/* tree ------------------------------------------------------------------- */
.tobago-tree {
overflow: auto;
padding: 0;
margin: 0;
- font: icon;
color: black;
white-space: nowrap;
}
@@ -1296,16 +1296,81 @@ div.tobago-tabGroup-toolBar {
font-weight: bold;
}
+.tobago-treeNode-toggle {
+ width: 16px;
+ height: 16px;
+}
+
+ /*XXX remove? */
.tobago-treeNode-icon {
width: 16px;
height: 16px;
}
+ /*XXX remove? */
.tobago-treeNode-junction {
width: 19px;
height: 16px;
}
+/* treeMenu ------------------------------------------------------------------- */
+
+.tobago-treeMenu {
+ overflow: auto;
+ padding: 0;
+ margin: 0;
+ color: black;
+ white-space: nowrap;
+}
+
+.tobago-treeMenuNode {
+ border: 1px solid #d8e9fb;
+ height: 18px;
+ margin: 0 0 -1px 0;
+}
+
+.tobago-treeMenuNode-toggle {
+ vertical-align: middle;
+ border: 0;
+ float: right;
+}
+
+.tobago-treeMenuNode a, .tobago-treeMenuNode a:active, .tobago-treeMenuNode a:hover {
+ padding: 1px 2px 1px 2px;
+}
+
+.tobago-treeMenuNode a {
+ color: black;
+ text-decoration: none;
+ display: block;
+ left:0;
+}
+
+.tobago-treeMenuNode a:hover {
+ text-decoration: underline;
+}
+
+.tobago-treeMenuNode a:focus {
+ background: #445566;
+ color: highlighttext;
+ text-decoration: none;
+}
+
+.tobago-treeMenuNode-markup-disabled a, .tobago-treeMenuNode-markup-disabled a:hover {
+ color: #888888;
+ text-decoration: none;
+ cursor: default;
+}
+
+.tobago-treeMenuNode-markup-marked, .tobago-treeMenuNode-markup-marked:focus,
+.tobago-treeMenuNode-markup-marked a, .tobago-treeMenuNode-markup-marked:focus a {
+ background-color: #d8e9fb;
+}
+
+.tobago-treeMenuNode-markup-strong {
+ font-weight: bold;
+}
+
/* treeListbox ------------------------------------------------------------------- */
.tobago-treeListbox {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties Thu Aug 12 14:36:56 2010
@@ -144,3 +144,6 @@ BoxToolBar.css.border-left-width=1
BoxToolBar.css.border-top-width=1
BoxToolBar.css.border-right-width=1
BoxToolBar.css.border-bottom-width=1
+
+TreeMenuCommand.custom.padding-left=15
+TreeMenuLabel.custom.padding-left=15
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css Thu Aug 12 14:36:56 2010
@@ -720,13 +720,7 @@ div.tobago-tabGroup-toolBar {
/* tree ------------------------------------------------------------------- */
-.tobago-treeNode-menu {
- border: 1px solid #CCCCCC;
- width: 200px; /* default */
- height: 16px;
-}
-
-.tobago-treeNode-menuIcon {
+.tobago-treeNode-icon {
width: 16px;
height: 16px;
float: right;
@@ -737,11 +731,13 @@ div.tobago-tabGroup-toolBar {
border: 0px;
}
+/*
.tobago-treeNode a {
font-size: 12px;
font-family: arial, helvetica, sans-serif;
}
+*/
.tobago-treeNode-disabled a {
color: #888888;
text-decoration: none;
@@ -765,3 +761,10 @@ div.tobago-tabGroup-toolBar {
.tobago-treeNode-marker, .tobago-treeNode-marker:focus, .tobago-treeNode-marker a, .tobago-treeNode-marker:focus a {
background-color: #d3d3d3;
}
+
+/* treeMenu ------------------------------------------------------------------- */
+
+.tobago-treeMenuNode {
+ border: 1px solid #888888;
+ height: 16px;
+}
Copied: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java (from r953990, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java?p2=myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java&r1=953990&r2=984805&rev=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java Thu Aug 12 14:36:56 2010
@@ -18,9 +18,9 @@ package org.apache.myfaces.tobago.render
*/
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.myfaces.tobago.util.ComponentUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -46,10 +46,14 @@ public abstract class CommandRendererBas
if (LOG.isDebugEnabled()) {
LOG.debug("queueEvent = '" + actionId + "'");
}
- component.queueEvent(new ActionEvent(component));
+ commandActivated(component);
}
}
+ protected void commandActivated(UIComponent component) {
+ component.queueEvent(new ActionEvent(component));
+ }
+
public String getImageWithPath(FacesContext facesContext, String image, boolean disabled) {
String imageWithPath = null;
if (disabled) {
Propchange: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java Thu Aug 12 14:36:56 2010
@@ -21,12 +21,10 @@ import org.apache.commons.lang.StringUti
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.UIPopup;
-import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.event.PopupFacetActionListener;
import org.apache.myfaces.tobago.internal.component.UICommandBase;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.VariableResolverUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,13 +59,12 @@ public class CommandRendererHelper {
private void initOnclick(FacesContext facesContext, UICommandBase command, Tag tag) {
disabled = ComponentUtils.getBooleanAttribute(command, Attributes.DISABLED);
- href = getEmptyHref(facesContext);
if (disabled) {
onclick = "";
href = "";
} else {
-
+ href = "#"; // this is to make the link "active", needed for focus, cursor, etc.
UIPopup popup = (UIPopup) command.getFacet(Facets.POPUP);
if (popup != null) {
if (!ComponentUtils.containsPopupActionListener(command)) {
@@ -138,11 +135,6 @@ public class CommandRendererHelper {
}
}
- private String getEmptyHref(FacesContext facesContext) {
- ClientProperties clientProperties = VariableResolverUtils.resolveClientProperties(facesContext);
- return clientProperties.getUserAgent().isMsie() ? "#" : "javascript:;";
- }
-
private String prepareOnClick(FacesContext facesContext, UIComponent component) {
String onclick;
onclick = (String) component.getAttributes().get(Attributes.ONCLICK);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-theme.xml Thu Aug 12 14:36:56 2010
@@ -255,6 +255,14 @@
<name>TreeNode</name>
<supported-markup>
<markup>strong</markup>
+ <markup>marked</markup>
+ </supported-markup>
+ </renderer>
+ <renderer>
+ <name>TreeMenuNode</name>
+ <supported-markup>
+ <markup>strong</markup>
+ <markup>marked</markup>
</supported-markup>
</renderer>
</renderers>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-tree.js Thu Aug 12 14:36:56 2010
@@ -54,62 +54,45 @@ Tobago.Tree.updateMarker = function(node
while (node) {
if (node.className && node.className.indexOf("tobago-treeNode") > -1) {
if (add) {
- Tobago.addCssClass(node, "tobago-treeNode-marker");
+ Tobago.addCssClass(node, "tobago-treeNode-markup-marked");
} else {
- Tobago.removeCssClass(node, "tobago-treeNode-marker");
+ Tobago.removeCssClass(node, "tobago-treeNode-markup-marked");
}
}
node = node.nextSibling;
}
}
-}
+};
Tobago.Tree.storeMarker = function(node, treeHiddenId) {
- var markerHidden = document.getElementById(treeHiddenId + '-marker');
+ var markerHidden = document.getElementById(treeHiddenId + '-marked');
if (markerHidden) {
Tobago.Tree.updateMarker(markerHidden.value, false);
markerHidden.value = node.id;
}
Tobago.Tree.updateMarker(node.id, true);
-}
+};
-function tobagoTreeNodeToggle(node, treeHiddenId, openFolderIcon, folderIcon, openMenuIcon, closeMenuIcon) {
- LOG.debug("toggle(" + node + ", " + treeHiddenId + ", " + openFolderIcon + ", " + folderIcon + ", "
- + openMenuIcon + ", " + closeMenuIcon + ")");
- var content = document.getElementById(node.id + "-cont");
- if (content) {
- var expandedState = document.getElementById(node.id + '-expanded');
- var icon = document.getElementById(node.id + '-icon');
- var menuIcon = document.getElementById(node.id + '-menuIcon');
- var junction = document.getElementById(node.id + '-junction');
- var hidden = document.getElementById(treeHiddenId);
- if (content.style.display == 'none') {
- content.style.display = 'block';
- if (icon) {
- icon.src = openFolderIcon;
- }
- if (menuIcon) {
- menuIcon.src = openMenuIcon;
- }
- if (junction) {
- junction.src = junction.src.replace(/plus\./, "minus.");
- }
- hidden.value = hidden.value + nodeStateId(node) + ";";
- expandedState.value = "true";
- } else {
- content.style.display = 'none';
- if (icon) {
- icon.src = folderIcon;
- }
- if (menuIcon) {
- menuIcon.src = closeMenuIcon;
- }
- if (junction) {
- junction.src = junction.src.replace(/minus\./, "plus.");
- }
- hidden.value = hidden.value.replace(";" + nodeStateId(node) + ";", ";");
- expandedState.value = "false";
- }
+function tobagoTreeNodeToggle(element) {
+ var node = jQuery(element);
+ var content = jQuery(Tobago.escapeClientId(element.id + Tobago.SUB_COMPONENT_SEP + "content"));
+ var expanded = node.find(".tobago-treeMenuNode-expanded, .tobago-treeNode-expanded");
+ var toggle = node.find(".tobago-treeMenuNode-toggle, .tobago-treeNode-toggle");
+ if (content.css("display") == "none") {
+ content.css("display", "block");
+ toggle.each(function() {
+ jQuery(this).attr("src", jQuery(this).attr("srcopen"));
+ Tobago.fixPngAlpha(this);
+ });
+ expanded.attr("value", "true");
+ } else {
+ content.css("display", "none");
+ toggle.each(function() {
+ jQuery(this).attr("src", jQuery(this).attr("srcclose"));
+ debugger;
+ Tobago.fixPngAlpha(this);
+ });
+ expanded.attr("value", "false");
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/style.css?rev=984805&r1=984804&r2=984805&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/style.css Thu Aug 12 14:36:56 2010
@@ -45,3 +45,4 @@ html, body {
text-decoration: none;
color: black;
}
+