void (final Module module, @NotNull 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.FALSE); final Ref<RadComponent> candidateLabel = new Ref<>(); final List<RadComponent> allLabels = new ArrayList<>(); FormEditingUtil.iterate(root, 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 radComponent && (prop == null || StringUtil.isEmpty((String)prop.getPropertyValue(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()) { 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] = (editor, component1) -> new MyQuickFix(editor, component1, label); } collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.label.for.error"), quickFixProviders); } } }