use of com.intellij.ui.FieldPanel in project intellij-community by JetBrains.
the class HtmlUnknownTagInspection method createOptionsPanel.
@NotNull
protected static JComponent createOptionsPanel(@NotNull final HtmlUnknownElementInspection inspection) {
final JPanel result = new JPanel(new BorderLayout());
final JPanel internalPanel = new JPanel(new BorderLayout());
result.add(internalPanel, BorderLayout.NORTH);
final Ref<FieldPanel> panelRef = new Ref<>();
final FieldPanel additionalAttributesPanel = new FieldPanel(null, null, new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
Messages.showTextAreaDialog(panelRef.get().getTextField(), StringUtil.wordsToBeginFromUpperCase(inspection.getPanelTitle()), inspection.getClass().getSimpleName(), s -> reparseProperties(s), strings -> StringUtil.join(strings, ","));
}
}, null);
((JButton) additionalAttributesPanel.getComponent(1)).setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
panelRef.set(additionalAttributesPanel);
additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
final Document document = e.getDocument();
try {
final String text = document.getText(0, document.getLength());
if (text != null) {
inspection.updateAdditionalEntries(text.trim());
}
} catch (BadLocationException e1) {
inspection.getLogger().error(e1);
}
}
});
final JCheckBox checkBox = new JCheckBox(inspection.getCheckboxTitle());
checkBox.setSelected(inspection.isCustomValuesEnabled());
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean b = checkBox.isSelected();
if (b != inspection.isCustomValuesEnabled()) {
inspection.enableCustomValues(b);
additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
}
}
});
internalPanel.add(checkBox, BorderLayout.NORTH);
internalPanel.add(additionalAttributesPanel, BorderLayout.CENTER);
additionalAttributesPanel.setPreferredSize(new Dimension(150, additionalAttributesPanel.getPreferredSize().height));
additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
additionalAttributesPanel.setText(inspection.getAdditionalEntries());
return result;
}
Aggregations