summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-04-06 07:57:40 +0000
committerHenri Sara <henri.sara@itmill.com>2009-04-06 07:57:40 +0000
commitd818356c57d9e117eaabb77ad45a57c6bca00bc0 (patch)
tree594ebc4c4310b58c8b545fba559b064c07c1201a /src/com
parent60221b16a87d721a2d271f3d3ec4360a18d46c9b (diff)
downloadvaadin-framework-d818356c57d9e117eaabb77ad45a57c6bca00bc0.tar.gz
vaadin-framework-d818356c57d9e117eaabb77ad45a57c6bca00bc0.zip
Merged to 6.0 #2603 (a single select tree could show multiple items as selected) and minor Tree and TextField cleanup/javadoc fixes
svn changeset:7313/svn branch:6.0
Diffstat (limited to 'src/com')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java7
-rw-r--r--src/com/itmill/toolkit/ui/TextField.java8
-rw-r--r--src/com/itmill/toolkit/ui/Tree.java44
3 files changed, 34 insertions, 25 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
index dd11136aa4..678f08a886 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
@@ -142,6 +142,11 @@ public class ITree extends FlowPanel implements Paintable {
rootNode.renderChildNodes(uidl.getChildIterator());
}
+ if (uidl.hasVariable("selected")) {
+ // update selection in case selected nodes were not visible
+ selectedIds = uidl.getStringArrayVariableAsSet("selected");
+ }
+
}
public void setSelected(TreeNode treeNode, boolean selected) {
@@ -152,7 +157,7 @@ public class ITree extends FlowPanel implements Paintable {
final TreeNode oldSelection = keyToNode.get(id);
if (oldSelection != null) {
// can be null if the node is not visible (parent
- // expanded)
+ // collapsed)
oldSelection.setSelected(false);
}
selectedIds.remove(id);
diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java
index dd8596f087..0b7336e215 100644
--- a/src/com/itmill/toolkit/ui/TextField.java
+++ b/src/com/itmill/toolkit/ui/TextField.java
@@ -409,7 +409,7 @@ public class TextField extends AbstractField {
*
* <p>
* If this property is true, writing null-representation string to text
- * field allways sets the field value to real null. If this property is
+ * field always sets the field value to real null. If this property is
* false, null setting is not made, but the null values are maintained.
* Maintenance of null-values is made by only converting the textfield
* contents to real null, if the text field matches the null-string
@@ -420,7 +420,7 @@ public class TextField extends AbstractField {
* By default this setting is false
* </p>
*
- * @return boolean Should the null-string represenation be allways converted
+ * @return boolean Should the null-string represenation be always converted
* to null-values.
* @see TextField#getNullRepresentation()
*/
@@ -454,7 +454,7 @@ public class TextField extends AbstractField {
*
* <p>
* If this property is true, writing null-representation string to text
- * field allways sets the field value to real null. If this property is
+ * field always sets the field value to real null. If this property is
* false, null setting is not made, but the null values are maintained.
* Maintenance of null-values is made by only converting the textfield
* contents to real null, if the text field matches the null-string
@@ -466,7 +466,7 @@ public class TextField extends AbstractField {
* </p>
*
* @param nullSettingAllowed
- * Should the null-string represenation be allways converted to
+ * Should the null-string represenation be always converted to
* null-values.
* @see TextField#getNullRepresentation()
*/
diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java
index 36b34ac50a..20c7e03961 100644
--- a/src/com/itmill/toolkit/ui/Tree.java
+++ b/src/com/itmill/toolkit/ui/Tree.java
@@ -32,8 +32,8 @@ import com.itmill.toolkit.terminal.Resource;
import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails;
/**
- * MenuTree component. MenuTree can be used to select an item (or multiple
- * items) from a hierarchical set of items.
+ * Tree component. A Tree can be used to select an item (or multiple items) from
+ * a hierarchical set of items.
*
* @author IT Mill Ltd.
* @version
@@ -72,7 +72,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
/**
* List of action handlers.
*/
- private LinkedList actionHandlers = null;
+ private LinkedList<Action.Handler> actionHandlers = null;
/**
* Action mapper.
@@ -396,10 +396,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
final Action action = (Action) actionMapper.get(st.nextToken());
if (action != null && containsId(itemId)
&& actionHandlers != null) {
- for (final Iterator i = actionHandlers.iterator(); i
- .hasNext();) {
- ((Action.Handler) i.next()).handleAction(action, this,
- itemId);
+ for (final Iterator<Action.Handler> i = actionHandlers
+ .iterator(); i.hasNext();) {
+ i.next().handleAction(action, this, itemId);
}
}
}
@@ -448,7 +447,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
}
// Initialize variables
- final Set actionSet = new LinkedHashSet();
+ final Set<Action> actionSet = new LinkedHashSet<Action>();
String[] selectedKeys;
if (isMultiSelect()) {
selectedKeys = new String[((Set) getValue()).size()];
@@ -459,7 +458,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
final LinkedList expandedKeys = new LinkedList();
// Iterates through hierarchical tree using a stack of iterators
- final Stack iteratorStack = new Stack();
+ final Stack<Iterator> iteratorStack = new Stack<Iterator>();
Collection ids;
if (partialUpdate) {
ids = getChildren(expandedItemId);
@@ -474,7 +473,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
while (!iteratorStack.isEmpty()) {
// Gets the iterator for current tree level
- final Iterator i = (Iterator) iteratorStack.peek();
+ final Iterator i = iteratorStack.peek();
// If the level is finished, back to previous tree level
if (!i.hasNext()) {
@@ -527,11 +526,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
// Actions
if (actionHandlers != null) {
- final ArrayList keys = new ArrayList();
- for (final Iterator ahi = actionHandlers.iterator(); ahi
- .hasNext();) {
- final Action[] aa = ((Action.Handler) ahi.next())
- .getActions(itemId, this);
+ final ArrayList<String> keys = new ArrayList<String>();
+ final Iterator<Action.Handler> ahi = actionHandlers
+ .iterator();
+ while (ahi.hasNext()) {
+ final Action[] aa = ahi.next().getActions(itemId, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
final String akey = actionMapper.key(aa[ai]);
@@ -561,8 +560,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
- for (final Iterator i = actionSet.iterator(); i.hasNext();) {
- final Action a = (Action) i.next();
+ final Iterator<Action> i = actionSet.iterator();
+ while (i.hasNext()) {
+ final Action a = i.next();
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
@@ -577,6 +577,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
}
if (partialUpdate) {
+ // update tree-level selection information in case some selected
+ // node(s) were collapsed
+ target.addVariable(this, "selected", selectedKeys);
+
partialUpdate = false;
} else {
// Selected
@@ -899,7 +903,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (actionHandler != null) {
if (actionHandlers == null) {
- actionHandlers = new LinkedList();
+ actionHandlers = new LinkedList<Action.Handler>();
actionMapper = new KeyMapper();
}
@@ -941,7 +945,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
final LinkedList visible = new LinkedList();
// Iterates trough hierarchical tree using a stack of iterators
- final Stack iteratorStack = new Stack();
+ final Stack<Iterator> iteratorStack = new Stack<Iterator>();
final Collection ids = rootItemIds();
if (ids != null) {
iteratorStack.push(ids.iterator());
@@ -949,7 +953,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
while (!iteratorStack.isEmpty()) {
// Gets the iterator for current tree level
- final Iterator i = (Iterator) iteratorStack.peek();
+ final Iterator i = iteratorStack.peek();
// If the level is finished, back to previous tree level
if (!i.hasNext()) {