List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:aajavafx.Schedule1Controller.java
public ObservableList<CustomerProperty> getCustomer() throws IOException, JSONException { Customers customers = new Customers(); Gson gson = new Gson(); ObservableList<CustomerProperty> customerProperty = FXCollections.observableArrayList(); JSONObject jo = new JSONObject(); CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("EMPLOYEE", "password"); provider.setCredentials(AuthScope.ANY, credentials); HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); HttpGet get = new HttpGet("http://localhost:8080/MainServerREST/api/customers"); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); customers = gson.fromJson(jo.toString(), Customers.class); customerProperty.add(new CustomerProperty(customers.getCuId(), customers.getCuFirstname(), customers.getCuLastname(), customers.getCuPersonnummer())); }//from ww w .ja va 2 s. c om return customerProperty; }
From source file:retsys.client.controller.CreditNoteController.java
@Override protected void postSave(String response) { try {/*from w ww . j av a 2 s .c o m*/ System.out.println("response: " + response); CreditNote creditNote = (CreditNote) new JsonHelper().convertJsonStringToObject(response, new TypeReference<CreditNote>() { }); creditNoteNo.setText(creditNote.getId().toString()); Iterator<CreditNoteDetail> it = creditNote.getCreditNoteDetails().iterator(); creditNoteDetail.setItems(null); ObservableList<CreditNoteItem> items = FXCollections.observableArrayList(); while (it.hasNext()) { CreditNoteDetail creditNoteChild = it.next(); items.add( new CreditNoteItem(creditNoteChild.getId(), creditNoteChild.getItem().getName() + " (ID:" + creditNoteChild.getItem().getId() + ")", creditNoteChild.getAmount(), creditNoteChild.getReturnQuantity(), creditNoteChild.isConfirm())); } creditNoteDetail.setItems(items); } catch (IOException ex) { Logger.getLogger(CreditNoteController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:aajavafx.DevicesController.java
public ObservableList<String> getCustomer() throws IOException, JSONException { ObservableList<String> customerStrings = FXCollections.observableArrayList(); //customers.add(new CustomerProperty(1, "Johny", "Walker", "London", "1972-07-01", "7207012222")); Customers myCustomer = new Customers(); //Managers manager = new Managers(); Gson gson = new Gson(); ObservableList<CustomerProperty> customersProperty = FXCollections.observableArrayList(); JSONObject jo = new JSONObject(); // SSL update ....... CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("EMPLOYEE", "password"); provider.setCredentials(AuthScope.ANY, credentials); HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); HttpGet get = new HttpGet("http://localhost:8080/MainServerREST/api/customers"); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL("http://localhost:8080/MainServerREST/api/customers"), Charset.forName("UTF-8"))); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8"))); // ........... System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); myCustomer = gson.fromJson(jo.toString(), Customers.class); customers.add(myCustomer);// w ww .j a va2s . c om System.out.println(myCustomer.getCuId()); String s = myCustomer.getCuId() + ". " + myCustomer.getCuFirstname() + " " + myCustomer.getCuLastname() + " " + myCustomer.getCuPersonnummer(); customerStrings.add(s); customersProperty.add(new CustomerProperty(myCustomer.getCuId(), myCustomer.getCuFirstname(), myCustomer.getCuLastname(), myCustomer.getCuBirthdate(), myCustomer.getCuAddress(), myCustomer.getCuPersonnummer())); } return customerStrings; }
From source file:fruitproject.FruitProject.java
private ObservableList<Map> generateDataInMap(String filename, List<String> addPairs1) { int max = 10; ObservableList<Map> allData = FXCollections.observableArrayList(); //JSON Scan/*from w w w .j av a2 s . c om*/ File f = new File(filename); FileInputStream fis; try { fis = new FileInputStream(f); int content; String result = ""; while ((content = fis.read()) != -1) { // convert to char and display it //System.out.print((char) content); result = result + ((char) content); } JSONObject js = new JSONObject(result); String js1 = js.getString("title"); System.out.println(js1); JSONArray arr = js.getJSONArray("fruits"); //System.out.println(arr.get(0)); int i = 0; while (i < arr.length()) { Map<String, String> dataRow = new HashMap<>(); JSONObject farr = arr.getJSONObject(i); //System.out.println(farr.get("amount")); //System.out.println(farr.get("name")); String value1 = String.valueOf(farr.get("name")); String value2 = String.valueOf(farr.get("amount")); String value3 = String.valueOf(farr.get("amount")); dataRow.put(Column1MapKey, value1); dataRow.put(Column2MapKey, value2); dataRow.put(Column3MapKey, "REMOVE"); i++; allData.add(dataRow); rows++; } i = 0; while (i < (addPairs1.size())) { Map<String, String> dataRow = new HashMap<>(); dataRow.put(Column1MapKey, addPairs1.get(i)); dataRow.put(Column2MapKey, addPairs1.get(i + 1)); dataRow.put(Column3MapKey, "REMOVE"); i = i + 2; allData.add(dataRow); rows++; } fis.close(); } catch (Exception ex) { System.out.println(ex.toString()); } return allData; }
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public ObservableList<TreeItem<JEVisClass>> getChildrenList(TreeItem<JEVisClass> item) { if (item == null || item.getValue() == null) { return FXCollections.emptyObservableList(); }//w w w. j a v a 2 s . c o m if (_itemChildren.containsKey(item)) { return _itemChildren.get(item); } ObservableList<TreeItem<JEVisClass>> list = FXCollections.observableArrayList(); try { for (JEVisClass child : item.getValue().getHeirs()) { TreeItem<JEVisClass> newItem = buildItem(child); list.add(newItem); } } catch (JEVisException ex) { Logger.getLogger(ClassTree.class.getName()).log(Level.SEVERE, null, ex); } // sortList(list); _itemChildren.put(item, list); return list; }
From source file:account.management.controller.ViewVouchersController.java
public List<Account> getAccounts() { HttpResponse<JsonNode> response = null; try {/*from ww w . java 2s . c o m*/ response = Unirest.get(MetaData.baseUrl + "get/accounts").asJson(); } catch (UnirestException ex) { Logger.getLogger(ViewVouchersController.class.getName()).log(Level.SEVERE, null, ex); } JSONArray account = response.getBody().getArray(); List<Account> account_list = FXCollections.observableArrayList(); for (int i = 1; i < account.length(); i++) { JSONObject obj = account.getJSONObject(i); int id = Integer.parseInt(obj.get("id").toString()); String name = obj.get("name").toString(); String desc = obj.get("description").toString(); int parent_id = Integer.parseInt(obj.get("parent").toString()); account_list.add(new Account(id, name, parent_id, desc, 0f, obj.get("account_type").toString())); } return account_list; }
From source file:org.nmrfx.processor.gui.RefManager.java
void setupItems(int dim) { ChartProcessor chartProcessor = processorController.chartProcessor; NMRData nmrData = getNMRData();//from w w w . j a va2 s. c om ObservableList<PropertySheet.Item> newItems = FXCollections.observableArrayList(); String dimName = "" + (dim + 1); if (dim == 0) { newItems.add(new TextOperationItem(stringListener, chartProcessor.getDatasetName(), dimName, "dataset", "Enter the name of the dataset")); ArrayList<String> extensionChoices = new ArrayList<>(); extensionChoices.add(".nv"); extensionChoices.add(".ucsf"); newItems.add(new ChoiceOperationItem(stringListener, chartProcessor.getExtension(), extensionChoices, dimName, "extension", "Filename extension (determines dataset type)")); if (nmrData != null) { ArrayList<String> choices = new ArrayList<>(); if (nmrData.getNDim() > 1) { ArrayList<Integer> dimList = new ArrayList<>(); for (int i = 1; i <= (nmrData.getNDim() - 1); i++) { dimList.add(i); } PermutationIterator permIter = new PermutationIterator(dimList); StringBuilder sBuilder = new StringBuilder(); while (permIter.hasNext()) { ArrayList<Integer> permDims = (ArrayList<Integer>) permIter.next(); sBuilder.setLength(0); if (nmrData.getVendor().equals("bruker")) { sBuilder.append(nmrData.getNDim()); } for (Integer iVal : permDims) { sBuilder.append(iVal); } choices.add(sBuilder.toString()); } newItems.add(new EditableChoiceOperationItem(stringListener, chartProcessor.getAcqOrder(), choices, dimName, "acqOrder", "Enter the acquisiton order of the dataset")); } } else { newItems.add(new TextOperationItem(stringListener, chartProcessor.getAcqOrder(), dimName, "acqOrder", "Enter the acquisiton order of the dataset")); } if ((nmrData != null) && nmrData.getVendor().equals("bruker")) { newItems.add(new BooleanOperationItem(boolListener, chartProcessor.getFixDSP(), dimName, "fixdsp", "Fix DSP buildup before FT")); } } //newItems.add(new IntRangeOperationItem(intListener, 3, 0, 5, "op", "opname", "opDesc")); for (String propName : propNames) { if (propName.equals("skip")) { if (dim > 0) { String value = getPropValue(dim, propName, false); boolean boolValue = false; if (value.equals("1")) { boolValue = true; } newItems.add(new BooleanOperationItem(boolListener, boolValue, dimName, propName, "Skip this dimension?")); } } else if (propName.equals("ref")) { String value = getPropValue(dim, propName, false); String defaultValue = getPropValue(dim, propName, true); if (nmrData != null) { if (dim == 0) { defaultValue = nmrData.getRef(0) + ""; } } String comment = " (default is " + defaultValue + ")"; newItems.add(new MenuTextOperationItem(stringListener, value, dimName, propName, "Select the " + propName + comment)); } else if (propName.contains("size")) { String value = getPropValue(dim, propName, false); int iValue = 0; try { iValue = Integer.parseInt(value); } catch (NumberFormatException nFe) { } String defaultValue = getPropValue(dim, propName, true); String comment = " (default is " + defaultValue + ")"; newItems.add(new IntOperationItem(intListener, iValue, 0, 1000000, dimName, propName, "Enter the " + propName + comment)); } else if (propName.equals("acqarray")) { int arraySize = 0; if (nmrData != null) { arraySize = nmrData.getArraySize(dim); } String comment = " (default is " + 0 + ")"; newItems.add(new IntOperationItem(intListener, arraySize, 0, 1000000, dimName, propName, "Enter the " + propName + comment)); } else { String value = getPropValue(dim, propName, false); String defaultValue = getPropValue(dim, propName, true); String comment = " (default is " + defaultValue + ")"; newItems.add(new TextOperationItem(stringListener, value, dimName, propName, "Enter the " + propName + comment)); } } refSheet.getItems().setAll(newItems); }
From source file:retsys.client.controller.PurchaseOrderController.java
public void addItem(ActionEvent event) { sno++;//w w w . j a va2 s. c o m ObservableList<POItem> list = poDetail.getItems(); if (list == null) { list = FXCollections.observableArrayList(); } POItem item = new POItem((int) txt_location.getUserData(), txt_location.getText(), txt_name.getText(), txt_brand.getText(), txt_model.getText(), Double.parseDouble(txt_qty.getText()), false, null); list.add(item); poDetail.setItems(list); }
From source file:com.exalttech.trex.ui.views.importPcap.ImportedPacketTableView.java
/** * Validate stream names//from w w w . j a v a2 s . c om * * @return */ private boolean validateStreamNames() { ObservableList<Integer> duplicateIndexesList = FXCollections.observableArrayList(); duplicateRowNamesMap.clear(); // validate saved stream names for (ImportPcapTableData tableData : tableDataList) { if (tableData.isSelected()) { // comparing with existing streams if ((existingNamesList.contains(tableData.getName()) || Util.isNullOrEmpty(tableData.getName().trim()))) { addDuplicateIndex(duplicateIndexesList, tableData); } // compairing with other streams in list if (duplicateRowNamesMap.get(tableData.getName()) != null) { // name is duplicate addDuplicateIndex(duplicateIndexesList, tableData); addDuplicateIndex(duplicateIndexesList, duplicateRowNamesMap.get(tableData.getName())); } else { // add existing names in imported table duplicateRowNamesMap.put(tableData.getName(), tableData); } } } highlightedRowFactory.getRowsToHighlight().setAll(duplicateIndexesList); boolean validNames = true; if (!duplicateIndexesList.isEmpty()) { validNames = false; Alert alert = Util.getAlert(Alert.AlertType.ERROR); alert.setContentText( "Some packet names (highlighted in red) have the same names of exisiting packets !"); alert.showAndWait(); } return validNames; }