vaadin / vaadin/framework

scrollTo(int Row, ...) in Tree doesn't expose necessary fields

Open
#10,449 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

(This affects Vaadin version 8.2.0.rc1)

To use the scrollTo method with the tree, the method implementing it needs to be aware of the current integer value of the row being scrolled to, but this isn't exposed by the Tree class.

The necessary information seems to be contained in the com.vaadin.data.provider.HierarchyMapper used by com.vaadin.data.provider.HierarchicalDataCommunicator. This HierarchyMapper field is logically set to private but the getter method is set to protected. As a workaround I created the following class in my project:

package com.vaadin.data.provider;

public class ThesTreeDataCommunicator<T> extends HierarchicalDataCommunicator<T> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	HierarchicalDataCommunicator<T> hier;
	
	public ThesTreeDataCommunicator(HierarchicalDataCommunicator<T> hier) {
		this.hier = hier;
	}
	
	public HierarchyMapper<T,?> getHierarchyMapper(){ 
		return hier.getHierarchyMapper();
	}

}

Further complicating the issue, the DataCommunicator for the Tree class doesn't have a getter either, so to get at the DataCommunicator the Tree has to be cast to a TreeGrid. Having to do this to use a provided method seems a bit counter-intuitive from an implementation standpoint.

As always thanks for your time and effort.

Regards,
Jeffrey

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Tree, TreeGrid, DataCommunicator, HierarchicalDataCommunicator, and HierarchyMapper, focusing on how scrollTo accesses the current row and how the communicator is exposed. Reproduce the limitation against Vaadin 8.2.0.rc1 and determine the supported API needed for Tree scrolling; done means the necessary fields can be accessed without the workaround described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.