IndentOptionsEditor () { return new SmartIndentOptionsEditor() { private JLabel myLabelIndentLabel; private IntegerField myLabelIndent; private JBLabel myStyleLabel; private JComboBox<LabelIndentStyle> myLabelIndentStyle; @Override protected void addComponents() { super.addComponents(); myLabelIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.label.indent")); myLabelIndent = new IntegerField(GroovyBundle.message("settings.code.style.label.indent.size"), 0, Integer.MAX_VALUE); add(myLabelIndentLabel, myLabelIndent); myStyleLabel = new JBLabel(GroovyBundle.message("settings.code.style.label.indent.style")); myLabelIndentStyle = new ComboBox<>(new EnumComboBoxModel<>(LabelIndentStyle.class)); add(myStyleLabel, myLabelIndentStyle); } @Override public boolean isModified(final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions options) { return super.isModified(settings, options) || myLabelIndent.getValue() != options.LABEL_INDENT_SIZE || isLabelStyleModified( options.LABEL_INDENT_ABSOLUTE, settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS ); } private boolean isLabelStyleModified(boolean absolute, boolean relative) { Object selectedStyle = myLabelIndentStyle.getSelectedItem(); if (absolute) { return selectedStyle != LabelIndentStyle.ABSOLUTE; } else if (relative) { return selectedStyle != LabelIndentStyle.RELATIVE; } else { return selectedStyle != LabelIndentStyle.RELATIVE_REVERSED; } } @Override public void apply(final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions options) { super.apply(settings, options); options.LABEL_INDENT_SIZE = myLabelIndent.getValue(); LabelIndentStyle labelIndentStyle = (LabelIndentStyle)myLabelIndentStyle.getSelectedItem(); options.LABEL_INDENT_ABSOLUTE = labelIndentStyle == LabelIndentStyle.ABSOLUTE; settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS = labelIndentStyle == LabelIndentStyle.RELATIVE; } @Override public void reset(@NotNull final CodeStyleSettings settings, @NotNull final CommonCodeStyleSettings.IndentOptions options) { super.reset(settings, options); myLabelIndent.setValue(options.LABEL_INDENT_SIZE); if (options.LABEL_INDENT_ABSOLUTE) { myLabelIndentStyle.setSelectedItem(LabelIndentStyle.ABSOLUTE); } else if (settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS) { myLabelIndentStyle.setSelectedItem(LabelIndentStyle.RELATIVE); } else { myLabelIndentStyle.setSelectedItem(LabelIndentStyle.RELATIVE_REVERSED); } } @Override public void setEnabled(final boolean enabled) { super.setEnabled(enabled); myLabelIndent.setEnabled(enabled); myLabelIndentLabel.setEnabled(enabled); myStyleLabel.setEnabled(enabled); myLabelIndentStyle.setEnabled(enabled); } }; }