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


Java FormEditingUtil.iterate方法代码示例

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


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

示例1: retargetComponentProperties

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

示例2: setPreviewBindings

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
public static void setPreviewBindings(final LwRootContainer rootContainer, final String classToBindName) {
  // 1. Prepare form to preview. We have to change container so that it has only one binding.
  rootContainer.setClassToBind(classToBindName);
  FormEditingUtil.iterate(
    rootContainer,
    new FormEditingUtil.ComponentVisitor<LwComponent>() {
      public boolean visit(final LwComponent iComponent) {
        iComponent.setBinding(null);
        return true;
      }
    }
  );
  if (rootContainer.getComponentCount() == 1) {
    //noinspection HardCodedStringLiteral
    ((LwComponent)rootContainer.getComponent(0)).setBinding(PREVIEW_BINDING_FIELD);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PreviewFormAction.java

示例3: haveCustomComponents

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
private static boolean haveCustomComponents(final GuiEditor editor) {
  // quick & dirty check
  if (editor.isFormInvalid()) {
    return true;
  }
  final Ref<Boolean> result = new Ref<Boolean>();
  FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      if (component instanceof RadErrorComponent || !component.getComponentClassName().startsWith("javax.swing")) {
        result.set(Boolean.TRUE);
        return false;
      }
      return true;
    }
  });
  return !result.isNull();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ReloadCustomComponentsAction.java

示例4: createBoundFields

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
private void createBoundFields(final PsiClass formClass) throws IncorrectOperationException {
  final Module module = myEditor.getRootContainer().getModule();
  final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final PsiManager psiManager = PsiManager.getInstance(myEditor.getProject());

  final Ref<IncorrectOperationException> exception = new Ref<IncorrectOperationException>();
  FormEditingUtil.iterate(myEditor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
    public boolean visit(final IComponent component) {
      if (component.getBinding() != null) {
        final PsiClass fieldClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
        if (fieldClass != null) {
          PsiType fieldType = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createType(fieldClass);
          try {
            PsiField field = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createField(component.getBinding(), fieldType);
            formClass.add(field);
          }
          catch (IncorrectOperationException e) {
            exception.set(e);
            return false;
          }
        }
      }
      return true;
    }
  });

  if (!exception.isNull()) {
    throw exception.get();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:CreateClassToBindFix.java

示例5: actionPerformed

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  final ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
  builder.beginUpdateSelection();
  try {
    FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
      public boolean visit(final IComponent component) {
        ((RadComponent) component).setSelected(true);
        return true;
      }
    });
  }
  finally {
    builder.endUpdateSelection();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SelectAllComponentsAction.java

示例6: moveToFirstComponent

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
private void moveToFirstComponent(final JComponent rootContainerDelegee) {
  final int[] minX = new int[]{Integer.MAX_VALUE};
  final int[] minY = new int[]{Integer.MAX_VALUE};
  final Ref<RadComponent> componentToBeSelected = new Ref<RadComponent>();
  FormEditingUtil.iterate(
    myEditor.getRootContainer(),
    new FormEditingUtil.ComponentVisitor<RadComponent>() {
      public boolean visit(final RadComponent component) {
        if (component instanceof RadAtomicComponent) {
          final JComponent _delegee = component.getDelegee();
          final Point p = SwingUtilities.convertPoint(
            _delegee,
            new Point(0, 0),
            rootContainerDelegee
          );
          if(minX[0] > p.x || minY[0] > p.y){
            minX[0] = p.x;
            minY[0] = p.y;
            componentToBeSelected.set(component);
          }
        }
        return true;
      }
    }
  );
  if(!componentToBeSelected.isNull()){
    FormEditingUtil.selectComponent(myEditor, componentToBeSelected.get());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:AbstractMoveSelectionAction.java

示例7: checkFile

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
@Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  if (file.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) {
      return null;
    }
    final Module module = ModuleUtil.findModuleForFile(virtualFile, file.getProject());
    if (module == null) {
      return null;
    }

    final LwRootContainer rootContainer;
    try {
      rootContainer = Utils.getRootContainer(file.getText(), new PsiPropertiesProvider(module));
    }
    catch (Exception e) {
      return null;
    }

    if (rootContainer.isInspectionSuppressed(getShortName(), null)) {
      return null;
    }
    final FormFileErrorCollector collector = new FormFileErrorCollector(file, manager, isOnTheFly);
    startCheckForm(rootContainer);
    FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor() {
      public boolean visit(final IComponent component) {
        if (!rootContainer.isInspectionSuppressed(getShortName(), component.getId())) {
          checkComponentProperties(module, component, collector);
        }
        return true;
      }
    });
    doneCheckForm(rootContainer);
    return collector.result();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:BaseFormInspection.java

示例8: syncSelection

import com.intellij.uiDesigner.FormEditingUtil; //导入方法依赖的package包/类
/**
 * This method synchronizes selection in the tree with the selected
 * RadComponent in the component hierarchy
 */
private void syncSelection() {
  // Found selected components
  final RadContainer rootContainer=myEditor.getRootContainer();
  final ArrayList<RadComponent> selection = new ArrayList<RadComponent>();
  FormEditingUtil.iterate(
    rootContainer,
    new FormEditingUtil.ComponentVisitor<RadComponent>() {
      public boolean visit(final RadComponent component) {
        if(component.isSelected()){
          selection.add(component);
        }
        return true;
      }
    }
  );
  if(selection.size() == 0){
    // If there is no selected component in the hierarchy, then
    // we have to select RadRootContainer
    selection.add(rootContainer);
  }

  final ComponentPtr[] componentPtrs = new ComponentPtr[selection.size()];
  for (int i = 0; i < selection.size(); i++) {
    componentPtrs [i] = new ComponentPtr(myEditor, selection.get(i));
  }

  // Set selection in the tree
  select(componentPtrs, null);

  // Notify the ComponentTree that selected component changed
  myEditor.fireSelectedComponentChanged();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ComponentTreeBuilder.java

示例9: checkComponentProperties

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


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