diff options
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractMedia.java | 7 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/ConnectorTracker.java | 76 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Tree.java | 34 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 1 |
4 files changed, 67 insertions, 51 deletions
diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 55464aeb8d..41677467bb 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -19,6 +19,7 @@ package com.vaadin.ui; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -88,9 +89,9 @@ public abstract class AbstractMedia extends AbstractComponent { int sourceIndex = Integer.parseInt(matcher.group(1)); if (sourceIndex < 0 || sourceIndex >= sources.size()) { - getLogger().warning( - "Requested source index " + sourceIndex - + " is out of bounds"); + getLogger().log(Level.WARNING, + "Requested source index {0} is out of bounds", + sourceIndex); return false; } diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index a888f9f7eb..a229003224 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -120,17 +120,23 @@ public class ConnectorTracker implements Serializable { if (previouslyRegistered == null) { connectorIdToConnector.put(connectorId, connector); uninitializedConnectors.add(connector); - getLogger().fine( - "Registered " + connector.getClass().getSimpleName() + " (" - + connectorId + ")"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "Registered {0} ({1})", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); + } } else if (previouslyRegistered != connector) { throw new RuntimeException("A connector with id " + connectorId + " is already registered!"); } else if (!wasUnregistered) { - getLogger().warning( - "An already registered connector was registered again: " - + connector.getClass().getSimpleName() + " (" - + connectorId + ")"); + getLogger() + .log(Level.WARNING, + "An already registered connector was registered again: {0} ({1})", + new Object[] { + connector.getClass().getSimpleName(), + connectorId }); } dirtyConnectors.add(connector); } @@ -149,10 +155,11 @@ public class ConnectorTracker implements Serializable { public void unregisterConnector(ClientConnector connector) { String connectorId = connector.getConnectorId(); if (!connectorIdToConnector.containsKey(connectorId)) { - getLogger().warning( - "Tried to unregister " - + connector.getClass().getSimpleName() + " (" - + connectorId + ") which is not registered"); + getLogger().log( + Level.WARNING, + "Tried to unregister {0} ({1}) which is not registered", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); return; } if (connectorIdToConnector.get(connectorId) != connector) { @@ -163,14 +170,19 @@ public class ConnectorTracker implements Serializable { dirtyConnectors.remove(connector); if (unregisteredConnectors.add(connector)) { - getLogger().fine( - "Unregistered " + connector.getClass().getSimpleName() - + " (" + connectorId + ")"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "Unregistered {0} ({1})", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); + } } else { - getLogger().warning( - "Unregistered " + connector.getClass().getSimpleName() - + " (" + connectorId - + ") that was already unregistered."); + getLogger().log( + Level.WARNING, + "Unregistered {0} ({1}) that was already unregistered.", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); } } @@ -273,11 +285,11 @@ public class ConnectorTracker implements Serializable { // This code should never be called as cleanup should take place // in detach() + getLogger() - .warning( - "cleanConnectorMap unregistered connector " - + getConnectorAndParentInfo(connector) - + "). This should have been done when the connector was detached."); + .log(Level.WARNING, + "cleanConnectorMap unregistered connector {0}. This should have been done when the connector was detached.", + getConnectorAndParentInfo(connector)); removeFromGlobalResourceHandler(connector); uninitializedConnectors.remove(connector); @@ -288,10 +300,12 @@ public class ConnectorTracker implements Serializable { && !uninitializedConnectors.contains(connector)) { uninitializedConnectors.add(connector); diffStates.remove(connector); - getLogger().fine( - "cleanConnectorMap removed state for " - + getConnectorAndParentInfo(connector) - + " as it is not visible"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger() + .log(Level.FINE, + "cleanConnectorMap removed state for {0} as it is not visible", + getConnectorAndParentInfo(connector)); + } } } @@ -335,9 +349,8 @@ public class ConnectorTracker implements Serializable { if (getLogger().isLoggable(Level.FINE)) { if (!dirtyConnectors.contains(connector)) { - getLogger().fine( - getConnectorAndParentInfo(connector) + " " - + "is now dirty"); + getLogger().log(Level.FINE, "{0} is now dirty", + getConnectorAndParentInfo(connector)); } } @@ -353,9 +366,8 @@ public class ConnectorTracker implements Serializable { public void markClean(ClientConnector connector) { if (getLogger().isLoggable(Level.FINE)) { if (dirtyConnectors.contains(connector)) { - getLogger().fine( - getConnectorAndParentInfo(connector) + " " - + "is no longer dirty"); + getLogger().log(Level.FINE, "{0} is no longer dirty", + getConnectorAndParentInfo(connector)); } } diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 32c5712f0f..a6dbea51ba 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -75,7 +75,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, /** * Set of expanded nodes. */ - private final HashSet<Object> expanded = new HashSet<Object>(); + private HashSet<Object> expanded = new HashSet<Object>(); /** * List of action handlers. @@ -845,9 +845,20 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, newDataSource)); } - // Ensure previous expanded items are cleaned up if they don't exist in - // the new container - cleanupExpandedItems(); + /* + * Ensure previous expanded items are cleaned up if they don't exist in + * the new container + */ + if (expanded != null) { + /* + * We need to check that the expanded-field is not null since + * setContainerDataSource() is called from the parent constructor + * (AbstractSelect()) and at that time the expanded field is not yet + * initialized. + */ + cleanupExpandedItems(); + } + } /* Expand event and listener */ @@ -1652,7 +1663,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, target.addAttribute("depth", depthToCheck); target.addAttribute("key", key(rootId)); } - } /** @@ -1677,24 +1687,16 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, return itemDescriptionGenerator; } - @Override - public void containerItemSetChange( - com.vaadin.data.Container.ItemSetChangeEvent event) { - - // Ensure removed items are cleaned up from expanded list - cleanupExpandedItems(); - - super.containerItemSetChange(event); - } - private void cleanupExpandedItems() { + Set<Object> removedItemIds = new HashSet<Object>(); for (Object expandedItemId : expanded) { if (getItem(expandedItemId) == null) { - expanded.remove(expandedItemId); + removedItemIds.add(expandedItemId); if (this.expandedItemId == expandedItemId) { this.expandedItemId = null; } } } + expanded.removeAll(removedItemIds); } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 7e54aa01a0..d12c8d89c9 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -43,6 +43,7 @@ import com.vaadin.shared.ui.ui.ScrollClientRpc; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIServerRpc; import com.vaadin.shared.ui.ui.UIState; +import com.vaadin.ui.Component.Focusable; import com.vaadin.util.CurrentInstance; /** |