Example usage for javafx.collections ObservableList contains

List of usage examples for javafx.collections ObservableList contains

Introduction

In this page you can find the example usage for javafx.collections ObservableList contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:de.pixida.logtest.designer.automaton.EditorAutomaton.java

private void createConfigFrame() {
    final int descriptionInputLines = 8;
    this.descriptionInput.setPrefRowCount(descriptionInputLines);
    this.descriptionInput.setWrapText(true);
    this.descriptionInput.textProperty()
            .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
                this.setDescription(newValue);
                this.graph.handleChange();
            });/*from w  w  w.  jav a 2 s. c  o  m*/
    this.configFrame.addOption("Description", this.descriptionInput);

    final ObservableList<String> options = FXCollections.observableArrayList("JavaScript", "python");
    if (!options.contains(Automaton.DEFAULT_SCRIPTING_LANGUAGE)) {
        options.add(0, Automaton.DEFAULT_SCRIPTING_LANGUAGE);
    }
    final ChoiceBox<String> scriptLanguageInput = new ChoiceBox<>(options);
    scriptLanguageInput
            .setValue(StringUtils.isBlank(this.scriptLanguage) || !options.contains(this.scriptLanguage)
                    ? Automaton.DEFAULT_SCRIPTING_LANGUAGE
                    : this.scriptLanguage);
    scriptLanguageInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                EditorAutomaton.this.scriptLanguage = scriptLanguageInput.getItems().get((Integer) newValue);
                this.graph.handleChange();
            });
    this.configFrame.addOption("Script language", scriptLanguageInput);

    final int onLoadInputLines = 8;
    this.onLoadInput.setPrefRowCount(onLoadInputLines);
    this.onLoadInput.setWrapText(true);
    this.onLoadInput.setStyle("-fx-font-family: monospace");
    this.onLoadInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.graph.handleChange();
    });
    this.configFrame.addOption("On Load", this.onLoadInput);
}

From source file:com.exalttech.trex.ui.views.importPcap.ImportedPacketTableView.java

/**
 * Add index to duplicate list//from  w w w .j a v a 2 s. c o  m
 * @param duplicateIndexesList
 * @param tableData 
 */
private void addDuplicateIndex(ObservableList<Integer> duplicateIndexesList, ImportPcapTableData tableData) {
    if (!duplicateIndexesList.contains(tableData.getIndex())) {
        duplicateIndexesList.add(tableData.getIndex());
    }
}

From source file:io.github.moosbusch.permagon.configuration.builder.spi.AbstractPermagonBuilder.java

protected Object putListProperty(String propertyName, Object value) {
    Object result = null;//from   www  . j a va2s  . co m
    Object childrenValue = Objects.requireNonNull(get(propertyName));

    if (childrenValue instanceof ObservableMap) {
        ObservableMap propertiesMap = (ObservableMap) childrenValue;
        Object obj = Objects.requireNonNull(propertiesMap.get(propertyName));

        if (obj instanceof ObservableList) {
            ObservableList childrenValueList = (ObservableList) obj;

            result = childrenValueList;

            if ((value instanceof Node) || (value instanceof Tab)) {
                if (!childrenValueList.contains(value)) {
                    childrenValueList.add(value);
                    properties.put(propertyName, childrenValueList);
                }
            }
        }
    }

    return result;
}

From source file:com.ubershy.streamsis.project.CuteProject.java

/**
 * Validates list with Actors/SisScenes. <br>
 * Throws exceptions if something is wrong telling programmer about errors he made.
 *
 * @param list/*  w ww.  ja v  a 2  s . c o m*/
 *            the list with Actors or SisScenes
 */
private <T> void validateListOfActorsOrSisScenes(ObservableList<T> list) {
    if (list.isEmpty()) {
        return;
    }
    if (list.contains(null)) {
        throw new RuntimeException("One of the elements in list is null");
    }
    String elementType = null;
    Object firstElement = list.get(0);
    if (firstElement instanceof Actor) {
        elementType = "Actor";
    }
    if (firstElement instanceof SisScene) {
        elementType = "SisScene";
    }
    if (elementType == null) {
        throw new RuntimeException("This method only checks lists of Actors or SisScenes");
    }

    ArrayList<String> names = new ArrayList<String>();
    for (T element : list) {
        String name = ((CuteElement) element).getElementInfo().getName();
        if (name != null) {
            names.add(name);
        } else {
            throw new RuntimeException(elementType + " has null name");
        }
    }
    HashSet<String> uniqueNames = new HashSet<String>(names);
    if (names.size() != uniqueNames.size()) {
        throw new RuntimeException("Some of " + elementType + "s don't have unique names");
    }
}

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 www  .  j  a va2s. c om
        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:org.beryx.viewreka.fxapp.Viewreka.java

public void showFilePane(boolean show, FxProject newProject) {
    ObservableList<Node> items = mainSplitPane.getItems();
    if (show) {//  w ww.j  a  va 2  s .com
        if (!items.contains(fileSplitPane)) {
            items.add(0, fileSplitPane);
        }
        configureMainSplitDivider(project);
    } else {
        items.remove(fileSplitPane);
    }
    mnuToggleFilePane.setText((show ? "Hide" : "Show") + " File Area");
    if (newProject != null) {
        newProject.getProjectSettingsManager().getSettings().setProperty(PROP_FILE_AREA_VISIBLE, show);
    }
}