Exemplo n.º 1
0
 @Override
 public void setValueIsAdjusting(boolean valueIsAdjusting) {
   if (valueIsAdjusting != isAdjusting) {
     isAdjusting = valueIsAdjusting;
     fireSelectionChanged(
         new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
   }
 }
Exemplo n.º 2
0
 @Override
 public void clearSelection() {
   System.err.println("DSM: clearSelection()");
   // new Exception().printStackTrace();
   delegate.clearSelection();
   fireSelectionChanged(
       new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
 }
Exemplo n.º 3
0
  @Override
  public void removeSelectionInterval(int index0, int index1) {
    System.err.println("DSM: removeSelectionInterval(" + index0 + " - " + index1 + ")");

    int start = Math.min(index0, index1);
    int end = Math.max(index0, index1);
    boolean oldValue = getValueIsAdjusting();

    setValueIsAdjusting(true);

    for (int i = start; i <= end; i++) {
      int modelIndex = sortedModel.convertRowIndexToModel(i);
      delegate.removeSelectionInterval(modelIndex, modelIndex);
    }

    setValueIsAdjusting(oldValue);
    fireSelectionChanged(
        new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
  }
Exemplo n.º 4
0
  private void addSelectionInterval(int index0, int index1, boolean clear) {
    System.err.println(
        "DSM: addSelectionInterval(" + index0 + " - " + index1 + ": clear = " + clear + ")");

    int start = Math.min(index0, index1);
    int end = Math.max(index0, index1);
    boolean oldValue = getValueIsAdjusting();

    setValueIsAdjusting(true);

    if (clear) {
      delegate.clearSelection();
    }

    for (int i = start; i <= end; i++) {
      int modelIndex = sortedModel.convertRowIndexToModel(i);
      delegate.addSelectionInterval(modelIndex, modelIndex);
    }

    setValueIsAdjusting(oldValue);
    fireSelectionChanged(
        new ListSelectionEvent(this, 0, sortedModel.getRowCount() - 1, getValueIsAdjusting()));
  }
Exemplo n.º 5
0
  @Override
  public int getMaxSelectionIndex() {
    int min = delegate.getMinSelectionIndex();

    if (min >= 0) {
      int max = delegate.getMaxSelectionIndex();
      int viewMaxIndex = 0;

      for (int i = min; i <= max; i++) {
        int viewIndex = sortedModel.convertRowIndexToView(i);

        if (viewIndex > viewMaxIndex) {
          viewMaxIndex = viewIndex;
        }
      }

      return viewMaxIndex;
    }

    return -1;
  }
Exemplo n.º 6
0
  public DummySelectionModel(SortedTableModel sortedModel) {
    this.sortedModel = sortedModel;

    sortedModel
        .getModel()
        .addTableModelListener(
            new TableModelListener() {
              @Override
              public void tableChanged(TableModelEvent e) {
                if (e.getType() == TableModelEvent.DELETE) {
                  //          System.err.println("DELETE event : " + e.getFirstRow() + "-" +
                  // e.getLastRow() + ": first row select status = " +
                  // delegate.isSelectedIndex(e.getFirstRow()));
                  delegate.removeIndexInterval(e.getFirstRow(), e.getLastRow());
                } else if (e.getType() == TableModelEvent.INSERT) {
                  delegate.insertIndexInterval(
                      e.getFirstRow(), e.getLastRow() - e.getFirstRow() + 1, true);
                }
              }
            });
  }
Exemplo n.º 7
0
 @Override
 public int getLeadSelectionIndex() {
   return sortedModel.convertRowIndexToView(delegate.getLeadSelectionIndex());
 }
Exemplo n.º 8
0
 @Override
 public void setLeadSelectionIndex(int index) {
   delegate.setLeadSelectionIndex(sortedModel.convertRowIndexToModel(index));
 }
Exemplo n.º 9
0
 @Override
 public boolean isSelectedIndex(int index) {
   return delegate.isSelectedIndex(sortedModel.convertRowIndexToModel(index));
 }