hzzz 8 years ago
parent
commit
082987e03c
  1. 16
      designer/src/com/fr/grid/GridKeyListener.java
  2. 6
      designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java
  3. 25
      designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java
  4. 10
      designer_base/src/com/fr/design/gui/itable/TableSorter.java

16
designer/src/com/fr/grid/GridKeyListener.java

@ -6,7 +6,6 @@ import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.elementcase.ElementCase;
import com.fr.stable.OperatingSystem;
import java.awt.*;
import java.awt.event.KeyEvent;
@ -18,6 +17,7 @@ import java.awt.event.KeyListener;
*/
public class GridKeyListener implements KeyListener {
private static final int DIFF = 48; // 103 - 55 = 48, 小键盘和大键盘数字的差值 48
private static final int DELAY = 32;
private Grid grid;
// Keypressed last time
private long keyPressedLastTime = 0;
@ -31,8 +31,7 @@ public class GridKeyListener implements KeyListener {
if (!grid.isEnabled() || evt.isConsumed()) {// 如果用户在自己的KyeListener里面consume了.就不执行下面的代码了.
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null) {
if (KeyEventWork.processKeyEvent(evt) == null) {
return;
}
long systemCurrentTime = System.currentTimeMillis();
@ -47,17 +46,14 @@ public class GridKeyListener implements KeyListener {
keyPressedLastTime = systemCurrentTime;
}
dealWithFloatSelection(reportPane, code);
} else {
if (systemCurrentTime - keyPressedLastTime <= 32) {
if (systemCurrentTime - keyPressedLastTime <= DELAY) {
return;
} else {
keyPressedLastTime = systemCurrentTime;
}
dealWithCellSelection(evt, code);
}
switch (code) {
case KeyEvent.VK_PAGE_UP: {// page up
reportPane.getVerticalScrollBar().setValue(Math.max(0, grid.getVerticalValue() - grid.getVerticalExtent()));
@ -71,16 +67,12 @@ public class GridKeyListener implements KeyListener {
}
// Richie:Ctrl + A全选单元格
case KeyEvent.VK_A:
boolean macOS = OperatingSystem.isMacOS() && evt.isMetaDown();
boolean windows = OperatingSystem.isWindows() && InputEventBaseOnOS.isControlDown(evt);
if (macOS || windows) {
if (InputEventBaseOnOS.isControlDown(evt)) {
reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount()));
isNeedRepaint = true;
}
isNeedRepaint = true;
break;
}
if (isNeedRepaint) {
reportPane.repaint();
}

6
designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java

@ -9,13 +9,13 @@ import java.awt.event.MouseEvent;
* Created by hzzz on 2017/5/26.
*/
public class InputEventBaseOnOS {
private static final boolean isMacOS = OperatingSystem.isMacOS();
private static final boolean IS_MACOS = OperatingSystem.isMacOS();
public static boolean isControlDown(MouseEvent e) {
return isMacOS ? e.isMetaDown() : e.isControlDown();
return IS_MACOS ? e.isMetaDown() : e.isControlDown();
}
public static boolean isControlDown(KeyEvent e) {
return isMacOS ? e.isMetaDown() : e.isControlDown();
return IS_MACOS ? e.isMetaDown() : e.isControlDown();
}
}

25
designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java

@ -22,7 +22,6 @@ import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.stable.StringUtils;
@ -177,7 +176,7 @@ public class CheckBoxList extends JComponent {
@Override
protected void processMouseEvent(MouseEvent e) {
if (e.getX() < 20) {
if (InputEventBaseOnOS.isControlDown(e) || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) {
if (e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) {
int[] indices = getSelectedIndices();
if (indices.length == 0) {
super.processMouseEvent(e);
@ -190,17 +189,17 @@ public class CheckBoxList extends JComponent {
}
int id = e.getID();
switch (id) {
case MouseEvent.MOUSE_PRESSED:
break;
case MouseEvent.MOUSE_RELEASED:
break;
case MouseEvent.MOUSE_CLICKED:
doCheck();
break;
case MouseEvent.MOUSE_EXITED:
break;
case MouseEvent.MOUSE_ENTERED:
break;
case MouseEvent.MOUSE_PRESSED:
break;
case MouseEvent.MOUSE_RELEASED:
break;
case MouseEvent.MOUSE_CLICKED:
doCheck();
break;
case MouseEvent.MOUSE_EXITED:
break;
case MouseEvent.MOUSE_ENTERED:
break;
}
}

10
designer_base/src/com/fr/design/gui/itable/TableSorter.java

@ -81,7 +81,7 @@ import javax.swing.table.TableModel;
public class TableSorter extends AbstractTableModel {
protected TableModel tableModel;
private static final int ADD = 4;
public static final int DESCENDING = -1;
public static final int NOT_SORTED = 0;
public static final int ASCENDING = 1;
@ -343,16 +343,13 @@ public class TableSorter extends AbstractTableModel {
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
// sorting columns may have been either moved or deleted from the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
@ -382,7 +379,6 @@ public class TableSorter extends AbstractTableModel {
column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the row order.
clearSortingState();
fireTableDataChanged();
@ -404,7 +400,7 @@ public class TableSorter extends AbstractTableModel {
// 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}
status = (status + ADD) % 3 - 1; // signed mod, returning {-1, 0, 1}
setSortingStatus(column, status);
}
}

Loading…
Cancel
Save