List of usage examples for javafx.collections FXCollections observableArrayList
public static <E> ObservableList<E> observableArrayList(Collection<? extends E> col)
From source file:de.hs.mannheim.modUro.controller.diagram.SimulationDiagramController.java
/** * Sets Content of Choicebox./* w w w . j a v a2 s.c o m*/ */ private void setChoiceBoxContent() { List<String> name = choiceBoxMetrictypeNames(); leftMetricType.setItems(FXCollections.observableArrayList(name)); rightMetricType.setItems(FXCollections.observableArrayList(name)); leftMetricType.getSelectionModel().select(leftLastSelectedIndex.intValue()); rightMetricType.getSelectionModel().select(rightLastSelectedIndex.intValue()); }
From source file:org.dataconservancy.packaging.gui.presenter.impl.EditPackageContentsPresenterImplTest.java
/** * Tests that after changing artifact types, the package expansion in the tree remains the same *//*w ww. ja va2s .co m*/ @Test public void testItemExpansionStaysAfterArtifactTypeChanges() { presenter.rebuildTreeView(); view.getRoot().setExpanded(true); view.getRoot().getChildren().get(0).setExpanded(true); TreeItem before = view.getRoot(); presenter.changeType(FXCollections.observableArrayList(dataFile), profileService.getNodeTransforms(dataFile).get(0)); assertTrue(view.getRoot().isExpanded()); assertTrue(view.getRoot().getChildren().get(0).isExpanded()); assertNotSame(before, view.getRoot()); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
private void onNewTermingologyBase() { int minFrequency = 5; try {//from ww w .j ava2 s.com minFrequency = Integer.parseInt(txtMinFrequency.getText()); } catch (NumberFormatException nfe) { // do nothing } List<Term> terms = terminologyBase.getTermsByFrequency(minFrequency); tblTerms.setItems(FXCollections.observableArrayList(this.wrapTerms(terms))); this.pushTermTable(); btnReload.setDisable(false); }
From source file:acmi.l2.clientmod.l2smr.Controller.java
@Override public void initialize(URL url, ResourceBundle resourceBundle) { stageProperty().addListener(observable -> initializeKeyCombinations()); this.l2Path.textProperty().bind( Bindings.when(l2DirProperty().isNotNull()).then(Bindings.convert(l2DirProperty())).otherwise("")); initializeUnr();//ww w .ja v a 2 s. c o m initializeUsx(); this.filterPane.setExpanded(false); this.filterPane.setDisable(true); this.smaPane.setDisable(true); table.itemsProperty().bind(Bindings.createObjectBinding(() -> { if (actors.get() == null) return FXCollections.emptyObservableList(); return FXCollections .observableArrayList( actors.get().stream() .filter(actor -> !rotatable.isSelected() || actor.getRotation() != null) .filter(actor -> !scalable.isSelected() || actor.getScale() != null || actor.getScale3D() != null) .filter(actor -> !rotating.isSelected() || actor.getRotationRate() != null) .filter(actor -> filterStaticMesh.getText() == null || filterStaticMesh.getText().isEmpty() || actor.getStaticMesh().toLowerCase() .contains(filterStaticMesh.getText().toLowerCase())) .filter(actor -> { Double x = getDoubleOrClearTextField(filterX); Double y = getDoubleOrClearTextField(filterY); Double z = getDoubleOrClearTextField(filterZ); Double range = getDoubleOrClearTextField(filterRange); return range == null || range(actor.getLocation(), x, y, z) < range; }).collect(Collectors.toList())); }, actors, filterStaticMesh.textProperty(), filterX.textProperty(), filterY.textProperty(), filterZ.textProperty(), filterRange.textProperty(), rotatable.selectedProperty(), scalable.selectedProperty(), rotating.selectedProperty())); }
From source file:herudi.controller.customerController.java
private void selectData() { if (listData == null) { listData = FXCollections.observableArrayList(crud.select()); } else {//ww w .j a v a2 s. co m listData.clear(); listData.addAll(crud.select()); } tableData.setItems(listData); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void handleLimitButtonAction(ActionEvent event) { int maxCount = -1; String topStr = txtTop.getText(); try {//from ww w. j a va 2 s. c om maxCount = Integer.parseInt(topStr); } catch (NumberFormatException e) { this.showAlert("Top must be a number."); } this.setSelectedTerm(); ObservableList<Term> terms = tblTerms.getItems(); List<Term> limitedTerms = new ArrayList<Term>(maxCount); int i = 0; for (Term term : terms) { if (i == maxCount) break; limitedTerms.add(term); i++; } tblTerms.setItems(FXCollections.observableArrayList(limitedTerms)); this.pushTermTable(); }
From source file:jobhunter.gui.FXMLController.java
void showSubscriptionItems() { Subscription selected = subscriptionsList.getSelectionModel().getSelectedItem(); if (selected != null) { SubscriptionRepository.findById(selected.getId()).ifPresent(sub -> { if (sub.getFailed()) { if (!feedsTableViewContainer.getChildren().contains(feedErrorLabel)) feedsTableViewContainer.getChildren().add(feedErrorLabel); } else { feedsTableViewContainer.getChildren().remove(feedErrorLabel); }// w w w.j a va 2 s . com subscriptionItemsTable.setItems(FXCollections.observableArrayList(sub.getSortedItems())); subscriptionItemsTable.getSelectionModel().clearSelection(); subscriptionItemsTable.requestFocus(); subscriptionItemsTable.getSelectionModel().selectFirst(); subscriptionItemsTable.getFocusModel().focus(0); subscriptionItemsTable.scrollTo(0); subscriptionTableClick(null); }); } else { subscriptionItemsTable.setItems(null); } }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
@FXML void onRefresh(ActionEvent event) { try {/*from w w w. ja v a 2 s .c om*/ tableStudy.setItems(FXCollections.observableArrayList(dataManager.getStudies().queryForAll())); tablePlate.setItems(FXCollections.observableArrayList(dataManager.getPlates().queryForAll())); tableSample.setItems(FXCollections.observableArrayList(dataManager.getSamples().queryForAll())); tableInjection.setItems(FXCollections.observableArrayList(dataManager.getInjections().queryForAll())); tableCompound.setItems(FXCollections.observableArrayList(dataManager.getCompounds().queryForAll())); tableHistory .setItems(FXCollections.observableArrayList(dataManager.getOperationHistories().queryForAll())); choicePlate.setItems(FXCollections.observableArrayList(dataManager.getPlates().queryForAll())); choicePlate.valueProperty().addListener(e -> { refreshPlateIntensity(choicePlate.getSelectionModel().getSelectedItem()); }); if (choicePlate.getItems().size() > 0) refreshPlateIntensity(choicePlate.getSelectionModel().getSelectedItem()); stackPlateIntensity.getChildren().clear(); JFreeChart chart = getChartForGlobalQC(); if (chart == null) { globalQCIntensity.setDisable(true); } else { globalQCIntensity.setDisable(false); stackGlobalQCIntensity.getChildren().clear(); ChartCanvas canvas = new ChartCanvas(chart); canvas.heightProperty().bind(stackGlobalQCIntensity.heightProperty()); canvas.widthProperty().bind(stackGlobalQCIntensity.widthProperty()); stackGlobalQCIntensity.getChildren().add(canvas); } commandManagerContext.setDataManager(dataManager); } catch (SQLException e) { e.printStackTrace(); AlertHelper.showExceptionAlert("Cannot refresh data", null, e); } }
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
@FXML void initialize() { assert clearLogButton != null : "fx:id=\"clearLogButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTable != null : "fx:id=\"fundsTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert logField != null : "fx:id=\"logField\" was not injected: check your FXML file 'mainlayout.fxml'."; assert buyButton != null : "fx:id=\"buyButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert sellButton != null : "fx:id=\"sellButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert showActiveOrdersButton != null : "fx:id=\"showActiveOrdersButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableLastColumn != null : "fx:id=\"tickerTableLastColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTablePairColumn != null : "fx:id=\"tickerTablePairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTable != null : "fx:id=\"tickersTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableBuyColumn != null : "fx:id=\"tickersTableBuyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableFeeColumn != null : "fx:id=\"tickersTableFeeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableSellColumn != null : "fx:id=\"tickersTableSellColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeAmountValue != null : "fx:id=\"tradeAmountValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceCurrencyType != null : "fx:id=\"tradeCurrencyPriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeCurrencyType != null : "fx:id=\"tradeCurrencyType\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceValue != null : "fx:id=\"tradePriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert updateFundsButton != null : "fx:id=\"updateFundsButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableCurrencyColumn != null : "fx:id=\"fundsTableCurrencyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableValueColumn != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTable != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersAmountColumn != null : "fx:id=\"activeOrdersAmountColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersPairColumn != null : "fx:id=\"activeOrdersPairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersRateColumn != null : "fx:id=\"activeOrdersRateColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTimeColumn != null : "fx:id=\"activeOrdersTimeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTypeColumn != null : "fx:id=\"activeOrdersTypeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersCancelColumn != null : "fx:id=\"activeOrdersCancelColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; //Holder for all main API methods of exchange app = new App(); //Loading configs loadExchangeConfig();//from w ww .j ava2 s. c o m //Populate choiceboxes at the trading section tradeCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradeCurrencyType.setValue(currencies.get(0)); tradePriceCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradePriceCurrencyType.setValue(currencies.get(0)); //Active Orders table activeOrdersAmountColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("amount")); activeOrdersPairColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("pair")); activeOrdersRateColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("rate")); activeOrdersTimeColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ActiveOrder, String> activeOrderStringCellDataFeatures) { ActiveOrder activeOrder = activeOrderStringCellDataFeatures.getValue(); DateFormat dateFormat = DateFormat.getDateTimeInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(activeOrder.getTimestamp() * 1000); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); activeOrdersTypeColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("type")); activeOrdersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeOrdersCancelColumn .setCellFactory(new Callback<TableColumn<ActiveOrder, Boolean>, TableCell<ActiveOrder, Boolean>>() { @Override public TableCell<ActiveOrder, Boolean> call( TableColumn<ActiveOrder, Boolean> activeOrderBooleanTableColumn) { return new ButtonCell<>(activeOrdersTable); } }); activeOrdersCancelColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<ActiveOrder, Boolean> activeOrderBooleanCellDataFeatures) { return new SimpleBooleanProperty(true); } }); //Tickers Table MenuItem showOrdersBook = new MenuItem("Show Orders Book"); MenuItem showPublicTrades = new MenuItem("Show Public Trades"); ContextMenu contextMenu = new ContextMenu(showOrdersBook, showPublicTrades); tickersTable.setItems(tickers); tickersTable.setContextMenu(contextMenu); tickersTableBuyColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("buy")); tickersTableFeeColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("fee")); tickersTableSellColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("sell")); tickersTableLastColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("last")); tickersTablePairColumn.setCellValueFactory(new PropertyValueFactory<Ticker, String>("pair")); tickersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tickersTable.setRowFactory(new Callback<TableView<Ticker>, TableRow<Ticker>>() { @Override public TableRow<Ticker> call(TableView<Ticker> tickerTableView) { return new TableRow<Ticker>() { @Override protected void updateItem(Ticker ticker, boolean b) { super.updateItem(ticker, b); if (!b) { if (tickersData.containsKey(ticker.getPair())) { if (ticker.getLast() < tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(186, 0, 0, 0.5);"); } else if (ticker.getLast() == tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(215, 193, 44, 0.5);"); } else { setStyle("-fx-control-inner-background: rgba(0, 147, 0, 0.5);"); } } } } }; } }); //Menu item to show Orders Book showOrdersBook.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_ORDERS_BOOK_LAYOUT), resources); root = (Parent) fxmlLoader.load(); OrdersBookController ordersBookController = fxmlLoader.getController(); ordersBookController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Orders Book for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Menu item to show Public Trades showPublicTrades.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_TRADES_LAYOUT), resources); root = (Parent) fxmlLoader.load(); PublicTradesController publicTradesController = fxmlLoader.getController(); publicTradesController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Public Trades for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Funds Table fundsTableCurrencyColumn.setCellValueFactory(new PropertyValueFactory<Fund, String>("currency")); fundsTableValueColumn.setCellValueFactory(new PropertyValueFactory<Fund, Double>("value")); fundsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); fundsTable.setItems(fundsData); //Task to load tickers data from server final javafx.concurrent.Service loadTickersService = new javafx.concurrent.Service() { @Override protected Task createTask() { Task<JSONObject> loadTickers = new Task<JSONObject>() { @Override protected JSONObject call() throws Exception { String[] pairsArray = new String[pairs.size()]; pairsArray = pairs.toArray(pairsArray); return App.getPairInfo(pairsArray); } }; loadTickers.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { logField.appendText(workerStateEvent.getSource().getException().getMessage() + "\r\n"); } }); loadTickers.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONObject jsonObject = (JSONObject) workerStateEvent.getSource().getValue(); //ugly hack to store old values //dump old values to tickersData //TODO think about better solution if (tickers.size() != 0) { for (Ticker x : tickers) { tickersData.put(x.getPair(), x); } } tickers.clear(); for (Iterator iterator = jsonObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); JSONObject data = jsonObject.getJSONObject(key); Ticker ticker = new Ticker(); ticker.setPair(key); ticker.setUpdated(data.optLong("updated")); ticker.setAvg(data.optDouble("avg")); ticker.setBuy(data.optDouble("buy")); ticker.setSell(data.optDouble("sell")); ticker.setHigh(data.optDouble("high")); ticker.setLast(data.optDouble("last")); ticker.setLow(data.optDouble("low")); ticker.setVol(data.optDouble("vol")); ticker.setVolCur(data.optDouble("vol_cur")); tickers.add(ticker); } } }); return loadTickers; } }; //Update tickers every 15 seconds //TODO better solution is required Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { loadTickersService.restart(); } }), new KeyFrame(Duration.seconds(15))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.playFromStart(); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void handleReloadButtonAction(ActionEvent event) { boolean haveCriteria = false; int minFrequency = -1; if (txtMinFrequency.getText().trim().length() > 0) { try {// ww w. ja v a2 s. c o m minFrequency = Integer.parseInt(txtMinFrequency.getText()); haveCriteria = true; } catch (NumberFormatException nfe) { this.showAlert("Min Frequency must be a number."); return; } } String searchText = txtSearch.getText(); boolean marked = chkMarked.isSelected(); boolean markedExpansions = chkExpansions.isSelected(); haveCriteria = minFrequency > 0 || searchText.length() > 0 || marked; if (haveCriteria) { this.setSelectedTerm(); List<Term> terms = terminologyBase.getTerms(minFrequency, searchText, marked, markedExpansions); tblTerms.setItems(FXCollections.observableArrayList(this.wrapTerms(terms))); this.pushTermTable(); } else { this.showAlert("No selection criteria entered."); } }