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


Java DomElementAnnotationsManager.getInstance方法代码示例

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


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

示例1: doUpdate

import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入方法依赖的package包/类
@Override
protected void doUpdate() {
  if (!myDomElement.isValid()) return;
  final Project project = myDomElement.getManager().getProject();
  if (project.isDisposed()) return;

  setUniformIcon(getNodeIcon());
  clearColoredText();

  final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
  final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(myDomElement);
  final List<DomElementProblemDescriptor> problems =
    holder.getProblems(myDomElement, highlightIfChildrenHaveProblems(), HighlightSeverity.ERROR);

  if (problems.size() > 0) {
    final String toolTip = TooltipUtils.getTooltipText(problems);
    addColoredFragment(getNodeName(), toolTip, getWavedAttributes(SimpleTextAttributes.STYLE_PLAIN));
    if (isShowContainingFileInfo()) {
      addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", toolTip, SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
  else if (myDomElement.getXmlTag() == null && !(myDomElement instanceof DomFileElement)) {
    addColoredFragment(getNodeName(), folder ? SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
  }
  else if (folder) {
    addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    final int childrenCount = getChildren().length;
    addColoredFragment(" (" + childrenCount + ')', SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
  else {
    addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);

    if (isShowContainingFileInfo()) {
      addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:BaseDomElementNode.java

示例2: hasErrors

import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入方法依赖的package包/类
private boolean hasErrors() {
  if (!myParentElement.isValid()) return false;

  for (DomElement domElement : myChildDescription.getStableValues(myParentElement)) {
    final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(getProject());
    final DomElementsProblemsHolder holder = annotationsManager.getCachedProblemHolder(domElement);
    final List<DomElementProblemDescriptor> problems = holder.getProblems(domElement, true, HighlightSeverity.ERROR);
    if (problems.size() > 0) return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DomElementsGroupNode.java

示例3: doUpdate

import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入方法依赖的package包/类
protected void doUpdate() {
  if (!myDomElement.isValid()) return;
  final Project project = myDomElement.getManager().getProject();
  if (project.isDisposed()) return;

  setUniformIcon(getNodeIcon());
  clearColoredText();

  final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
  final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(myDomElement);
  final List<DomElementProblemDescriptor> problems =
    holder.getProblems(myDomElement, highlightIfChildrenHaveProblems(), HighlightSeverity.ERROR);

  if (problems.size() > 0) {
    final String toolTip = TooltipUtils.getTooltipText(problems);
    addColoredFragment(getNodeName(), toolTip, getWavedAttributes(SimpleTextAttributes.STYLE_PLAIN));
    if (isShowContainingFileInfo()) {
      addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", toolTip, SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
  else if (myDomElement.getXmlTag() == null && !(myDomElement instanceof DomFileElement)) {
    addColoredFragment(getNodeName(), folder ? SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
  }
  else if (folder) {
    addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    final int childrenCount = getChildren().length;
    addColoredFragment(" (" + childrenCount + ')', SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
  else {
    addColoredFragment(getNodeName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);

    if (isShowContainingFileInfo()) {
      addColoredFragment(" (" + DomUtil.getFile(myDomElement).getName() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:BaseDomElementNode.java

示例4: getTableCellRendererComponent

import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  final Component component = myRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  if (!myRoot.isValid()) {
    return component;
  }

  final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(myRowDomElement.getManager().getProject());
  final DomElementsProblemsHolder holder = annotationsManager.getCachedProblemHolder(myRoot);
  final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(myCellValueDomElement);
  final List<DomElementProblemDescriptor> warningProblems = new ArrayList<DomElementProblemDescriptor>(holder.getProblems(myCellValueDomElement, true, HighlightSeverity.WARNING));
  warningProblems.removeAll(errorProblems);

  final boolean hasErrors = errorProblems.size() > 0;
  if (hasErrors) {
    component.setForeground(JBColor.RED);
    if (component instanceof JComponent) {
      ((JComponent)component).setToolTipText(TooltipUtils.getTooltipText(errorProblems));
    }
  }
  else {
    component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
    if (component instanceof JComponent) {
      ((JComponent)component).setToolTipText(null);
    }
  }

  // highlight empty cell with errors
  if (hasErrors && (value == null || value.toString().trim().length() == 0)) {
    component.setBackground(BaseControl.ERROR_BACKGROUND);
  }
  else if (warningProblems.size() > 0) {
    component.setBackground(BaseControl.WARNING_BACKGROUND);
    if(isSelected) component.setForeground(JBColor.foreground());
  }

  final List<DomElementProblemDescriptor> errorDescriptors =
    annotationsManager.getCachedProblemHolder(myRowDomElement).getProblems(myRowDomElement, true, true);

  if (table.getModel().getColumnCount() - 1 == column) {
    if (errorDescriptors.size() > 0) {
      final JPanel wrapper = new JPanel(new BorderLayout());
      wrapper.add(component, BorderLayout.CENTER);

      wrapper.setBackground(component.getBackground());

      final JLabel errorLabel = new JLabel(getErrorIcon());

      wrapper.setToolTipText(TooltipUtils.getTooltipText(errorDescriptors));

      wrapper.add(errorLabel, BorderLayout.EAST);

      if (component instanceof JComponent) {
        final JComponent jComponent = (JComponent)component;
        wrapper.setBorder(jComponent.getBorder());
        jComponent.setBorder(BorderFactory.createEmptyBorder());
        jComponent.setToolTipText(TooltipUtils.getTooltipText(errorDescriptors));
      }

      return wrapper;
    } else {
      if (component instanceof JComponent) {
        ((JComponent)component).setToolTipText(null);
      }
    }
  }

  return component;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:70,代码来源:ErrorableTableCellRenderer.java

示例5: getTableCellRendererComponent

import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  final Component component = myRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  if (!myRoot.isValid()) {
    return component;
  }

  final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(myRowDomElement.getManager().getProject());
  final DomElementsProblemsHolder holder = annotationsManager.getCachedProblemHolder(myRoot);
  final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(myCellValueDomElement);
  final List<DomElementProblemDescriptor> warningProblems = new ArrayList<DomElementProblemDescriptor>(holder.getProblems(myCellValueDomElement, true, HighlightSeverity.WARNING));
  warningProblems.removeAll(errorProblems);

  final boolean hasErrors = errorProblems.size() > 0;
  if (hasErrors) {
    component.setForeground(JBColor.RED);
    if (component instanceof JComponent) {
      ((JComponent)component).setToolTipText(TooltipUtils.getTooltipText(errorProblems));
    }
  }
  else {
    component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
    if (component instanceof JComponent) {
      ((JComponent)component).setToolTipText(null);
    }
  }

  // highlight empty cell with errors
  if (hasErrors && (value == null || value.toString().trim().length() == 0)) {
    component.setBackground(BaseControl.ERROR_BACKGROUND);
  }
  else if (warningProblems.size() > 0) {
    component.setBackground(BaseControl.WARNING_BACKGROUND);
    if(isSelected) component.setForeground(JBColor.foreground());
  }

  final List<DomElementProblemDescriptor> errorDescriptors =
    annotationsManager.getCachedProblemHolder(myRowDomElement).getProblems(myRowDomElement, true, true);

  if (table.getModel().getColumnCount() - 1 == column) {
    if (errorDescriptors.size() > 0) {
      final JPanel wrapper = new JPanel(new BorderLayout());
      wrapper.add(component, BorderLayout.CENTER);

      wrapper.setBackground(component.getBackground());

      final JLabel errorLabel = new JLabel(getErrorIcon());

      wrapper.setToolTipText(TooltipUtils.getTooltipText(errorDescriptors));

      wrapper.add(errorLabel, BorderLayout.EAST);

      if (component instanceof JComponent) {
        final JComponent jComponent = (JComponent)component;
        wrapper.setBorder(jComponent.getBorder());
        jComponent.setBorder(BorderFactory.createEmptyBorder());
        jComponent.setToolTipText(TooltipUtils.getTooltipText(errorDescriptors));
      }

      return wrapper;
    } else {
      if (component instanceof JComponent) {
        ((JComponent)component).setToolTipText(null);
      }
    }
  }

  return component;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:69,代码来源:ErrorableTableCellRenderer.java


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