mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+4
-5
@@ -74,14 +74,13 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
DuplicatesIndex.ourEnabledLightProfiles;
|
||||
if (usingLightProfile) {
|
||||
LighterAST ast = node.getLighterAST();
|
||||
assert ast != null;
|
||||
((LightDuplicateProfile)profile).process(ast, new LightDuplicateProfile.Callback() {
|
||||
DuplicatedCodeProcessor<LighterASTNode> myProcessor;
|
||||
@Override
|
||||
public void process(int hash, int hash2, @NotNull final LighterAST ast, @NotNull final LighterASTNode... nodes) {
|
||||
class LightDuplicatedCodeProcessor extends DuplicatedCodeProcessor<LighterASTNode> {
|
||||
|
||||
LightDuplicatedCodeProcessor(VirtualFile file, Project project) {
|
||||
private LightDuplicatedCodeProcessor(VirtualFile file, Project project) {
|
||||
super(file, project, myFilterOutGeneratedCode);
|
||||
}
|
||||
|
||||
@@ -129,7 +128,7 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
|
||||
class OldDuplicatedCodeProcessor extends DuplicatedCodeProcessor<PsiFragment> {
|
||||
|
||||
OldDuplicatedCodeProcessor(VirtualFile file, Project project) {
|
||||
private OldDuplicatedCodeProcessor(VirtualFile file, Project project) {
|
||||
super(file, project, myFilterOutGeneratedCode);
|
||||
}
|
||||
|
||||
@@ -225,7 +224,7 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
return null;
|
||||
}
|
||||
|
||||
static abstract class DuplicatedCodeProcessor<T> implements FileBasedIndex.ValueProcessor<TIntArrayList> {
|
||||
abstract static class DuplicatedCodeProcessor<T> implements FileBasedIndex.ValueProcessor<TIntArrayList> {
|
||||
final TreeMap<Integer, TextRange> reportedRanges = new TreeMap<>();
|
||||
final TIntObjectHashMap<VirtualFile> reportedFiles = new TIntObjectHashMap<>();
|
||||
final TIntObjectHashMap<PsiElement> reportedPsi = new TIntObjectHashMap<>();
|
||||
@@ -258,7 +257,7 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(VirtualFile file, TIntArrayList list) {
|
||||
public boolean process(@NotNull VirtualFile file, TIntArrayList list) {
|
||||
for(int i = 0, len = list.size(); i < len; i+=2) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
|
||||
+2
-3
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.progress.DumbProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
|
||||
import com.intellij.openapi.progress.util.ReadTask;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
@@ -36,8 +37,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import static com.intellij.openapi.progress.util.ProgressIndicatorUtils.scheduleWithWriteActionPriority;
|
||||
|
||||
|
||||
class TimeStampedIndentOptions extends IndentOptions {
|
||||
private long myTimeStamp;
|
||||
@@ -158,7 +157,7 @@ class DetectAndAdjustIndentOptionsTask extends ReadTask {
|
||||
}
|
||||
else {
|
||||
PsiDocumentManager manager = PsiDocumentManager.getInstance(myProject);
|
||||
manager.performForCommittedDocument(myDocument, () -> scheduleWithWriteActionPriority(myExecutor, this));
|
||||
manager.performForCommittedDocument(myDocument, () -> ProgressIndicatorUtils.scheduleWithWriteActionPriority(myExecutor, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,33 +32,40 @@ public class GuiFormFileType implements /*UIBased*/FileType {
|
||||
@NonNls public static final String DEFAULT_EXTENSION = "form";
|
||||
@NonNls public static final String DOT_DEFAULT_EXTENSION = "." + DEFAULT_EXTENSION;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "GUI_DESIGNER_FORM";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return IdeBundle.message("filetype.description.gui.designer.form");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDefaultExtension() {
|
||||
return DEFAULT_EXTENSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return PlatformIcons.UI_FORM_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBinary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
|
||||
return CharsetToolkit.UTF8;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ import com.intellij.uiDesigner.inspections.FormErrorCollector;
|
||||
import com.intellij.uiDesigner.inspections.StringDescriptorInspection;
|
||||
import com.intellij.uiDesigner.lw.IComponent;
|
||||
import com.intellij.uiDesigner.lw.IProperty;
|
||||
import com.intellij.uiDesigner.lw.ITabbedPane;
|
||||
import com.intellij.uiDesigner.lw.StringDescriptor;
|
||||
import com.intellij.uiDesigner.propertyInspector.IntrospectedProperty;
|
||||
import com.intellij.uiDesigner.propertyInspector.properties.BorderProperty;
|
||||
import com.intellij.uiDesigner.quickFixes.QuickFix;
|
||||
import com.intellij.uiDesigner.radComponents.RadComponent;
|
||||
import com.intellij.uiDesigner.radComponents.RadContainer;
|
||||
import com.intellij.uiDesigner.radComponents.RadTabbedPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -51,6 +51,7 @@ public class I18nFormInspection extends StringDescriptorInspection {
|
||||
super("HardCodedStringLiteral");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkStringDescriptor(final Module module,
|
||||
final IComponent component,
|
||||
final IProperty prop,
|
||||
@@ -69,14 +70,16 @@ public class I18nFormInspection extends StringDescriptorInspection {
|
||||
|
||||
if (prop.getName().equals(BorderProperty.NAME)) {
|
||||
provider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new I18nizeFormBorderQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.border.title"),
|
||||
(RadContainer)component);
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (prop.getName().equals(RadTabbedPane.TAB_TITLE_PROPERTY) || prop.getName().equals(RadTabbedPane.TAB_TOOLTIP_PROPERTY)) {
|
||||
else if (prop.getName().equals(ITabbedPane.TAB_TITLE_PROPERTY) || prop.getName().equals(ITabbedPane.TAB_TOOLTIP_PROPERTY)) {
|
||||
provider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new I18nizeTabTitleQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.tab.title", prop.getName()),
|
||||
component, prop.getName());
|
||||
@@ -85,6 +88,7 @@ public class I18nFormInspection extends StringDescriptorInspection {
|
||||
}
|
||||
else {
|
||||
provider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new I18nizeFormPropertyQuickFix(editor, UIDesignerBundle.message("i18n.quickfix.property", prop.getName()),
|
||||
component,
|
||||
@@ -100,15 +104,13 @@ public class I18nFormInspection extends StringDescriptorInspection {
|
||||
}
|
||||
|
||||
private static boolean isPropertyDescriptor(final IProperty prop) {
|
||||
return !prop.getName().equals(BorderProperty.NAME) && !prop.getName().equals(RadTabbedPane.TAB_TITLE_PROPERTY) &&
|
||||
!prop.getName().equals(RadTabbedPane.TAB_TOOLTIP_PROPERTY);
|
||||
return !prop.getName().equals(BorderProperty.NAME) && !prop.getName().equals(ITabbedPane.TAB_TITLE_PROPERTY) &&
|
||||
!prop.getName().equals(ITabbedPane.TAB_TOOLTIP_PROPERTY);
|
||||
}
|
||||
|
||||
private static boolean isHardCodedStringDescriptor(final StringDescriptor descriptor) {
|
||||
if (descriptor.isNoI18n()) {
|
||||
return false;
|
||||
}
|
||||
return descriptor.getBundleName() == null &&
|
||||
return !descriptor.isNoI18n() &&
|
||||
descriptor.getBundleName() == null &&
|
||||
descriptor.getKey() == null &&
|
||||
StringUtil.containsAlphaCharacters(descriptor.getValue());
|
||||
}
|
||||
@@ -132,6 +134,7 @@ public class I18nFormInspection extends StringDescriptorInspection {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
|
||||
if (file.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
|
||||
|
||||
+45
-35
@@ -49,16 +49,19 @@ public abstract class BaseFormInspection extends BaseJavaLocalInspectionTool imp
|
||||
myInspectionKey = inspectionKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nls @NotNull
|
||||
public String getDisplayName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return UIDesignerBundle.message("form.inspections.group");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull @NonNls public String getShortName() {
|
||||
return myInspectionKey;
|
||||
}
|
||||
@@ -67,56 +70,63 @@ public abstract class BaseFormInspection extends BaseJavaLocalInspectionTool imp
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(PsiElement psiRoot) {
|
||||
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(psiRoot.getProject()).getCurrentProfile();
|
||||
HighlightDisplayKey key = HighlightDisplayKey.find(myInspectionKey);
|
||||
return key != null && profile.isToolEnabled(key, psiRoot);
|
||||
}
|
||||
|
||||
@Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
|
||||
if (file.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
return null;
|
||||
}
|
||||
final Module module = ModuleUtil.findModuleForFile(virtualFile, file.getProject());
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final LwRootContainer rootContainer;
|
||||
try {
|
||||
rootContainer = Utils.getRootContainer(file.getText(), new PsiPropertiesProvider(module));
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rootContainer.isInspectionSuppressed(getShortName(), null)) {
|
||||
return null;
|
||||
}
|
||||
final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager, isOnTheFly);
|
||||
startCheckForm(rootContainer);
|
||||
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor() {
|
||||
public boolean visit(final IComponent component) {
|
||||
if (!rootContainer.isInspectionSuppressed(getShortName(), component.getId())) {
|
||||
checkComponentProperties(module, component, collector);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
doneCheckForm(rootContainer);
|
||||
return collector.result();
|
||||
@Override
|
||||
@Nullable
|
||||
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
|
||||
if (!file.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
return null;
|
||||
}
|
||||
final Module module = ModuleUtil.findModuleForFile(virtualFile, file.getProject());
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final LwRootContainer rootContainer;
|
||||
try {
|
||||
rootContainer = Utils.getRootContainer(file.getText(), new PsiPropertiesProvider(module));
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rootContainer.isInspectionSuppressed(getShortName(), null)) {
|
||||
return null;
|
||||
}
|
||||
final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager, isOnTheFly);
|
||||
startCheckForm(rootContainer);
|
||||
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor() {
|
||||
@Override
|
||||
public boolean visit(final IComponent component) {
|
||||
if (!rootContainer.isInspectionSuppressed(getShortName(), component.getId())) {
|
||||
checkComponentProperties(module, component, collector);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
doneCheckForm(rootContainer);
|
||||
return collector.result();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCheckForm(IRootContainer rootContainer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneCheckForm(IRootContainer rootContainer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ErrorInfo[] checkComponent(@NotNull GuiEditor editor, @NotNull RadComponent component) {
|
||||
FormEditorErrorCollector collector = new FormEditorErrorCollector(editor, component);
|
||||
|
||||
+4
@@ -31,16 +31,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author yole
|
||||
*/
|
||||
public class BoundFieldAssignmentInspection extends BaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return UIDesignerBundle.message("form.inspections.group");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return UIDesignerBundle.message("inspection.bound.field.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getShortName() {
|
||||
@@ -52,6 +55,7 @@ public class BoundFieldAssignmentInspection extends BaseJavaLocalInspectionTool
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+6
-10
@@ -37,12 +37,7 @@ import java.util.List;
|
||||
* @author yole
|
||||
*/
|
||||
public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
private static final ThreadLocal<HashMap<IRootContainer, MnemonicMap>> myContainerMnemonicMap = new ThreadLocal<HashMap<IRootContainer, MnemonicMap>>() {
|
||||
@Override
|
||||
protected HashMap<IRootContainer, MnemonicMap> initialValue() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
};
|
||||
private static final ThreadLocal<HashMap<IRootContainer, MnemonicMap>> myContainerMnemonicMap = ThreadLocal.withInitial(HashMap::new);
|
||||
|
||||
public DuplicateMnemonicInspection() {
|
||||
super("DuplicateMnemonic");
|
||||
@@ -62,6 +57,7 @@ public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
myContainerMnemonicMap.get().remove(rootContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
SupportCode.TextWithMnemonic twm = getTextWithMnemonic(module, component);
|
||||
if (twm != null) {
|
||||
@@ -70,7 +66,7 @@ public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SupportCode.TextWithMnemonic getTextWithMnemonic(final Module module, final IComponent component) {
|
||||
static SupportCode.TextWithMnemonic getTextWithMnemonic(final Module module, final IComponent component) {
|
||||
if (module.isDisposed()) return null;
|
||||
IProperty prop = FormInspectionUtil.findProperty(component, SwingProperties.TEXT);
|
||||
if (prop != null) {
|
||||
@@ -109,6 +105,7 @@ public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
FormInspectionUtil.getText(module, oldComponent),
|
||||
FormInspectionUtil.getText(module, component)),
|
||||
new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new AssignMnemonicFix(editor, component,
|
||||
UIDesignerBundle.message("inspection.duplicate.mnemonics.quickfix"));
|
||||
@@ -138,7 +135,7 @@ public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
private final char myMnemonicChar;
|
||||
private final List<Integer> myExclusiveContainerStack;
|
||||
|
||||
public MnemonicKey(final char mnemonicChar, final List<Integer> exclusiveContainerStack) {
|
||||
MnemonicKey(final char mnemonicChar, final List<Integer> exclusiveContainerStack) {
|
||||
myMnemonicChar = mnemonicChar;
|
||||
myExclusiveContainerStack = exclusiveContainerStack;
|
||||
}
|
||||
@@ -156,8 +153,7 @@ public class DuplicateMnemonicInspection extends BaseFormInspection {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (int)myMnemonicChar;
|
||||
int result = (int)myMnemonicChar;
|
||||
result = 31 * result + myExclusiveContainerStack.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
* @author yole
|
||||
*/
|
||||
public class FormSpellCheckingInspection extends StringDescriptorInspection {
|
||||
public static final String SHORT_NAME = "SpellCheckingInspection";
|
||||
private static final String SHORT_NAME = "SpellCheckingInspection";
|
||||
|
||||
public FormSpellCheckingInspection() {
|
||||
super(SHORT_NAME);
|
||||
@@ -60,7 +60,7 @@ public class FormSpellCheckingInspection extends StringDescriptorInspection {
|
||||
final String word = textRange.substring(value);
|
||||
if (manager.hasProblem(word)) {
|
||||
final List<String> suggestions = manager.getSuggestions(word);
|
||||
if (suggestions.size() > 0 && prop instanceof IntroStringProperty) {
|
||||
if (!suggestions.isEmpty() && prop instanceof IntroStringProperty) {
|
||||
EditorQuickFixProvider changeToProvider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(final GuiEditor editor, final RadComponent component1) {
|
||||
|
||||
+3
-1
@@ -42,6 +42,7 @@ public class MissingMnemonicInspection extends BaseFormInspection {
|
||||
return UIDesignerBundle.message("inspection.missing.mnemonics");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
String value = FormInspectionUtil.getText(module, component);
|
||||
if (value == null) {
|
||||
@@ -49,7 +50,7 @@ public class MissingMnemonicInspection extends BaseFormInspection {
|
||||
}
|
||||
IProperty textProperty = FormInspectionUtil.findProperty(component, SwingProperties.TEXT);
|
||||
SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
|
||||
if (twm.myMnemonicIndex < 0 && twm.myText.length() > 0) {
|
||||
if (twm.myMnemonicIndex < 0 && !twm.myText.isEmpty()) {
|
||||
if (FormInspectionUtil.isComponentClass(module, component, AbstractButton.class)) {
|
||||
collector.addError(getID(), component, textProperty,
|
||||
UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
|
||||
@@ -67,6 +68,7 @@ public class MissingMnemonicInspection extends BaseFormInspection {
|
||||
}
|
||||
|
||||
private static class MyEditorQuickFixProvider implements EditorQuickFixProvider {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new AssignMnemonicFix(editor, component,
|
||||
UIDesignerBundle.message("inspections.missing.mnemonic.quickfix"));
|
||||
|
||||
+9
-5
@@ -35,7 +35,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -52,6 +51,7 @@ public class NoButtonGroupInspection extends BaseFormInspection {
|
||||
return UIDesignerBundle.message("inspection.no.button.group");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
if (FormInspectionUtil.isComponentClass(module, component, JRadioButton.class)) {
|
||||
final IRootContainer root = FormEditingUtil.getRoot(component);
|
||||
@@ -69,6 +69,7 @@ public class NoButtonGroupInspection extends BaseFormInspection {
|
||||
final String groupName = root.getButtonGroupName(child);
|
||||
if (groupName == null) {
|
||||
quickFixProvider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new CreateGroupQuickFix(editor, component, c1.getColumn() == c2.getColumn());
|
||||
}
|
||||
@@ -77,6 +78,7 @@ public class NoButtonGroupInspection extends BaseFormInspection {
|
||||
}
|
||||
else {
|
||||
quickFixProvider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new AddToGroupQuickFix(editor, component, groupName);
|
||||
}
|
||||
@@ -103,18 +105,19 @@ public class NoButtonGroupInspection extends BaseFormInspection {
|
||||
FormEditingUtil.nextRow(container, c1.getRow()) == c2.getRow();
|
||||
}
|
||||
}
|
||||
return (c1.getRow() == c2.getRow() && Math.abs(c1.getColumn() - c2.getColumn()) == 1) ||
|
||||
(c1.getColumn() == c2.getColumn() && Math.abs(c1.getRow() - c2.getRow()) == 1);
|
||||
return c1.getRow() == c2.getRow() && Math.abs(c1.getColumn() - c2.getColumn()) == 1 ||
|
||||
c1.getColumn() == c2.getColumn() && Math.abs(c1.getRow() - c2.getRow()) == 1;
|
||||
}
|
||||
|
||||
private static class CreateGroupQuickFix extends QuickFix {
|
||||
private final boolean myVerticalGroup;
|
||||
|
||||
public CreateGroupQuickFix(final GuiEditor editor, final RadComponent component, boolean verticalGroup) {
|
||||
CreateGroupQuickFix(final GuiEditor editor, final RadComponent component, boolean verticalGroup) {
|
||||
super(editor, UIDesignerBundle.message("inspection.no.button.group.quickfix.create"), component);
|
||||
myVerticalGroup = verticalGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
RadContainer parent = myComponent.getParent();
|
||||
ArrayList<RadComponent> buttonsToGroup = new ArrayList<>();
|
||||
@@ -166,11 +169,12 @@ public class NoButtonGroupInspection extends BaseFormInspection {
|
||||
private static class AddToGroupQuickFix extends QuickFix {
|
||||
private final String myGroupName;
|
||||
|
||||
public AddToGroupQuickFix(final GuiEditor editor, final RadComponent component, final String groupName) {
|
||||
AddToGroupQuickFix(final GuiEditor editor, final RadComponent component, final String groupName) {
|
||||
super(editor, UIDesignerBundle.message("inspection.no.button.group.quickfix.add", groupName), component);
|
||||
myGroupName = groupName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(myComponent);
|
||||
if (root == null) return;
|
||||
|
||||
+9
-5
@@ -34,9 +34,9 @@ import com.intellij.uiDesigner.quickFixes.QuickFix;
|
||||
import com.intellij.uiDesigner.radComponents.RadComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -51,6 +51,7 @@ public class NoLabelForInspection extends BaseFormInspection {
|
||||
return UIDesignerBundle.message("inspection.no.label.for");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(final Module module, final IComponent component, FormErrorCollector collector) {
|
||||
ComponentItem item = Palette.getInstance(module.getProject()).getItem(component.getComponentClassName());
|
||||
if (item != null && item.isCanAttachLabel()) {
|
||||
@@ -62,6 +63,7 @@ public class NoLabelForInspection extends BaseFormInspection {
|
||||
final Ref<RadComponent> candidateLabel = new Ref<>();
|
||||
final List<RadComponent> allLabels = new ArrayList<>();
|
||||
FormEditingUtil.iterate(root, new FormEditingUtil.ComponentVisitor() {
|
||||
@Override
|
||||
public boolean visit(final IComponent c2) {
|
||||
if (FormInspectionUtil.isComponentClass(module, c2, JLabel.class)) {
|
||||
IProperty prop = FormInspectionUtil.findProperty(c2, SwingProperties.LABEL_FOR);
|
||||
@@ -72,15 +74,15 @@ public class NoLabelForInspection extends BaseFormInspection {
|
||||
else if (component instanceof RadComponent &&
|
||||
(prop == null || StringUtil.isEmpty((String)prop.getPropertyValue(c2)))) {
|
||||
RadComponent radComponent = (RadComponent) component;
|
||||
final RadComponent radComponent2 = ((RadComponent)c2);
|
||||
final RadComponent radComponent2 = (RadComponent)c2;
|
||||
allLabels.add(radComponent2);
|
||||
if (radComponent.getParent() == radComponent2.getParent() && radComponent.getParent().getLayoutManager().isGrid()) {
|
||||
GridConstraints gc1 = radComponent.getConstraints();
|
||||
GridConstraints gc2 = radComponent2.getConstraints();
|
||||
int nextColumn = FormEditingUtil.nextCol(radComponent.getParent(), gc2.getColumn());
|
||||
int nextRow = FormEditingUtil.nextRow(radComponent.getParent(), gc2.getRow());
|
||||
if ((gc1.getRow() == gc2.getRow() && nextColumn == gc1.getColumn()) ||
|
||||
(gc1.getColumn() == gc2.getColumn() && nextRow == gc1.getRow())) {
|
||||
if (gc1.getRow() == gc2.getRow() && nextColumn == gc1.getColumn() ||
|
||||
gc1.getColumn() == gc2.getColumn() && nextRow == gc1.getRow()) {
|
||||
candidateLabel.set(radComponent2);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +100,7 @@ public class NoLabelForInspection extends BaseFormInspection {
|
||||
for (int i = 0; i < quickFixProviders.length; i++) {
|
||||
final RadComponent label = allLabels.get(i);
|
||||
quickFixProviders[i] = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new MyQuickFix(editor, component, label);
|
||||
}
|
||||
@@ -111,12 +114,13 @@ public class NoLabelForInspection extends BaseFormInspection {
|
||||
private static class MyQuickFix extends QuickFix {
|
||||
private final RadComponent myLabel;
|
||||
|
||||
public MyQuickFix(final GuiEditor editor, RadComponent component, RadComponent label) {
|
||||
MyQuickFix(final GuiEditor editor, RadComponent component, RadComponent label) {
|
||||
super(editor, UIDesignerBundle.message("inspection.no.label.for.quickfix",
|
||||
label.getComponentTitle()), component);
|
||||
myLabel = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myEditor.ensureEditable()) {
|
||||
return;
|
||||
|
||||
+4
-1
@@ -45,12 +45,14 @@ public class NoScrollPaneInspection extends BaseFormInspection {
|
||||
return UIDesignerBundle.message("inspection.no.scroll.pane");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
if (FormInspectionUtil.isComponentClass(module, component, Scrollable.class) &&
|
||||
!FormInspectionUtil.isComponentClass(module, component, JTextField.class) &&
|
||||
!FormInspectionUtil.isComponentClass(module, component.getParentContainer(), JScrollPane.class)) {
|
||||
collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.scroll.pane"),
|
||||
new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
|
||||
return new MyQuickFix(editor, component);
|
||||
}
|
||||
@@ -60,10 +62,11 @@ public class NoScrollPaneInspection extends BaseFormInspection {
|
||||
}
|
||||
|
||||
private static class MyQuickFix extends QuickFix {
|
||||
public MyQuickFix(final GuiEditor editor, RadComponent component) {
|
||||
MyQuickFix(final GuiEditor editor, RadComponent component) {
|
||||
super(editor, UIDesignerBundle.message("inspection.no.scroll.pane.quickfix"), component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String scrollPane = JScrollPane.class.getName();
|
||||
ComponentItem item = Palette.getInstance(myEditor.getProject()).getItem(scrollPane);
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ public class OneButtonGroupInspection extends BaseFormInspection {
|
||||
return UIDesignerBundle.message("inspection.one.button.group");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
final IRootContainer root = FormEditingUtil.getRoot(component);
|
||||
if (root == null) return;
|
||||
|
||||
+5
@@ -38,6 +38,7 @@ public abstract class StringDescriptorInspection extends BaseFormInspection {
|
||||
super(inspectionKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
|
||||
for(IProperty prop: component.getModifiedProperties()) {
|
||||
Object propValue = prop.getPropertyValue(component);
|
||||
@@ -77,10 +78,12 @@ public abstract class StringDescriptorInspection extends BaseFormInspection {
|
||||
private static class MockTabTitleProperty implements IProperty {
|
||||
public static MockTabTitleProperty INSTANCE = new MockTabTitleProperty();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ITabbedPane.TAB_TITLE_PROPERTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPropertyValue(final IComponent component) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,10 +92,12 @@ public abstract class StringDescriptorInspection extends BaseFormInspection {
|
||||
private static class MockTabToolTipProperty implements IProperty {
|
||||
public static MockTabToolTipProperty INSTANCE = new MockTabToolTipProperty();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ITabbedPane.TAB_TOOLTIP_PROPERTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPropertyValue(final IComponent component) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user