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 2012/01/03 17:13:03 UTC
svn commit: r1226847 [1/2] - in /myfaces/tobago/branches/tobago-tree-table:
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/myfa...
Author: lofwyr
Date: Tue Jan 3 16:13:02 2012
New Revision: 1226847
URL: http://svn.apache.org/viewvc?rev=1226847&view=rev
Log:
TOBAGO-1049: Tree inside of the Sheet (aka TreeTable)
- refactoring: using same model for normal trees and trees in sheets
Added:
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/Expanded.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/TemporaryTreeState.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeDataModel.java
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml
- copied, changed from r1199440, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple-with-data.xhtml
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple.xhtml
- copied, changed from r1220715, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml
Modified:
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/component/TreeModelBuilder.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITree.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeData.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeDataTagDeclaration.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeListboxTagDeclaration.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeMenuTagDeclaration.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeTagDeclaration.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/DefaultMutableTreeNodeAnalyser.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/MixedTreeModel.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Node.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeAnalyser.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreePath.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TreeController.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/component/TreeModelBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/component/TreeModelBuilder.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/component/TreeModelBuilder.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/component/TreeModelBuilder.java Tue Jan 3 16:13:02 2012
@@ -21,10 +21,28 @@ import org.apache.myfaces.tobago.model.M
import javax.faces.context.FacesContext;
+/**
+ * @deprecated since XXX 1.6.0 ???
+ */
+@Deprecated
public interface TreeModelBuilder {
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
void buildTreeModelBegin(FacesContext facesContext, MixedTreeModel model);
+
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
void buildTreeModelChildren(FacesContext facesContext, MixedTreeModel model);
+
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
void buildTreeModelEnd(FacesContext facesContext, MixedTreeModel model);
}
Added: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java Tue Jan 3 16:13:02 2012
@@ -0,0 +1,85 @@
+package org.apache.myfaces.tobago.internal.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.internal.model.TemporaryTreeState;
+import org.apache.myfaces.tobago.model.TreeDataModel;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.io.IOException;
+
+public class AbstractUIData extends javax.faces.component.UIData {
+
+ /**
+ * Only for tree model.
+ */
+ private boolean initialized;
+
+ /**
+ * Only for tree model.
+ */
+ private DataModel dataModel;
+
+ /**
+ * Only for tree model.
+ * Caches the expanded state information and the path of the nodes,
+ * to make these information available in child nodes.
+ */
+ private TemporaryTreeState temporaryTreeState;
+
+ // XXX Is there a better possibility to support tree data models?
+ @Override
+ protected DataModel getDataModel() {
+ if (!initialized) {
+ Object value = getValue();
+
+ if (value instanceof DefaultMutableTreeNode) {
+ dataModel = new TreeDataModel((DefaultMutableTreeNode) value);
+ }
+ initialized = true;
+ }
+
+ if (dataModel != null) {
+ return dataModel;
+ } else {
+ return super.getDataModel();
+ }
+ }
+
+ public boolean hasRows() {
+ return getRows() != 0;
+ }
+
+ public TemporaryTreeState getTemporaryTreeState() {
+ return temporaryTreeState;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException {
+ temporaryTreeState = new TemporaryTreeState();
+ super.encodeBegin(context);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException {
+ super.encodeEnd(context);
+ temporaryTreeState = null;
+ }
+}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java Tue Jan 3 16:13:02 2012
@@ -39,6 +39,7 @@ import org.apache.myfaces.tobago.layout.
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.model.SheetState;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.apache.myfaces.tobago.util.CreateComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,9 +59,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-public abstract class AbstractUISheet extends javax.faces.component.UIData
+public abstract class AbstractUISheet extends AbstractUIData
implements SheetStateChangeSource, SortActionSource, InvokeOnComponent, OnComponentPopulated,
- LayoutContainer, LayoutComponent, SupportsRenderedPartially{
+ LayoutContainer, LayoutComponent, SupportsRenderedPartially {
private static final Logger LOG = LoggerFactory.getLogger(AbstractUISheet.class);
@@ -204,10 +205,6 @@ public abstract class AbstractUISheet ex
return getRowCount() != -1;
}
- public boolean hasRows() {
- return getRows() != 0;
- }
-
public boolean isPagingVisible() {
return isShowPagingAlways() || hasRows() && (!hasRowCount() || getRowCount() > getRows());
}
@@ -276,8 +273,8 @@ public abstract class AbstractUISheet ex
public List<UIColumn> getAllColumns() {
List<UIColumn> columns = new ArrayList<UIColumn>();
- for (UIComponent kid : (List<UIComponent>) getChildren()) {
- if (kid instanceof UIColumn && !(kid instanceof ColumnEvent)) {
+ for (UIComponent kid : (List<UIComponent>) ComponentUtils.findDescendantList(this, UIColumn.class)) {
+ if (!(kid instanceof ColumnEvent)) {
columns.add((UIColumn) kid);
}
}
@@ -286,8 +283,8 @@ public abstract class AbstractUISheet ex
public List<UIColumn> getRenderedColumns() {
List<UIColumn> columns = new ArrayList<UIColumn>();
- for (UIComponent kid : (List<UIComponent>) getChildren()) {
- if (kid instanceof UIColumn && kid.isRendered() && !(kid instanceof ColumnEvent)) {
+ for (UIComponent kid : (List<UIComponent>) ComponentUtils.findDescendantList(this, UIColumn.class)) {
+ if (kid.isRendered() && !(kid instanceof ColumnEvent)) {
columns.add((UIColumn) kid);
}
}
@@ -563,7 +560,7 @@ public abstract class AbstractUISheet ex
facesContext, ComponentTypes.SHEET_LAYOUT, RendererTypes.SHEET_LAYOUT, parent));
}
}
-
+
public LayoutManager getLayoutManager() {
return (LayoutManager) getFacet(Facets.LAYOUT);
}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITree.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITree.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITree.java Tue Jan 3 16:13:02 2012
@@ -17,26 +17,25 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.TreeModelBuilder;
+import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.model.MixedTreeModel;
import org.apache.myfaces.tobago.model.TreeSelectable;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import javax.faces.application.FacesMessage;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
-public abstract class AbstractUITree extends javax.faces.component.UIInput implements NamingContainer, LayoutComponent {
+public abstract class AbstractUITree extends AbstractUIData
+// extends javax.faces.component.UIInput
+ implements NamingContainer, LayoutComponent {
+
+ private static final Log LOG = LogFactory.getLog(AbstractUITree.class);
public static final String MESSAGE_NOT_LEAF = "tobago.tree.MESSAGE_NOT_LEAF";
@@ -45,11 +44,38 @@ public abstract class AbstractUITree ext
public static final String SELECT_STATE = SEP + "selectState";
public static final String MARKED = "marked";
- private MixedTreeModel model;
+ @Override
+ public void processValidators(FacesContext facesContext) {
+ final int last = hasRows() ? getFirst() + getRows() : Integer.MAX_VALUE;
+ for (int rowIndex = getFirst(); rowIndex < last; rowIndex++) {
+ setRowIndex(rowIndex);
+ if (!isRowAvailable()) {
+ break;
+ }
+ for (UIComponent child : getChildren()) {
+ child.processValidators(facesContext);
+ }
+ }
+ }
- // XXX may be removed
- private Set<String> expandedCache;
+ @Override
+ public void processUpdates(FacesContext facesContext) {
+ final int last = hasRows() ? getFirst() + getRows() : Integer.MAX_VALUE;
+ for (int rowIndex = getFirst(); rowIndex < last; rowIndex++) {
+ setRowIndex(rowIndex);
+ if (!isRowAvailable()) {
+ break;
+ }
+ for (UIComponent child : getChildren()) {
+ child.processUpdates(facesContext);
+ }
+ }
+ }
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public UIComponent getRoot() {
// find the UITreeNode in the children.
for (UIComponent child : (List<UIComponent>) getChildren()) {
@@ -63,31 +89,13 @@ public abstract class AbstractUITree ext
return null;
}
- @Override
- public void encodeEnd(FacesContext facesContext) throws IOException {
- model = new MixedTreeModel();
- expandedCache = new HashSet<String>();
- for (Object child : getChildren()) {
- if (child instanceof TreeModelBuilder) {
- TreeModelBuilder builder = (TreeModelBuilder) child;
- builder.buildTreeModelBegin(facesContext, model);
- builder.buildTreeModelChildren(facesContext, model);
- builder.buildTreeModelEnd(facesContext, model);
- }
- }
-
- super.encodeEnd(facesContext);
-
- model = null;
- expandedCache = null;
- }
-
+ /**
+ * @deprecated Since 1.5.0.
+ */
+ @Deprecated
public MixedTreeModel getModel() {
- return model;
- }
-
- public Set<String> getExpandedCache() {
- return expandedCache;
+ Deprecation.LOG.error("Doesn't work anymore.");
+ return null;
}
@Override
@@ -102,6 +110,7 @@ public abstract class AbstractUITree ext
return TreeSelectable.parse(ComponentUtils.getStringAttribute(this, Attributes.SELECTABLE));
}
+/*
@Override
public void processDecodes(FacesContext facesContext) {
@@ -110,7 +119,7 @@ public abstract class AbstractUITree ext
}
if (ComponentUtils.isOutputOnly(this)) {
- setValid(true);
+// XXX setValid(true);
} else {
// in tree first decode node and than decode children
@@ -122,9 +131,12 @@ public abstract class AbstractUITree ext
}
}
}
+*/
+/* XXX
@Override
public void validate(FacesContext context) {
+*/
// todo: validate must be written new, without TreeState
/*
@@ -151,6 +163,7 @@ public abstract class AbstractUITree ext
}
*/
// call all validators
+/*
if (getValidators() != null) {
for (Validator validator : getValidators()) {
try {
@@ -174,6 +187,7 @@ public abstract class AbstractUITree ext
// nothing to update for tree's
// TODO: updating the model here and *NOT* in the decode phase
}
+*/
public abstract Object getState();
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeData.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeData.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeData.java Tue Jan 3 16:13:02 2012
@@ -17,473 +17,72 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.component.OnComponentCreated;
import org.apache.myfaces.tobago.component.TreeModelBuilder;
+import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.model.MixedTreeModel;
-import org.apache.myfaces.tobago.model.Node;
-import org.apache.myfaces.tobago.model.TreePath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import javax.faces.FacesException;
-import javax.faces.component.ContextCallback;
+import javax.el.ValueExpression;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-import javax.swing.tree.DefaultMutableTreeNode;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+/**
+ * @deprecated since XXX 1.6.0 ???
+ */
+@Deprecated
public abstract class AbstractUITreeData extends javax.faces.component.UIInput
- implements NamingContainer, TreeModelBuilder {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractUITreeData.class);
+ implements NamingContainer, TreeModelBuilder, OnComponentCreated {
public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeData";
- private String var;
-
- private DefaultMutableTreeNode currentNode;
-
- private TreePath rowIndex;
-
- // XXX hack: fix this if there is a Listener
- private Object marked;
-
- // Holds for each node the states of the child components of this UITreeData.
- private Map<TreePath, Object> pathStates = new HashMap<TreePath, Object>();
-
- @Override
- public void processDecodes(FacesContext facesContext) {
-
- decodeNodes(facesContext, (DefaultMutableTreeNode) getValue(), new TreePath(0));
- }
-
- private void decodeNodes(FacesContext facesContext, DefaultMutableTreeNode node, TreePath position) {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (decode) = '" + position + "'");
- AbstractUITreeNode templateComponent = getTemplateComponent();
- templateComponent.processDecodes(facesContext);
- setRowIndex(facesContext, null);
-
- // XXX hack: fix this if there is a Listener
- if (templateComponent.isMarked()) {
- marked = templateComponent.getValue();
- }
-
- int index = 0;
- for (Enumeration e = node.children(); e.hasMoreElements();) {
- DefaultMutableTreeNode sub = (DefaultMutableTreeNode) e.nextElement();
- decodeNodes(facesContext, sub, new TreePath(position, index));
- index++;
- }
- }
-
- @Override
- public void decode(FacesContext facesContext) {
-
- }
-
- @Override
- public void processValidators(FacesContext facesContext) {
- validateNodes(facesContext, (DefaultMutableTreeNode) getValue(), new TreePath(0));
- }
-
- private void validateNodes(FacesContext facesContext, DefaultMutableTreeNode node, TreePath position) {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (validate) = '" + position + "'");
- AbstractUITreeNode templateComponent = getTemplateComponent();
- templateComponent.processValidators(facesContext);
- setRowIndex(facesContext, null);
-
- int index = 0;
- for (Enumeration e = node.children(); e.hasMoreElements();) {
- DefaultMutableTreeNode sub = (DefaultMutableTreeNode) e.nextElement();
- validateNodes(facesContext, sub, new TreePath(position, index));
- index++;
- }
- }
-
- @Override
- public void processUpdates(FacesContext facesContext) {
- updateNodes(facesContext, (DefaultMutableTreeNode) getValue(), new TreePath(0));
- }
-
- private void updateNodes(FacesContext facesContext, DefaultMutableTreeNode node, TreePath position) {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (update) = '" + position + "'");
- AbstractUITreeNode templateComponent = getTemplateComponent();
- templateComponent.processUpdates(facesContext);
- setRowIndex(facesContext, null);
-
- int index = 0;
- for (Enumeration e = node.children(); e.hasMoreElements();) {
- DefaultMutableTreeNode sub = (DefaultMutableTreeNode) e.nextElement();
- updateNodes(facesContext, sub, new TreePath(position, index));
- index++;
- }
- }
-
- public TreePath getRowIndex() {
- return rowIndex;
- }
-
- private void setRowIndex(FacesContext facesContext, TreePath rowIndex) {
-
- if (ObjectUtils.equals(this.rowIndex, rowIndex)) {
- return; // nothing to do, if already set.
- }
-
- AbstractUITreeNode template = getTemplateComponent();
- pathStates.put(this.rowIndex, saveStateDeep(facesContext, template));
- if (LOG.isDebugEnabled()) {
- LOG.debug("save " + this.rowIndex + " ex=" + template.isExpanded());
- }
-
- this.rowIndex = rowIndex;
- if (rowIndex != null) {
- DefaultMutableTreeNode model = (DefaultMutableTreeNode) getValue();
- currentNode = rowIndex.getNode(model);
- facesContext.getExternalContext().getRequestMap().put(var, currentNode);
- } else {
- FacesContext.getCurrentInstance().getExternalContext().getRequestMap().remove(var);
- currentNode = null;
+ /**
+ * Patch for backward compatibility.
+ */
+ public void onComponentCreated(FacesContext facesContext, UIComponent parent) {
+ if (parent instanceof AbstractUITree) {
+ ValueExpression ve = getValueExpression("var");
+ if (ve != null) {
+ parent.setValueExpression("var", ve);
+ } else {
+ ((AbstractUITree)parent).setVar(getVar());
+ }
}
- Object state = pathStates.get(this.rowIndex);
- if (state != null) {
- restoreStateDeep(facesContext, template, state);
- if (LOG.isDebugEnabled()) {
- LOG.debug("restore " + this.rowIndex + " ex=" + template.isExpanded());
+ if (parent instanceof AbstractUITree) {
+ ValueExpression ve = getValueExpression("value");
+ if (ve != null) {
+ parent.setValueExpression("value", ve);
+ } else {
+ ((AbstractUITree)parent).setValue(getValue());
}
}
}
- /**
- * Restores the state of the component and the state of all facets and children from the state object.
- */
- private void restoreStateDeep(FacesContext facesContext, UIComponent template, Object stateObject) {
- final List<Object> state = (List<Object>) stateObject;
- int i = 0;
- template.restoreState(facesContext, state.get(i++));
-
- // reset the client id (see spec 3.1.6)
- template.setId(template.getId());
-
- final Iterator<UIComponent> facetsAndChildren = template.getFacetsAndChildren();
- while (facetsAndChildren.hasNext()) {
- UIComponent component = (UIComponent) facetsAndChildren.next();
- restoreStateDeep(facesContext, component, state.get(i++));
- }
- }
+ public abstract String getVar();
/**
- * Put the state of the component and the state of all facets and children into a object.
+ * @deprecated since XXX 1.6.0 ???
*/
- private Object saveStateDeep(FacesContext facesContext, UIComponent template) {
- final List<Object> state = new ArrayList<Object>();
- state.add(template.saveState(facesContext));
-
- final Iterator<UIComponent> facetsAndChildren = template.getFacetsAndChildren();
- while (facetsAndChildren.hasNext()) {
- UIComponent component = (UIComponent) facetsAndChildren.next();
- state.add(saveStateDeep(facesContext, component));
- }
- return state;
- }
-/*
- public void buildTreeModel(MixedTreeModel model) {
- model.beginBuildNodeData(this);
- // childred are not needed to add here
- model.endBuildNodeData(this);
- }
- */
-
+ @Deprecated
public void buildTreeModelBegin(FacesContext facesContext, MixedTreeModel model) {
- Object data = getValue();
- if (data instanceof Node) {
- buildTreeModelNodes(facesContext, model, (Node) data, new TreePath(0));
- } else if (data instanceof DefaultMutableTreeNode) {
- buildTreeModelNodes(facesContext, model, (DefaultMutableTreeNode) data, new TreePath(0));
- }
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public void buildTreeModelChildren(FacesContext facesContext, MixedTreeModel model) {
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public void buildTreeModelEnd(FacesContext facesContext, MixedTreeModel model) {
+ Deprecation.LOG.error("Doesn't work anymore.");
}
- public void buildTreeModelNodes(
- FacesContext facesContext, MixedTreeModel model, Node node, TreePath position) {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (build) node = '" + position + "'");
-
- getTemplateComponent().buildTreeModelBegin(facesContext, model);
-
- int index = 0;
- for (Node sub : node.getChildren()) {
- buildTreeModelNodes(facesContext, model, sub, new TreePath(position, index));
- index++;
- }
-
- getTemplateComponent().buildTreeModelEnd(facesContext, model);
-
- setRowIndex(facesContext, null);
- }
-
- public void buildTreeModelNodes(
- FacesContext facesContext, MixedTreeModel model, DefaultMutableTreeNode node, TreePath position) {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (build) dmtn = '" + position + "'");
-
- getTemplateComponent().buildTreeModelBegin(facesContext, model);
-
- int index = 0;
- for (Enumeration e = node.children(); e.hasMoreElements();) {
- DefaultMutableTreeNode sub = (DefaultMutableTreeNode) e.nextElement();
- buildTreeModelNodes(facesContext, model, sub, new TreePath(position, index));
- index++;
- }
-
- getTemplateComponent().buildTreeModelEnd(facesContext, model);
-
- setRowIndex(facesContext, null);
- }
-
- @Override
- public void encodeChildren(FacesContext context) throws IOException {
- }
-
- @Override
- public void encodeEnd(FacesContext facesContext) throws IOException {
- encodeNodes(facesContext, (DefaultMutableTreeNode) getValue(), new TreePath(0));
- super.encodeEnd(facesContext);
- }
-
- private void encodeNodes(FacesContext facesContext, DefaultMutableTreeNode node, TreePath position)
- throws IOException {
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (begin) = '" + position + "'");
- final AbstractUITreeNode template = getTemplateComponent();
- super.encodeBegin(facesContext); // XXX hack!
- // template.getRenderer().pre
- template.encodeBegin(facesContext);
- setRowIndex(facesContext, null);
-
- int index = 0;
- for (Enumeration e = node.children(); e.hasMoreElements();) {
- DefaultMutableTreeNode sub = (DefaultMutableTreeNode) e.nextElement();
- encodeNodes(facesContext, sub, new TreePath(position, index));
- index++;
- }
-
- setRowIndex(facesContext, position);
- LOG.debug("path index (end) = '" + position + "'");
- getTemplateComponent().encodeEnd(facesContext);
- setRowIndex(facesContext, null);
- }
-
- @Override
- public boolean getRendersChildren() {
- return true;
- }
-
- @Override
- public void updateModel(FacesContext facesContext) {
- // nothing to update for tree's
- // TODO: updating the model here and *NOT* in the decode phase
- }
-
- public AbstractUITreeNode getTemplateComponent() {
- for (Object child : getChildren()) {
- if (child instanceof AbstractUITreeNode) {
- return (AbstractUITreeNode) child;
- }
- }
- return null;
- }
-
- @Override
- public String getClientId(FacesContext context) {
- String clientId = super.getClientId(context);
- if (rowIndex == null) {
- return clientId;
- }
- return clientId + NamingContainer.SEPARATOR_CHAR + rowIndex;
- }
-
- public UIComponent findComponent(String searchId) {
-
- assert searchId.matches("^(_\\d+)+" + SEPARATOR_CHAR + ".*")
- : "The searchId '" + searchId + "' does not start with a tree structure";
-
- searchId = searchId.substring(searchId.indexOf(SEPARATOR_CHAR) + 1);
- return super.findComponent(searchId);
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- super.queueEvent(new FacesEventWrapper(event, getRowIndex(), this));
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (event instanceof FacesEventWrapper) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- FacesEvent originalEvent = ((FacesEventWrapper) event).getWrappedFacesEvent();
- TreePath eventPathIndex = ((FacesEventWrapper) event).getRowIndex();
- TreePath currentPathIndex = getRowIndex();
- setRowIndex(facesContext, eventPathIndex);
- try {
- originalEvent.getComponent().broadcast(originalEvent);
- } finally {
- setRowIndex(facesContext, currentPathIndex);
- }
- } else {
- super.broadcast(event);
- }
- }
-
- public boolean invokeOnComponent(FacesContext facesContext, String clientId, ContextCallback callback)
- throws FacesException {
- TreePath oldRowIndex = getRowIndex();
- try {
- String sheetId = getClientId(facesContext);
- if (clientId.startsWith(sheetId)) {
- String idRemainder = clientId.substring(sheetId.length());
- if (LOG.isDebugEnabled()) {
- LOG.debug("idRemainder = '" + idRemainder + "'");
- }
- if (idRemainder.matches("^:(_\\d+)+:.*")) {
- idRemainder = idRemainder.substring(1);
- int idx = idRemainder.indexOf(":");
- try {
- TreePath rowIndex = new TreePath(idRemainder.substring(0, idx));
- if (LOG.isDebugEnabled()) {
- LOG.debug("set rowIndex = '" + rowIndex + "'");
- }
- setRowIndex(facesContext, rowIndex);
- } catch (NumberFormatException e) {
- LOG.warn("idRemainder = '" + idRemainder + "'", e);
- }
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("no match for '^:(_\\d+)+:.*'");
- }
- }
- }
-
- return FacesUtils.invokeOnComponent(facesContext, this, clientId, callback);
-
- } finally {
- // we should reset rowIndex on UISheet
- setRowIndex(facesContext, oldRowIndex);
- }
- }
-
- @Override
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
- state[1] = var;
- return state;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- var = (String) values[1];
- }
-
- public String getVar() {
- return var;
- }
-
- public void setVar(String var) {
- this.var = var;
- }
-
- public DefaultMutableTreeNode getCurrentNode() {
- return currentNode;
- }
-
- public void setCurrentNode(DefaultMutableTreeNode currentNode) {
- this.currentNode = currentNode;
- }
-
- private static class FacesEventWrapper extends FacesEvent {
-
- private static final long serialVersionUID = 1L;
-
- private FacesEvent wrappedFacesEvent;
- private TreePath rowIndex;
-
- FacesEventWrapper(FacesEvent facesEvent, TreePath rowIndex, AbstractUITreeData redirectComponent) {
- super(redirectComponent);
- wrappedFacesEvent = facesEvent;
- this.rowIndex = rowIndex;
- }
-
- @Override
- public PhaseId getPhaseId() {
- return wrappedFacesEvent.getPhaseId();
- }
-
- @Override
- public void setPhaseId(PhaseId phaseId) {
- wrappedFacesEvent.setPhaseId(phaseId);
- }
-
- @Override
- public void queue() {
- wrappedFacesEvent.queue();
- }
-
- @Override
- public String toString() {
- return wrappedFacesEvent.toString();
- }
-
- @Override
- public boolean isAppropriateListener(
- FacesListener faceslistener) {
- return wrappedFacesEvent.isAppropriateListener(faceslistener);
- }
-
- @Override
- public void processListener(FacesListener faceslistener) {
- wrappedFacesEvent.processListener(faceslistener);
- }
-
- public FacesEvent getWrappedFacesEvent() {
- return wrappedFacesEvent;
- }
-
- public TreePath getRowIndex() {
- return rowIndex;
- }
- }
-
- // XXX hack: fix this if there is a Listener
- public Object getMarker() {
- return marked;
- }
}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java Tue Jan 3 16:13:02 2012
@@ -26,124 +26,51 @@ import org.apache.myfaces.tobago.event.T
import org.apache.myfaces.tobago.event.TreeExpansionListener;
import org.apache.myfaces.tobago.event.TreeMarkedEvent;
import org.apache.myfaces.tobago.event.TreeMarkedListener;
+import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.model.MixedTreeModel;
import org.apache.myfaces.tobago.model.TreePath;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.swing.tree.DefaultMutableTreeNode;
-import java.io.IOException;
+import javax.swing.tree.TreeNode;
import java.util.List;
+import java.util.Stack;
public abstract class AbstractUITreeNode
extends UIOutput implements SupportsMarkup, TreeModelBuilder, Configurable {
private static final Logger LOG = LoggerFactory.getLogger(AbstractUITreeNode.class);
- private int depth;
- private boolean folder;
- private TreePath path;
- private List<Boolean> junctions;
- private boolean hasNextSibling;
-
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public void buildTreeModelBegin(FacesContext facesContext, MixedTreeModel model) {
- model.beginBuildNode();
- setDepth(computeDepth(this));
- setFolder(computeFolder());
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public void buildTreeModelChildren(FacesContext facesContext, MixedTreeModel model) {
- for (Object child : getChildren()) {
- if (child instanceof TreeModelBuilder) {
- TreeModelBuilder builder = (TreeModelBuilder) child;
- builder.buildTreeModelBegin(facesContext, model);
- builder.buildTreeModelChildren(facesContext, model);
- builder.buildTreeModelEnd(facesContext, model);
- }
- }
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 ???
+ */
+ @Deprecated
public void buildTreeModelEnd(FacesContext facesContext, MixedTreeModel model) {
- model.endBuildNode();
- }
-
- @Override
- public void encodeBegin(FacesContext context) throws IOException {
- AbstractUITree tree = ComponentUtils.findAncestor(this, AbstractUITree.class);
- MixedTreeModel mixedModel = tree.getModel();
- mixedModel.onEncodeBegin();
- setPath(mixedModel.getPath());
- setHasNextSibling(computeHasNextSibling());
- setJunctions(mixedModel.getJunctions());
- super.encodeBegin(context);
- }
-
- private int computeDepth(UIComponent component) {
- int depth = 0;
- while (component != null) {
- depth++;
- if (component instanceof AbstractUITree) {
- return depth;
- }
- if (component instanceof AbstractUITreeData) {
- Object dataTree = ((AbstractUITreeData) component).getValue();
- // todo: make independent from impl.
- if (dataTree instanceof DefaultMutableTreeNode) {
- return ((DefaultMutableTreeNode) dataTree).getDepth(); // XXX expensive
- }
- LOG.warn("Tree type not supported");
- }
- component = component.getParent();
- }
- throw new RuntimeException("Not inside of a UITree");
- }
-
- private boolean computeFolder() {
- DefaultMutableTreeNode node = getDataNode();
- if (node != null) {
- return !node.isLeaf();
- } else {
- for (UIComponent child : (List<UIComponent>) getChildren()) {
- if ((child instanceof AbstractUITreeNode || child instanceof AbstractUITreeData) && child.isRendered()) {
- return true;
- }
- }
- return false;
- }
- }
-
- private boolean computeHasNextSibling() {
- DefaultMutableTreeNode node = getDataNode();
- if (node != null) {
- if (node.isRoot()) {
- return hasSiblingAfter(getParent().getParent(), getParent());
- } else {
- return node.getNextSibling() != null;
- }
- } else {
- return hasSiblingAfter(getParent(), this);
- }
- }
-
- private boolean hasSiblingAfter(UIComponent parent, UIComponent child) {
- boolean found = false;
- for (Object sibling : parent.getChildren()) {
- if (child.equals(sibling)) {
- found = true;
- continue;
- }
- if (found) {
- return true;
- }
- }
- return false;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
/**
@@ -151,7 +78,7 @@ public abstract class AbstractUITreeNode
* Returns null if it will be called not inside of {@link AbstractUITreeData}
*/
// todo: make independent from impl.: DefaultMutableTreeNode
- private DefaultMutableTreeNode getDataNode() {
+/* private DefaultMutableTreeNode getDataNode() {
UIComponent component = this;
while (component != null) {
if (component instanceof AbstractUITreeData) {
@@ -165,27 +92,34 @@ public abstract class AbstractUITreeNode
component = component.getParent();
}
return null;
- }
+ }*/
@Override
public Object getValue() {
- LOG.error("XXXXXXXXXXX should not be called!!!!!!!!!!!!");
+ LOG.error("XXX: Should not be called!", new Exception());
return super.getValue();
}
+ protected DefaultMutableTreeNode getRowData() {
+ final UIData data = ComponentUtils.findAncestor(this, UIData.class);
+ final Object rowData = data.getRowData();
+ return (DefaultMutableTreeNode) rowData;
+ }
+
/**
* Returns the level of the tree node inside of the virtual tree. The root node has level 0.
* The children of the root note have level 1, and so on.
*/
public int getLevel() {
- return path.getLength() - 1;
+ final DefaultMutableTreeNode node = getRowData();
+ return node.getLevel();
}
public String nodeStateId(FacesContext facesContext) {
- String clientId = getClientId(facesContext);
- AbstractUITree tree = ComponentUtils.findAncestor(this, AbstractUITree.class);
- String treeId = tree.getClientId(facesContext);
- return clientId.substring(treeId.length() + 1);
+ final String clientId = getClientId(facesContext);
+ final UIData data = ComponentUtils.findAncestor(this, UIData.class);
+ String dataId = data.getClientId(facesContext);
+ return clientId.substring(dataId.length() + 1);
}
@Override
@@ -225,59 +159,84 @@ public abstract class AbstractUITreeNode
}
}
- public void restoreState(FacesContext context, Object componentState) {
- Object[] values = (Object[]) componentState;
- super.restoreState(context, values[0]);
- path = (TreePath) values[1];
- folder = (Boolean) values[2];
- }
-
- public Object saveState(FacesContext context) {
- Object[] values = new Object[3];
- values[0] = super.saveState(context);
- values[1] = path;
- values[2] = folder;
- return values;
- }
-
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public int getDepth() {
- return depth;
+ Deprecation.LOG.error("Doesn't work anymore.");
+ return 1;
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public void setDepth(int depth) {
- this.depth = depth;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
public boolean isFolder() {
- return folder;
+ final DefaultMutableTreeNode rowData = getRowData();
+ return !rowData.isLeaf();
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public void setFolder(boolean folder) {
- this.folder = folder;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public TreePath getPath() {
- return path;
+ Deprecation.LOG.error("Doesn't work anymore.");
+ return new TreePath(0);
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public void setPath(TreePath path) {
- this.path = path;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
public List<Boolean> getJunctions() {
+ final DefaultMutableTreeNode node = getRowData();
+ List<Boolean> junctions = new Stack<Boolean>();
+ for (TreeNode ancestor : node.getPath()) {
+ junctions.add(((DefaultMutableTreeNode)ancestor).getNextSibling() != null);
+ }
return junctions;
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public void setJunctions(List<Boolean> junctions) {
- this.junctions = junctions;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public boolean isHasNextSibling() {
- return hasNextSibling;
+ return getRowData().getNextSibling() != null;
}
+ /**
+ * @deprecated since XXX 1.6.0 version???
+ */
+ @Deprecated
public void setHasNextSibling(boolean hasNextSibling) {
- this.hasNextSibling = hasNextSibling;
+ Deprecation.LOG.error("Doesn't work anymore.");
}
public abstract MethodBinding getTreeExpansionListener();
Added: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/Expanded.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/Expanded.java?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/Expanded.java (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/Expanded.java Tue Jan 3 16:13:02 2012
@@ -0,0 +1,37 @@
+package org.apache.myfaces.tobago.internal.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Expanded {
+
+ private String id;
+ private boolean expanded;
+
+ public Expanded(String id, boolean expanded) {
+ this.id = id;
+ this.expanded = expanded;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public boolean isExpanded() {
+ return expanded;
+ }
+}
Added: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/TemporaryTreeState.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/TemporaryTreeState.java?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/TemporaryTreeState.java (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/model/TemporaryTreeState.java Tue Jan 3 16:13:02 2012
@@ -0,0 +1,33 @@
+package org.apache.myfaces.tobago.internal.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Stack;
+
+public class TemporaryTreeState {
+
+ private Stack<Expanded> path;
+
+ public TemporaryTreeState() {
+ this.path = new Stack<Expanded>();
+ }
+
+ public Stack<Expanded> getPath() {
+ return path;
+ }
+}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeDataTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeDataTagDeclaration.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeDataTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeDataTagDeclaration.java Tue Jan 3 16:13:02 2012
@@ -28,7 +28,10 @@ import org.apache.myfaces.tobago.interna
/**
* Describes a sub tree of nodes.
* The value has to be a javax.swing.tree.TreeNode object to use as rootNode in the tree.
+ *
+ * @deprecated since XXX 1.6.0 ???
*/
+@Deprecated
@Tag(name = "treeData")
@BodyContentDescription(anyTagOf = "<tc:treeNode>")
@UIComponentTag(
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeListboxTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeListboxTagDeclaration.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeListboxTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeListboxTagDeclaration.java Tue Jan 3 16:13:02 2012
@@ -66,7 +66,10 @@ public interface TreeListboxTagDeclarati
/**
* <strong>ValueBindingExpression</strong> pointing to a object to save the
* component's state.
+ *
+ * @deprecated since XXX 1.6.0 ???
*/
+ @Deprecated
@TagAttribute
@UIComponentTagAttribute(type = "java.lang.Object", expression = DynamicExpression.VALUE_BINDING_REQUIRED)
void setState(String state);
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeMenuTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeMenuTagDeclaration.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeMenuTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeMenuTagDeclaration.java Tue Jan 3 16:13:02 2012
@@ -51,7 +51,9 @@ public interface TreeMenuTagDeclaration
* <strong>ValueBindingExpression</strong> pointing to a object to save the
* component's state.
*
+ * @deprecated since XXX 1.6.0 ???
*/
+ @Deprecated
@TagAttribute
@UIComponentTagAttribute(type = "java.lang.Object", expression = DynamicExpression.VALUE_BINDING_REQUIRED)
void setState(String state);
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeTagDeclaration.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/TreeTagDeclaration.java Tue Jan 3 16:13:02 2012
@@ -27,6 +27,8 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.internal.taglib.declaration.HasCurrentMarkup;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasValue;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasVar;
import org.apache.myfaces.tobago.internal.taglib.declaration.IsGridLayoutComponent;
import org.apache.myfaces.tobago.internal.taglib.declaration.IsRequired;
@@ -45,7 +47,7 @@ import org.apache.myfaces.tobago.interna
"org.apache.myfaces.tobago.TreeData"
})
public interface TreeTagDeclaration
- extends HasIdBindingAndRendered, IsRequired, IsGridLayoutComponent, HasMarkup, HasCurrentMarkup {
+ extends HasIdBindingAndRendered, HasValue, HasVar, IsRequired, IsGridLayoutComponent, HasMarkup, HasCurrentMarkup {
/**
* Flag indicating whether or not this component should be render selectable items.
@@ -78,7 +80,9 @@ public interface TreeTagDeclaration
* <strong>ValueBindingExpression</strong> pointing to a object to save the
* component's state.
*
+ * @deprecated since XXX 1.6.0 ???
*/
+ @Deprecated
@TagAttribute
@UIComponentTagAttribute(type = "java.lang.Object", expression = DynamicExpression.VALUE_BINDING_REQUIRED)
void setState(String state);
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/DefaultMutableTreeNodeAnalyser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/DefaultMutableTreeNodeAnalyser.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/DefaultMutableTreeNodeAnalyser.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/DefaultMutableTreeNodeAnalyser.java Tue Jan 3 16:13:02 2012
@@ -19,7 +19,10 @@ package org.apache.myfaces.tobago.model;
import javax.swing.tree.DefaultMutableTreeNode;
-
+/**
+ * @deprecated since XXX 1.6.0 version???
+ */
+@Deprecated
public class DefaultMutableTreeNodeAnalyser implements TreeAnalyser {
private DefaultMutableTreeNode node;
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/MixedTreeModel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/MixedTreeModel.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/MixedTreeModel.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/MixedTreeModel.java Tue Jan 3 16:13:02 2012
@@ -24,6 +24,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
+/**
+ * @deprecated since XXX 1.6.0 ???
+ */
+@Deprecated
public class MixedTreeModel {
private static final Logger LOG = LoggerFactory.getLogger(MixedTreeModel.class);
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Node.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Node.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Node.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Node.java Tue Jan 3 16:13:02 2012
@@ -58,7 +58,7 @@ public class Node {
for (int i = 0; i < children.size(); i++) {
Node child = children.get(i);
if (child.equals(node)) {
- return i;
+ return i;
}
}
return -1;
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeAnalyser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeAnalyser.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeAnalyser.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeAnalyser.java Tue Jan 3 16:13:02 2012
@@ -18,8 +18,9 @@ package org.apache.myfaces.tobago.model;
*/
/**
- * Date: 04.12.2008
+ * @deprecated since XXX 1.6.0 version???
*/
+@Deprecated
public interface TreeAnalyser {
int computeDepth();
Added: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeDataModel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeDataModel.java?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeDataModel.java (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreeDataModel.java Tue Jan 3 16:13:02 2012
@@ -0,0 +1,83 @@
+package org.apache.myfaces.tobago.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.faces.model.DataModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+public class TreeDataModel extends DataModel {
+
+ private DefaultMutableTreeNode data;
+ private int rowIndex = -1;
+ private Map<Integer, DefaultMutableTreeNode> mapping;
+
+ public TreeDataModel(DefaultMutableTreeNode data) {
+ this.data = data;
+ init();
+ }
+
+ private void init() {
+ mapping = new HashMap<Integer, DefaultMutableTreeNode>();
+ int counter = 0;
+ final Enumeration enumeration = data.preorderEnumeration();
+ while (enumeration.hasMoreElements()) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
+ mapping.put(counter, node);
+ counter++;
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+
+ return mapping.size();
+ }
+
+ @Override
+ public DefaultMutableTreeNode getRowData() {
+ return mapping.get(rowIndex);
+ }
+
+ @Override
+ public int getRowIndex() {
+ return rowIndex;
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return data;
+ }
+
+ @Override
+ public boolean isRowAvailable() {
+ return 0 <= rowIndex && rowIndex < getRowCount();
+ }
+
+ @Override
+ public void setRowIndex(int rowIndex) {
+ this.rowIndex = rowIndex;
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ this.data = (DefaultMutableTreeNode) data;
+ }
+}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreePath.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreePath.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreePath.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/model/TreePath.java Tue Jan 3 16:13:02 2012
@@ -27,8 +27,10 @@ import java.util.List;
/**
* Handles a path in a tree from the root node to the position inside this tree.
*
- * Date: 02.12.2008
+ * @since 1.5.0
+ * @deprecated
*/
+@Deprecated
public class TreePath implements Serializable {
private int[] path;
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Tue Jan 3 16:13:02 2012
@@ -251,6 +251,24 @@ public class ComponentUtils {
}
/**
+ * Searches the component tree beneath the component and return all component matching the type.
+ */
+ public static List<UIComponent> findDescendantList(UIComponent component, Class type) {
+
+ // todo Can this be generified with T extends UIComponent?
+
+ List<UIComponent> result = new ArrayList<UIComponent>();
+
+ for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+ if (type.isAssignableFrom(child.getClass())) {
+ result.add(child);
+ }
+ result.addAll(findDescendantList(child, type));
+ }
+ return result;
+ }
+
+ /**
* Looks for the attribute "for" in the component. If there is any
* search for the component which is referenced by the "for" attribute,
* and return their clientId.
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/test/java/org/apache/myfaces/tobago/model/MixedTreeModelUnitTest.java Tue Jan 3 16:13:02 2012
@@ -23,6 +23,10 @@ import org.junit.Test;
import javax.swing.tree.DefaultMutableTreeNode;
+/**
+ * @deprecated since XXX 1.6.0 ???
+ */
+@Deprecated
public class MixedTreeModelUnitTest {
@Test
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TreeController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TreeController.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TreeController.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TreeController.java Tue Jan 3 16:13:02 2012
@@ -19,15 +19,18 @@ package org.apache.myfaces.tobago.exampl
import org.apache.myfaces.tobago.example.data.CategoryTree;
import org.apache.myfaces.tobago.example.data.SmallTree;
+import org.apache.myfaces.tobago.model.TreeDataModel;
import javax.swing.tree.DefaultMutableTreeNode;
public class TreeController {
-
+
private DefaultMutableTreeNode tree = CategoryTree.createSample();
private DefaultMutableTreeNode small = SmallTree.createSample();
+ private TreeDataModel treeInSheet = new TreeDataModel(tree);
+
public DefaultMutableTreeNode getTree() {
return tree;
}
@@ -35,4 +38,8 @@ public class TreeController {
public DefaultMutableTreeNode getSmall() {
return small;
}
+
+ public TreeDataModel getTreeInSheet() {
+ return treeInSheet;
+ }
}
Copied: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml (from r1199440, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml?p2=myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml&r1=1199440&r2=1226847&rev=1226847&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-simple.xhtml (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-tree.xhtml Tue Jan 3 16:13:02 2012
@@ -23,20 +23,38 @@
xmlns:f="http://java.sun.com/jsf/core">
<tc:page id="page">
- <tc:gridLayoutConstraint width="600px" height="600px"/>
+ <tc:gridLayoutConstraint width="1200px" height="1205px"/>
+
+ <tc:sheet value="#{tree.tree}" id="row" columns="*;*" var="row" rows="14">
+
+ <tc:column label="Tree" id="tree">
+ <tc:treeNode>
+ <tc:treeIndent/>
+ <tc:treeLabel value="#{row.userObject.name}"/>
+ </tc:treeNode>
+ </tc:column>
- <tc:sheet value="#{sheet.solarArray}" id="sheet" columns="*;*" var="luminary" rows="5">
<tc:column label="Name" id="name" sortable="true">
- <tc:out value="#{luminary.name}"/>
+ <tc:out value="#{row.userObject.name}"/>
</tc:column>
+
<tc:column label="Orbit Of" id="orbit">
- <tc:out value="#{luminary.orbit}"/>
+ <tc:out value="Tip: #{row.userObject.tip}"/>
</tc:column>
+
</tc:sheet>
- <tc:script file="script/tobago-assert.js"/>
- <!--todo-->
- <!--<tc:script onload="TobagoAssert.assertLayout('page:todo', 0, 0, 600, 14);"/>-->
+<!--
+ <tc:tree showRoot="true">
+ <tc:treeData value="#{tree.tree}" var="row">
+
+ <tc:treeNode expanded="true">
+ <tc:treeIndent/>
+ <tc:treeLabel value="#{row.userObject.name}"/>
+ </tc:treeNode>
+ </tc:treeData>
+ </tc:tree>
+-->
</tc:page>
</f:view>
Added: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml Tue Jan 3 16:13:02 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="600px" height="300px"/>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;*"/>
+ </f:facet>
+
+ <tc:out value="Tree with commands as nodes:"/>
+
+ <tc:tree id="tree" value="#{tree.tree}" var="node" showRoot="true" showRootJunction="true">
+ <tc:treeNode id="node" expanded="true">
+ <tc:treeIndent/>
+ <tc:treeCommand label="#{node.userObject.name}" action="#{node.userObject.action}"/>
+ </tc:treeNode>
+ </tc:tree>
+
+ </tc:page>
+</f:view>
Added: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple-with-data.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple-with-data.xhtml?rev=1226847&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple-with-data.xhtml (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple-with-data.xhtml Tue Jan 3 16:13:02 2012
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <tc:page>
+ <tc:gridLayoutConstraint width="600px" height="300px" />
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;*"/>
+ </f:facet>
+
+ <tc:out value="Simple tree with deprecated <tc:treeData> tag:"/>
+
+ <tc:tree id="tree" selectable="single" showRoot="true" showRootJunction="true">
+ <tc:treeData value="#{tree.tree}" var="node" id="data">
+ <tc:treeNode id="template" expanded="true">
+ <tc:treeIndent/>
+ <tc:treeLabel value="#{node.userObject.name}"/>
+ </tc:treeNode>
+ </tc:treeData>
+ </tc:tree>
+
+ </tc:page>
+</f:view>
Copied: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple.xhtml (from r1220715, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple.xhtml?p2=myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml&r1=1220715&r2=1226847&rev=1226847&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-simple.xhtml Tue Jan 3 16:13:02 2012
@@ -22,16 +22,19 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
- <tc:page>
+ <tc:page id="page">
<tc:gridLayoutConstraint width="600px" height="300px"/>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;*"/>
+ </f:facet>
- <tc:tree id="tree" selectable="single" showRoot="true" showRootJunction="true">
- <tc:treeData value="#{tree.tree}" var="node" id="data">
- <tc:treeNode id="template" expanded="true">
- <tc:treeIndent/>
- <tc:treeLabel value="#{node.userObject.name}"/>
- </tc:treeNode>
- </tc:treeData>
+ <tc:out value="Simple tree:"/>
+
+ <tc:tree id="tree" value="#{tree.tree}" var="node" showRoot="true" showRootJunction="true">
+ <tc:treeNode id="node" expanded="true">
+ <tc:treeIndent/>
+ <tc:treeLabel value="#{node.userObject.name}"/>
+ </tc:treeNode>
</tc:tree>
</tc:page>
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java Tue Jan 3 16:13:02 2012
@@ -48,10 +48,7 @@ public class TreeCommandRenderer extends
public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
final UITreeCommand command = (UITreeCommand) component;
final UITreeNode node = ComponentUtils.findAncestor(command, UITreeNode.class);
- if (node.isDisabled()) {
- command.setDisabled(true);
- }
-
+ command.setDisabled(node.isDisabled());
super.prepareRender(facesContext, component);
}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeIndentRenderer.java Tue Jan 3 16:13:02 2012
@@ -22,7 +22,6 @@ import org.apache.myfaces.tobago.compone
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.internal.component.AbstractUITree;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
@@ -33,6 +32,7 @@ import org.apache.myfaces.tobago.util.Co
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
import java.io.IOException;
import java.util.List;
@@ -44,35 +44,39 @@ public class TreeIndentRenderer extends
final UITreeIndent indent = (UITreeIndent) component;
final UITreeNode node = ComponentUtils.findAncestor(indent, UITreeNode.class);
- final AbstractUITree tree = ComponentUtils.findAncestor(indent, AbstractUITree.class);
+ final UIData data = ComponentUtils.findAncestor(indent, UIData.class);
final boolean folder = node.isFolder();
final int level = node.getLevel();
- final boolean hasNextSibling = node.isHasNextSibling();
final List<Boolean> junctions = node.getJunctions();
- final boolean showRoot = ((UITree) tree).isShowRoot();
+ // todo: sheet
+ final boolean showRoot = data instanceof UITree && ((UITree) data).isShowRoot();
final boolean showJunctions = indent.isShowJunctions();
- final boolean showRootJunction = ((UITree) tree).isShowRootJunction();
- final boolean expanded = folder && node.isExpanded() || !showRoot && level == 0;
+ // todo: sheet
+ final boolean showRootJunction = data instanceof UITree && ((UITree) data).isShowRootJunction();
+ final boolean expanded = folder && node.isExpanded();
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- encodeIndent(facesContext, writer, node, showJunctions, !showRoot || !showRootJunction && showJunctions, junctions);
+ encodeIndent(
+ facesContext, writer, node, showJunctions, showRootJunction, showRoot, junctions);
encodeTreeJunction(
- facesContext, writer, node, !showJunctions, !showRootJunction, expanded, folder, level == 0, hasNextSibling);
+ facesContext, writer, node, showJunctions, showRootJunction, junctions, expanded, folder, level == 0);
}
- private void encodeIndent(
+ private void encodeIndent(
final FacesContext facesContext, final TobagoResponseWriter writer, final UITreeNode node,
- final boolean showJunctions, final boolean dropFirst, final List<Boolean> junctions)
+ final boolean showJunctions, final boolean showRootJunction, final boolean showRoot,
+ final List<Boolean> junctions)
throws IOException {
+ final boolean dropFirst = !showRoot || !showRootJunction && showJunctions;
final String blank = ResourceManagerUtils.getImageWithPath(facesContext, "image/blank.gif");
final String perpendicular = ResourceManagerUtils.getImageWithPath(facesContext, "image/I.gif");
- for (int i = dropFirst ? 1 : 0; i < junctions.size(); i++) {
+ for (int i = dropFirst ? 1 : 0; i < junctions.size() - 1; i++) {
Boolean junction = junctions.get(i);
writer.startElement(HtmlElements.IMG, null);
writer.writeClassAttribute(Classes.create(node, "junction"));
@@ -87,13 +91,14 @@ public class TreeIndentRenderer extends
}
private void encodeTreeJunction(
- FacesContext facesContext, TobagoResponseWriter writer, UITreeNode node,
- boolean hideJunctions, boolean hideRootJunction, boolean expanded, boolean folder,
- boolean root, boolean hasNextSibling)
+ final FacesContext facesContext, final TobagoResponseWriter writer, final UITreeNode node,
+ final boolean showJunctions, final boolean showRootJunction, final List<Boolean> junctions,
+ final boolean expanded, final boolean folder, final boolean root)
throws IOException {
- if (hideJunctions || hideRootJunction && root) {
+ if (!showJunctions || !showRootJunction && root) {
return;
}
+ final boolean hasNextSibling = junctions.get(junctions.size() - 1); // last element
writer.startElement(HtmlElements.IMG, null);
writer.writeClassAttribute(Classes.create(node, "toggle", Markup.NULL));
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeLabelRenderer.java Tue Jan 3 16:13:02 2012
@@ -18,13 +18,11 @@ package org.apache.myfaces.tobago.render
*/
import org.apache.myfaces.tobago.component.UITreeLabel;
-import org.apache.myfaces.tobago.component.UITreeNode;
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.HtmlElements;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
-import org.apache.myfaces.tobago.util.ComponentUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,9 +38,6 @@ public class TreeLabelRenderer extends L
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
final UITreeLabel label = (UITreeLabel) component;
- final UITreeNode node = ComponentUtils.findAncestor(label, UITreeNode.class);
- final boolean folder = node.isFolder();
-
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
writer.startElement(HtmlElements.LABEL, label);
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java?rev=1226847&r1=1226846&r2=1226847&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeListboxRenderer.java Tue Jan 3 16:13:02 2012
@@ -58,16 +58,6 @@ public class TreeListboxRenderer extends
}
@Override
- public void decode(FacesContext facesContext, UIComponent component) {
- if (ComponentUtils.isOutputOnly(component)) {
- return;
- }
-
- AbstractUITree tree = (AbstractUITree) component;
- tree.setValid(true);
- }
-
- @Override
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
// will be rendered in encodeEnd()
}