当前位置: 首页>>代码示例>>Java>>正文


Java FormEditingUtil.getRoot方法代码示例

本文整理汇总了Java中com.intellij.uiDesigner.FormEditingUtil.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java FormEditingUtil.getRoot方法的具体用法?Java FormEditingUtil.getRoot怎么用?Java FormEditingUtil.getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.uiDesigner.FormEditingUtil的用法示例。


在下文中一共展示了FormEditingUtil.getRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkCreateBindingFromText

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
public static void checkCreateBindingFromText(final RadComponent component, final String text) {
  if (!component.isDefaultBinding()) {
    return;
  }
  RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(component);
  PsiField boundField = findBoundField(root, component.getBinding());
  if (boundField == null || !isFieldUnreferenced(boundField)) {
    return;
  }

  String binding = suggestBindingFromText(component, text);
  if (binding != null) {
    new BindingProperty(component.getProject()).setValueEx(component, binding);
    // keep the binding marked as default
    component.setDefaultBinding(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:BindingProperty.java

示例2: updateLabelForBinding

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IntroComponentProperty.java

示例3: setValueImpl

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
protected void setValueImpl(final RadComponent component, final String value) throws Exception {
  if (Comparing.strEqual(value, component.getBinding(), true)) {
    return;
  }

  if (value.length() > 0 && !PsiNameHelper.getInstance(component.getProject()).isIdentifier(value)) {
    throw new Exception("Value '" + value + "' is not a valid identifier");
  }

  final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
  final String oldBinding = getValue(component);

  // Check that binding remains unique

  if (value.length() > 0) {
    if (!FormEditingUtil.isBindingUnique(component, value, root)) {
      throw new Exception(UIDesignerBundle.message("error.binding.not.unique"));
    }

    component.setBinding(value);
    component.setDefaultBinding(false);
  }
  else {
    if (component.isCustomCreateRequired()) {
      throw new Exception(UIDesignerBundle.message("error.custom.create.binding.required"));
    }
    component.setBinding(null);
    component.setCustomCreate(false);
  }

  // Set new value or rename old one. It means that previous binding exists
  // and the new one doesn't exist we need to ask user to create new field
  // or rename old one.

  updateBoundFieldName(root, oldBinding, value, component.getComponentClassName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:BindingProperty.java

示例4: suggestBindingFromText

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
@Nullable
public static String suggestBindingFromText(final RadComponent component, String text) {
  if (StringUtil.startsWithIgnoreCase(text, PREFIX_HTML)) {
    text = Pattern.compile("<.+?>").matcher(text).replaceAll("");
  }
  ArrayList<String> words = new ArrayList<String>(StringUtil.getWordsIn(text));
  if (words.size() > 0) {
    StringBuilder nameBuilder = new StringBuilder(StringUtil.decapitalize(words.get(0)));
    for(int i=1; i<words.size() && i < 4; i++) {
      nameBuilder.append(StringUtil.capitalize(words.get(i)));
    }
    final String shortClassName = StringUtil.capitalize(InsertComponentProcessor.getShortClassName(component.getComponentClassName()));
    if (shortClassName.equalsIgnoreCase(nameBuilder.toString())) {
      // avoid "buttonButton" case
      return null;
    }
    nameBuilder.append(shortClassName);

    RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
    Project project = root.getProject();
    String binding = JavaCodeStyleManager.getInstance(project).propertyNameToVariableName(nameBuilder.toString(), VariableKind.FIELD);
    if (FormEditingUtil.findComponentWithBinding(root, binding, component) != null) {
      binding = InsertComponentProcessor.getUniqueBinding(root, nameBuilder.toString());
    }
    return binding;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:BindingProperty.java

示例5: getDefaultBinding

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:BindingProperty.java

示例6: setValueImpl

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
protected void setValueImpl(final RadComponent component, final Boolean value) throws Exception {
  if (value.booleanValue() && component.getBinding() == null) {
    String initialBinding = BindingProperty.getDefaultBinding(component);
    String binding = Messages.showInputDialog(
      component.getProject(),
      UIDesignerBundle.message("custom.create.field.name.prompt"),
      UIDesignerBundle.message("custom.create.title"), Messages.getQuestionIcon(),
      initialBinding, new IdentifierValidator(component.getProject()));
    if (binding == null) {
      return;
    }
    try {
      new BindingProperty(component.getProject()).setValue(component, binding);
    }
    catch (Exception e1) {
      LOG.error(e1);
    }
  }
  component.setCustomCreate(value.booleanValue());
  if (value.booleanValue()) {
    final IRootContainer root = FormEditingUtil.getRoot(component);
    if (root.getClassToBind() != null && Utils.getCustomCreateComponentCount(root) == 1) {
      final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), root.getClassToBind());
      if (aClass != null && FormEditingUtil.findCreateComponentsMethod(aClass) == null) {
        generateCreateComponentsMethod(aClass);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:CustomCreateProperty.java

示例7: canCreateListener

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
private static boolean canCreateListener(final ArrayList<RadComponent> selection) {
  if (selection.size() == 0) return false;
  final RadRootContainer root = (RadRootContainer)FormEditingUtil.getRoot(selection.get(0));
  if (root.getClassToBind() == null) return false;
  String componentClass = selection.get(0).getComponentClassName();
  for(RadComponent c: selection) {
    if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null) return false;
    if (BindingProperty.findBoundField(root, c.getBinding()) == null) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:CreateListenerAction.java

示例8: prepareActionGroup

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
@Nullable
public static DefaultActionGroup prepareActionGroup(final RadComponent component) {
  final IRootContainer root = FormEditingUtil.getRoot(component);
  final String classToBind = root == null ? null : root.getClassToBind();
  if (classToBind != null) {
    final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), classToBind);
    if (aClass != null) {
      final PsiField boundField = aClass.findFieldByName(component.getBinding(), false);
      if (boundField != null) {
        return buildNavigateActionGroup(component, boundField);
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ListenerNavigateButton.java

示例9: checkComponentProperties

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
  if (FormInspectionUtil.isComponentClass(module, component, JRadioButton.class)) {
    final IRootContainer root = FormEditingUtil.getRoot(component);
    if (root == null) return;
    if (root.getButtonGroupName(component) == null) {
      EditorQuickFixProvider quickFixProvider = null;
      IContainer parent = component.getParentContainer();
      for(int i=0; i<parent.getComponentCount(); i++) {
        IComponent child = parent.getComponent(i);
        if (child != component &&
            FormInspectionUtil.isComponentClass(module, child, JRadioButton.class)) {
          final GridConstraints c1 = component.getConstraints();
          final GridConstraints c2 = child.getConstraints();
          if (areCellsAdjacent(parent, c1, c2)) {
            final String groupName = root.getButtonGroupName(child);
            if (groupName == null) {
              quickFixProvider = new EditorQuickFixProvider() {
                 public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
                   return new CreateGroupQuickFix(editor, component, c1.getColumn() == c2.getColumn());
                 }
               };
              break;
            }
            else {
              quickFixProvider = new EditorQuickFixProvider() {
                public QuickFix createQuickFix(GuiEditor editor, RadComponent component) {
                  return new AddToGroupQuickFix(editor, component, groupName);
                }
              };
            }
          }
        }
      }
      collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.no.button.group.error"), quickFixProvider);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:NoButtonGroupInspection.java

示例10: run

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
public void run() {
  RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(myComponent);
  if (root == null) return;
  for(RadButtonGroup group: root.getButtonGroups()) {
    if (group.getName().equals(myGroupName)) {
      root.setGroupForComponent(myComponent, group);
      break;
    }
  }
  myEditor.refreshAndSave(true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:NoButtonGroupInspection.java

示例11: checkComponentProperties

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
protected void checkComponentProperties(Module module, IComponent component, FormErrorCollector collector) {
  final IRootContainer root = FormEditingUtil.getRoot(component);
  if (root == null) return;
  String groupName = root.getButtonGroupName(component);
  if (groupName != null) {
    final String[] sameGroupComponents = root.getButtonGroupComponentIds(groupName);
    for(String id: sameGroupComponents) {
      final IComponent otherComponent = FormEditingUtil.findComponent(root, id);
      if (otherComponent != null && otherComponent != component) {
        return;
      }
    }
    collector.addError(getID(), component, null, UIDesignerBundle.message("inspection.one.button.group.error"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:OneButtonGroupInspection.java

示例12: getValue

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
public RadButtonGroup getValue(RadComponent component) {
  final RadRootContainer rootContainer = (RadRootContainer) FormEditingUtil.getRoot(component);
  return rootContainer == null ? null : (RadButtonGroup) FormEditingUtil.findGroupForComponent(rootContainer, component);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ButtonGroupProperty.java

示例13: getComponent

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
public JComponent getComponent(RadComponent component, RadButtonGroup value, InplaceContext inplaceContext) {
  myComponent = component;
  myRootContainer = (RadRootContainer) FormEditingUtil.getRoot(myComponent);
  updateModel();
  return myCbx;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:ButtonGroupProperty.java

示例14: setValueFromComponent

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
@Override
protected void setValueFromComponent(final RadComponent component, final T value) {
  RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
  JLabel label = myRenderer.getComponent(root, value, false, false);
  myTf.setText(label.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:IntRegexEditor.java

示例15: getFieldNames

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:75,代码来源:BindingEditor.java


注:本文中的com.intellij.uiDesigner.FormEditingUtil.getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。