List of usage examples for javafx.collections ObservableList size
int size();
From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java
/** * Evaluate the contents of the XPath expression area * on the given compilation unit. This updates the xpath * result panel, and can log XPath exceptions to the * event log panel./* w ww . jav a2 s .c o m*/ * * @param compilationUnit The AST root * @param version The language version */ public void evaluateXPath(Node compilationUnit, LanguageVersion version) { try { String xpath = getXpathExpression(); if (StringUtils.isBlank(xpath)) { invalidateResults(false); return; } ObservableList<Node> results = FXCollections.observableArrayList(xpathEvaluator.evaluateQuery( compilationUnit, version, getXpathVersion(), xpath, ruleBuilder.getRuleProperties())); xpathResultListView.setItems( results.stream().map(parent::wrapNode).collect(Collectors.toCollection(LiveArrayList::new))); parent.highlightXPathResults(results); violationsTitledPane.setText("Matched nodes\t(" + results.size() + ")"); } catch (XPathEvaluationException e) { invalidateResults(true); designerRoot.getLogger().logEvent(new LogEntry(e, Category.XPATH_EVALUATION_EXCEPTION)); } xpathResultListView.refresh(); }
From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java
private void addChartSeries(final String title, final List<? extends Number> samples) { logger.info(title + ": " + samples.size() + " samples."); final XYChart.Series<Number, Number> series = new XYChart.Series<>(); series.setName(title);/* ww w . ja v a2 s. c o m*/ final ObservableList<XYChart.Data<Number, Number>> data = series.getData(); for (int i = 0; i < samples.size(); i += 4) { final Number number = samples.get(i); if (number != null) { final XYChart.Data<Number, Number> dataPoint = new XYChart.Data<>(i, number); data.add(dataPoint); } } chartRangeSlider.setMax(samples.size()); if (data.size() > 0) { chart.getData().add(series); } }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public boolean isListViewItemDuplicated(ListView listView, String value) { boolean valid = false; ObservableList<String> list = listView.getItems(); if (list.size() != 0 && !value.isEmpty()) { for (int i = 0; i < list.size(); i++) { if (!list.get(i).equals(value)) { valid = true;//from w ww .j a va 2 s .co m } } } else if (list.size() == 0) { valid = true; } return valid; }
From source file:memoryaid.SetReminderController.java
@FXML private void handleSetReminderBtnAction(ActionEvent event) throws Exception { System.out.println("You clicked Add Reminder!"); String rType = (String) reminderTypeBox.getValue(); String rName = reminderNameText.getText(); LocalDate rSDate = startDateId.getValue(); LocalDate rEDate = endDateId.getValue(); List<LocalDate> reminderDates = new ArrayList<>(); String hours = (String) reminderHhBox.getValue(); String minutes = (String) reminderMmBox.getValue(); String seconds = (String) reminderSsBox.getValue(); ObservableList<String> repeat = multiSelectComboBox.getCheckModel().getCheckedItems(); String imgPath = imagePathText.getText(); if (rType == null || rName == null || rSDate == null || rEDate == null || hours == null || minutes == null || seconds == null || repeat.size() == 0 || imgPath == null) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait();/*from w w w . j a v a2 s .co m*/ System.out.println("Please fill all the fields"); } else if (rSDate.isAfter(rEDate) == true) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("End date cannot be before the Start date"); alert.showAndWait(); System.out.println("End date should be greater than start date"); } else { String rTime = hours + ":" + minutes + ":" + seconds; if (rType != null && rName != null && !rName.isEmpty() && rEDate != null && hours != null && minutes != null && seconds != null && repeat != null && imgPath != null) { String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/Reminders"; File destinationPathObject = new File(destinationPath + "/" + rName + ".png"); File sourceFilePathObject = new File(imgPath); FileUtils.copyFile(sourceFilePathObject, destinationPathObject); System.out.println( "You clicked Add Reminder!" + rType + rName + rSDate + rEDate + rTime + repeat + imgPath); System.out.println("****Inside if"); Reminder reminderToSet = new Reminder(); reminderToSet.setReminderName(rName); reminderToSet.setReminderType(rType); reminderToSet.setStartDate(rSDate); reminderToSet.setEndDate(rEDate); //endDateToCheck = rEDate.plusDays(1); if (repeat.contains("Every Monday")) { reminderToSet.setRepeatMon("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.MONDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatMon("false"); } if (repeat.contains("Every Tuesday")) { reminderToSet.setRepeatTue("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.TUESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatTue("false"); } if (repeat.contains("Every Wednesday")) { reminderToSet.setRepeatWed("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.WEDNESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatWed("false"); } if (repeat.contains("Every Thursday")) { reminderToSet.setRepeatThu("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.THURSDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatThu("false"); } if (repeat.contains("Every Friday")) { reminderToSet.setRepeatFri("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.FRIDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatFri("false"); } if (repeat.contains("Every Saturday")) { reminderToSet.setRepeatSat("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SATURDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatSat("false"); } if (repeat.contains("Every Sunday")) { reminderToSet.setRepeatSun("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SUNDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } } else { reminderToSet.setRepeatSun("false"); } if (repeat.contains("None")) { reminderToSet.setRepeatNone("true"); reminderDates.add(rSDate); } else { reminderToSet.setRepeatNone("false"); } System.out.println("%%%%Reminder DATes" + reminderDates); reminderToSet.setReminderTime(rTime); reminderToSet.setReminderStatus("New"); DbConnection db = new DbConnection(); Connection conn = db.connect(); PreparedStatement preparedStmt = null; String insertSql = "INSERT into Reminders(ReminderType, ReminderName, StartDate, EndDate, ReminderTime, RepeatM, RepeatT, RepeatW, RepeatTH, RepeatF, RepeatSat, RepeatSun)" + "values(?,?,?,?,?,?,?,?,?,?,?,?)"; preparedStmt = conn.prepareStatement(insertSql); preparedStmt.setString(1, reminderToSet.getReminderType()); preparedStmt.setString(2, reminderToSet.getReminderName()); preparedStmt.setString(3, reminderToSet.getStartDate().toString()); preparedStmt.setString(4, reminderToSet.getEndDate().toString()); preparedStmt.setString(5, reminderToSet.getReminderTime()); preparedStmt.setString(6, reminderToSet.getRepeatMon()); preparedStmt.setString(7, reminderToSet.getRepeatTue()); preparedStmt.setString(8, reminderToSet.getRepeatWed()); preparedStmt.setString(9, reminderToSet.getRepeatThu()); preparedStmt.setString(10, reminderToSet.getRepeatFri()); preparedStmt.setString(11, reminderToSet.getRepeatSat()); preparedStmt.setString(12, reminderToSet.getRepeatSun()); preparedStmt.executeUpdate(); System.out.println("Reminder Inserted Successfully "); //Get the inserted reminders RId String getRIdsql = "Select max(RId) as RId from Reminders"; ResultSet rSet = conn.createStatement().executeQuery(getRIdsql); int newRId = 0; while (rSet.next()) { newRId = rSet.getInt(1); } System.out.println("RID ^^^^^^^^" + newRId); PreparedStatement preparedStmtRDetails = null; for (int i = 0; i < reminderDates.size(); i++) { String rDetailsSql = "Insert into ReminderDetails(RId,DetailNum,ReminderDate,ReminderStatus)" + " values(?,?,?,?)"; preparedStmtRDetails = conn.prepareStatement(rDetailsSql); preparedStmtRDetails.setInt(1, newRId); preparedStmtRDetails.setInt(2, i); preparedStmtRDetails.setString(3, reminderDates.get(i).toString()); preparedStmtRDetails.setString(4, "New"); preparedStmtRDetails.executeUpdate(); System.out.println("ReminderDetails Table Insert Successfull "); } Parent setReminder = FXMLLoader.load(getClass().getResource("SetReminder.fxml")); Scene set_reminder_refresh_scene = new Scene(setReminder); Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); app_stage.hide(); app_stage.setScene(set_reminder_refresh_scene); app_stage.show(); } else { System.out.println("Inside else"); //show alert Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait(); } } }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public boolean isValidVehicleNo(ListView listView, String vehicleNo) { boolean valid = true; String vehicleNoTrimed = vehicleNo.trim(); ObservableList<String> list = listView.getItems(); if (vehicleNoTrimed.length() < 14 && vehicleNoTrimed.length() > 4) { if (list.size() != 0 && !vehicleNo.isEmpty()) { for (int i = 0; i < list.size(); i++) { if (list.get(i).equals(vehicleNo)) { valid = false;// w w w .j a v a2s .c o m } // else { // // valid = false; // // } } } else if (list.size() == 0) { valid = true; } } else { valid = false; } return valid; }
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public void fireEventExport(ObservableList<TreeItem<JEVisClass>> items) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save JEVisClasses to File"); fileChooser.getExtensionFilters().addAll(new ExtensionFilter("JEVis Files", "*.jev"), new ExtensionFilter("All Files", "*.*")); DateTime now = DateTime.now();/*from ww w . ja v a 2 s. c o m*/ DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd"); if (items.size() > 1) { fileChooser.setInitialFileName("JEViClassExport_" + fmt.print(now) + ".jev"); } else { try { fileChooser.setInitialFileName(items.get(0).getValue().getName() + "_" + fmt.print(now) + ".jev"); } catch (JEVisException ex) { Logger.getLogger(ClassTree.class.getName()).log(Level.SEVERE, null, ex); } } File selectedFile = fileChooser.showSaveDialog(JEConfig.getStage()); if (selectedFile != null) { List<JEVisClass> classes = new ArrayList<>(); for (TreeItem<JEVisClass> item : items) { classes.add(item.getValue()); } String extension = FilenameUtils.getExtension(selectedFile.getName()); if (extension.isEmpty()) { selectedFile = new File(selectedFile.getAbsoluteFile() + ".jsv"); } ClassExporter ce = new ClassExporter(selectedFile, classes); // mainStage.display(selectedFile); } }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public boolean isValidUniqueEmail(ListView listView, String email) { boolean valid = true; ObservableList<String> list = listView.getItems(); boolean isEmail = org.apache.commons.validator.routines.EmailValidator.getInstance().isValid(email); if (isEmail == true) { if (list.size() != 0 && !email.isEmpty()) { for (int i = 0; i < list.size(); i++) { if (list.get(i).equals(email)) { valid = false;//from w w w . j a v a 2 s. co m } // else { // valid = false; // } } } else if (list.size() == 0) { valid = true; } } return valid; }
From source file:csg.files.CSGFiles.java
public void saveScheduleData(AppDataComponent schData, String filePath) throws IOException { ScheduleData schDataManager = (ScheduleData) schData; JsonArrayBuilder schArrayBuilder = Json.createArrayBuilder(); ObservableList<ScheduleItem> schedule = schDataManager.getSchedule(); ArrayList<ScheduleItem> holidays = new ArrayList(); ArrayList<ScheduleItem> lectures = new ArrayList(); ArrayList<ScheduleItem> references = new ArrayList(); ArrayList<ScheduleItem> recitations = new ArrayList(); ArrayList<ScheduleItem> hws = new ArrayList(); for (int i = 0; i < schedule.size(); i++) { if (schedule.get(i).getType().equals("holiday")) { holidays.add(schedule.get(i)); } else if (schedule.get(i).getType().equals("lecture")) { lectures.add(schedule.get(i)); } else if (schedule.get(i).getType().equals("reference")) { references.add(schedule.get(i)); } else if (schedule.get(i).getType().equals("recitation")) { recitations.add(schedule.get(i)); } else if (schedule.get(i).getType().equals("hw")) { hws.add(schedule.get(i));/* w w w.j a va2s . co m*/ } } JsonArrayBuilder holidayArrayBuilder = Json.createArrayBuilder(); for (ScheduleItem scheduleItem : holidays) { JsonObject holidayJson = Json.createObjectBuilder().add(JSON_MONTH, scheduleItem.getDateMon()) .add(JSON_DAY, scheduleItem.getDateDay()).add(JSON_TITLE, scheduleItem.getTitle()) .add(JSON_LINK, scheduleItem.getLink()).build(); holidayArrayBuilder.add(holidayJson); } JsonArray holidayArray = holidayArrayBuilder.build(); JsonArrayBuilder lectureArrayBuilder = Json.createArrayBuilder(); for (ScheduleItem scheduleItem : lectures) { JsonObject lecJson = Json.createObjectBuilder().add(JSON_MONTH, scheduleItem.getDateMon()) .add(JSON_DAY, scheduleItem.getDateDay()).add(JSON_TITLE, scheduleItem.getTitle()) .add(JSON_TOPIC, scheduleItem.getTopic()).add(JSON_LINK, scheduleItem.getLink()).build(); lectureArrayBuilder.add(lecJson); } JsonArray lectureArray = lectureArrayBuilder.build(); JsonArrayBuilder referencesArrayBuilder = Json.createArrayBuilder(); for (ScheduleItem scheduleItem : references) { JsonObject lecJson = Json.createObjectBuilder().add(JSON_MONTH, scheduleItem.getDateMon()) .add(JSON_DAY, scheduleItem.getDateDay()).add(JSON_TITLE, scheduleItem.getTitle()) .add(JSON_TOPIC, scheduleItem.getTopic()).add(JSON_LINK, scheduleItem.getLink()).build(); referencesArrayBuilder.add(lecJson); } JsonArray referenceArray = referencesArrayBuilder.build(); JsonArrayBuilder recitationArrayBuilder = Json.createArrayBuilder(); for (ScheduleItem scheduleItem : recitations) { JsonObject lecJson = Json.createObjectBuilder().add(JSON_MONTH, scheduleItem.getDateMon()) .add(JSON_DAY, scheduleItem.getDateDay()).add(JSON_TITLE, scheduleItem.getTitle()) .add(JSON_TOPIC, scheduleItem.getTopic()).build(); recitationArrayBuilder.add(lecJson); } JsonArray recitaitonArray = recitationArrayBuilder.build(); JsonArrayBuilder hwArrayBuilder = Json.createArrayBuilder(); for (ScheduleItem scheduleItem : hws) { JsonObject lecJson = Json.createObjectBuilder().add(JSON_MONTH, scheduleItem.getDateMon()) .add(JSON_DAY, scheduleItem.getDateDay()).add(JSON_TITLE, scheduleItem.getTitle()) .add(JSON_TOPIC, scheduleItem.getTopic()).add(JSON_LINK, scheduleItem.getLink()) .add(JSON_TIME, scheduleItem.getTime()).add(JSON_CRITERIA, scheduleItem.getCriteria()).build(); hwArrayBuilder.add(lecJson); } JsonArray hwArray = hwArrayBuilder.build(); JsonObject dataManagerJSO = Json.createObjectBuilder().add(JSON_MONDAYMON, workspace.getMonMonthDate()) .add(JSON_MONDAYDAY, workspace.getMonDayDate()).add(JSON_FRIDAYMONTH, workspace.getFriMonthDate()) .add(JSON_FRIDAYDAY, workspace.getFriDayDate()).add(JSON_HOLIDAYS, holidayArray) .add(JSON_LECTURES, lectureArray).add(JSON_REF, referenceArray) .add(JSON_RECITATION, recitaitonArray).add(JSON_HW, hwArray).build(); // AND NOW OUTPUT IT TO A JSON FILE WITH PRETTY PRINTING Map<String, Object> properties = new HashMap<>(1); properties.put(JsonGenerator.PRETTY_PRINTING, true); JsonWriterFactory writerFactory = Json.createWriterFactory(properties); StringWriter sw = new StringWriter(); JsonWriter jsonWriter = writerFactory.createWriter(sw); jsonWriter.writeObject(dataManagerJSO); jsonWriter.close(); // INIT THE WRITER OutputStream os = new FileOutputStream(filePath); JsonWriter jsonFileWriter = Json.createWriter(os); jsonFileWriter.writeObject(dataManagerJSO); String prettyPrinted = sw.toString(); PrintWriter pw = new PrintWriter(filePath); pw.write(prettyPrinted); pw.close(); }
From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java
private void displayRows(List<DatasetRow> rows) { ObservableList<TableColumn> cols = comparisonTableView.getColumns(); cols.clear();//from www . j av a2 s . c o m List<DatasetColumn> datasetCols = rows.stream().flatMap(row -> row.getColumns().stream()).distinct() .collect(Collectors.toList()); for (DatasetColumn datasetCol : datasetCols) { cols.add(createTableColumnForDatasetColumn(datasetCol.getName(), datasetCol)); } // Add the by-unique before the columns. Function<DatasetRow, String> uniqueMap = getByUniqueMap(); cols.add(0, createTableColumnForDatasetRow("Unique", row -> truncateString(uniqueMap.apply(row), 30))); // Add the dataset after the columns. cols.add(createTableColumnForDatasetRow("Dataset", row -> row.getDataset().getCitation())); comparisonTableView.setItems(FXCollections.observableList(rows)); statusTextField.setText("Displaying " + rows.size() + " rows across " + cols.size() + " columns"); }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public boolean isValidUniqueTelephoneNumber(ListView listView, String telephone) { boolean valid = true; String telephoneNumber = telephone.trim(); ObservableList<String> list = listView.getItems(); String regex_Number = "([0-9])*"; //Regex pattern for Single Name with initials. Pattern pattern_Number = Pattern.compile(regex_Number); // Pattern Compliler Matcher matcher_Number = pattern_Number.matcher(telephoneNumber); // Pattern Matcher where the Single Name argument is checked with the given pattern boolean matched_Number = matcher_Number.matches(); // Result of the matcher is returned as a boolean for Single Name if (matched_Number == true && telephoneNumber.length() < 14 && telephoneNumber.length() > 9) { if (list.size() != 0 && !telephone.isEmpty()) { for (int i = 0; i < list.size(); i++) { if (list.get(i).equals(telephone)) { valid = false;//from w ww. j a v a 2 s. c o m } // else { // // valid = false; // // } } } else if (list.size() == 0) { valid = true; } } else { valid = false; } return valid; }