mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IntegerField for Java label indent setting
This commit is contained in:
@@ -19,15 +19,21 @@ import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.ui.components.fields.IntegerField;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.intellij.psi.codeStyle.CodeStyleConstraints.MAX_INDENT_SIZE;
|
||||
import static com.intellij.psi.codeStyle.CodeStyleConstraints.MIN_INDENT_SIZE;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaIndentOptionsEditor extends SmartIndentOptionsEditor {
|
||||
private JTextField myLabelIndent;
|
||||
private static final String LABEL_INDENT_LABEL = ApplicationBundle.message("editbox.indent.label.indent");
|
||||
|
||||
private IntegerField myLabelIndent;
|
||||
private JLabel myLabelIndentLabel;
|
||||
|
||||
private JCheckBox myLabelIndentAbsolute;
|
||||
@@ -37,8 +43,9 @@ public class JavaIndentOptionsEditor extends SmartIndentOptionsEditor {
|
||||
protected void addComponents() {
|
||||
super.addComponents();
|
||||
|
||||
myLabelIndent = new JTextField(4);
|
||||
add(myLabelIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.label.indent")), myLabelIndent);
|
||||
myLabelIndent = new IntegerField(LABEL_INDENT_LABEL, MIN_INDENT_SIZE, MAX_INDENT_SIZE);
|
||||
myLabelIndent.setColumns(4);
|
||||
add(myLabelIndentLabel = new JLabel(LABEL_INDENT_LABEL), myLabelIndent);
|
||||
|
||||
myLabelIndentAbsolute = new JCheckBox(ApplicationBundle.message("checkbox.indent.absolute.label.indent"));
|
||||
add(myLabelIndentAbsolute, true);
|
||||
@@ -64,7 +71,7 @@ public class JavaIndentOptionsEditor extends SmartIndentOptionsEditor {
|
||||
|
||||
public void apply(final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions options) {
|
||||
super.apply(settings, options);
|
||||
options.LABEL_INDENT_SIZE = getFieldValue(myLabelIndent, Integer.MIN_VALUE, options.LABEL_INDENT_SIZE);
|
||||
options.LABEL_INDENT_SIZE = myLabelIndent.getValue();
|
||||
|
||||
options.LABEL_INDENT_ABSOLUTE = myLabelIndentAbsolute.isSelected();
|
||||
CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
@@ -74,7 +81,7 @@ public class JavaIndentOptionsEditor extends SmartIndentOptionsEditor {
|
||||
|
||||
public void reset(@NotNull final CodeStyleSettings settings, @NotNull final CommonCodeStyleSettings.IndentOptions options) {
|
||||
super.reset(settings, options);
|
||||
myLabelIndent.setText(Integer.toString(options.LABEL_INDENT_SIZE));
|
||||
myLabelIndent.setValue(options.LABEL_INDENT_SIZE);
|
||||
myLabelIndentAbsolute.setSelected(options.LABEL_INDENT_ABSOLUTE);
|
||||
CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
myCbDontIndentTopLevelMembers.setSelected(javaSettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS);
|
||||
|
||||
Reference in New Issue
Block a user