Skip to content

Commit

Permalink
make buttons work with grid view
Browse files Browse the repository at this point in the history
  • Loading branch information
s1mpl3x committed Aug 20, 2015
1 parent bf07e55 commit 521ca99
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
14 changes: 6 additions & 8 deletions src/main/java/eu/over9000/skadi/ui/HandlerControlButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,19 @@ public void setDisable(final boolean b) {
openChat.setDisable(b);
}

public void resetQualities() {
public void resetQualities(final Channel candidate) {
openStream.getItems().clear();
openStream.getItems().add(worstItem);

final Channel candidate = table.getSelectionModel().getSelectedItem();

if ((candidate != null) && (candidate.isOnline() != null) && candidate.isOnline()) {
final QualityRetrievalService service = new QualityRetrievalService(this::openStreamWithQuality, candidate);
service.setOnSucceeded(event -> {
if (candidate.equals(table.getSelectionModel().getSelectedItem())) {
openStream.getItems().clear();
openStream.getItems().addAll(service.getValue());
openStream.getItems().add(new SeparatorMenuItem());
openStream.getItems().add(worstItem);
}
openStream.getItems().clear();
openStream.getItems().addAll(service.getValue());
openStream.getItems().add(new SeparatorMenuItem());
openStream.getItems().add(worstItem);

});
service.start();
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/eu/over9000/skadi/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,7 @@ private void setupTable() {
table.setItems(sortedChannelList);

table.getSelectionModel().selectedItemProperty().addListener((obs, oldV, newV) -> {
details.setDisable(newV == null);
remove.setDisable(newV == null);
chatAndStreamButton.setDisable(newV == null);
chatAndStreamButton.resetQualities();
onSelection(newV);
if ((newV == null) && splitPane.getItems().contains(detailPane)) {
doDetailSlide(false);
}
Expand All @@ -515,6 +512,13 @@ private void setupTable() {
});
}

public void onSelection(final Channel channel) {
details.setDisable(channel == null);
remove.setDisable(channel == null);
chatAndStreamButton.setDisable(channel == null);
chatAndStreamButton.resetQualities(channel);
}

public void openDetailPage(final Channel channel) {
if (channel == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public ChannelGridCell(final ChannelGrid grid, final MainWindow mainWindow) {
}
if (event.getButton() == MouseButton.PRIMARY) {
if (event.getClickCount() == 1) {
mainWindow.onSelection(getItem());
updateSelected(true);
grid.select(getItem());
grid.updateItems();
Expand Down

0 comments on commit 521ca99

Please sign in to comment.