List of usage examples for javafx.scene.control TableCell TableCell
public TableCell()
From source file:hash.HashFilesController.java
/** * Initializes the controller class.//from ww w . ja va 2s .c o m */ @Override public void initialize(URL url, ResourceBundle rb) { SessionFactory sFactory = HibernateUtilities.getSessionFactory(); Session session = sFactory.openSession(); session.beginTransaction(); Query query = session.createQuery("from Checksum where caseFile = " + CreateCaseController.getCaseNumber()); List<Checksum> checksumsForCase = (List<Checksum>) query.list(); checksumIDColumn.setCellValueFactory(new PropertyValueFactory("checksumID")); fileNameColumn.setCellValueFactory(new PropertyValueFactory("fileName")); filePathColumn.setCellValueFactory(new PropertyValueFactory("filePath")); dateTimeGeneratedColumn.setCellValueFactory(new PropertyValueFactory("dateTimeGenerated")); DateTimeFormatter format = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT); dateTimeGeneratedColumn.setCellFactory(column -> { return new TableCell<Checksum, LocalDateTime>() { @Override protected void updateItem(LocalDateTime item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setText(null); setStyle(""); } else { // Format date. setText(format.format(item)); } } }; }); md5Column.setCellValueFactory(new PropertyValueFactory("MD5Value")); checksumTableView.getItems().addAll(checksumsForCase); session.getTransaction().commit(); session.close(); }
From source file:br.com.OCTur.view.ClassificacaoController.java
/** * Initializes the controller class.//from ww w . j ava 2 s .c o m */ @Override public void initialize(URL url, ResourceBundle rb) { snGrafico = new SwingNode(); spContainer.setContent(snGrafico); tcCidade.setCellValueFactory( (TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Cidade> param) -> new SimpleObjectProperty<>( param.getValue().getEntidade())); tcClassificacao.setCellValueFactory(( TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Integer> param) -> new SimpleObjectProperty<>( cidades.indexOf(param.getValue()) + 1)); tcPais.setCellValueFactory( (TableColumn.CellDataFeatures<EntidadeGrafico<Cidade>, Pais> param) -> new SimpleObjectProperty<>( param.getValue().getEntidade().getEstado().getPais())); tcNota.setCellValueFactory(new PropertyValueFactory<>("value")); tcNota.setCellFactory(( TableColumn<EntidadeGrafico<Cidade>, Double> param) -> new TableCell<EntidadeGrafico<Cidade>, Double>() { @Override protected void updateItem(Double item, boolean empty) { if (empty) { setText(""); } else { setText(NumberFormatter.duasCasas(item)); } } }); tvCidade.setItems(cidades); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.MetaDataPane.java
@FXML void initialize() { assert attributeColumn != null : "fx:id=\"attributeColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert imageView != null : "fx:id=\"imageView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert tableView != null : "fx:id=\"tableView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert valueColumn != null : "fx:id=\"valueColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; TagUtils.registerListener(this); ImageGalleryController.getDefault().getCategoryManager().registerListener(this); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setPlaceholder(new Label("Select a file to show its details here.")); attributeColumn.setCellValueFactory((param) -> new SimpleObjectProperty<>(param.getValue().getKey())); attributeColumn.setCellFactory(/* w ww. j a v a2s .com*/ (param) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, DrawableAttribute<?>>() { @Override protected void updateItem(DrawableAttribute<?> item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (item != null) { setText(item.getDisplayName()); setGraphic(new ImageView(item.getIcon())); } else { setGraphic(null); setText(null); } } }); attributeColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellValueFactory((p) -> { if (p.getValue().getKey() == DrawableAttribute.TAGS) { return new SimpleStringProperty( ((Collection<TagName>) p.getValue().getValue()).stream().map(TagName::getDisplayName) .filter((String t) -> t.startsWith(Category.CATEGORY_PREFIX) == false) .collect(Collectors.joining(" ; ", "", ""))); } else { return new SimpleStringProperty(StringUtils.join((Iterable<?>) p.getValue().getValue(), " ; ")); } }); valueColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellFactory((p) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { Text text = new Text(item); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } else { setGraphic(null); } } }); tableView.getColumns().setAll(Arrays.asList(attributeColumn, valueColumn)); //listen for selection change controller.getSelectionModel().lastSelectedProperty().addListener((observable, oldFileID, newFileID) -> { setFile(newFileID); }); // MetaDataPane.this.visibleProperty().bind(controller.getMetaDataCollapsed().not()); // MetaDataPane.this.managedProperty().bind(controller.getMetaDataCollapsed().not()); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane.java
@FXML void initialize() { assert attributeColumn != null : "fx:id=\"attributeColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert imageView != null : "fx:id=\"imageView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert tableView != null : "fx:id=\"tableView\" was not injected: check your FXML file 'MetaDataPane.fxml'."; assert valueColumn != null : "fx:id=\"valueColumn\" was not injected: check your FXML file 'MetaDataPane.fxml'."; TagUtils.registerListener(this); Category.registerListener(this); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setPlaceholder(new Label("Select a file to show its details here.")); attributeColumn.setCellValueFactory((param) -> new SimpleObjectProperty<>(param.getValue().getKey())); attributeColumn.setCellFactory(/*from w ww .j a v a2s. co m*/ (param) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, DrawableAttribute<?>>() { @Override protected void updateItem(DrawableAttribute<?> item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (item != null) { setText(item.getDisplayName()); setGraphic(new ImageView(item.getIcon())); } else { setGraphic(null); setText(null); } } }); attributeColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellValueFactory((p) -> { if (p.getValue().getKey() == DrawableAttribute.TAGS) { return new SimpleStringProperty( ((Collection<TagName>) p.getValue().getValue()).stream().map(TagName::getDisplayName) .filter((String t) -> t.startsWith(Category.CATEGORY_PREFIX) == false) .collect(Collectors.joining(" ; ", "", ""))); } else { return new SimpleStringProperty(StringUtils.join((Collection<?>) p.getValue().getValue(), " ; ")); } }); valueColumn.setPrefWidth(USE_COMPUTED_SIZE); valueColumn.setCellFactory((p) -> new TableCell<Pair<DrawableAttribute<?>, ? extends Object>, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { Text text = new Text(item); text.wrappingWidthProperty().bind(getTableColumn().widthProperty()); setGraphic(text); } else { setGraphic(null); } } }); tableView.getColumns().setAll(Arrays.asList(attributeColumn, valueColumn)); //listen for selection change controller.getSelectionModel().lastSelectedProperty().addListener((observable, oldFileID, newFileID) -> { setFile(newFileID); }); // MetaDataPane.this.visibleProperty().bind(controller.getMetaDataCollapsed().not()); // MetaDataPane.this.managedProperty().bind(controller.getMetaDataCollapsed().not()); }
From source file:org.apache.cayenne.modeler.layout.ObjectEntityRelationshipsTabLayout.java
@Override public void initializeLayout() { super.initializeLayout(); newRelationshipButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.PLUS, "16px")); newRelationshipButton.setText(null); synchronizeWithDatabaseEntityButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.REFRESH, "16px")); synchronizeWithDatabaseEntityButton.setText(null); viewRelatedDatabaseEntityButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.TABLE, "16px")); viewRelatedDatabaseEntityButton.setText(null); deleteButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.TRASH, "16px")); deleteButton.setText(null);/*from ww w.ja v a 2s . c o m*/ cutButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.CUT, "16px")); cutButton.setText(null); copyButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.COPY, "16px")); copyButton.setText(null); pasteButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.PASTE, "16px")); pasteButton.setText(null); attributeUsedForLockingColumn.setText(null); attributeIsInheritedColumn.setText(null); attributeUsedForLockingColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px")); attributeIsInheritedColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LEVEL_UP, "16px")); relationshipNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); relationshipTargetColumn.setCellValueFactory(cellData -> cellData.getValue().javaTypeProperty()); attributeDatabasePathColumn .setCellValueFactory(cellData -> cellData.getValue().databaseAttributePathProperty()); // FIXME: See if there is a way of doing this without using the string "databaseType"... attributeDatabaseTypeColumn .setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter, String>("databaseType")); attributeUsedForLockingColumn.setCellValueFactory(cellData -> cellData.getValue().usedForLockingProperty()); attributeUsedForLockingColumn.setCellFactory((column) -> { return new TableCell<ObjectAttributeAdapter, Boolean>() { @Override protected void updateItem(final Boolean item, final boolean empty) { super.updateItem(item, empty); setAlignment(Pos.CENTER); setStyle("-fx-padding: 0;"); setText(""); if (item == null || empty || item == false) setGraphic(null); else setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px")); } }; }); }
From source file:org.apache.cayenne.modeler.layout.ObjectEntityAttributesTabLayout.java
@Override public void initializeLayout() { super.initializeLayout(); newAttributeButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.PLUS, "16px")); newAttributeButton.setText(null);/*from w w w . j a va 2 s. c o m*/ synchronizeWithDatabaseEntityButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.REFRESH, "16px")); synchronizeWithDatabaseEntityButton.setText(null); viewRelatedDatabaseEntityButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.TABLE, "16px")); viewRelatedDatabaseEntityButton.setText(null); deleteButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.TRASH, "16px")); deleteButton.setText(null); cutButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.CUT, "16px")); cutButton.setText(null); copyButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.COPY, "16px")); copyButton.setText(null); pasteButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.PASTE, "16px")); pasteButton.setText(null); attributeUsedForLockingColumn.setText(null); attributeIsInheritedColumn.setText(null); attributeUsedForLockingColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px")); attributeIsInheritedColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LEVEL_UP, "16px")); attributeNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); attributeTypeColumn.setCellValueFactory(cellData -> cellData.getValue().javaTypeProperty()); attributeDatabasePathColumn .setCellValueFactory(cellData -> cellData.getValue().databaseAttributePathProperty()); // FIXME: See if there is a way of doing this without using the string "databaseType"... attributeDatabaseTypeColumn .setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter, String>("databaseType")); attributeUsedForLockingColumn.setCellValueFactory(cellData -> cellData.getValue().usedForLockingProperty()); attributeUsedForLockingColumn.setCellFactory((column) -> { return new TableCell<ObjectAttributeAdapter, Boolean>() { @Override protected void updateItem(final Boolean item, final boolean empty) { super.updateItem(item, empty); setAlignment(Pos.CENTER); setStyle("-fx-padding: 0;"); setText(""); if (item == null || empty || item == false) setGraphic(null); else setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px")); } }; }); // Callback<TableColumn<ObjAttribute, String>, TableCell<ObjAttribute, String>> comboBoxCellFactory // = (TableColumn<ObjAttribute, String> param) -> new ComboBoxEditingCell(); // // ComboBoxTableCell attributeTypeCell = new ComboBoxTableCell(javaTypes); // attributeTypeColumn.setCellFactory(attributeTypeCell); //// attributeTypeColumn.setCellFactory(ComboBoxTableCell.forTableColumn(ObjectEntityUtilities.getRegisteredTypeNames())); // attributeTypeColumn.setEditable(true); //// attributeTypeColumn.set // attributeTypeColumn.setOnEditCommit( // new EventHandler<CellEditEvent<ObjAttribute, String>>() { // @Override // public void handle(CellEditEvent<ObjAttribute,String> t) { // System.out.println(t); //// ((ObjAttribute) t.getTableView().getItems().get(t.getTablePosition().getRow())).setLevel(t.getNewValue()); // } // }); // attributeTypeColumn.setPromptText("Java Type"); // emailComboBox.setEditable(true); // emailComboBox.valueProperty().addListener(new ChangeListener<String>() { // @Override // public void changed(ObservableValue ov, String t, String t1) { // address = t1; // } // }); }
From source file:com.mycompany.pfinanzaspersonales.BuscadorController.java
@FXML private void btnBuscar(ActionEvent event) throws IOException { String desde_t = "", hasta_t = ""; if (input_desde.getValue() != null) { desde_t = input_desde.getValue().toString(); }//w w w . jav a2s . c o m if (input_hasta.getValue() != null) { hasta_t = input_hasta.getValue().toString(); } final String desde = desde_t; final String hasta = hasta_t; final Task<Void> tarea = new Task<Void>() { @Override protected Void call() throws Exception { HttpResponse response; List<NameValuePair> parametros = new ArrayList<NameValuePair>(); parametros.add(new BasicNameValuePair("tipo", cbb_tipo.getValue().toString())); parametros.add(new BasicNameValuePair("pago", cbb_pago.getValue().toString())); parametros.add(new BasicNameValuePair("desde", desde)); parametros.add(new BasicNameValuePair("hasta", hasta)); System.out.println(desde); response = JSON.request(Config.URL + "usuarios/buscar.json", parametros); JSONObject jObject = JSON.JSON(response); tabla_json = new ArrayList<TablaBuscar>(); try { editar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("editar")); eliminar.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("eliminar")); fecha.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("fecha")); categoria.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("categoria")); tpago.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("pago")); tmonto.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("monto")); ttipo.setCellValueFactory(new PropertyValueFactory<TablaBuscar, String>("tipo")); tabla_json = new ArrayList<TablaBuscar>(); if (!jObject.get("data").equals(null)) { JSONArray jsonArr = jObject.getJSONArray("data"); for (int i = 0; i < jsonArr.length(); i++) { JSONObject data_json = jsonArr.getJSONObject(i); tabla_json.add(new TablaBuscar(data_json.get("idgastos").toString(), data_json.get("idgastos").toString(), data_json.get("idgastos").toString(), data_json.get("monto").toString(), data_json.get("fecha").toString(), data_json.get("nom_mediopago").toString(), data_json.get("categoria").toString(), data_json.get("tipo").toString())); } } tabla_buscador.setItems(FXCollections.observableArrayList(tabla_json)); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void succeeded() { super.succeeded(); eliminar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { return new TableCell<String, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty() && !empty) { final VBox vbox = new VBox(5); Image image = new Image(getClass().getResourceAsStream("/Imagenes/delete.png")); final Button boton = new Button("", new ImageView(image)); boton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Action response = Dialogs.create().title("Eliminar Gasto") .message("Ests seguro que desaeas eliminar el gasto?") .showConfirm(); if (response == Dialog.ACTION_YES) { TablaBuscar tabla = tabla_json.get(getTableRow().getIndex()); List<NameValuePair> parametros = new ArrayList<NameValuePair>(); String url = ""; if (tabla.getTipo() == "Gastos") { parametros .add(new BasicNameValuePair("idgastos", tabla.getId())); url = Config.URL + "gastos/eliminar.json"; } else { parametros.add( new BasicNameValuePair("idingresos", tabla.getId())); url = Config.URL + "ingresos/eliminar.json"; } HttpResponse responseJSON = JSON.request(url, parametros); JSONObject jObject = JSON.JSON(responseJSON); int code = Integer.parseInt(jObject.get("code").toString()); if (code == 201) { int selectdIndex = getTableRow().getIndex(); tabla_json.remove(selectdIndex); tabla_buscador.getItems().remove(selectdIndex); } else { Dialogs.create().title("Error sincronizacin").message( "Hubo un error al intentar eliminar . ERROR: 301") .showInformation(); } } } }); vbox.getChildren().add(boton); setGraphic(vbox); } else { setGraphic(null); } } }; } }); editar.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() { @Override public TableCell<String, String> call(TableColumn<String, String> p) { return new TableCell<String, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!isEmpty() && !empty) { final VBox vbox = new VBox(5); Image image = new Image(getClass().getResourceAsStream("/Imagenes/edit.png")); final Button boton = new Button("", new ImageView(image)); boton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TablaBuscar tabla = tabla_json.get(getTableRow().getIndex()); Parent parent = null; if (tabla.getTipo() == "Gastos") { AgregarGastos AG = AgregarGastos.getInstance(); AG.setID(tabla.getId()); AG.setMonto(tabla.getMonto()); AG.setCategoria(tabla.getCategoria()); AG.setPago(tabla.getPago()); AG.setActualizacion(true); try { parent = FXMLLoader.load(this.getClass() .getResource("/fxml/AgregarGastos.fxml")); } catch (IOException ex) { Logger.getLogger(FXMLController.class.getName()) .log(Level.SEVERE, null, ex); } } else { AgregarIngresos AI = AgregarIngresos.getInstance(); AI.setID(tabla.getId()); AI.setMonto(tabla.getMonto()); AI.setCategoria(tabla.getCategoria()); AI.setPago(tabla.getPago()); AI.setActualizar(true); try { parent = FXMLLoader.load(this.getClass() .getResource("/fxml/AgregarIngresos.fxml")); } catch (IOException ex) { Logger.getLogger(FXMLController.class.getName()) .log(Level.SEVERE, null, ex); } } Stage stage = new Stage(); Scene scene = new Scene(parent); stage.setScene(scene); stage.show(); } }); vbox.getChildren().add(boton); setGraphic(vbox); } else { setGraphic(null); } } }; } }); } }; new Thread(tarea).start(); }
From source file:retsys.client.controller.PurchaseOrderConfirmController.java
/** * Initializes the controller class./*from w w w . j av a 2s. com*/ */ @Override public void initialize(URL url, ResourceBundle rb) { po_date.setValue(LocalDate.now()); loc_of_material.setCellValueFactory(new PropertyValueFactory<POItem, String>("location")); material_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("name")); brand_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("brand")); model_code.setCellValueFactory(new PropertyValueFactory<POItem, String>("model")); quantity.setCellValueFactory(new PropertyValueFactory<POItem, Integer>("quantity")); confirm.setCellValueFactory(new PropertyValueFactory<POItem, Boolean>("confirm")); confirm.setCellFactory(CheckBoxTableCell.forTableColumn(confirm)); billNo.setCellValueFactory(new PropertyValueFactory<POItem, String>("billNo")); billNo.setCellFactory(TextFieldTableCell.forTableColumn()); supervisor.setCellValueFactory(new PropertyValueFactory<POItem, String>("supervisor")); supervisor.setCellFactory(TextFieldTableCell.forTableColumn()); receivedDate.setCellValueFactory(new PropertyValueFactory<POItem, LocalDate>("receivedDate")); receivedDate.setCellFactory(new Callback<TableColumn<POItem, LocalDate>, TableCell<POItem, LocalDate>>() { @Override public TableCell<POItem, LocalDate> call(TableColumn<POItem, LocalDate> param) { TableCell<POItem, LocalDate> cell = new TableCell<POItem, LocalDate>() { @Override protected void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (empty || item == null) { setText(null); setGraphic(null); } else { setText(formatter.format(item)); } } @Override public void startEdit() { super.startEdit(); System.out.println("start edit"); DatePicker dateControl = null; if (this.getItem() != null) { dateControl = new DatePicker(this.getItem()); } else { dateControl = new DatePicker(); } dateControl.valueProperty().addListener(new ChangeListener<LocalDate>() { @Override public void changed(ObservableValue<? extends LocalDate> observable, LocalDate oldValue, LocalDate newValue) { if (newValue == null) { cancelEdit(); } else { commitEdit(newValue); } } }); this.setGraphic(dateControl); } @Override public void cancelEdit() { super.cancelEdit(); System.out.println("cancel edit"); setGraphic(null); if (this.getItem() != null) { setText(formatter.format(this.getItem())); } else { setText(null); } } @Override public void commitEdit(LocalDate newValue) { super.commitEdit(newValue); System.out.println("commit edit"); setGraphic(null); setText(formatter.format(newValue)); } }; return cell; } }); poDetail.getColumns().setAll(loc_of_material, material_name, brand_name, model_code, quantity, confirm, receivedDate, billNo, supervisor); AutoCompletionBinding<PurchaseOrder> bindForTxt_name = TextFields.bindAutoCompletion(project, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<PurchaseOrder>>() { @Override public Collection<PurchaseOrder> call(AutoCompletionBinding.ISuggestionRequest param) { List<PurchaseOrder> list = null; try { LovHandler lovHandler = new LovHandler("purchaseorders", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<PurchaseOrder>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<PurchaseOrder>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<PurchaseOrder>() { @Override public String toString(PurchaseOrder object) { System.out.println("here..." + object); String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format( LocalDateTime.ofInstant(object.getDate().toInstant(), ZoneId.systemDefault())); return "Project:" + object.getProject().getName() + " PO Date:" + strDate + " PO No.:" + object.getId(); } @Override public PurchaseOrder fromString(String string) { throw new UnsupportedOperationException(); } }); bindForTxt_name .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<PurchaseOrder>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<PurchaseOrder> event) { populateData(event.getCompletion()); } }); AutoCompletionBinding<Vendor> bindForVendor = TextFields.bindAutoCompletion(vendor, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() { @Override public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) { List<Vendor> list = null; try { LovHandler lovHandler = new LovHandler("vendors", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Vendor>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Vendor>() { @Override public String toString(Vendor object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Vendor fromString(String string) { throw new UnsupportedOperationException(); } }); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void addDateColumn() { final TableColumn<DateBean, LocalDate> col = new TableColumn<>("Date"); col.setCellValueFactory(new PropertyValueFactory<>("date")); col.setCellFactory(column -> {//from w w w.ja va 2 s . c o m return new TableCell<DateBean, LocalDate>() { @Override protected void updateItem(final LocalDate item, final boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setText(null); setStyle(""); } else { setText(DrBookingsApplication.DATE_FORMATTER.format(item)); } } }; }); col.getStyleClass().addAll("center-left"); tableView.getColumns().add(col); }
From source file:dtv.controller.FXMLMainController.java
public void init(ObservableList<DVBChannel> serviceData, TableView<DVBChannel> table, TableColumn<DVBChannel, Integer> idx, TableColumn<DVBChannel, String> name, TableColumn<DVBChannel, String> type, TableColumn<DVBChannel, String> ppr) { table.setEditable(true);//from w w w . ja v a 2s . c om idx.setCellValueFactory(cellData -> cellData.getValue().idxProperty().asObject()); name.setCellValueFactory(cellData -> cellData.getValue().nameProperty()); name.setEditable(true); type.setCellValueFactory(cellData -> cellData.getValue().typeProperty()); // nid.setCellValueFactory(cellData -> cellData.getValue().nidProperty().asObject()); ppr.setCellValueFactory(cellData -> cellData.getValue().pprProperty()); // newCol.setCellValueFactory(cellData -> cellData.getValue().neewProperty()); // Context menu table.setRowFactory(tableView -> { final TableRow<DVBChannel> row = new TableRow<>(); final ContextMenu rowMenu = new ContextMenu(); final MenuItem removeItem = new MenuItem("Delete"); removeItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { final DVBChannel service = row.getItem(); serviceData.removeAll(service); } }); rowMenu.getItems().addAll(removeItem); row.contextMenuProperty().bind(Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu) .otherwise((ContextMenu) null)); return row; }); ppr.setCellFactory(col -> { final TableCell<DVBChannel, String> cell = new TableCell<>(); cell.textProperty().bind(cell.itemProperty()); cell.itemProperty().addListener((obs, oldValue, newValue) -> { if (newValue != null) { final ContextMenu cellMenu = new ContextMenu(); for (String pref : Utils.prefTab) { final CheckMenuItem prefMenuItem = new CheckMenuItem(pref); if (Utils.isPreferenceOn(cell.getText(), pref)) { prefMenuItem.setSelected(true); } prefMenuItem.selectedProperty().addListener((obs1, old_val, new_val) -> { final String new_ppr; final DVBChannel service = (DVBChannel) cell.getTableRow().getItem(); if (new_val) { new_ppr = Utils.add_ppr(cell.getText(), pref); } else { new_ppr = Utils.remove_ppr(cell.getText(), pref); } service.setPpr(new_ppr); service.setModified(true); }); cellMenu.getItems().add(prefMenuItem); cell.setContextMenu(cellMenu); } } else { cell.setContextMenu(null); } }); return cell; }); // Editable service name name.setCellFactory(p -> new EditingCell()); name.setOnEditCommit(t -> { final DVBChannel service = t.getTableView().getItems().get(t.getTablePosition().getRow()); service.setName(t.getNewValue()); service.setModified(true); }); }