List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:condorclient.CreateJobDialogController.java
@FXML private void runJobFired(ActionEvent event) { nrun = Integer.parseInt(sampleNumText.getText().trim()); if (nrun == 0) { return;//from w w w . java 2 s . c o m } int eachrun = 0; // System.out.println("map:" + map.toString()); ObservableList<String> slotname = FXCollections.observableArrayList(); XMLHandler handler = new XMLHandler(); if (allocMthod == 0) {//slot? if (!slotNumIsOk()) { return; } int i = 0; for (String s : map.keySet()) { if (i >= useslotnum) { break; } i = i + map.get(s).size(); if (i <= useslotnum) {//? slotname.addAll(map.get(s)); } else { i = i - map.get(s).size(); for (String rest : map.get(s)) { if (i >= useslotnum) { break; } slotname.add(rest); i++; } } } //slotname //?? // System.out.println("allocMthod:" + allocMthod + "useslotnum:" + useslotnum + "\nslotname:" + slotname.toString()); } else if (allocMthod == 1) {//? // if (!nodeNumInputIsOk()) {//??? return; } int i = 0; for (String s : map.keySet()) { if (i >= usenodenum) { break; } i++; if (slotname.size() + map.get(s).size() <= nrun) { slotname.addAll(map.get(s)); } else if (slotname.size() < nrun) {//??ip? for (String rs : map.get(s)) { slotname.add(rs); if (slotname.size() == nrun) { break; } } break; } } //System.out.println("allocMthod:" + allocMthod + "usenodenum:" + usenodenum + "\nslotname:" + slotname.toString()); } else if (allocMthod == 2) {//? int i = 0; for (String s : apponitmap.keySet()) { // slotname.addAll(map.get(s));//apponitmap?keylist if (i >= nrun) { break; } i++; //s if (slotname.size() + map.get(s).size() <= nrun) { slotname.addAll(map.get(s)); } else if (slotname.size() < nrun) {//??machine?slot for (String rs : map.get(s)) { slotname.add(rs); if (slotname.size() == nrun) { break; } } break; } } if (slotname.size() == 0) { //System.out.println("+++++"+otherError.getText()); otherError.setText("?"); return; } //System.out.println("allocMthod:" + allocMthod + "zhi ding ge shu:" + apponitmap.keySet().size() + "\nslotname:" + slotname.toString()); } else if (allocMthod == 3) {//???????? int aptNum = 0; if (slotNum <= nrun) {//?? aptNum = slotNum; } else { aptNum = nrun; } for (int i = 0; i < aptNum; i++) {//slotNum slotname.add(""); } } eachrun = nrun / slotname.size(); int restrun = nrun - eachrun * slotname.size();//?slot //System.out.println("eachrun" + eachrun + "restrun" + restrun); URL url = null; String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); } catch (MalformedURLException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } Schedd schedd = null; try { schedd = new Schedd(url); } catch (ServiceException e2) { } int j = 0; // String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date()); String resultdirstr = resultFileText.getText().trim() + "\\" + jobNameText.getText().trim() + "\\" + timestamp; System.out.println(resultdirstr); try { FileUtils.forceMkdir(new File(resultdirstr)); } catch (IOException ex) { Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(timestamp); //? File infoFile = new File(infoFileText.getText().trim()); File expFile = new File(expFileText.getText().trim()); File[] transfiles = { infoFile, expFile }; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } int clusterId = 0; try { clusterId = xact.createCluster(); } catch (RemoteException e) { } for (String name : slotname) {//3slot?? j++; int jobId = 0; try { jobId = xact.createJob(clusterId); } catch (RemoteException e) { } String jobdirstr = resultdirstr + "\\" + jobId; File jobdir = new File(jobdirstr); try { FileUtils.forceMkdir(jobdir);//?job } catch (IOException ex) { Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex); } //??job /* for (File f : transfiles) { try { FileUtils.copyFileToDirectory(f, jobdir); } catch (IOException ex) { Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex); } }*/ if (j == slotname.size()) { eachrun = eachrun + restrun; } String eachrunstr = "" + eachrun; String argumentsStr = infoFile.getName() + " " + expFile.getName() + " " + eachrunstr;// null;//".exl .ixl nrun" String requirementsStr = "Name==\"" + name + "\"";//Name=slot1@Lenovo-PC;String req="Name==\"slot1@Lenovo-PC\""; if (name.equals("")) { requirementsStr = null;//?? } System.out.println("requirementsStr:" + requirementsStr + "eachrunstr:" + eachrunstr); ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()}; // ClassAdStructAttr attribute =new ClassAdStructAttr("WhenToTransferOutput",ClassAdAttrType.value3,"ON_EXIT_OR_EVICT"); // attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, jobdirstr); // attributes[1] = new ClassAdStructAttr("JobLeaseDuration", ClassAdAttrType.value1,"1200"); String commandStr = handler.getexecutableFile();//? try { xact.submit(clusterId, jobId, "htcondor", UniverseType.VANILLA, commandStr, argumentsStr, requirementsStr, attributes, transfiles); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { xact.commit(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { schedd.requestReschedule();// } catch (RemoteException ex) { Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex); } String jobName = jobNameText.getText(); handler.addJob(jobName, "" + clusterId, resultdirstr, expFileText.getText().trim(), infoFileText.getText().trim());//jobItem exeCreate = 1; stage.close(); }
From source file:herudi.controller.productController.java
private void displayProductCode() { Service<ObservableList<ProductCode>> service = new Service<ObservableList<ProductCode>>() { @Override//from ww w . j av a 2s . c o m 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(); }
From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java
private ObservableList<CSVRow> readFile(File csvFile) throws IOException { ObservableList<CSVRow> rows = FXCollections.observableArrayList(); Integer maxColumns = 0;//from w w w .ja va 2 s .c o m try (Reader in = new InputStreamReader(new FileInputStream(csvFile));) { CSVParser parse = csvFormat.parse(in); for (CSVRecord record : parse.getRecords()) { if (maxColumns < record.size()) { maxColumns = record.size(); } CSVRow row = new CSVRow(); for (int i = 0; i < record.size(); i++) { row.getColumns().add(new SimpleStringProperty(record.get(i))); } rows.add(row); } this.numbeColumns = maxColumns; } return rows; }
From source file:aajavafx.Schedule1Controller.java
public ObservableList<EmployeeScheduleProperty> getSchedule() throws IOException, JSONException { EmployeeSchedule mySchedule = new EmployeeSchedule(); Customers customers = new Customers(); Employees employee = new Employees(); Gson gson = new Gson(); ObservableList<EmployeeScheduleProperty> employeeScheduleProperty = 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/employeeschedule"); 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); jo = (JSONObject) jsonArray.getJSONObject(i); mySchedule = gson.fromJson(jo.toString(), EmployeeSchedule.class); employeeScheduleProperty.add(new EmployeeScheduleProperty(mySchedule.getSchId(), mySchedule.getSchDate(), mySchedule.getSchFromTime(), mySchedule.getSchUntilTime(), mySchedule.getEmplVisitedCust(), mySchedule.getCustomersCuId().getCuPersonnummer(), mySchedule.getEmployeesEmpId().getEmpUsername())); }//from w w w . j a va 2 s .com return employeeScheduleProperty; }
From source file:io.github.moosbusch.permagon.configuration.builder.spi.AbstractPermagonBuilder.java
private void init() { initConverters();// www . j a va 2 s . co m properties.put(NODE_CHILDREN_PROPERTY, FXCollections.observableArrayList()); properties.put(NODE_ITEMS_PROPERTY, FXCollections.observableArrayList()); properties.put(NODE_TABS_PROPERTY, FXCollections.observableArrayList()); properties.put(NODE_BUTTONS_PROPERTY, FXCollections.observableArrayList()); properties.put(NODE_MENUS_PROPERTY, FXCollections.observableArrayList()); }
From source file:aajavafx.EmployeeController.java
public ObservableList<EmployeeProperty> getEmployee() throws IOException, JSONException, Exception { Employees myEmployee = new Employees(); Managers manager = new Managers(); Gson gson = new Gson(); ObservableList<EmployeeProperty> employeesProperty = 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/employees"); 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); myEmployee = gson.fromJson(jo.toString(), Employees.class); System.out.println(myEmployee.getEmpPhone()); employeesProperty.add(new EmployeeProperty(myEmployee.getEmpId(), myEmployee.getEmpLastname(), myEmployee.getEmpFirstname(), myEmployee.getEmpUsername(), myEmployee.getEmpPassword(), myEmployee.getEmpEmail(), myEmployee.getEmpPhone(), myEmployee.getManagersManId().getManId(), myEmployee.getEmpRegistered())); }/*from w w w .ja v a2 s. c o m*/ return employeesProperty; }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
/** * This method is invoked when the monthly in/out button has been toggled * * @param actionEvent/*from w ww.j a va 2 s . com*/ */ public void monthlyInOutToggled(ActionEvent actionEvent) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month of Year"); yAxis.setLabel("In/Out in Euro"); final BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis); barChart.setTitle("Monthly in/out"); chartFrame.setCenter(barChart); ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { Account account = accountCombo.getValue(); String accountLabel = getAccountLabel(account); XYChart.Series<String, Number> inSeries = new XYChart.Series<>(); inSeries.setName("In" + accountLabel); barChart.getData().add(inSeries); XYChart.Series<String, Number> outSeries = new XYChart.Series<>(); outSeries.setName("Out" + accountLabel); barChart.getData().add(outSeries); ValueRange<LocalDate> period = getTransactionOpRange(account, yearCombo.getValue()); if (period.isEmpty()) { return; } ObservableList<String> monthLabels = FXCollections.observableArrayList(); for (LocalDate date = period.from().withDayOfMonth(1); !date.isAfter(period.to()); date = date .plusMonths(1)) { monthLabels.add(getMonthLabel(date.getYear(), date.getMonthValue())); } xAxis.setCategories(monthLabels); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { List<TransactionVolume> incomingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyIncomingVolumes(false) : transactionRepository.getMonthlyIncomingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { incomingVolumes = incomingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : incomingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume()); Platform.runLater(() -> { inSeries.getData().add(data); StackPane barNode = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); barNode.getChildren().add(labelNode); barNode.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, of(volume.getYear(), volume.getMonth(), 1), event)); }); } List<TransactionVolume> outgoingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyOutgoingVolumes(false) : transactionRepository.getMonthlyOutgoingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { outgoingVolumes = outgoingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : outgoingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume().abs()); Platform.runLater(() -> { outSeries.getData().add(data); StackPane node = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); node.getChildren().add(labelNode); node.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS ? null : account), volume.getDate(), event)); }); } return null; } }; } }; service.start(); } }
From source file:com.mycompany.songbitmaven.RecommendationController.java
public void loadTable() { ObservableList<SongInfo> tracks = FXCollections.observableArrayList(); TableColumn nameColumn = new TableColumn("Name"); nameColumn.setMinWidth(250);//from ww w . ja v a2 s. co m nameColumn.setCellValueFactory(new PropertyValueFactory<SongInfo, String>("name")); TableColumn artistColumn = new TableColumn("Artist"); artistColumn.setMinWidth(250); artistColumn.setCellValueFactory(new PropertyValueFactory<SongInfo, String>("artist")); table.getColumns().setAll(nameColumn, artistColumn); tracks.clear(); for (int i = 0; i < recommendations.size(); i++) { recommendations.get(i).updateArtist(); tracks.add(recommendations.get(i)); } table.setItems(tracks); }
From source file:retsys.client.controller.DeliveryChallanReturnController.java
/** * Initializes the controller class.//from www . java 2 s . c om */ @Override public void initialize(URL url, ResourceBundle rb) { dc_date.setValue(LocalDate.now()); material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name")); brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand")); model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model")); units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model")); quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity")); amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount")); dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, amount); // TODO AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() { @Override public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) { List<Item> list = null; try { LovHandler lovHandler = new LovHandler("items", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Item>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Item>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Item>() { @Override public String toString(Item object) { System.out.println("here..." + object); return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Item fromString(String string) { throw new UnsupportedOperationException(); } }); //event handler for setting other item fields with values from selected Item object //fires after autocompletion bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) { Item item = event.getCompletion(); //fill other item related fields txt_name.setUserData(item.getId()); txt_brand.setText(item.getBrand()); txt_model.setText(null); // item doesn't have this field. add?? txt_rate.setText(String.valueOf(item.getRate())); } }); AutoCompletionBinding<DeliveryChallan> bindForProject = TextFields.bindAutoCompletion(project, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<DeliveryChallan>>() { @Override public Collection<DeliveryChallan> call(AutoCompletionBinding.ISuggestionRequest param) { List<DeliveryChallan> list = null; try { LovHandler lovHandler = new LovHandler("deliverychallans", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<DeliveryChallan>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<DeliveryChallan>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<DeliveryChallan>() { @Override public String toString(DeliveryChallan object) { System.out.println("here..." + object); String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(LocalDateTime .ofInstant(object.getChallanDate().toInstant(), ZoneId.systemDefault())); return "Project:" + object.getProject().getName() + " DC Date:" + strDate + " DC No.:" + object.getId(); } @Override public DeliveryChallan fromString(String string) { throw new UnsupportedOperationException(); } }); bindForProject .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan> event) { DeliveryChallan dc = event.getCompletion(); dc_no.setText(dc.getId().toString()); dc_date.setValue(LocalDateTime .ofInstant(dc.getChallanDate().toInstant(), ZoneId.systemDefault()).toLocalDate()); dc_no.setText(dc.getId().toString()); project.setText(dc.getProject().getName() + " (ID:" + dc.getProject().getId() + ")"); deliverymode.setText(dc.getDeliveryMode()); concernperson.setText(dc.getConcernPerson()); ObservableList<DCItem> items = FXCollections.observableArrayList(); Iterator detailsIt = dc.getDeliveryChallanDetail().iterator(); while (detailsIt.hasNext()) { DeliveryChallanDetail detail = (DeliveryChallanDetail) detailsIt.next(); Item item = detail.getItem(); int id = item.getId(); String site = item.getSite(); String name = item.getName(); String brand = item.getBrand(); String model = null; int rate = item.getRate().intValue(); int quantity = detail.getQuantity(); int amount = detail.getAmount(); String units = detail.getUnits(); items.add(new DCItem(id, name + " (ID:" + id + ")", brand, model, rate, quantity, units, amount)); } dcDetail.setItems(items); populateAuditValues(dc); } }); txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { calcAmount(); } } }); }
From source file:retsys.client.controller.DeliveryChallanController.java
public void addItem(ActionEvent event) { ObservableList<DCItem> list = dcDetail.getItems(); if (list == null) { list = FXCollections.observableArrayList(); }/*from w w w . ja v a2 s. com*/ DCItem item = new DCItem(splitId(txt_name.getText()), txt_name.getText(), txt_brand.getText(), txt_model.getText(), Double.valueOf(txt_rate.getText()).intValue(), Integer.parseInt(txt_qty.getText()), txt_units.getText(), Double.valueOf(txt_amount.getText()).intValue()); list.add(item); dcDetail.setItems(list); }