Example usage for javafx.collections ObservableMap get

List of usage examples for javafx.collections ObservableMap get

Introduction

In this page you can find the example usage for javafx.collections ObservableMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

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

protected void buildPane(Pane pane) {
    if (containsKey(NODE_CHILDREN_PROPERTY)) {
        Object obj = Objects.requireNonNull(get(NODE_CHILDREN_PROPERTY));

        if (obj instanceof ObservableMap) {
            ObservableMap propertiesMap = (ObservableMap) obj;
            Object childrenObj = Objects.requireNonNull(propertiesMap.get(NODE_CHILDREN_PROPERTY));

            if (childrenObj instanceof ObservableList) {
                pane.getChildren().addAll((ObservableList) childrenObj);
            }/*  www .  j  a  v  a2  s . co  m*/
        }
    }
}

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

protected void buildTabPane(TabPane pane) {
    if (containsKey(NODE_TABS_PROPERTY)) {
        Object obj = Objects.requireNonNull(get(NODE_TABS_PROPERTY));

        if (obj instanceof ObservableMap) {
            ObservableMap propertiesMap = (ObservableMap) obj;
            Object childrenObj = Objects.requireNonNull(propertiesMap.get(NODE_TABS_PROPERTY));

            if (childrenObj instanceof ObservableList) {
                pane.getTabs().addAll((ObservableList) childrenObj);
            }/*w  ww.j a  v a 2 s.  c  o m*/
        }
    }
}

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

protected void buildTab(Tab pane) {
    if (containsKey(NODE_CONTENT_PROPERTY)) {
        Object obj = Objects.requireNonNull(get(NODE_CONTENT_PROPERTY));

        if (obj instanceof ObservableMap) {
            ObservableMap propertiesMap = (ObservableMap) obj;
            Object childrenObj = Objects.requireNonNull(propertiesMap.get(NODE_CONTENT_PROPERTY));

            if (childrenObj instanceof Node) {
                pane.setContent((Node) childrenObj);
            }/*  w w  w . jav a 2 s .  c  o  m*/
        }
    }
}

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 va2  s .  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:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java

public void addFormatIcons() {
    colFormats.setCellFactory(/*from   w w  w  .ja v a2 s  .c  o m*/
            new Callback<TableColumn<ReportRow, ObservableMap<String, String>>, TableCell<ReportRow, ObservableMap<String, String>>>() {
                @Override
                public TableCell<ReportRow, ObservableMap<String, String>> call(
                        TableColumn<ReportRow, ObservableMap<String, String>> param) {
                    TableCell<ReportRow, ObservableMap<String, String>> cell = new TableCell<ReportRow, ObservableMap<String, String>>() {
                        @Override
                        public void updateItem(ObservableMap<String, String> item, boolean empty) {
                            super.updateItem(item, empty);
                            if (!empty && item != null) {

                                HBox box = new HBox();
                                box.setSpacing(3);
                                box.setAlignment(Pos.CENTER_LEFT);

                                for (String i : item.keySet()) {
                                    ImageView icon = new ImageView();
                                    icon.setId("but" + i);
                                    icon.setFitHeight(20);
                                    icon.setFitWidth(20);
                                    icon.setImage(new Image("images/formats/" + i + ".png"));
                                    icon.setCursor(Cursor.HAND);

                                    String type = i;
                                    String path = item.get(i);
                                    icon.setOnMouseClicked(new EventHandler<MouseEvent>() {
                                        @Override
                                        public void handle(MouseEvent event) {
                                            ArrayMessage am = new ArrayMessage();
                                            am.add(GuiConfig.PERSPECTIVE_SHOW, new UiMessage());
                                            am.add(GuiConfig.PERSPECTIVE_SHOW + "." + GuiConfig.COMPONENT_SHOW,
                                                    new ShowMessage(type, path));
                                            getContext().send(GuiConfig.PERSPECTIVE_SHOW, am);
                                        }
                                    });

                                    ContextMenu contextMenu = new ContextMenu();
                                    javafx.scene.control.MenuItem download = new javafx.scene.control.MenuItem(
                                            "Download report");
                                    contextMenu.getItems().add(download);
                                    icon.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                                        public void handle(ContextMenuEvent e) {
                                            contextMenu.show(icon, e.getScreenX(), e.getScreenY());
                                        }
                                    });
                                    box.getChildren().add(icon);
                                }

                                setGraphic(box);
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                    return cell;
                }
            });
}