Java 类com.intellij.uiDesigner.lw.IProperty 实例源码

项目:intellij-ce-playground    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:intellij-ce-playground    文件:MorphAction.java   
private static void retargetComponentProperties(final GuiEditor editor, final RadComponent c, final RadComponent newComponent) {
  FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      RadComponent rc = (RadComponent) component;
      for(IProperty p: component.getModifiedProperties()) {
        if (p instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) p;
          final String value = icp.getValue(rc);
          if (value.equals(c.getId())) {
            try {
              icp.setValue((RadComponent)component, newComponent.getId());
            }
            catch (Exception e) {
              // ignore
            }
          }
        }
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:DuplicateComponentsAction.java   
private static void adjustDuplicates(final Map<RadComponent, RadComponent> duplicates) {
  for(RadComponent c: duplicates.keySet()) {
    RadComponent copy = duplicates.get(c);
    if (c.getBinding() != null) {
      String binding = BindingProperty.getDefaultBinding(copy);
      new BindingProperty(c.getProject()).setValueEx(copy, binding);
      copy.setDefaultBinding(true);
    }
    for(IProperty prop: copy.getModifiedProperties()) {
      if (prop instanceof IntroComponentProperty) {
        final IntroComponentProperty componentProperty = (IntroComponentProperty)prop;
        String copyValue = componentProperty.getValue(copy);
        for(RadComponent original: duplicates.keySet()) {
          if (original.getId().equals(copyValue)) {
            componentProperty.setValueEx(copy, duplicates.get(original).getId());
          }
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:FormEditorErrorCollector.java   
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);
}
项目:intellij-ce-playground    文件:Java15FormInspection.java   
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
  final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final PsiManager psiManager = PsiManager.getInstance(module.getProject());
  final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (aClass == null) {
    return;
  }

  for(final IProperty prop: component.getModifiedProperties()) {
    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
    if (getter == null) continue;
    final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
    if (Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel)) {
      registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
    }
  }
}
项目:intellij-ce-playground    文件:FormInspectionUtil.java   
@Nullable public static String getText(@NotNull final Module module, final IComponent component) {
  IProperty textProperty = findProperty(component, SwingProperties.TEXT);
  if (textProperty != null) {
    Object propValue = textProperty.getPropertyValue(component);
    String value = null;
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor) propValue;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
    }
    else if (propValue instanceof String) {
      value = (String) propValue;
    }
    if (value != null) {
      return value;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:MissingMnemonicInspection.java   
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
  String value = FormInspectionUtil.getText(module, component);
  if (value == null) {
    return;
  }
  IProperty textProperty = FormInspectionUtil.findProperty(component, SwingProperties.TEXT);
  SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
  if (twm.myMnemonicIndex < 0 && twm.myText.length() > 0) {
    if (FormInspectionUtil.isComponentClass(module, component, AbstractButton.class)) {
      collector.addError(getID(), component, textProperty,
                         UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                         new MyEditorQuickFixProvider());
    }
    else if (FormInspectionUtil.isComponentClass(module, component, JLabel.class)) {
      IProperty labelForProperty = FormInspectionUtil.findProperty(component, SwingProperties.LABEL_FOR);
      if (labelForProperty != null && !StringUtil.isEmpty((String) labelForProperty.getPropertyValue(component))) {
        collector.addError(getID(), component, textProperty,
                           UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                           new MyEditorQuickFixProvider());
      }
    }
  }
}
项目:tools-idea    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:tools-idea    文件:MorphAction.java   
private static void retargetComponentProperties(final GuiEditor editor, final RadComponent c, final RadComponent newComponent) {
  FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      RadComponent rc = (RadComponent) component;
      for(IProperty p: component.getModifiedProperties()) {
        if (p instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) p;
          final String value = icp.getValue(rc);
          if (value.equals(c.getId())) {
            try {
              icp.setValue((RadComponent)component, newComponent.getId());
            }
            catch (Exception e) {
              // ignore
            }
          }
        }
      }
      return true;
    }
  });
}
项目:tools-idea    文件:DuplicateComponentsAction.java   
private static void adjustDuplicates(final Map<RadComponent, RadComponent> duplicates) {
  for(RadComponent c: duplicates.keySet()) {
    RadComponent copy = duplicates.get(c);
    if (c.getBinding() != null) {
      String binding = BindingProperty.getDefaultBinding(copy);
      new BindingProperty(c.getProject()).setValueEx(copy, binding);
      copy.setDefaultBinding(true);
    }
    for(IProperty prop: copy.getModifiedProperties()) {
      if (prop instanceof IntroComponentProperty) {
        final IntroComponentProperty componentProperty = (IntroComponentProperty)prop;
        String copyValue = componentProperty.getValue(copy);
        for(RadComponent original: duplicates.keySet()) {
          if (original.getId().equals(copyValue)) {
            componentProperty.setValueEx(copy, duplicates.get(original).getId());
          }
        }
      }
    }
  }
}
项目:tools-idea    文件:FormEditorErrorCollector.java   
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);
}
项目:tools-idea    文件:Java15FormInspection.java   
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
  final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final PsiManager psiManager = PsiManager.getInstance(module.getProject());
  final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (aClass == null) {
    return;
  }

  for(final IProperty prop: component.getModifiedProperties()) {
    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
    if (getter == null) continue;
    final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
    if (Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel)) {
      registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
    }
  }
}
项目:tools-idea    文件:FormInspectionUtil.java   
@Nullable public static String getText(@NotNull final Module module, final IComponent component) {
  IProperty textProperty = findProperty(component, SwingProperties.TEXT);
  if (textProperty != null) {
    Object propValue = textProperty.getPropertyValue(component);
    String value = null;
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor) propValue;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
    }
    else if (propValue instanceof String) {
      value = (String) propValue;
    }
    if (value != null) {
      return value;
    }
  }
  return null;
}
项目:tools-idea    文件:MissingMnemonicInspection.java   
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
  String value = FormInspectionUtil.getText(module, component);
  if (value == null) {
    return;
  }
  IProperty textProperty = FormInspectionUtil.findProperty(component, SwingProperties.TEXT);
  SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
  if (twm.myMnemonicIndex < 0 && twm.myText.length() > 0) {
    if (FormInspectionUtil.isComponentClass(module, component, AbstractButton.class)) {
      collector.addError(getID(), component, textProperty,
                         UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                         new MyEditorQuickFixProvider());
    }
    else if (FormInspectionUtil.isComponentClass(module, component, JLabel.class)) {
      IProperty labelForProperty = FormInspectionUtil.findProperty(component, SwingProperties.LABEL_FOR);
      if (labelForProperty != null && !StringUtil.isEmpty((String) labelForProperty.getPropertyValue(component))) {
        collector.addError(getID(), component, textProperty,
                           UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                           new MyEditorQuickFixProvider());
      }
    }
  }
}
项目:consulo-ui-designer    文件:IntroStringProperty.java   
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
  if (component.isLoadingProperties()) {
    return;
  }
  // only generate binding from text if default locale is active (IDEADEV-9427)
  if (value.getValue() == null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Locale locale = root.getStringDescriptorLocale();
    if (locale != null && locale.getDisplayName().length() > 0) {
      return;
    }
  }

  BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
  if (component.getDelegee() instanceof JLabel) {
    for(IProperty prop: component.getModifiedProperties()) {
      if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
        ((IntroComponentProperty) prop).updateLabelForBinding(component);
      }
    }
  }
}
项目:consulo-ui-designer    文件:MorphAction.java   
private static void retargetComponentProperties(final GuiEditor editor, final RadComponent c, final RadComponent newComponent) {
  FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      RadComponent rc = (RadComponent) component;
      for(IProperty p: component.getModifiedProperties()) {
        if (p instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) p;
          final String value = icp.getValue(rc);
          if (value.equals(c.getId())) {
            try {
              icp.setValue((RadComponent)component, newComponent.getId());
            }
            catch (Exception e) {
              // ignore
            }
          }
        }
      }
      return true;
    }
  });
}
项目:consulo-ui-designer    文件:DuplicateComponentsAction.java   
private static void adjustDuplicates(final Map<RadComponent, RadComponent> duplicates) {
  for(RadComponent c: duplicates.keySet()) {
    RadComponent copy = duplicates.get(c);
    if (c.getBinding() != null) {
      String binding = BindingProperty.getDefaultBinding(copy);
      new BindingProperty(c.getProject()).setValueEx(copy, binding);
      copy.setDefaultBinding(true);
    }
    for(IProperty prop: copy.getModifiedProperties()) {
      if (prop instanceof IntroComponentProperty) {
        final IntroComponentProperty componentProperty = (IntroComponentProperty)prop;
        String copyValue = componentProperty.getValue(copy);
        for(RadComponent original: duplicates.keySet()) {
          if (original.getId().equals(copyValue)) {
            componentProperty.setValueEx(copy, duplicates.get(original).getId());
          }
        }
      }
    }
  }
}
项目:consulo-ui-designer    文件:FormEditorErrorCollector.java   
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);
}
项目:consulo-ui-designer    文件:Java15FormInspection.java   
@Override
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector)
{
    final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
    final PsiManager psiManager = PsiManager.getInstance(module.getProject());
    final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
    if(aClass == null)
    {
        return;
    }

    for(final IProperty prop : component.getModifiedProperties())
    {
        final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
        if(getter == null)
        {
            continue;
        }
        final LanguageLevel languageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
        if(Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel))
        {
            registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
        }
    }
}
项目:consulo-ui-designer    文件:FormInspectionUtil.java   
@Nullable public static String getText(@NotNull final Module module, final IComponent component) {
  IProperty textProperty = findProperty(component, SwingProperties.TEXT);
  if (textProperty != null) {
    Object propValue = textProperty.getPropertyValue(component);
    String value = null;
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor) propValue;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
    }
    else if (propValue instanceof String) {
      value = (String) propValue;
    }
    if (value != null) {
      return value;
    }
  }
  return null;
}
项目:consulo-ui-designer    文件:MissingMnemonicInspection.java   
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
  String value = FormInspectionUtil.getText(module, component);
  if (value == null) {
    return;
  }
  IProperty textProperty = FormInspectionUtil.findProperty(component, SwingProperties.TEXT);
  SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
  if (twm.myMnemonicIndex < 0 && twm.myText.length() > 0) {
    if (FormInspectionUtil.isComponentClass(module, component, AbstractButton.class)) {
      collector.addError(getID(), component, textProperty,
                         UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                         new MyEditorQuickFixProvider());
    }
    else if (FormInspectionUtil.isComponentClass(module, component, JLabel.class)) {
      IProperty labelForProperty = FormInspectionUtil.findProperty(component, SwingProperties.LABEL_FOR);
      if (labelForProperty != null && !StringUtil.isEmpty((String) labelForProperty.getPropertyValue(component))) {
        collector.addError(getID(), component, textProperty,
                           UIDesignerBundle.message("inspection.missing.mnemonics.message", value),
                           new MyEditorQuickFixProvider());
      }
    }
  }
}
项目:intellij-ce-playground    文件:GuiEditor.java   
private void refreshProperties() {
  final Ref<Boolean> anythingModified = new Ref<Boolean>();
  FormEditingUtil.iterate(myRootContainer, new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      final RadComponent radComponent = (RadComponent)component;
      boolean componentModified = false;
      for (IProperty prop : component.getModifiedProperties()) {
        if (prop instanceof IntroStringProperty) {
          IntroStringProperty strProp = (IntroStringProperty)prop;
          componentModified = strProp.refreshValue(radComponent) || componentModified;
        }
      }

      if (component instanceof RadContainer) {
        componentModified = ((RadContainer)component).updateBorder() || componentModified;
      }

      if (component.getParentContainer() instanceof RadTabbedPane) {
        componentModified = ((RadTabbedPane)component.getParentContainer()).refreshChildTitle(radComponent) || componentModified;
      }
      if (componentModified) {
        anythingModified.set(Boolean.TRUE);
      }

      return true;
    }
  });
  if (!anythingModified.isNull()) {
    refresh();
    DesignerToolWindow designerToolWindow = DesignerToolWindowManager.getInstance(this);
    ComponentTree tree = designerToolWindow.getComponentTree();
    if (tree != null) tree.repaint();
    PropertyInspector inspector = designerToolWindow.getPropertyInspector();
    if (inspector != null) inspector.synchWithTree(true);
  }
}
项目:intellij-ce-playground    文件:AssignMnemonicFix.java   
public void run() {
  IProperty textProperty = FormInspectionUtil.findProperty(myComponent, SwingProperties.TEXT);
  StringDescriptor descriptor = (StringDescriptor) textProperty.getPropertyValue(myComponent);
  String value = StringDescriptorManager.getInstance(myComponent.getModule()).resolve(myComponent, descriptor);
  String[] variants = fillMnemonicVariants(SupportCode.parseText(value).myText);
  String result = Messages.showEditableChooseDialog(UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.prompt"),
                                                    UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.title"),
                                                    Messages.getQuestionIcon(), variants, variants [0], null);
  if (result != null) {
    if (!myEditor.ensureEditable()) {
      return;
    }
    FormInspectionUtil.updateStringPropertyValue(myEditor, myComponent, (IntroStringProperty)textProperty, descriptor, result);
  }
}
项目:intellij-ce-playground    文件:FormFileErrorCollector.java   
public void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
                     @NotNull String errorMessage,
                     EditorQuickFixProvider... editorQuickFixProviders) {
  final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage),
                                                                                (LocalQuickFix)null,
                                                                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
  if (problemDescriptor instanceof ProblemDescriptorBase && component != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(myFile.getProject(), myFile.getVirtualFile(),
                                                                    component.getId());
    ((ProblemDescriptorBase) problemDescriptor).setNavigatable(navigatable);
  }
  myProblems.add(problemDescriptor);
}
项目:intellij-ce-playground    文件:FormInspectionUtil.java   
@Nullable
public static IProperty findProperty(final IComponent component, final String name) {
  IProperty[] props = component.getModifiedProperties();
  for(IProperty prop: props) {
    if (prop.getName().equals(name)) return prop;
  }
  return null;
}
项目:intellij-ce-playground    文件:RadLayoutManager.java   
protected static void ensureChildrenVisible(final RadContainer container) {
  if (container.getLayoutManager().areChildrenExclusive()) {
    // ensure that components which were hidden by previous layout are visible (IDEADEV-16077)
    for (RadComponent child : container.getComponents()) {
      final IProperty property = FormInspectionUtil.findProperty(child, SwingProperties.VISIBLE);
      if (property == null || property.getPropertyValue(child) == Boolean.TRUE) {
        child.getDelegee().setVisible(true);
      }
    }
  }
}
项目:intellij-ce-playground    文件:InvalidPropertyKeyFormInspection.java   
protected void checkStringDescriptor(final Module module,
                                     final IComponent component,
                                     final IProperty prop,
                                     final StringDescriptor descriptor,
                                     final FormErrorCollector collector) {
  String error = checkDescriptor(descriptor, module);
  if (error != null) {
    collector.addError(getID(), component, prop, error);
  }
}
项目:intellij-ce-playground    文件:InvalidPropertyKeyFormInspection.java   
@Nullable
private static String checkDescriptor(final StringDescriptor descriptor, final Module module) {
  final String bundleName = descriptor.getDottedBundleName();
  final String key = descriptor.getKey();
  if (bundleName == null && key == null) return null;
  if (bundleName == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.specified");
  }

  if (key == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.property.key.not.specified");
  }

  PropertiesReferenceManager manager = PropertiesReferenceManager.getInstance(module.getProject());
  List<PropertiesFile> propFiles = manager.findPropertiesFiles(module, bundleName);

  if (propFiles.size() == 0) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.found", bundleName);
  }

  for(PropertiesFile propFile: propFiles) {
    final com.intellij.lang.properties.IProperty property = propFile.findPropertyByKey(key);
    if (property == null) {
      return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.key.not.found",
                                       key, bundleName, propFile.getLocale().getDisplayName());
    }
  }
  return null;
}
项目:tools-idea    文件:GuiEditor.java   
private void refreshProperties() {
  final Ref<Boolean> anythingModified = new Ref<Boolean>();
  FormEditingUtil.iterate(myRootContainer, new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      final RadComponent radComponent = (RadComponent)component;
      boolean componentModified = false;
      for (IProperty prop : component.getModifiedProperties()) {
        if (prop instanceof IntroStringProperty) {
          IntroStringProperty strProp = (IntroStringProperty)prop;
          componentModified = strProp.refreshValue(radComponent) || componentModified;
        }
      }

      if (component instanceof RadContainer) {
        componentModified = ((RadContainer)component).updateBorder() || componentModified;
      }

      if (component.getParentContainer() instanceof RadTabbedPane) {
        componentModified = ((RadTabbedPane)component.getParentContainer()).refreshChildTitle(radComponent) || componentModified;
      }
      if (componentModified) {
        anythingModified.set(Boolean.TRUE);
      }

      return true;
    }
  });
  if (!anythingModified.isNull()) {
    refresh();
    final UIDesignerToolWindowManager twm = UIDesignerToolWindowManager.getInstance(getProject());
    twm.getComponentTree().repaint();
    twm.getPropertyInspector().synchWithTree(true);
  }
}
项目:tools-idea    文件:AssignMnemonicFix.java   
public void run() {
  IProperty textProperty = FormInspectionUtil.findProperty(myComponent, SwingProperties.TEXT);
  StringDescriptor descriptor = (StringDescriptor) textProperty.getPropertyValue(myComponent);
  String value = StringDescriptorManager.getInstance(myComponent.getModule()).resolve(myComponent, descriptor);
  String[] variants = fillMnemonicVariants(SupportCode.parseText(value).myText);
  String result = Messages.showEditableChooseDialog(UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.prompt"),
                                                    UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.title"),
                                                    Messages.getQuestionIcon(), variants, variants [0], null);
  if (result != null) {
    if (!myEditor.ensureEditable()) {
      return;
    }
    FormInspectionUtil.updateStringPropertyValue(myEditor, myComponent, (IntroStringProperty)textProperty, descriptor, result);
  }
}
项目:tools-idea    文件:FormFileErrorCollector.java   
public void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
                     @NotNull String errorMessage,
                     EditorQuickFixProvider... editorQuickFixProviders) {
  final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage),
                                                                                (LocalQuickFix)null,
                                                                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
  if (problemDescriptor instanceof ProblemDescriptorBase && component != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(myFile.getProject(), myFile.getVirtualFile(),
                                                                    component.getId());
    ((ProblemDescriptorBase) problemDescriptor).setNavigatable(navigatable);
  }
  myProblems.add(problemDescriptor);
}
项目:tools-idea    文件:FormInspectionUtil.java   
@Nullable
public static IProperty findProperty(final IComponent component, final String name) {
  IProperty[] props = component.getModifiedProperties();
  for(IProperty prop: props) {
    if (prop.getName().equals(name)) return prop;
  }
  return null;
}
项目:tools-idea    文件:RadLayoutManager.java   
protected static void ensureChildrenVisible(final RadContainer container) {
  if (container.getLayoutManager().areChildrenExclusive()) {
    // ensure that components which were hidden by previous layout are visible (IDEADEV-16077)
    for (RadComponent child : container.getComponents()) {
      final IProperty property = FormInspectionUtil.findProperty(child, SwingProperties.VISIBLE);
      if (property == null || property.getPropertyValue(child) == Boolean.TRUE) {
        child.getDelegee().setVisible(true);
      }
    }
  }
}
项目:tools-idea    文件:InvalidPropertyKeyFormInspection.java   
protected void checkStringDescriptor(final Module module,
                                     final IComponent component,
                                     final IProperty prop,
                                     final StringDescriptor descriptor,
                                     final FormErrorCollector collector) {
  String error = checkDescriptor(descriptor, module);
  if (error != null) {
    collector.addError(getID(), component, prop, error);
  }
}
项目:tools-idea    文件:InvalidPropertyKeyFormInspection.java   
@Nullable
private static String checkDescriptor(final StringDescriptor descriptor, final Module module) {
  final String bundleName = descriptor.getDottedBundleName();
  final String key = descriptor.getKey();
  if (bundleName == null && key == null) return null;
  if (bundleName == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.specified");
  }

  if (key == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.property.key.not.specified");
  }

  PropertiesReferenceManager manager = PropertiesReferenceManager.getInstance(module.getProject());
  List<PropertiesFile> propFiles = manager.findPropertiesFiles(module, bundleName);

  if (propFiles.size() == 0) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.found", bundleName);
  }

  for(PropertiesFile propFile: propFiles) {
    final com.intellij.lang.properties.IProperty property = propFile.findPropertyByKey(key);
    if (property == null) {
      return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.key.not.found",
                                       key, bundleName, propFile.getLocale().getDisplayName());
    }
  }
  return null;
}
项目:consulo-ui-designer    文件:AssignMnemonicFix.java   
public void run() {
  IProperty textProperty = FormInspectionUtil.findProperty(myComponent, SwingProperties.TEXT);
  StringDescriptor descriptor = (StringDescriptor) textProperty.getPropertyValue(myComponent);
  String value = StringDescriptorManager.getInstance(myComponent.getModule()).resolve(myComponent, descriptor);
  String[] variants = fillMnemonicVariants(SupportCode.parseText(value).myText);
  String result = Messages.showEditableChooseDialog(UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.prompt"),
                                                    UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.title"),
                                                    Messages.getQuestionIcon(), variants, variants [0], null);
  if (result != null) {
    if (!myEditor.ensureEditable()) {
      return;
    }
    FormInspectionUtil.updateStringPropertyValue(myEditor, myComponent, (IntroStringProperty)textProperty, descriptor, result);
  }
}
项目:consulo-ui-designer    文件:FormFileErrorCollector.java   
public void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
                     @NotNull String errorMessage,
                     EditorQuickFixProvider... editorQuickFixProviders) {
  final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage),
                                                                                (LocalQuickFix)null,
                                                                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
  if (problemDescriptor instanceof ProblemDescriptorBase && component != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(myFile.getProject(), myFile.getVirtualFile(),
                                                                    component.getId());
    ((ProblemDescriptorBase) problemDescriptor).setNavigatable(navigatable);
  }
  myProblems.add(problemDescriptor);
}
项目:consulo-ui-designer    文件:FormInspectionUtil.java   
@Nullable
public static IProperty findProperty(final IComponent component, final String name) {
  IProperty[] props = component.getModifiedProperties();
  for(IProperty prop: props) {
    if (prop.getName().equals(name)) return prop;
  }
  return null;
}
项目:consulo-ui-designer    文件:RadLayoutManager.java   
protected static void ensureChildrenVisible(final RadContainer container) {
  if (container.getLayoutManager().areChildrenExclusive()) {
    // ensure that components which were hidden by previous layout are visible (IDEADEV-16077)
    for (RadComponent child : container.getComponents()) {
      final IProperty property = FormInspectionUtil.findProperty(child, SwingProperties.VISIBLE);
      if (property == null || property.getPropertyValue(child) == Boolean.TRUE) {
        child.getDelegee().setVisible(true);
      }
    }
  }
}
项目:consulo-ui-designer    文件:InvalidPropertyKeyFormInspection.java   
protected void checkStringDescriptor(final Module module,
                                     final IComponent component,
                                     final IProperty prop,
                                     final StringDescriptor descriptor,
                                     final FormErrorCollector collector) {
  String error = checkDescriptor(descriptor, module);
  if (error != null) {
    collector.addError(getID(), component, prop, error);
  }
}