Add buttons to follow and open in browser to show tab

This commit is contained in:
0xboobface 2018-10-30 19:07:10 +01:00
parent b476c452ad
commit 3d245d6515
1 changed files with 50 additions and 22 deletions

View File

@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.AutosizeAlert;
import ctbrec.ui.DesktopIntergation;
import ctbrec.ui.TabSelectionListener;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
@ -175,11 +176,41 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
grid.add(createLabel("End", true), 0, 1);
grid.add(createLabel(formatter.format(endTime), false), 1, 1);
Button record = new Button("Record Model");
record.setOnAction((evt) -> record(model));
grid.add(record, 1, 2);
GridPane.setMargin(record, new Insets(10));
Button follow = new Button("Follow");
follow.setOnAction((evt) -> follow(model));
grid.add(follow, 1, 3);
GridPane.setMargin(follow, new Insets(10));
Button openInBrowser = new Button("Open in Browser");
openInBrowser.setOnAction((evt) -> DesktopIntergation.open(model.getUrl()));
grid.add(openInBrowser, 1, 4);
GridPane.setMargin(openInBrowser, new Insets(10));
root.setCenter(grid);
loadImage(model, thumb);
record.setOnAction((evt) -> {
record.prefWidthProperty().bind(openInBrowser.widthProperty());
follow.prefWidthProperty().bind(openInBrowser.widthProperty());
}
private void follow(Model model) {
setCursor(Cursor.WAIT);
new Thread(() -> {
try {
model.follow();
} catch (Exception e) {
LOG.error("Couldn't follow model {}", model, e);
showErrorDialog("Oh no!", "Couldn't follow model", e.getMessage());
} finally {
Platform.runLater(() -> {
setCursor(Cursor.DEFAULT);
});
}
}).start();
}
private void record(Model model) {
setCursor(Cursor.WAIT);
new Thread(() -> {
try {
@ -192,9 +223,6 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
});
}
}).start();
});
loadImage(model, thumb);
}
private void loadImage(Model model, ImageView thumb) {