vaadin / vaadin/framework

Sortable TwinColSelect

Open
#2,254 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Originally by eperchuk


Hi,

I have created a widget that extends your TwinColSelect control (v6.7.5), adding two buttons to the right of the selections box which allow them to be re-ordered. I have also added some additional functionality to the TwinColSelect control:

  1. optionally allowing for duplicate selections - in this case the items are never removed from the options box and can be selected as many times as desired
  2. optionally maintaining the initial option order - by default, if an option is selected and then removed, it returns to the bottom of the options list. If this option is enabled, an option will return to it's original location in the options window after being unselected.

However, in order to provide this functionality, I had to make modifications to some of your classes:
AbstractSelect
TwinColSelect
VOptionGroupBase
VTwinColSelect

The reason these modifications were needed is because AbstractSelect and VOptionGroupBase store the selections using a Set, which does not allow storing duplicate values, but more importantly, does not maintain order. I have introduced the idea of setting a "Collection Strategy" into AbstractSelect. By default, AbstractSelect still uses a HashSet implementation, but controls that subclass AbstractSelect can specify they would like to use a different Collection type (i.e. an ArrayList). I would greatly appreciate it if you would take a look at the modifications I have made to your code and consider integrating them into a future release of Vaadin. I have attached all the necessary code for my widget. Let me know if you have any questions.

Thank you,[[br]]
Eric Perchuk[[br]]
Software Engineer[[br]]
NYSE Euronext


Imported from https://dev.vaadin.com/ issue #8592

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 reviewing the proposed changes to AbstractSelect, TwinColSelect, VOptionGroupBase, and VTwinColSelect, along with the attached widget code. Compare the collection-strategy changes with the existing selection behavior, then verify that sorting, duplicate selections, and restoration of the initial option order are all covered before considering integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.