Java 类com.intellij.uiDesigner.SwingProperties 实例源码

项目:intellij-ce-playground    文件:IntrospectedProperty.java   
@Override
public boolean appliesTo(final RadComponent component) {
  @NonNls String name = getName();
  //noinspection SimplifiableIfStatement
  if (name.equals(SwingProperties.PREFERRED_SIZE) ||
      name.equals(SwingProperties.MINIMUM_SIZE) ||
      name.equals(SwingProperties.MAXIMUM_SIZE)) {
    // our own properties must be used instead
    final RadContainer parent = component.getParent();
    return parent != null && !(parent.getLayoutManager() instanceof RadGridLayoutManager);
  }

  // check if property is available in the JDK used by the module containing the component
  final PsiManager psiManager = PsiManager.getInstance(component.getProject());
  final GlobalSearchScope scope = component.getModule().getModuleWithDependenciesAndLibrariesScope(true);
  PsiClass componentClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (componentClass == null) return true;
  final PsiMethod[] psiMethods = componentClass.findMethodsByName(myReadMethod.getName(), true);
  for(PsiMethod method: psiMethods) {
    if (!method.hasModifierProperty(PsiModifier.STATIC) &&
        method.getParameterList().getParametersCount() == 0) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:DuplicateMnemonicInspection.java   
@Nullable
public 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) {
    Object propValue = prop.getPropertyValue(component);
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor)propValue;
      String value;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
      SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
      if (twm.myMnemonicIndex >= 0 &&
          (FormInspectionUtil.isComponentClass(module, component, JLabel.class) || FormInspectionUtil.isComponentClass(module, component, AbstractButton.class))) {
        return twm;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:NoLabelForInspection.java   
public void run() {
  if (!myEditor.ensureEditable()) {
    return;
  }
  Runnable runnable = new Runnable() {
    public void run() {
      final Palette palette = Palette.getInstance(myEditor.getProject());
      IntrospectedProperty[] props = palette.getIntrospectedProperties(myLabel);
      boolean modified = false;
      for(IntrospectedProperty prop: props) {
        if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) prop;
          icp.setValueEx(myLabel, myComponent.getId());
          modified = true;
          break;
        }
      }
      if (modified) myEditor.refreshAndSave(false);
    }
  };
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), runnable,
                                                UIDesignerBundle.message("inspection.no.label.for.command"), null);
}
项目: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    文件:IntrospectedProperty.java   
@Override
public boolean appliesTo(final RadComponent component) {
  @NonNls String name = getName();
  //noinspection SimplifiableIfStatement
  if (name.equals(SwingProperties.PREFERRED_SIZE) ||
      name.equals(SwingProperties.MINIMUM_SIZE) ||
      name.equals(SwingProperties.MAXIMUM_SIZE)) {
    // our own properties must be used instead
    final RadContainer parent = component.getParent();
    return parent != null && !(parent.getLayoutManager() instanceof RadGridLayoutManager);
  }

  // check if property is available in the JDK used by the module containing the component
  final PsiManager psiManager = PsiManager.getInstance(component.getProject());
  final GlobalSearchScope scope = component.getModule().getModuleWithDependenciesAndLibrariesScope(true);
  PsiClass componentClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (componentClass == null) return true;
  final PsiMethod[] psiMethods = componentClass.findMethodsByName(myReadMethod.getName(), true);
  for(PsiMethod method: psiMethods) {
    if (!method.hasModifierProperty(PsiModifier.STATIC) &&
        method.getParameterList().getParametersCount() == 0) {
      return true;
    }
  }
  return false;
}
项目:tools-idea    文件:DuplicateMnemonicInspection.java   
@Nullable
public 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) {
    Object propValue = prop.getPropertyValue(component);
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor)propValue;
      String value;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
      SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
      if (twm.myMnemonicIndex >= 0 &&
          (FormInspectionUtil.isComponentClass(module, component, JLabel.class) || FormInspectionUtil.isComponentClass(module, component, AbstractButton.class))) {
        return twm;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:NoLabelForInspection.java   
public void run() {
  if (!myEditor.ensureEditable()) {
    return;
  }
  Runnable runnable = new Runnable() {
    public void run() {
      final Palette palette = Palette.getInstance(myEditor.getProject());
      IntrospectedProperty[] props = palette.getIntrospectedProperties(myLabel);
      boolean modified = false;
      for(IntrospectedProperty prop: props) {
        if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) prop;
          icp.setValueEx(myLabel, myComponent.getId());
          modified = true;
          break;
        }
      }
      if (modified) myEditor.refreshAndSave(false);
    }
  };
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), runnable,
                                                UIDesignerBundle.message("inspection.no.label.for.command"), null);
}
项目: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    文件:IntrospectedProperty.java   
@Override
public boolean appliesTo(final RadComponent component) {
  @NonNls String name = getName();
  //noinspection SimplifiableIfStatement
  if (name.equals(SwingProperties.PREFERRED_SIZE) ||
      name.equals(SwingProperties.MINIMUM_SIZE) ||
      name.equals(SwingProperties.MAXIMUM_SIZE)) {
    // our own properties must be used instead
    final RadContainer parent = component.getParent();
    return parent != null && !(parent.getLayoutManager() instanceof RadGridLayoutManager);
  }

  // check if property is available in the JDK used by the module containing the component
  final PsiManager psiManager = PsiManager.getInstance(component.getProject());
  final GlobalSearchScope scope = component.getModule().getModuleWithDependenciesAndLibrariesScope(true);
  PsiClass componentClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (componentClass == null) return true;
  final PsiMethod[] psiMethods = componentClass.findMethodsByName(myReadMethod.getName(), true);
  for(PsiMethod method: psiMethods) {
    if (!method.hasModifierProperty(PsiModifier.STATIC) &&
        method.getParameterList().getParametersCount() == 0) {
      return true;
    }
  }
  return false;
}
项目:consulo-ui-designer    文件:DuplicateMnemonicInspection.java   
@Nullable
public 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) {
    Object propValue = prop.getPropertyValue(component);
    if (propValue instanceof StringDescriptor) {
      StringDescriptor descriptor = (StringDescriptor)propValue;
      String value;
      if (component instanceof RadComponent) {
        value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor);
      }
      else {
        value = StringDescriptorManager.getInstance(module).resolve(descriptor, null);
      }
      SupportCode.TextWithMnemonic twm = SupportCode.parseText(value);
      if (twm.myMnemonicIndex >= 0 &&
          (FormInspectionUtil.isComponentClass(module, component, JLabel.class) || FormInspectionUtil.isComponentClass(module, component, AbstractButton.class))) {
        return twm;
      }
    }
  }
  return null;
}
项目:consulo-ui-designer    文件:NoLabelForInspection.java   
public void run() {
  if (!myEditor.ensureEditable()) {
    return;
  }
  Runnable runnable = new Runnable() {
    public void run() {
      final Palette palette = Palette.getInstance(myEditor.getProject());
      IntrospectedProperty[] props = palette.getIntrospectedProperties(myLabel);
      boolean modified = false;
      for(IntrospectedProperty prop: props) {
        if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
          IntroComponentProperty icp = (IntroComponentProperty) prop;
          icp.setValueEx(myLabel, myComponent.getId());
          modified = true;
          break;
        }
      }
      if (modified) myEditor.refreshAndSave(false);
    }
  };
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), runnable,
                                                UIDesignerBundle.message("inspection.no.label.for.command"), null);
}
项目: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    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:intellij-ce-playground    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目: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    文件: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    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:tools-idea    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目: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    文件: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    文件:IntroDimensionProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  if (getName().equals(SwingProperties.MINIMUM_SIZE) ||
      getName().equals(SwingProperties.MAXIMUM_SIZE) ||
      getName().equals(SwingProperties.PREFERRED_SIZE)) {
    return;
  }
  super.importSnapshotValue(context, component, radComponent);
}
项目:consulo-ui-designer    文件:IntroIntProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  // exclude property from snapshot import to avoid exceptions because of not imported model 
  if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
    super.importSnapshotValue(context, component, radComponent);
  }
}
项目: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    文件: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    文件:IntroComponentProperty.java   
@Override protected void setValueImpl(final RadComponent component, final String value) throws Exception {
  component.getDelegee().putClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName(), value);
  if (getName().equals(SwingProperties.LABEL_FOR) && !component.isLoadingProperties() && component.getModule() != null) {
    updateLabelForBinding(component);
  }
}
项目:intellij-ce-playground    文件:Painter.java   
public static void paintComponentTag(final RadComponent component, final Graphics g) {
  if (component instanceof RadContainer) return;
  for (IProperty prop : component.getModifiedProperties()) {
    if (prop.getName().equals(SwingProperties.TEXT)) {
      final Object desc = prop.getPropertyValue(component);
      if (!(desc instanceof StringDescriptor) || ((StringDescriptor)desc).getValue() == null ||
          ((StringDescriptor)desc).getValue().length() > 0) {
        return;
      }
    }
    else if (prop.getName().equals(SwingProperties.MODEL)) {
      // don't paint tags on non-empty lists
      final Object value = prop.getPropertyValue(component);
      if (value instanceof String[] && ((String[])value).length > 0) {
        return;
      }
    }
  }

  Rectangle bounds = component.getDelegee().getBounds();
  if (bounds.width > 100 && bounds.height > 40) {
    StringBuilder tagBuilder = new StringBuilder();
    if (component.getBinding() != null) {
      tagBuilder.append(component.getBinding()).append(':');
    }
    String className = component.getComponentClassName();
    int pos = className.lastIndexOf('.');
    if (pos >= 0) {
      tagBuilder.append(className.substring(pos + 1));
    }
    else {
      tagBuilder.append(className);
    }
    final Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(tagBuilder.toString(), g);
    Graphics2D g2d = (Graphics2D)g;
    g2d.setColor(PlatformColors.BLUE);
    g2d.fillRect(0, 0, (int)stringBounds.getWidth(), (int)stringBounds.getHeight());
    g2d.setColor(JBColor.WHITE);
    UISettings.setupAntialiasing(g);
    g.drawString(tagBuilder.toString(), 0, g.getFontMetrics().getAscent());
  }
}
项目:intellij-ce-playground    文件:NoLabelForInspection.java   
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);
    }
  }
}
项目:tools-idea    文件:IntroComponentProperty.java   
@Override protected void setValueImpl(final RadComponent component, final String value) throws Exception {
  component.getDelegee().putClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName(), value);
  if (getName().equals(SwingProperties.LABEL_FOR) && !component.isLoadingProperties() && component.getModule() != null) {
    updateLabelForBinding(component);
  }
}
项目:tools-idea    文件:Painter.java   
public static void paintComponentTag(final RadComponent component, final Graphics g) {
  if (component instanceof RadContainer) return;
  for (IProperty prop : component.getModifiedProperties()) {
    if (prop.getName().equals(SwingProperties.TEXT)) {
      final Object desc = prop.getPropertyValue(component);
      if (!(desc instanceof StringDescriptor) || ((StringDescriptor)desc).getValue() == null ||
          ((StringDescriptor)desc).getValue().length() > 0) {
        return;
      }
    }
    else if (prop.getName().equals(SwingProperties.MODEL)) {
      // don't paint tags on non-empty lists
      final Object value = prop.getPropertyValue(component);
      if (value instanceof String[] && ((String[])value).length > 0) {
        return;
      }
    }
  }

  Rectangle bounds = component.getDelegee().getBounds();
  if (bounds.width > 100 && bounds.height > 40) {
    StringBuilder tagBuilder = new StringBuilder();
    if (component.getBinding() != null) {
      tagBuilder.append(component.getBinding()).append(':');
    }
    String className = component.getComponentClassName();
    int pos = className.lastIndexOf('.');
    if (pos >= 0) {
      tagBuilder.append(className.substring(pos + 1));
    }
    else {
      tagBuilder.append(className);
    }
    final Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(tagBuilder.toString(), g);
    Graphics2D g2d = (Graphics2D)g;
    g2d.setColor(PlatformColors.BLUE);
    g2d.fillRect(0, 0, (int)stringBounds.getWidth(), (int)stringBounds.getHeight());
    g2d.setColor(Color.WHITE);
    g.drawString(tagBuilder.toString(), 0, g.getFontMetrics().getAscent());
  }
}
项目:tools-idea    文件:NoLabelForInspection.java   
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);
    }
  }
}
项目:consulo-ui-designer    文件:IntroComponentProperty.java   
@Override protected void setValueImpl(final RadComponent component, final String value) throws Exception {
  component.getDelegee().putClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName(), value);
  if (getName().equals(SwingProperties.LABEL_FOR) && !component.isLoadingProperties() && component.getModule() != null) {
    updateLabelForBinding(component);
  }
}
项目:consulo-ui-designer    文件:Painter.java   
public static void paintComponentTag(final RadComponent component, final Graphics g) {
  if (component instanceof RadContainer) return;
  for (IProperty prop : component.getModifiedProperties()) {
    if (prop.getName().equals(SwingProperties.TEXT)) {
      final Object desc = prop.getPropertyValue(component);
      if (!(desc instanceof StringDescriptor) || ((StringDescriptor)desc).getValue() == null ||
          ((StringDescriptor)desc).getValue().length() > 0) {
        return;
      }
    }
    else if (prop.getName().equals(SwingProperties.MODEL)) {
      // don't paint tags on non-empty lists
      final Object value = prop.getPropertyValue(component);
      if (value instanceof String[] && ((String[])value).length > 0) {
        return;
      }
    }
  }

  Rectangle bounds = component.getDelegee().getBounds();
  if (bounds.width > 100 && bounds.height > 40) {
    StringBuilder tagBuilder = new StringBuilder();
    if (component.getBinding() != null) {
      tagBuilder.append(component.getBinding()).append(':');
    }
    String className = component.getComponentClassName();
    int pos = className.lastIndexOf('.');
    if (pos >= 0) {
      tagBuilder.append(className.substring(pos + 1));
    }
    else {
      tagBuilder.append(className);
    }
    final Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(tagBuilder.toString(), g);
    Graphics2D g2d = (Graphics2D)g;
    g2d.setColor(PlatformColors.BLUE);
    g2d.fillRect(0, 0, (int)stringBounds.getWidth(), (int)stringBounds.getHeight());
    g2d.setColor(Color.WHITE);
    g.drawString(tagBuilder.toString(), 0, g.getFontMetrics().getAscent());
  }
}
项目:consulo-ui-designer    文件:NoLabelForInspection.java   
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);
    }
  }
}