Exemplo n.º 1
0
 @Override
 public void mousePressed(MouseEvent e) {
   rightClick = AppD.isRightClick(e);
   table.stopEditing();
   mousePressedRow = rowHeader.locationToIndex(e.getPoint());
   rowHeader.requestFocus();
 }
Exemplo n.º 2
0
  public void keyPressed(KeyEvent e) {
    boolean undoNeeded = false;

    switch (e.getKeyCode()) {
      case KeyEvent.VK_DELETE:
      case KeyEvent.VK_BACK_SPACE:
        int[] selRows = rowHeader.getSelectedIndices();
        undoNeeded = table.getCASView().deleteCasCells(selRows);
        break;
    }

    if (undoNeeded) {
      // store undo info
      table.getApplication().storeUndoInfo();
    }
  }
Exemplo n.º 3
0
  public void mouseDragged(MouseEvent e) {
    e.consume();

    // update selection
    int mouseDraggedRow = rowHeader.locationToIndex(e.getPoint());

    // make sure mouse pressed is initialized, this may not be the case
    // after closing the popup menu
    if (mousePressedRow < 0) {
      table.stopEditing();
      mousePressedRow = mouseDraggedRow;
    }
    if (AppD.isControlDown(e)) rowHeader.addSelectionInterval(mousePressedRow, mouseDraggedRow);
    else rowHeader.setSelectionInterval(mousePressedRow, mouseDraggedRow);
  }
Exemplo n.º 4
0
  @Override
  public void mouseReleased(MouseEvent e) {
    e.consume();

    // handle marble click
    int releasedRow = table.rowAtPoint(e.getPoint());
    if (releasedRow == mousePressedRow) {
      int totalHeight = 0;
      for (int i = 0; i < releasedRow; i++) totalHeight += table.getRowHeight(i);

      int marbleTop =
          ((JPanel)
                  rowHeader
                      .getCellRenderer()
                      .getListCellRendererComponent(
                          rowHeader, (releasedRow + 1) + "", releasedRow, false, false))
              .getComponent(1)
              .getY();
      if (e.getY() > marbleTop + totalHeight - 4 && e.getY() < marbleTop + totalHeight + 16) {

        GeoCasCell clickedCell = table.getGeoCasCell(table.rowAtPoint(e.getPoint()));
        if (table.isEditing()) {
          table.stopEditing();
        }
        clickedCell.toggleTwinGeoEuclidianVisible();
      }
    }

    mousePressedRow = -1;
    // handle right click

    if (rightClick) {
      if (!rowHeader.isSelectedIndex(releasedRow)) {
        rowHeader.setSelectedIndex(releasedRow);
      }
      if (rowHeader.getSelectedIndices().length > 0) {
        RowHeaderPopupMenu popupMenu = new RowHeaderPopupMenu(rowHeader, table);
        popupMenu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
  }
Exemplo n.º 5
0
 public void valueChanged(ListSelectionEvent e) {
   ListSelectionModel lsm = (ListSelectionModel) e.getSource();
   int minIndex = lsm.getMinSelectionIndex();
   int maxIndex = lsm.getMaxSelectionIndex();
   if (minIndex == maxIndex) table.startEditingRow(minIndex);
 }