List of usage examples for javafx.collections ObservableList addAll
public boolean addAll(E... elements);
From source file:com.cyberlogix.mist6020biometrics.RosterController.java
public void seedTable() { System.out.println("Seeding Table"); students = new ArrayList<>(); ObjectMapper jackson = new ObjectMapper(); try {//w w w.j av a 2 s .c o m String url = ServerConnect.STUDENTS_URL + "/all"; ServerConnect sc = new ServerConnect(); ServerResponse msg = sc.processRequest("", url, ServerConnect.METHOD_GET); if (msg.getStatusCode() == 200 || msg.getStatusCode() == 201) { JSONArray payload = msg.getResponse().getJSONArray("payload"); System.err.println(payload); if (payload.length() > 0) { for (int i = 0; i < payload.length(); i++) { Student student = jackson.readValue(payload.getJSONObject(i).toString(), Student.class); students.add(student); } ObservableList<Student> data = FXCollections.observableArrayList(); data.addAll(students); //add Data to table colRegNo.setCellValueFactory(new PropertyValueFactory<Student, String>("regNo")); colName.setCellValueFactory(new PropertyValueFactory<Student, String>("name")); colSignedIn.setCellValueFactory(new PropertyValueFactory<Student, String>("signedIn")); colSignedIn.setStyle("-fx-text-fill: green; -fx-font-weight: bold;"); tblRoster.setItems(data); } } else { // Dialogs.showErrorDialog(new Stage(), msg.getResponse().getString("message"), "Error " + msg.getStatusCode(), "Error"); alertBox.setText(msg.getResponse().getString("message")); alertBox.setStyle("-fx-text-fill: red; -fx-font-weight: bold;"); } } catch (JSONException | IOException e) { UtilHelper.debugTrace(e); } }
From source file:jp.toastkid.script.Controller.java
/** * Set stage to this controller and apply style. * @param stage/*from ww w.j a v a2s .c om*/ */ public void setStage(final Stage stage) { this.stage = stage; final ObservableList<String> stylesheets = this.stage.getScene().getStylesheets(); if (stylesheets != null) { stylesheets.clear(); } stylesheets.addAll(stage.getScene().getStylesheets()); stylesheets.add(getClass().getClassLoader().getResource("keywords.css").toExternalForm()); }
From source file:com.gmail.frogocomics.schematic.gui.Main.java
@Override public void start(Stage primaryStage) throws Exception { this.primaryStage = primaryStage; this.root = new GridPane(); this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE); Label title = new Label("Schematic Utilities"); title.setId("schematic-utilities"); title.setPrefWidth(this.primaryScene.getWidth() + 500); this.root.add(title, 0, 0); filesSelected.setId("files-selected"); this.root.add(filesSelected, 0, 1); Region spacer1 = new Region(); spacer1.setPrefWidth(30);//from w w w . j av a 2 s .co m spacer1.setPrefHeight(30); Region spacer2 = new Region(); spacer2.setPrefWidth(30); spacer2.setPrefHeight(30); Region spacer3 = new Region(); spacer3.setPrefWidth(30); spacer3.setPrefHeight(250); Region spacer4 = new Region(); spacer4.setPrefWidth(1000); spacer4.setPrefHeight(10); Region spacer5 = new Region(); spacer5.setPrefWidth(30); spacer5.setPrefHeight(30); Region spacer6 = new Region(); spacer6.setPrefWidth(1000); spacer6.setPrefHeight(10); Region spacer7 = new Region(); spacer7.setPrefWidth(1000); spacer7.setPrefHeight(100); Region spacer8 = new Region(); spacer8.setPrefWidth(30); spacer8.setPrefHeight(30); this.root.add(spacer4, 0, 3); listView.setId("schematic-list"); listView.setEditable(false); listView.setPrefWidth(500); listView.setPrefHeight(250); this.root.add(new HBox(spacer3, listView), 0, 4); uploadFiles.setPadding(new Insets(5, 5, 5, 5)); uploadFiles.setPrefWidth(120); uploadFiles.setPrefHeight(30); uploadFiles.setOnAction((event) -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select schematic(s)"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"), new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2")); List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage); if (selectedFiles != null) { if (selectedFiles.size() == 1) { filesSelected.setText("There is currently 1 file selected"); } else { filesSelected.setText( "There are currently " + String.valueOf(selectedFiles.size()) + " files selected"); } ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList(); selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName())) .collect(Collectors.toList())); listView.setItems(selectedSchematicFiles); this.schematics = selectedSchematicFiles; } }); this.root.add(new HBox(spacer1, uploadFiles, spacer2, new Label("Only .schematic files are allowed at this point!")), 0, 2); editing.setPadding(new Insets(5, 5, 5, 5)); editing.setPrefWidth(240); editing.setPrefHeight(30); editing.setDisable(true); editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene())); this.root.add(new HBox(spacer8, editing), 0, 8); loadSchematics.setPadding(new Insets(5, 5, 5, 5)); loadSchematics.setPrefWidth(120); loadSchematics.setPrefHeight(30); loadSchematics.setOnAction(event -> { if (this.schematics != null) { ((Runnable) () -> { for (SchematicLocation location : this.schematics) { if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) { try { Schematics.schematics.add(McEditSchematicObject.load(location.getLocation())); } catch (ParseException | ClassicNotSupportedException | IOException e) { e.printStackTrace(); } } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) { try { Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation())); } catch (IOException e) { e.printStackTrace(); } } } }).run(); loadSchematics.setDisable(true); uploadFiles.setDisable(true); listView.setDisable(true); editing.setDisable(false); } }); this.root.add(spacer6, 0, 5); this.root.add(new HBox(spacer5, loadSchematics), 0, 6); this.root.add(spacer7, 0, 7); this.primaryScene.getStylesheets() .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800"); this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm()); this.primaryStage.setScene(this.primaryScene); this.primaryStage.setResizable(false); this.primaryStage.setTitle("Schematic Utilities - by frogocomics"); this.primaryStage.show(); }
From source file:org.beryx.viewreka.fxapp.ProjectLibs.java
public void addBundles() { List<BundleInfo> bundleEntries = lstLib.getItems().stream().map(libEntry -> libEntry.getBundleInfo()) .filter(Objects::nonNull).collect(Collectors.toList()); BundleChooser bundleChooser = BundleChooser.createWith(guiSettingsManager, bundleEntries, existingBundles); bundleChooser.showDialog("Viewreka Bundles"); List<LibListEntry> uncataloged = lstLib.getItems().stream().filter(entry -> entry.getBundleInfo() == null) .collect(Collectors.toList()); List<LibListEntry> bundles = bundleChooser.getSelectedBundlesMap().values().stream() .map(LibListEntry::forBundleInfo).collect(Collectors.toList()); ObservableList<LibListEntry> items = lstLib.getItems(); items.clear();/*from ww w . j a v a 2 s . c om*/ items.addAll(bundles); items.addAll(uncataloged); }
From source file:com.ggvaidya.scinames.ui.BulkChangeEditorController.java
public void setBulkChangeEditor(BulkChangeEditor bce) { bulkChangeEditor = bce;//w w w.j a v a 2s . c om project = bce.getProjectView().getProject(); List<DatasetColumn> columns = project.getDatasets().stream().flatMap(ds -> ds.getColumns().stream()) .distinct().collect(Collectors.toList()); comboBoxNameIdentifiers.setItems(FXCollections.observableArrayList(columns)); comboBoxMethods.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> { ChangeGenerator generator = comboBoxMethods.getSelectionModel().getSelectedItem(); if (generator.needsDatasetColumn()) { // Activate it if this method needs a column comboBoxNameIdentifiers.setDisable(false); } else { // Otherwise comboBoxNameIdentifiers.setDisable(true); } }); ObservableList<Dataset> datasets = FXCollections.observableArrayList(); datasets.add(ALL); datasets.addAll(project.getDatasets()); datasetsComboBox.setItems(datasets); datasetsComboBox.getSelectionModel().clearAndSelect(0); setupChangesTableView(); // findChanges(); }
From source file:com.SignalDiagram.FXMLDocumentController.java
private void updateAnalogChart(List<XYChart.Series<Double, Double>> serieList, ObservableList<XYChart.Series<Double, Double>> chartData, AnalogSignal signal) { chartData.clear();/*ww w.ja v a 2s.c om*/ serieList.clear(); for (List<Point2D> lp : signal.getPoints()) { XYChart.Series<Double, Double> test = updatePoints(lp); serieList.add(updatePoints(lp)); } chartData.addAll(serieList); }
From source file:com.github.technosf.posterer.controllers.impl.RequestController.java
/** * Validate the security Certificate selected * <p>//from ww w.ja v a2 s .c om * Loads the certificate and give it to the cert viewer */ public void certificateValidate() { KeyStoreBean keyStore = null; try { keyStore = new KeyStoreBean(certificateFileChooser.getValue(), certificatePassword.getText()); KeyStoreViewerController.loadStage(keyStore).show(); ObservableList<String> aliases = FXCollections.observableArrayList("Do not use certificate"); aliases.addAll(keyStore.getAliases()); useAlias.itemsProperty().setValue(aliases); useAlias.setDisable(false); } catch (KeyStoreBeanException e) { logger.debug(e.getMessage(), e); statusController.appendStatus("Certificate file cannot be opened: [%1$s]", e.getCause().getMessage()); } }
From source file:herudi.controller.customerController.java
private void displayZip() { Service<ObservableList<MicroMarket>> service = new Service<ObservableList<MicroMarket>>() { @Override//from w w w . j a v a 2 s.c o m protected Task<ObservableList<MicroMarket>> createTask() { return new Task<ObservableList<MicroMarket>>() { @Override protected ObservableList<MicroMarket> call() throws Exception { ObservableList<MicroMarket> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectZip()); } else { listTask.clear(); listTask.addAll(crud.selectZip()); } cbZip.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.customerController.java
private void displayDiscountCode() { Service<ObservableList<DiscountCode>> service = new Service<ObservableList<DiscountCode>>() { @Override/* w w w.ja v a 2 s . co m*/ protected Task<ObservableList<DiscountCode>> createTask() { return new Task<ObservableList<DiscountCode>>() { @Override protected ObservableList<DiscountCode> call() throws Exception { ObservableList<DiscountCode> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectCode()); } else { listTask.clear(); listTask.addAll(crud.selectCode()); } cbDiscount.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.productController.java
private void displayProductCode() { Service<ObservableList<ProductCode>> service = new Service<ObservableList<ProductCode>>() { @Override//from w w w .j a v a 2 s. c om protected Task<ObservableList<ProductCode>> createTask() { return new Task<ObservableList<ProductCode>>() { @Override protected ObservableList<ProductCode> call() throws Exception { ObservableList<ProductCode> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectProductCode()); } else { listTask.clear(); listTask.addAll(crud.selectProductCode()); } cbProductCode.setItems(listTask); return listTask; } }; } }; service.start(); }