Java 类javafx.collections.ObservableMap 实例源码

项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testMapStrProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put("key1", one);
    ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapOne, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapTwo,
            "{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testObservableMapStr(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put("key1", one);
    ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    Function<WithObsMapStr, ObservableMap<String, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapStr, ObservableMap<String, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapStr.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapOne, "{\"map\":{\"key1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapTwo,
            "{\"map\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", getter, setter, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testMapIntProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put(1, one);
    ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    testProperty(WithMapIntProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapOne, "{\"prop\":{\"1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapTwo,
            "{\"prop\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testObservableMapInt(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put(1, one);
    ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapOne, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapTwo, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
            getter, setter, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testCustomTreeMapStrProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<String, CustomObject> mapEmpty = new TreeMap<>();
    Map<String, CustomObject> mapOne = new TreeMap<>();
    mapOne.put("key1", one);
    Map<String, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    ObservableMap<String, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<String, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<String, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapEmptyObs, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapOneObs, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapTwoObs,
            "{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testCustomObservableTreeMapStr(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<String, CustomObject> mapEmpty = new TreeMap<>();
    Map<String, CustomObject> mapOne = new TreeMap<>();
    mapOne.put("key1", one);
    Map<String, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    ObservableMap<String, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<String, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<String, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    Function<WithObsMapStr, ObservableMap<String, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapStr, ObservableMap<String, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapStr.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapEmptyObs, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapOneObs, "{\"map\":{\"key1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapTwoObs,
            "{\"map\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", getter, setter, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testCustomTreeMapIntProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<Integer, CustomObject> mapEmpty = new TreeMap<>();
    Map<Integer, CustomObject> mapOne = new TreeMap<>();
    mapOne.put(1, one);
    Map<Integer, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    ObservableMap<Integer, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<Integer, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<Integer, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    testProperty(WithMapIntProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapEmptyObs, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapOneObs, "{\"prop\":{\"1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapTwoObs,
            "{\"prop\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
项目:fx-gson    文件:FxGsonTest.java   
@Theory
public void testCustomObservableTreeMapInt(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<Integer, CustomObject> mapEmpty = new TreeMap<>();
    Map<Integer, CustomObject> mapOne = new TreeMap<>();
    mapOne.put(1, one);
    Map<Integer, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    ObservableMap<Integer, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<Integer, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<Integer, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapEmptyObs, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapOneObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapTwoObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
            getter, setter, gson);
}
项目:arma-dialog-creator    文件:DefaultStringTableXmlParser.java   
private void fetchKeys(Element element, StringTableKeyPath path, List<StringTableKey> tableKeys) {
    List<Element> keyElements = XmlUtil.getChildElementsWithTagName(element, StringTableXmlConstants.KEY);

    for (Element keyElement : keyElements) {
        String id = keyElement.getAttribute(StringTableXmlConstants.ID).trim();

        if (id.length() > 0) {
            List<Element> valueElements = XmlUtil.getChildElementsWithTagName(keyElement, null);
            ObservableMap<Language, String> map = FXCollections.observableMap(new HashMap<>(valueElements.size()));
            for (Element valueElement : valueElements) {
                Language language;
                String langName = valueElement.getTagName();
                try {
                    language = KnownLanguage.valueOf(langName);
                } catch (IllegalArgumentException e) {
                    language = new CustomLanguage(langName);
                }
                map.put(language, XmlUtil.getImmediateTextContent(valueElement));
            }
            tableKeys.add(new StringTableKeyImpl(id, path.deepCopy(), map));
        }
    }
}
项目:JttDesktop    文件:StatusFilterPropertyUpdater.java   
/**
 * Constructs a new {@link StatusFilterPropertyUpdater}.
 * @param map the map notifying.
 * @param status the {@link BuildResultStatus} to filter for.
 * @param property the {@link ObjectProperty} to update.
 */
public StatusFilterPropertyUpdater( 
         ObservableMap< BuildResultStatus, Color > map,
         BuildResultStatus status, 
         ObjectProperty< Color > property
) {
   super( 
            map, 
            ( k, v ) -> {
               if ( k == status ) {
                  property.set( v );
               }
            }, 
            ( k, v ) -> { /* do nothing if removed, leave previous value */ } 
   );
}
项目:JttDesktop    文件:StatusConfigurationPane.java   
/**
 * General mechanism for adding {@link ColorPicker}s.
 * @param row the row to add the items on.
 * @param label the {@link Label} describing the {@link ColorPicker}.
 * @param picker the {@link ColorPicker}.
 * @param shortcut the {@link Button} providing the shortcut.
 * @param map the {@link ObservableMap} providing the {@link Color}.
 */
private void addItemConfiguration( int row, Label label, ColorPicker picker, Button shortcut, ObservableMap< BuildResultStatus, Color > map ) {
   add( label, 0, row );

   styling.configureColorPicker( picker, map.get( status ) );

   map.addListener( 
            new StatusFilterPropertyUpdater( map, status, picker.valueProperty() )
   );
   picker.valueProperty().addListener( ( s, o, n ) -> map.put( status, n ) );
   add( picker, 1, row );

   shortcut.setMaxWidth( Double.MAX_VALUE );
   shortcut.setOnAction( e -> picker.setValue( shortcuts.shortcutColorProperty().get() ) );
   add( shortcut, 2, row );
}
项目:JttDesktop    文件:StatusConfigurationPaneTest.java   
private void assertThatElementsAreProvided( 
         Label label, String labelText, 
         ColorPicker picker,
         Button button,
         ObservableMap< BuildResultStatus, Color > map 
){
   assertThat( systemUnderTest.getChildren().contains( label ), is( true ) );
   assertThat( label.getText(), is( labelText ) );
   verify( styling ).createBoldLabel( labelText );

   assertThat( systemUnderTest.getChildren().contains( picker ), is( true ) );
   verify( styling ).configureColorPicker( picker, map.get( status ) );

   assertThat( systemUnderTest.getChildren().contains( button ), is( true ) );
   assertThat( button.getText(), is( StatusConfigurationPane.SHORTCUT_BUTTON_TEXT ) );
   assertThat( button.getMaxWidth(), is( Double.MAX_VALUE ) );
}
项目:aic-praise    文件:AbstractPerspective.java   
protected void newModel(Supplier<ObservableMap<Integer, Supplier<ModelPageEditor>>> initialModelPagesSupplier) {
    undoManagersForgetHistory();
    callUndoManagers(um -> um.undoAvailableProperty().removeListener(this::checkGlobalUndoState));

    modelPageEditors.set(initialModelPagesSupplier.get());

    // Unbind and create a new page change undo manager for the new model
    canUndoPageChange.unbind();
    canRedoPageChange.unbind();
    pageChangeUndoManager.close();

    pageChangeUndoManager = newPageChangeUndoManager();
    canUndoPageChange.bind(pageChangeUndoManager.undoAvailableProperty());
    canRedoPageChange.bind(pageChangeUndoManager.redoAvailableProperty());

    bindModelPageEditorUndoManager(0);
    currentModelPageIndexProperty.set(0);

    callUndoManagers(um -> um.undoAvailableProperty().addListener(this::checkGlobalUndoState));
}
项目:reta    文件:BufferingManager.java   
/**
 * @param bean
 *            bean instance
 * @param propertyName
 *            bean set property name
 * @return {@link ObservableMapBuffering} for the property
 * @param <K>
 *            map key type
 * @param <E>
 *            map value type
 */
public <K, E> ObservableMapBuffering<K, E> bufferingMap(final Object bean, final String propertyName)
{
    ObservableMapBuffering<K, E> lb = null;
    @SuppressWarnings("unchecked")
    final Map<K, E> value = getPropertyValue(bean, propertyName, Map.class);
    if (value instanceof ObservableMap<?, ?>)
    {
        lb = new ObservableMapBuffering<>(bean.getClass(), propertyName, (ObservableMap<K, E>) value);
    }
    else
    {
        lb = new ObservableMapBuffering<>(bean.getClass(), propertyName, FXCollections.observableMap(value));
    }
    add(lb);
    return lb;
}
项目:fx-player    文件:MediaInfo.java   
private static <T> T setIfUpdate(ObservableMap<? extends String, ? extends Object> map,
        String key, WritableValue<T>... props) {
    T newValue = (T) map.get(key);
    if (newValue != null) {
        boolean stringEmpty = false;
        if (newValue instanceof String) {
            String newStr = (String) newValue;
            stringEmpty = newStr.isEmpty();
        }
        for (WritableValue<T> prop : props) {
            if (stringEmpty) {
                if (prop.getValue() == null) {
                    prop.setValue(newValue);
                }
            } else {
                prop.setValue(newValue);
            }
        }
    }
    return newValue;
}
项目:SynchronizeFX    文件:Listeners.java   
@Override
public void onChanged(final MapChangeListener.Change<? extends Object, ? extends Object> change) {
    final ObservableMap<?, ?> map = change.getMap();
    if (disabledFor.containsKey(map)) {
        return;
    }
    try {
        final UUID mapId = objectRegistry.getIdOrFail(map);
        final Object key = change.getKey();
        if (change.wasAdded()) {
            final Object value = change.getValueAdded();
            final List<Command> commands = creator.putToMap(mapId, key, value);
            registerListenersOnEverything(key);
            if (value != null) {
                registerListenersOnEverything(value);
            }
            distributeCommands(commands);
        } else {
            distributeCommands(creator.removeFromMap(mapId, key));
        }
    } catch (final SynchronizeFXException e) {
        topology.onError(e);
    }
}
项目:marathonv5    文件:Dockable.java   
public void setContainer(IDockingContainer container) {
    ObservableMap<Object, Object> properties = getComponent().getProperties();
    if (container == null) {
        properties.remove(DockingDesktop.DOCKING_CONTAINER);
    } else {
        properties.put(DockingDesktop.DOCKING_CONTAINER, container);
    }
}
项目:shuffleboard    文件:PropertyUtils.java   
/**
 * Binds a property to a specific key in a map. If there is no entry for that key, the property's
 * value will be set to null.
 *
 * @param property the property to bind
 * @param map      the map to bind to
 * @param key      the key for the entry to bind to
 * @param v2t      a conversion function for converting objects of type <i>V</i> to type <i>T</i>
 * @param <K>      the types of the keys in the map
 * @param <V>      the types of the values in the map
 * @param <T>      the type of data in the property
 */
public static <K, V, T extends V> void bindToMapBidirectionally(Property<T> property,
                                                                ObservableMap<K, V> map,
                                                                K key,
                                                                Function<V, T> v2t) {
  property.addListener((__, oldValue, newValue) -> map.put(key, newValue));
  map.addListener((MapChangeListener<K, V>) change -> {
    if (change.getKey().equals(key)) {
      if (change.wasRemoved() && !map.containsKey(key)) {
        property.setValue(null);
      } else if (change.wasAdded()) {
        property.setValue(v2t.apply(change.getValueAdded()));
      }
    }
  });
}
项目:CalendarFX    文件:Entry.java   
/**
 * Returns an observable map of properties on this entry for use primarily
 * by application developers.
 *
 * @return an observable map of properties on this entry for use primarily
 * by application developers
 */
public final ObservableMap<Object, Object> getProperties() {
    if (properties == null) {
        properties = FXCollections.observableMap(new HashMap<>());

        MapChangeListener<? super Object, ? super Object> changeListener = change -> {
            if (change.getKey().equals("com.calendarfx.recurrence.source")) { //$NON-NLS-1$
                if (change.getValueAdded() != null) {
                    @SuppressWarnings("unchecked")
                    Entry<T> source = (Entry<T>) change.getValueAdded();

                    // lookup of property first to instantiate
                    recurrenceSourceProperty();
                    recurrenceSource.set(source);
                }
            } else if (change.getKey().equals("com.calendarfx.recurrence.id")) { //$NON-NLS-1$
                if (change.getValueAdded() != null) {
                    setRecurrenceId((String) change.getValueAdded());
                }
            }
        };

        properties.addListener(changeListener);
    }

    return properties;
}
项目:drd    文件:ObservableMergers.java   
@SafeVarargs
public static <K, V> void mergeMap(ObservableMap<K, V> into,
    ObservableMap<K, V>... maps) {
    final ObservableMap<K, V> map = into;
    for (ObservableMap<K, V> m : maps) {
        map.putAll(m);
        m.addListener((MapChangeListener<K, V>) c -> {
            if (c.wasAdded()) {
                map.put(c.getKey(), c.getValueAdded());
            }
            if (c.wasRemoved()) {
                map.remove(c.getKey());
            }
        });
    }
}
项目:drd    文件:ObservableMergers.java   
@SafeVarargs
public static <K, V, W> void mergeMap(Function<? super W, ? extends V> mapper,
    ObservableMap<K, V> into, ObservableMap<K, W>... maps) {
    final ObservableMap<K, V> map = into;
    for (ObservableMap<K, W> m : maps) {
        for (Entry<K, W> entry : m.entrySet()) {
            map.put(entry.getKey(), mapper.apply(entry.getValue()));
        }
        m.addListener((MapChangeListener<K, W>) c -> {
            if (c.wasAdded()) {
                map.put(c.getKey(), mapper.apply(c.getValueAdded()));
            }
            if (c.wasRemoved()) {
                map.remove(c.getKey());
            }
        });
    }
}
项目:voogasalad-ltub    文件:GeneralGameDataBar.java   
public GeneralGameDataBar(ObservableMap<String, String> data) {
    this.setSpacing(SPACING);
    data.addListener(new MapChangeListener<String, String>() {
        @Override
        public void onChanged(@SuppressWarnings("rawtypes") MapChangeListener.Change change) {
            redraw(data);
        }
    });
    redraw(data);
}
项目:voogasalad-ltub    文件:GeneralGameDataBar.java   
private void redraw(ObservableMap<String, String> data) {
    this.getChildren().clear();
    bonuses = new Text(myResources.getString(NUM_BONUSES) + data.get(myResources.getString(bonusKey)));
    gold = new Text(myResources.getString(NUM_GOLD) + data.get(myResources.getString(goldKey)));
    levels = new Text(myResources.getString(NUM_LEVEL) + data.get(myResources.getString(levelKey)));
    lives = new Text(myResources.getString(NUM_LIVES) + data.get(myResources.getString(livesKey)));
    this.getChildren().addAll(lives, levels, gold, bonuses);
}
项目:jmonkeybuilder    文件:DynamicIconSupport.java   
/**
 * Adds support changing icons by selection.
 *
 * @param button the button.
 */
@FXThread
public static void addSupport(@NotNull final ToggleButton button) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getTheme();

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ImageView graphic = (ImageView) button.getGraphic();
    final Image image = graphic.getImage();
    final Image original = FILE_ICON_MANAGER.getOriginal(image);

    final ObservableMap<Object, Object> properties = button.getProperties();
    properties.put(NOT_SELECTED_IMAGE, image);
    properties.put(SELECTED_IMAGE, original);

    button.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            graphic.setImage((Image) properties.get(SELECTED_IMAGE));
        } else {
            graphic.setImage((Image) properties.get(NOT_SELECTED_IMAGE));
        }
    });

    if (button.isSelected()) {
        graphic.setImage(original);
    } else {
        graphic.setImage(image);
    }
}
项目:jmonkeybuilder    文件:DynamicIconSupport.java   
/**
 * Adds support changing icons by pressed.
 *
 * @param button the button.
 */
