mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Commenter form
This commit is contained in:
+3
-32
@@ -182,7 +182,7 @@
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="5a70" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="5a70" binding="myCommenterPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -191,37 +191,8 @@
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ApplicationBundle" title-key="title.naming.comment.code"/>
|
||||
<children>
|
||||
<component id="da6e1" class="javax.swing.JCheckBox" binding="myCbLineCommentAtFirstColumn">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label resource-bundle="messages/ApplicationBundle" key="checkbox.line.comment.at.first.column"/>
|
||||
<margin top="5" left="10" bottom="2" right="2"/>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.line.comment.at.first.column"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="841a8" class="javax.swing.JCheckBox" binding="myCbBlockCommentAtFirstColumn">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label resource-bundle="messages/ApplicationBundle" key="checkbox.block.comment.at.first.column"/>
|
||||
<margin top="2" left="10" bottom="2" right="2"/>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.block.comment.at.first.column"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4d5fe" class="javax.swing.JCheckBox" binding="myCbPrependWithSpace">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.line.comment.add.space"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="83565" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
|
||||
+15
-34
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.application.options.codeStyle.CommenterForm;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
@@ -24,7 +25,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.JavaVisibilityPanel;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
@@ -33,8 +33,6 @@ import com.intellij.ui.components.JBList;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,10 +50,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
private JTextField myLocalVariableSuffixField;
|
||||
|
||||
private JCheckBox myCbPreferLongerNames;
|
||||
private JCheckBox myCbLineCommentAtFirstColumn;
|
||||
private JCheckBox myCbBlockCommentAtFirstColumn;
|
||||
private JCheckBox myCbPrependWithSpace;
|
||||
|
||||
private final MembersOrderList myMembersOrderList;
|
||||
|
||||
private final CodeStyleSettings mySettings;
|
||||
@@ -66,21 +60,15 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
private JPanel myMembersPanel;
|
||||
private JCheckBox myRepeatSynchronizedCheckBox;
|
||||
private JPanel myVisibilityPanel;
|
||||
|
||||
@SuppressWarnings("unused") private JPanel myCommenterPanel;
|
||||
private CommenterForm myCommenterForm;
|
||||
|
||||
public CodeStyleGenerationConfigurable(CodeStyleSettings settings) {
|
||||
mySettings = settings;
|
||||
myMembersOrderList = new MembersOrderList();
|
||||
myPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
myJavaVisibilityPanel = new JavaVisibilityPanel(false, true, RefactoringBundle.message("default.visibility.border.title"));
|
||||
myCbLineCommentAtFirstColumn.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myCbLineCommentAtFirstColumn.isSelected()) {
|
||||
myCbPrependWithSpace.setSelected(false);
|
||||
}
|
||||
myCbPrependWithSpace.setEnabled(!myCbLineCommentAtFirstColumn.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
@@ -224,7 +212,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
}*/
|
||||
|
||||
public void reset(CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings javaCommonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
myCbPreferLongerNames.setSelected(settings.PREFER_LONGER_NAMES);
|
||||
|
||||
myFieldPrefixField.setText(settings.FIELD_NAME_PREFIX);
|
||||
@@ -237,11 +224,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
myParameterSuffixField.setText(settings.PARAMETER_NAME_SUFFIX);
|
||||
myLocalVariableSuffixField.setText(settings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
|
||||
myCbLineCommentAtFirstColumn.setSelected(javaCommonSettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbBlockCommentAtFirstColumn.setSelected(javaCommonSettings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbPrependWithSpace.setSelected(javaCommonSettings.LINE_COMMENT_ADD_SPACE && !javaCommonSettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbPrependWithSpace.setEnabled(!javaCommonSettings .LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
|
||||
myCbGenerateFinalLocals.setSelected(settings.GENERATE_FINAL_LOCALS);
|
||||
myCbGenerateFinalParameters.setSelected(settings.GENERATE_FINAL_PARAMETERS);
|
||||
myMembersOrderList.reset(mySettings);
|
||||
@@ -250,6 +232,8 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
myInsertOverrideAnnotationCheckBox.setSelected(settings.INSERT_OVERRIDE_ANNOTATION);
|
||||
myRepeatSynchronizedCheckBox.setSelected(settings.REPEAT_SYNCHRONIZED);
|
||||
myJavaVisibilityPanel.setVisibility(settings.VISIBILITY);
|
||||
|
||||
myCommenterForm.reset(settings);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
@@ -257,7 +241,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
}
|
||||
|
||||
public void apply(CodeStyleSettings settings) throws ConfigurationException {
|
||||
CommonCodeStyleSettings javaCommonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
settings.PREFER_LONGER_NAMES = myCbPreferLongerNames.isSelected();
|
||||
|
||||
settings.FIELD_NAME_PREFIX = setPrefixSuffix(myFieldPrefixField.getText(), true);
|
||||
@@ -270,10 +253,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
settings.PARAMETER_NAME_SUFFIX = setPrefixSuffix(myParameterSuffixField.getText(), false);
|
||||
settings.LOCAL_VARIABLE_NAME_SUFFIX = setPrefixSuffix(myLocalVariableSuffixField.getText(), false);
|
||||
|
||||
javaCommonSettings.LINE_COMMENT_AT_FIRST_COLUMN = myCbLineCommentAtFirstColumn.isSelected();
|
||||
javaCommonSettings.BLOCK_COMMENT_AT_FIRST_COLUMN = myCbBlockCommentAtFirstColumn.isSelected();
|
||||
javaCommonSettings.LINE_COMMENT_ADD_SPACE = myCbPrependWithSpace.isSelected();
|
||||
|
||||
settings.GENERATE_FINAL_LOCALS = myCbGenerateFinalLocals.isSelected();
|
||||
settings.GENERATE_FINAL_PARAMETERS = myCbGenerateFinalParameters.isSelected();
|
||||
|
||||
@@ -284,6 +263,8 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
settings.VISIBILITY = myJavaVisibilityPanel.getVisibility();
|
||||
|
||||
myMembersOrderList.apply(settings);
|
||||
|
||||
myCommenterForm.apply(settings);
|
||||
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
DaemonCodeAnalyzer.getInstance(project).settingsChanged();
|
||||
@@ -304,8 +285,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
}
|
||||
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings javaCommonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
|
||||
boolean isModified = isModified(myCbPreferLongerNames, settings.PREFER_LONGER_NAMES);
|
||||
|
||||
isModified |= isModified(myFieldPrefixField, settings.FIELD_NAME_PREFIX);
|
||||
@@ -318,11 +297,6 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
isModified |= isModified(myParameterSuffixField, settings.PARAMETER_NAME_SUFFIX);
|
||||
isModified |= isModified(myLocalVariableSuffixField, settings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
|
||||
isModified |= isModified(myCbLineCommentAtFirstColumn, javaCommonSettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
isModified |= isModified(myCbBlockCommentAtFirstColumn, javaCommonSettings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
isModified |= isModified(myCbPrependWithSpace, javaCommonSettings.LINE_COMMENT_ADD_SPACE);
|
||||
|
||||
|
||||
isModified |= isModified(myCbGenerateFinalLocals, settings.GENERATE_FINAL_LOCALS);
|
||||
isModified |= isModified(myCbGenerateFinalParameters, settings.GENERATE_FINAL_PARAMETERS);
|
||||
|
||||
@@ -332,6 +306,8 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
|
||||
isModified |= myMembersOrderList.isModified(settings);
|
||||
isModified |= !settings.VISIBILITY.equals(myJavaVisibilityPanel.getVisibility());
|
||||
|
||||
isModified |= myCommenterForm.isModified(settings);
|
||||
|
||||
return isModified;
|
||||
}
|
||||
@@ -348,6 +324,11 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
return !textField.getText().trim().equals(value);
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myCommenterForm = new CommenterForm(JavaLanguage.INSTANCE);
|
||||
myCommenterPanel = myCommenterForm.getCommenterPanel();
|
||||
}
|
||||
|
||||
private static class MembersOrderList extends JBList {
|
||||
|
||||
private static abstract class PropertyManager {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.codeStyle.CommenterForm">
|
||||
<grid id="27dc6" binding="myCommenterPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none" title-resource-bundle="messages/ApplicationBundle" title-key="title.naming.comment.code"/>
|
||||
<children>
|
||||
<component id="e86e0" class="com.intellij.ui.components.JBCheckBox" binding="myLineCommentAtFirstColumnCb">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.line.comment.at.first.column"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="c2a8d">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="98a1c" class="com.intellij.ui.components.JBCheckBox" binding="myLineCommentAddSpaceCb">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.line.comment.add.space"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="35ede" class="com.intellij.ui.components.JBCheckBox" binding="myBlockCommentAtFirstJBCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.block.comment.at.first.column"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options.codeStyle;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Reusable commenter settings form.
|
||||
*/
|
||||
public class CommenterForm {
|
||||
private JPanel myCommenterPanel;
|
||||
private JBCheckBox myLineCommentAtFirstColumnCb;
|
||||
private JBCheckBox myLineCommentAddSpaceCb;
|
||||
private JBCheckBox myBlockCommentAtFirstJBCheckBox;
|
||||
|
||||
private final Language myLanguage;
|
||||
|
||||
public CommenterForm(Language language) {
|
||||
myLanguage = language;
|
||||
myCommenterPanel.setBorder(IdeBorderFactory.createTitledBorder(ApplicationBundle.message("title.naming.comment.code")));
|
||||
myLineCommentAtFirstColumnCb.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myLineCommentAtFirstColumnCb.isSelected()) {
|
||||
myLineCommentAddSpaceCb.setSelected(false);
|
||||
}
|
||||
myLineCommentAddSpaceCb.setEnabled(!myLineCommentAtFirstColumnCb.isSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reset(@NotNull CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage);
|
||||
myLineCommentAtFirstColumnCb.setSelected(langSettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myBlockCommentAtFirstJBCheckBox.setSelected(langSettings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
myLineCommentAddSpaceCb.setSelected(langSettings.LINE_COMMENT_ADD_SPACE && !langSettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myLineCommentAddSpaceCb.setEnabled(!langSettings .LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
}
|
||||
|
||||
|
||||
public void apply(@NotNull CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage);
|
||||
langSettings.LINE_COMMENT_AT_FIRST_COLUMN = myLineCommentAtFirstColumnCb.isSelected();
|
||||
langSettings.BLOCK_COMMENT_AT_FIRST_COLUMN = myBlockCommentAtFirstJBCheckBox.isSelected();
|
||||
langSettings.LINE_COMMENT_ADD_SPACE = myLineCommentAddSpaceCb.isSelected();
|
||||
}
|
||||
|
||||
public boolean isModified(@NotNull CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage);
|
||||
return myLineCommentAtFirstColumnCb.isSelected() != langSettings.LINE_COMMENT_AT_FIRST_COLUMN
|
||||
|| myBlockCommentAtFirstJBCheckBox.isSelected() != langSettings.BLOCK_COMMENT_AT_FIRST_COLUMN
|
||||
|| myLineCommentAddSpaceCb.isSelected() != langSettings.LINE_COMMENT_ADD_SPACE;
|
||||
}
|
||||
|
||||
public JPanel getCommenterPanel() {
|
||||
return myCommenterPanel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user