Exemplo n.º 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);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
0
 @Nullable
 public HighlightInfoType getSelectedType() {
   final SeverityBasedTextAttributes selection =
       (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
   return selection != null ? selection.getType() : null;
 }