List of usage examples for javafx.scene.control TableCell TableCell
public TableCell()
From source file:com.github.drbookings.ui.controller.MainController.java
private void addEarningsColumn() { final TableColumn<DateBean, Number> col = new TableColumn<>("TotalEarnings"); col.setCellValueFactory(new PropertyValueFactory<>("totalEarnings")); col.setCellFactory(column -> {// ww w. j a v a 2 s . c om return new TableCell<DateBean, Number>() { @Override protected void updateItem(final Number item, final boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setText(null); } else { setText(decimalFormat.format(item)); } } }; }); col.getStyleClass().add("opace"); tableView.getColumns().add(col); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
private void changeColumnTextColor(TableColumn column, Color color) { column.setCellFactory(new Callback<TableColumn, TableCell>() { public TableCell call(TableColumn param) { return new TableCell<ReportRow, String>() { @Override//from www.j av a2 s . co m public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { this.setTextFill(color); setText(item); } } }; } }); }
From source file:frontend.GUIController.java
@Override public void initialize(URL url, ResourceBundle rb) throws IllegalArgumentException { at = new AnnotationTask(); comboBoxes = new ArrayList<ComboBox<String>>(); comboBoxes.add(combo1);/*from w w w .j ava 2 s .c o m*/ comboBoxes.add(combo3); comboBoxes.add(combo5); comboBoxes.add(combo7); comboBoxes.add(combo9); comboBoxes.add(combo2); comboBoxes.add(combo4); comboBoxes.add(combo6); comboBoxes.add(combo8); comboBoxes.add(combo10); for (int i = 0; i < comboBoxes.size(); i++) { comboBoxes.get(i).setPromptText("Choose one"); } predModel.getItems().add(MODELTYPE.SENTIMENT_WORD); predModel.getItems().add(MODELTYPE.CUSTOM); /* Handle ComboBox event. predModel.setOnAction((event) -> { if(predModel.getSelectionModel().getSelectedItem().equals(MODELTYPE.CUSTOM)){ System.out.println("ComboBox Action (selected: " + MODELTYPE.CUSTOM + ")"); try { this.selectModelFile(event); } catch (Exception e) { e.printStackTrace(); } } });//*/ //predModel.getItems().add(MODELTYPE.SENTIMENT); //predModel.getSelectionModel().selectFirst(); //progressBar = new ProgressIndicator(); // always use 'custom' config - what's in the config file! predModel.getSelectionModel().selectLast(); predModel.setDisable(true); // tabPane.prefWidthProperty().bind(scene.widthProperty()); // tabPane.prefHeightProperty().bind(scene.heightProperty()); tweetText.setCellValueFactory(new PropertyValueFactory<Tweet, String>("tweet")); tweetText.setCellFactory(new Callback<TableColumn<Tweet, String>, TableCell<Tweet, String>>() { @Override public TableCell<Tweet, String> call(TableColumn<Tweet, String> param) { final TableCell<Tweet, String> cell = new TableCell<Tweet, String>() { private Text text; @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { text = new Text(item.toString()); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } } }; return cell; } }); tweetLabel.setCellValueFactory(new PropertyValueFactory<Tweet, LABEL>("label")); tweetLabel.setCellFactory(ComboBoxTableCell.<Tweet, LABEL>forTableColumn(LABEL.values())); tweetLabel.setEditable(true); // add here // // tweetLabel.setOnEditCommit( // (CellEditEvent<Tweet, LABEL> t) -> { // ((Tweet) t.getTableView().getItems().get( // t.getTablePosition().getRow()) // ).setLabel(t.getNewValue()); // }); tweetLabel.setOnEditCommit(event -> { @SuppressWarnings("rawtypes") final TableColumn.CellEditEvent _evn = (TableColumn.CellEditEvent) event; int rowId = _evn.getTablePosition().getRow(); String newVal = _evn.getNewValue().toString(); Tweet t = ((Tweet) _evn.getTableView().getItems().get(rowId)); t.setLabel(LABEL.getEnum(newVal)); System.out.println("Getting new value at row : " + rowId + " with label " + newVal); System.out.println("Tweet information : " + t.toString()); String[] meta = t.getMeta(); System.out.println(t.getTweet() + "\t" + meta[meta.length - 8]); System.out.println( personData.get(rowId).getTweet() + "\t" + personData.get(rowId).getMeta()[meta.length - 8]); }); tweetFeature.setCellValueFactory(new PropertyValueFactory<Tweet, String>("feature")); tweetProb.setCellValueFactory(new PropertyValueFactory<Tweet, Double>("probability")); dirChooser.setInitialDirectory(new File(System.getProperty("user.dir"))); /*tweetText.prefWidthProperty().bind(featureTable.widthProperty().divide(4)); // w * 2/4 tweetLabel.prefWidthProperty().bind(featureTable.widthProperty().divide(2)); // w * 1/4 tweetFeature.prefWidthProperty().bind(featureTable.widthProperty().divide(4)); // w * 1/4 */ }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addChartScore() { colScore.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override//from w w w .ja v a 2s . c om public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { Double score = item.indexOf("%") < 0 || item.indexOf("?") >= 0 ? 0 : Double.parseDouble(item.substring(0, item.indexOf('%'))); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Correct", score), new PieChart.Data("Error", 100 - score)); PieChart chart = new PieChart(pieChartData); chart.setId("pie_chart"); chart.setMinSize(22, 22); chart.setMaxSize(22, 22); HBox box = new HBox(); box.setSpacing(8); box.setAlignment(Pos.CENTER_LEFT); Label score_label = new Label(item); score_label.setTextFill(Color.LIGHTGRAY); box.getChildren().add(chart); box.getChildren().add(score_label); setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addFormatIcons() { colFormats.setCellFactory(// w w w . j av a 2 s . c om new Callback<TableColumn<ReportRow, ObservableMap<String, String>>, TableCell<ReportRow, ObservableMap<String, String>>>() { @Override public TableCell<ReportRow, ObservableMap<String, String>> call( TableColumn<ReportRow, ObservableMap<String, String>> param) { TableCell<ReportRow, ObservableMap<String, String>> cell = new TableCell<ReportRow, ObservableMap<String, String>>() { @Override public void updateItem(ObservableMap<String, String> item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { HBox box = new HBox(); box.setSpacing(3); box.setAlignment(Pos.CENTER_LEFT); for (String i : item.keySet()) { ImageView icon = new ImageView(); icon.setId("but" + i); icon.setFitHeight(20); icon.setFitWidth(20); icon.setImage(new Image("images/formats/" + i + ".png")); icon.setCursor(Cursor.HAND); String type = i; String path = item.get(i); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ArrayMessage am = new ArrayMessage(); am.add(GuiConfig.PERSPECTIVE_SHOW, new UiMessage()); am.add(GuiConfig.PERSPECTIVE_SHOW + "." + GuiConfig.COMPONENT_SHOW, new ShowMessage(type, path)); getContext().send(GuiConfig.PERSPECTIVE_SHOW, am); } }); ContextMenu contextMenu = new ContextMenu(); javafx.scene.control.MenuItem download = new javafx.scene.control.MenuItem( "Download report"); contextMenu.getItems().add(download); icon.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { public void handle(ContextMenuEvent e) { contextMenu.show(icon, e.getScreenX(), e.getScreenY()); } }); box.getChildren().add(icon); } setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addDeleteIcon() { colDelete.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override/*from w ww . ja v a 2 s . co m*/ public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { String path = getModel().getItemById(item).getDeletePath(); HBox box = new HBox(); box.setSpacing(3); box.setAlignment(Pos.CENTER_LEFT); Button icon = new Button(); icon.setMinHeight(20); icon.setPrefHeight(20); icon.setMaxHeight(20); icon.setMinWidth(20); icon.setPrefWidth(20); icon.setMaxWidth(20); icon.getStyleClass().addAll("delete-img", "periodic-img"); icon.setCursor(Cursor.HAND); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { // Delete report File file = new File(path); File dir = new File(file.getParent()); try { FileUtils.deleteDirectory(dir); } catch (IOException e) { e.printStackTrace(); } getModel().removeItem(item); addData(); } }); box.getChildren().add(icon); setGraphic(box); } } }; return cell; } }); }
From source file:org.ado.biblio.desktop.AppPresenter.java
private Callback<TableColumn<Book, String>, TableCell<Book, String>> getHighlightCellFactory() { return param -> new TableCell<Book, String>() { @Override//w w w.j av a2 s . c o m protected void updateItem(String item, boolean empty) { getTableRow().getStyleClass().remove("bookLent"); if (getTableRow().getItem() != null) { setText(item); final boolean lent = isBookLend(); if (lent) { getTableRow().getStyleClass().add("bookLent"); } } else { setText(null); } } private boolean isBookLend() { final TableRow tableRow = getTableRow(); if (tableRow == null) { return false; } final Object item = tableRow.getItem(); if (item == null) { LOGGER.warn("Unexpected null in table row \"{}\".", tableRow.getIndex()); return false; } return ((BookDetails) item).isLent(); } }; }
From source file:io.bitsquare.gui.main.funds.withdrawal.WithdrawalView.java
private void setAddressColumnCellFactory() { addressColumn// www . j a va 2 s . c o m .setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue())); addressColumn.setCellFactory( new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() { @Override public TableCell<WithdrawalListItem, WithdrawalListItem> call( TableColumn<WithdrawalListItem, WithdrawalListItem> column) { return new TableCell<WithdrawalListItem, WithdrawalListItem>() { private HyperlinkWithIcon hyperlinkWithIcon; @Override public void updateItem(final WithdrawalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { String address = item.getAddressString(); hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK); hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item)); hyperlinkWithIcon.setTooltip(new Tooltip( "Open external blockchain explorer for " + "address: " + address)); setGraphic(hyperlinkWithIcon); } else { setGraphic(null); if (hyperlinkWithIcon != null) hyperlinkWithIcon.setOnAction(null); } } }; } }); }
From source file:io.bitsquare.gui.main.funds.withdrawal.WithdrawalView.java
private void setBalanceColumnCellFactory() { balanceColumn/*from w ww. ja v a 2 s. c o m*/ .setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue())); balanceColumn.setCellFactory( new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() { @Override public TableCell<WithdrawalListItem, WithdrawalListItem> call( TableColumn<WithdrawalListItem, WithdrawalListItem> column) { return new TableCell<WithdrawalListItem, WithdrawalListItem>() { @Override public void updateItem(final WithdrawalListItem item, boolean empty) { super.updateItem(item, empty); setGraphic((item != null && !empty) ? item.getBalanceLabel() : null); } }; } }); }
From source file:io.bitsquare.gui.main.funds.withdrawal.WithdrawalView.java
private void setSelectColumnCellFactory() { selectColumn//w ww .j a v a2 s . c om .setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue())); selectColumn.setCellFactory( new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() { @Override public TableCell<WithdrawalListItem, WithdrawalListItem> call( TableColumn<WithdrawalListItem, WithdrawalListItem> column) { return new TableCell<WithdrawalListItem, WithdrawalListItem>() { CheckBox checkBox; @Override public void updateItem(final WithdrawalListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { if (checkBox == null) { checkBox = new CheckBox(); checkBox.setOnAction(e -> selectForWithdrawal(item, checkBox.isSelected())); setGraphic(checkBox); } } else { setGraphic(null); if (checkBox != null) { checkBox.setOnAction(null); checkBox = null; } } } }; } }); }