List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:statos2_0.StatOS2_0.java
private ObservableList<String> GetByTag() { JSONArray product = null;/* w ww. j a v a 2 s. c om*/ JSONParser jP = new JSONParser(); ArrayList<HashMap<String, String>> prod = new ArrayList<HashMap<String, String>>(); List<NameValuePair> params = new ArrayList<NameValuePair>(); // JSON URL JSONObject jsons = null; jsons = jP.makeHttpRequest(url_getstores, "GET", params); int success = jsons.getInt("success"); if (success == 1) { // // product = jsons.getJSONArray("products"); // for (int i = 0; i < product.length(); i++) { JSONObject c = product.getJSONObject(i); // json String id = c.getString("id"); String name = c.getString("name"); // HashMap HashMap<String, String> map = new HashMap<String, String>(); // HashMap => map.put("id", id); map.put("name", name); // HashList ArrayList prod.add(map); //System.out.println("prod="+prod); } } // ObservableList<String> al = FXCollections.observableArrayList(); //if(balance1.size()>=0){balanceadd();} // System.out.println("!!"+prod); for (int i = 0; i < prod.size(); i++) { al.add(prod.get(i).get("name")); } return al; }
From source file:musicmetadatak1009705.FolderTreeView.java
private TreeItem<File> createNode(final File f) { return new TreeItem<File>(f) { private boolean isLeaf; private boolean isFirstTimeChildren = true; private boolean isFirstTimeLeaf = true; @Override/*from w w w . ja va 2 s. c om*/ public ObservableList<TreeItem<File>> getChildren() { if (isFirstTimeChildren) { isFirstTimeChildren = false; super.getChildren().setAll(buildChildren(this)); } return super.getChildren(); } @Override public boolean isLeaf() { if (isFirstTimeLeaf) { isFirstTimeLeaf = false; File f = (File) getValue(); isLeaf = f.isFile(); } return isLeaf; } private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) { File f = TreeItem.getValue(); if (f == null) { return FXCollections.emptyObservableList(); } if (f.isFile()) { return FXCollections.emptyObservableList(); } File[] files = f.listFiles(); if (files != null) { ObservableList<TreeItem<File>> children = FXCollections.observableArrayList(); for (File childFile : files) { //System.out.println("Adding " + childFile.getAbsolutePath()); if (childFile.isDirectory()) { children.add(createNode(childFile)); } } return children; } return FXCollections.emptyObservableList(); } }; }
From source file:herudi.controller.customerController.java
private void displayDiscountCode() { Service<ObservableList<DiscountCode>> service = new Service<ObservableList<DiscountCode>>() { @Override//ww w . j a va 2 s . c o 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:com.properned.application.SystemController.java
public void initialize() { logger.info("Initialize System controller"); localeButton.disableProperty().bind(multiLanguageProperties.isLoadedProperty().not()); saveButton.disableProperty().bind(multiLanguageProperties.isDirtyProperty().not() .or(multiLanguageProperties.isLoadedProperty().not())); Stage primaryStage = Properned.getInstance().getPrimaryStage(); primaryStage.titleProperty()//from w ww . j a va 2 s . c om .bind(multiLanguageProperties.baseNameProperty() .concat(Bindings.when(multiLanguageProperties.isLoadedProperty()) .then(new SimpleStringProperty(" (") .concat(multiLanguageProperties.parentDirectoryPathProperty()).concat(")")) .otherwise("")) .concat(Bindings.when(multiLanguageProperties.isDirtyProperty()).then(" *").otherwise(""))); FilteredList<String> filteredList = new FilteredList<>(multiLanguageProperties.getListMessageKey(), new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); SortedList<String> sortedList = new SortedList<>(filteredList, new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); messageKeyList.setItems(sortedList); filterText.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { // Filter the list filteredList.setPredicate(new Predicate<String>() { @Override public boolean test(String t) { String filter = filterText.getText(); if (filter == null || filter.equals("")) { return true; } return t.contains(filter); } }); // check the add button disabled status if (isKeyCanBeAdded(newValue)) { addButton.setDisable(false); } else { addButton.setDisable(true); } } }); ChangeListener<String> changeMessageListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { logger.info("Message key selection changed : " + newValue); valueList.setItems(FXCollections.observableArrayList()); valueList.setItems(FXCollections .observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet())); } }; messageKeyList.getSelectionModel().selectedItemProperty().addListener(changeMessageListener); messageKeyList.setCellFactory(c -> new MessageKeyListCell(multiLanguageProperties)); valueList.setCellFactory(c -> new ValueListCell(multiLanguageProperties, messageKeyList)); filterText.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.DOWN) { messageKeyList.requestFocus(); event.consume(); } else if (event.getCode() == KeyCode.ENTER) { addKey(); event.consume(); } } }); }
From source file:gmailclientfx.controllers.InboxController.java
@Override public void initialize(URL url, ResourceBundle rb) { allMessages = FXCollections.observableArrayList(); fetchInboxThread = new Thread() { public void run() { //while(true) //{// ww w . ja v a 2 s .c o m fetchInbox(); //} } }; fetchInboxThread.start(); }
From source file:fr.ericlab.sondy.core.DataManipulation.java
public ObservableList<String> getAvailableStopwords(AppVariables appVariables) { ObservableList<String> stopwordsList = FXCollections.observableArrayList(); File dir = new File(appVariables.configuration.getWorkspace() + "/stopwords/"); boolean error = false; if (!dir.exists()) { try {/* w w w.j av a 2 s. co m*/ dir.mkdirs(); InputStream twitterInputStream = DataManipulation.class .getResource("/resources/stopwords/twitter(en)").openStream(); InputStream commonInputStream = DataManipulation.class .getResource("/resources/stopwords/common(en)").openStream(); OutputStream twitterOutStream = new FileOutputStream( new File(appVariables.configuration.getWorkspace() + "/stopwords/twitter(en)")); OutputStream commonOutStream = new FileOutputStream( new File(appVariables.configuration.getWorkspace() + "/stopwords/common(en)")); IOUtils.copy(twitterInputStream, twitterOutStream); IOUtils.copy(commonInputStream, commonOutStream); IOUtils.closeQuietly(twitterInputStream); IOUtils.closeQuietly(twitterOutStream); IOUtils.closeQuietly(commonInputStream); IOUtils.closeQuietly(commonOutStream); } catch (IOException ex) { Logger.getLogger(DataManipulation.class.getName()).log(Level.SEVERE, null, ex); error = true; appVariables.addLogEntry("[global] can't access workspace"); } } if (!error) { List<File> files = (List<File>) FileUtils.listFiles(dir, HiddenFileFilter.VISIBLE, null); for (File file : files) { stopwordsList.add("stopwords: " + file.getName()); } } return stopwordsList; }
From source file:retsys.client.controller.CreditNoteController.java
public void addItem(ActionEvent event) { sno++;/*from w w w .j a v a2s .c om*/ ObservableList<CreditNoteItem> list = creditNoteDetail.getItems(); if (list == null) { list = FXCollections.observableArrayList(); } Integer id = null; if (!creditNoteNo.getText().isEmpty()) { id = Integer.parseInt(creditNoteNo.getText()); } CreditNoteItem item = new CreditNoteItem(name.getText(), Double.parseDouble(amount.getText()), Double.parseDouble(quantity.getText()), true); list.add(item); totalCredit.setText(Double.toString(Double.sum(Double.parseDouble(totalCredit.getText() + "0"), Double.parseDouble(amount.getText()) * Double.parseDouble(quantity.getText())))); creditNoteDetail.setItems(list); }
From source file:herudi.controller.productController.java
private void displayManufacturer() { Service<ObservableList<Manufacturer>> service = new Service<ObservableList<Manufacturer>>() { @Override// ww w . ja v a 2s. c om protected Task<ObservableList<Manufacturer>> createTask() { return new Task<ObservableList<Manufacturer>>() { @Override protected ObservableList<Manufacturer> call() throws Exception { ObservableList<Manufacturer> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectManufacturerID()); } else { listTask.clear(); listTask.addAll(crud.selectManufacturerID()); } cbManufacturer.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.customerController.java
private void displayZip() { Service<ObservableList<MicroMarket>> service = new Service<ObservableList<MicroMarket>>() { @Override/*from www .j a v a 2 s . c om*/ 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:com.SignalDiagram.FXMLDocumentController.java
@Override public void initialize(URL url, ResourceBundle rb) { radBtn_amplitude.setToggleGroup(radioAnalogGroup); radBtn_frequence.setToggleGroup(radioAnalogGroup); radBtn_phase.setToggleGroup(radioAnalogGroup); txtField_bits.setText("1"); txtField_seed.setText("0"); m_analogSerieList = new ArrayList<>(); m_digitalSignal = new DigitalSignal(exampleMessage, modulationType.NRZ_L, false); m_analogSignal = new AnalogSignal(exampleMessage, AnalogSignal.analogType.AMPLITUDE); m_digitalChartData = FXCollections.observableArrayList(); m_analogChartData = FXCollections.observableArrayList(); m_digitalSerie = new LineChart.Series<>(); m_digitalSerie = updatePoints(m_digitalSignal.getPoints()); m_analogSignal.getPoints().stream().forEach((lp) -> { m_analogSerieList.add(updatePoints(lp)); });//w w w.j ava 2s. c o m m_digitalChartData.add(m_digitalSerie); m_digitalChart.setData(m_digitalChartData); //FIX m_analogChartData.addAll(m_analogSerieList); m_analogChart.setData(m_analogChartData); cmbBox_DigitalType.setItems(FXCollections.observableList(m_digitalSignal.getModulationTypes())); txtField_binaryInput.setText(m_digitalSignal.getMessage()); initListeners(); cmbBox_DigitalType.valueProperty().set("nrz-m"); m_analogChart.setTitle("Analog Signal"); }