예제 #1
0
    @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();
      }
    }
예제 #2
0
    @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;
    }
예제 #3
0
  @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);
  }