private void adjustFocusAndSelection(MouseEvent e) {
      if (shouldIgnore(e)) {
        return;
      }

      Point p = e.getPoint();
      int row = grid.rowAtPoint(p);
      int column = grid.columnAtPoint(p);

      // The autoscroller can generate drag events outside range.
      if ((column == -1) || (row == -1)) {
        System.err.println("Out of bounds");
        return;
      }

      if (grid.editCellAt(row, column, e)) {
        setDispatchComponent(e);
        repostEvent(e);
      } else {
        grid.requestFocus();
      }

      GridCellEditor editor = grid.getCurrentCellEditor();
      if (editor == null || editor.shouldSelectCell(e)) {
        // Update selection model
        setValueIsAdjusting(true);
        grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown());
      }
    }
    public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
Example #3
0
 @Override
 public void mousePressed(MouseEvent e) {
   Object o = e.getSource();
   if (o instanceof TableCellEditor) {
     actionPerformed(null);
   } else if (o instanceof JButton) {
     // DEBUG: view button click -> control key down + edit button(same cell) press -> remain
     // selection color
     ButtonModel m = ((JButton) e.getComponent()).getModel();
     if (m.isPressed() && table.isRowSelected(table.getEditingRow()) && e.isControlDown()) {
       setBackground(table.getBackground());
     }
   }
 }
 public void mouseClicked(MouseEvent e) {
   JTableHeader h = (JTableHeader) e.getSource();
   TableColumnModel columnModel = h.getColumnModel();
   int viewColumn = columnModel.getColumnIndexAtX(e.getX());
   int column = columnModel.getColumn(viewColumn).getModelIndex();
   if (column != -1) {
     int status = getSortingStatus(column);
     if (!e.isControlDown()) {
       cancelSorting();
     }
     // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
     // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
     status = status + (e.isShiftDown() ? -1 : 1);
     status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
     setSortingStatus(column, status);
   }
 }
Example #5
0
 public void mousePressed(MouseEvent e) { // needed for MouseListener interface
   if (e.isControlDown()) getEditor().toggleListSelected();
   //      mouseLeftButtonDown = true;
   getEditor().nodeSelected(this);
 }