use of javafx.beans.property.ReadOnlyObjectWrapper 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.beans.property.ReadOnlyObjectWrapper in project Retrospector by NonlinearFruit.
the class ListsTabController method updateListTab.
private void updateListTab() {
listTableData.clear();
if (!listGroupCreator.isSelected())
return;
boolean creator = listGroupCreator.isSelected();
boolean title = listGroupTitle.isSelected();
boolean season = listGroupSeason.isSelected();
boolean episode = listGroupEpisode.isSelected();
Chartagories chartagory = episode ? Chartagories.CURRENT_MEDIA : season ? Chartagories.SEASON : title ? Chartagories.TITLE : Chartagories.CREATOR;
Integer top = listTop10.isSelected() ? 10 : listTop25.isSelected() ? 25 : listTop50.isSelected() ? 50 : listTop100.isSelected() ? 100 : listTop500.isSelected() ? 500 : 1000;
LocalDate start = listCustomDateRange.isSelected() ? listStartDate.getValue().minus(1, ChronoUnit.DAYS) : LocalDate.of(Integer.parseInt(listYear.getText()) - 1, 12, 31);
start = listUseAllTime.isSelected() ? LocalDate.MIN : start;
LocalDate end = listCustomDateRange.isSelected() ? listEndDate.getValue().plus(1, ChronoUnit.DAYS) : LocalDate.of(Integer.parseInt(listYear.getText()) + 1, 1, 1);
end = listUseAllTime.isSelected() ? LocalDate.MAX : end;
String user = listUser.getText();
for (Media media : DataManager.getMedia()) {
for (Stroolean stroolean : strooleans) {
if (stroolean.isBoolean() && media.getCategory().equals(stroolean.getString())) {
boolean homeless = true;
for (Media data : listTableData) {
Media temp = new Media();
temp.clone(media);
temp.setCategory(data.getCategory());
temp.setType(data.getType());
if (UtilityCloset.isSameMedia(chartagory, data, temp)) {
homeless = false;
for (Review review : media.getReviews()) {
if (review.getDate().isBefore(end) && review.getDate().isAfter(start) && review.getUser().equals(user)) {
data.getReviews().add(review);
}
}
break;
}
}
if (homeless) {
Media m = new Media();
if (creator)
m.setCreator(media.getCreator());
if (title)
m.setTitle(media.getTitle());
if (season)
m.setSeasonId(media.getSeasonId());
if (episode)
m.setEpisodeId(media.getEpisodeId());
m.setCategory(media.getCategory());
for (Review review : media.getReviews()) {
if (review.getUser().equals(user)) {
if (review.getDate().isBefore(end) && review.getDate().isAfter(start)) {
m.getReviews().add(review);
}
}
}
listTableData.add(m);
}
}
}
}
List rankedResults = listTableData.stream().sorted(new MediaComparator()).limit(top).collect(Collectors.toList());
listTable.setItems(FXCollections.observableArrayList(rankedResults));
listRankColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + rankedResults.indexOf(p.getValue())));
listTable.refresh();
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project Retrospector by NonlinearFruit.
the class MediaSectionController method initialize.
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
chartRatingOverTime.getData().add(new XYChart.Series(FXCollections.observableArrayList(new XYChart.Data(0, 0))));
checkTitle.setSelected(true);
checkCreator.setSelected(true);
checkSeason.setSelected(true);
checkEpisode.setSelected(true);
checkCategory.setSelected(true);
checkTitle.selectedProperty().addListener((observe, old, neo) -> updateMedia());
checkCreator.selectedProperty().addListener((observe, old, neo) -> updateMedia());
checkSeason.selectedProperty().addListener((observe, old, neo) -> updateMedia());
checkEpisode.selectedProperty().addListener((observe, old, neo) -> updateMedia());
checkCategory.selectedProperty().addListener((observe, old, neo) -> updateMedia());
mediaTableFilter = new FilteredList(allMedia);
SortedList<Media> mediaSortable = new SortedList<>(mediaTableFilter);
mediaTable.setItems(mediaSortable);
mediaSortable.comparatorProperty().bind(mediaTable.comparatorProperty());
mediaColumnRowNumber.setSortable(false);
mediaColumnRowNumber.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + mediaTable.getItems().indexOf(p.getValue())));
mediaColumnTitle.setComparator(new NaturalOrderComparator());
mediaColumnCreator.setComparator(new NaturalOrderComparator());
mediaColumnSeason.setComparator(new NaturalOrderComparator());
mediaColumnEpisode.setComparator(new NaturalOrderComparator());
mediaColumnCategory.setComparator(new NaturalOrderComparator());
mediaColumnTitle.setCellValueFactory(new PropertyValueFactory<>("Title"));
mediaColumnCreator.setCellValueFactory(new PropertyValueFactory<>("Creator"));
mediaColumnSeason.setCellValueFactory(new PropertyValueFactory<>("SeasonId"));
mediaColumnEpisode.setCellValueFactory(new PropertyValueFactory<>("EpisodeId"));
mediaColumnCategory.setCellValueFactory(new PropertyValueFactory<>("Category"));
chartRotY.setLabel("Reviews");
chartRotY.setAutoRanging(false);
chartRotY.setLowerBound(0);
chartRotY.setUpperBound(10);
chartRotY.setTickUnit(2);
chartRotY.setMinorTickCount(2);
chartRotX.setLabel("Time");
chartRotX.setAutoRanging(false);
chartRotX.setTickUnit(1);
chartRotX.setMinorTickCount(4);
chartRotX.setTickLabelFormatter(new StringConverter<Number>() {
@Override
public String toString(Number number) {
double x = number.doubleValue();
double decimal = x % 1;
double year = x - decimal;
double days = decimal * 365.25;
if (days > 365 || days < 1) {
return ((int) year) + "";
}
LocalDate date = LocalDate.ofYearDay((int) year, (int) days);
return date.format(DateTimeFormatter.ofPattern("MMM uuuu"));
}
@Override
public Number fromString(String string) {
//To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project Gargoyle by callakrsos.
the class DaoWizardViewController method initialize.
@FXML
public void initialize() {
tbParams.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
// this.colProgramTypeLock.setCellValueFactory(v ->
// v.getValue().lockYnProperty());
// this.colProgramTypeLock.setCellFactory(v ->{
// return
// });
tbmSysDaoDVOProperty = new SimpleObjectProperty<>(new TbmSysDaoDVO());
colParamTestValue.setCellFactory(TextFieldTableCell.forTableColumn());
methodDesc.setCellFactory(TextFieldTableCell.forTableColumn());
methodName.setCellFactory(TextFieldTableCell.forTableColumn());
// [시작] 넘버링 컬럼
colMethodNo.setCellValueFactory(new NumberingCellValueFactory<>(tbMethods.getItems()));
/*
* 2015-11-02 기존에 사용하던 NumberingCellValueFactory을 적용할 수 없음.
* colParamNo컬럼같은경우는 method에 따라 데이터의 주소값이 바뀌는 타입이라 주소값이 바뀌는 상태에선 적절한 넘버링
* 데이터가 화면에 보여주지않음. 하여 주소값을 계속 유지시킬 수 있도록 tbMethods에서 선택된 메소드정보에서 값을
* 참조하여 넘버링을 시킴.
*
* 2016-04-19 파람의 아이템을 삭제하고 다시 호출했을때 인덱스 순서가 맞지않던 버그 fix
*/
colParamNo.setCellValueFactory(param -> {
return new ReadOnlyObjectWrapper<Integer>(tbParams.getItems().indexOf(param.getValue()) + 1);
});
// [끝] 넘버링 컬럼
colParamTypes.setCellFactory(ChoiceBoxTableCell.forTableColumn("Nomal", "Arrays"));
// 텍스트의 내용이 변경되면 메모리에 적재시키기 위한 이벤트 함수.
// 2015.11.17 키 이벤트가 눌릴때 처리되지않게함, 타이밍 문제가 있어, 저장시에 문제가 있음.
// txtSql.getCodeArea().setOnKeyPressed();
txtSql.getCodeArea().setOnKeyReleased(event -> {
if (!event.isShortcutDown()) {
TbpSysDaoMethodsDVO selectedMethodItem = getSelectedMethodItem();
if (selectedMethodItem != null)
selectedMethodItem.setSqlBody(txtSql.getText());
}
});
StringConverter<String> classConverter = new StringConverter<String>() {
@Override
public String toString(String clazz) {
if (clazz == null || clazz.isEmpty())
return "";
String result = clazz;
int lastIndexOf = clazz.lastIndexOf('.');
if (lastIndexOf >= 0) {
result = clazz.substring(lastIndexOf + 1);
}
return result;
}
@Override
public String fromString(String clazz) {
return clazz;
}
};
// 메소드 컬럼에서 Result Vo Class를 더블클릭한경우 VO참조를 걸 수 있도록 팝업창을 뜨는 로직 포함되있음.
colResultVoClass.setCellFactory(param -> {
TextFieldTableCell<TbpSysDaoMethodsDVO, String> textFieldTableCell = new TextFieldTableCell<>();
textFieldTableCell.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
String clazz = textFieldTableCell.getItem();
try {
BaseOpenClassResourceView view = null;
if (ValueUtil.isNotEmpty(clazz)) {
view = new MeerketAbstractVoOpenClassResourceView(clazz);
} else {
view = new MeerketAbstractVoOpenClassResourceView();
}
view.setConsumer(str -> {
if (str == null || str.isEmpty())
return;
try {
int selectedItem = tbMethods.getSelectionModel().getSelectedIndex();
tbMethods.getItems().get(selectedItem).setResultVoClass(str);
} catch (Exception e) {
DialogUtil.showExceptionDailog(e, "로드할 수 없는 클래스 유형입니다.");
return;
}
});
ResultDialog<String> show = view.show();
show.consume();
} catch (Exception e) {
e.printStackTrace();
}
}
});
textFieldTableCell.setConverter(classConverter);
return textFieldTableCell;
});
colResultVoClass.setCellValueFactory(param -> param.getValue().resultVoClassProperty());
// SQL 에디터 마우스 클릭이벤트, 선택한 메소드 항목이 없다면 Editable을 활성화 시키지않는다.
txtSql.getCodeArea().setOnMouseClicked(event -> {
if (!event.isShortcutDown()) {
int selectedMethodIndex = getSelectedMethodIndex();
if (selectedMethodIndex == -1) {
txtSql.getCodeArea().setEditable(false);
} else {
txtSql.getCodeArea().setEditable(true);
}
}
});
// 2016-08-27 custom 항목 추가. 이 항목추가시 typeMapping.properties 파일의 항목도 추가야함.
ObservableList<String> collect = DatabaseTypeMappingResourceLoader.getInstance().getEntry().stream().map(v -> v.getValue().toString()).distinct().collect(FxCollectors.toObservableList());
collect.addAll(Arrays.asList("Integer", "Long", "Double"));
colProgramType.setCellFactory(ChoiceBoxTableCell.forTableColumn(collect));
lblMessage.setText(MSG_NO_WARNNING);
// 메뉴등록작업
applyContextMenu();
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
the class TraderDisputeView method getTradeIdColumn.
private TableColumn<Dispute, Dispute> getTradeIdColumn() {
TableColumn<Dispute, Dispute> column = new TableColumn<Dispute, Dispute>("Trade ID") {
{
setMinWidth(110);
}
};
column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(item.getShortTradeId(), true);
Optional<Trade> tradeOptional = tradeManager.getTradeById(item.getTradeId());
if (tradeOptional.isPresent()) {
field.setMouseTransparent(false);
field.setTooltip(new Tooltip("Open popup for details"));
field.setOnAction(event -> tradeDetailsWindow.show(tradeOptional.get()));
} else {
field.setMouseTransparent(true);
}
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
return column;
}
Aggregations