Add radiobuttons to switch between online/offline models

CTB seems to split up the followed tab between online and offline
models. This change adds radiobuttons at the bottom of the followed tab
to switch between online and offline models.
This commit is contained in:
0xboobface 2018-10-03 13:37:08 +02:00
parent 4cbb855bc6
commit 530ce820d5
2 changed files with 40 additions and 2 deletions

View File

@ -1,20 +1,56 @@
package ctbrec.ui;
import javafx.concurrent.WorkerStateEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.HBox;
public class FollowedTab extends ThumbOverviewTab {
private Label status;
private String onlineUrl;
private String offlineUrl;
public FollowedTab(String title, String url) {
super(title, url, true);
onlineUrl = url;
offlineUrl = url + "offline/";
status = new Label("Logging in...");
grid.getChildren().add(status);
}
@Override
void createGui() {
super.createGui();
addOnlineOfflineSelector();
}
private void addOnlineOfflineSelector() {
ToggleGroup group = new ToggleGroup();
RadioButton online = new RadioButton("online");
online.setToggleGroup(group);
RadioButton offline = new RadioButton("offline");
offline.setToggleGroup(group);
pagination.getChildren().add(online);
pagination.getChildren().add(offline);
HBox.setMargin(online, new Insets(5,5,5,40));
HBox.setMargin(offline, new Insets(5,5,5,5));
online.setSelected(true);
group.selectedToggleProperty().addListener((e) -> {
if(online.isSelected()) {
super.url = onlineUrl;
} else {
super.url = offlineUrl;
}
updateService.restart();
});
}
@Override
protected void onSuccess() {
grid.getChildren().remove(status);

View File

@ -78,6 +78,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
String url;
boolean loginRequired;
HttpClient client = HttpClient.getInstance();
HBox pagination;
int page = 1;
TextField pageInput = new TextField(Integer.toString(page));
Button pagePrev = new Button("");
@ -96,7 +97,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
initializeUpdateService();
}
private void createGui() {
void createGui() {
grid.setPadding(new Insets(5));
grid.setHgap(5);
grid.setVgap(5);
@ -108,6 +109,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
gridLock.lock();
try {
filter();
moveActiveRecordingsToFront();
} finally {
gridLock.unlock();
}
@ -124,7 +126,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
scrollPane.setFitToWidth(true);
BorderPane.setMargin(scrollPane, new Insets(5));
HBox pagination = new HBox(5);
pagination = new HBox(5);
pagination.getChildren().add(pagePrev);
pagination.getChildren().add(pageNext);
pagination.getChildren().add(pageInput);