/** * Gets the value from the data source. This is only here because of clarity * in the code that handles both the data model value and the field value. * * @return The value of the property data source */ private Object getDataSourceValue() { return dataSource.getValue(); }
@Override public void buttonClick(Button.ClickEvent event) { Long businessServiceId = idProperty.getValue(); String businessServiceLabel = labelProperty.getValue(); BusinessServiceVertex vertex = new BusinessServiceVertex( businessServiceId, businessServiceLabel, 0 /* does not matter in this case*/); fireVertexUpdatedEvent(vertex); } });
@Override public void valueChange(Property.ValueChangeEvent event) { updateAuthenticationFields((Boolean) event.getProperty().getValue()); } });
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Property<OnmsIpInterface> property = source.getContainerProperty(itemId, columnId); if (property == null || property.getValue() == null) { return null; } else { return property.getValue().getIpAddressAsString(); } } }
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Property<?> property = source.getContainerProperty(itemId, columnId); if (property == null || property.getValue() == null) { return null; } else { return InetAddressUtils.str((InetAddress)property.getValue()); } } }
private Collection<String> getAuthenticationClassProperties() throws ClassNotFoundException { return !getChangedProperties().containsKey(AUTHENTICATION) ? new ArrayList<>() : java.util.Arrays.stream(Class.forName((String) getChangedProperties().get(AUTHENTICATION).getValue()).getDeclaredFields()) .filter(field -> !Modifier.isFinal(field.getModifiers())) .map(field -> StringUtils.substringAfterLast(field.toString(), ".")) .collect(Collectors.toList()); } }
public static void setAssetPropertyName(Item item, Node assetNode, String fileName) throws RepositoryException { // Set the Asset name property if empty if (item.getItemProperty(AssetNodeTypes.Asset.ASSET_NAME) == null || item.getItemProperty(AssetNodeTypes.Asset.ASSET_NAME).getValue() == null || StringUtils.isBlank(item.getItemProperty(AssetNodeTypes.Asset.ASSET_NAME).getValue().toString())) { assetNode.setProperty(AssetNodeTypes.Asset.ASSET_NAME, FilenameUtils.removeExtension(fileName)); } }
@Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { recreateCells(Integer.valueOf(valueChangeEvent.getProperty().getValue().toString()), m_gridLayout.getRows()); } });
@Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { recreateCells(m_gridLayout.getColumns(), Integer.valueOf(valueChangeEvent.getProperty().getValue().toString())); } });
protected void attachListener(T component) { component.addValueChangeListener(event -> { Object value = event.getProperty().getValue(); componentValueChanged(value, event instanceof CubaValueChangeEvent && ((CubaValueChangeEvent) event).isUserOriginated()); }); }
@Override public void valueChange(ValueChangeEvent event) { double red = (Double) event.getProperty().getValue(); if (!updatingColors) { Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue()); setColor(newColor); } } });
@Test public void returnsPropertiesWithChangedValues() throws RepositoryException { Node parentNode = session.getRootNode().addNode("node"); parentNode.setProperty("name", ""); JcrNodeAdapter adapter = new JcrNodeAdapter(parentNode); Property itemProperty1 = adapter.getItemProperty("name"); itemProperty1.setValue("changed"); Property itemProperty2 = adapter.getItemProperty("name"); assertThat(itemProperty2.getValue(), equalTo("changed")); } }
@Test public void addItemProperty() throws Exception { // GIVEN final Node underlyingNode = session.getRootNode().addNode("underlying"); Property<String> property = new ObjectProperty<>(propertyValue, String.class); final JcrNodeAdapter item = new JcrNodeAdapter(underlyingNode); // WHEN final boolean b = item.addItemProperty(propertyName, property); // THEN assertTrue(b); assertEquals(property.getValue(), item.getItemProperty(propertyName).getValue().toString()); }
@Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().getNavigator().addViewChangeListener(HeaderLayout.this); UI.getCurrent().getNavigator().navigateTo("wallboard/" + m_nativeSelect.getContainerProperty(m_nativeSelect.getValue(), "title").getValue()); } });
@Test public void getItemPropertyWithExistingProperty() throws Exception { // GIVEN Node node = session.getRootNode().addNode(nodeName); node.setProperty(propertyName, propertyValue); JcrNodeAdapter adapter = new JcrNodeAdapter(node); // WHEN Property property = adapter.getItemProperty(propertyName); // THEN assertEquals(propertyValue, property.getValue()); assertSame(property, adapter.getItemProperty(propertyName)); }
@Test public void getItemPropertyWithNewProperty() throws Exception { // GIVEN Node node = session.getRootNode().addNode(nodeName); JcrNodeAdapter adapter = new JcrNodeAdapter(node); // WHEN Property<String> property = new ObjectProperty<>("", String.class); adapter.addItemProperty(propertyName, property); // THEN assertEquals("", property.getValue()); assertSame(property, adapter.getItemProperty(propertyName)); }
@Test public void createCodeFieldChangeValue() { // GIVEN baseItem.addItemProperty(propertyName, new ObjectProperty<>("private String s", String.class)); Field<String> field = factory.createField(); assertEquals("private String s", field.getValue()); // WHEN field.setValue("new Value"); // THEN assertEquals("new Value", baseItem.getItemProperty(propertyName).getValue()); }
@Test public void testDefaultValue() throws Exception { // GIVEN baseItem = new JcrNewNodeAdapter(baseNode, baseNode.getPrimaryNodeType().getName()); checkBoxField = new CheckBoxFieldFactory(definition, baseItem, uiContext, i18NAuthoringSupport); checkBoxField.setComponentProvider(componentProvider); definition.setDefaultValue("true"); // WHEN Field<Boolean> field = checkBoxField.createField(); // THEN assertEquals(true, field.getPropertyDataSource().getValue()); }