Example usage for javafx.collections ObservableList set

List of usage examples for javafx.collections ObservableList set

Introduction

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

Prototype

E set(int index, E element);

Source Link

Document

Replaces the element at the specified position in this list with the specified element (optional operation).

Usage

From source file:Main.java

public static void main(String[] args) {
    ObservableList<String> list = FXCollections.observableArrayList("one", "two");
    System.out.println(list);//from   w w w  .j  a v  a2  s .c  o m

    list.addListener(Main::onChanged);

    list.addAll("A", "B");
    System.out.println("After addAll() - list: " + list);

    list.remove(1, 3);
    System.out.println("After remove() - list: " + list);

    list.retainAll("one");
    System.out.println("After retainAll() - list: " + list);

    list.set(0, "ONE");
    System.out.println("After set() - list: " + list);
}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Resets all marks at the processing chain container, items are kept.
 *//*from w ww . j ava2  s  . co m*/
private void resetProcessingChainContainer() {
    for (Node o : chainContainer.getChildren()) {
        if (o instanceof VBox) {
            VBox v = (VBox) o;
            HBox hbox = (HBox) v.getChildren().get(0);
            Node cBox = hbox.getChildren().get(0);
            if (cBox instanceof ComboBox) {
                cBox.setStyle(FX_BORDER_COLOR_NULL);
                ComboBox box = (ComboBox) cBox;
                ObservableList<ProcessingStepConfiguration> confs = (ObservableList<ProcessingStepConfiguration>) box
                        .getItems();
                for (ProcessingStepConfiguration cfgI : confs) {
                    cfgI.setCompatible(true);
                    confs.set(confs.indexOf(cfgI), cfgI);
                }
            }
        }
    }
}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Validates the chain items of a ComboBox
 * and marks the box according to the chosen item.
 *
 * @param box Item to validate//from  w w  w  . jav a 2 s.c o m
 * @return True if chosen item is valid, else false
 */
private boolean validateChainContainer(ComboBox box) {
    String format = this.dataBean.getAttributeValue(OUTPUTFORMAT);
    if (format == null) {
        box.setStyle(FX_BORDER_COLOR_RED);
        setStatusTextUI(I18n.format(GUI_PROCESS_NO_FORMAT));
    }
    MIMETypes mtypes = Config.getInstance().getMimeTypes();
    MIMEType mtype = mtypes.findByName(format);

    ProcessingStepConfiguration cfg = (ProcessingStepConfiguration) box.getValue();
    ObservableList<ProcessingStepConfiguration> items = (ObservableList<ProcessingStepConfiguration>) box
            .getItems();

    if (format != null && mtype == null) {
        box.setStyle(FX_BORDER_COLOR_RED);
        for (ProcessingStepConfiguration cfgI : items) {
            cfgI.setCompatible(false);
            //Workaround to force cell update
            items.set(items.indexOf(cfgI), cfgI);
        }
        setStatusTextUI(I18n.format(GUI_PROCESS_FORMAT_NOT_FOUND));
        return false;
    }

    //Mark items that are incompatible
    for (ProcessingStepConfiguration cfgI : items) {
        if (format != null) {
            cfgI.setCompatible(cfgI.isCompatibleWithFormat(mtype.getType()));
        } else {
            cfgI.setCompatible(false);
        }
        items.set(items.indexOf(cfgI), cfgI);
    }

    if (format == null) {
        return false;
    }

    if (cfg == null) {
        box.setStyle(FX_BORDER_COLOR_NULL);
        return true;
    }

    if (cfg.isCompatible()) {
        box.setStyle(FX_BORDER_COLOR_NULL);
    } else {
        box.setStyle(FX_BORDER_COLOR_RED);
        setStatusTextUI(I18n.format(GUI_PROCESS_NOT_COMPATIBLE, box.getValue()));
    }
    return cfg.isCompatible();
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iNumZone numro de la zone/* w  w  w  . ja  v a 2s  . c  o m*/
 * @param points liste de points du polygone
 * @return ancres du polygone
 */
private static ObservableList<AncreForme> olCreeAncresPourPolygone(int iNumZone,
        final ObservableList<Double> points) {
    ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList();

    for (int i = 0; i < points.size(); i += 2) {
        final int idx = i;

        DoubleProperty xProperty = new SimpleDoubleProperty(points.get(i));
        DoubleProperty yProperty = new SimpleDoubleProperty(points.get(i + 1));

        xProperty.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
            points.set(idx, (double) x);
            String chaine = "";
            chaine = points.stream().map((point) -> point.toString() + ",").reduce(chaine, String::concat);
            chaine = chaine.substring(0, chaine.length() - 1);
            zones[iNumZone].setStrCoordonneesZone(chaine);
        });

        yProperty.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
            points.set(idx + 1, (double) y);
            String chaine = "";
            chaine = points.stream().map((point) -> point.toString() + ",").reduce(chaine, String::concat);
            chaine = chaine.substring(0, chaine.length() - 1);
            zones[iNumZone].setStrCoordonneesZone(chaine);
        });

        olAnchors.add(new AncreForme(Color.GOLD, xProperty, yProperty));
    }

    return olAnchors;
}