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


Java FxmlConstants类代码示例

本文整理汇总了Java中org.jetbrains.plugins.javaFX.fxml.FxmlConstants的典型用法代码示例。如果您正苦于以下问题:Java FxmlConstants类的具体用法?Java FxmlConstants怎么用?Java FxmlConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: invoke

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
  final XmlTag tag = (XmlTag)element.getParent();
  final String value;
  if (tag.getSubTags().length == 0) {
    value = tag.getValue().getText().trim();
  }
  else {
    value = StringUtil.join(tag.getSubTags(), new Function<XmlTag, String>() {
      @Override
      public String fun(XmlTag childTag) {
        final XmlAttribute valueAttr = childTag.getAttribute(FxmlConstants.FX_VALUE);
        if (valueAttr != null) {
          return valueAttr.getValue();
        }
        return "";
      }
    }, ", ");
  }
  final XmlAttribute attribute = XmlElementFactory.getInstance(project).createXmlAttribute(tag.getName(), value);
  final XmlTag parentTag = tag.getParentTag();
  parentTag.add(attribute);
  tag.delete();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaFxCollapseSubTagToAttributeIntention.java

示例2: isAvailable

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
  if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_NAME && element.getParent() instanceof XmlTag) {
    final XmlTag tag = (XmlTag)element.getParent();
    for (XmlTag xmlTag : tag.getSubTags()) {
      if (xmlTag.getAttribute(FxmlConstants.FX_VALUE) == null) return false;
    }
    final XmlTag parentTag = tag.getParentTag();
    if (parentTag != null &&
        tag.getDescriptor() instanceof JavaFxPropertyElementDescriptor &&
        parentTag.getDescriptor() instanceof JavaFxClassBackedElementDescriptor) {

      setText("Collapse tag '" + tag.getName() + "' to attribute");
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaFxCollapseSubTagToAttributeIntention.java

示例3: collectTargets

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
private static <T> void collectTargets(PsiField field, final ArrayList<T> targets, final Function<PsiElement, T> fun, final boolean stopAtFirst) {
  final PsiClass containingClass = field.getContainingClass();
  LOG.assertTrue(containingClass != null);
  final String qualifiedName = containingClass.getQualifiedName();
  LOG.assertTrue(qualifiedName != null);
  final List<VirtualFile> fxmls = JavaFxControllerClassIndex.findFxmlsWithController(field.getProject(), qualifiedName);
  if (fxmls.isEmpty()) return;
  ReferencesSearch.search(field, GlobalSearchScope.filesScope(field.getProject(), fxmls)).forEach(
    new Processor<PsiReference>() {
      @Override
      public boolean process(PsiReference reference) {
        final PsiElement referenceElement = reference.getElement();
        if (referenceElement == null) return true;
        final PsiFile containingFile = referenceElement.getContainingFile();
        if (containingFile == null) return true;
        if (!JavaFxFileTypeFactory.isFxml(containingFile)) return true;
        if (!(referenceElement instanceof XmlAttributeValue)) return true;
        final XmlAttributeValue attributeValue = (XmlAttributeValue)referenceElement;
        final PsiElement parent = attributeValue.getParent();
        if (!(parent instanceof XmlAttribute)) return true;
        if (!FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName())) return true;
        targets.add(fun.fun(parent));
        return !stopAtFirst;
      }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaFxRelatedItemLineMarkerProvider.java

示例4: getElementDescriptor

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Nullable
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
  final String name = childTag.getName();
  if (FxmlConstants.FX_DEFINE.equals(myName)) {
    if (FxmlConstants.FX_DEFAULT_ELEMENTS.contains(name)) {
      return new JavaFxDefaultPropertyElementDescriptor(name, childTag);
    }
    return new JavaFxClassBackedElementDescriptor(name, childTag);
  }

  if (FxmlConstants.FX_ROOT.equals(myName)) {
    final JavaFxClassBackedElementDescriptor tagDescriptor = getRootTagDescriptor(contextTag);
    if (tagDescriptor != null) {
      return tagDescriptor.getElementDescriptor(childTag, contextTag);
    }
    return new JavaFxClassBackedElementDescriptor(name, childTag);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaFxDefaultPropertyElementDescriptor.java

示例5: getReferencedTag

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Nullable
public static XmlTag getReferencedTag(XmlTag tag) {
  final String tagName = tag.getName();
  if (FxmlConstants.FX_REFERENCE.equals(tagName) || FxmlConstants.FX_COPY.equals(tagName)) {
    final XmlAttribute attribute = tag.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE);
    if (attribute != null) {
      final XmlAttributeValue valueElement = attribute.getValueElement();
      if (valueElement != null) {
        final PsiReference reference = valueElement.getReference();
        if (reference != null) {
          final PsiElement resolve = reference.resolve();
          if (resolve instanceof XmlAttributeValue) {
            return PsiTreeUtil.getParentOfType(resolve, XmlTag.class);
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaFxDefaultPropertyElementDescriptor.java

示例6: getIncludedRoot

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
public static XmlTag getIncludedRoot(XmlTag context) {
  if (context == null) return null;
  final XmlAttribute xmlAttribute = context.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE);
  if (xmlAttribute != null) {
    final XmlAttributeValue valueElement = xmlAttribute.getValueElement();
    if (valueElement != null) {
      final PsiReference reference = valueElement.getReference();
      if (reference != null) {
        final PsiElement resolve = reference.resolve();
        if (resolve instanceof XmlFile) {
          final XmlTag rootTag = ((XmlFile)resolve).getRootTag();
          if (rootTag != null) {
            return rootTag;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaFxDefaultPropertyElementDescriptor.java

示例7: getAttributesDescriptors

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Override
public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
  if (context != null) {
    final String name = context.getName();
    if (Comparing.equal(name, getName()) && myPsiClass != null) {
      final List<XmlAttributeDescriptor> simpleAttrs = new ArrayList<XmlAttributeDescriptor>();
      collectInstanceProperties(simpleAttrs);
      collectStaticAttributesDescriptors(context, simpleAttrs);
      for (String defaultProperty : FxmlConstants.FX_DEFAULT_PROPERTIES) {
        simpleAttrs.add(new JavaFxDefaultAttributeDescriptor(defaultProperty, myPsiClass));
      }
      return simpleAttrs.isEmpty() ? XmlAttributeDescriptor.EMPTY : simpleAttrs.toArray(new XmlAttributeDescriptor[simpleAttrs.size()]);
    }
  }
  return XmlAttributeDescriptor.EMPTY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaFxClassBackedElementDescriptor.java

示例8: getAttributeDescriptor

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Nullable
@Override
public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) {
  if (myPsiClass == null) return null;
  if (myPsiClass.findFieldByName(attributeName, true) == null) {
    if (FxmlConstants.FX_DEFAULT_PROPERTIES.contains(attributeName)){
      return new JavaFxDefaultAttributeDescriptor(attributeName, myPsiClass);
    } else {
      final PsiMethod propertySetter = JavaFxPsiUtil.findPropertySetter(attributeName, context);
      if (propertySetter != null) {
        return new JavaFxStaticPropertyAttributeDescriptor(propertySetter, attributeName);
      }
      final PsiMethod getter = JavaFxPsiUtil.findPropertyGetter(attributeName, myPsiClass);
      if (getter != null) {
        return new JavaFxPropertyAttributeDescriptor(attributeName, myPsiClass);
      }
      return null;
    }
  }
  return new JavaFxPropertyAttributeDescriptor(attributeName, myPsiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaFxClassBackedElementDescriptor.java

示例9: validateValue

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Nullable
@Override
public String validateValue(XmlElement context, String value) {
  if (context instanceof XmlAttributeValue) {
    final PsiElement parent = context.getParent();
    if (parent instanceof XmlAttribute) {
      final XmlAttribute attribute = (XmlAttribute)parent;
      final String attributeName = attribute.getName();
      if (FxmlConstants.FX_VALUE.equals(attributeName)) {
        final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
        if (tagClass != null) {
          final PsiMethod method = JavaFxPsiUtil.findValueOfMethod(tagClass);
          if (method == null) {
            return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + ".";
          }
        }
      } else if (FxmlConstants.TYPE.equals(attributeName)) {
        final PsiReference[] references = context.getReferences();
        if (references.length == 0 || references[references.length - 1].resolve() == null) {
          return "Cannot resolve class " + value;
        }
      }
    }
  }
  return super.validateValue(context, value);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaFxDefaultAttributeDescriptor.java

示例10: getIncludedRoot

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
private static XmlTag getIncludedRoot(XmlTag context) {
  if (context == null) return null;
  final XmlAttribute xmlAttribute = context.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE);
  if (xmlAttribute != null) {
    final XmlAttributeValue valueElement = xmlAttribute.getValueElement();
    if (valueElement != null) {
      final PsiReference reference = valueElement.getReference();
      if (reference != null) {
        final PsiElement resolve = reference.resolve();
        if (resolve instanceof XmlFile) {
          final XmlTag rootTag = ((XmlFile)resolve).getRootTag();
          if (rootTag != null) {
            return rootTag;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:JavaFxDefaultPropertyElementDescriptor.java

示例11: validateValue

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Nullable
@Override
public String validateValue(XmlElement context, String value) {
  if (context instanceof XmlAttributeValue) {
    final PsiElement parent = context.getParent();
    if (parent instanceof XmlAttribute) {
      final XmlAttribute attribute = (XmlAttribute)parent;
      final String attributeName = attribute.getName();
      if (FxmlConstants.FX_VALUE.equals(attributeName)) {
        final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
        if (tagClass != null) {
          final PsiMethod method = JavaFxPsiUtil.findValueOfMethod(tagClass);
          if (method == null) {
            return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + ".";
          }
        }
      }
    }
  }
  return super.validateValue(context, value);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:JavaFxDefaultAttributeDescriptor.java

示例12: createParseHandler

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
protected IXMLBuilder createParseHandler(final String path, final Map<String, Set<String>> map) {
  return new NanoXmlUtil.IXMLBuilderAdapter() {
    @Override
    public void addAttribute(String key, String nsPrefix, String nsURI, String value, String type) throws Exception {
      if (value != null && FxmlConstants.FX_ID.equals(nsPrefix + ":" + key)) {
        Set<String> paths = map.get(value);
        if (paths == null) {
          paths = new HashSet<String>();
          map.put(value, paths);
        }
        paths.add(path);
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FxmlDataIndexer.java

示例13: canProcessElement

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Override
public boolean canProcessElement(@NotNull PsiElement element) {
  if (element instanceof XmlAttributeValue && JavaFxFileTypeFactory.isFxml(element.getContainingFile())) {
    final PsiElement parent = element.getParent();
    return parent instanceof XmlAttribute && FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName());
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaFxRenameAttributeProcessor.java

示例14: buildVisitor

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder,
                                      final boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlFile(XmlFile file) {
      if (!JavaFxFileTypeFactory.isFxml(file)) return;
      super.visitXmlFile(file);
    }

    @Override
    public void visitXmlAttribute(XmlAttribute attribute) {
      if (FxmlConstants.FX_ID.equals(attribute.getName())) {
        final XmlAttributeValue valueElement = attribute.getValueElement();
        if (valueElement != null && valueElement.getTextLength() > 0) {
          final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(attribute.getContainingFile());
          if (controllerClass != null) {
            final PsiReference reference = valueElement.getReference();
            if (reference instanceof JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef && ((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).isUnresolved()) {
              final PsiClass fieldClass =
                checkContext(((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).getXmlAttributeValue());
              if (fieldClass != null) {
                final String text = reference.getCanonicalText();
                final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(fieldClass.getLanguage());
                boolean validName = namesValidator != null && namesValidator.isIdentifier(text, fieldClass.getProject());
                holder.registerProblem(reference.getElement(), reference.getRangeInElement(), "Unresolved fx:id reference",
                                       isOnTheFly && validName ? new LocalQuickFix[]{new CreateFieldFromUsageQuickFix(text)} : LocalQuickFix.EMPTY_ARRAY);
              }
            }
          }
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaFxUnresolvedFxIdReferenceInspection.java

示例15: visitXmlAttribute

import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; //导入依赖的package包/类
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
  final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
  if (descriptor instanceof JavaFxStaticPropertyAttributeDescriptor) {
    final PsiElement declaration = descriptor.getDeclaration();
    if (declaration instanceof PsiMember) {
      appendClassName(((PsiMember)declaration).getContainingClass());
    }
  }
  else if (descriptor instanceof JavaFxDefaultAttributeDescriptor && FxmlConstants.TYPE.equals(descriptor.getName())) {
    appendClassName(JavaFxPsiUtil.findPsiClass(attribute.getValue(), attribute));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaFxImportsOptimizer.java


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