本文整理汇总了Java中com.intellij.util.xml.highlighting.DomElementAnnotationsManager类的典型用法代码示例。如果您正苦于以下问题:Java DomElementAnnotationsManager类的具体用法?Java DomElementAnnotationsManager怎么用?Java DomElementAnnotationsManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DomElementAnnotationsManager类属于com.intellij.util.xml.highlighting包,在下文中一共展示了DomElementAnnotationsManager类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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;
}
示例3: validate
import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入依赖的package包/类
private void validate() {
DomElement domElement = getDomElement();
final List<DomElementProblemDescriptor> list =
DomElementAnnotationsManager.getInstance(getProject()).getCachedProblemHolder(domElement).getProblems(domElement);
final List<String> messages = new ArrayList<String>();
for (final DomElementProblemDescriptor descriptor : list) {
if (descriptor instanceof DomCollectionProblemDescriptor
&& myChildDescription.equals(((DomCollectionProblemDescriptor)descriptor).getChildDescription())) {
messages.add(descriptor.getDescriptionTemplate());
}
}
myCollectionPanel.setErrorMessages(ArrayUtil.toStringArray(messages));
myCollectionPanel.repaint();
}
示例4: DomFileEditor
import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入依赖的package包/类
public DomFileEditor(final Project project, final VirtualFile file, final String name, final Factory<? extends T> component) {
super(project, file);
myComponentFactory = component;
myName = name;
DomElementAnnotationsManager.getInstance(project).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() {
@Override
public void highlightingFinished(@NotNull DomFileElement element) {
if (isInitialised() && getComponent().isShowing() && element.isValid()) {
updateHighlighting();
}
}
}, this);
}
示例5: 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);
}
}
}
示例6: DomFileEditor
import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入依赖的package包/类
public DomFileEditor(final Project project, final VirtualFile file, final String name, final Factory<? extends T> component) {
super(project, file);
myComponentFactory = component;
myName = name;
DomElementAnnotationsManager.getInstance(project).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() {
public void highlightingFinished(@NotNull DomFileElement element) {
if (isInitialised() && getComponent().isShowing() && element.isValid()) {
updateHighlighting();
}
}
}, this);
}
示例7: testResolveProblemsAreReportedOnlyOnce
import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; //导入依赖的package包/类
public void testResolveProblemsAreReportedOnlyOnce() throws Throwable {
final MyElement myElement = createElement("<a><my-class>abc</my-class></a>", MyElement.class);
new MockDomInspection(MyElement.class).checkFile(DomUtil.getFile(myElement), InspectionManager.getInstance(getProject()), true);
final DomElementsProblemsHolder holder = DomElementAnnotationsManager.getInstance(getProject()).getProblemHolder(myElement);
final DomElement element = myElement.getMyClass();
assertEquals(0, holder.getProblems(myElement).size());
assertEquals(0, holder.getProblems(myElement).size());
assertEquals(1, holder.getProblems(element).size());
assertEquals(1, holder.getProblems(element).size());
assertEquals(1, holder.getProblems(myElement, true, true).size());
assertEquals(1, holder.getProblems(myElement, true, true).size());
}
示例8: 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;
}
示例9: 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;
}