Author: nbelaevski
Date: 2010-11-01 10:33:47 -0400 (Mon, 01 Nov 2010)
New Revision: 19832
Removed:
sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/component/
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/SelectionImpl.java
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeRange.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
Log:
https://jira.jboss.org/browse/RF-9315
- removed selection interface
- renamed toggleMode/selectionMode attributes
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01
14:24:14 UTC (rev 19831)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01
14:33:47 UTC (rev 19832)
@@ -22,6 +22,8 @@
package org.richfaces.component;
import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -124,15 +126,16 @@
}
@Attribute(defaultValue = "SwitchType.DEFAULT")
- public abstract SwitchType getToggleMode();
+ public abstract SwitchType getToggleType();
@Attribute(defaultValue = "SwitchType.client")
- public abstract SwitchType getSelectionMode();
+ public abstract SwitchType getSelectionType();
- public Selection getSelection() {
- Selection selection = (Selection) getStateHelper().eval(PropertyKeys.selection);
+ public Collection<Object> getSelection() {
+ @SuppressWarnings("unchecked")
+ Collection<Object> selection = (Collection<Object>)
getStateHelper().eval(PropertyKeys.selection);
if (selection == null) {
- selection = new SelectionImpl();
+ selection = new HashSet<Object>();
ValueExpression ve = getValueExpression(PropertyKeys.selection.toString());
if (ve != null) {
@@ -145,7 +148,7 @@
return selection;
}
- public void setSelection(Selection selection) {
+ public void setSelection(Collection<Object> selection) {
getStateHelper().put(PropertyKeys.selection, selection);
}
@@ -285,14 +288,14 @@
} else if (event instanceof TreeSelectionEvent) {
TreeSelectionEvent selectionEvent = (TreeSelectionEvent) event;
- Selection selection = getSelection();
+ Collection<Object> selection = getSelection();
for (Object addedKey: selectionEvent.getAddedKeys()) {
- selection.addToSelection(addedKey);
+ selection.add(addedKey);
}
for (Object removedKey: selectionEvent.getRemovedKeys()) {
- selection.removeFromSelection(removedKey);
+ selection.remove(removedKey);
}
}
}
Deleted:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/SelectionImpl.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/SelectionImpl.java 2010-11-01
14:24:14 UTC (rev 19831)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/SelectionImpl.java 2010-11-01
14:33:47 UTC (rev 19832)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class SelectionImpl implements Selection, Serializable {
-
- private static final long serialVersionUID = 7738700662652136887L;
-
- private Set<Object> selectedKeys = new HashSet<Object>();
-
- public boolean addToSelection(Object rowKey) {
- return selectedKeys.add(rowKey);
- }
-
- public boolean isSelected(Object rowKey) {
- return selectedKeys.contains(rowKey);
- }
-
- public Iterator<Object> getSelectionIterator() {
- return Iterators.unmodifiableIterator(selectedKeys.iterator());
- }
-
- public boolean removeFromSelection(Object rowKey) {
- return selectedKeys.remove(rowKey);
- }
-
- public boolean isEmpty() {
- return selectedKeys.isEmpty();
- }
-
- public void clear() {
- selectedKeys = new HashSet<Object>();
- }
-
-}
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeRange.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-11-01
14:24:14 UTC (rev 19831)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-11-01
14:33:47 UTC (rev 19832)
@@ -42,7 +42,7 @@
this.facesContext = facesContext;
this.tree = tree;
- traverseAll = SwitchType.client == tree.getToggleMode();
+ traverseAll = (SwitchType.client == tree.getToggleType());
}
public boolean shouldIterateChildren(Object rowKey) {
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01
14:24:14 UTC (rev 19831)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01
14:33:47 UTC (rev 19832)
@@ -28,6 +28,7 @@
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -45,7 +46,6 @@
import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.MetaComponentResolver;
-import org.richfaces.component.Selection;
import org.richfaces.component.SwitchType;
import org.richfaces.component.TreeDecoderHelper;
import org.richfaces.event.TreeSelectionEvent;
@@ -54,7 +54,6 @@
import org.richfaces.log.RichfacesLogger;
import com.google.common.base.Strings;
-import com.google.common.collect.Iterators;
/**
@@ -154,7 +153,7 @@
protected String getAjaxSubmitFunction(FacesContext context, UIComponent component)
{
AbstractTree tree = (AbstractTree) component;
- if (tree.getToggleMode() != SwitchType.ajax && tree.getSelectionMode() !=
SwitchType.ajax) {
+ if (tree.getToggleType() != SwitchType.ajax && tree.getSelectionType() !=
SwitchType.ajax) {
return null;
}
@@ -182,7 +181,7 @@
String selectedNodeId = "";
AbstractTree tree = (AbstractTree) component;
- Iterator<Object> selectedKeys =
tree.getSelection().getSelectionIterator();
+ Iterator<Object> selectedKeys = tree.getSelection().iterator();
if (selectedKeys.hasNext()) {
Object selectionKey = selectedKeys.next();
@@ -218,13 +217,13 @@
protected SwitchType getSelectionMode(FacesContext context, UIComponent component) {
AbstractTree tree = (AbstractTree) component;
- SwitchType selectionMode = tree.getSelectionMode();
- if (selectionMode != null && selectionMode != SwitchType.ajax &&
selectionMode != SwitchType.client) {
+ SwitchType selectionType = tree.getSelectionType();
+ if (selectionType != null && selectionType != SwitchType.ajax &&
selectionType != SwitchType.client) {
//TODO - better message
- throw new IllegalArgumentException(String.valueOf(selectionMode));
+ throw new IllegalArgumentException(String.valueOf(selectionType));
}
- return selectionMode;
+ return selectionType;
}
protected String getNamingContainerSeparatorChar(FacesContext context) {
@@ -298,16 +297,16 @@
selectionRowKey = tree.getRowKeyConverter().getAsObject(context, component,
selectionRowKeyString);
}
- Selection selection = tree.getSelection();
+ Collection<Object> selection = tree.getSelection();
Set<Object> addedKeys = new HashSet<Object>(2);
Set<Object> removedKeys = new HashSet<Object>(2);
if (selectionRowKey == null) {
- Iterators.addAll(removedKeys, selection.getSelectionIterator());
- } else if (!selection.isSelected(selectionRowKey)) {
+ removedKeys.addAll(selection);
+ } else if (!selection.contains(selectionRowKey)) {
addedKeys.add(selectionRowKey);
- Iterators.addAll(removedKeys, selection.getSelectionIterator());
+ removedKeys.addAll(selection);
}
if (!removedKeys.isEmpty() || !addedKeys.isEmpty()) {
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-01
14:24:14 UTC (rev 19831)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-01
14:33:47 UTC (rev 19832)
@@ -159,7 +159,7 @@
if (newState ^ this.isExpanded()) {
var tree = this.getTree();
- switch (tree.getToggleMode()) {
+ switch (tree.getToggleType()) {
case 'client':
this.elt.addClass(TREE_CLASSES[newState ? 1 :
0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
this.__getHandle().addClass(TREE_HANDLE_CLASSES[newState ? 1 :
0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
@@ -247,8 +247,8 @@
init: function (id, options) {
this.$super.init.call(this, id);
- this.__toggleMode = options.toggleMode || 'ajax';
- this.__selectionMode = options.selectionMode || 'client';
+ this.__toggleType = options.toggleType || 'ajax';
+ this.__selectionType = options.selectionType || 'client';
if (options.ajaxSubmitFunction) {
this.__ajaxSubmitFunction = new Function("event", "source",
"params", options.ajaxSubmitFunction);
@@ -302,7 +302,7 @@
var clientParams = {};
clientParams[toggleSource + NEW_NODE_TOGGLE_STATE] = newNodeState;
- if (this.__toggleMode == 'server') {
+ if (this.getToggleType() == 'server') {
var form = $(richfaces.getDomElement(this.id)).closest('form');
richfaces.submitForm(form, clientParams);
} else {
@@ -310,12 +310,12 @@
}
},
- getToggleMode: function() {
- return this.__toggleMode;
+ getToggleType: function() {
+ return this.__toggleType;
},
- getSelectionMode: function() {
- return this.__selectionMode;
+ getSelectionType: function() {
+ return this.__selectionType;
},
getTree: function() {
@@ -331,7 +331,7 @@
},
__handleSelectionChange: function() {
- if (this.__selectionMode == 'client') {
+ if (this.getSelectionType() == 'client') {
this.__updateSelection();
} else {
this.__ajaxSubmitFunction(null, this.id);
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-11-01
14:24:14 UTC (rev 19831)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-11-01
14:33:47 UTC (rev 19832)
@@ -30,8 +30,8 @@
<script type="text/javascript">
RichFaces.ui.Tree.setNamingContainerSeparatorChar(#{toScriptArgs(getNamingContainerSeparatorChar(facesContext))});
<cdk:scriptObject name="options">
- <cdk:scriptOption attributes="toggleMode"
defaultValue="SwitchType.DEFAULT" />
- <cdk:scriptOption name="selectionMode"
value="#{getSelectionMode(facesContext, component)}"
defaultValue="SwitchType.client" />
+ <cdk:scriptOption attributes="toggleType"
defaultValue="SwitchType.DEFAULT" />
+ <cdk:scriptOption name="selectionType"
value="#{getSelectionMode(facesContext, component)}"
defaultValue="SwitchType.client" />
<cdk:scriptOption name="ajaxSubmitFunction"
value="#{getAjaxSubmitFunction(facesContext, component)}" />
</cdk:scriptObject>