summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2017-05-17 11:26:59 +0300
committerHenri Sara <henri.sara@gmail.com>2017-05-17 14:29:18 +0300
commit21c54c9228a63ac6c199b0a70603a72f6041586a (patch)
treefb7d9e158af86ceecfdbdab631222f6dbbf7a09b /server
parent6b3482da66bb6781128fd2d34adec3655617fb6c (diff)
downloadvaadin-framework-21c54c9228a63ac6c199b0a70603a72f6041586a.tar.gz
vaadin-framework-21c54c9228a63ac6c199b0a70603a72f6041586a.zip
Add getters for providers to Tree and TreeGrid
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java39
-rw-r--r--server/src/main/java/com/vaadin/ui/Tree.java40
-rw-r--r--server/src/main/java/com/vaadin/ui/TreeGrid.java9
3 files changed, 76 insertions, 12 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
index ce6f7db13e..ca8ccc89dd 100644
--- a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
+++ b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
@@ -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;
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java
index 85a9e3a615..4ddd74caa4 100644
--- a/server/src/main/java/com/vaadin/ui/Tree.java
+++ b/server/src/main/java/com/vaadin/ui/Tree.java
@@ -540,6 +540,46 @@ public class Tree<T> extends Composite
}
/**
+ * 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.
*
diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java
index e526f3b7cd..b73794e25a 100644
--- a/server/src/main/java/com/vaadin/ui/TreeGrid.java
+++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java
@@ -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();
+ }
}