Java Code Examples for javafx.collections.ObservableMap#put()

The following examples show how to use javafx.collections.ObservableMap#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Participant.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
public static ObservableMap<String,String> getAvailableAttributes() {
    ObservableMap<String,String> attribMap = FXCollections.observableMap(new LinkedHashMap() );
    
    attribMap.put("bib", "Bib");
    attribMap.put("first", "First Name");
    attribMap.put("middle", "Middle Name");
    attribMap.put("last", "Last Name");
    attribMap.put("age", "Age");
    attribMap.put("birth","Birthday");
    attribMap.put("sex-gender", "Sex");
    attribMap.put("city", "City");
    attribMap.put("state", "State");
    attribMap.put("zip","Zip Code");
    attribMap.put("country", "Country");
    attribMap.put("status","Status");
    attribMap.put("note","Note");
    attribMap.put("email", "EMail");
    // TODO: routine to add custom attributes based on db lookup
    return attribMap; 
}
 
Example 2
Source File: MapPropertyExTests.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void changeListenerRegistrationAndDeregistration() {
	MapProperty<Integer, String> property = propertyProvider.get();

	// register listener
	ChangeExpector<Integer, String> changeListener = null;
	changeListener = new ChangeExpector<>(property);
	property.addListener(changeListener);

	// add second listener (and remove again)
	ChangeExpector<Integer, String> changeListener2 = null;
	changeListener2 = new ChangeExpector<>(property);
	property.addListener(changeListener2);
	property.removeListener(changeListener2);

	ObservableMap<Integer, String> newValue = FXCollections
			.observableMap(new HashMap<Integer, String>());
	changeListener.addExpectation(property.get(), newValue);
	newValue.put(1, "1");
	property.set(newValue);
	changeListener.check();
}
 
Example 3
Source File: Dockable.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * 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.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    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);
    }
}
 
Example 5
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * 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.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    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);
    }
}
 
Example 6
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@FxThread
private static void updateListener(@NotNull final Node node, @NotNull final ImageView imageView,
                                   @NotNull final ReadOnlyBooleanProperty condition,
                                   @NotNull final Object listenerKey, @NotNull final Object notSelectedKey,
                                   @NotNull final Object selectedKey) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

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

    final ObservableMap<Object, Object> properties = node.getProperties();
    final Image newImage = imageView.getImage();

    if (newImage == null) {
        properties.remove(listenerKey);
        return;
    }

    final Image original = FILE_ICON_MANAGER.getOriginal(newImage);

    properties.put(notSelectedKey, newImage);
    properties.put(selectedKey, original);

    final ChangeListener<Boolean> listener = (observable, oldValue, newValue) -> {
        if (newValue) {
            imageView.setImage((Image) properties.get(selectedKey));
        } else {
            imageView.setImage((Image) properties.get(notSelectedKey));
        }
    };

    condition.addListener(listener);

    properties.put(listenerKey, listener);

    if (condition.get()) {
        imageView.setImage(original);
    } else {
        imageView.setImage(newImage);
    }
}
 
Example 7
Source File: PreferencesViewModelTest.java    From bisq with GNU Affero General Public License v3.0 3 votes vote down vote up
@Test
public void getArbitrationLanguages() {

    RefundAgentManager refundAgentManager = mock(RefundAgentManager.class);

    final ObservableMap<NodeAddress, RefundAgent> refundAgents = FXCollections.observableHashMap();

    ArrayList<String> languagesOne = new ArrayList<>() {{
        add("en");
        add("de");
    }};

    ArrayList<String> languagesTwo = new ArrayList<>() {{
        add("en");
        add("es");
    }};

    RefundAgent one = new RefundAgent(new NodeAddress("refundAgent:1"), null, languagesOne, 0L,
            null, null, null, null, null);

    RefundAgent two = new RefundAgent(new NodeAddress("refundAgent:2"), null, languagesTwo, 0L,
            null, null, null, null, null);

    refundAgents.put(one.getNodeAddress(), one);
    refundAgents.put(two.getNodeAddress(), two);

    Preferences preferences = PreferenceMakers.empty;

    when(refundAgentManager.getObservableMap()).thenReturn(refundAgents);

    PreferencesViewModel model = new PreferencesViewModel(preferences, refundAgentManager, null);

    assertEquals("English, Deutsch, español", model.getArbitrationLanguages());
}
 
Example 8
Source File: PreferencesViewModelTest.java    From bisq with GNU Affero General Public License v3.0 3 votes vote down vote up
@Test
public void getMediationLanguages() {

    MediatorManager mediationManager = mock(MediatorManager.class);

    final ObservableMap<NodeAddress, Mediator> mnediators = FXCollections.observableHashMap();

    ArrayList<String> languagesOne = new ArrayList<>() {{
        add("en");
        add("de");
    }};

    ArrayList<String> languagesTwo = new ArrayList<>() {{
        add("en");
        add("es");
    }};

    Mediator one = new Mediator(new NodeAddress("refundAgent:1"), null, languagesOne, 0L,
            null, null, null, null, null);

    Mediator two = new Mediator(new NodeAddress("refundAgent:2"), null, languagesTwo, 0L,
            null, null, null, null, null);

    mnediators.put(one.getNodeAddress(), one);
    mnediators.put(two.getNodeAddress(), two);

    Preferences preferences = PreferenceMakers.empty;

    when(mediationManager.getObservableMap()).thenReturn(mnediators);

    PreferencesViewModel model = new PreferencesViewModel(preferences, null, mediationManager);

    assertEquals("English, Deutsch, español", model.getMediationLanguages());
}