コード例 #1
0
 private void fillList(final HighlightSeverity severity) {
   DefaultListModel model = new DefaultListModel();
   model.removeAllElements();
   final List<SeverityBasedTextAttributes> infoTypes =
       new ArrayList<SeverityBasedTextAttributes>();
   infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   Collections.sort(
       infoTypes,
       new Comparator<SeverityBasedTextAttributes>() {
         @Override
         public int compare(
             SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) {
           return -mySeverityRegistrar.compare(
               attributes1.getSeverity(), attributes2.getSeverity());
         }
       });
   SeverityBasedTextAttributes preselection = null;
   for (SeverityBasedTextAttributes type : infoTypes) {
     model.addElement(type);
     if (type.getSeverity().equals(severity)) {
       preselection = type;
     }
   }
   myOptionsList.setModel(model);
   myOptionsList.setSelectedValue(preselection, true);
 }
コード例 #2
0
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
      Element info = new Element(INFO_TAG);
      String severityName = severity.getName();
      final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
      if (infoType != null) {
        infoType.writeExternal(info);
        final Color color = myRendererColors.get(severityName);
        if (color != null) {
          info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
        }
        element.addContent(info);
      }
    }

    if (myReadOrder != null && !myReadOrder.isEmpty()) {
      myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
      final JDOMExternalizableStringList ext =
          new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
      getOrderMap()
          .forEachEntry(
              new TObjectIntProcedure<HighlightSeverity>() {
                @Override
                public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                  ext.set(oIdx, orderSeverity.getName());
                  return true;
                }
              });
      ext.writeExternal(element);
    }
  }
コード例 #3
0
 @Nullable
 public HighlightSeverity getSeverity(@NotNull String name) {
   final HighlightInfoType type = STANDARD_SEVERITIES.get(name);
   if (type != null) return type.getSeverity(null);
   final SeverityBasedTextAttributes attributes = myMap.get(name);
   if (attributes != null) return attributes.getSeverity();
   return null;
 }
コード例 #4
0
 @Nullable
 public TextAttributes getTextAttributesBySeverity(@NotNull HighlightSeverity severity) {
   final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
   if (infoType != null) {
     return infoType.getAttributes();
   }
   return null;
 }
コード例 #5
0
 @NotNull
 private List<HighlightSeverity> getDefaultOrder() {
   Collection<SeverityBasedTextAttributes> values = myMap.values();
   List<HighlightSeverity> order =
       new ArrayList<HighlightSeverity>(STANDARD_SEVERITIES.size() + values.size());
   for (HighlightInfoType type : STANDARD_SEVERITIES.values()) {
     order.add(type.getSeverity(null));
   }
   for (SeverityBasedTextAttributes attributes : values) {
     order.add(attributes.getSeverity());
   }
   ContainerUtil.sort(order);
   return order;
 }
コード例 #6
0
  @NotNull
  public HighlightInfoType.HighlightInfoTypeImpl getHighlightInfoTypeBySeverity(
      @NotNull HighlightSeverity severity) {
    HighlightInfoType infoType = STANDARD_SEVERITIES.get(severity.getName());
    if (infoType != null) {
      return (HighlightInfoType.HighlightInfoTypeImpl) infoType;
    }

    if (severity == HighlightSeverity.INFORMATION) {
      return (HighlightInfoType.HighlightInfoTypeImpl) HighlightInfoType.INFORMATION;
    }

    final SeverityBasedTextAttributes type = getAttributesBySeverity(severity);
    return (HighlightInfoType.HighlightInfoTypeImpl)
        (type == null ? HighlightInfoType.WARNING : type.getType());
  }
コード例 #7
0
 private void reset(SeverityBasedTextAttributes info) {
   final MyTextAttributesDescription description =
       new MyTextAttributesDescription(
           info.getType().toString(),
           null,
           info.getAttributes(),
           info.getType().getAttributesKey());
   @NonNls Element textAttributes = new Element("temp");
   try {
     info.getAttributes().writeExternal(textAttributes);
     description.getTextAttributes().readExternal(textAttributes);
   } catch (Exception e) {
     LOG.error(e);
   }
   myOptionsPanel.reset(description);
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 @Override
 protected void doOKAction() {
   apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue());
   final Collection<SeverityBasedTextAttributes> infoTypes =
       new HashSet<SeverityBasedTextAttributes>(
           SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   final ListModel listModel = myOptionsList.getModel();
   final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
   for (int i = listModel.getSize() - 1; i >= 0; i--) {
     final SeverityBasedTextAttributes info =
         (SeverityBasedTextAttributes) listModel.getElementAt(i);
     order.add(info.getSeverity());
     if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) {
       infoTypes.remove(info);
       final Color stripeColor = info.getAttributes().getErrorStripeColor();
       mySeverityRegistrar.registerSeverity(
           info, stripeColor != null ? stripeColor : LightColors.YELLOW);
     }
   }
   for (SeverityBasedTextAttributes info : infoTypes) {
     mySeverityRegistrar.unregisterSeverity(info.getSeverity());
   }
   mySeverityRegistrar.setOrder(order);
   super.doOKAction();
 }
コード例 #10
0
 @Nullable
 public HighlightInfoType getSelectedType() {
   final SeverityBasedTextAttributes selection =
       (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
   return selection != null ? selection.getType() : null;
 }