本文整理汇总了Java中javafx.collections.ObservableMap类的典型用法代码示例。如果您正苦于以下问题:Java ObservableMap类的具体用法?Java ObservableMap怎么用?Java ObservableMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObservableMap类属于javafx.collections包,在下文中一共展示了ObservableMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMapStrProperty
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例2: testObservableMapStr
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例3: testMapIntProperty
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例4: testObservableMapInt
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例5: testCustomTreeMapStrProperty
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例6: testCustomObservableTreeMapStr
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例7: testCustomTreeMapIntProperty
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例8: testCustomObservableTreeMapInt
import javafx.collections.ObservableMap; //导入依赖的package包/类
@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);
}
示例9: fetchKeys
import javafx.collections.ObservableMap; //导入依赖的package包/类
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));
}
}
}
示例10: StatusFilterPropertyUpdater
import javafx.collections.ObservableMap; //导入依赖的package包/类
/**
* 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 */ }
);
}
示例11: addItemConfiguration
import javafx.collections.ObservableMap; //导入依赖的package包/类
/**
* 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 );
}
示例12: assertThatElementsAreProvided
import javafx.collections.ObservableMap; //导入依赖的package包/类
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 ) );
}
示例13: newModel
import javafx.collections.ObservableMap; //导入依赖的package包/类
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));
}
示例14: bufferingMap
import javafx.collections.ObservableMap; //导入依赖的package包/类
/**
* @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;
}
示例15: setIfUpdate
import javafx.collections.ObservableMap; //导入依赖的package包/类
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;
}