Java 类com.intellij.uiDesigner.inspections.FormInspectionUtil 实例源码

项目:intellij-ce-playground    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:tools-idea    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:consulo-ui-designer    文件:IntroComponentProperty.java   
void updateLabelForBinding(final RadComponent component) {
  String value = getValue(component);
  String text = FormInspectionUtil.getText(component.getModule(), component);
  if (text != null && value != null) {
    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    if (root != null) {
      RadComponent valueComponent = (RadComponent)FormEditingUtil.findComponent(root, value);
      if (valueComponent != null) {
        if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
          valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
        }
        BindingProperty.checkCreateBindingFromText(valueComponent, text);
      }
    }
  }
}
项目:intellij-ce-playground    文件:BindingProperty.java   
public static String getDefaultBinding(final RadComponent c) {
  RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(c);
  String binding = null;
  String text = FormInspectionUtil.getText(c.getModule(), c);
  if (text != null) {
    binding = suggestBindingFromText(c, text);
  }
  if (binding == null) {
    binding = InsertComponentProcessor.suggestBinding(root, c.getComponentClassName());
  }
  return binding;
}
项目: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    文件:BindingProperty.java   
public static String getDefaultBinding(final RadComponent c) {
  RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(c);
  String binding = null;
  String text = FormInspectionUtil.getText(c.getModule(), c);
  if (text != null) {
    binding = suggestBindingFromText(c, text);
  }
  if (binding == null) {
    binding = InsertComponentProcessor.suggestBinding(root, c.getComponentClassName());
  }
  return binding;
}
项目: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    文件:BindingProperty.java   
public static String getDefaultBinding(final RadComponent c) {
  RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(c);
  String binding = null;
  String text = FormInspectionUtil.getText(c.getModule(), c);
  if (text != null) {
    binding = suggestBindingFromText(c, text);
  }
  if (binding == null) {
    binding = InsertComponentProcessor.suggestBinding(root, c.getComponentClassName());
  }
  return binding;
}
项目: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    文件:BindingEditor.java   
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;
}
项目:intellij-ce-playground    文件:MorphAction.java   
private static boolean morphComponent(final GuiEditor editor, final RadComponent oldComponent, ComponentItem targetItem) {
  targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor, targetItem, "Morph to Non-Palette Component");
  if (targetItem == null) {
    return false;
  }
  final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor, targetItem);
  if (newComponent == null) return false;
  newComponent.setBinding(oldComponent.getBinding());
  newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints());
  newComponent.getConstraints().restore(oldComponent.getConstraints());

  updateBoundFieldType(editor, oldComponent, targetItem);

  final IProperty[] oldProperties = oldComponent.getModifiedProperties();
  final Palette palette = Palette.getInstance(editor.getProject());
  for(IProperty prop: oldProperties) {
    IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent, prop.getName());
    if (newProp == null || !prop.getClass().equals(newProp.getClass())) continue;
    Object oldValue = prop.getPropertyValue(oldComponent);
    try {
      //noinspection unchecked
      newProp.setValue(newComponent, oldValue);
    }
    catch (Exception e) {
      // ignore
    }
  }

  retargetComponentProperties(editor, oldComponent, newComponent);
  final RadContainer parent = oldComponent.getParent();
  int index = parent.indexOfComponent(oldComponent);
  parent.removeComponent(oldComponent);
  parent.addComponent(newComponent, index);
  newComponent.setSelected(true);

  if (oldComponent.isDefaultBinding()) {
    final String text = FormInspectionUtil.getText(newComponent.getModule(), newComponent);
    if (text != null) {
      String binding = BindingProperty.suggestBindingFromText(newComponent, text);
      if (binding != null) {
        new BindingProperty(newComponent.getProject()).setValueEx(newComponent, binding);
      }
    }
    newComponent.setDefaultBinding(true);
  }
  return true;
}
项目:tools-idea    文件:BindingEditor.java   
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;
}
项目:tools-idea    文件:MorphAction.java   
private static boolean morphComponent(final GuiEditor editor, final RadComponent oldComponent, ComponentItem targetItem) {
  targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor, targetItem, "Morph to Non-Palette Component");
  if (targetItem == null) {
    return false;
  }
  final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor, targetItem);
  if (newComponent == null) return false;
  newComponent.setBinding(oldComponent.getBinding());
  newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints());
  newComponent.getConstraints().restore(oldComponent.getConstraints());

  updateBoundFieldType(editor, oldComponent, targetItem);

  final IProperty[] oldProperties = oldComponent.getModifiedProperties();
  final Palette palette = Palette.getInstance(editor.getProject());
  for(IProperty prop: oldProperties) {
    IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent, prop.getName());
    if (newProp == null || !prop.getClass().equals(newProp.getClass())) continue;
    Object oldValue = prop.getPropertyValue(oldComponent);
    try {
      //noinspection unchecked
      newProp.setValue(newComponent, oldValue);
    }
    catch (Exception e) {
      // ignore
    }
  }

  retargetComponentProperties(editor, oldComponent, newComponent);
  final RadContainer parent = oldComponent.getParent();
  int index = parent.indexOfComponent(oldComponent);
  parent.removeComponent(oldComponent);
  parent.addComponent(newComponent, index);
  newComponent.setSelected(true);

  if (oldComponent.isDefaultBinding()) {
    final String text = FormInspectionUtil.getText(newComponent.getModule(), newComponent);
    if (text != null) {
      String binding = BindingProperty.suggestBindingFromText(newComponent, text);
      if (binding != null) {
        new BindingProperty(newComponent.getProject()).setValueEx(newComponent, binding);
      }
    }
    newComponent.setDefaultBinding(true);
  }
  return true;
}
项目:consulo-ui-designer    文件:MorphAction.java   
private static boolean morphComponent(final GuiEditor editor, final RadComponent oldComponent, ComponentItem targetItem) {
  targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor, targetItem, "Morph to Non-Palette Component");
  if (targetItem == null) {
    return false;
  }
  final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor, targetItem);
  if (newComponent == null) return false;
  newComponent.setBinding(oldComponent.getBinding());
  newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints());
  newComponent.getConstraints().restore(oldComponent.getConstraints());

  updateBoundFieldType(editor, oldComponent, targetItem);

  final IProperty[] oldProperties = oldComponent.getModifiedProperties();
  final Palette palette = Palette.getInstance(editor.getProject());
  for(IProperty prop: oldProperties) {
    IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent, prop.getName());
    if (newProp == null || !prop.getClass().equals(newProp.getClass())) continue;
    Object oldValue = prop.getPropertyValue(oldComponent);
    try {
      //noinspection unchecked
      newProp.setValue(newComponent, oldValue);
    }
    catch (Exception e) {
      // ignore
    }
  }

  retargetComponentProperties(editor, oldComponent, newComponent);
  final RadContainer parent = oldComponent.getParent();
  int index = parent.indexOfComponent(oldComponent);
  parent.removeComponent(oldComponent);
  parent.addComponent(newComponent, index);
  newComponent.setSelected(true);

  if (oldComponent.isDefaultBinding()) {
    final String text = FormInspectionUtil.getText(newComponent.getModule(), newComponent);
    if (text != null) {
      String binding = BindingProperty.suggestBindingFromText(newComponent, text);
      if (binding != null) {
        new BindingProperty(newComponent.getProject()).setValueEx(newComponent, binding);
      }
    }
    newComponent.setDefaultBinding(true);
  }
  return true;
}