package app.lsgui.gui.twitchbrowser;

import org.controlsfx.control.GridView;

import app.lsgui.model.twitch.ITwitchItem;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.scene.control.Tab;

public final class BrowserTab extends Tab {

    private ListProperty<ITwitchItem> items = new SimpleListProperty<>(FXCollections.observableArrayList());
    private ListProperty<ITwitchItem> activeItems = new SimpleListProperty<>(FXCollections.observableArrayList());

    public BrowserTab(final String name) {
        super(name);
        setContent(this.buildGridView());
    }

    public GridView<ITwitchItem> getGridView() {
        return (GridView<ITwitchItem>) getContent();
    }

    private GridView<ITwitchItem> buildGridView() {
        final GridView<ITwitchItem> gridView = new GridView<>();
        gridView.setCellFactory(param -> new TwitchItemPane());
        gridView.setCellWidth(TwitchItemPane.WIDTH);
        gridView.cellHeightProperty().bind(TwitchItemPane.HEIGHT_PROPERTY);
        gridView.itemsProperty().bind(this.activeItemsProperty());
        return gridView;
    }

    public ListProperty<ITwitchItem> itemsProperty() {
        return this.items;
    }

    public ListProperty<ITwitchItem> activeItemsProperty() {
        return this.activeItems;
    }

    public void resetActiveItems() {
        this.activeItemsProperty().set(this.itemsProperty().get());
    }
}

@@ -256,16 +256,59 @@
 tions;%0D%0A
+import javafx.collections.ObservableList;%0D%0A
 import j
@@ -333,16 +333,16 @@
 l.Tab;%0D%0A
-
 %0D%0Apublic
@@ -607,16 +607,68 @@
 ist());%0D
+%0A    private GridView%3CITwitchItem%3E contentGridView;%0D
 %0A%0D%0A    p
@@ -740,39 +740,93 @@
     
-setContent(this.buildGridView()
+this.contentGridView = this.buildGridView();%0D%0A        setContent(this.contentGridView
 );%0D%0A
@@ -903,44 +903,28 @@
 urn 
-(GridView%3CITwitchItem%3E) getContent()
+this.contentGridView
 ;%0D%0A 
@@ -1310,24 +1310,24 @@
 operty());%0D%0A
-
         retu
@@ -1341,32 +1341,342 @@
 View;%0D%0A    %7D%0D%0A%0D%0A
+    public void refresh() %7B%0D%0A        final ObservableList%3CITwitchItem%3E gridViewItems = this.getGridView().getItems();%0D%0A        this.getGridView().itemsProperty().unbind();%0D%0A        this.getGridView().setItems(FXCollections.observableArrayList());%0D%0A        this.getGridView().setItems(gridViewItems);%0D%0A    %7D%0D%0A%0D%0A
     public ListP

add variable for gridview