forked from j62/ctbrec
Add "Ignore" to context menu of RecordedModelsTab
This commit is contained in:
parent
90cb08a3cc
commit
dbeb814465
|
@ -1,5 +1,7 @@
|
||||||
package ctbrec.ui.controls;
|
package ctbrec.ui.controls;
|
||||||
|
|
||||||
|
import static javafx.scene.control.ButtonType.*;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -8,6 +10,7 @@ import javafx.application.Platform;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Alert.AlertType;
|
||||||
import javafx.scene.control.ButtonType;
|
import javafx.scene.control.ButtonType;
|
||||||
import javafx.scene.control.Dialog;
|
import javafx.scene.control.Dialog;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
|
@ -28,18 +31,18 @@ public class Dialogs {
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
alert.setHeaderText(header);
|
alert.setHeaderText(header);
|
||||||
String content = text;
|
String content = text;
|
||||||
if(t != null) {
|
if (t != null) {
|
||||||
content += " " + t.getLocalizedMessage();
|
content += " " + t.getLocalizedMessage();
|
||||||
}
|
}
|
||||||
alert.setContentText(content);
|
alert.setContentText(content);
|
||||||
if(parent != null) {
|
if (parent != null) {
|
||||||
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
|
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
|
||||||
stage.getScene().getStylesheets().addAll(parent.getStylesheets());
|
stage.getScene().getStylesheets().addAll(parent.getStylesheets());
|
||||||
}
|
}
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
};
|
};
|
||||||
|
|
||||||
if(Platform.isFxApplicationThread()) {
|
if (Platform.isFxApplicationThread()) {
|
||||||
r.run();
|
r.run();
|
||||||
} else {
|
} else {
|
||||||
Platform.runLater(r);
|
Platform.runLater(r);
|
||||||
|
@ -56,7 +59,7 @@ public class Dialogs {
|
||||||
InputStream icon = Dialogs.class.getResourceAsStream("/icon.png");
|
InputStream icon = Dialogs.class.getResourceAsStream("/icon.png");
|
||||||
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
||||||
stage.getIcons().add(new Image(icon));
|
stage.getIcons().add(new Image(icon));
|
||||||
if(parent != null) {
|
if (parent != null) {
|
||||||
stage.getScene().getStylesheets().addAll(parent.getStylesheets());
|
stage.getScene().getStylesheets().addAll(parent.getStylesheets());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,4 +84,12 @@ public class Dialogs {
|
||||||
|
|
||||||
return dialog.showAndWait();
|
return dialog.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean showConfirmDialog(String title, String message, String header, Scene parent) {
|
||||||
|
AutosizeAlert confirm = new AutosizeAlert(AlertType.CONFIRMATION, message, parent, YES, NO);
|
||||||
|
confirm.setTitle(title);
|
||||||
|
confirm.setHeaderText(header);
|
||||||
|
confirm.showAndWait();
|
||||||
|
return confirm.getResult() == ButtonType.YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,6 +610,8 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
switchStreamSource.setOnAction(e -> switchStreamSource(selectedModels.get(0)));
|
switchStreamSource.setOnAction(e -> switchStreamSource(selectedModels.get(0)));
|
||||||
MenuItem follow = new MenuItem("Follow");
|
MenuItem follow = new MenuItem("Follow");
|
||||||
follow.setOnAction(e -> follow(selectedModels));
|
follow.setOnAction(e -> follow(selectedModels));
|
||||||
|
MenuItem ignore = new MenuItem("Ignore");
|
||||||
|
ignore.setOnAction(e -> ignore(selectedModels));
|
||||||
MenuItem notes = new MenuItem("Notes");
|
MenuItem notes = new MenuItem("Notes");
|
||||||
notes.setOnAction(e -> notes(selectedModels));
|
notes.setOnAction(e -> notes(selectedModels));
|
||||||
MenuItem openRecDir = new MenuItem("Open recording directory");
|
MenuItem openRecDir = new MenuItem("Open recording directory");
|
||||||
|
@ -621,7 +623,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
} else {
|
} else {
|
||||||
menu.getItems().addAll(resumeRecording, pauseRecording);
|
menu.getItems().addAll(resumeRecording, pauseRecording);
|
||||||
}
|
}
|
||||||
menu.getItems().addAll(copyUrl, openInPlayer, openInBrowser, openRecDir, switchStreamSource, follow, notes);
|
menu.getItems().addAll(copyUrl, openInPlayer, openInBrowser, openRecDir, switchStreamSource, follow, notes, ignore);
|
||||||
|
|
||||||
if (selectedModels.size() > 1) {
|
if (selectedModels.size() > 1) {
|
||||||
copyUrl.setDisable(true);
|
copyUrl.setDisable(true);
|
||||||
|
@ -634,6 +636,17 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ignore(ObservableList<JavaFxModel> selectedModels) {
|
||||||
|
for (JavaFxModel fxModel : selectedModels) {
|
||||||
|
Model modelToIgnore = fxModel.getDelegate();
|
||||||
|
Config.getInstance().getSettings().modelsIgnored.add(modelToIgnore);
|
||||||
|
}
|
||||||
|
boolean removeAsWell = Dialogs.showConfirmDialog("Ignore Model", null, "Remove as well?", getTabPane().getScene());
|
||||||
|
if (removeAsWell) {
|
||||||
|
stopAction(selectedModels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void follow(ObservableList<JavaFxModel> selectedModels) {
|
private void follow(ObservableList<JavaFxModel> selectedModels) {
|
||||||
new FollowAction(getTabPane(), new ArrayList<JavaFxModel>(selectedModels)).execute();
|
new FollowAction(getTabPane(), new ArrayList<JavaFxModel>(selectedModels)).execute();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue