Browse Source

Merge pull request #921 in BA/design from ~HZZZ/design:REPORT-2773 to 9.0

* commit '79b0c94c75ccd777da8ab05060d5c7c8d8099582':
  PMD
  REPORT-2773 mac中复制快捷键的修复
master
superman 8 years ago
parent
commit
3559fae85f
  1. 9
      designer/src/com/fr/design/report/UnitFieldPane.java
  2. 23
      designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java
  3. 3
      designer_base/src/com/fr/design/gui/frpane/UITextPane.java
  4. 24
      designer_base/src/com/fr/design/gui/itextarea/UITextArea.java
  5. 16
      designer_base/src/com/fr/design/gui/itextfield/UINumberField.java
  6. 27
      designer_base/src/com/fr/design/gui/itextfield/UITextField.java

9
designer/src/com/fr/design/report/UnitFieldPane.java

@ -6,6 +6,8 @@ package com.fr.design.report;
import java.awt.Dimension;
import javax.swing.JFormattedTextField;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
@ -42,11 +44,11 @@ public class UnitFieldPane extends JPanel {
public void setUnitType(int unitType) {
if (unitType == Constants.UNIT_CM) {
this.setText(Inter.getLocText("Unit_CM"));
this.setText(Inter.getLocText("FR-Designer_Unit_CM"));
} else if (unitType == Constants.UNIT_INCH) {
this.setText(Inter.getLocText("PageSetup-inches"));
this.setText(Inter.getLocText("FR-Designer_Unit_INCH"));
} else {
this.setText(Inter.getLocText("PageSetup-mm"));
this.setText(Inter.getLocText("FR-Designer_Unit_MM-mm"));
}
//ajust the heigt of unitLabel.
@ -67,6 +69,7 @@ public class UnitFieldPane extends JPanel {
valueSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0));
textField = ((JSpinner.DefaultEditor) valueSpinner.getEditor()).getTextField();
textField.setColumns(4);
InputEventBaseOnOS.addBasicEditInputMap(textField);
this.add(valueSpinner);
unitLable = new UnitLabel(unitType, valueSpinner.getPreferredSize().height);
this.add(unitLable);

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

@ -2,9 +2,13 @@ package com.fr.common.inputevent;
import com.fr.stable.OperatingSystem;
import javax.swing.*;
import javax.swing.text.DefaultEditorKit;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* Created by hzzz on 2017/5/26.
*/
@ -18,4 +22,23 @@ public class InputEventBaseOnOS {
public static boolean isControlDown(KeyEvent e) {
return IS_MACOS ? e.isMetaDown() : e.isControlDown();
}
public static void addBasicEditInputMap(JComponent jComponent) {
InputMap inputMap = jComponent.getInputMap();
while (inputMap.getParent() != null) {
inputMap = inputMap.getParent();
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction);
}
}
}

3
designer_base/src/com/fr/design/gui/frpane/UITextPane.java

@ -1,5 +1,6 @@
package com.fr.design.gui.frpane;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
@ -22,11 +23,13 @@ public class UITextPane extends JTextPane implements UIObserver {
public UITextPane() {
super();
InputEventBaseOnOS.addBasicEditInputMap(this);
iniListener();
}
public UITextPane(StyledDocument doc) {
super(doc);
InputEventBaseOnOS.addBasicEditInputMap(this);
iniListener();
}

24
designer_base/src/com/fr/design/gui/itextarea/UITextArea.java

@ -1,5 +1,6 @@
package com.fr.design.gui.itextarea;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.utils.gui.GUICoreUtils;
@ -7,33 +8,14 @@ import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.DefaultEditorKit;
import java.awt.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class UITextArea extends JTextArea implements UIObserver {
private UIObserverListener uiObserverListener;
public UITextArea(int i, int j) {
super(i, j);
InputMap inputMap = this.getInputMap();
while (inputMap.getParent() != null) {
inputMap = inputMap.getParent();
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction);
}
InputEventBaseOnOS.addBasicEditInputMap(this);
initComponents();
}
@ -44,11 +26,13 @@ public class UITextArea extends JTextArea implements UIObserver {
public UITextArea() {
super();
InputEventBaseOnOS.addBasicEditInputMap(this);
initComponents();
}
public UITextArea(String s) {
super(s);
InputEventBaseOnOS.addBasicEditInputMap(this);
initComponents();
}

16
designer_base/src/com/fr/design/gui/itextfield/UINumberField.java

@ -1,20 +1,17 @@
package com.fr.design.gui.itextfield;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import com.fr.base.Utils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.*;
/**
* Number Field.
*/
@ -54,7 +51,6 @@ public class UINumberField extends UITextField {
this.maxDecimalLength = maxDecimalLength;
this.minValue = minValue;
this.maxValue = maxValue;
setFieldDocument();
}

27
designer_base/src/com/fr/design/gui/itextfield/UITextField.java

@ -1,5 +1,6 @@
package com.fr.design.gui.itextfield;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
@ -10,12 +11,8 @@ import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import java.awt.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* @author Jerry
@ -31,42 +28,32 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
public UITextField() {
super();
InputMap inputMap = this.getInputMap();
while (inputMap.getParent() != null) {
inputMap = inputMap.getParent();
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction);
}
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)) == null) {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction);
}
InputEventBaseOnOS.addBasicEditInputMap(this);
initListener();
}
public UITextField(int columns) {
super(columns);
InputEventBaseOnOS.addBasicEditInputMap(this);
initListener();
}
public UITextField(String text, int columns) {
super(text, columns);
InputEventBaseOnOS.addBasicEditInputMap(this);
initListener();
}
public UITextField(String text) {
super(text);
InputEventBaseOnOS.addBasicEditInputMap(this);
initListener();
}
public UITextField(Document doc, String text, int columns) {
super(doc, text, columns);
InputEventBaseOnOS.addBasicEditInputMap(this);
initListener();
}

Loading…
Cancel
Save