/** * 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 Object generateCell(Table source, Object itemId, Object columnId) { final ZoneId userTimeZoneId = UserTimeZoneExtractor.extractUserTimeZoneIdOrNull(source.getUI()); final Property property = source.getContainerProperty(itemId, columnId); if (property == null || property.getValue() == null) { return null; } String formattedValue; if(property.getType().equals(Instant.class)){ formattedValue = timeformatService.format((Instant) property.getValue(), userTimeZoneId); } else if(property.getType().equals(Date.class)){ formattedValue = timeformatService.format((Date) property.getValue(), userTimeZoneId); } else { formattedValue = property.toString(); } return formattedValue; } }
@Override public void setValue(T newValue) throws ReadOnlyException { // Causes a value change to be sent to this listener which in turn fires // a new value change event for this property wrappedProperty.setValue(newValue); }
@Override public Class getType() { return wrappedProperty.getType(); }
/** Reflects the read-only status of the datasource. */ @Override public boolean isReadOnly() { return dataSource == null ? false : dataSource.isReadOnly(); }
/** * Sets the Property's read-only mode to the specified status. * * @param newStatus * the new read-only status of the Property. */ @Override public void setReadOnly(boolean newStatus) { if (dataSource != null) { dataSource.setReadOnly(newStatus); } }
@Override public void setScale(double scale) { m_scaleProperty.setValue(scale); }
@Override public Class getType() { return itemProperty.getType(); }
@Override public boolean isReadOnly() { return wrappedProperty.isReadOnly(); }
/** * Sets the Property's read-only mode to the specified status. * * This functionality is optional, but all properties must implement the * <code>isReadOnly</code> mode query correctly. * * @param newStatus new read-only status of the Property * @return this (for method chaining) * @see #setReadOnly(boolean) */ public default S withReadOnly(boolean newStatus) { ((Property) this).setReadOnly(newStatus); return (S) this; }
@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); } });
@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")); } }
@Override public void setItemProperties(Item item, Object itemId) { item.getItemProperty(MBeansTree.MetaMBeansTreeItem.ICON).setValue(Config.Icons.DUMMY); item.getItemProperty(MBeansTree.MetaMBeansTreeItem.CAPTION).setValue(((Map.Entry) itemId).getValue()); item.getItemProperty(MBeansTree.MetaMBeansTreeItem.TOOLTIP).setValue(((Map.Entry) itemId).getValue()); } }
/** * Constructs a new <code>DateField</code> that's bound to the specified * <code>Property</code> and has no caption. * * @param dataSource * the Property to be edited with this editor. */ public DateField(Property dataSource) throws IllegalArgumentException { if (!Date.class.isAssignableFrom(dataSource.getType())) { throw new IllegalArgumentException( "Can't use " + dataSource.getType().getName() + " typed property as datasource"); } setPropertyDataSource(dataSource); }
@Override public boolean isReadOnly() { return itemProperty.isReadOnly(); }
@Override public void setReadOnly(boolean newStatus) { itemProperty.setReadOnly(newStatus); }
@Override public void valueChange(ValueChangeEvent event) { if (Boolean.TRUE.equals(event.getProperty().getValue())) { m_selectedCheckboxes.add(property.getValue()); m_notSelectedCheckboxes.remove(property.getValue()); } else { m_selectedCheckboxes.remove(property.getValue()); m_notSelectedCheckboxes.add(property.getValue()); } } });
@Test public void testGetItemPropertyWithBooleanPropertyFromJcr() throws Exception { // GIVEN // Create a NewNodeAdapter String nodeName = "rootNode"; String id = "propertyID"; Boolean value = Boolean.TRUE; Node parentNode = session.getRootNode().addNode(nodeName); // Create the JCR property parentNode.setProperty(id, value); session.save(); JcrNodeAdapter adapter = new JcrNodeAdapter(parentNode); // WHEN Property property = adapter.getItemProperty(id); // THEN assertEquals(PropertyType.nameFromValue(PropertyType.BOOLEAN), property.getType().getSimpleName()); assertEquals(value, property.getValue()); }