@FXML void loadSelectedPlaylist() { Playlist p = (Playlist) playlistsView.getSelectionModel().getSelectedItem(); if (p == null) return; tracksView.setPlaceholder(offlinePlaceHolder); Platform.runLater( () -> { List<Track> tracks = p.getTracks(); tracksView.getItems().clear(); for (int i = tracks.size() - 1; i >= 0; i--) { tracksView.getItems().add(tracks.get(i)); } if (findTrack) { Platform.runLater( () -> { tracksView.getSelectionModel().select(currentTrack); tracksView.scrollTo(currentTrack); tracksView.requestFocus(); findTrack = false; }); } else { if (tracksView.getItems().size() > 0) { tracksView.scrollTo(0); } } }); }
public void actionButtonPressed(ActionEvent actionEvent) { Object source = actionEvent.getSource(); // если нажата не кнопка - выходим из метода if (!(source instanceof Button)) { return; } Button clickedButton = (Button) source; // System.out.println(clickedButton.getId()); switch (clickedButton.getId()) { case "btnAddSite": System.out.println("Here 1"); editDialogSites.setSites(new Sites()); showDialog(); collectionSiteBook.add(editDialogSites.getSite()); break; case "btnUpdateSite": System.out.println("Here 2"); editDialogSites.setSites((Sites) tableSiteBook.getSelectionModel().getSelectedItem()); showDialog(); break; case "btsDeleteSite": System.out.println("Here 3"); collectionSiteBook.delete((Sites) tableSiteBook.getSelectionModel().getSelectedItem()); break; } }
private void aandacht() { if (table.getSelectionModel().getSelectedItem() != null) { aandachtBtn.setText("Toegevoegd!"); aandachtBtn.setStyle("-fx-background-color: GREEN;"); llnController.setAandachtsPunt(table.getSelectionModel().getSelectedItem().getCommentaar()); } }
@SuppressWarnings("unchecked") private void initComponents() { pane = new AnchorPane(); pane.setPrefSize(800, 600); pane.setStyle( "-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);"); txPesquisa = new TextField(); DropShadow ds = new DropShadow(); ds.setSpread(0.5); ds.setColor(Color.web("#FF0000")); txPesquisa.setEffect(ds); txPesquisa.setPromptText("Digite o item para pesquisa"); txPesquisa.setPrefWidth(200); txPesquisa.setFocusTraversable(false); tbVitrine = new TableView<ItensProperty>(); initItens(); tbVitrine.setItems(listItens); tbVitrine.setPrefSize(780, 550); columnProduto = new TableColumn<ItensProperty, String>(); columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto")); columnProduto.setText("Produto"); columnPreco = new TableColumn<ItensProperty, Double>(); columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco")); columnPreco.setText("Preço"); tbVitrine.getColumns().addAll(columnProduto, columnPreco); pane.getChildren().addAll(txPesquisa, tbVitrine); }
/** This handles the deletion of a meter or multiple meters */ @FXML private void handleDeleteMeter() { int selectedIndex = meterTable.getSelectionModel().getSelectedIndex(); consumptionHeatMap.removeHeatMap(); generationHeatMap.removeHeatMap(); // if something is selected if (selectedIndex >= 0) { meterTable.getItems().remove(selectedIndex); meterTable.getSelectionModel().clearSelection(selectedIndex); } else { // nothing is selected Dialogs.create() .title("No selection") .masthead("No meter selected") .message("Please select a meter in the table") .showError(); } // TODO: handles whenever there are no meters left, there is a glitch // with the columns being fixed intervalGraphPanel.removeMeter(selectedIndex); barChartPanel.removeMeter(selectedIndex); }
@Override public void initialize() { disputesTable = new TableView<>(); VBox.setVgrow(disputesTable, Priority.SOMETIMES); disputesTable.setMinHeight(150); root.getChildren().add(disputesTable); TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn(); disputesTable.getColumns().add(tradeIdColumn); TableColumn<Dispute, Dispute> roleColumn = getRoleColumn(); disputesTable.getColumns().add(roleColumn); TableColumn<Dispute, Dispute> dateColumn = getDateColumn(); disputesTable.getColumns().add(dateColumn); TableColumn<Dispute, Dispute> contractColumn = getContractColumn(); disputesTable.getColumns().add(contractColumn); TableColumn<Dispute, Dispute> stateColumn = getStateColumn(); disputesTable.getColumns().add(stateColumn); disputesTable.getSortOrder().add(dateColumn); disputesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); Label placeholder = new Label("There are no open tickets"); placeholder.setWrapText(true); disputesTable.setPlaceholder(placeholder); disputesTable.getSelectionModel().clearSelection(); disputeChangeListener = (observableValue, oldValue, newValue) -> onSelectDispute(newValue); }
// Kustutab listist tehtud sündmuse public void kustutaButtonVajutatud() { ObservableList<Kodut66.Input> inputM22ratud, k6ikInputs; k6ikInputs = table.getItems(); inputM22ratud = table.getSelectionModel().getSelectedItems(); inputM22ratud.forEach(k6ikInputs::remove); }
@FXML void initialize() { getAllImageViewsForButtons(); configureWidthHeightForImageViews(); configureButtons(); contentPane.setAlignment(Pos.CENTER); // show all customers and all employees titleLabel.setText("All Customers and All Employees"); TableView table = new TableView(); TableColumn fnCol = new TableColumn("First Name"); fnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lnCol = new TableColumn("Last Name"); lnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn emailCol = new TableColumn("email"); emailCol.setCellValueFactory(new PropertyValueFactory<>("email")); table.getColumns().addAll(fnCol, lnCol, emailCol); ObservableList<Person> data = FXCollections.observableArrayList(operation.getAllCustomersAndEmployees()); table.setItems(data); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); contentPane.getChildren().add(table); }
public SQLHistorySearchCtrl( SQLTextAreaServices sqlTextAreaServices, Session session, ObservableList<SQLHistoryEntry> items) { _sqlTextAreaServices = sqlTextAreaServices; FxmlHelper<SQLHistorySearchView> fxmlHelper = new FxmlHelper<>(SQLHistorySearchView.class); _view = fxmlHelper.getView(); _dialog = new Stage(); _dialog.setTitle( new I18n(getClass()) .t("SQLHistorySearchCtrl.title", session.getMainTabContext().getSessionTabTitle())); _dialog.initModality(Modality.WINDOW_MODAL); _dialog.initOwner(AppState.get().getPrimaryStage()); Region region = fxmlHelper.getRegion(); _dialog.setScene(new Scene(region)); GuiUtils.makeEscapeClosable(region); new StageDimensionSaver( "sqlhistorysearch", _dialog, new Pref(getClass()), region.getPrefWidth(), region.getPrefHeight(), _dialog.getOwner()); _view.cboFilterType.setItems( FXCollections.observableList(Arrays.asList(SqlHistoryFilterType.values()))); _view.cboFilterType.getSelectionModel().selectFirst(); _view.btnApply.setOnAction(e -> onApply()); _view.chkFiltered.setOnAction(e -> onChkFiltered()); _view.split.getItems().add(_tblHistory); _view.split.getItems().add(_txtSqlPreview); _originalTableLoader = new RowObjectTableLoader<>(); _originalTableLoader.initColsByAnnotations(SQLHistoryEntry.class); _originalTableLoader.addRowObjects(items); _currentLoader = _originalTableLoader.cloneLoader(); _currentLoader.load(_tblHistory); _tblHistory .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> onTableSelectionChanged()); _tblHistory.setOnMouseClicked(e -> onTblHistoryClicked(e)); _txtSqlPreview.setEditable(false); _dialog.setOnCloseRequest(e -> close()); _view.txtFilter.requestFocus(); _splitPositionSaver.apply(_view.split); _dialog.showAndWait(); }
@Override protected void activate() { currencyComboBox.setItems(model.getTradeCurrencies()); currencyComboBox.getSelectionModel().select(model.getTradeCurrency()); currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25)); currencyComboBox.setOnAction( e -> { model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); updateChartData(); }); model.getOfferBookListItems().addListener(changeListener); tradeCurrencySubscriber = EasyBind.subscribe( model.tradeCurrency, newValue -> { String code = newValue.getCode(); areaChart.setTitle("Offer book for " + newValue.getName()); priceColumnLabel.set("Price (" + code + "/BTC)"); volumeColumnLabel.set("Volume (" + code + ")"); xAxis.setLabel(priceColumnLabel.get()); xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", "")); }); buyOfferTableView.setItems(model.getBuyOfferList()); sellOfferTableView.setItems(model.getSellOfferList()); updateChartData(); }
@FXML private void handleDeleteDepartment() { int selectedIndex = departmentTable.getSelectionModel().getSelectedIndex(); if (selectedIndex >= 0) { for (int i = main.getEmployees().size() - 1; i >= 0; i--) { ViewEmployee vEmp = main.getEmployees().get(i); if (vEmp.getDepartment() .equals(departmentTable.getSelectionModel().getSelectedItem().getName())) { for (ViewDepartment vDep : main.getDepartments()) { if (vDep.getDirectorName().equals(vEmp.getLastName() + " " + vEmp.getFirstName())) { vDep.setDirectorName("-"); } } main.getEmployees().remove(vEmp); } } con.deleteDepartment(departmentTable.getSelectionModel().getSelectedItem().getId()); departmentTable.getItems().remove(selectedIndex); } else { Alert alert = new Alert(AlertType.WARNING); alert.initOwner(main.getPrimaryStage()); alert.setTitle("Ничего не выбрано"); alert.setHeaderText("Не выбран отдел"); alert.setContentText("Пожалуйста, выберите отдел"); alert.showAndWait(); } }
private void eliminar() { if (comboListar.getSelectionModel().getSelectedIndex() == 0) { eliminar( 5, listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(), 6); txtfNombre.setText(null); } if (comboListar.getSelectionModel().getSelectedIndex() == 1) { eliminar( 6, listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(), 7); txtfNombre.setText(null); } if (comboListar.getSelectionModel().getSelectedIndex() == 2) { eliminar( 7, listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(), 8); txtfNombre.setText(null); } if (comboListar.getSelectionModel().getSelectedIndex() == 3) { eliminar( 8, listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(), 5); txtfNombre.setText(null); } }
@FXML private void initialize() { personTableNameColumn.setCellValueFactory( (dataFeatures) -> dataFeatures.getValue().nameProperty()); personTableNameColumn.setCellFactory(TextFieldTableCell.forTableColumn()); personTableNameColumn.setOnEditCommit( (cellEditEvent) -> { int row = cellEditEvent.getTablePosition().getRow(); Person person = cellEditEvent.getTableView().getItems().get(row); person.setName(cellEditEvent.getNewValue()); }); personTableEmailColumn.setCellValueFactory( (dataFeatures) -> dataFeatures.getValue().emailProperty()); personTableEmailColumn.setCellFactory(TextFieldTableCell.forTableColumn()); personTableNameColumn.setOnEditCommit( (cellEditEvent) -> { int row = cellEditEvent.getTablePosition().getRow(); Person person = cellEditEvent.getTableView().getItems().get(row); person.setEmail(cellEditEvent.getNewValue()); }); ReadOnlyObjectProperty<Person> selectionProperty = personTableView.getSelectionModel().selectedItemProperty(); selectionProperty.addListener( (observable, oldValue, newValue) -> { personPaneController.setModel(newValue); }); personList = personTableView.getItems(); }
public void loadData(boolean forceReload) { ICFSecuritySchemaObj schemaObj = (ICFSecuritySchemaObj) javafxSchema.getSchema(); if ((containingCluster == null) || forceReload) { CFSecurityAuthorization auth = schemaObj.getAuthorization(); long containingClusterId = auth.getSecClusterId(); containingCluster = schemaObj.getClusterTableObj().readClusterByIdIdx(containingClusterId); } if ((listOfSysCluster == null) || forceReload) { observableListOfSysCluster = null; listOfSysCluster = schemaObj .getSysClusterTableObj() .readSysClusterByClusterIdx(containingCluster.getRequiredId(), javafxIsInitializing); if (listOfSysCluster != null) { observableListOfSysCluster = FXCollections.observableArrayList(listOfSysCluster); observableListOfSysCluster.sort(compareSysClusterByQualName); } else { observableListOfSysCluster = FXCollections.observableArrayList(); } dataTable.setItems(observableListOfSysCluster); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
// https://docs.oracle.com/javafx/2/ui_controls/table-view.htm @SuppressWarnings("unchecked") public DataPanel(final String string) { super(string); tableView = new ScrollPane(); tableView.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); tableView.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); // set(MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithHeight(), // MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithWidth()); elementName = new TableColumn<>("element-name"); elementValue = new TableColumn<>("element-value"); elementName.setCellValueFactory(new PropertyValueFactory<TableEntry, String>("elementName")); elementValue.setCellValueFactory(new PropertyValueFactory<TableEntry, String>("elementValue")); dataTable = new TableView<TableEntry>(); dataTable.getColumns().addAll(elementName, elementValue); dataTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); dataTable.setPrefHeight( MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithHeight()); dataTable.setPrefWidth( MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithWidth()); dataTable.setEditable(true); tableView.setContent(dataTable); ; tableView.setFitToHeight(true); tableView.setFitToWidth(true); setContent(tableView); }
@FXML private void genararb(ActionEvent event) { tablabloque.getColumns().clear(); String[] titulos = { "Numero", "bloque", "Fecha De Creacion", "Fecha De Modificacion", }; for (int i = 0; i < titulos.length; i++) { final int j = i; this.titulo = new TableColumn(titulos[i]); this.titulo.setCellValueFactory( new Callback< TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ObservableList, String> parametro) { return new SimpleStringProperty((String) parametro.getValue().get(j)); } }); tablabloque.getColumns().addAll(titulo); // Asignamos un tamaño a ls columnnas titulo.setMinWidth(120); // Centrar los datos de la tabla titulo.setCellFactory( new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { TableCell cell = new TableCell() { @Override protected void updateItem(Object t, boolean bln) { if (t != null) { super.updateItem(t, bln); setText(t.toString()); setAlignment(Pos.CENTER); // Setting the Alignment } } }; return cell; } }); } tbbloque = FXCollections.observableArrayList(); for (Tbbloque bloq : resultsbloque) { ObservableList<String> row = FXCollections.observableArrayList(); row.add(bloq.getId().toString()); row.add(bloq.getNombre()); row.add(df1.format(bloq.getFechacreacion())); System.out.print(bloq.getFechacreacion()); String fecha = bloq.getFechamodificacion() == null ? bloq.getFechamodificacion() + "" : df1.format(bloq.getFechamodificacion()); row.add(fecha); tbbloque.addAll(row); } tablabloque.setItems(tbbloque); }
private void deleteSelectedSkillFilter() { SkillFilter selectedItem = skillFiltersTableView.getSelectionModel().getSelectedItem(); if (selectedItem != null) { skillFiltersTableView.getItems().remove(selectedItem); skillFiltersTableView.getSelectionModel().clearSelection(); updateOfficialFiltersResult(); } }
@Override public void saveAsExcel() { TableView<ItemPrice> itemTable = new ItemTable(this).getTable(); itemTable.setItems(item.list()); itemTable.setId(module + " List as of " + Util.formatDate(LocalDate.now())); new ExcelWriter( Arrays.asList(Arrays.asList(itemTable)), module, Util.dateToFileName(LocalDate.now())); }
public void putInTable(ObservableList<Medarbejder> datars) { viewNavn.setCellValueFactory(new PropertyValueFactory("navn")); viewEmail.setCellValueFactory(new PropertyValueFactory("email")); viewAfdeling.setCellValueFactory(new PropertyValueFactory("afdeling")); TableView.setItems(null); TableView.setItems(datars); }
private Boolean validateInput() { Boolean validation = true; // Check if inputs are null or empty if (_durationTextField.getText().length() == 0) { _durationTextField.setStyle("-fx-text-box-border: red;"); validation = false; } else { _durationTextField.setStyle("-fx-text-box-border: lightgrey;"); } if (_datePicker.getValue() == null) { _datePicker.setStyle("-fx-date-picker-border: red;"); validation = false; } else { _datePicker.setStyle("-fx-date-picker-border: lightgrey;"); } if (_startTimeTextField.getText().length() == 0) { _startTimeTextField.setStyle("-fx-text-box-border: red;"); validation = false; } else { _startTimeTextField.setStyle("-fx-text-box-border: lightgrey;"); } // check if inputs are matching the given regex if (validation) { if (_durationTextField.getText().matches("(\\d*)")) { _duration = Integer.parseInt(_durationTextField.getText()); _durationTextField.setStyle("-fx-text-box-border: lightgrey;"); } else { _durationTextField.setStyle("-fx-text-box-border: red;"); validation = false; } // define Regex: 0-24h, 0-59min, 0-69sek if (_startTimeTextField.getText().matches("([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])")) { _localDate = _datePicker.getValue(); String[] times = _startTimeTextField.getText().split(":"); _localTime = LocalTime.of( Integer.parseInt(times[0]), Integer.parseInt(times[1]), Integer.parseInt(times[2])); _startTimeTextField.setStyle("-fx-text-box-border: lightgrey;"); } else { _startTimeTextField.setStyle("-fx-text-box-border: red;"); validation = false; } } if (_allTeamsTableView.getSelectionModel().getSelectedItem() == null || _allTeamsOpponentTableView.getSelectionModel().getSelectedItem() == null) { validation = false; } return validation; }
private void CargarTabla() { tablabloque.getColumns().clear(); String[] titulos = { "Bloque", "Pregunta", }; for (int i = 0; i < titulos.length; i++) { final int j = i; this.titulo = new TableColumn(titulos[i]); this.titulo.setCellValueFactory( new Callback< TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ObservableList, String> parametro) { return new SimpleStringProperty((String) parametro.getValue().get(j)); } }); tablabloque.getColumns().addAll(titulo); // Asignamos un tamaño a ls columnnas if (i == 0) { titulo.setMinWidth(120); } else { titulo.setMinWidth(450); } // Centrar los datos de la tabla titulo.setCellFactory( new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { TableCell cell = new TableCell() { @Override protected void updateItem(Object t, boolean bln) { if (t != null) { super.updateItem(t, bln); setText(t.toString()); setAlignment(Pos.CENTER); // Setting the Alignment } } }; return cell; } }); } tbbloque = FXCollections.observableArrayList(); for (Tbbloquesxpregunta bloqxpreg : resultsbloqxpreg) { ObservableList<String> row = FXCollections.observableArrayList(); row.add(bloqxpreg.getIdbloque().getNombre()); row.add(bloqxpreg.getIdpregunta().getNombre()); tbbloque.addAll(row); } tablabloque.setItems(tbbloque); }
void playRandom() { List<Track> tracks = tracksView.getItems(); Random random = new Random(); int size = tracks.size(); int r = random.nextInt(size - 1); tracksView.getSelectionModel().select(r); tracksView.scrollTo(tracksView.getSelectionModel().getSelectedIndex()); Track nextTrack = (Track) tracksView.getSelectionModel().getSelectedItem(); playTrack(nextTrack); }
@FXML private void HandleTableButtonAction(ActionEvent event) throws IOException { // Create the custom dialog. Dialog<Pair<ObservableList, ObservableList<ZRow>>> dialog = new Dialog<>(); dialog.setTitle("Editeur de tableau"); dialog.setHeaderText(""); // Set the icon (must be included in the project). dialog.setGraphic( new ImageView(MainApp.class.getResource("assets/static/icons/table.png").toString())); // Set the button types. dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("fxml/TableEditor.fxml")); BorderPane tableEditor = loader.load(); TableView<ZRow> tbView = (TableView) tableEditor.getCenter(); TableController controller = loader.getController(); controller.setEditor(this); dialog.getDialogPane().setContent(tableEditor); dialog.setResultConverter( dialogButton -> { if (dialogButton == ButtonType.OK) { return new Pair<>(tbView.getColumns(), tbView.getItems()); } return null; }); Optional<Pair<ObservableList, ObservableList<ZRow>>> result = dialog.showAndWait(); result.ifPresent( datas -> { String[][] data = new String[datas.getValue().size()][datas.getValue().get(0).getRow().size()]; String[] headers = new String[datas.getKey().size()]; int cpt = 0; for (Object key : datas.getKey()) { headers[cpt] = ((TextField) ((TableColumn) key).getGraphic()).getText(); cpt++; } for (int i = 0; i < datas.getValue().size(); i++) { for (int j = 0; j < datas.getValue().get(i).getRow().size(); j++) { data[i][j] = datas.getValue().get(i).getRow().get(j); } } String tablestring = FlipTable.of(headers, data); SourceText.replaceText(SourceText.getSelection(), "\n\n" + tablestring + "\n\n"); SourceText.requestFocus(); }); }
private Pane buildUpperArea() { Pane up = new Pane(); up.prefHeightProperty().bind(this.heightProperty()); up.prefWidthProperty().bind(this.widthProperty()); TableView<DebateDetails> table = new TableView<DebateDetails>(); table.prefHeightProperty().bind(up.heightProperty()); table.prefWidthProperty().bind(up.widthProperty()); final Label label = new Label("Debate Tournament"); label.setFont(new Font("Arial", 20)); table.setEditable(false); table.getChildrenUnmodifiable().clear(); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); TableColumn<DebateDetails, String> divCol = new TableColumn<DebateDetails, String>("Division"); divCol.setCellValueFactory(new PropertyValueFactory<>("division")); TableColumn<DebateDetails, String> teamCountCol = new TableColumn<DebateDetails, String>("Team Count"); teamCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("teamCount"))); TableColumn<DebateDetails, String> debCountCol = new TableColumn<DebateDetails, String>("Debate Count"); debCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("totalMatch"))); TableColumn<DebateDetails, String> debCompCol = new TableColumn<DebateDetails, String>("Debates Completed "); debCompCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchCompleted"))); TableColumn<DebateDetails, String> debRemCol = new TableColumn<DebateDetails, String>("Upcoming Debates"); debRemCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchRemaining"))); final ObservableList<DebateDetails> data = FXCollections.observableArrayList(TeamManager.getDebateDetails()); table.setItems(data); table.getColumns().add(divCol); table.getColumns().add(teamCountCol); table.getColumns().add(debCountCol); table.getColumns().add(debCompCol); table.getColumns().add(debRemCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(label, table); up.getChildren().add(vbox); return up; }
@FXML private void handleButton(ActionEvent event) throws ClassNotFoundException, InstantiationException, IllegalAccessException { try { conn = DbConn.connect(); String sql = "SELECT patient_id, first_name, last_name, date_of_birth FROM PR_PATIENT where first_name LIKE '%" + search_first.getText() + "%'"; // "SELECT patient_id, first_name, last_name, date_of_birth FROM PR_PATIENT where first_name // LIKE '%"+search_first.getText()+"%'"; ResultSet rs = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY) .executeQuery(sql); ObservableList<Object> data = FXCollections.observableArrayList(); for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) { final int j = i; TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i + 1)); col.setCellValueFactory( new Callback<CellDataFeatures<ObservableList, String>, ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) { return new SimpleStringProperty(param.getValue().get(j).toString()); } }); search_results.getColumns().addAll(col); } while (rs.next()) { ObservableList<String> row = FXCollections.observableArrayList(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row.add(rs.getString(i)); } System.out.println(row); data.add(row); // search_results.setItems(row); } search_results.setItems(data); // search_results.setItems(table); // ObservableList<Patient> data = search_results.getItems(); // data.add(new Patient (FirstName.getText(), LastName.getText(), DOB.getText())); // FirstName.setText(""); rs.close(); } catch (SQLException e) { System.out.println("Error " + e.getMessage()); } }
@FXML public void mapearDatos() { if (tablaResultados.getSelectionModel().getSelectedItem() != null) { txtfNombre.setText( listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getNombreAutor()); txtfNombre.setDisable(false); nombre = listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getNombreAutor(); } }
private void initSuccessAlert() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText("Saving successful!"); alert.setTitle("Saving successful"); alert.setContentText( "A new Match between " + _allTeamsTableView.getSelectionModel().getSelectedItem().getName() + " and " + _allTeamsOpponentTableView.getSelectionModel().getSelectedItem().getName() + " was saved successfully!"); alert.showAndWait(); }
public void setFddObjectModel(FddObjectModel fddObjectModel) { logger.entry(); if (fddObjectModel != null) { fddObjectModel .getInteractionClasses() .values() .stream() .forEach( (value) -> { interactions.add(new InteractionState(value)); }); InteractionTableView.setItems(interactions); interactions.forEach( (interaction) -> { interaction .onProperty() .addListener( (observable, oldValue, newValue) -> { if (!newValue) { cb.setSelected(false); } else if (interactions.stream().allMatch(a -> a.isOn())) { cb.setSelected(true); } }); }); InteractionTableColumn.setCellValueFactory(new PropertyValueFactory<>("interactionName")); CheckTableColumn.setCellValueFactory( new Callback< TableColumn.CellDataFeatures<InteractionState, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<InteractionState, Boolean> param) { return param.getValue().onProperty(); } }); CheckTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(CheckTableColumn)); cb.setUserData(CheckTableColumn); cb.setOnAction( (ActionEvent event) -> { CheckBox cb1 = (CheckBox) event.getSource(); TableColumn tc = (TableColumn) cb1.getUserData(); InteractionTableView.getItems() .stream() .forEach( (item) -> { item.setOn(cb1.isSelected()); }); }); CheckTableColumn.setGraphic(cb); } logger.exit(); }
private void refresh() { List<ImageResource> imageResources = new ArrayList<>(); List<Resource> resources = book.getResources() .getResourcesByMediaTypes( new MediaType[] {MediaType.GIF, MediaType.PNG, MediaType.SVG, MediaType.JPG}); for (Resource resource : resources) { imageResources.add((ImageResource) resource); } tableView.setItems(FXCollections.observableList(imageResources)); tableView.getSelectionModel().select(0); }
public void populateDataTableModel() { removeEntries(); TableEntry projectName = new TableEntry(); TableEntry projectShortName = new TableEntry(); TableEntry projectDescription = new TableEntry(); projectName.setElementName(PROJECT_NAME); projectShortName.setElementName(PROJECT_SHORT_NAME); projectDescription.setElementName(PROJECT_DETAILS); dataTable.getItems().add(projectName); dataTable.getItems().add(projectShortName); dataTable.getItems().add(projectDescription); }