use of javafx.fxml.FXMLLoader in project Retrospector by NonlinearFruit.
the class SearchTabController method initSearchTab.
private void initSearchTab() {
searchEditMedia.setDisable(true);
searchDeleteMedia.setDisable(true);
// Table Double Click
searchTable.setRowFactory(tv -> {
TableRow<Media> row = new TableRow<>();
row.setOnMouseClicked(event -> {
if (event.getClickCount() == 2 && (!row.isEmpty())) {
setMedia(row.getItem());
setTab(TAB.MEDIA);
}
});
return row;
});
// Table data setup
searchTableData = DataManager.getMedia();
FilteredList<Media> mediaFiltered = new FilteredList(searchTableData, x -> true);
SortedList<Media> mediaSortable = new SortedList<>(mediaFiltered);
searchTable.setItems(mediaSortable);
mediaSortable.comparatorProperty().bind(searchTable.comparatorProperty());
// Link to data properties
searchTitleColumn.setCellValueFactory(new PropertyValueFactory<>("Title"));
searchCreatorColumn.setCellValueFactory(new PropertyValueFactory<>("Creator"));
searchSeasonColumn.setCellValueFactory(new PropertyValueFactory<>("SeasonId"));
searchEpisodeColumn.setCellValueFactory(new PropertyValueFactory<>("EpisodeId"));
searchCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("Category"));
// Values for special columns
searchNumberColumn.setSortable(false);
searchNumberColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + searchTable.getItems().indexOf(p.getValue())));
searchReviewsColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, Integer>, ObservableValue<Integer>>() {
@Override
public ObservableValue<Integer> call(TableColumn.CellDataFeatures<Media, Integer> p) {
return new ReadOnlyObjectWrapper(p.getValue().getReviews().size());
}
});
searchMeanRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {
@Override
public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
return new ReadOnlyObjectWrapper(p.getValue().getAverageRating());
}
});
searchCurrentRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {
@Override
public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
return new ReadOnlyObjectWrapper(p.getValue().getCurrentRating());
}
});
// Comparators for string columns
searchTitleColumn.setComparator(new NaturalOrderComparator());
searchCreatorColumn.setComparator(new NaturalOrderComparator());
searchSeasonColumn.setComparator(new NaturalOrderComparator());
searchEpisodeColumn.setComparator(new NaturalOrderComparator());
searchCategoryColumn.setComparator(new NaturalOrderComparator());
searchTable.getSelectionModel().selectedItemProperty().addListener((observe, old, neo) -> {
setMedia(neo);
});
searchBox.textProperty().addListener((observa, old, neo) -> {
String query = neo;
if (query == null || query.equals(""))
mediaFiltered.setPredicate(x -> true);
else {
String[] queries = query.split(":");
mediaFiltered.setPredicate(x -> QueryProcessor.isMatchForMedia(query, x));
}
updateStats();
});
// Buttons
searchNewMedia.setOnAction(e -> {
Media neo = new Media();
neo.setId(DataManager.createDB(neo));
setMedia(neo);
setTab(TAB.MEDIA);
});
searchQuickEntry.setOnAction(e -> {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("QuickEntry.fxml"));
Parent root1 = (Parent) fxmlLoader.load();
QuickEntryController qec = fxmlLoader.getController();
qec.setup(currentTab);
Stage stage = new Stage();
stage.setTitle("Quick Entry");
stage.setScene(new Scene(root1));
stage.show();
} catch (Exception ex) {
}
});
searchStandardEntry.setOnAction(e -> {
Media neo = new Media();
neo.setId(DataManager.createDB(neo));
setMedia(neo);
setTab(TAB.MEDIA);
});
searchBackup.setOnAction(e -> DataManager.makeBackup());
searchCheatsheet.setOnAction(e -> {
new Cheatsheet().start(new Stage());
});
searchEditMedia.setOnAction(e -> {
setTab(TAB.MEDIA);
});
searchDeleteMedia.setOnAction(e -> {
if (new Alert(Alert.AlertType.WARNING, "Are you sure you want to delete this?", ButtonType.NO, ButtonType.YES).showAndWait().get().equals(ButtonType.YES)) {
DataManager.deleteDB(getMedia());
updateSearchTab();
}
});
// Init stuff
updateStats();
}
use of javafx.fxml.FXMLLoader in project Retrospector by NonlinearFruit.
the class Retrospector method start.
@Override
public void start(final Stage initStage) throws Exception {
final Task<Parent> task = new Task<Parent>() {
@Override
protected Parent call() throws InterruptedException, IOException {
updateProgress(0, 8);
updateMessage("Loading Database . . .");
DataManager.startDB();
updateProgress(1, 8);
updateMessage("Loading Core . . .");
FXMLLoader ldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/Core.fxml"));
Parent root = ldr.load();
CoreController core = ldr.getController();
updateProgress(2, 8);
updateMessage("Loading Search . . .");
FXMLLoader searchldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/search/SearchTab.fxml"));
searchldr.load();
core.setSearchController(searchldr);
updateProgress(3, 8);
updateMessage("Loading Media . . .");
FXMLLoader medialdr = new FXMLLoader(getClass().getResource("/retrospector/fxml/media/MediaTab.fxml"));
medialdr.load();
core.setMediaController(medialdr);
updateProgress(4, 8);
updateMessage("Loading Review . . .");
FXMLLoader reviewldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/ReviewTab.fxml"));
reviewldr.load();
core.setReviewController(reviewldr);
updateProgress(5, 8);
updateMessage("Loading Chart . . .");
FXMLLoader statldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/chart/StatsTab.fxml"));
statldr.load();
core.setStatsController(statldr);
updateProgress(6, 8);
updateMessage("Loading List . . .");
FXMLLoader listldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/ListsTab.fxml"));
listldr.load();
core.setListController(listldr);
updateProgress(7, 8);
updateMessage("Loading Achievements . . .");
FXMLLoader achieveldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/achievements/AchievementTab.fxml"));
achieveldr.load();
core.setAchieveController(achieveldr);
updateProgress(8, 8);
updateMessage("Done!");
return root;
}
};
showSplash(initStage, task, () -> showMainStage(task.valueProperty().get()));
new Thread(task).start();
}
use of javafx.fxml.FXMLLoader in project aic-praise by aic-sri-international.
the class HOGMPageEditorController method initialize.
// END-ModelPageEditor
//
@FXML
private void initialize() throws IOException {
FXUtil.anchor(modelCodeArea);
modelEditorPane.getChildren().add(modelCodeArea);
FXMLLoader queryLoader = QueryController.newLoader();
Pane queryPane = queryLoader.load();
queryController = queryLoader.getController();
queryController.setModelPageEditor(this);
FXUtil.anchor(queryPane);
queryOutputPane.getChildren().add(queryPane);
}
use of javafx.fxml.FXMLLoader in project aic-praise by aic-sri-international.
the class HOGMPerspective method create.
@Override
protected ModelPageEditor create(String model, List<String> defaultQueries) {
ModelPageEditor result = null;
FXMLLoader loader = HOGMPageEditorController.newLoader();
try {
loader.load();
result = loader.getController();
result.setPage(model, defaultQueries);
} catch (Throwable t) {
FXUtil.exception(t);
}
return result;
}
use of javafx.fxml.FXMLLoader in project aic-praise by aic-sri-international.
the class SGSolverDemoApp method start.
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader rootLoader = new FXMLLoader(getClass().getResource("sgsolverdemo.fxml"));
Parent root = rootLoader.load();
SGSolverDemoController controller = rootLoader.getController();
controller.setMainStage(primaryStage);
Scene scene = new Scene(root, 1024, 768);
primaryStage.setScene(scene);
scene.getStylesheets().add("com/sri/ai/praise/sgsolver/demo/sgsolverdemo.css");
scene.getStylesheets().add(GlyphsStyle.BLUE.getStylePath());
primaryStage.show();
}
Aggregations