Browse Source

Merge remote-tracking branch 'origin/dev' into dev

master
mengao 8 years ago
parent
commit
de88676473
  1. 4
      designer/src/com/fr/design/actions/file/newReport/NewPolyReportAction.java
  2. 4
      designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java
  3. 366
      designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java
  4. 12
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  5. 172
      designer/src/com/fr/design/mainframe/FormatBrushAction.java
  6. 392
      designer/src/com/fr/grid/GridKeyListener.java
  7. 1605
      designer/src/com/fr/grid/GridMouseAdapter.java
  8. 21
      designer_base/src/com/fr/common/inputevent/InputEventBaseOnOS.java
  9. 4
      designer_base/src/com/fr/design/actions/edit/CopyAction.java
  10. 4
      designer_base/src/com/fr/design/actions/edit/CutAction.java
  11. 4
      designer_base/src/com/fr/design/actions/edit/PasteAction.java
  12. 12
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  13. 3
      designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java
  14. 30
      designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java
  15. 2593
      designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java
  16. 75
      designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
  17. 8
      designer_base/src/com/fr/design/gui/frpane/UIAdvancedTextPane.java
  18. 8
      designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java
  19. 7
      designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java
  20. 585
      designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java
  21. 11
      designer_base/src/com/fr/design/gui/ilist/UIList.java
  22. 20
      designer_base/src/com/fr/design/gui/itable/TableSorter.java
  23. 51
      designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  24. 20
      designer_base/src/com/fr/design/gui/itextarea/UITextArea.java
  25. 38
      designer_base/src/com/fr/design/gui/itextfield/UITextField.java
  26. 63
      designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java
  27. 3
      designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java
  28. 2
      designer_base/src/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaDefaultInputMap.java
  29. 24
      designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java
  30. 2
      designer_base/src/com/fr/design/locale/designer.properties
  31. 2
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  32. 2
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  33. 2
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  34. 2
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  35. 2
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  36. 35
      designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  37. 20
      designer_base/src/com/fr/design/menu/KeySetUtils.java
  38. 3
      designer_base/src/com/fr/design/roleAuthority/UIRoleTreeUI.java
  39. 4
      designer_form/src/com/fr/design/designer/beans/actions/CopyAction.java
  40. 4
      designer_form/src/com/fr/design/designer/beans/actions/CutAction.java
  41. 4
      designer_form/src/com/fr/design/designer/beans/actions/PasteAction.java
  42. 5
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  43. 4
      designer_form/src/com/fr/design/mainframe/actions/NewFormAction.java
  44. 479
      designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java

