diff --git a/designer/src/com/fr/grid/GridKeyListener.java b/designer/src/com/fr/grid/GridKeyListener.java index e60097fd6..b3d57ab67 100644 --- a/designer/src/com/fr/grid/GridKeyListener.java +++ b/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(); } diff --git a/designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java b/designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java index cee80d334..29b6b9ce3 100644 --- a/designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java +++ b/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(); } } diff --git a/designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java b/designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java index fa21465cb..28c9e85e8 100644 --- a/designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java +++ b/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; @@ -32,7 +31,7 @@ import com.fr.stable.StringUtils; public class CheckBoxList extends JComponent { /** * 选择状态----全选和全不选 - * + * * @editor zhou * @since 2012-4-1下午2:39:10 */ @@ -54,7 +53,7 @@ public class CheckBoxList extends JComponent { /** * Class constructor. - * + * * @param items * Items with which to populate the list. * @param default_state @@ -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; } } diff --git a/designer_base/src/com/fr/design/gui/itable/TableSorter.java b/designer_base/src/com/fr/design/gui/itable/TableSorter.java index 93b2c5154..4b2f2995c 100644 --- a/designer_base/src/com/fr/design/gui/itable/TableSorter.java +++ b/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,17 +343,14 @@ 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. + // If the table structure has changed, cancel the sorting; the + // 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 + // We can map a cell event through to the view without widening // when the following conditions apply: // // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, @@ -382,8 +379,7 @@ public class TableSorter extends AbstractTableModel { column, e.getType())); return; } - - // Something has happened to the data that may have invalidated the row order. + // Something has happened to the data that may have invalidated the row order. clearSortingState(); fireTableDataChanged(); return; @@ -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); } }