@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);
}
java类javafx.collections.ObservableMap的实例源码
FxGsonTest.java 文件源码
项目:fx-gson
阅读 27
收藏 0
点赞 0
评论 0
FxGsonTest.java 文件源码
项目:fx-gson
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
FxGsonTest.java 文件源码
项目:fx-gson
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
DefaultStringTableXmlParser.java 文件源码
项目:arma-dialog-creator
阅读 19
收藏 0
点赞 0
评论 0
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));
}
}
}
StatusFilterPropertyUpdater.java 文件源码
项目:JttDesktop
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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 */ }
);
}
StatusConfigurationPane.java 文件源码
项目:JttDesktop
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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 );
}
StatusConfigurationPaneTest.java 文件源码
项目:JttDesktop
阅读 17
收藏 0
点赞 0
评论 0
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 ) );
}
AbstractPerspective.java 文件源码
项目:aic-praise
阅读 24
收藏 0
点赞 0
评论 0
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));
}
BufferingManager.java 文件源码
项目:reta
阅读 23
收藏 0
点赞 0
评论 0
/**
* @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;
}
MediaInfo.java 文件源码
项目:fx-player
阅读 35
收藏 0
点赞 0
评论 0
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;
}
Listeners.java 文件源码
项目:SynchronizeFX
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
Dockable.java 文件源码
项目:marathonv5
阅读 18
收藏 0
点赞 0
评论 0
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);
}
}
PropertyUtils.java 文件源码
项目:shuffleboard
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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()));
}
}
});
}
Entry.java 文件源码
项目:CalendarFX
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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;
}
ObservableMergers.java 文件源码
项目:drd
阅读 22
收藏 0
点赞 0
评论 0
@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());
}
});
}
}
ObservableMergers.java 文件源码
项目:drd
阅读 20
收藏 0
点赞 0
评论 0
@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());
}
});
}
}
GeneralGameDataBar.java 文件源码
项目:voogasalad-ltub
阅读 18
收藏 0
点赞 0
评论 0
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);
}
GeneralGameDataBar.java 文件源码
项目:voogasalad-ltub
阅读 20
收藏 0
点赞 0
评论 0
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);
}
DynamicIconSupport.java 文件源码
项目:jmonkeybuilder
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
DynamicIconSupport.java 文件源码
项目:jmonkeybuilder
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
EditorAreaComponent.java 文件源码
项目:jmonkeybuilder
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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);
});
}
EditorAreaComponent.java 文件源码
项目:jmonkeybuilder
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
EditorAreaComponent.java 文件源码
项目:jmonkeybuilder
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
ActivityDiagramSkin.java 文件源码
项目:waterrower-workout
阅读 19
收藏 0
点赞 0
评论 0
private void updateActivities() {
ObservableMap<LocalDate, Activity> activities = getSkinnable().getActivityMap();
updateMonthLabels();
updateWeekLabels();
updateActivityRectangles(activities);
}
BeanPathAdapter.java 文件源码
项目:Java-9-Programming-Blueprints
阅读 26
收藏 0
点赞 0
评论 0
/**
* @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);
}