@Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (getCurrentLayer() != null) { try { final Property layerProperty = getCurrentLayer().getConfiguration().getProperty(propertyName); if (layerProperty != null) { layerProperty.setValue(evt.getNewValue()); } } catch (ValidationException e) { throw new IllegalStateException(e.getMessage(), e); } } } }
@Override public JComponent createControl() { bindingContext = new BindingContext(); PropertySet propertySet = bindingContext.getPropertySet(); propertySet.addPropertyChangeListener(new PropertyChangeHandler()); addEditablePropertyDescriptors(); PropertyPane propertyPane = new PropertyPane(bindingContext); return propertyPane.createPanel(); }
@Override public void handleLayerContentChanged() { final Property[] editorProperties = bindingContext.getPropertySet().getProperties(); for (Property editorProperty : editorProperties) { final String propertyName = editorProperty.getDescriptor().getName(); final Property layerProperty = getCurrentLayer().getConfiguration().getProperty(propertyName); if (layerProperty != null) { final Binding binding = bindingContext.getBinding(propertyName); final Object layerValue = layerProperty.getValue(); final Object editorValue = binding.getPropertyValue(); if (editorValue != layerValue && (editorValue == null || !editorValue.equals(layerValue))) { binding.setPropertyValue(layerValue); } } } }
/** * Defines an editable property. * * @param propertyDescriptor The property's descriptor. */ protected final void addPropertyDescriptor(PropertyDescriptor propertyDescriptor) { String propertyName = propertyDescriptor.getName(); Object value = getCurrentLayer().getConfiguration().getValue(propertyName); if (value == null) { value = propertyDescriptor.getDefaultValue(); } Property editorProperty = new Property(propertyDescriptor, new DefaultPropertyAccessor(value)); bindingContext.getPropertySet().addProperty(editorProperty); }