4
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));
}
/**

4
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);
}
};

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

File diff suppressed because one or more lines are too long

12
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<T extends TemplateElementCase> 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<T extends TemplateElementCase> 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<T extends TemplateElementCase> 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<T extends TemplateElementCase> 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()) {

172
designer/src/com/fr/design/mainframe/FormatBrushAction.java

File diff suppressed because one or more lines are too long

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

@ -1,212 +1,208 @@
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 Grid grid;
// Keypressed last time
private long keyPressedLastTime = 0;
private boolean isKeyPressedContentChanged = false;
public GridKeyListener(Grid grid) {
this.grid = grid;
}
public void keyPressed(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {// 如果用户在自己的KyeListener里面consume了.就不执行下面的代码了.
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null) {
return;
}
long systemCurrentTime = System.currentTimeMillis();
int code = evt.getKeyCode();
boolean isNeedRepaint = false;
ElementCasePane reportPane = grid.getElementCasePane();
ElementCase report = reportPane.getEditingElementCase();
if (reportPane.getSelection() instanceof FloatSelection) {
if (systemCurrentTime - keyPressedLastTime <= 2) {
return;
} else {
keyPressedLastTime = systemCurrentTime;
}
dealWithFloatSelection(reportPane, code);
} else {
if (systemCurrentTime - keyPressedLastTime <= 32) {
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()));
isNeedRepaint = true;
break;
}
case KeyEvent.VK_PAGE_DOWN: {// page down
reportPane.getVerticalScrollBar().setValue(grid.getVerticalValue() + grid.getVerticalExtent());
isNeedRepaint = true;
break;
}
// Richie:Ctrl + A全选单元格
case KeyEvent.VK_A:
if (code == KeyEvent.VK_A && evt.isControlDown()) {
reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount()));
isNeedRepaint = true;
}
isNeedRepaint = true;
break;
}
if (isNeedRepaint) {
reportPane.repaint();
}
}
/**
* 单选中悬浮元素时只处理4个方向键
*
* @param reportPane
* @param code
*/
private void dealWithFloatSelection(ElementCasePane reportPane, int code) {
boolean isContentChanged = false;
FloatSelection floatselection = (FloatSelection)reportPane.getSelection();
switch (code) {
case KeyEvent.VK_LEFT: {// left
floatselection.moveLeft(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_RIGHT: {// right
floatselection.moveRight(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_UP: {// up
floatselection.moveUp(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_DOWN: {// down
floatselection.moveDown(reportPane);
isContentChanged = true;
break;
}
}
if (isContentChanged) {
grid.getElementCasePane().repaint();
this.isKeyPressedContentChanged = true;
}
}
private void dealWithCellSelection(KeyEvent evt, int code) {
switch (code) {
case KeyEvent.VK_ESCAPE: {
if (grid.isCellEditing()) {
grid.cancelEditing();
}
break;
}
case KeyEvent.VK_F2: {
if (!grid.isCellEditing()) {
grid.startEditing();
}
break;
}
}
// 支持小键盘
if (IS_NUM_PAD_KEY(code)) {
keyTyped(evt);
}
}
public void keyReleased(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null) {
return;
}
if (this.isKeyPressedContentChanged) {
grid.getElementCasePane().fireTargetModified();
this.isKeyPressedContentChanged = false;
}
}
public void keyTyped(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null || evt.isControlDown()) {// uneditable.
return;
}
char ch = evt.getKeyChar();
if (ch == KeyEvent.VK_TAB) {// 禁止Tab键.
return;
}
int code = evt.getKeyCode();
if (Character.isDefined(ch)) {// VK_SUBTRACT小键盘的减号
Selection s = grid.getElementCasePane().getSelection();
if (s instanceof CellSelection) {
if (!grid.getElementCasePane().isSelectedOneCell()) {
Toolkit.getDefaultToolkit().beep();
return;
}
if (!grid.isCellEditing()) {
grid.startEditing(true);
}
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);
grid.editorComponent.dispatchEvent(ke);
ke.consume();
} else {
if (!evt.isConsumed()) {
grid.editorComponent.dispatchEvent(evt);
}
}
}
}
}
}
/**
* 小键盘
* @param code
* @return
*/
private static boolean IS_NUM_PAD_KEY(int code){
return code == KeyEvent.VK_NUMPAD0 || code == KeyEvent.VK_NUMPAD1
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;
private boolean isKeyPressedContentChanged = false;
public GridKeyListener(Grid grid) {
this.grid = grid;
}
public void keyPressed(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {// 如果用户在自己的KyeListener里面consume了.就不执行下面的代码了.
return;
}
if (KeyEventWork.processKeyEvent(evt) == null) {
return;
}
long systemCurrentTime = System.currentTimeMillis();
int code = evt.getKeyCode();
boolean isNeedRepaint = false;
ElementCasePane reportPane = grid.getElementCasePane();
ElementCase report = reportPane.getEditingElementCase();
if (reportPane.getSelection() instanceof FloatSelection) {
if (systemCurrentTime - keyPressedLastTime <= 2) {
return;
} else {
keyPressedLastTime = systemCurrentTime;
}
dealWithFloatSelection(reportPane, code);
} else {
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()));
isNeedRepaint = true;
break;
}
case KeyEvent.VK_PAGE_DOWN: {// page down
reportPane.getVerticalScrollBar().setValue(grid.getVerticalValue() + grid.getVerticalExtent());
isNeedRepaint = true;
break;
}
// Richie:Ctrl + A全选单元格
case KeyEvent.VK_A:
if (InputEventBaseOnOS.isControlDown(evt)) {
reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount()));
}
isNeedRepaint = true;
break;
}
if (isNeedRepaint) {
reportPane.repaint();
}
}
/**
* 单选中悬浮元素时只处理4个方向键
*
* @param reportPane
* @param code
*/
private void dealWithFloatSelection(ElementCasePane reportPane, int code) {
boolean isContentChanged = false;
FloatSelection floatselection = (FloatSelection) reportPane.getSelection();
switch (code) {
case KeyEvent.VK_LEFT: {// left
floatselection.moveLeft(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_RIGHT: {// right
floatselection.moveRight(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_UP: {// up
floatselection.moveUp(reportPane);
isContentChanged = true;
break;
}
case KeyEvent.VK_DOWN: {// down
floatselection.moveDown(reportPane);
isContentChanged = true;
break;
}
}
if (isContentChanged) {
grid.getElementCasePane().repaint();
this.isKeyPressedContentChanged = true;
}
}
private void dealWithCellSelection(KeyEvent evt, int code) {
switch (code) {
case KeyEvent.VK_ESCAPE: {
if (grid.isCellEditing()) {
grid.cancelEditing();
}
break;
}
case KeyEvent.VK_F2: {
if (!grid.isCellEditing()) {
grid.startEditing();
}
break;
}
}
// 支持小键盘
if (IS_NUM_PAD_KEY(code)) {
keyTyped(evt);
}
}
public void keyReleased(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null) {
return;
}
if (this.isKeyPressedContentChanged) {
grid.getElementCasePane().fireTargetModified();
this.isKeyPressedContentChanged = false;
}
}
public void keyTyped(KeyEvent evt) {
if (!grid.isEnabled() || evt.isConsumed()) {
return;
}
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt);
if (newEvt == null || InputEventBaseOnOS.isControlDown(evt)) {// uneditable.
return;
}
char ch = evt.getKeyChar();
if (ch == KeyEvent.VK_TAB) {// 禁止Tab键.
return;
}
int code = evt.getKeyCode();
if (Character.isDefined(ch)) {// VK_SUBTRACT小键盘的减号
Selection s = grid.getElementCasePane().getSelection();
if (s instanceof CellSelection) {
if (!grid.getElementCasePane().isSelectedOneCell()) {
Toolkit.getDefaultToolkit().beep();
return;
}
if (!grid.isCellEditing()) {
grid.startEditing(true);
}
if (grid.getCellEditor() != null && grid.editorComponent != null) {
if (IS_NUM_PAD_KEY(code)) {
KeyEvent ke = new KeyEvent(grid, KeyEvent.KEY_PRESSED, 0, 0, code - DIFF, ch);
grid.editorComponent.dispatchEvent(ke);
ke.consume();
} else {
if (!evt.isConsumed()) {
grid.editorComponent.dispatchEvent(evt);
}
}
}
}
}
}
/**
* 小键盘
*
* @param code
* @return
*/
private static boolean IS_NUM_PAD_KEY(int code) {
return code == KeyEvent.VK_NUMPAD0 || code == KeyEvent.VK_NUMPAD1
|| code == KeyEvent.VK_NUMPAD2
|| code == KeyEvent.VK_NUMPAD3
|| code == KeyEvent.VK_NUMPAD4
@ -215,10 +211,10 @@ public class GridKeyListener implements KeyListener {
|| code == KeyEvent.VK_NUMPAD7
|| code == KeyEvent.VK_NUMPAD8
|| code == KeyEvent.VK_NUMPAD9
|| code == KeyEvent.VK_MULTIPLY
|| code == KeyEvent.VK_MULTIPLY
|| code == KeyEvent.VK_ADD
|| code == KeyEvent.VK_SUBTRACT
|| code == KeyEvent.VK_DECIMAL
|| code == KeyEvent.VK_DIVIDE;
}
}
}

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

File diff suppressed because it is too large Load Diff

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/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

4
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

4
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

12
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -6,6 +6,7 @@ import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ucenter.Client;
import com.fr.design.extra.ucenter.XMLHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject;
@ -108,9 +109,6 @@ public class LoginWebBridge {
if (StringUtils.isEmpty(userName)) {
return;
}
if (StringUtils.isNotEmpty(this.userName)) {
updateMessageCount();
}
this.userName = userName;
}
@ -143,15 +141,13 @@ public class LoginWebBridge {
if (getMessage.isServerAlive()) {
try {
String res = getMessage.getResponseText();
if (res.equals(FAILED_MESSAGE_STATUS)) {
} else {
if (!ComparatorUtils.equals(res, FAILED_MESSAGE_STATUS)) {
JSONObject jo = new JSONObject(res);
if (jo.getString("status").equals(SUCCESS_MESSAGE_STATUS)) {
if (SUCCESS_MESSAGE_STATUS.equals(jo.optString("status"))) {
setMessageCount(Integer.parseInt(jo.getString("message")));
}
}
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
} catch (Exception ignore) {
}
}
sleep(CHECK_MESSAGE_TIME);

3
designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java

@ -38,9 +38,6 @@ public class PluginLoginExecutor implements Executor {
@Override
public void run(Process<String> process) {
String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel);
if (Integer.valueOf(loginResult) == 0) {
LoginWebBridge.getHelper().updateMessageCount();
}
result = loginResult;
}
}

30
designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java

@ -10,6 +10,7 @@
package com.fr.design.gui.autocomplete;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.PopupWindowDecorator;
import com.fr.general.FRLogger;
import javax.swing.*;
import javax.swing.event.CaretEvent;
@ -40,6 +41,7 @@ import java.util.List;
class AutoCompletePopupWindow extends JWindow implements CaretListener,
ListSelectionListener, MouseListener {
private final static int DIS = 5;
/**
* The parent AutoCompletion instance.
*/
@ -179,7 +181,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
} else {
doAutocomplete();
}
} else if (AutoCompletion.getDebug()) {
} else if (AutoCompletion.isDebug()) {
Thread.dumpStack();
}
}
@ -300,8 +302,8 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/
private void installKeyBindings() {
if (AutoCompletion.getDebug()) {
System.out.println("PopupWindow: Installing keybindings");
if (AutoCompletion.isDebug()) {
FRLogger.getLogger().debug("PopupWindow: Installing keybindings");
}
if (escapeKap == null) { // Lazily create actions.
@ -313,7 +315,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
ActionMap am = comp.getActionMap();
replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape);
if (AutoCompletion.getDebug() && oldEscape.action == escapeKap.action) {
if (AutoCompletion.isDebug() && oldEscape.action == escapeKap.action) {
Thread.dumpStack();
}
replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp);
@ -371,7 +373,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/
private void positionDescWindow() {
boolean showDescWindow = descWindow != null && ac.getShowDescWindow();
boolean showDescWindow = descWindow != null && ac.isShowDescWindow();
if (!showDescWindow) {
return;
}
@ -387,14 +389,14 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
// Try to position to the right first (LTR)
int x;
if (ac.getTextComponentOrientation().isLeftToRight()) {
x = getX() + getWidth() + 5;
x = getX() + getWidth() + DIS;
if (x + descWindow.getWidth() > screenBounds.x + screenBounds.width) { // doesn't fit
x = getX() - 5 - descWindow.getWidth();
x = getX() - DIS - descWindow.getWidth();
}
} else { // RTL
x = getX() - 5 - descWindow.getWidth();
x = getX() - DIS - descWindow.getWidth();
if (x < screenBounds.x) { // Doesn't fit
x = getX() + getWidth() + 5;
x = getX() + getWidth() + DIS;
}
}
@ -604,7 +606,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y);
//Dimension screenSize = getToolkit().getScreenSize();
boolean showDescWindow = descWindow != null && ac.getShowDescWindow();
boolean showDescWindow = descWindow != null && ac.isShowDescWindow();
int totalH = getHeight();
if (showDescWindow) {
totalH = Math.max(totalH, descWindow.getHeight());
@ -655,7 +657,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
installKeyBindings();
lastLine = ac.getLineOfCaret();
selectFirstItem();
if (descWindow == null && ac.getShowDescWindow()) {
if (descWindow == null && ac.isShowDescWindow()) {
descWindow = createDescriptionWindow();
positionDescWindow();
}
@ -693,7 +695,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
// because of the way child JWindows' visibility is handled - in
// some ways it's dependent on the parent, in other ways it's not.
if (descWindow != null) {
descWindow.setVisible(visible && ac.getShowDescWindow());
descWindow.setVisible(visible && ac.isShowDescWindow());
}
}
@ -708,8 +710,8 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/
private void uninstallKeyBindings() {
if (AutoCompletion.getDebug()) {
System.out.println("PopupWindow: Removing keybindings");
if (AutoCompletion.isDebug()) {
FRLogger.getLogger().debug("PopupWindow: Removing keybindings");
}
JTextComponent comp = ac.getTextComponent();

2593
designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java

File diff suppressed because it is too large Load Diff

75
designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java

@ -14,6 +14,7 @@ import com.fr.design.gui.autocomplete.ParameterizedCompletionInsertionInfo.Repla
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.DocumentRange;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.ChangeableHighlightPainter;
import com.fr.general.FRLogger;
import javax.swing.*;
import javax.swing.event.CaretEvent;
@ -254,7 +255,7 @@ class ParameterizedCompletionContext {
*
* @param offs The offset into the document.
* @return The text of the parameter containing the offset, or
* <code>null</code> if the offset is not in a parameter.
* <code>null</code> if the offset is not in a parameter.
*/
public String getArgumentText(int offs) {
List<Highlight> paramHighlights = getParameterHighlights();
@ -284,7 +285,7 @@ class ParameterizedCompletionContext {
* Returns the highlight of the current parameter.
*
* @return The current parameter's highlight, or <code>null</code> if
* the caret is not in a parameter's bounds.
* the caret is not in a parameter's bounds.
* @see #getCurrentParameterStartOffset()
*/
private Highlight getCurrentParameterHighlight() {
@ -332,7 +333,7 @@ class ParameterizedCompletionContext {
* Returns the starting offset of the current parameter.
*
* @return The current parameter's starting offset, or <code>-1</code> if
* the caret is not in a parameter's bounds.
* the caret is not in a parameter's bounds.
* @see #getCurrentParameterHighlight()
*/
private int getCurrentParameterStartOffset() {
@ -407,7 +408,7 @@ class ParameterizedCompletionContext {
* Inserts the choice selected in the parameter choices window.
*
* @return Whether the choice was inserted. This will be <code>false</code>
* if the window is not visible, or no choice is selected.
* if the window is not visible, or no choice is selected.
*/
boolean insertSelectedChoice() {
if (paramChoicesWindow != null && paramChoicesWindow.isVisible()) {
@ -438,11 +439,9 @@ class ParameterizedCompletionContext {
* @see #uninstallKeyBindings()
*/
private void installKeyBindings() {
if (AutoCompletion.getDebug()) {
System.out.println("CompletionContext: Installing keybindings");
if (AutoCompletion.isDebug()) {
FRLogger.getLogger().debug("CompletionContext: Installing keybindings");
}
JTextComponent tc = ac.getTextComponent();
InputMap im = tc.getInputMap();
ActionMap am = tc.getActionMap();
@ -489,7 +488,6 @@ class ParameterizedCompletionContext {
im.put(ks, IM_KEY_CLOSING);
oldClosingAction = am.get(IM_KEY_CLOSING);
am.put(IM_KEY_CLOSING, new ClosingAction());
}
@ -513,12 +511,7 @@ class ParameterizedCompletionContext {
List<Highlight> highlights = getParameterHighlights();
for (int i = 0; i < highlights.size(); i++) {
Highlight hl = highlights.get(i);
// Check "< dot", not "<= dot" as OutlineHighlightPainter paints
// starting at one char AFTER the highlight starts, to work around
// Java issue. Thanks to Matthew Adereth!
if (currentNext == null || currentNext.getStartOffset() </*=*/dot ||
(hl.getStartOffset() > dot &&
hl.getStartOffset() <= currentNext.getStartOffset())) {
if (needUpdate(currentNext, hl, dot)) {
currentNext = hl;
pos = i;
}
@ -538,6 +531,15 @@ class ParameterizedCompletionContext {
}
private boolean needUpdate(Highlight currentNext, Highlight hl, int dot) {
// Check "< dot", not "<= dot" as OutlineHighlightPainter paints
// starting at one char AFTER the highlight starts, to work around
// Java issue. Thanks to Matthew Adereth!
return currentNext == null || currentNext.getStartOffset() </*=*/dot ||
(hl.getStartOffset() > dot &&
hl.getStartOffset() <= currentNext.getStartOffset());
}
/**
* Moves to and selects the previous parameter.
@ -562,10 +564,7 @@ class ParameterizedCompletionContext {
for (int i = 0; i < highlights.size(); i++) {
Highlight h = highlights.get(i);
if (currentPrev == null || currentPrev.getStartOffset() >= dot ||
(h.getStartOffset() < selStart &&
(h.getStartOffset() > currentPrev.getStartOffset() ||
pos == lastSelectedParam))) {
if (pos == lastSelectedParam || needUpdate(currentPrev, dot, h, selStart)) {
currentPrev = h;
pos = i;
}
@ -593,6 +592,12 @@ class ParameterizedCompletionContext {
}
private boolean needUpdate(Highlight currentPrev, int dot, Highlight h, int selStart) {
return currentPrev == null
|| currentPrev.getStartOffset() >= dot
|| (currentPrev.getStartOffset() < h.getStartOffset() && h.getStartOffset() < selStart);
}
private void possiblyUpdateParamCopies(Document doc) {
@ -616,7 +621,7 @@ class ParameterizedCompletionContext {
try {
replacement = doc.getText(start, len);
} catch (BadLocationException ble) {
// Never happens
// Never happens
}
// Replace any param copies tracking this parameter with the
@ -718,7 +723,7 @@ class ParameterizedCompletionContext {
return h;
} catch (BadLocationException ble) {
// Never happens
// Never happens
}
return null;
@ -733,8 +738,8 @@ class ParameterizedCompletionContext {
*/
private void uninstallKeyBindings() {
if (AutoCompletion.getDebug()) {
System.out.println("CompletionContext Uninstalling keybindings");
if (AutoCompletion.isDebug()) {
FRLogger.getLogger().debug("CompletionContext Uninstalling keybindings");
}
JTextComponent tc = ac.getTextComponent();
@ -1037,7 +1042,6 @@ class ParameterizedCompletionContext {
* @see #uninstall()
*/
public void install(JTextComponent tc) {
boolean replaceTabs = false;
if (tc instanceof RSyntaxTextArea) {
RSyntaxTextArea textArea = (RSyntaxTextArea) tc;
@ -1047,14 +1051,10 @@ class ParameterizedCompletionContext {
}
Highlighter h = tc.getHighlighter();
try {
// Insert the parameter text
ParameterizedCompletionInsertionInfo info =
pc.getInsertionInfo(tc, replaceTabs);
ParameterizedCompletionInsertionInfo info = pc.getInsertionInfo(tc, replaceTabs);
tc.replaceSelection(info.getTextToInsert());
// Add highlights around the parameters.
final int replacementCount = info.getReplacementCount();
for (int i = 0; i < replacementCount; i++) {
@ -1067,40 +1067,31 @@ class ParameterizedCompletionContext {
for (int i = 0; i < info.getReplacementCopyCount(); i++) {
ReplacementCopy rc = info.getReplacementCopy(i);
paramCopyInfos.add(new ParamCopyInfo(rc.getId(),
(Highlight) h.addHighlight(rc.getStart(), rc.getEnd(),
paramCopyP)));
(Highlight) h.addHighlight(rc.getStart(), rc.getEnd(), paramCopyP)));
}
// Go back and start at the first parameter.
tc.setCaretPosition(info.getSelectionStart());
if (info.hasSelection()) {
tc.moveCaretPosition(info.getSelectionEnd());
}
minPos = info.getMinOffset();
maxPos = info.getMaxOffset();
try {
defaultEndOffs = tc.getDocument().createPosition(
info.getDefaultEndOffs());
defaultEndOffs = tc.getDocument().createPosition(info.getDefaultEndOffs());
} catch (BadLocationException ble) {
// Never happens
// Never happens
}
// Listen for document events AFTER we insert
tc.getDocument().addDocumentListener(this);
} catch (BadLocationException ble) {
// Never happens
// Never happens
}
// Add listeners to the text component, AFTER text insertion.
tc.addCaretListener(this);
tc.addFocusListener(this);
installKeyBindings();
}
public void removeUpdate(DocumentEvent e) {
handleDocumentEvent(e);
}

8
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) {

8
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;
@ -17,6 +19,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;
@ -74,12 +78,12 @@ 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.
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);
}

7
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;
@ -24,6 +25,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
@ -207,8 +210,8 @@ 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(),
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());
}
super.processMouseEvent(e);

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

@ -1,311 +1,300 @@
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 {
/**
* 选择状态----全选和全不选
*
* @editor zhou
* @since 2012-4-1下午2:39:10
*/
public static enum SelectedState {
ALL, NONE
}
private boolean[] selects;
private JList jlist;
private UICheckBox chooseAll;
public CheckBoxList(Object[] items) {
this(items, SelectedState.NONE, StringUtils.EMPTY);
}
public CheckBoxList(Object[] items, String name) {
this(items, SelectedState.NONE, name);
}
/**
* Class constructor.
*
* @param items
* Items with which to populate the list.
* @param default_state
* default state, true or false
*/
public CheckBoxList(Object[] items, SelectedState state, String name) {
jlist = new BOXLIST(items);
jlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.selects = new boolean[items.length];
boolean default_state = (state == SelectedState.ALL);
Arrays.fill(this.selects, default_state);
jlist.setCellRenderer(new CheckListCellRenderer());
jlist.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
doCheck();
}
public void mouseReleased(MouseEvent e) {
doCheck();
}
});
jlist.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == ' ') {
doCheck();
}
}
});
this.setLayout(new BorderLayout());
chooseAll = new UICheckBox(name, default_state);
chooseAll.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (chooseAll.isSelected()) {
setSelected(true);
} else {
setSelected(false);
}
}
});
this.add(chooseAll, BorderLayout.NORTH);
this.add(jlist, BorderLayout.CENTER);
}
/*
* 用于CellRenderer显示value为text
*/
protected String value2Text(Object value) {
return value != null ? value.toString() : StringUtils.EMPTY;
}
public void setItems(Object[] os) {
if (os == null) {
this.setSelected(false);
} else {
for (int i = 0, len = os.length; i < len; i++) {
Object o = os[i];
for (int j = 0, jen = jlist.getModel().getSize(); j < jen; j++) {
if (o.equals(jlist.getModel().getElementAt(j))) {
this.setSelected(j, true);
}
}
}
}
this.repaint();
}
/**
* Is selected
*/
public boolean isSelected(int index) {
if (selects == null || index >= selects.length) {
return false;
}
return selects[index];
}
public void setSelected(int index, boolean isSelected) {
if (selects == null || index >= selects.length) {
return;
}
selects[index] = isSelected;
this.repaint(this.getBounds());
this.fireCheckBoxListSelectionChangeListener();
}
private void setSelected(boolean isSelected) {
if (selects == null) {
return;
}
for (int i = 0; i < selects.length; i++) {
selects[i] = isSelected;
}
this.repaint(this.getBounds());
this.fireCheckBoxListSelectionChangeListener();
}
/**
* Returns an array of the objects that have been selected. Overrides the
* JList method.
*/
public Object[] getSelectedValues() {
return this.jlist.getSelectedValues();
}
private class BOXLIST extends JList {
public BOXLIST(Object[] items) {
super(items);
}
@Override
protected void processMouseEvent(MouseEvent e) {
if (e.getX() < 20) {
if (e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) {
int[] indices = getSelectedIndices();
if (indices.length == 0) {
super.processMouseEvent(e);
}
} else {
super.processMouseEvent(e);
}
} else {
super.processMouseEvent(e);
}
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;
}
}
@Override
protected void processMouseMotionEvent(MouseEvent e) {
if (e.getX() < 20) {
return;
}
super.processMouseEvent(e);
}
@Override
public Object[] getSelectedValues() {
List<Object> list = new ArrayList<Object>(selects.length);
for (int i = 0; i < selects.length; i++) {
if (selects[i]) {
list.add(this.getModel().getElementAt(i));
}
}
return list.toArray();
}
}
private void doCheck() {
// p:这里必须改变所有选择checkbox.
int index = jlist.getSelectedIndex();
boolean sValue = !selects[index];
// p:开始设置所有选择的checkbox.
int[] indices = jlist.getSelectedIndices();
for (int i = 0; i < indices.length; i++) {
setSelected(indices[i], sValue);
}
for (boolean selected : selects) {
if (!selected) {
chooseAll.setSelected(false);
return;
}
}
chooseAll.setSelected(true);
repaint();
}
private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer {
public CheckListCellRenderer() {
this.setOpaque(true);
this.setBorder(noFocusBorder);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
this.setText(value2Text(value));
this.setSelected(selects[index]);
this.setFont(list.getFont());
if (isSelected) {
this.setBackground(list.getSelectionBackground());
this.setForeground(list.getSelectionForeground());
} else {
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
if (cellHasFocus) {
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
} else {
this.setBorder(noFocusBorder);
}
return this;
}
}
public void addCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) {
this.listenerList.add(CheckBoxListSelectionChangeListener.class, l);
}
public void removeCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) {
this.listenerList.remove(CheckBoxListSelectionChangeListener.class, l);
}
public void fireCheckBoxListSelectionChangeListener() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == CheckBoxListSelectionChangeListener.class) {
((CheckBoxListSelectionChangeListener)listeners[i + 1]).selectionChanged(this);
}
}
}
public static interface CheckBoxListSelectionChangeListener extends EventListener {
public void selectionChanged(CheckBoxList target);
}
public ListModel getModel() {
return jlist.getModel();
}
private final static int X_COORDINATE = 20;
/**
* 选择状态----全选和全不选
*
* @editor zhou
* @since 2012-4-1下午2:39:10
*/
public static enum SelectedState {
ALL, NONE
}
private boolean[] selects;
private JList jlist;
private UICheckBox chooseAll;
public CheckBoxList(Object[] items) {
this(items, SelectedState.NONE, StringUtils.EMPTY);
}
public CheckBoxList(Object[] items, String name) {
this(items, SelectedState.NONE, name);
}
/**
* Class constructor.
*
* @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);
jlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.selects = new boolean[items.length];
boolean default_state = (state == SelectedState.ALL);
Arrays.fill(this.selects, default_state);
jlist.setCellRenderer(new CheckListCellRenderer());
jlist.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
doCheck();
}
public void mouseReleased(MouseEvent e) {
doCheck();
}
});
jlist.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == ' ') {
doCheck();
}
}
});
this.setLayout(new BorderLayout());
chooseAll = new UICheckBox(name, default_state);
chooseAll.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (chooseAll.isSelected()) {
setSelected(true);
} else {
setSelected(false);
}
}
});
this.add(chooseAll, BorderLayout.NORTH);
this.add(jlist, BorderLayout.CENTER);
}
/*
* 用于CellRenderer显示value为text
*/
protected String value2Text(Object value) {
return value != null ? value.toString() : StringUtils.EMPTY;
}
public void setItems(Object[] os) {
if (os == null) {
this.setSelected(false);
} else {
for (int i = 0, len = os.length; i < len; i++) {
Object o = os[i];
for (int j = 0, jen = jlist.getModel().getSize(); j < jen; j++) {
if (o.equals(jlist.getModel().getElementAt(j))) {
this.setSelected(j, true);
}
}
}
}
this.repaint();
}
/**
* Is selected
*/
public boolean isSelected(int index) {
if (selects == null || index >= selects.length) {
return false;
}
return selects[index];
}
public void setSelected(int index, boolean isSelected) {
if (selects == null || index >= selects.length) {
return;
}
selects[index] = isSelected;
this.repaint(this.getBounds());
this.fireCheckBoxListSelectionChangeListener();
}
private void setSelected(boolean isSelected) {
if (selects == null) {
return;
}
for (int i = 0; i < selects.length; i++) {
selects[i] = isSelected;
}
this.repaint(this.getBounds());
this.fireCheckBoxListSelectionChangeListener();
}
/**
* Returns an array of the objects that have been selected. Overrides the
* JList method.
*/
public Object[] getSelectedValues() {
return this.jlist.getSelectedValues();
}
private class BOXLIST extends JList {
public BOXLIST(Object[] items) {
super(items);
}
@Override
protected void processMouseEvent(MouseEvent e) {
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);
}
} else {
super.processMouseEvent(e);
}
} else {
super.processMouseEvent(e);
}
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;
}
}
@Override
protected void processMouseMotionEvent(MouseEvent e) {
if (e.getX() < X_COORDINATE) {
return;
}
super.processMouseEvent(e);
}
@Override
public Object[] getSelectedValues() {
List<Object> list = new ArrayList<Object>(selects.length);
for (int i = 0; i < selects.length; i++) {
if (selects[i]) {
list.add(this.getModel().getElementAt(i));
}
}
return list.toArray();
}
}
private void doCheck() {
// p:这里必须改变所有选择checkbox.
int index = jlist.getSelectedIndex();
boolean sValue = !selects[index];
// p:开始设置所有选择的checkbox.
int[] indices = jlist.getSelectedIndices();
for (int i = 0; i < indices.length; i++) {
setSelected(indices[i], sValue);
}
for (boolean selected : selects) {
if (!selected) {
chooseAll.setSelected(false);
return;
}
}
chooseAll.setSelected(true);
repaint();
}
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(NO_FOCUS_BORDER);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
this.setText(value2Text(value));
this.setSelected(selects[index]);
this.setFont(list.getFont());
if (isSelected) {
this.setBackground(list.getSelectionBackground());
this.setForeground(list.getSelectionForeground());
} else {
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
if (cellHasFocus) {
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
} else {
this.setBorder(NO_FOCUS_BORDER);
}
return this;
}
}
public void addCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) {
this.listenerList.add(CheckBoxListSelectionChangeListener.class, l);
}
public void removeCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) {
this.listenerList.remove(CheckBoxListSelectionChangeListener.class, l);
}
public void fireCheckBoxListSelectionChangeListener() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == CheckBoxListSelectionChangeListener.class) {
((CheckBoxListSelectionChangeListener) listeners[i + 1]).selectionChanged(this);
}
}
}
public static interface CheckBoxListSelectionChangeListener extends EventListener {
public void selectionChanged(CheckBoxList target);
}
public ListModel getModel() {
return jlist.getModel();
}
}

