title: GlazedList: using the set method to update eventlist displayed in table removes table selection
body: <p>I am using GlazedList with JFX TableView.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>TableView&lt;Person&gt; table = new TableView&lt;Person&gt;();
  table.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );
  EventList&lt;Person&gt; person_list = new BasicEventList&lt;Person&gt;();
  Map&lt;int, Person&gt; map;
  
  public void updatePerson(Person p){
    int personID = p.getID();
    int index = person_list.indexOf( map.get(personID) );
  
    Person person = person_list.get(index);
    person.setFirstName(p.getFirstName());
    person.setLastName(p.getLastName());
  
    person_list.set(index, person);
  }
  </code></pre>
  
  <p>Problem:
  When selecting multiple rows in the table, and the method updatePerson is called, after "person_list.set(index, person);" is called, all my table selection except for the last selected row are un-selected.</p>
  
  <p>When is "updatePerson" called?
  This method is called every time my back-end receives an update and push this updated value to my front-end. It happens periodically every few seconds.</p>
  
  <p>What i wish to achieve:
  When user selects multiple row, the table will continue to reflect the updated values without deselecting my selected rows.</p>
  
  <p>EDIT:
  The following is a sample code i used to test.</p>
  
  <pre><code>public class ObservableJFXTableView extends Application {
      private final TableView&lt;Person&gt; table = new TableView&lt;&gt;();
      private FilterMatcherEditor filterMatcherEditor = new FilterMatcherEditor();
  
      private EventList&lt;Person&gt; people;
      private ObservableList&lt;Person&gt; data;
      final HBox hb = new HBox();
  
      public static void main(String[] args){
          launch(args);
      }
  
      private void setupGlazedList(){
          people = new BasicEventList&lt;Person&gt;();
  
          ObservableElementList.Connector&lt;Person&gt; personCOnnector = GlazedLists.beanConnector(Person.class);
          EventList&lt;Person&gt; observedPeople = new ObservableElementList&lt;Person&gt;(people, personConnector);
  
          EventList&lt;Person&gt; filtered_list = new FilterList&lt;Person(observedPeople, filterMatcherEditor);
          data = new EventObservableList&lt;Person&gt;(filtered_list);
      }
  
      private void populatedList(){
          people.add(new Person("Jacob", "Smith", "a@example.com"));
          people.add(new Person("James", "Johnson", "b@example.com"));
          people.add(new Person("Christopher", "Lim", "c@example.com"));
          people.add(new Person("Emma", "Jones", "d@example.com"));
          people.add(new Person("Michael", "Brown", "a@example.com"));
      }
  
      @Override
      public void start(Stage stage){
          Scene scene = new Scene(new Group());
          stage.setTitle("Table View Example");
          stage.setWidth(450);
          stage.setHeight(550);
  
          final Label label = new Label("Address Book");
          label.setFont(new Font("Arial"), 20);
  
          table.setEditable(true);
          table.getSelectionModel().setSeletionMode(SelectionMode.MULTIPLE);
  
          TableColumn&lt;Person, String&gt; firstNameCol = new TableColumn&lt;&gt;("First Name");
          firstNameCol.setMinWidth(100);
          firstNameCol.setCellValueFactory(new PropertyValueFactory&lt;&gt;("firstName"));
  
          TableColumn&lt;Person, String&gt; lastNameCol = new TableColumn&lt;&gt;("Last Name");
          lastNameCol.setMinWidth(100);
          lastNameCol.setCellValueFactory(new PropertyValueFactory&lt;&gt;("lastName"));
  
          TableColumn&lt;Person, String&gt; emailCol = new TableColumn&lt;&gt;("Email");
          emailCol.setMinWidth(100);
          emailCol.setCellValueFactory(new PropertyValueFactory&lt;&gt;("email"));
  
          setupGlazedList();
          populatedList();
  
          table.setItems(data);
          table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
  
          final Button editButton = new Button("Edit -&gt; people.get(2)");
          editButton.setOnAction((ActionEvent e) -&gt; {
              people.get(2).setFirstName("NewFirst");
              people.get(2).setLastName("NewLast");
              people.get(2).setEmail("NewEmail");
          });
  
          hb.getChildren().add(editButton);
          hb.setSpacing(3);
  
          final VBox vbox = new VBox();
          vbox.setSpaceing(5);
          vbox.setPadding(new Insets(10,0,0,10));
          vbox.getChildren().addAll(filterMatcherEditor.getTextField(), label, table, hb);
  
          ((Group) scene.getRoot()).getChildren().addAll(vbox);
  
          stage.setScene(scene);
          stage.show();
      }
  
      private static class FilterMatcherEditor extends AbstractMatcherEditor&lt;Person&gt;{
          private TextField tf;
  
          public FilterMatcherEditor(){
              tf = new TextField();
              tf.textProperty().addListener((observable, oldValue, newValue) -&gt; filterChanged());
          }
  
          public TextField getTextField(){
              return tf;
          }
  
          public void filterChanged(){
              if (tf.getText().isEmpty())
                  this.fireMatchAll();
              else
                  this.fireChanged(new FilterMatcher(tf.getText()));
          }
  
          private static class FilterMatcher implements Matcher {
              private final String textFieldInput;
  
              public FilterMatcher(String text){
                  this.textFieldInput = text;
              }
  
              public boolean matched(Object obj){
                  final Person person = (Person) obj;
  
                  for (Object obj: person.getAll()){
                      String str = ((String) obj).toUpperCase();
                      if ( str.contains(textFieldInput.toUpperCase()))
                          return true;
                  }
                  return false;
              }
          }
      }
  
      public class Person {
          private final SimpleStringProperty firstName;
          private final SimpleStringProeprty lastName;
          private final SimpleStringProperty email;
  
          private final PropertyChangeSupport support = new PropertyChangeSupport(this);
  
          private Person(String fName, String lName, String email){
              this.firstName = new SimpleStringProperty(fName);
              this.lastName = new SimpleStringProperty(lName);
              this.email = new SimpleStringProperty(email);
          }
  
          public void addPropertyChangeListener(PropertyChangeListener l){
              support.addPropertyChangeListener(l);
          }
          public void removePropertyChangeListener(PropertyChangeListener l){
              support.removePropertyChangeListener(l);
          }
  
          public String getFirstName(){
              return firstName.get();
          }
          public void setFirstName(String str){
              final String old = firstName.get();
              firstName.set(str);
              support.firePropertyCHange("firstName", old, str);
          }
  
          public String getLastName(){
              return lastName.get();
          }
          public void setLastName(String str){
              final String old = lastName.get();
              lastName.set(str);
              support.firePropertyCHange("lastName", old, str);
          }
  
          public String getEmail(){
              return email.get();
          }
          public void setEmail(String str){
              final String old = email.get();
              email.set(str);
              support.firePropertyCHange("email", old, str);
          }
  
          public List&lt;String&gt; getAll(){
              List&lt;String&gt; strList = new ArrayList&lt;String&gt;();
              strList.add(firstName.get());
              strList.add(lastName.get());
              strList.add(email.get());
  
              return strList;
          }
      }
  }
  </code></pre>
  
  <p>Try using shift click to select multiple row, then click on the edit button, the 3rd row will be updated but all multiple selected rows will be unselected, except for one row.</p>