public static Set<String> collectUsedBundleNames(final IRootContainer rootContainer) { final Set<String> bundleNames = new HashSet<String>(); iterateStringDescriptors(rootContainer, new StringDescriptorVisitor<IComponent>() { public boolean visit(final IComponent component, final StringDescriptor descriptor) { if(descriptor.getBundleName() != null && !bundleNames.contains(descriptor.getBundleName())) { bundleNames.add(descriptor.getBundleName()); } return true; } }); return bundleNames; }
protected void setValueImpl(final RadComponent component, final Boolean value) throws Exception { if (value.booleanValue() && component.getBinding() == null) { String initialBinding = BindingProperty.getDefaultBinding(component); String binding = Messages.showInputDialog( component.getProject(), UIDesignerBundle.message("custom.create.field.name.prompt"), UIDesignerBundle.message("custom.create.title"), Messages.getQuestionIcon(), initialBinding, new IdentifierValidator(component.getProject())); if (binding == null) { return; } try { new BindingProperty(component.getProject()).setValue(component, binding); } catch (Exception e1) { LOG.error(e1); } } component.setCustomCreate(value.booleanValue()); if (value.booleanValue()) { final IRootContainer root = FormEditingUtil.getRoot(component); if (root.getClassToBind() != null && Utils.getCustomCreateComponentCount(root) == 1) { final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), root.getClassToBind()); if (aClass != null && FormEditingUtil.findCreateComponentsMethod(aClass) == null) { generateCreateComponentsMethod(aClass); } } } }
@Nullable public static DefaultActionGroup prepareActionGroup(final RadComponent component) { final IRootContainer root = FormEditingUtil.getRoot(component); final String classToBind = root == null ? null : root.getClassToBind(); if (classToBind != null) { final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), classToBind); if (aClass != null) { final PsiField boundField = aClass.findFieldByName(component.getBinding(), false); if (boundField != null) { return buildNavigateActionGroup(component, boundField); } } } return null; }
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(Module module, IComponent component, FormErrorCollector collector) { final IRootContainer root = FormEditingUtil.getRoot(component); if (root == null) return; String groupName = root.getButtonGroupName(component); if (groupName != null) { final String[] sameGroupComponents = root.getButtonGroupComponentIds(groupName); for(String id: sameGroupComponents) { final IComponent otherComponent = FormEditingUtil.findComponent(root, id); if (otherComponent != null && otherComponent != component) { return; } } collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.one.button.group.error")); } }
public static IRootContainer getRoot(IComponent component) { while(component != null) { if(component.getParentContainer() instanceof IRootContainer) { return (IRootContainer) component.getParentContainer(); } component = component.getParentContainer(); } return null; }
public static Locale[] collectUsedLocales(final Module module, final IRootContainer rootContainer) { final Set<Locale> locales = new HashSet<Locale>(); final PropertiesReferenceManager propManager = PropertiesReferenceManager.getInstance(module.getProject()); for(String bundleName : collectUsedBundleNames(rootContainer)) { List<PropertiesFile> propFiles = propManager.findPropertiesFiles(module, bundleName.replace('/', '.')); for(PropertiesFile propFile : propFiles) { locales.add(propFile.getLocale()); } } return locales.toArray(new Locale[locales.size()]); }
@Nullable public static IButtonGroup findGroupForComponent(final IRootContainer radRootContainer, @NotNull final IComponent component) { for(IButtonGroup group : radRootContainer.getButtonGroups()) { for(String id : group.getComponentIds()) { if(component.getId().equals(id)) { return group; } } } return null; }
public static void analyzeErrors(final GuiEditor editor, final IRootContainer rootContainer, @Nullable final ProgressIndicator progress) { analyzeErrors(editor.getModule(), editor.getFile(), editor, rootContainer, progress); }
private static String[] getFieldNames(final RadComponent component, final String currentName) { final ArrayList<String> result = new ArrayList<String>(); if (currentName != null){ result.add(currentName); } final IRootContainer root = FormEditingUtil.getRoot(component); final String className = root.getClassToBind(); if (className == null) { return ArrayUtil.toStringArray(result); } final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), className); if (aClass == null) { return ArrayUtil.toStringArray(result); } final PsiField[] fields = aClass.getFields(); for (final PsiField field : fields) { if (field.hasModifierProperty(PsiModifier.STATIC)) { continue; } final String fieldName = field.getName(); if (Comparing.equal(currentName, fieldName)) { continue; } if (!FormEditingUtil.isBindingUnique(component, fieldName, root)) { continue; } final String componentClassName; if (component instanceof RadErrorComponent) { componentClassName = component.getComponentClassName(); } else if (component instanceof RadHSpacer || component instanceof RadVSpacer) { componentClassName = Spacer.class.getName(); } else { componentClassName = component.getComponentClass().getName(); } final PsiType componentType; try { componentType = JavaPsiFacade.getInstance(component.getProject()).getElementFactory().createTypeFromText(componentClassName, null); } catch (IncorrectOperationException e) { continue; } final PsiType fieldType = field.getType(); if (!fieldType.isAssignableFrom(componentType)) { continue; } result.add(fieldName); } String text = FormInspectionUtil.getText(component.getModule(), component); if (text != null) { String binding = BindingProperty.suggestBindingFromText(component, text); if (binding != null && !result.contains(binding)) { result.add(binding); } } final String[] names = ArrayUtil.toStringArray(result); Arrays.sort(names); return names; }
public void startCheckForm(IRootContainer rootContainer) { }
public void doneCheckForm(IRootContainer rootContainer) { }
void startCheckForm(IRootContainer radRootContainer);
void doneCheckForm(IRootContainer radRootContainer);