@FXThread
public static void addSupport(@NotNull final ButtonBase button) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getTheme();

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ImageView graphic = (ImageView) button.getGraphic();
    final Image image = graphic.getImage();
    final Image original = FILE_ICON_MANAGER.getOriginal(image);

    final ObservableMap<Object, Object> properties = button.getProperties();
    properties.put(NOT_PRESSED_IMAGE, image);
    properties.put(PRESSED_IMAGE, original);

    button.pressedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            graphic.setImage((Image) properties.get(PRESSED_IMAGE));
        } else {
            graphic.setImage((Image) properties.get(NOT_PRESSED_IMAGE));
        }
    });

    if (button.isPressed()) {
        graphic.setImage(original);
    } else {
        graphic.setImage(image);
    }
}
项目:jmonkeybuilder    文件:EditorAreaComponent.java   
/**
 * Handle the request to close a file editor.
 */
@FXThread
private void processChangeTabs(@NotNull final ListChangeListener.Change<? extends Tab> change) {
    if (!change.next()) return;

    final List<? extends Tab> removed = change.getRemoved();
    if (removed == null || removed.isEmpty()) return;

    removed.forEach(tab -> {

        final ObservableMap<Object, Object> properties = tab.getProperties();
        final FileEditor fileEditor = (FileEditor) properties.get(KEY_EDITOR);
        final Path editFile = fileEditor.getEditFile();

        DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, ObjectDictionary::remove);

        fileEditor.notifyClosed();

        if (isIgnoreOpenedFiles()) return;

        final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace();
        if (workspace != null) workspace.removeOpenedFile(editFile);
    });
}
项目:jmonkeybuilder    文件:EditorAreaComponent.java   
/**
 * Get the current showed editor.
 *
 * @return the current editor.
 */
