@SuppressWarnings("unchecked") private void setType(DataType newType) { if (valueEditor == null || !newType.xml.equals(data.type)) { data.type = newType.xml; if (!newType.javaType.isInstance(data.value)) data.value = newType.decode(""); valueEditorWrapper.removeAll(); if (valueEditor != null) valueEditor.dispose(); JComponent editor = null; valueEditor = newType.createEditor(noExtras, PropertiesSheetStyle.DARK); valueEditor.setValue(data.value); valueEditor.addListener( new UpdateListener() { @Override public void updated() { data.value = valueEditor.getValue(); DynamicEditor.this.updated(); } }); editor = Layout.horizontalBox(style.fieldDimension, valueEditor.getComponents()); valueEditorWrapper.add(editor, BorderLayout.CENTER); valueEditorWrapper.revalidate(); } }
@Override public void dispose() { super.dispose(); typeChooser.dispose(); valueEditorWrapper.removeAll(); if (valueEditor != null) valueEditor.dispose(); data = null; typeChooser = null; valueEditorWrapper = null; valueEditor = null; style = null; }
@Override public void applyToFieldPanel(StructureFieldPanel panel) { int expansion = panel.getExtraPropertiesExpansion(); final Extras e = (Extras) panel.getExtras(); // === Default Value final DataEditor<Dynamic> defaultField = new DynamicEditor(panel.style); defaultField.setValue(e.defaultValue); defaultField.addListener( new UpdateListener() { @Override public void updated() { e.defaultValue = defaultField.getValue(); } }); panel.addGenericRow(expansion, "Default", defaultField); }