/*------------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved.
------------------------------------------------------------------------------------*/

package com.togethersoft.modules.xmleditor.xmlcomponent;

import java.util.*;
import javax.swing.*;

import com.togethersoft.modules.xmleditor.dtd.*;
import com.togethersoft.modules.xmleditor.xmltree.*;

import java.beans.PropertyEditor;
import com.togethersoft.openapi.ide.inspector.IdeInspectorProperty;
import com.togethersoft.openapi.ide.inspector.util.editors.SwingComboBoxEditor;


public class ValueInspectorProperty extends IdeInspectorProperty
{
  private ValueHolder m_valueHolder;

  //--------------------------------------------------------------------
  public ValueInspectorProperty (ValueHolder valueHolder)
  {
    super (valueHolder.getTypeClass());
    m_valueHolder = valueHolder;

    setName (valueHolder.getDisplayName());

    PropertyEditor propertyEditor = m_valueHolder.getEditor();
    if (propertyEditor != null)
      setPropertyEditor (propertyEditor);
  }

  //--------------------------------------------------------------------
  public Object getValue()
  {
    return m_valueHolder.getValueObject();
  }

  //--------------------------------------------------------------------
  public void setValue (Object value)
  {
    m_valueHolder.setValueObject (value);
  }

  //--------------------------------------------------------------------
  public boolean canSetValue (Object value)
  {
    return true;
  }

  //--------------------------------------------------------------------
  public boolean isReadable() { return true; }
  //--------------------------------------------------------------------
  public boolean isWritable()
  {
    return ! m_valueHolder.hasReadonlyValue();
  }

  //--------------------------------------------------------------------
}
