update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / application / options / JavaIndentOptionsEditor.java
blobdb274ab1e3154fb2ab32c94579bf043196f2a7d9
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.application.options;
18 import com.intellij.openapi.application.ApplicationBundle;
19 import com.intellij.psi.codeStyle.CodeStyleSettings;
21 import javax.swing.*;
23 /**
24 * @author yole
26 public class JavaIndentOptionsEditor extends SmartIndentOptionsEditor {
27 private JTextField myLabelIndent;
28 private JLabel myLabelIndentLabel;
30 private JCheckBox myLabelIndentAbsolute;
31 private JCheckBox myCbDontIndentTopLevelMembers;
33 protected void addComponents() {
34 super.addComponents();
36 myLabelIndent = new JTextField(4);
37 add(myLabelIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.label.indent")), myLabelIndent);
39 myLabelIndentAbsolute = new JCheckBox(ApplicationBundle.message("checkbox.indent.absolute.label.indent"));
40 add(myLabelIndentAbsolute, true);
42 myCbDontIndentTopLevelMembers = new JCheckBox(ApplicationBundle.message("checkbox.do.not.indent.top.level.class.members"));
43 add(myCbDontIndentTopLevelMembers);
46 public boolean isModified(final CodeStyleSettings settings, final CodeStyleSettings.IndentOptions options) {
47 boolean isModified = super.isModified(settings, options);
49 isModified |= isFieldModified(myLabelIndent, options.LABEL_INDENT_SIZE);
50 isModified |= isFieldModified(myLabelIndentAbsolute, options.LABEL_INDENT_ABSOLUTE);
51 isModified |= isFieldModified(myCbDontIndentTopLevelMembers, settings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS);
53 return isModified;
56 public void apply(final CodeStyleSettings settings, final CodeStyleSettings.IndentOptions options) {
57 super.apply(settings, options);
58 try {
59 options.LABEL_INDENT_SIZE = Integer.parseInt(myLabelIndent.getText());
61 catch (NumberFormatException e) {
62 //stay with default
64 options.LABEL_INDENT_ABSOLUTE = myLabelIndentAbsolute.isSelected();
65 settings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = myCbDontIndentTopLevelMembers.isSelected();
68 public void reset(final CodeStyleSettings settings, final CodeStyleSettings.IndentOptions options) {
69 super.reset(settings, options);
70 myLabelIndent.setText(Integer.toString(options.LABEL_INDENT_SIZE));
71 myLabelIndentAbsolute.setSelected(options.LABEL_INDENT_ABSOLUTE);
72 myCbDontIndentTopLevelMembers.setSelected(settings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS);
75 public void setEnabled(final boolean enabled) {
76 super.setEnabled(enabled);
77 myLabelIndent.setEnabled(enabled);
78 myLabelIndentLabel.setEnabled(enabled);
79 myLabelIndentAbsolute.setEnabled(enabled);