Example #1
0
 public void clearFilterFlags() {
   DataSet ds = Main.main.getCurrentDataSet();
   if (ds != null) {
     FilterWorker.clearFilterFlags(ds.allPrimitives());
   }
   disabledCount = 0;
   disabledAndHiddenCount = 0;
 }
Example #2
0
  public void executeFilters(Collection<? extends OsmPrimitive> primitives) {
    DataSet ds = Main.main.getCurrentDataSet();
    if (ds == null) return;

    boolean changed = false;
    List<OsmPrimitive> deselect = new ArrayList<OsmPrimitive>();

    ds.beginUpdate();
    try {
      for (int i = 0; i < 2; i++) {
        for (OsmPrimitive primitive : primitives) {

          if (i == 0 && primitive instanceof Node) {
            continue;
          }

          if (i == 1 && !(primitive instanceof Node)) {
            continue;
          }

          if (primitive.isDisabled()) {
            disabledCount--;
          }
          if (primitive.isDisabledAndHidden()) {
            disabledAndHiddenCount--;
          }
          changed = changed | FilterWorker.executeFilters(primitive, filterMatcher);
          if (primitive.isDisabled()) {
            disabledCount++;
          }
          if (primitive.isDisabledAndHidden()) {
            disabledAndHiddenCount++;
          }

          if (primitive.isSelected() && primitive.isDisabled()) {
            deselect.add(primitive);
          }
        }
      }
    } finally {
      ds.endUpdate();
    }

    if (changed) {
      Main.map.mapView.repaint();
      Main.map.filterDialog.updateDialogHeader();
      ds.clearSelection(deselect);
    }
  }
Example #3
0
  public void executeFilters() {
    DataSet ds = Main.main.getCurrentDataSet();
    boolean changed = false;
    if (ds == null) {
      disabledAndHiddenCount = 0;
      disabledCount = 0;
      changed = true;
    } else {
      final Collection<OsmPrimitive> deselect = new HashSet<OsmPrimitive>();

      ds.beginUpdate();
      try {

        final Collection<OsmPrimitive> all = ds.allNonDeletedCompletePrimitives();

        changed = FilterWorker.executeFilters(all, filterMatcher);

        disabledCount = 0;
        disabledAndHiddenCount = 0;
        // collect disabled and selected the primitives
        for (OsmPrimitive osm : all) {
          if (osm.isDisabled()) {
            disabledCount++;
            if (osm.isSelected()) {
              deselect.add(osm);
            }
            if (osm.isDisabledAndHidden()) {
              disabledAndHiddenCount++;
            }
          }
        }
        disabledCount -= disabledAndHiddenCount;
      } finally {
        ds.endUpdate();
      }

      if (!deselect.isEmpty()) {
        ds.clearSelection(deselect);
      }
    }

    if (Main.isDisplayingMapView() && changed) {
      Main.map.mapView.repaint();
      Main.map.filterDialog.updateDialogHeader();
    }
  }