11
designer_base/src/com/fr/design/gui/ilist/UIList.java

@ -17,7 +17,7 @@ import java.util.Vector;
* 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() {
@ -46,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;
@ -71,6 +71,7 @@ public class UIList extends JList{
}
return null;
}
public JToolTip createToolTip() {
UIToolTip tip = new UIToolTip(icon);
tip.setComponent(this);

20
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,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,
@ -380,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;
@ -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);
}
}

51
designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java

@ -1,36 +1,23 @@
package com.fr.design.gui.itabpane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.core.UITabComponent;
import com.fr.design.gui.ibutton.UITabButton;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fr.base.BaseUtils;
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())
@ -40,6 +27,7 @@ import com.fr.stable.StringUtils;
*/
public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
private static final long serialVersionUID = 1L;
private static final int DIS = 30;
private UILabel nameLabel;
@ -125,7 +113,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() {
/**
@ -143,9 +131,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
private void show(final JPanel panel) {
int count = centerPane.getComponentCount();// 获取centerPanel中控件数
List<Component> list = new ArrayList<Component>();//
for (Component comp : centerPane.getComponents()) {
list.add(comp);
}
list.addAll(Arrays.asList(centerPane.getComponents()));
if (count > 0) {// 如果centerPanel中控件数大于0就执行效果
for (int i = 0; i < count; i++) {
Component comp = centerPane.getComponent(i);// 获得该位置的控件
@ -159,11 +145,11 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
int height = centerPane.getHeight();
int width = centerPane.getWidth();
int y = -height;
for (int i = 0; i <= height; i += 30) {
for (int i = 0; i <= height; i += DIS) {
// 设置面板位置
currentPanel.setBounds(0, i, width, height);
panel.setBounds(0, y, width, height);
y += 30;
y += DIS;
try {
Thread.sleep(3);
} catch (InterruptedException e) {
@ -173,7 +159,6 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
centerPane.remove(currentPanel);// 移除当前面板
}
panel.setBounds(0, 0, width, height);
}
}.start();
break;

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

@ -7,13 +7,33 @@ 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);
}
initComponents();
}

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

@ -1,20 +1,21 @@
package com.fr.design.gui.itextfield;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
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
@ -30,6 +31,22 @@ 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);
}
initListener();
}
@ -186,6 +203,7 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
/**
* 主函数
*
* @param args 参数
*/
public static void main(String... args) {

63
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.JTree;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
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;
/**
* CheckBoxTree is a special JTree which uses UICheckBox as the tree renderer.
* In addition to regular JTree's features, it also allows you select any number
@ -37,11 +30,11 @@ import com.fr.design.gui.icheckbox.UICheckBox;
* select one or several tree nodes and press SPACE key to toggle the
* check box selection for all selected tree nodes.
* <p/>
* 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.
*/
@ -111,7 +104,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.
*
@ -122,7 +115,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);
@ -168,7 +161,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();
@ -177,8 +170,7 @@ public class CheckBoxTree extends JTree {
}
if (_treeCellRenderer == null) {
_treeCellRenderer = createCellRenderer(cellRenderer);
}
else {
} else {
_treeCellRenderer.setActualTreeRenderer(cellRenderer);
}
return _treeCellRenderer;
@ -194,8 +186,7 @@ public class CheckBoxTree extends JTree {
public TreeCellRenderer getActualCellRenderer() {
if (_treeCellRenderer != null) {
return _treeCellRenderer.getActualTreeRenderer();
}
else {
} else {
return super.getCellRenderer();
}
}
@ -245,13 +236,13 @@ public class CheckBoxTree extends JTree {
}
TreePath path = _tree.getPathForLocation(e.getX(), e.getY());
if (path == null)
if (path == null) {
return null;
}
if (clicksInCheckBox(e, path)) {
return path;
}
else {
} else {
return null;
}
}
@ -259,13 +250,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;
}
}
@ -320,8 +309,9 @@ public class CheckBoxTree extends JTree {
return;
}
if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE)
if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) {
toggleSelections();
}
}
public void keyTyped(KeyEvent e) {
@ -349,8 +339,7 @@ public class CheckBoxTree extends JTree {
selectionModel.removeSelectionPath(path);
else
selectionModel.addSelectionPath(path);
}
finally {
} finally {
if (!selectionModel.isSingleEventMode()) {
selectionModel.setBatchMode(false);
}
@ -365,8 +354,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);

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 {

2
designer_base/src/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaDefaultInputMap.java

@ -34,7 +34,7 @@ public class RSyntaxTextAreaDefaultInputMap extends RTADefaultInputMap {
*/
public RSyntaxTextAreaDefaultInputMap() {
int defaultMod = getDefaultModifier();
int defaultMod = DEFAULT_MODIFIER;
//int ctrl = InputEvent.CTRL_MASK;
int shift = InputEvent.SHIFT_MASK;
//int alt = InputEvent.ALT_MASK;

24
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 (<code>InputEvent.CTRL_MASK</code>).
*
* @return The default modifier key.
*/
public static final int DEFAULT_MODIFIER = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/**
* Constructs the default input map for an <code>RTextArea</code>.
*/
@ -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 (<code>InputEvent.CTRL_MASK</code>).
*
* @return The default modifier key.
*/
protected static final int getDefaultModifier() {
return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
}
}

2
designer_base/src/com/fr/design/locale/designer.properties

@ -1132,7 +1132,7 @@ FRFont-bold=bold
FR-Designer_Set_Submit_Condition=
Form-Change_Widget_Name=Change Widget Name
ReportColumns-Report_Columns=Report Columns
Can_not_use_FormatBursh=
FR-Designer_Can_not_use_FormatBursh=
CellElement-Property_Table=CellElement Property Table
Dictionary-Dynamic_SQL=Dynamic SQL
FR-Designer_Form-CheckBoxGroup=CheckBoxGroup

2
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -1132,7 +1132,7 @@ FRFont-bold=Bold
FR-Designer_Set_Submit_Condition=Submit Condition
Form-Change_Widget_Name=Change Control Name
ReportColumns-Report_Columns=Multi-columns/lines display
Can_not_use_FormatBursh=Can't use format painter in multiple selections
FR-Designer_Can_not_use_FormatBursh=Can't use format painter in multiple selections
CellElement-Property_Table=Cell Attribute Table
Dictionary-Dynamic_SQL=Dynamic SQL
FR-Designer_Form-CheckBoxGroup=CheckBoxGroup

2
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\u592A\u5B57
FR-Designer_Set_Submit_Condition=\u66F8\u304D\u8FBC\u307F\u6761\u4EF6\u8A2D\u5B9A
Form-Change_Widget_Name=\u30A6\u30A3\u30B8\u30A7\u30C3\u30C8\u540D\u3092\u5909\u66F4\u3059\u308B
ReportColumns-Report_Columns=\u5E33\u7968\u306E\u30B5\u30D6\u30D5\u30A3\u30FC\u30EB\u30C9
Can_not_use_FormatBursh=\u9023\u7D9A\u3057\u306A\u3044\u8907\u6570\u9818\u57DF\u3067\u306F\u66F8\u5F0F\u30B3\u30D4\u30FC\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
FR-Designer_Can_not_use_FormatBursh=\u9023\u7D9A\u3057\u306A\u3044\u8907\u6570\u9818\u57DF\u3067\u306F\u66F8\u5F0F\u30B3\u30D4\u30FC\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
CellElement-Property_Table=\u30BB\u30EB\u5C5E\u6027\u8868
Dictionary-Dynamic_SQL=\u52D5\u7684SQL
FR-Designer_Form-CheckBoxGroup=\u30C1\u30A7\u30C3\u30AF\u30DC\u30C3\u30AF\u30B9\u30B0\u30EB\u30FC\u30D7

2
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\uAD75\uAC8C
FR-Designer_Set_Submit_Condition=\uC81C\uCD9C\uC870\uAC74\uC124\uC815
Form-Change_Widget_Name=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984\uBCC0\uACBD
ReportColumns-Report_Columns=\uBB38\uC11C\uC140\uB098\uB204\uAE30
Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\!
FR-Designer_Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\!
CellElement-Property_Table=\uC140\uC18D\uC131\uD45C
Dictionary-Dynamic_SQL=\uB3D9\uC801 SQL
FR-Designer_Form-CheckBoxGroup=\uCCB4\uD06C\uBC15\uC2A4\uADF8\uB8F9

2
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\u52A0\u7C97
FR-Designer_Set_Submit_Condition=\u8BBE\u7F6E\u63D0\u4EA4\u6761\u4EF6
Form-Change_Widget_Name=\u66F4\u6539\u63A7\u4EF6\u540D
ReportColumns-Report_Columns=\u62A5\u8868\u5206\u680F
Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\!
FR-Designer_Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\!
CellElement-Property_Table=\u5355\u5143\u683C\u5C5E\u6027\u8868
Dictionary-Dynamic_SQL=\u52A8\u6001SQL
FR-Designer_Form-CheckBoxGroup=\u590D\u9009\u6846\u7EC4

2
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\u7C97\u9AD4
FR-Designer_Set_Submit_Condition=\u8A2D\u5B9A\u63D0\u4EA4\u689D\u4EF6
Form-Change_Widget_Name=\u66F4\u6539\u63A7\u5236\u9805\u540D
ReportColumns-Report_Columns=\u5831\u8868\u5206\u6B04
Can_not_use_FormatBursh=\u7121\u6CD5\u4F7F\u7528\u8907\u88FD\u683C\u5F0F
FR-Designer_Can_not_use_FormatBursh=\u7121\u6CD5\u4F7F\u7528\u8907\u88FD\u683C\u5F0F
CellElement-Property_Table=\u5132\u5B58\u683C\u5C6C\u6027\u8868
Dictionary-Dynamic_SQL=\u52D5\u614BSQL
FR-Designer_Form-CheckBoxGroup=\u5FA9\u9078\u6846\u7D44

35
designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -13,10 +13,7 @@ import com.fr.general.LogRecordTime;
import com.fr.stable.xml.LogRecordTimeProvider;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
@ -24,6 +21,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();
@ -132,8 +131,7 @@ public class DesignerLogHandler {
private UIMenuItem clear;
private LogHandlerArea() {
jTextArea = new JTextPane();
jTextArea = initLogJTextArea();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UIScrollPane js = new UIScrollPane(jTextArea);
this.add(js, BorderLayout.CENTER);
@ -158,9 +156,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
@ -188,6 +186,23 @@ public class DesignerLogHandler {
});
}
private JTextPane initLogJTextArea() {
final JTextPane resultPane = new JTextPane();
InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear");
ActionMap actionMap = resultPane.getActionMap();
actionMap.put("clear", new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
resultPane.setText("");
caption.clearMessage();
DesignerLogImpl.getInstance().clear();
}
});
return resultPane;
}
public void printStackTrace(LogRecordTimeProvider logRecordTime) {
LogRecord logRecord = logRecordTime.getLogRecord();
Date date = logRecordTime.getDate();
@ -297,6 +312,4 @@ public class DesignerLogHandler {
};
}
}

