Browse Source

Merge pull request #903 in BA/design from ~HZZZ/design:fix-REPORT-2773 to dev

* commit 'ac5976346ac2ce30299cf629d062c78ed029e458':
  PMD
  PMD
  PMD
  PMD
  REPORT-2773 mac中复制快捷键的修复
  PMD
  PMD
  REPORT-2773 mac中复制快捷键的修复
  REPORT-2773 mac中复制快捷键的修复
master
superman 8 years ago
parent
commit
d30d8bfc7b
  1. 366
      designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java
  2. 32
      designer/src/com/fr/grid/GridKeyListener.java
  3. 27
      designer/src/com/fr/grid/GridMouseAdapter.java
  4. 21
      designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java
  5. 4
      designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java
  6. 3
      designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java
  7. 49
      designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java
  8. 14
      designer_base/src/com/fr/design/gui/itable/TableSorter.java
  9. 3
      designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java
  10. 3
      designer_base/src/com/fr/design/roleAuthority/UIRoleTreeUI.java
  11. 5
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

366
designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java

File diff suppressed because one or more lines are too long

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

@ -1,22 +1,23 @@
package com.fr.grid;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.mainframe.ElementCasePane;
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 java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/**
*
* @editor zhou
* @since 2012-3-23上午10:55:36
*/
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;
@ -30,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();
@ -46,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()));
@ -70,14 +67,12 @@ public class GridKeyListener implements KeyListener {
}
// Richie:Ctrl + A全选单元格
case KeyEvent.VK_A:
if (code == KeyEvent.VK_A && evt.isControlDown()) {
if (InputEventBaseOnOS.isControlDown(evt)) {
reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount()));
isNeedRepaint = true;
}
isNeedRepaint = true;
break;
}
if (isNeedRepaint) {
reportPane.repaint();
}
@ -166,7 +161,7 @@ public class GridKeyListener implements KeyListener {
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null || evt.isControlDown()) {// uneditable.
if (newEvt == null || InputEventBaseOnOS.isControlDown(evt)) {// uneditable.
return;
}
char ch = evt.getKeyChar();
@ -187,8 +182,7 @@ public class GridKeyListener implements KeyListener {
if (grid.getCellEditor() != null && grid.editorComponent != null) {
if (IS_NUM_PAD_KEY(code)) {
// 103 - 55 = 48, 小键盘和大键盘数字的差值 48
KeyEvent ke = new KeyEvent(grid, KeyEvent.KEY_PRESSED, 0, 0, code - 48, ch);
KeyEvent ke = new KeyEvent(grid, KeyEvent.KEY_PRESSED, 0, 0, code - DIFF, ch);
grid.editorComponent.dispatchEvent(ke);
ke.consume();
} else {
@ -200,8 +194,10 @@ public class GridKeyListener implements KeyListener {
}
}
}
/**
* 小键盘
*
* @param code
* @return
*/

27
designer/src/com/fr/grid/GridMouseAdapter.java

@ -1,26 +1,14 @@
package com.fr.grid;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.present.CellWriteAttrPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
@ -37,7 +25,12 @@ import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.OLDPIX;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;
import java.util.Map;
/**
* the MouseListener of the Grid
@ -172,7 +165,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
ElementCasePane reportPane = grid.getElementCasePane();
TemplateElementCase report = reportPane.getEditingElementCase();
boolean isShiftDown = evt.isShiftDown();
boolean isControlDown = evt.isControlDown();
boolean isControlDown = InputEventBaseOnOS.isControlDown(evt);
int clickCount = evt.getClickCount();
// peter:需要判断是否在可移动CellSelection的区域
grid.setDragType(isMoveCellSelection(this.oldEvtX, this.oldEvtY));
@ -344,7 +337,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
return;
}
boolean isControlDown = evt.isControlDown();
boolean isControlDown = InputEventBaseOnOS.isControlDown(evt);
long systemCurrentTime = System.currentTimeMillis();
if (systemCurrentTime - lastMouseMoveTime <= DRAG_REFRESH_TIME) {// alex:Drag

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

@ -0,0 +1,21 @@
package com.fr.common.inputevent;
import com.fr.stable.OperatingSystem;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/**
* Created by hzzz on 2017/5/26.
*/
public class InputEventBaseOnOS {
private static final boolean IS_MACOS = OperatingSystem.isMacOS();
public static boolean isControlDown(MouseEvent e) {
return IS_MACOS ? e.isMetaDown() : e.isControlDown();
}
public static boolean isControlDown(KeyEvent e) {
return IS_MACOS ? e.isMetaDown() : e.isControlDown();
}
}

4
designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java

@ -1,5 +1,7 @@
package com.fr.design.gui.icombobox;
import com.fr.common.inputevent.InputEventBaseOnOS;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
@ -76,7 +78,7 @@ public class ExtendedComboBox extends UIComboBox {
protected JList createList() {
return new JList(comboBox.getModel()) {
public void processMouseEvent(MouseEvent e) {
if (e.isControlDown()) {
if (InputEventBaseOnOS.isControlDown(e)) {
// Fix for 4234053. Filter out the Control
// Key from the list.
// ie., don't allow CTRL key deselection.

3
designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java

@ -16,6 +16,7 @@ import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.constants.UIConstants;
import sun.swing.DefaultLookup;
@ -209,7 +210,7 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener {
@Override
public void processMouseEvent(MouseEvent e) {
if (e.isControlDown()) {
if (InputEventBaseOnOS.isControlDown(e)) {
e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ DEFAULT_MODIFIER, e.getX(), e.getY(), e.getClickCount(),
e.isPopupTrigger());
}

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

@ -1,34 +1,24 @@
package com.fr.design.gui.ilist;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EventListener;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.stable.StringUtils;
/**
* CheckBoxs + JList.
*/
public class CheckBoxList extends JComponent {
private final static int X_COORDINATE = 20;
/**
* 选择状态----全选和全不选
*
@ -54,10 +44,8 @@ public class CheckBoxList extends JComponent {
/**
* Class constructor.
*
* @param items
* Items with which to populate the list.
* @param default_state
* default state, true or false
* @param items Items with which to populate the list.
* @param state default state, true or false
*/
public CheckBoxList(Object[] items, SelectedState state, String name) {
jlist = new BOXLIST(items);
@ -175,8 +163,9 @@ public class CheckBoxList extends JComponent {
@Override
protected void processMouseEvent(MouseEvent e) {
if (e.getX() < 20) {
if (e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) {
if (e.getX() < X_COORDINATE) {
boolean anyMaskDown = e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown();
if (anyMaskDown) {
int[] indices = getSelectedIndices();
if (indices.length == 0) {
super.processMouseEvent(e);
@ -205,7 +194,7 @@ public class CheckBoxList extends JComponent {
@Override
protected void processMouseMotionEvent(MouseEvent e) {
if (e.getX() < 20) {
if (e.getX() < X_COORDINATE) {
return;
}
@ -246,13 +235,13 @@ public class CheckBoxList extends JComponent {
repaint();
}
private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer {
public CheckListCellRenderer() {
this.setOpaque(true);
this.setBorder(noFocusBorder);
this.setBorder(NO_FOCUS_BORDER);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@ -271,7 +260,7 @@ public class CheckBoxList extends JComponent {
if (cellHasFocus) {
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
} else {
this.setBorder(noFocusBorder);
this.setBorder(NO_FOCUS_BORDER);
}
return this;

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

@ -15,6 +15,8 @@ import java.util.List;
import java.util.Map;
import javax.swing.Icon;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
@ -79,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;
@ -341,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:
//
@ -380,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();
@ -396,13 +394,13 @@ public class TableSorter extends AbstractTableModel {
int column = columnModel.getColumn(viewColumn).getModelIndex();
if (column != -1) {
int status = getSortingStatus(column);
if (!e.isControlDown()) {
if (!InputEventBaseOnOS.isControlDown(e)) {
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}
status = (status + ADD) % 3 - 1; // signed mod, returning {-1, 0, 1}
setSortingStatus(column, status);
}
}

3
designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java

@ -1,5 +1,6 @@
package com.fr.design.gui.itree.refreshabletree;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.general.NameObject;
import com.fr.design.gui.itree.refreshabletree.loader.ChildrenLoaderFactory;
import com.fr.general.ComparatorUtils;
@ -147,7 +148,7 @@ public abstract class UserObjectRefreshJTree<T extends UserObjectOP<?>> extends
}
}
// marks:鼠标在上次选中的paths上,则将上次的paths设为的树的路径,否则将鼠标所在的节点设为选中的节点
if (!(e.isShiftDown() || e.isControlDown())) {
if (!(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e))) {
if (isFind) {
setSelectionPaths(oldPaths);
} else {

3
designer_base/src/com/fr/design/roleAuthority/UIRoleTreeUI.java

@ -1,5 +1,6 @@
package com.fr.design.roleAuthority;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.gui.itree.UITreeUI;
import javax.swing.tree.TreePath;
@ -15,7 +16,7 @@ import java.awt.event.MouseEvent;
public class UIRoleTreeUI extends UITreeUI {
protected void selectPathForEvent(TreePath path, MouseEvent event) { /* Adjust from the anchor point. */
if (event.isControlDown() && tree.isPathSelected(path)) {
if (InputEventBaseOnOS.isControlDown(event) && tree.isPathSelected(path)) {
tree.removeSelectionPath(path);
} else if (event.isShiftDown()) {
tree.setAnchorSelectionPath(null);

5
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -1,5 +1,6 @@
package com.fr.design.designer.beans.models;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
@ -61,7 +62,7 @@ public class SelectionModel {
* @param e 鼠标事件
*/
public void selectACreatorAtMouseEvent(MouseEvent e) {
if (!e.isControlDown() && !e.isShiftDown()) {
if (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown()) {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
selection.reset();
}
@ -372,7 +373,7 @@ public class SelectionModel {
public Direction getDirectionAt(MouseEvent e) {
Direction dir;
if (e.isControlDown() || e.isShiftDown()) {
if (InputEventBaseOnOS.isControlDown(e) || e.isShiftDown()) {
XCreator creator = designer.getComponentAt(e.getX(), e.getY(), selection.getSelectedCreators());
if (creator != designer.getRootComponent() && selection.addedable(creator)) {
return Location.add;

Loading…
Cancel
Save