@FXThread
public @Nullable FileEditor getCurrentEditor() {
    final Tab selectedTab = getSelectionModel().getSelectedItem();
    if (selectedTab == null) return null;
    final ObservableMap<Object, Object> properties = selectedTab.getProperties();
    return (FileEditor) properties.get(KEY_EDITOR);
}
项目:jmonkeybuilder    文件:EditorAreaComponent.java   
/**
 * Add and open the new file editor.
 *
 * @param editor   the editor
 * @param needShow the need show
 */
@FXThread
private void addEditor(@NotNull final FileEditor editor, final boolean needShow) {

    final Path editFile = editor.getEditFile();

    final Tab tab = new Tab(editor.getFileName());
    tab.setGraphic(new ImageView(ICON_MANAGER.getIcon(editFile, DEFAULT_FILE_ICON_SIZE)));
    tab.setContent(editor.getPage());
    tab.setOnCloseRequest(event -> handleRequestToCloseEditor(editor, tab, event));

    final ObservableMap<Object, Object> properties = tab.getProperties();
    properties.put(KEY_EDITOR, editor);

    editor.dirtyProperty().addListener((observable, oldValue, newValue) -> {
        tab.setText(newValue == Boolean.TRUE ? "*" + editor.getFileName() : editor.getFileName());
    });

    final ObservableList<Tab> tabs = getTabs();
    tabs.add(tab);

    if (needShow) {
        final SingleSelectionModel<Tab> selectionModel = getSelectionModel();
        selectionModel.select(tab);
    }

    DictionaryUtils.runInWriteLock(getOpenedEditors(), editFile, tab, ObjectDictionary::put);

    EditorUtil.decrementLoading();

    if (isIgnoreOpenedFiles()) {
        return;
    }

    final Workspace workspace = WORKSPACE_MANAGER.getCurrentWorkspace();

    if (workspace != null) {
        workspace.addOpenedFile(editFile, editor);
    }
}
项目:waterrower-workout    文件:ActivityDiagramSkin.java   
private void updateActivities() {

        ObservableMap<LocalDate, Activity> activities = getSkinnable().getActivityMap();

        updateMonthLabels();
        updateWeekLabels();
        updateActivityRectangles(activities);
    }
