public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) { Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell"); TableRow<?> row = null; for (Node tableRow : tableRowCell) { TableRow<?> r = (TableRow<?>) tableRow; if (r.getIndex() == rowIndex) { row = r; break; } } Set<Node> cells = row.lookupAll(".table-cell"); for (Node node : cells) { TableCell<?, ?> cell = (TableCell<?, ?>) node; if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) { Bounds bounds = cell.getBoundsInParent(); Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2); Point2D rowLocal = row.localToScene(localToParent, true); return rowLocal; } } return null; }
@Test public void scrollToRow() throws Throwable { Stage primaryStage = getPrimaryStage(); primaryStage.setWidth(250); primaryStage.setHeight(250); TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view"); Platform.runLater(() -> { tableView.marathon_select("{\"rows\":[10]}"); }); new Wait("Wating for rows to be select.") { @Override public boolean until() { return tableViewNode.getSelectionModel().getSelectedIndex() == 10; } }; new Wait("Waiting for the point to be in viewport") { @Override public boolean until() { Point2D point = getPoint(tableViewNode, 1, 10); return tableViewNode.getBoundsInLocal().contains(point); } }; }
public void start(Stage primaryStage) throws Exception { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getLayout("server.fxml")); StackPane root = new StackPane(); root.getChildren().add((Node)loader.load()); s = new Scene(root, 800, 480); primaryStage.setScene(s); primaryStage.show(); this.primaryStage = primaryStage; this.table = (TableView<TX>) s.lookup("#table"); this.model = FXCollections.observableArrayList(); this.table.setItems(model); ObservableList<TableColumn<TX, ?>> cols = this.table.getColumns(); TableColumn<TX, Integer> id = (TableColumn<TX, Integer>)cols.get(0); id.setCellValueFactory(cellData -> cellData.getValue().id.asObject()); TableColumn<TX, String> pin = (TableColumn<TX, String>)cols.get(1); pin.setCellValueFactory(cellData -> cellData.getValue().pin); TableColumn<TX, String> desc = (TableColumn<TX, String>)cols.get(2); desc.setCellValueFactory(cellData -> cellData.getValue().desc); TableColumn<TX, String> status = (TableColumn<TX, String>)cols.get(3); status.setCellValueFactory(cellData -> cellData.getValue().status); TableColumn<TX, String> amount = (TableColumn<TX, String>)cols.get(4); amount.setCellValueFactory(cellData -> cellData.getValue().amount); TableColumn<TX, Long> time = (TableColumn<TX, Long>)cols.get(5); time.setCellValueFactory(cellData -> cellData.getValue().timeFilled.asObject()); primaryStage.setOnCloseRequest((WindowEvent event) -> System.exit(0)); onRequestReceived(-1, "Test TX", new BigDecimal(1)); CryptoServer server = new CryptoServer(location, this); Thread t = new Thread(server); t.start(); }
private TableView<OrganizationView> createOrganizationTable(ObservableList<OrganizationView> orgas) { TableView<OrganizationView> result = new TableView<>(orgas); TableColumn<OrganizationView, String> name = new TableColumn<>("Name"); TableColumn<OrganizationView, String> owned = new TableColumn<>("Owned"); TableColumn<OrganizationView, Integer> serverCount = new TableColumn<>("Servers"); name.setCellValueFactory(new PropertyValueFactory<>("name")); serverCount.setCellValueFactory(new PropertyValueFactory<>("serverCount")); owned.setCellValueFactory(new PropertyValueFactory<>("isOwned")); serverCount.setMinWidth(70); serverCount.setMaxWidth(70); owned.setMaxWidth(70); owned.setMinWidth(70); result.getColumns().add(name); result.getColumns().add(serverCount); result.getColumns().add(owned); return result; }
static <T> TableView<ClassifierResult<T>> createClassifierTable() { TableView<ClassifierResult<T>> ret = new TableView<>(); ret.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); TableColumn<ClassifierResult<T>, String> tab0 = new TableColumn<>("name"); tab0.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getName())); ret.getColumns().add(tab0); TableColumn<ClassifierResult<T>, String> tab1 = new TableColumn<>("score"); tab1.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore()))); ret.getColumns().add(tab1); TableColumn<ClassifierResult<T>, Double> tab2 = new TableColumn<>("weight"); tab2.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getWeight())); ret.getColumns().add(tab2); TableColumn<ClassifierResult<T>, String> tab3 = new TableColumn<>("w. score"); tab3.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore() * data.getValue().getClassifier().getWeight()))); ret.getColumns().add(tab3); ret.setItems(FXCollections.observableArrayList()); return ret; }
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) { Set<Node> lookupAll = getTableCells(tableView); TableCell<?, ?> cell = null; for (Node node : lookupAll) { TableCell<?, ?> cell1 = (TableCell<?, ?>) node; TableRow<?> tableRow = cell1.getTableRow(); TableColumn<?, ?> tableColumn = cell1.getTableColumn(); if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) { cell = cell1; break; } } if (cell != null) { return cell; } return null; }
@SuppressWarnings("unchecked") public void selectCells(TableView<?> tableView, String value) { @SuppressWarnings("rawtypes") TableViewSelectionModel selectionModel = tableView.getSelectionModel(); selectionModel.clearSelection(); JSONObject cells = new JSONObject(value); JSONArray object = (JSONArray) cells.get("cells"); for (int i = 0; i < object.length(); i++) { JSONArray jsonArray = object.getJSONArray(i); int rowIndex = Integer.parseInt(jsonArray.getString(0)); int columnIndex = getColumnIndex(jsonArray.getString(1)); @SuppressWarnings("rawtypes") TableColumn column = tableView.getColumns().get(columnIndex); if (getVisibleCellAt(tableView, rowIndex, columnIndex) == null) { tableView.scrollTo(rowIndex); tableView.scrollToColumn(column); } selectionModel.select(rowIndex, column); } }
@FXML private void btnMapDevicesAction() { try { FXMLLoader loader = new FXMLLoader(MainDisplay.class.getResource("/fxml/MapDevicesDialog.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.UNDECORATED); stage.setScene(scene); stage.show(); Node node = scene.lookup("#tblMapDevice"); if(node instanceof TableView) { TableView<Pair<String, String>> table = (TableView)node; ArrayList<Pair<String, String>> pairList = new ArrayList<>(); dataContainer.getDeviceMap().entrySet().forEach(entry -> pairList.add(new Pair<String, String>(entry.getKey(), entry.getValue()))); ObservableList<Pair<String, String>> tableModel = FXCollections.<Pair<String, String>> observableArrayList(pairList); table.setItems(tableModel); } } catch(IOException e) { e.printStackTrace(); } }
@Override @SuppressWarnings("unchecked") protected void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty) { TableView<DesignVariable> tv = getTableView(); TableRow<DesignVariable> tr = getTableRow(); if ((tv != null) && (tr != null)) { if (tv.getItems().get(getTableRow().getIndex()).isOutput()) { setTextFill(Color.BLUE); } else if (tv.getItems().get(getTableRow().getIndex()).getValue().equals("INVALID")) { setTextFill(Color.ORANGE); } else { setTextFill(Color.GREEN); } } else { setTextFill(Color.YELLOW); } setText(item); } else { setText(""); } }
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) { if (selector.equals("mnth-cell")) { return Arrays.asList( new JavaFXTableCellElement(this, ((Integer) params[0]).intValue() - 1, ((Integer) params[1]).intValue() - 1)); } else if (selector.equals("all-cells")) { TableView<?> tableView = (TableView<?>) getComponent(); int rowCount = tableView.getItems().size(); int columnCount = tableView.getColumns().size(); ArrayList<IJavaFXElement> r = new ArrayList<>(); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { r.add(new JavaFXTableCellElement(this, i, j)); } } return r; } else if (selector.equals("select-by-properties")) { return findSelectByProperties(new JSONObject((String) params[0])); } return super.getByPseudoElement(selector, params); }
@Test public void scrollMultipleRows() { Stage primaryStage = getPrimaryStage(); primaryStage.setWidth(250); primaryStage.setHeight(250); TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view"); Platform.runLater(() -> { tableViewNode.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); tableView.marathon_select("{\"rows\":[2,9]}"); }); new Wait("Wating for rows to be select.") { @Override public boolean until() { return tableViewNode.getSelectionModel().getSelectedIndices().size() > 1; } }; new Wait("Waiting for the point to be in viewport") { @Override public boolean until() { Point2D point = getPoint(tableViewNode, 2, 9); return tableViewNode.getBoundsInLocal().contains(point); } }; }
@Test public void scrollTomnthCell() { Stage primaryStage = getPrimaryStage(); primaryStage.setWidth(250); primaryStage.setHeight(250); TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view"); List<String> columnName = new ArrayList<>(); Platform.runLater(() -> { JavaFXTableCellElement cell = (JavaFXTableCellElement) tableView.findElementByCssSelector(".::mnth-cell(7,3)"); cell.getPseudoComponent(); columnName.add(cell.getAttribute("viewColumnName")); }); new Wait("Wating cells column name.") { @Override public boolean until() { return columnName.size() > 0; } }; new Wait("Waiting for the point to be in viewport") { @Override public boolean until() { return getPoint(tableViewNode, 2, 7) != null; } }; Point2D point = getPoint(tableViewNode, 2, 7); AssertJUnit.assertTrue(tableViewNode.getBoundsInLocal().contains(point)); AssertJUnit.assertEquals("Email", columnName.get(0)); }
private void updateTableValues(ComboBox<String> traceNameComboBox) { if (openedWindowsCtr == 0) { return; } int selectedIndex = traceNameComboBox.getSelectionModel().getSelectedIndex(); if (selectedIndex == -1) { return; } GenericTrace<?> trace = plotData.getAllTraces().get(selectedIndex); List<PlotDataTableModel> dataList = new ArrayList<>(); for (int i = 0; i < trace.getxArray().length; i++) { if (trace.getxArray() == null) return; if (trace.getzArray() == null && trace.getyArray() == null) { dataList.add(new PlotDataTableModel(trace.getxArray()[i], 0.0, 0.0)); } else if (trace.getzArray() == null) { dataList.add(new PlotDataTableModel(trace.getxArray()[i], trace.getyArray()[i], 0.0)); } else { dataList.add(new PlotDataTableModel(trace.getxArray()[i], trace.getyArray()[i], trace.getzArray()[i])); } } table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.setItems(FXCollections.observableArrayList(dataList)); }
private TableView<MemoryRow> createMemoryTable() { TableView<MemoryRow> table = new TableView<>(); table.setEditable(true); TableColumn<MemoryRow, String> idColumn = new TableColumn<>("Address"); idColumn.setCellValueFactory(memoryFactory("address")); setPercentSize(table, idColumn, 0.5); table.getColumns().add(idColumn); TableColumn<MemoryRow, String> valueColumn = new TableColumn<>("Value"); valueColumn.setCellValueFactory(memoryFactory("value")); setPercentSize(table, valueColumn, 0.5); table.getColumns().add(valueColumn); table.setItems(memoryAddresses); table.setMinHeight(80); return table; }
@Override public Void call(Object p) { if(isIgnored(p)){return null;} final TableView<?> t = (TableView<?>) p; DnDPrepare.tableColumns(DragDropFX.this, t.getColumns()); t.getColumns().addListener(new ListChangeListener<TableColumn<?,?>>(){ @Override public void onChanged( javafx.collections.ListChangeListener.Change<? extends TableColumn<?, ?>> arg0) { while(arg0.next()){ if(arg0.wasAdded()){ DnDPrepare.tableColumns(DragDropFX.this, arg0.getAddedSubList()); } } } }); return null; }
@Test public void select() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { Point2D point = getPoint(tableView, 1, 1); TableCellFactorySample.EditingCell tf = (EditingCell) getCellAt(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); tf.startEdit(); tf.updateItem("Cell Modified", false); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Cell Modified", recording.getParameters()[0]); }
public VarsPanel(AppSession session) { this.session = session; table = new TableView(); table.setPrefWidth(300); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); setCenter(table); TableColumn nameCol = new TableColumn("Variable"); nameCol.setMinWidth(120); nameCol.setMaxWidth(250); nameCol.setCellValueFactory(new PropertyValueFactory("name")); nameCol.setCellFactory(c -> new StringTooltipCell()); TableColumn typeCol = new TableColumn("Type"); typeCol.setMinWidth(45); typeCol.setMaxWidth(60); typeCol.setCellValueFactory(new PropertyValueFactory("type")); TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value"); valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue())); valueCol.setCellFactory(c -> new VarValueCell()); table.getColumns().addAll(nameCol, typeCol, valueCol); table.setItems(session.getVars()); table.setRowFactory(tv -> { TableRow<Var> row = new TableRow<>(); row.setOnMouseClicked(e -> { if (e.getClickCount() == 2 && !row.isEmpty()) { Var var = row.getItem(); session.logVar(var); } }); return row ; }); }
@Test public void selectAllRows() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); Point2D point = getPoint(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); tableView.getSelectionModel().selectRange(0, 5); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("all", recording.getParameters()[0]); }
@SuppressWarnings("unchecked") @Test public void selectACell() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { tableView.getSelectionModel().setCellSelectionEnabled(true); Point2D point = getPoint(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); @SuppressWarnings("rawtypes") TableColumn column = getTableColumnAt(tableView, 1); tableView.getSelectionModel().select(1, column); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", recording.getParameters()[0]); }
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { tableView.getSelectionModel().setCellSelectionEnabled(true); tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); Point2D point = getPoint(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); @SuppressWarnings("rawtypes") TableColumn column = getTableColumnAt(tableView, 1); tableView.getSelectionModel().select(1, column); tableView.getSelectionModel().select(2, column); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"],[\"2\",\"Last\"]]}", recording.getParameters()[0]); }
@SuppressWarnings("unchecked") @Test public void selectAllCells() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { tableView.getSelectionModel().setCellSelectionEnabled(true); tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); Point2D point = getPoint(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); tableView.getSelectionModel().selectRange(0, getTableColumnAt(tableView, 0), 5, getTableColumnAt(tableView, 2)); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("all", recording.getParameters()[0]); }
@SuppressWarnings("unchecked") @Test public void getText() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); List<Object> text = new ArrayList<>(); Platform.runLater(() -> { tableView.getSelectionModel().setCellSelectionEnabled(true); Point2D point = getPoint(tableView, 1, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); @SuppressWarnings("rawtypes") TableColumn column = getTableColumnAt(tableView, 1); tableView.getSelectionModel().select(1, column); rfxTableView.focusLost(null); text.add(rfxTableView.getAttribute("text")); }); new Wait("Waiting for table text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", text.get(0)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void select() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { Point2D point = getPoint(tableView, 2, 1); ChoiceBoxTableCell cell = (ChoiceBoxTableCell) getCellAt(tableView, 1, 2); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); cell.startEdit(); tableView.edit(1, (TableColumn) tableView.getColumns().get(2)); Person person = (Person) tableView.getItems().get(1); person.setLastName("Jones"); cell.commitEdit("Jones"); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Jones", recording.getParameters()[0]); }
@Test public void select() { TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { Point2D point = getPoint(tableView, 0, 1); RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr); rfxTableView.focusGained(null); Person person = (Person) tableView.getItems().get(1); person.invitedProperty().set(true); rfxTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(":checked", recording.getParameters()[0]); }
private void defineTable() { tableView = new TableView<>(); TableColumn<JWKItem, String> idCol = new TableColumn<>("ID"); TableColumn<JWKItem, String> typeCol = new TableColumn<>("Type"); TableColumn<JWKItem, Boolean> privateCol = new TableColumn<>("Private"); TableColumn<JWKItem, String> keyUseCol = new TableColumn<>("Key Usage"); idCol.setCellValueFactory(new PropertyValueFactory<>("kid")); typeCol.setCellValueFactory(new PropertyValueFactory<>("keyType")); privateCol.setCellValueFactory(new PropertyValueFactory<>("privatePart")); keyUseCol.setCellValueFactory(new PropertyValueFactory<>("keyUse")); tableView.getColumns().addAll(idCol, typeCol, privateCol, keyUseCol); ObservableList<JWKItem> list = getItemList(); tableView.setItems(list); /* tableView.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null) { System.out.println(newSelection); } }); */ }
public ZsetAction(TableView dataTable, TableColumn rowColumn, TableColumn keyColumn, TableColumn valueColumn) { this.dataTable = dataTable; this.rowColumn = rowColumn; this.keyColumn = keyColumn; this.valueColumn = valueColumn; }
public StringAction(TableView dataTable, TableColumn rowColumn, TableColumn keyColumn, TableColumn valueColumn) { this.dataTable = dataTable; this.rowColumn = rowColumn; this.keyColumn = keyColumn; this.valueColumn = valueColumn; }
@SuppressWarnings("unchecked") private void configureBox(HBox root) { StackPane container = new StackPane(); //container.setPrefHeight(700); container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight()); container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;"); table= new TableView<AttClass>(); Label lview= new Label(); lview.setText("View Records"); lview.setId("lview"); bottomPane= new VBox(); tclock= new Text(); tclock.setId("lview"); //tclock.setFont(Font.font("Calibri", 20)); final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { tclock.setText(DateFormat.getDateTimeInstance().format(new Date())); } })); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); bottomPane.getChildren().addAll(tclock,lview); bottomPane.setAlignment(Pos.CENTER); //table pane namecol= new TableColumn<>("First Name"); namecol.setMinWidth(170); namecol.setCellValueFactory(new PropertyValueFactory<>("name")); admcol= new TableColumn<>("Identication No."); admcol.setMinWidth(180); admcol.setCellValueFactory(new PropertyValueFactory<>("adm")); typecol= new TableColumn<>("Type"); typecol.setMinWidth(130); typecol.setCellValueFactory(new PropertyValueFactory<>("type")); timecol= new TableColumn<>("Signin"); timecol.setMinWidth(140); timecol.setCellValueFactory(new PropertyValueFactory<>("timein")); datecol= new TableColumn<>("Date"); datecol.setMinWidth(180); datecol.setCellValueFactory(new PropertyValueFactory<>("date")); table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol); table.setItems(getAtt()); att= getAtt(); table.setItems(FXCollections.observableArrayList(att)); table.setMinHeight(500); btnrefresh = new Button("Refresh"); btnrefresh.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { table.setItems(getAtt()); } }); laytable= new VBox(10); laytable.getChildren().addAll(table, btnrefresh); laytable.setAlignment(Pos.TOP_LEFT); container.getChildren().addAll(bottomPane,laytable); setAnimation(); sc.setContent(container); root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)"); root.getChildren().addAll(getActionPane(),sc); //service.start(); }
public SetAction(TableView dataTable, TableColumn rowColumn, TableColumn keyColumn, TableColumn valueColumn) { this.dataTable = dataTable; this.rowColumn = rowColumn; this.keyColumn = keyColumn; this.valueColumn = valueColumn; }
public ProductFetcherTask(final TableView products) { valueProperty().addListener(new ChangeListener<ObservableList<FullProductListing>>() { @Override public void changed(ObservableValue<? extends ObservableList<FullProductListing>> ov, ObservableList<FullProductListing> oldValues, ObservableList<FullProductListing> newValues) { // insert results into table products.setItems(newValues); // remove progress indicator products.setPlaceholder(null); } }); }
private TableView<QuickViewEntry> createSectionView(QuickViewSection section) { String title = section.getTitle(); String contentHeader = section.getContentHeader(); String descriptionHeader = section.getDescriptionHeader(); TableView<QuickViewEntry> table = new TableView<>(); table.setEditable(false); table.setMouseTransparent(true); table.setFocusTraversable(false); table.getStylesheets().add("/noScrollTableView.css"); TableColumn<QuickViewEntry, String> headerColumn = new TableColumn<>(title); table.getColumns().add(headerColumn); TableColumn<QuickViewEntry, String> contentColumn = new TableColumn<>( contentHeader); contentColumn.setCellValueFactory(cellFactory("content")); setPercentSize(table, contentColumn, 0.4); headerColumn.getColumns().add(contentColumn); TableColumn<QuickViewEntry, String> descriptionColumn = new TableColumn<>( descriptionHeader); descriptionColumn.setCellValueFactory(cellFactory("description")); setPercentSize(table, descriptionColumn, 0.6); headerColumn.getColumns().add(descriptionColumn); ObservableList<QuickViewEntry> entries = FXCollections.observableArrayList(); entries.addAll(section.getEntries()); table.setItems(entries); int headerHeight = 50; int rows = entries.size(); table.setPrefHeight(rows * 24 + headerHeight); return table; }
@Override public void initialize(URL location, ResourceBundle resources) { tblPedidos.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); limparDados(); dtpData.requestFocus(); tabDados.setDisable(true); /* * TODO Sugest�o: Como esse campo n�o existe mais, voc� pode transformar * ele em SEMESTRAL e UNICA (al�m de tirar esse atributo da entidade) e * a� filtra pelas reservas que tem mesmo dia de come�o e fim (isso d� * pra fazer em uma linha usando LocalDate). */ ObservableList<EnumTipoReserva> comboTipo = FXCollections.observableArrayList(EnumTipoReserva.UNICA, EnumTipoReserva.SEMESTRAL); cmbTipo.setItems(comboTipo); ObservableList<EnumTipoServidor> servidores = FXCollections.observableArrayList(EnumTipoServidor.PROFESSOR); cmbServidor.setItems(servidores); tbcID.setCellValueFactory(new PropertyValueFactory<>("id")); tbcHorario.setCellValueFactory(new PropertyValueFactory<>("horarios")); tbcData.setCellValueFactory(new PropertyValueFactory<>("dataSolicitacao")); tbcTipo.setCellValueFactory(new PropertyValueFactory<>("tipo")); tbcDados.setCellValueFactory(new PropertyValueFactory<>("solicitante")); tbcDescricao.setCellValueFactory(new PropertyValueFactory<>("observacao")); // preencherDadosTblPedidos(reserva.getReservasEmAbertNaSemana(LocalDate.now())); preencherDadosTblPedidos(reserva.buscarReservasPedidas()); }
public int getColumnAt(TableView<?> tableView, Point2D point) { TableCell<?, ?> selected = getTableCellAt(tableView, point); if (selected == null) { return -1; } return tableView.getColumns().indexOf(selected.getTableColumn()); }
public int getRowAt(TableView<?> tableView, Point2D point) { TableCell<?, ?> selected = getTableCellAt(tableView, point); if (selected == null) { return -1; } return selected.getTableRow().getIndex(); }
private TableCell<?, ?> getTableCellAt(TableView<?> tableView, Point2D point) { point = tableView.localToScene(point); Set<Node> lookupAll = getTableCells(tableView); TableCell<?, ?> selected = null; for (Node cellNode : lookupAll) { Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true); if (boundsInScene.contains(point)) { selected = (TableCell<?, ?>) cellNode; break; } } return selected; }
private Set<Node> getTableCells(TableView<?> tableView) { Set<Node> l = tableView.lookupAll("*"); Set<Node> r = new HashSet<>(); for (Node node : l) { if (node instanceof TableCell<?, ?>) { r.add(node); } } return r; }
public List<String> getSelectedColumnText(TableView<?> tableView, int[] columns) { List<String> text = new ArrayList<String>(); for (int column : columns) { String columnName = getColumnName(tableView, column); text.add(escapeSpecialCharacters(columnName)); } return text; }