Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mylar-dev] [defect] Does StructuredViewer suppports more than one InterestFilter

If it does, There is a defect in mehtod AbstractApplyMylarAction#installInterestFilter(StructuredViewer)

 protected boolean installInterestFilter(StructuredViewer viewer) {
  try {
   if (viewer != null) {
    boolean found = false;
    for (int i = 0; i < viewer.getFilters().length; i++) {
     ViewerFilter viewerFilter = viewer.getFilters()[i];
     if (viewerFilter instanceof InterestFilter)
      found = true;
    }
    if (!found) {
     viewer.getControl().setRedraw(false);
     viewer.addFilter(interestFilter);
      viewer.getControl().setRedraw(true);
     return true;
    }
   } else {
    MylarStatusHandler.log("Could not install interest filter", this);
   }
  } catch (Throwable t) {
   MylarStatusHandler.fail (t, "Could not install viewer fitler on: " + prefId, false);
  }
  return false;
 }


We should change it to (using "interestFilter.equals(viewerFilter)" instead of "viewerFilter instanceof InterestFilter")

 protected boolean installInterestFilter(StructuredViewer viewer) {
  try {
   if (viewer == null) {
    MylarStatusHandler.log("Could not install interest filter", this);
    return false;
   }

   // viewer supports duplicated ViewerFilter, so we should check whether the filter has existed or not
   boolean found = false;
   for (ViewerFilter viewerFilter : viewer.getFilters()) {
    if (interestFilter.equals (viewerFilter)) {
     found = true;
     break;
    }
   }
   
   if (!found) {
    viewer.getControl().setRedraw(false);
    viewer.addFilter(interestFilter);
    viewer.getControl().setRedraw(true);
    return true;
   }
  } catch (Throwable t) {
   MylarStatusHandler.fail(t, "Could not install viewer fitler on: " + prefId, false);
  }
  return false;
 }

 


Back to the top