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:
parent
4cbb855bc6
commit
530ce820d5
|
@ -1,20 +1,56 @@
|
||||||
package ctbrec.ui;
|
package ctbrec.ui;
|
||||||
|
|
||||||
import javafx.concurrent.WorkerStateEvent;
|
import javafx.concurrent.WorkerStateEvent;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.RadioButton;
|
||||||
|
import javafx.scene.control.ToggleGroup;
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
|
||||||
public class FollowedTab extends ThumbOverviewTab {
|
public class FollowedTab extends ThumbOverviewTab {
|
||||||
private Label status;
|
private Label status;
|
||||||
|
private String onlineUrl;
|
||||||
|
private String offlineUrl;
|
||||||
|
|
||||||
public FollowedTab(String title, String url) {
|
public FollowedTab(String title, String url) {
|
||||||
super(title, url, true);
|
super(title, url, true);
|
||||||
|
onlineUrl = url;
|
||||||
|
offlineUrl = url + "offline/";
|
||||||
|
|
||||||
status = new Label("Logging in...");
|
status = new Label("Logging in...");
|
||||||
grid.getChildren().add(status);
|
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
|
@Override
|
||||||
protected void onSuccess() {
|
protected void onSuccess() {
|
||||||
grid.getChildren().remove(status);
|
grid.getChildren().remove(status);
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
String url;
|
String url;
|
||||||
boolean loginRequired;
|
boolean loginRequired;
|
||||||
HttpClient client = HttpClient.getInstance();
|
HttpClient client = HttpClient.getInstance();
|
||||||
|
HBox pagination;
|
||||||
int page = 1;
|
int page = 1;
|
||||||
TextField pageInput = new TextField(Integer.toString(page));
|
TextField pageInput = new TextField(Integer.toString(page));
|
||||||
Button pagePrev = new Button("◀");
|
Button pagePrev = new Button("◀");
|
||||||
|
@ -96,7 +97,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
initializeUpdateService();
|
initializeUpdateService();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGui() {
|
void createGui() {
|
||||||
grid.setPadding(new Insets(5));
|
grid.setPadding(new Insets(5));
|
||||||
grid.setHgap(5);
|
grid.setHgap(5);
|
||||||
grid.setVgap(5);
|
grid.setVgap(5);
|
||||||
|
@ -108,6 +109,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
gridLock.lock();
|
gridLock.lock();
|
||||||
try {
|
try {
|
||||||
filter();
|
filter();
|
||||||
|
moveActiveRecordingsToFront();
|
||||||
} finally {
|
} finally {
|
||||||
gridLock.unlock();
|
gridLock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +126,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
scrollPane.setFitToWidth(true);
|
scrollPane.setFitToWidth(true);
|
||||||
BorderPane.setMargin(scrollPane, new Insets(5));
|
BorderPane.setMargin(scrollPane, new Insets(5));
|
||||||
|
|
||||||
HBox pagination = new HBox(5);
|
pagination = new HBox(5);
|
||||||
pagination.getChildren().add(pagePrev);
|
pagination.getChildren().add(pagePrev);
|
||||||
pagination.getChildren().add(pageNext);
|
pagination.getChildren().add(pageNext);
|
||||||
pagination.getChildren().add(pageInput);
|
pagination.getChildren().add(pageInput);
|
||||||
|
|
Loading…
Reference in New Issue