]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add getters for providers to Tree and TreeGrid
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 17 May 2017 08:26:59 +0000 (11:26 +0300)
committerHenri Sara <henri.sara@gmail.com>
Wed, 17 May 2017 11:29:18 +0000 (14:29 +0300)
server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
server/src/main/java/com/vaadin/ui/Tree.java
server/src/main/java/com/vaadin/ui/TreeGrid.java

index ce6f7db13e2226d82ed6961e9c3c1f08f5a0b6cc..ca8ccc89dda36e929ba4caeb8a8da75d82b37cb7 100644 (file)
@@ -79,8 +79,7 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
      */
     public HierarchicalDataCommunicator() {
         super();
-        dataProvider = new TreeDataProvider<>(
-                new TreeData<>());
+        dataProvider = new TreeDataProvider<>(new TreeData<>());
     }
 
     @Override
@@ -226,24 +225,29 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
 
         JsonObject hierarchyData = Json.createObject();
         if (depth != -1) {
-            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_DEPTH, depth);
+            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_DEPTH,
+                    depth);
         }
 
         boolean isLeaf = !getDataProvider().hasChildren(item);
         if (isLeaf) {
-            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF, true);
+            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF,
+                    true);
         } else {
             String key = getKeyMapper().key(item);
-            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_COLLAPSED,
+            hierarchyData.put(
+                    HierarchicalDataCommunicatorConstants.ROW_COLLAPSED,
                     mapper.isCollapsed(key));
-            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF, false);
+            hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_LEAF,
+                    false);
             hierarchyData.put(
                     HierarchicalDataCommunicatorConstants.ROW_COLLAPSE_ALLOWED,
                     itemCollapseAllowedProvider.test(item));
         }
 
         // add hierarchy information to row as metadata
-        dataObject.put(HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION,
+        dataObject.put(
+                HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION,
                 hierarchyData);
 
         return dataObject;
@@ -386,8 +390,7 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
         }
         int collapsedSubTreeSize = mapper.collapse(collapsedRowKey,
                 collapsedRowIndex);
-        getClientRpc().removeRows(collapsedRowIndex + 1,
-                collapsedSubTreeSize);
+        getClientRpc().removeRows(collapsedRowIndex + 1, collapsedSubTreeSize);
 
         // FIXME seems like a slight overkill to do this just for refreshing
         // expanded status
@@ -435,8 +438,10 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
                 expandedNodeSize);
         rowKeysPendingExpand.remove(expandedRowKey);
 
-        boolean success = doPushRows(Range.withLength(expandedRowIndex + 1,
-                Math.min(expandedNodeSize, latestCacheSize)), expandedNodeSize);
+        boolean success = doPushRows(
+                Range.withLength(expandedRowIndex + 1,
+                        Math.min(expandedNodeSize, latestCacheSize)),
+                expandedNodeSize);
 
         if (success) {
             // FIXME seems like a slight overkill to do this just for refreshing
@@ -531,10 +536,20 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
     /**
      * Returns parent index for the row or {@code null}
      *
-     * @param rowIndex the row index
+     * @param rowIndex
+     *            the row index
      * @return the parent index or {@code null} for top-level items
      */
     public Integer getParentIndex(int rowIndex) {
         return mapper.getParentIndex(rowIndex);
     }
+
+    /**
+     * Gets the item collapse allowed provider.
+     * 
+     * @return the item collapse allowed provider
+     */
+    public ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider() {
+        return itemCollapseAllowedProvider;
+    }
 }
index 85a9e3a615cc9902878697f42fb307fe6df0c273..4ddd74caa49b13dd15bd6e4c470692988cfe15d1 100644 (file)
@@ -539,6 +539,46 @@ public class Tree<T> extends Composite
         treeGrid.setStyleGenerator(styleGenerator);
     }
 
+    /**
+     * Gets the item caption generator.
+     *
+     * @return the item caption generator
+     */
+    public ItemCaptionGenerator<T> getItemCaptionGenerator() {
+        return captionGenerator;
+    }
+
+    /**
+     * Gets the item icon generator.
+     *
+     * @see IconGenerator
+     *
+     * @return the item icon generator
+     */
+    public IconGenerator<T> getItemIconGenerator() {
+        return iconProvider;
+    }
+
+    /**
+     * Gets the item collapse allowed provider.
+     * 
+     * @return the item collapse allowed provider
+     */
+    public ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider() {
+        return treeGrid.getItemCollapseAllowedProvider();
+    }
+
+    /**
+     * Gets the style generator.
+     * 
+     * @see StyleGenerator
+     *
+     * @return the item style generator
+     */
+    public StyleGenerator<T> getStyleGenerator() {
+        return treeGrid.getStyleGenerator();
+    }
+
     /**
      * Adds an item click listener. The listener is called when an item of this
      * {@code Tree} is clicked.
index e526f3b7cdb11fc5745afc275776f1f32f153e11..b73794e25acd5130f23c0e9d6e1999b2b231ef8f 100644 (file)
@@ -548,4 +548,13 @@ public class TreeGrid<T> extends Grid<T>
     private void fireCollapseEvent(T item, boolean userOriginated) {
         fireEvent(new CollapseEvent<>(this, item, userOriginated));
     }
+
+    /**
+     * Gets the item collapse allowed provider.
+     * 
+     * @return the item collapse allowed provider
+     */
+    public ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider() {
+        return getDataCommunicator().getItemCollapseAllowedProvider();
+    }
 }