public ChangeListChooserPanel( final Project project, @NotNull final NullableConsumer<String> okEnabledListener) { super(new BorderLayout()); myProject = project; myOkEnabledListener = okEnabledListener; add(myPanel, BorderLayout.CENTER); myRbExisting.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEnabledItems(); } }); }
public JComponent createComponent() { if (myProject == null) { myProject = JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables(); } final JPanel panel = new JPanel(new GridBagLayout()); myRbDefaultLabel = new JRadioButton( DebuggerBundle.message("label.compound.renderer.configurable.use.default.renderer")); myRbExpressionLabel = new JRadioButton( DebuggerBundle.message("label.compound.renderer.configurable.use.expression")); final ButtonGroup labelButtonsGroup = new ButtonGroup(); labelButtonsGroup.add(myRbDefaultLabel); labelButtonsGroup.add(myRbExpressionLabel); myRbDefaultChildrenRenderer = new JRadioButton( DebuggerBundle.message("label.compound.renderer.configurable.use.default.renderer")); myRbExpressionChildrenRenderer = new JRadioButton( DebuggerBundle.message("label.compound.renderer.configurable.use.expression")); myRbListChildrenRenderer = new JRadioButton( DebuggerBundle.message("label.compound.renderer.configurable.use.expression.list")); final ButtonGroup childrenButtonGroup = new ButtonGroup(); childrenButtonGroup.add(myRbDefaultChildrenRenderer); childrenButtonGroup.add(myRbExpressionChildrenRenderer); childrenButtonGroup.add(myRbListChildrenRenderer); myLabelEditor = new DebuggerExpressionTextField(myProject, null, "ClassLabelExpression"); myChildrenEditor = new DebuggerExpressionTextField(myProject, null, "ClassChildrenExpression"); myChildrenExpandedEditor = new DebuggerExpressionTextField(myProject, null, "ClassChildrenExpression"); myChildrenListEditor = createChildrenListEditor(); final ItemListener updateListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEnabledState(); } }; myRbExpressionLabel.addItemListener(updateListener); myRbListChildrenRenderer.addItemListener(updateListener); myRbExpressionChildrenRenderer.addItemListener(updateListener); myClassNameField = new ClassNameEditorWithBrowseButton( new ActionListener() { public void actionPerformed(ActionEvent e) { PsiClass psiClass = DebuggerUtils.getInstance() .chooseClassDialog( DebuggerBundle.message( "title.compound.renderer.configurable.choose.renderer.reference.type"), myProject); if (psiClass != null) { String qName = JVMNameUtil.getNonAnonymousClassName(psiClass); myClassNameField.setText(qName); updateContext(qName); } } }, myProject); myClassNameField .getEditorTextField() .addFocusListener( new FocusAdapter() { public void focusLost(FocusEvent e) { final String qName = myClassNameField.getText(); updateContext(qName); } }); panel.add( new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.apply.to")), new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); panel.add( myClassNameField, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); panel.add( new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.when.rendering")), new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0)); panel.add( myRbDefaultLabel, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); panel.add( myRbExpressionLabel, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); panel.add( myLabelEditor, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0)); panel.add( new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.when.expanding")), new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0)); panel.add( myRbDefaultChildrenRenderer, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); panel.add( myRbExpressionChildrenRenderer, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); panel.add( myChildrenEditor, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0)); myExpandedLabel = new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.test.can.expand")); panel.add( myExpandedLabel, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 30, 0, 0), 0, 0)); panel.add( myChildrenExpandedEditor, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0)); panel.add( myRbListChildrenRenderer, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0)); panel.add( myChildrenListEditor, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(4, 30, 0, 0), 0, 0)); myMainPanel = new JPanel(new CardLayout()); myMainPanel.add(new JPanel(), EMPTY_PANEL_ID); myMainPanel.add(panel, DATA_PANEL_ID); return myMainPanel; }