20
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);
}
};

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);

4
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

4
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

4
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

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;

4
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);
}
};
}

479
designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java

@ -21,250 +21,255 @@ 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;
public DataTableConfigPane() {
table = new DataEditingTable();
JScrollPane scrollPane = new JScrollPane(table);
this.setLayout(new DataTableLayout());
this.add(scrollPane, BorderLayout.CENTER);
}
public void populate(DataTableConfig config) {
table.populate(config);
}
public DataTableConfig update() {
return table.update();
}
class DataTableLayout extends BorderLayout {
public void layoutContainer(Container target) {
super.layoutContainer(target);
table.doLayout();
}
}
class DataEditingTable extends JTable {
private DataTableConfig config;
private BeanTableModel model;
private TableColumnModelListener modeListener;
public DataEditingTable() {
this.setBorder(BorderFactory.createLineBorder(new Color(210, 210, 210), 1));
this.setColumnSelectionAllowed(true);
this.setRowSelectionAllowed(true);
MouseAdapterListener l = new MouseAdapterListener(this);
this.addMouseListener(l);
this.addMouseMotionListener(l);
model = new BeanTableModel();
modeListener = new TableColumnModelListener() {
@Override
public void columnAdded(TableColumnModelEvent e) {
}
@Override
public void columnMarginChanged(ChangeEvent e) {
DataTableConfigPane.this.propertyChange();
}
@Override
public void columnMoved(TableColumnModelEvent e) {
DataTableConfigPane.this.propertyChange();
}
@Override
public void columnRemoved(TableColumnModelEvent e) {
}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {
}
};
}
public TableCellRenderer getCellRenderer(int row, int column) {
TableCellRenderer renderer = super.getCellRenderer(row, column);
if (renderer instanceof UILabel) {
((UILabel) renderer).setHorizontalAlignment(UILabel.CENTER);
}
return renderer;
}
public void populate(DataTableConfig config) {
this.getTableHeader().getColumnModel().removeColumnModelListener(modeListener);
if (config == null) {
config = DataTableConfig.DEFAULT_TABLE_DATA_CONFIG;
}
this.config = config;
model = new BeanTableModel();
this.setModel(model);
this.setRowHeight(0, config.getRowHeight());
for (int i = 0; i < config.getColumnCount(); i++) {
this.getColumn(this.getColumnName(i)).setPreferredWidth(config.getColumnWidth(i));
}
this.getTableHeader().getColumnModel().addColumnModelListener(modeListener);
this.doLayout();
this.repaint();
}
public DataTableConfig update() {
config.setRowHeight(this.getRowHeight(0));
model = new BeanTableModel();
String[] columns = new String[this.getColumnCount()];
for (int i = 0; i < this.getColumnCount(); i++) {
config.setColumnWidth(i, this.getColumn(this.getColumnName(i)).getWidth());
columns[i] = this.getColumnName(i);
}
config.setColumns(columns);
return config;
}
public class BeanTableModel extends AbstractTableModel {
@Override
public int getColumnCount() {
return config.getColumnCount();
}
@Override
public int getRowCount() {
return 1;
}
@Override
public String getColumnName(int column) {
return config.getColumnName(column);
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return config.getTableDataName() + "." + config.getColumnName(columnIndex);
}
}
class MouseAdapterListener extends MouseAdapter {
private JTable table;
int oldY = 0;
int newY = 0;
int row = 0;
int oldHeight = 0;
boolean drag = false;
int increase = 0;
JPopupMenu popupMenu;
public MouseAdapterListener(JTable table) {
this.table = table;
popupMenu = new JPopupMenu();
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
}
class CutAction extends UpdateAction {
/**
* Constructor
*/
public CutAction() {
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));
}
@Override
public void actionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
table.getColumnModel().removeColumn(table.getColumn(table.getColumnName(column)));
DataTableConfigPane.this.propertyChange();
}
}
public void mouseMoved(MouseEvent e) {
int onRow = table.rowAtPoint(e.getPoint());
int height = 0;
for (int i = 0; i <= onRow; i++) {
height = height + table.getRowHeight(i);
}
if (height - e.getY() < 3) {
drag = true;
table.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
} else {
drag = false;
table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
private void trigger_popup(MouseEvent e) {
popupMenu.show(table, e.getX(), e.getY());
}
public void mouseDragged(MouseEvent e) {
if (drag) {
int value = oldHeight + e.getY() - oldY;
if (value < 30)
table.setRowHeight(row, 30);
else
table.setRowHeight(row, oldHeight + e.getY() - oldY);
DataTableConfigPane.this.propertyChange();
}
}
public void mousePressed(MouseEvent e) {
oldY = e.getY();
row = table.rowAtPoint(e.getPoint());
oldHeight = table.getRowHeight(row);
if (e.getButton() == MouseEvent.BUTTON3) {
trigger_popup(e);
}
}
public void mouseReleased(MouseEvent e) {
newY = e.getY();
table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
}
private ArrayList<PropertyChangeListener> changetList = new ArrayList<PropertyChangeListener>();
public void addpropertyChangeListener(PropertyChangeListener l) {
changetList.add(l);
}
@Override
public void propertyChange() {
for (PropertyChangeListener l : changetList) {
l.propertyChange();
}
}
private DataEditingTable table;
public DataTableConfigPane() {
table = new DataEditingTable();
JScrollPane scrollPane = new JScrollPane(table);
this.setLayout(new DataTableLayout());
this.add(scrollPane, BorderLayout.CENTER);
}
public void populate(DataTableConfig config) {
table.populate(config);
}
public DataTableConfig update() {
return table.update();
}
class DataTableLayout extends BorderLayout {
public void layoutContainer(Container target) {
super.layoutContainer(target);
table.doLayout();
}
}
class DataEditingTable extends JTable {
private DataTableConfig config;
private BeanTableModel model;
private TableColumnModelListener modeListener;
public DataEditingTable() {
this.setBorder(BorderFactory.createLineBorder(new Color(210, 210, 210), 1));
this.setColumnSelectionAllowed(true);
this.setRowSelectionAllowed(true);
MouseAdapterListener l = new MouseAdapterListener(this);
this.addMouseListener(l);
this.addMouseMotionListener(l);
model = new BeanTableModel();
modeListener = new TableColumnModelListener() {
@Override
public void columnAdded(TableColumnModelEvent e) {
}
@Override
public void columnMarginChanged(ChangeEvent e) {
DataTableConfigPane.this.propertyChange();
}
@Override
public void columnMoved(TableColumnModelEvent e) {
DataTableConfigPane.this.propertyChange();
}
@Override
public void columnRemoved(TableColumnModelEvent e) {
}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {
}
};
}
public TableCellRenderer getCellRenderer(int row, int column) {
TableCellRenderer renderer = super.getCellRenderer(row, column);
if (renderer instanceof UILabel) {
((UILabel) renderer).setHorizontalAlignment(UILabel.CENTER);
}
return renderer;
}
public void populate(DataTableConfig config) {
this.getTableHeader().getColumnModel().removeColumnModelListener(modeListener);
if (config == null) {
config = DataTableConfig.DEFAULT_TABLE_DATA_CONFIG;
}
this.config = config;
model = new BeanTableModel();
this.setModel(model);
this.setRowHeight(0, config.getRowHeight());
for (int i = 0; i < config.getColumnCount(); i++) {
this.getColumn(this.getColumnName(i)).setPreferredWidth(config.getColumnWidth(i));
}
this.getTableHeader().getColumnModel().addColumnModelListener(modeListener);
this.doLayout();
this.repaint();
}
public DataTableConfig update() {
config.setRowHeight(this.getRowHeight(0));
model = new BeanTableModel();
String[] columns = new String[this.getColumnCount()];
for (int i = 0; i < this.getColumnCount(); i++) {
config.setColumnWidth(i, this.getColumn(this.getColumnName(i)).getWidth());
columns[i] = this.getColumnName(i);
}
config.setColumns(columns);
return config;
}
public class BeanTableModel extends AbstractTableModel {
@Override
public int getColumnCount() {
return config.getColumnCount();
}
@Override
public int getRowCount() {
return 1;
}
@Override
public String getColumnName(int column) {
return config.getColumnName(column);
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return config.getTableDataName() + "." + config.getColumnName(columnIndex);
}
}
class MouseAdapterListener extends MouseAdapter {
private final static int DIS = 30;
private final static int SMALL_DIS = 3;
private JTable table;
int oldY = 0;
int newY = 0;
int row = 0;
int oldHeight = 0;
boolean drag = false;
int increase = 0;
JPopupMenu popupMenu;
public MouseAdapterListener(JTable table) {
this.table = table;
popupMenu = new JPopupMenu();
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
popupMenu.add(new CutAction());
}
class CutAction extends UpdateAction {
/**
* Constructor
*/
public CutAction() {
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, DEFAULT_MODIFIER));
}
@Override
public void actionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
table.getColumnModel().removeColumn(table.getColumn(table.getColumnName(column)));
DataTableConfigPane.this.propertyChange();
}
}
public void mouseMoved(MouseEvent e) {
int onRow = table.rowAtPoint(e.getPoint());
int height = 0;
for (int i = 0; i <= onRow; i++) {
height = height + table.getRowHeight(i);
}
if (height - e.getY() < SMALL_DIS) {
drag = true;
table.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
} else {
drag = false;
table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
private void trigger_popup(MouseEvent e) {
popupMenu.show(table, e.getX(), e.getY());
}
public void mouseDragged(MouseEvent e) {
if (drag) {
int value = oldHeight + e.getY() - oldY;
if (value < DIS) {
table.setRowHeight(row, DIS);
} else {
table.setRowHeight(row, oldHeight + e.getY() - oldY);
}
DataTableConfigPane.this.propertyChange();
}
}
public void mousePressed(MouseEvent e) {
oldY = e.getY();
row = table.rowAtPoint(e.getPoint());
oldHeight = table.getRowHeight(row);
if (e.getButton() == MouseEvent.BUTTON3) {
trigger_popup(e);
}
}
public void mouseReleased(MouseEvent e) {
newY = e.getY();
table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
}
private ArrayList<PropertyChangeListener> changetList = new ArrayList<PropertyChangeListener>();
public void addpropertyChangeListener(PropertyChangeListener l) {
changetList.add(l);
}
@Override
public void propertyChange() {
for (PropertyChangeListener l : changetList) {
l.propertyChange();
}
}
@Override
public void propertyChange(Object mark) {
}
@Override
public void propertyChange(Object[] marks) {
@Override
public void propertyChange(Object[] marks) {
}
}
}
Loading…
Cancel
Save