public void addError(@NotNull final String inspectionId, final IComponent component, @Nullable IProperty prop, @NotNull String errorMessage, EditorQuickFixProvider... editorQuickFixProviders) { if (myResults == null) { myResults = new ArrayList<ErrorInfo>(); } List<QuickFix> quickFixes = new ArrayList<QuickFix>(); for (EditorQuickFixProvider provider : editorQuickFixProviders) { if (provider != null) { quickFixes.add(provider.createQuickFix(myEditor, myComponent)); } } final ErrorInfo errorInfo = new ErrorInfo(myComponent, prop == null ? null : prop.getName(), errorMessage, myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile), quickFixes.toArray(new QuickFix[quickFixes.size()])); errorInfo.setInspectionId(inspectionId); myResults.add(errorInfo); }
public ErrorInfo(IComponent component, @NonNls final String propertyName, @NotNull final String description, @NotNull HighlightDisplayLevel highlightDisplayLevel, @NotNull final QuickFix[] fixes) { myComponent = component instanceof RadComponent ? (RadComponent) component : null; myHighlightDisplayLevel = highlightDisplayLevel; myPropertyName = propertyName; myDescription = description; myFixes = fixes; }
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) { if (FormInspectionUtil.isComponentClass(module, component, JRadioButton.class)) { final IRootContainer root = FormEditingUtil.getRoot(component); if (root == null) return; if (root.getButtonGroupName(component) == null) { EditorQuickFixProvider quickFixProvider = null; IContainer parent = component.getParentContainer(); for(int i=0; i<parent.getComponentCount(); i++) { IComponent child = parent.getComponent(i); if (child != component && FormInspectionUtil.isComponentClass(module, child, JRadioButton.class)) { final GridConstraints c1 = component.getConstraints(); final GridConstraints c2 = child.getConstraints(); if (areCellsAdjacent(parent, c1, c2)) { final String groupName = root.getButtonGroupName(child); if (groupName == null) { quickFixProvider = new EditorQuickFixProvider() { public QuickFix createQuickFix(GuiEditor editor, RadComponent component) { return new CreateGroupQuickFix(editor, component, c1.getColumn() == c2.getColumn()); } }; break; } else { quickFixProvider = new EditorQuickFixProvider() { public QuickFix createQuickFix(GuiEditor editor, RadComponent component) { return new AddToGroupQuickFix(editor, component, groupName); } }; } } } } collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.button.group.error"), quickFixProvider); } } }
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()) { IComponent root = component; while(root.getParentContainer() != null) { root = root.getParentContainer(); } final Ref<Boolean> found = new Ref<Boolean>(Boolean.FALSE); final Ref<RadComponent> candidateLabel = new Ref<RadComponent>(); final List<RadComponent> allLabels = new ArrayList<RadComponent>(); FormEditingUtil.iterate(root, new FormEditingUtil.ComponentVisitor() { public boolean visit(final IComponent c2) { if (FormInspectionUtil.isComponentClass(module, c2, JLabel.class)) { IProperty prop = FormInspectionUtil.findProperty(c2, SwingProperties.LABEL_FOR); if (prop != null && component.getId().equals(prop.getPropertyValue(c2))) { found.set(Boolean.TRUE); return false; } else if (component instanceof RadComponent && (prop == null || StringUtil.isEmpty((String)prop.getPropertyValue(c2)))) { RadComponent radComponent = (RadComponent) component; 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())) { candidateLabel.set(radComponent2); } } } } return true; } }); if (!found.get().booleanValue()) { if (!candidateLabel.isNull()) { allLabels.clear(); allLabels.add(candidateLabel.get()); } EditorQuickFixProvider[] quickFixProviders = new EditorQuickFixProvider[allLabels.size()]; for (int i = 0; i < quickFixProviders.length; i++) { final RadComponent label = allLabels.get(i); quickFixProviders[i] = new EditorQuickFixProvider() { public QuickFix createQuickFix(GuiEditor editor, RadComponent component) { return new MyQuickFix(editor, component, label); } }; } collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.label.for.error"), quickFixProviders); } } }
public QuickFix createQuickFix(GuiEditor editor, RadComponent component) { return new AssignMnemonicFix(editor, component, UIDesignerBundle.message("inspections.missing.mnemonic.quickfix")); }
QuickFix createQuickFix(GuiEditor editor, RadComponent component);