From 9bd59185bd2a9b1e9a3249ef611907d488e19564 Mon Sep 17 00:00:00 2001 From: hzzz Date: Tue, 23 May 2017 15:47:12 +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 --- .../file/newReport/NewPolyReportAction.java | 4 +++- .../file/newReport/NewWorkBookAction.java | 4 +++- .../fr/design/mainframe/ElementCasePane.java | 12 ++++++---- .../design/mainframe/FormatBrushAction.java | 2 +- .../fr/design/actions/edit/CopyAction.java | 4 +++- .../com/fr/design/actions/edit/CutAction.java | 4 +++- .../fr/design/actions/edit/PasteAction.java | 4 +++- .../gui/autocomplete/AutoCompletion.java | 5 ++-- .../design/gui/frpane/UIAdvancedTextPane.java | 8 ++++--- .../gui/icombobox/ExtendedComboBox.java | 4 +++- .../fr/design/gui/icombobox/UIComboBoxUI.java | 4 +++- .../gui/itabpane/UITabsHeaderIconPane.java | 4 +++- .../ui/rtextarea/RTADefaultInputMap.java | 24 +++++++------------ .../loghandler/DesignerLogHandler.java | 8 ++++--- .../src/com/fr/design/menu/KeySetUtils.java | 20 +++++++++------- .../designer/beans/actions/CopyAction.java | 4 +++- .../designer/beans/actions/CutAction.java | 4 +++- .../designer/beans/actions/PasteAction.java | 4 +++- .../mainframe/actions/NewFormAction.java | 4 +++- .../widget/editors/DataTableConfigPane.java | 4 +++- 20 files changed, 80 insertions(+), 51 deletions(-) diff --git a/designer/src/com/fr/design/actions/file/newReport/NewPolyReportAction.java b/designer/src/com/fr/design/actions/file/newReport/NewPolyReportAction.java index ea7785f7a..924d0c01d 100644 --- a/designer/src/com/fr/design/actions/file/newReport/NewPolyReportAction.java +++ b/designer/src/com/fr/design/actions/file/newReport/NewPolyReportAction.java @@ -11,13 +11,15 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JPolyWorkBook; import com.fr.general.Inter; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class NewPolyReportAction extends UpdateAction { public NewPolyReportAction() { this.setName(Inter.getLocText("M-New_Multi_Report")); this.setMnemonic('F'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/formExport.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, DEFAULT_MODIFIER)); } /** diff --git a/designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java b/designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java index 268adafbf..cda7a0aa1 100644 --- a/designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java +++ b/designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java @@ -12,6 +12,8 @@ import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class NewWorkBookAction extends UpdateAction { public NewWorkBookAction() { @@ -47,7 +49,7 @@ public class NewWorkBookAction extends UpdateAction { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_N, DEFAULT_MODIFIER); } }; diff --git a/designer/src/com/fr/design/mainframe/ElementCasePane.java b/designer/src/com/fr/design/mainframe/ElementCasePane.java index dcc68ab81..52bbc6393 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePane.java @@ -127,6 +127,8 @@ import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.unit.FU; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * This class used to edit Report. */ @@ -280,7 +282,7 @@ public abstract class ElementCasePane extends Tar } } }); - formatBrush.registerKeyboardAction(keyListener, KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); + formatBrush.registerKeyboardAction(keyListener, KeyStroke.getKeyStroke(KeyEvent.VK_B, DEFAULT_MODIFIER), JComponent.WHEN_IN_FOCUSED_WINDOW); formatBrush.registerKeyboardAction(escKey, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } @@ -855,7 +857,7 @@ public abstract class ElementCasePane extends Tar // clearReportPage old values. inputMapAncestor.clear(); actionMap.clear(); - inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK), "cut"); + inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), "cut"); actionMap.put("cut", new AbstractAction() { public void actionPerformed(ActionEvent evt) { if (cut()) { @@ -863,13 +865,13 @@ public abstract class ElementCasePane extends Tar } } }); - inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "copy"); + inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), "copy"); actionMap.put("copy", new AbstractAction() { public void actionPerformed(ActionEvent evt) { copy(); } }); - inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), "paste"); + inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), "paste"); actionMap.put("paste", new AbstractAction() { public void actionPerformed(ActionEvent evt) { if (paste()) { @@ -887,7 +889,7 @@ public abstract class ElementCasePane extends Tar } } }); - inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK), "delete_all"); + inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, DEFAULT_MODIFIER), "delete_all"); actionMap.put("delete_all", new AbstractAction() { public void actionPerformed(ActionEvent evt) { if (clearAll()) { diff --git a/designer/src/com/fr/design/mainframe/FormatBrushAction.java b/designer/src/com/fr/design/mainframe/FormatBrushAction.java index 296fb6d20..cf4c98448 100644 --- a/designer/src/com/fr/design/mainframe/FormatBrushAction.java +++ b/designer/src/com/fr/design/mainframe/FormatBrushAction.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.design.actions.ElementCaseAction; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Author : daisy * Date: 13-8-7 * Time: 上午11:05 */ public class FormatBrushAction extends ElementCaseAction { private ElementCasePane ePane; private CellSelection oldSelection; public FormatBrushAction(ElementCasePane t) { super(t); this.setName(Inter.getLocText("M_Edit-FormatBrush")); this.setMnemonic('B'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/formatBrush.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)); } public boolean executeActionReturnUndoRecordNeeded() { ePane = (ElementCasePane) getEditingComponent(); if (ePane != null) { Selection selection = ePane.getSelection(); if (!(selection instanceof CellSelection)) { return false; } oldSelection = ((CellSelection) selection).clone(); ePane.setFormatReferencedCell(oldSelection); int cellRectangleCount = oldSelection.getCellRectangleCount(); if (cellRectangleCount > 1) { //格式刷只支持单次选择的区域,如果用ctrl复选选中了多片区域,点击格式刷按钮时弹出提示 //判断是不是连续区域 //荣国是连续区域,那么这些长方形的长加起来应该等于 if (!isContinueArea()) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Can_not_use_FormatBursh")); ePane.setFormatState(DesignerContext.FORMAT_STATE_NULL); ePane.getFormatBrush().setSelected(false); return false; } } //只对单个区域进行格式刷操作 ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setNotShowingTableSelectPane(false); ePane.repaint(); return true; } return false; } /** * 判断是不是连续区域 * * @return */ private boolean isContinueArea() { int xStart = oldSelection.getCellRectangle(1).x; int xend = 0; int yStrat = oldSelection.getCellRectangle(1).y; int yend = 0; int totalNum = 0; for (int i = 0; i < oldSelection.getCellRectangleCount(); i++) { Rectangle temp = oldSelection.getCellRectangle(i); if (temp.getX() < xStart) { xStart = temp.x; } if (temp.getX() + temp.getWidth() > xend) { xend = (int) (temp.getX() + temp.getWidth()); } if (temp.getY() < yStrat) { yStrat = temp.y; } if (temp.getY() + temp.getHeight() > yend) { yend = (int) (temp.getY() + temp.getHeight()); } totalNum += (int) (temp.getWidth() * temp.getHeight()); } if ((xend - xStart) * (yend - yStrat) == totalNum) { oldSelection = new CellSelection(xStart, yStrat, (xend - xStart), (yend - yStrat)); ePane.setSelection(oldSelection); ePane.setFormatReferencedCell(oldSelection); return true; } return false; } public void updateFormatBrush(Style[][] referencedStyle, CellSelection cs, ElementCasePane reportPane) { //得到被参照的单元格的行列数 if (referencedStyle == null) { return; } int rowSpan = referencedStyle[0].length; int columnSpan = referencedStyle.length; //开始进行格式刷样式复制 TemplateElementCase elementCase = reportPane.getEditingElementCase(); int rowNum = cs.getRowSpan(); int columnNum = cs.getColumnSpan(); //如果只点选了一个,则自动补足 if (cs.getColumnSpan() * cs.getRowSpan() == 1) { rowNum = rowSpan; columnNum = columnSpan; } for (int j = 0; j < rowNum; j++) { for (int i = 0; i < columnNum; i++) { int column = i + cs.getColumn(); int row = j + cs.getRow(); TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(cellElement); } cellElement.setStyle(referencedStyle[i % columnSpan][j % rowSpan]); } } } private Style[][] getOldStyles(CellSelection oldSelection) { Style[][] referencedStyle = new Style[oldSelection.getColumnSpan()][oldSelection.getRowSpan()]; int cellRectangleCount = oldSelection.getCellRectangleCount(); TemplateElementCase elementCase = ePane.getEditingElementCase(); for (int rect = 0; rect < cellRectangleCount; rect++) { Rectangle cellRectangle = oldSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(cellElement); } Style style = cellElement.getStyle(); if (style == null) { style = style.DEFAULT_STYLE; } referencedStyle[i][j] = style; } } } return referencedStyle; } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.design.actions.ElementCaseAction; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import javax.swing.*; import java.awt.*; import java.awt.event.*; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; /** * Author : daisy * Date: 13-8-7 * Time: 上午11:05 */ public class FormatBrushAction extends ElementCaseAction { private ElementCasePane ePane; private CellSelection oldSelection; public FormatBrushAction(ElementCasePane t) { super(t); this.setName(Inter.getLocText("M_Edit-FormatBrush")); this.setMnemonic('B'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/formatBrush.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, DEFAULT_MODIFIER)); } public boolean executeActionReturnUndoRecordNeeded() { ePane = (ElementCasePane) getEditingComponent(); if (ePane != null) { Selection selection = ePane.getSelection(); if (!(selection instanceof CellSelection)) { return false; } oldSelection = ((CellSelection) selection).clone(); ePane.setFormatReferencedCell(oldSelection); int cellRectangleCount = oldSelection.getCellRectangleCount(); if (cellRectangleCount > 1) { //格式刷只支持单次选择的区域,如果用ctrl复选选中了多片区域,点击格式刷按钮时弹出提示 //判断是不是连续区域 //荣国是连续区域,那么这些长方形的长加起来应该等于 if (!isContinueArea()) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Can_not_use_FormatBursh")); ePane.setFormatState(DesignerContext.FORMAT_STATE_NULL); ePane.getFormatBrush().setSelected(false); return false; } } //只对单个区域进行格式刷操作 ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setNotShowingTableSelectPane(false); ePane.repaint(); return true; } return false; } /** * 判断是不是连续区域 * * @return */ private boolean isContinueArea() { int xStart = oldSelection.getCellRectangle(1).x; int xend = 0; int yStrat = oldSelection.getCellRectangle(1).y; int yend = 0; int totalNum = 0; for (int i = 0; i < oldSelection.getCellRectangleCount(); i++) { Rectangle temp = oldSelection.getCellRectangle(i); if (temp.getX() < xStart) { xStart = temp.x; } if (temp.getX() + temp.getWidth() > xend) { xend = (int) (temp.getX() + temp.getWidth()); } if (temp.getY() < yStrat) { yStrat = temp.y; } if (temp.getY() + temp.getHeight() > yend) { yend = (int) (temp.getY() + temp.getHeight()); } totalNum += (int) (temp.getWidth() * temp.getHeight()); } if ((xend - xStart) * (yend - yStrat) == totalNum) { oldSelection = new CellSelection(xStart, yStrat, (xend - xStart), (yend - yStrat)); ePane.setSelection(oldSelection); ePane.setFormatReferencedCell(oldSelection); return true; } return false; } public void updateFormatBrush(Style[][] referencedStyle, CellSelection cs, ElementCasePane reportPane) { //得到被参照的单元格的行列数 if (referencedStyle == null) { return; } int rowSpan = referencedStyle[0].length; int columnSpan = referencedStyle.length; //开始进行格式刷样式复制 TemplateElementCase elementCase = reportPane.getEditingElementCase(); int rowNum = cs.getRowSpan(); int columnNum = cs.getColumnSpan(); //如果只点选了一个,则自动补足 if (cs.getColumnSpan() * cs.getRowSpan() == 1) { rowNum = rowSpan; columnNum = columnSpan; } for (int j = 0; j < rowNum; j++) { for (int i = 0; i < columnNum; i++) { int column = i + cs.getColumn(); int row = j + cs.getRow(); TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(cellElement); } cellElement.setStyle(referencedStyle[i % columnSpan][j % rowSpan]); } } } private Style[][] getOldStyles(CellSelection oldSelection) { Style[][] referencedStyle = new Style[oldSelection.getColumnSpan()][oldSelection.getRowSpan()]; int cellRectangleCount = oldSelection.getCellRectangleCount(); TemplateElementCase elementCase = ePane.getEditingElementCase(); for (int rect = 0; rect < cellRectangleCount; rect++) { Rectangle cellRectangle = oldSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(cellElement); } Style style = cellElement.getStyle(); if (style == null) { style = style.DEFAULT_STYLE; } referencedStyle[i][j] = style; } } } return referencedStyle; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/edit/CopyAction.java b/designer_base/src/com/fr/design/actions/edit/CopyAction.java index d0579a579..b3a932ba5 100644 --- a/designer_base/src/com/fr/design/actions/edit/CopyAction.java +++ b/designer_base/src/com/fr/design/actions/edit/CopyAction.java @@ -11,6 +11,8 @@ import com.fr.general.Inter; import javax.swing.*; import java.awt.event.KeyEvent; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Copy. */ @@ -21,7 +23,7 @@ public class CopyAction extends TemplateComponentAction { this.setName(Inter.getLocText("M_Edit-Copy")); this.setMnemonic('C'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); } @Override diff --git a/designer_base/src/com/fr/design/actions/edit/CutAction.java b/designer_base/src/com/fr/design/actions/edit/CutAction.java index 735ec5bf3..b0e7847a6 100644 --- a/designer_base/src/com/fr/design/actions/edit/CutAction.java +++ b/designer_base/src/com/fr/design/actions/edit/CutAction.java @@ -12,6 +12,8 @@ import com.fr.design.actions.TemplateComponentAction; import com.fr.design.designer.TargetComponent; import com.fr.general.Inter; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Cut. */ @@ -25,7 +27,7 @@ public class CutAction extends TemplateComponentAction { this.setName(Inter.getLocText("M_Edit-Cut")); this.setMnemonic('T'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); } @Override diff --git a/designer_base/src/com/fr/design/actions/edit/PasteAction.java b/designer_base/src/com/fr/design/actions/edit/PasteAction.java index f6b71e421..4ca42c0f2 100644 --- a/designer_base/src/com/fr/design/actions/edit/PasteAction.java +++ b/designer_base/src/com/fr/design/actions/edit/PasteAction.java @@ -12,6 +12,8 @@ import com.fr.design.actions.TemplateComponentAction; import com.fr.design.designer.TargetComponent; import com.fr.general.Inter; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Paste. */ @@ -25,7 +27,7 @@ public class PasteAction extends TemplateComponentAction { this.setName(Inter.getLocText("M_Edit-Paste")); this.setMnemonic('P'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); } @Override diff --git a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java index 83047ad71..122beb1e6 100644 --- a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java +++ b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java @@ -20,6 +20,8 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.*; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Adds auto-completion to a text component. Provides a popup window with a @@ -308,8 +310,7 @@ public class AutoCompletion { */ public static KeyStroke getDefaultTriggerKey() { // Default to CTRL, even on Mac, since Ctrl+Space activates Spotlight - int mask = InputEvent.CTRL_MASK; - return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, mask); + return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, DEFAULT_MODIFIER); } diff --git a/designer_base/src/com/fr/design/gui/frpane/UIAdvancedTextPane.java b/designer_base/src/com/fr/design/gui/frpane/UIAdvancedTextPane.java index 0194551da..8ce8ec1a0 100644 --- a/designer_base/src/com/fr/design/gui/frpane/UIAdvancedTextPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/UIAdvancedTextPane.java @@ -20,6 +20,8 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.menu.KeySetUtils; import com.fr.general.Inter; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * p:这是一个增强的JTextPane,支持很多Action */ @@ -143,7 +145,7 @@ public class UIAdvancedTextPane extends UITextPane { setName(Inter.getLocText("M_Edit-Cut")); setMnemonic('T'); setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); - setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)); + setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); } public void actionPerformed(ActionEvent evt) { @@ -162,7 +164,7 @@ public class UIAdvancedTextPane extends UITextPane { this.setName(Inter.getLocText("M_Edit-Copy")); this.setMnemonic('C'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); } public void actionPerformed(ActionEvent evt) { @@ -181,7 +183,7 @@ public class UIAdvancedTextPane extends UITextPane { this.setName(Inter.getLocText("M_Edit-Paste")); this.setMnemonic('P'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); } public void actionPerformed(ActionEvent evt) { diff --git a/designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java b/designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java index 86a5b5cf2..47ddbdac3 100644 --- a/designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java +++ b/designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java @@ -17,6 +17,8 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.ComboPopup; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class ExtendedComboBox extends UIComboBox { private static final int VALUE120 = 120; @@ -79,7 +81,7 @@ public class ExtendedComboBox extends UIComboBox { // Key from the list. // ie., don't allow CTRL key deselection. e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers() - ^ InputEvent.CTRL_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); + ^ DEFAULT_MODIFIER, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } super.processMouseEvent(e); } diff --git a/designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java b/designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java index 28ae0aebf..ae1089fa9 100644 --- a/designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java +++ b/designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java @@ -24,6 +24,8 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.stable.Constants; import com.fr.stable.StringUtils; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * @author zhou F * @since 2012-5-9下午4:33:07 @@ -208,7 +210,7 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { @Override public void processMouseEvent(MouseEvent e) { if (e.isControlDown()) { - e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ InputEvent.CTRL_MASK, e.getX(), e.getY(), e.getClickCount(), + e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ DEFAULT_MODIFIER, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } super.processMouseEvent(e); diff --git a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java index 1ba60ed57..1ec189cc1 100644 --- a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java +++ b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java @@ -32,6 +32,8 @@ import com.fr.design.gui.core.UITabComponent; import com.fr.design.gui.ibutton.UITabButton; import com.fr.stable.StringUtils; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * 本来想弄个延迟加载的,发现在单元格属性表那边没有意义,就算了.这个面板是纯粹的,没有与模板的任何交互操作(比如说populate() update()) * @@ -125,7 +127,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent { inputMapAncestor.clear(); actionMap.clear(); - inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_MASK), "switch"); + inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, DEFAULT_MODIFIER), "switch"); actionMap.put("switch", new AbstractAction() { /** diff --git a/designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java b/designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java index 5e1a7cfe7..35a1995ed 100644 --- a/designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java +++ b/designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java @@ -41,6 +41,14 @@ import javax.swing.text.DefaultEditorKit; public class RTADefaultInputMap extends InputMap { + /** + * Returns the default modifier key for a system. For example, on Windows + * this would be the CTRL key (InputEvent.CTRL_MASK). + * + * @return The default modifier key. + */ + public static final int DEFAULT_MODIFIER = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + /** * Constructs the default input map for an RTextArea. */ @@ -48,7 +56,7 @@ public class RTADefaultInputMap extends InputMap { super(); - int defaultModifier = getDefaultModifier(); + int defaultModifier = DEFAULT_MODIFIER; //int ctrl = InputEvent.CTRL_MASK; int alt = InputEvent.ALT_MASK; int shift = InputEvent.SHIFT_MASK; @@ -134,18 +142,4 @@ public class RTADefaultInputMap extends InputMap { */ } - - - /** - * Returns the default modifier key for a system. For example, on Windows - * this would be the CTRL key (InputEvent.CTRL_MASK). - * - * @return The default modifier key. - */ - protected static final int getDefaultModifier() { - return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - } - - - } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 501f957df..59afdba51 100644 --- a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -24,6 +24,8 @@ import java.util.Date; import java.util.logging.Handler; import java.util.logging.LogRecord; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class DesignerLogHandler { protected static final int INFO_INT = FRLogLevel.INFO.intValue(); protected static final int ERRO_INT = FRLogLevel.ERROR.intValue(); @@ -158,9 +160,9 @@ public class DesignerLogHandler { clear.setIcon(BaseUtils.readIcon("/com/fr/design/images/log/clear.png")); popup.add(clear); - selectAll.setAccelerator(KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK)); - copy.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_MASK)); - clear.setAccelerator(KeyStroke.getKeyStroke('L', InputEvent.CTRL_MASK)); + selectAll.setAccelerator(KeyStroke.getKeyStroke('A', DEFAULT_MODIFIER)); + copy.setAccelerator(KeyStroke.getKeyStroke('C', DEFAULT_MODIFIER)); + clear.setAccelerator(KeyStroke.getKeyStroke('L', DEFAULT_MODIFIER)); jTextArea.addMouseListener(new MouseAdapter() { // check for right click diff --git a/designer_base/src/com/fr/design/menu/KeySetUtils.java b/designer_base/src/com/fr/design/menu/KeySetUtils.java index 1b62fcdc4..401da7fb9 100644 --- a/designer_base/src/com/fr/design/menu/KeySetUtils.java +++ b/designer_base/src/com/fr/design/menu/KeySetUtils.java @@ -12,6 +12,8 @@ import javax.swing.*; import java.awt.event.KeyEvent; import java.util.Locale; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Created by IntelliJ IDEA. * Author : daisy @@ -36,7 +38,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MODIFIER); } }; @@ -71,7 +73,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_W, DEFAULT_MODIFIER); } }; @@ -88,7 +90,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_S, DEFAULT_MODIFIER); } }; @@ -122,7 +124,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_Z, DEFAULT_MODIFIER); } }; @@ -139,7 +141,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_Y, DEFAULT_MODIFIER); } }; @@ -156,7 +158,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_E, DEFAULT_MODIFIER); } }; @@ -353,7 +355,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_M, DEFAULT_MODIFIER); } }; @@ -370,7 +372,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_E, DEFAULT_MODIFIER); } }; @@ -387,7 +389,7 @@ public class KeySetUtils { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_E, DEFAULT_MODIFIER); } }; diff --git a/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java b/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java index 23686f651..d3906040d 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java @@ -8,6 +8,8 @@ import javax.swing.*; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class CopyAction extends FormEditAction { public CopyAction(FormDesigner t) { @@ -15,7 +17,7 @@ public class CopyAction extends FormEditAction { this.setName(Inter.getLocText("M_Edit-Copy")); this.setMnemonic('C'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); } @Override diff --git a/designer_form/src/com/fr/design/designer/beans/actions/CutAction.java b/designer_form/src/com/fr/design/designer/beans/actions/CutAction.java index 9acb26148..1f81c1280 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/CutAction.java @@ -9,6 +9,8 @@ import com.fr.base.BaseUtils; import com.fr.general.Inter; import com.fr.design.mainframe.FormDesigner; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class CutAction extends FormEditAction { public CutAction(FormDesigner t) { @@ -16,7 +18,7 @@ public class CutAction extends FormEditAction { this.setName(Inter.getLocText("M_Edit-Cut")); this.setMnemonic('T'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); } @Override diff --git a/designer_form/src/com/fr/design/designer/beans/actions/PasteAction.java b/designer_form/src/com/fr/design/designer/beans/actions/PasteAction.java index 85ce1d6ed..351a809f6 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/PasteAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/PasteAction.java @@ -9,6 +9,8 @@ import com.fr.base.BaseUtils; import com.fr.general.Inter; import com.fr.design.mainframe.FormDesigner; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class PasteAction extends FormEditAction { public PasteAction(FormDesigner t) { @@ -16,7 +18,7 @@ public class PasteAction extends FormEditAction { this.setName(Inter.getLocText("M_Edit-Paste")); this.setMnemonic('P'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); } @Override diff --git a/designer_form/src/com/fr/design/mainframe/actions/NewFormAction.java b/designer_form/src/com/fr/design/mainframe/actions/NewFormAction.java index 107b9da58..78b17d4b3 100644 --- a/designer_form/src/com/fr/design/mainframe/actions/NewFormAction.java +++ b/designer_form/src/com/fr/design/mainframe/actions/NewFormAction.java @@ -14,6 +14,8 @@ import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class NewFormAction extends UpdateAction { public NewFormAction() { @@ -48,7 +50,7 @@ public class NewFormAction extends UpdateAction { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK); + return KeyStroke.getKeyStroke(KeyEvent.VK_F, DEFAULT_MODIFIER); } }; } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java index 36c54f4ec..417d761cc 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java @@ -21,6 +21,8 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class DataTableConfigPane extends JComponent implements PropertyChangeListener { private DataEditingTable table; @@ -183,7 +185,7 @@ public class DataTableConfigPane extends JComponent implements PropertyChangeLis this.setName(Inter.getLocText("M_Edit-Cut")); this.setMnemonic('T'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK)); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); } @Override