use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar.SeverityBasedTextAttributes in project intellij-community by JetBrains.
the class SeverityEditorDialog method doOKAction.
@Override
protected void doOKAction() {
apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue());
final Collection<SeverityBasedTextAttributes> infoTypes = new HashSet<>(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
final ListModel listModel = myOptionsList.getModel();
final List<HighlightSeverity> order = new ArrayList<>();
for (int i = listModel.getSize() - 1; i >= 0; i--) {
SeverityBasedTextAttributes info = (SeverityBasedTextAttributes) listModel.getElementAt(i);
order.add(info.getSeverity());
if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) {
infoTypes.remove(info);
final Color stripeColor = info.getAttributes().getErrorStripeColor();
final boolean exists = mySeverityRegistrar.getSeverity(info.getSeverity().getName()) != null;
if (exists) {
info.getType().getAttributesKey().getDefaultAttributes().setErrorStripeColor(stripeColor);
} else {
HighlightInfoType.HighlightInfoTypeImpl type = info.getType();
TextAttributesKey key = type.getAttributesKey();
final TextAttributes defaultAttributes = key.getDefaultAttributes().clone();
defaultAttributes.setErrorStripeColor(stripeColor);
key = TextAttributesKey.createTextAttributesKey(key.getExternalName(), defaultAttributes);
type = new HighlightInfoType.HighlightInfoTypeImpl(type.getSeverity(null), key);
info = new SeverityBasedTextAttributes(info.getAttributes(), type);
}
mySeverityRegistrar.registerSeverity(info, stripeColor != null ? stripeColor : LightColors.YELLOW);
}
}
for (SeverityBasedTextAttributes info : infoTypes) {
mySeverityRegistrar.unregisterSeverity(info.getSeverity());
}
mySeverityRegistrar.setOrder(order);
super.doOKAction();
}
use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar.SeverityBasedTextAttributes in project intellij-community by JetBrains.
the class SeverityEditorDialog method fillList.
private void fillList(@Nullable final HighlightSeverity severity) {
DefaultListModel model = new DefaultListModel();
model.removeAllElements();
final List<SeverityBasedTextAttributes> infoTypes = new ArrayList<>();
infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
Collections.sort(infoTypes, (attributes1, attributes2) -> -mySeverityRegistrar.compare(attributes1.getSeverity(), attributes2.getSeverity()));
SeverityBasedTextAttributes preselection = null;
for (SeverityBasedTextAttributes type : infoTypes) {
if (HighlightSeverity.INFO.equals(type.getSeverity()))
continue;
model.addElement(type);
if (type.getSeverity().equals(severity)) {
preselection = type;
}
}
if (preselection == null && !infoTypes.isEmpty()) {
preselection = infoTypes.get(0);
}
myOptionsList.setModel(model);
myOptionsList.setSelectedValue(preselection, true);
}
use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar.SeverityBasedTextAttributes in project intellij-community by JetBrains.
the class SeverityEditorDialog method apply.
private void apply(SeverityBasedTextAttributes info) {
if (info == null) {
return;
}
MyTextAttributesDescription description = new MyTextAttributesDescription(info.getType().toString(), null, new TextAttributes(), info.getType().getAttributesKey());
myOptionsPanel.apply(description, null);
Element textAttributes = new Element("temp");
try {
description.getTextAttributes().writeExternal(textAttributes);
info.getAttributes().readExternal(textAttributes);
} catch (Exception e) {
LOG.error(e);
}
}
Aggregations