mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
UnusedDeclarationInspection ui
This commit is contained in:
@@ -369,7 +369,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
QuickFixAction.registerQuickFixAction(info, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field), null);
|
||||
SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(field, new Processor<String>() {
|
||||
public boolean process(final String annoName) {
|
||||
QuickFixAction.registerQuickFixAction(info, myUnusedSymbolInspection.createQuickFix(annoName, field));
|
||||
QuickFixAction.registerQuickFixAction(info, myUnusedSymbolInspection.createQuickFix(annoName, "fields"));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -377,7 +377,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
}
|
||||
else if (!myRefCountHolder.isReferenced(field) && weAreSureThereAreNoUsages(field)) {
|
||||
return formatUnusedSymbolHighlightInfo("field.is.not.used", field);
|
||||
return formatUnusedSymbolHighlightInfo("field.is.not.used", field, "fields");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -471,14 +471,12 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
PsiIdentifier identifier = method.getNameIdentifier();
|
||||
final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(method), myUnusedSymbolKey);
|
||||
if (PropertyUtil.isSimplePropertySetter(method)) {
|
||||
SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(method, new Processor<String>() {
|
||||
public boolean process(final String annoName) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, myUnusedSymbolInspection.createQuickFix(annoName, method));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes(method, new Processor<String>() {
|
||||
public boolean process(final String annoName) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, myUnusedSymbolInspection.createQuickFix(annoName, "methods"));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
@@ -529,19 +527,20 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
@Nullable
|
||||
private HighlightInfo processClass(PsiClass aClass) {
|
||||
if (!isClassUnused(aClass)) return null;
|
||||
String element = "classes";
|
||||
if (aClass.getContainingClass() != null && aClass.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
String pattern = aClass.isInterface()
|
||||
? "private.inner.interface.is.not.used"
|
||||
: "private.inner.class.is.not.used";
|
||||
return formatUnusedSymbolHighlightInfo(pattern, aClass);
|
||||
return formatUnusedSymbolHighlightInfo(pattern, aClass, element);
|
||||
}
|
||||
if (aClass.getParent() instanceof PsiDeclarationStatement) { // local class
|
||||
return formatUnusedSymbolHighlightInfo("local.class.is.not.used", aClass);
|
||||
return formatUnusedSymbolHighlightInfo("local.class.is.not.used", aClass, element);
|
||||
}
|
||||
if (aClass instanceof PsiTypeParameter) {
|
||||
return formatUnusedSymbolHighlightInfo("type.parameter.is.not.used", aClass);
|
||||
return formatUnusedSymbolHighlightInfo("type.parameter.is.not.used", aClass, element);
|
||||
}
|
||||
return formatUnusedSymbolHighlightInfo("class.is.not.used", aClass);
|
||||
return formatUnusedSymbolHighlightInfo("class.is.not.used", aClass, element);
|
||||
}
|
||||
|
||||
private final Map<PsiClass, Boolean> unusedClassCache = new THashMap<PsiClass, Boolean>();
|
||||
@@ -564,12 +563,18 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
private HighlightInfo formatUnusedSymbolHighlightInfo(@PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String pattern,
|
||||
PsiNameIdentifierOwner aClass) {
|
||||
PsiNameIdentifierOwner aClass, final String element) {
|
||||
String symbolName = aClass.getName();
|
||||
String message = JavaErrorMessages.message(pattern, symbolName);
|
||||
PsiElement identifier = aClass.getNameIdentifier();
|
||||
HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
|
||||
final HighlightInfo highlightInfo = createUnusedSymbolInfo(identifier, message);
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(aClass), myUnusedSymbolKey);
|
||||
SpecialAnnotationsUtil.createAddToSpecialAnnotationFixes((PsiModifierListOwner)aClass, new Processor<String>() {
|
||||
public boolean process(final String annoName) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, myUnusedSymbolInspection.createQuickFix(annoName, element));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection.OptionsPanel">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" 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="618" height="400"/>
|
||||
<xy x="20" y="20" width="394" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="b6cc3" class="javax.swing.JCheckBox" binding="myCheckLocalVariablesCheckBox" default-binding="true">
|
||||
<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"/>
|
||||
<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">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.localvars"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="36ace">
|
||||
<constraints>
|
||||
<grid row="7" 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="bcd0d" class="javax.swing.JCheckBox" binding="myCheckClassesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" 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>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.classes"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b2b9f" class="javax.swing.JCheckBox" binding="myCheckFieldsCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" 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>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.fields"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6664b" class="javax.swing.JCheckBox" binding="myCheckParametersCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<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">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.parameters"/>
|
||||
@@ -47,7 +30,9 @@
|
||||
</component>
|
||||
<component id="c49dc" class="javax.swing.JCheckBox" binding="myCheckMethodsCheckBox" default-binding="true">
|
||||
<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"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.methods"/>
|
||||
@@ -55,7 +40,7 @@
|
||||
</component>
|
||||
<component id="2077d" class="javax.swing.JCheckBox" binding="myReportUnusedParametersInPublics" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.public.method.parameters"/>
|
||||
@@ -63,12 +48,28 @@
|
||||
</component>
|
||||
<grid id="a47a5" binding="myAnnos" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="b2b9f" class="javax.swing.JCheckBox" binding="myCheckFieldsCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.fields"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bcd0d" class="javax.swing.JCheckBox" binding="myCheckClassesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.classes"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+14
-8
@@ -11,16 +11,15 @@ import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.deadCode.UnusedCodeExtension;
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.JDOMExternalizableStringList;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -74,6 +73,7 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
return SHORT_NAME;
|
||||
}
|
||||
|
||||
@Pattern("[a-zA-Z_0-9.]+")
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getID() {
|
||||
@@ -100,20 +100,26 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
private JPanel myPanel;
|
||||
|
||||
public OptionsPanel() {
|
||||
|
||||
myCheckLocalVariablesCheckBox.setSelected(LOCAL_VARIABLE);
|
||||
myCheckClassesCheckBox.setSelected(CLASS);
|
||||
myCheckFieldsCheckBox.setSelected(FIELD);
|
||||
myCheckMethodsCheckBox.setSelected(METHOD);
|
||||
|
||||
myCheckParametersCheckBox.setSelected(PARAMETER);
|
||||
myReportUnusedParametersInPublics.setSelected(REPORT_PARAMETER_FOR_PUBLIC_METHODS);
|
||||
myReportUnusedParametersInPublics.setEnabled(PARAMETER);
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOCAL_VARIABLE = myCheckLocalVariablesCheckBox.isSelected();
|
||||
CLASS = myCheckClassesCheckBox.isSelected();
|
||||
FIELD = myCheckFieldsCheckBox.isSelected();
|
||||
PARAMETER = myCheckParametersCheckBox.isSelected();
|
||||
METHOD = myCheckMethodsCheckBox.isSelected();
|
||||
REPORT_PARAMETER_FOR_PUBLIC_METHODS = myReportUnusedParametersInPublics.isSelected();
|
||||
|
||||
PARAMETER = myCheckParametersCheckBox.isSelected();
|
||||
REPORT_PARAMETER_FOR_PUBLIC_METHODS = PARAMETER && myReportUnusedParametersInPublics.isSelected();
|
||||
myReportUnusedParametersInPublics.setEnabled(PARAMETER);
|
||||
}
|
||||
};
|
||||
myCheckLocalVariablesCheckBox.addActionListener(listener);
|
||||
@@ -123,7 +129,7 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
myCheckParametersCheckBox.addActionListener(listener);
|
||||
myReportUnusedParametersInPublics.addActionListener(listener);
|
||||
|
||||
String title = InspectionsBundle.message("dependency.injection.annotations.list");
|
||||
String title = "Do not check if annotated by";
|
||||
final JPanel listPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(INJECTION_ANNOS, title);
|
||||
|
||||
myAnnos.add(listPanel, BorderLayout.CENTER);
|
||||
@@ -139,11 +145,11 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
return new OptionsPanel().getPanel();
|
||||
}
|
||||
|
||||
public IntentionAction createQuickFix(final String qualifiedName, final PsiElement context) {
|
||||
public IntentionAction createQuickFix(final String qualifiedName, String element) {
|
||||
return SpecialAnnotationsUtil.createAddToSpecialAnnotationsListIntentionAction(
|
||||
QuickFixBundle.message("fix.unused.symbol.injection.text", qualifiedName),
|
||||
QuickFixBundle.message("fix.unused.symbol.injection.text", element, qualifiedName),
|
||||
QuickFixBundle.message("fix.unused.symbol.injection.family"),
|
||||
INJECTION_ANNOS, qualifiedName, context);
|
||||
INJECTION_ANNOS, qualifiedName);
|
||||
}
|
||||
|
||||
private static List<String> getRegisteredAnnotations() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.ui.ReorderableListController;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SeparatorFactory;
|
||||
import com.intellij.ui.SortedListModel;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -83,24 +85,34 @@ public class SpecialAnnotationsUtil {
|
||||
listChanged();
|
||||
}
|
||||
});
|
||||
|
||||
final JScrollPane listScrollPane = ScrollPaneFactory.createScrollPane(injectionList);
|
||||
listScrollPane.setBorder(BorderFactory.createEtchedBorder());
|
||||
// listScrollPane.setBorder(BorderFactory.createEtchedBorder());
|
||||
listScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
final FontMetrics fontMetrics = injectionList.getFontMetrics(injectionList.getFont());
|
||||
listScrollPane.setPreferredSize(new Dimension(0, fontMetrics.getHeight() * 5));
|
||||
listScrollPane.setMinimumSize(new Dimension(0, fontMetrics.getHeight() * 3));
|
||||
//int height = injectionList.getCellRenderer().getListCellRendererComponent(injectionList, "foo", 0, false, false).getSize().height;
|
||||
//injectionList.setFixedCellHeight(height);
|
||||
//injectionList.setPreferredSize(new Dimension(0, height * 3));
|
||||
//injectionList.setMinimumSize(new Dimension(0, height * 3));
|
||||
// injectionList.setVisibleRowCount(3);
|
||||
|
||||
final JPanel listPanel = new JPanel(new BorderLayout());
|
||||
listPanel.setBorder(BorderFactory.createTitledBorder(borderTitle));
|
||||
|
||||
listPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.PROJECT_VIEW_TOOLBAR, actionGroup, true).getComponent(), BorderLayout.NORTH);
|
||||
listPanel.add(listScrollPane, BorderLayout.SOUTH);
|
||||
return listPanel;
|
||||
ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
|
||||
listPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH);
|
||||
listPanel.add(listScrollPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(SeparatorFactory.createSeparator(borderTitle, null), BorderLayout.NORTH);
|
||||
panel.add(listPanel, BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public static IntentionAction createAddToSpecialAnnotationsListIntentionAction(final String text, final String family, final List<String> targetList,
|
||||
final String qualifiedName,
|
||||
final PsiElement context) {
|
||||
final String qualifiedName) {
|
||||
return new IntentionAction() {
|
||||
@NotNull
|
||||
public String getText() {
|
||||
@@ -117,7 +129,7 @@ public class SpecialAnnotationsUtil {
|
||||
}
|
||||
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
doQuickFixInternal(project, targetList, qualifiedName, context);
|
||||
doQuickFixInternal(project, targetList, qualifiedName);
|
||||
}
|
||||
|
||||
public boolean startInWriteAction() {
|
||||
@@ -141,12 +153,12 @@ public class SpecialAnnotationsUtil {
|
||||
}
|
||||
|
||||
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
|
||||
doQuickFixInternal(project, targetList, qualifiedName, context);
|
||||
doQuickFixInternal(project, targetList, qualifiedName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void doQuickFixInternal(final Project project, final List<String> targetList, final String qualifiedName, final PsiElement context) {
|
||||
private static void doQuickFixInternal(final Project project, final List<String> targetList, final String qualifiedName) {
|
||||
targetList.add(qualifiedName);
|
||||
Collections.sort(targetList);
|
||||
final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
|
||||
|
||||
+71
-38
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.profile.codeInspection.ui.InspectionToolsConfigurable">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myWholePanel" 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"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
@@ -8,52 +8,85 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a4fd5" class="javax.swing.JComboBox" binding="myProfiles">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="d67c2" binding="myPanel" layout-manager="CardLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="9715e" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
|
||||
<grid id="6012b" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Add"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="95fc" class="javax.swing.JButton" binding="myDeleteButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Delete"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4aa90" class="javax.swing.JButton" binding="myImportButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Import"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f1082" class="javax.swing.JButton" binding="myExportButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Export"/>
|
||||
</properties>
|
||||
</component>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a4fd5" class="javax.swing.JComboBox" binding="myProfiles">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="316ed" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="true" same-size-vertically="false" hgap="5" vgap="0">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9715e" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Add"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="95fc" class="javax.swing.JButton" binding="myDeleteButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Delete"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4aa90" class="javax.swing.JButton" binding="myImportButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Import"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f1082" class="javax.swing.JButton" binding="myExportButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Export"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="3617d" class="javax.swing.JCheckBox" binding="myShareProfileCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Share profile"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="4774b">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+15
-11
@@ -60,6 +60,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
private JButton myDeleteButton;
|
||||
private JButton myImportButton;
|
||||
private JButton myExportButton;
|
||||
private JCheckBox myShareProfileCheckBox;
|
||||
|
||||
private ArrayList<String> myDeletedProfiles = new ArrayList<String>();
|
||||
protected final InspectionProfileManager myProfileManager;
|
||||
@@ -155,7 +156,6 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
private void addProfile(InspectionProfileImpl model) {
|
||||
final String modelName = model.getName();
|
||||
final SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(myProjectProfileManager, modelName, model);
|
||||
addSharedProfileListener(panel);
|
||||
myPanel.add(modelName, panel);
|
||||
if (!myPanels.containsKey(modelName)) {
|
||||
((DefaultComboBoxModel)myProfiles.getModel()).addElement(model);
|
||||
@@ -195,9 +195,18 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
myProfiles.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final InspectionProfileImpl profile = (InspectionProfileImpl)myProfiles.getSelectedItem();
|
||||
final SingleInspectionProfilePanel panel = getSelectedPanel();
|
||||
myDeleteButton.setEnabled(myProfiles.getModel().getSize() > 1);
|
||||
myLayout.show(myPanel, profile.getName());
|
||||
SingleInspectionProfilePanel panel = getSelectedPanel();
|
||||
if (panel != null) {
|
||||
myShareProfileCheckBox.setSelected(panel.isProfileShared());
|
||||
}
|
||||
}
|
||||
});
|
||||
myShareProfileCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getSelectedPanel().setProfileShared(myShareProfileCheckBox.isSelected());
|
||||
myProfiles.repaint();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -243,7 +252,6 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
model.addElement(profile);
|
||||
final String profileName = profile.getName();
|
||||
final SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(myProjectProfileManager, profileName, ((InspectionProfileImpl)profile).getModifiableModel());
|
||||
addSharedProfileListener(panel);
|
||||
myPanels.put(profileName, panel);
|
||||
panel.reset();
|
||||
myPanel.add(profileName, panel);
|
||||
@@ -252,14 +260,10 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
myProfiles.setSelectedItem(inspectionProfile);
|
||||
myLayout.show(myPanel, inspectionProfile.getName());
|
||||
myDeleteButton.setEnabled(getProfiles().size() > 1 && inspectionProfile.getProfileManager() == myProfileManager);
|
||||
}
|
||||
|
||||
private void addSharedProfileListener(final SingleInspectionProfilePanel panel) {
|
||||
panel.addSharedProfileListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myProfiles.repaint();
|
||||
}
|
||||
});
|
||||
SingleInspectionProfilePanel panel = getSelectedPanel();
|
||||
if (panel != null) {
|
||||
myShareProfileCheckBox.setSelected(panel.isProfileShared());
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<Profile> getProfiles() {
|
||||
|
||||
+19
-28
@@ -27,7 +27,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
@@ -94,7 +93,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
@NonNls private static final String EMPTY_HTML = "<html><body></body></html>";
|
||||
private boolean myIsInRestore = false;
|
||||
|
||||
private JCheckBox myShareProfile = new JCheckBox("Share profile");
|
||||
private boolean myShareProfile;
|
||||
private final InspectionProjectProfileManager myProjectProfileManager;
|
||||
|
||||
public SingleInspectionProfilePanel(final String inspectionProfileName, final ModifiableModel profile) {
|
||||
@@ -121,13 +120,6 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
});
|
||||
myUserActivityWatcher.register(myOptionsPanel);
|
||||
updateSelectedProfileState();
|
||||
final JPanel sharePanel = new JPanel(new BorderLayout());
|
||||
sharePanel.add(myShareProfile, BorderLayout.EAST);
|
||||
add(sharePanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
public void addSharedProfileListener(ActionListener sharedProfileListener) {
|
||||
myShareProfile.addActionListener(sharedProfileListener);
|
||||
}
|
||||
|
||||
private void updateSelectedProfileState() {
|
||||
@@ -738,6 +730,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
|
||||
myOptionsPanel.removeAll();
|
||||
myOptionsPanel.add(SeparatorFactory.createSeparator("Options", null), BorderLayout.NORTH);
|
||||
|
||||
final NamedScope scope = node.getScope();
|
||||
if (scope != null || node.isInspectionNode()) {
|
||||
@@ -773,7 +766,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
new Insets(0, 0, 0, 0), 0, 0));
|
||||
}
|
||||
|
||||
myOptionsPanel.add(withSeverity);
|
||||
myOptionsPanel.add(withSeverity, BorderLayout.CENTER);
|
||||
}
|
||||
myOptionsPanel.validate();
|
||||
GuiUtils.enableChildren(myOptionsPanel, node.isChecked());
|
||||
@@ -786,6 +779,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
|
||||
private void initOptionsAndDescriptionPanel() {
|
||||
myOptionsPanel.removeAll();
|
||||
myOptionsPanel.add(SeparatorFactory.createSeparator("Options", null));
|
||||
myOptionsPanel.add(new JPanel());
|
||||
try {
|
||||
myBrowser.read(new StringReader(EMPTY_HTML), null);
|
||||
@@ -856,19 +850,17 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
initDescriptors();
|
||||
fillTreeData(myProfileFilter != null ? myProfileFilter.getFilter() : null, true);
|
||||
|
||||
JPanel descriptionPanel = new JPanel();
|
||||
descriptionPanel.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.description.title")));
|
||||
descriptionPanel.setLayout(new BorderLayout());
|
||||
JPanel descriptionPanel = new JPanel(new BorderLayout());
|
||||
descriptionPanel.add(SeparatorFactory.createSeparator(InspectionsBundle.message("inspection.description.title"), null), BorderLayout.NORTH);
|
||||
descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER);
|
||||
|
||||
JPanel rightPanel = new JPanel(new GridLayout(2, 1, 0, 5));
|
||||
rightPanel.add(descriptionPanel);
|
||||
Splitter rightPanel = new Splitter(true);
|
||||
rightPanel.setFirstComponent(descriptionPanel);
|
||||
|
||||
JPanel panel1 = new JPanel(new VerticalFlowLayout());
|
||||
panel1.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.export.options.panel.title")));
|
||||
myOptionsPanel = panel1;
|
||||
myOptionsPanel = new JPanel(new BorderLayout());
|
||||
initOptionsAndDescriptionPanel();
|
||||
rightPanel.add(myOptionsPanel);
|
||||
rightPanel.setSecondComponent(myOptionsPanel);
|
||||
rightPanel.setHonorComponentsMinimumSize(true);
|
||||
|
||||
final JPanel treePanel = new JPanel(new BorderLayout());
|
||||
treePanel.add(initTreeScrollPane(), BorderLayout.CENTER);
|
||||
@@ -894,7 +886,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
public boolean isModified() {
|
||||
if (myModified) return true;
|
||||
if (mySelectedProfile.isChanged()) return true;
|
||||
if (myShareProfile.isSelected() != (mySelectedProfile.getProfileManager() == myProjectProfileManager)) return true;
|
||||
if (myShareProfile != (mySelectedProfile.getProfileManager() == myProjectProfileManager)) return true;
|
||||
if (!Comparing.strEqual(myInitialProfile, mySelectedProfile.getName())) return true;
|
||||
if (descriptorsAreChanged()) {
|
||||
return setSelectedProfileModified(true);
|
||||
@@ -909,18 +901,13 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
final String filter = myProfileFilter.getFilter();
|
||||
myProfileFilter.reset();
|
||||
myProfileFilter.setSelectedItem(filter);
|
||||
myShareProfile.setVisible(myProjectProfileManager != null);
|
||||
myShareProfile.setSelected(mySelectedProfile.getProfileManager() == myProjectProfileManager);
|
||||
}
|
||||
|
||||
public void setSharedEnabled(boolean enabled) {
|
||||
myShareProfile.setEnabled(enabled);
|
||||
myShareProfile = mySelectedProfile.getProfileManager() == myProjectProfileManager;
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
final ModifiableModel selectedProfile = getSelectedProfile();
|
||||
final ProfileManager profileManager =
|
||||
myShareProfile.isSelected() ? myProjectProfileManager : InspectionProfileManager.getInstance();
|
||||
myShareProfile ? myProjectProfileManager : InspectionProfileManager.getInstance();
|
||||
if (selectedProfile.getProfileManager() != profileManager) {
|
||||
if (selectedProfile.getProfileManager().getProfile(selectedProfile.getName(), false) != null) {
|
||||
selectedProfile.getProfileManager().deleteProfile(selectedProfile.getName());
|
||||
@@ -986,7 +973,11 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
|
||||
public boolean isProfileShared() {
|
||||
return myShareProfile.isSelected();
|
||||
return myShareProfile;
|
||||
}
|
||||
|
||||
public void setProfileShared(boolean profileShared) {
|
||||
myShareProfile = profileShared;
|
||||
}
|
||||
|
||||
private class LevelSelection implements ActionListener {
|
||||
|
||||
@@ -214,7 +214,7 @@ change.new.operator.type.text=Change ''{0}'' to ''new {1}{2}''
|
||||
change.new.operator.type.family=Change new operator type
|
||||
|
||||
fix.unused.symbol.injection.family=Add to Dependency Injection Annotations
|
||||
fix.unused.symbol.injection.text=Add ''{0}'' to dependency injection annotations list
|
||||
fix.unused.symbol.injection.text=Suppress for {0} annotated by ''{1}''
|
||||
fix.add.special.annotation.family=Add to Special Annotations
|
||||
fix.add.special.annotation.text=Add ''{0}'' to special annotations list
|
||||
|
||||
|
||||
Reference in New Issue
Block a user