项目:Java-9-Programming-Blueprints    文件:BeanPathAdapter.java   
/**
 * @see BeanPathAdapter.FieldBean#performOperation(String, String,
 *      Class, String, Observable, Class, SelectionModel, FieldProperty,
 *      FieldBeanOperation)
 */
public <K, V> FieldProperty<?, ?, ?> performOperation(
        final String fieldPath,
        final ObservableMap<K, V> observableMap,
        final Class<V> mapValueClass, final String collectionItemPath,
        final Class<?> collectionItemPathType,
        final SelectionModel<V> selectionModel,
        final FieldProperty<?, ?, ?> itemMaster,
        final FieldBeanOperation operation) {
    return performOperation(fieldPath, fieldPath, mapValueClass,
            collectionItemPath, (Observable) observableMap,
            collectionItemPathType, selectionModel, itemMaster,
            operation);
}
项目:fx-gson    文件:FxGsonBuilder.java   
/**
 * Creates a {@link GsonBuilder} instance pre-configured based on the current configuration. This method is NOT free
 * of side-effects to this {@code FxGsonBuilder} instance and hence should not be called multiple times.
 *
 * @return an instance of GsonBuilder configured with the options currently set in this builder
 */
public GsonBuilder builder() {
    // serialization of nulls is necessary to have properties with null values deserialized properly
    builder.serializeNulls()
           .registerTypeAdapter(ObservableList.class, new ObservableListCreator())
           .registerTypeAdapter(ObservableSet.class, new ObservableSetCreator())
           .registerTypeAdapter(ObservableMap.class, new ObservableMapCreator())
           .registerTypeAdapterFactory(new JavaFxPropertyTypeAdapterFactory(strictProperties, strictPrimitives));
    if (includeExtras) {
        builder.registerTypeAdapterFactory(new JavaFxExtraTypeAdapterFactory());
    }
    return builder;
}
项目:arma-dialog-creator    文件:StringTableKeyImpl.java   
@Override
@NotNull
public StringTableKey deepCopy() {
    ObservableMap<Language, String> map = FXCollections.observableHashMap();
    map.putAll(this.getLanguageTokenMap());
    return new StringTableKeyImpl(getId(), getPath(), map);
}
项目:arma-dialog-creator    文件:DefaultStringTableXmlParserTest.java   
private static ObservableMap<Language, String> getMap(Language[] langs, String[] vals) {
    ObservableMap<Language, String> map = FXCollections.observableMap(new HashMap<>());
    int i = 0;
    for (Language language : langs) {
        map.put(language, vals[i++]);
    }
    return map;
}
项目:openjfx-8u-dev-tests    文件:NewTabPaneBase.java   
protected Map<Object, Object> getProperties(final int IDX) {
    return new GetAction<Map<Object, Object>>() {
        @Override
        public void run(Object... parameters) throws Exception {
            TabWrap tabWrap = getTabWrapByIndex(IDX);
            ObservableMap<Object, Object> properties = ((Tab) tabWrap.getControl()).getProperties();

            setResult(Collections.unmodifiableMap(properties));
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:JttDesktop    文件:JobPanelDescriptionBaseImpl.java   
/**
 * Method to update the {@link Color} of a {@link Label}.
 * @param coloursMap the {@link ObservableMap} of {@link Color}s to use.
 * @param configurationProperty the {@link ObjectProperty} from the {@link BuildWallConfiguration}.
 * @param textLabel the {@link Label} to update.
 */
private void updateColour( 
         ObservableMap< BuildResultStatus, Color > coloursMap, 
         ObjectProperty< Color > configurationProperty,
         Label textLabel
){
   Color themeColor = coloursMap.get( job.getBuildStatus() );
   if ( themeColor != null ) {
      textLabel.textFillProperty().set( themeColor );
   } else {
      textLabel.textFillProperty().set( configurationProperty.get() );
   }
}
项目:JttDesktop    文件:MapChangeListenerRegistrationImpl.java   
/**
 * Constructs a new {@link MapChangeListenerRegistrationImpl}.
 * @param observableMap the {@link ObservableMap} associated.
 * @param action the {@link MapChangeListener} associated with the {@link ObservableMap}.
 */
public MapChangeListenerRegistrationImpl( 
         ObservableMap< KeyTypeT, ValueTypeT > observableMap, 
         MapChangeListener< KeyTypeT, ValueTypeT > action 
) {
   this.map = observableMap;
   this.listener = action;
}
项目:JttDesktop    文件:StatusConfigurationPaneTest.java   
private void assertThatElementsAreUpdated(
         ObservableMap< BuildResultStatus, Color > map,
         ColorPicker picker
) {
   map.put( status, Color.BLANCHEDALMOND );
   assertThat( picker.getValue(), is( Color.BLANCHEDALMOND ) );

   map.put( status, null );
   assertThat( picker.getValue(), is( nullValue() ) );
}
项目:drbookings    文件:DateBean.java   
private Callable<ObservableMap<String, Number>> calculateEarningsPerOrigin() {
    return () -> {
        final ObservableMap<String, Number> result = FXCollections.observableMap(new TreeMap<>());
        final Stream<BookingEntry> s = getRooms().stream().flatMap(r -> r.getFilteredBookingEntries().stream());
        s.forEach(b -> {
            double n = result.getOrDefault(b.getElement().getBookingOrigin().getName(), Double.valueOf(0))
                    .doubleValue();
            n += b.getEarnings(SettingsManager.getInstance().isShowNetEarnings());
            result.put(b.getElement().getBookingOrigin().getName(), n);
        });
        return result;
    };
}
项目:j.commons    文件:DemoFXMLController.java   
@FXML
public void onDebug(ActionEvent actionEvent) {
    final ObservableMap<String, String> rmbStyleMap = FXCollections.observableHashMap();
    rmbStyleMap.addListener((InvalidationListener)(observable) ->
            rmb.setStyle(rmbStyleMap.entrySet().stream()
                    .map((entry) -> entry.getKey() + ": " + entry.getValue() + ";")
                    .reduce((s1, s2) -> s1 + s2).orElse("")));

    final Button bSize = new Button("Size");
    bSize.setOnAction((event) -> rmbStyleMap.put("-fx-size", "35"));

    final Button bGraphic = new Button("Graphic");
    bGraphic.setOnAction((event) -> rmbStyleMap.put("-fx-graphic","url(\"http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Add-icon.png\")"));

    final HBox menuButtonRow = new HBox();
    menuButtonRow.setAlignment(Pos.CENTER_LEFT);
    menuButtonRow.getChildren().addAll(new Label("RadialMenuButton:"), bSize, bGraphic);

    final VBox vbox = new VBox();
    vbox.getChildren().addAll(menuButtonRow);

    final Dialog dialog = new Dialog();
    dialog.initModality(Modality.NONE);
    dialog.initOwner(pane.getScene().getWindow());
    dialog.setTitle("Debugging actions");
    dialog.setHeaderText("Select an action to perform below:");
    dialog.getDialogPane().setContent(vbox);
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.show();
}
项目:SmartModInserter    文件:ObservableMapValues.java   
public ObservableMapValues(ObservableList<T> internalStore, ObservableMap<?, T> referencedMap) {
    this.internalStore = internalStore;
    this.referencedMap = referencedMap;

    referencedMap.addListener((MapChangeListener<Object, T>) change -> {
        if (change.wasAdded()) {
            internalStore.add(change.getValueAdded());
        }
        if (change.wasRemoved()) {
            internalStore.remove(change.getValueRemoved());
        }
    });
}