From 6f119a3d2126683a3b5c2d24b05acdd0e1242dd0 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 24 May 2017 20:09:10 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-2773=20mac=E4=B8=AD=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E7=9A=84=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/gui/ilist/UIList.java | 24 ++------ .../fr/design/gui/itextarea/UITextArea.java | 8 +-- .../fr/design/gui/itextfield/UITextField.java | 8 +-- .../gui/itree/checkboxtree/CheckBoxTree.java | 60 +++++++------------ 4 files changed, 37 insertions(+), 63 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ilist/UIList.java b/designer_base/src/com/fr/design/gui/ilist/UIList.java index 2a31fe6c3..8916cf18c 100644 --- a/designer_base/src/com/fr/design/gui/ilist/UIList.java +++ b/designer_base/src/com/fr/design/gui/ilist/UIList.java @@ -6,14 +6,10 @@ import com.fr.design.mainframe.JTemplate; import com.fr.stable.StringUtils; import javax.swing.*; -import javax.swing.text.DefaultEditorKit; import java.awt.*; -import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.Vector; -import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; - /** * Created with IntelliJ IDEA. * User: pony @@ -21,20 +17,11 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M * Time: 上午11:07 * To change this template use File | Settings | File Templates. */ -public class UIList extends JList{ +public class UIList extends JList { private Icon icon; public UIList() { super(); - InputMap inputMap = this.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), - DefaultEditorKit.selectAllAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), - DefaultEditorKit.copyAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), - DefaultEditorKit.pasteAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), - DefaultEditorKit.cutAction); } public UIList(ListModel dataModel) { @@ -59,12 +46,12 @@ public class UIList extends JList{ if (rendererComp.getPreferredSize().width > getVisibleRect().width) { String tips = (rendererComp instanceof JComponent) ? ((JComponent) rendererComp).getToolTipText() : null; if (tips == null) { - if(value instanceof JTemplate){ + if (value instanceof JTemplate) { tips = ((JTemplate) value).getEditingFILE().getName(); icon = ((JTemplate) value).getEditingFILE().getIcon(); - } else if (value instanceof ListModelElement || value instanceof TableProcedure){ - tips = ((JLabel)rendererComp).getText(); - icon = ((JLabel)rendererComp).getIcon(); + } else if (value instanceof ListModelElement || value instanceof TableProcedure) { + tips = ((JLabel) rendererComp).getText(); + icon = ((JLabel) rendererComp).getIcon(); } } return tips; @@ -84,6 +71,7 @@ public class UIList extends JList{ } return null; } + public JToolTip createToolTip() { UIToolTip tip = new UIToolTip(icon); tip.setComponent(this); diff --git a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java index 8194b10ce..03a70a6ef 100644 --- a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java +++ b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java @@ -19,13 +19,13 @@ public class UITextArea extends JTextArea implements UIObserver { public UITextArea(int i, int j) { super(i, j); InputMap inputMap = this.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction); initComponents(); } diff --git a/designer_base/src/com/fr/design/gui/itextfield/UITextField.java b/designer_base/src/com/fr/design/gui/itextfield/UITextField.java index ff4556acb..0af105058 100644 --- a/designer_base/src/com/fr/design/gui/itextfield/UITextField.java +++ b/designer_base/src/com/fr/design/gui/itextfield/UITextField.java @@ -33,13 +33,13 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); InputMap inputMap = this.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction); initListener(); } diff --git a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java index c56efdfd6..a22264477 100644 --- a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java +++ b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java @@ -5,8 +5,14 @@ */ package com.fr.design.gui.itree.checkboxtree; -import java.awt.Component; -import java.awt.Rectangle; +import com.fr.design.gui.icheckbox.UICheckBox; + +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.text.Position; +import javax.swing.tree.*; +import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; @@ -16,19 +22,6 @@ import java.beans.PropertyChangeListener; import java.util.Hashtable; import java.util.Vector; -import javax.swing.*; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.Position; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; - -import com.fr.design.gui.icheckbox.UICheckBox; - import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; /** @@ -39,11 +32,11 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M * select one or several tree nodes and press SPACE key to toggle the * check box selection for all selected tree nodes. *

- * In order to retrieve which tree paths are selected, you need to call + * In order to retrieve which tree paths are selected, you need to call * {@link #getCheckBoxTreeSelectionModel()}. - * It will return the selection model that keeps track of which tree + * It will return the selection model that keeps track of which tree * paths have been checked. For example - * {@link CheckBoxTreeSelectionModel#getSelectionPaths()} + * {@link CheckBoxTreeSelectionModel#getSelectionPaths()} * will give the list of paths which have * been checked. */ @@ -90,8 +83,7 @@ public class CheckBoxTree extends JTree { public CheckBoxTree(TreeModel newModel) { super(newModel); InputMap inputMap = this.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), - "selectAll"); + inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), "selectAll"); init(); } @@ -116,7 +108,7 @@ public class CheckBoxTree extends JTree { addPropertyChangeListener(JTree.SELECTION_MODEL_PROPERTY, _modelChangeListener); updateRowMapper(); } - + /** * Inserts the mouse listener at the particular index in the listeners' chain. * @@ -127,7 +119,7 @@ public class CheckBoxTree extends JTree { private void insertMouseListener(Component component, MouseListener l, int index) { MouseListener[] listeners = component.getMouseListeners(); for (int i = 0, length = listeners.length; i < length; i++) { - component.removeMouseListener(listeners[i]); + component.removeMouseListener(listeners[i]); } // for (MouseListener listener : listeners) { // component.removeMouseListener(listener); @@ -173,7 +165,7 @@ public class CheckBoxTree extends JTree { * Gets the cell renderer with check box. * * @return CheckBoxTree's own cell renderer which has the check box. The actual cell renderer - * you set by setCellRenderer() can be accessed by using {@link #getActualCellRenderer()}. + * you set by setCellRenderer() can be accessed by using {@link #getActualCellRenderer()}. */ public TreeCellRenderer getCellRenderer() { TreeCellRenderer cellRenderer = super.getCellRenderer(); @@ -182,8 +174,7 @@ public class CheckBoxTree extends JTree { } if (_treeCellRenderer == null) { _treeCellRenderer = createCellRenderer(cellRenderer); - } - else { + } else { _treeCellRenderer.setActualTreeRenderer(cellRenderer); } return _treeCellRenderer; @@ -199,8 +190,7 @@ public class CheckBoxTree extends JTree { public TreeCellRenderer getActualCellRenderer() { if (_treeCellRenderer != null) { return _treeCellRenderer.getActualTreeRenderer(); - } - else { + } else { return super.getCellRenderer(); } } @@ -255,8 +245,7 @@ public class CheckBoxTree extends JTree { if (clicksInCheckBox(e, path)) { return path; - } - else { + } else { return null; } } @@ -264,13 +253,11 @@ public class CheckBoxTree extends JTree { protected boolean clicksInCheckBox(MouseEvent e, TreePath path) { if (!_tree.isCheckBoxVisible(path)) { return false; - } - else { + } else { Rectangle bounds = _tree.getPathBounds(path); if (_tree.getComponentOrientation().isLeftToRight()) { return e.getX() < bounds.x + _hotspot; - } - else { + } else { return e.getX() > bounds.x + bounds.width - _hotspot; } } @@ -354,8 +341,7 @@ public class CheckBoxTree extends JTree { selectionModel.removeSelectionPath(path); else selectionModel.addSelectionPath(path); - } - finally { + } finally { if (!selectionModel.isSingleEventMode()) { selectionModel.setBatchMode(false); } @@ -370,8 +356,8 @@ public class CheckBoxTree extends JTree { return; } for (int i = 0, length = treePaths.length; i < length; i++) { - TreePath tmpTreePath = treePaths[i]; - toggleSelection(tmpTreePath); + TreePath tmpTreePath = treePaths[i]; + toggleSelection(tmpTreePath); } // for (TreePath treePath : treePaths) { // toggleSelection(treePath);