public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor) { final HighlightSeverity severity = info.getType().getSeverity(null); myMap.put(severity.getName(), info); if (renderColor != null) { myRendererColors.put(severity.getName(), renderColor); } myOrderMap = null; HighlightDisplayLevel.registerSeverity( severity, getHighlightInfoTypeBySeverity(severity).getAttributesKey()); severitiesChanged(); }
@Override public void readExternal(Element element) throws InvalidDataException { myMap.clear(); myRendererColors.clear(); final List children = element.getChildren(INFO_TAG); for (Object child : children) { final Element infoElement = (Element) child; final SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes(infoElement); Color color = null; final String colorStr = infoElement.getAttributeValue(COLOR_ATTRIBUTE); if (colorStr != null) { color = new Color(Integer.parseInt(colorStr, 16)); } registerSeverity(highlightInfo, color); } myReadOrder = new JDOMExternalizableStringList(); myReadOrder.readExternal(element); List<HighlightSeverity> read = new ArrayList<HighlightSeverity>(myReadOrder.size()); final List<HighlightSeverity> knownSeverities = getDefaultOrder(); for (String name : myReadOrder) { HighlightSeverity severity = getSeverity(name); if (severity == null || !knownSeverities.contains(severity)) continue; read.add(severity); } OrderMap orderMap = fromList(read); if (orderMap.isEmpty()) { orderMap = fromList(knownSeverities); } else { // enforce include all known List<HighlightSeverity> list = getOrderAsList(orderMap); for (int i = 0; i < knownSeverities.size(); i++) { HighlightSeverity stdSeverity = knownSeverities.get(i); if (!list.contains(stdSeverity)) { for (int oIdx = 0; oIdx < list.size(); oIdx++) { HighlightSeverity orderSeverity = list.get(oIdx); HighlightInfoType type = STANDARD_SEVERITIES.get(orderSeverity.getName()); if (type != null && knownSeverities.indexOf(type.getSeverity(null)) > i) { list.add(oIdx, stdSeverity); myReadOrder = null; break; } } } } orderMap = fromList(list); } myOrderMap = orderMap; severitiesChanged(); }
public void setOrder(@NotNull List<HighlightSeverity> orderList) { myOrderMap = fromList(orderList); myReadOrder = null; severitiesChanged(); }