@NotNull
  @Override
  public JComponent getComponent(
      @Nullable PropertiesContainer container,
      @Nullable PropertyContext context,
      Object object,
      @Nullable InplaceContext inplaceContext) {
    myComponent = (RadComponent) container;
    myRootComponent =
        context instanceof RadPropertyContext
            ? ((RadPropertyContext) context).getRootComponent()
            : null;

    String value = (String) object;
    JTextField text = getComboText();

    if (text == null) {
      if (StringUtil.isEmpty(value) || value.equals("true") || value.equals("false")) {
        myBooleanResourceValue = null;
      } else {
        myBooleanResourceValue = value;
      }

      try {
        myIgnoreCheckBoxValue = true;
        myCheckBox.setSelected(Boolean.parseBoolean(value));
      } finally {
        myIgnoreCheckBoxValue = false;
      }

      if (inplaceContext == null) {
        myEditor.setBorder(null);
        myCheckBox.setText(null);
      } else {
        myEditor.setBorder(myCheckBoxBorder);
        myCheckBox.setText(myBooleanResourceValue);
      }
    } else {
      text.setText(value);
      if (inplaceContext != null) {
        text.setColumns(0);
        if (inplaceContext.isStartChar()) {
          text.setText(inplaceContext.getText(text.getText()));
        }
      }
    }
    return myEditor;
  }
 private JTextField getComboText() {
   JComponent component = myEditor.getChildComponent();
   if (component instanceof JTextField) {
     return (JTextField) component;
   }
   if (component instanceof JComboBox) {
     JComboBox combo = (JComboBox) component;
     return (JTextField) combo.getEditor().getEditorComponent();
   }
   return null;
 }
  public ResourceEditor(
      @Nullable ResourceType[] types, Set<AttributeFormat> formats, @Nullable String[] values) {
    myTypes = types;
    myIsDimension = formats.contains(AttributeFormat.Dimension);

    if (formats.contains(AttributeFormat.Boolean)) {
      myCheckBox = new JCheckBox();
      myEditor =
          new ComponentWithBrowseButton<JCheckBox>(myCheckBox, null) {
            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };
      myCheckBox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              if (!myIgnoreCheckBoxValue) {
                myBooleanResourceValue = null;
                fireValueCommitted(false, true);
              }
            }
          });
    } else if (formats.contains(AttributeFormat.Enum)) {
      ComboboxWithBrowseButton editor =
          new ComboboxWithBrowseButton(SystemInfo.isWindows ? new MyComboBox() : new JComboBox()) {
            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };

      final JComboBox comboBox = editor.getComboBox();
      DefaultComboBoxModel model = new DefaultComboBoxModel(values);
      model.insertElementAt(StringsComboEditor.UNSET, 0);
      comboBox.setModel(model);
      comboBox.setEditable(true);
      ComboEditor.installListeners(
          comboBox,
          new ComboEditor.ComboEditorListener(this) {
            @Override
            protected void onValueChosen() {
              if (comboBox.getSelectedItem() == StringsComboEditor.UNSET) {
                comboBox.setSelectedItem(null);
              }
              super.onValueChosen();
            }
          });
      myEditor = editor;
      comboBox.setSelectedIndex(0);
    } else {
      myEditor =
          new TextFieldWithBrowseButton() {
            @Override
            protected void installPathCompletion(
                FileChooserDescriptor fileChooserDescriptor, @Nullable Disposable parent) {}

            @Override
            public Dimension getPreferredSize() {
              return getComponentPreferredSize();
            }
          };
      myEditor.registerKeyboardAction(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {}
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
          JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

      JTextField textField = getComboText();
      textField.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              fireValueCommitted(false, true);
            }
          });
      textField
          .getDocument()
          .addDocumentListener(
              new DocumentAdapter() {
                @Override
                protected void textChanged(final DocumentEvent e) {
                  preferredSizeChanged();
                }
              });
      selectTextOnFocusGain(textField);
    }

    if (myCheckBox == null) {
      myEditor.registerKeyboardAction(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {}
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
          JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

    myEditor.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showDialog();
          }
        });
    myEditor.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            myEditor.getChildComponent().requestFocus();
          }
        });
  }
 private Dimension getComponentPreferredSize() {
   Dimension size1 = myEditor.getChildComponent().getPreferredSize();
   Dimension size2 = myEditor.getButton().getPreferredSize();
   return new Dimension(Math.max(size1.width, 25) + 5 + size2.width, size1.height);
 }