Browse Source

Merge pull request #1513 in BA/design from ~PLOUGH/design:feature/9.0 to feature/9.0

* commit '942cf831409066a9d2b07db41ef23630dceac7e1':
  REPORT-4634 组件叠加体验优化=>5 支持 delete 和 backspace 删除组件
  REPORT-4634 组件叠加体验优化=>4缩略图=>调整代码
  REPORT-4634 组件叠加体验优化=>4缩略图=>修复删除组件后,预览框不消失的bug
  REPORT-4634 组件叠加体验优化=>4缩略图=>完成缩略图显示
  REPORT-4634 组件叠加体验优化=>4缩略图=>缩略图框架
  REPORT-4634 组件叠加体验优化=>3=>icon 替换
  REPORT-4634 组件叠加体验优化=>3=>处理操作置灰的情况
  REPORT-4634 组件叠加体验优化=>3=>右键菜单支持
  REPORT-4634 组件叠加体验优化=>3=>上移、下移、置顶、置底
  REPORT-4634 组件叠加体验优化=>3=>增加4个按钮、快捷键
  REPORT-4634 组件叠加体验优化=>2=>修复点击控件树的npe问题
  REPORT-4634 组件叠加体验优化=>2=>调整交互和视觉
  REPORT-4634 组件叠加体验优化=>2=>修复添加控件,控件树不刷新的问题
  REPORT-4634 组件叠加体验优化=>1=>tabpane 点击控件树退出编辑(tabpane的实现有点奇怪,先不管)
  REPORT-4634 组件叠加体验优化=>1=>控件树中点击图表块自身、绝对布局自身,可退出编辑状态
  REPORT-4634 组件叠加体验优化=>1=>点击控件时,控件树的选项跟着变化
  REPORT-4634 组件叠加体验优化=>1=>点击控件树退出绝对布局编辑
  REPORT-4634 组件叠加体验优化=>1、2 初步框架
master
superman 7 years ago
parent
commit
7b5967a02f
  1. BIN
      designer_base/src/com/fr/design/images/control/to_bottom.png
  2. BIN
      designer_base/src/com/fr/design/images/control/to_top.png
  3. 4
      designer_base/src/com/fr/design/locale/designer.properties
  4. 4
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  5. 4
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  6. 4
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  7. 4
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  8. 4
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  9. 19
      designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java
  10. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java
  11. 60
      designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java
  12. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java
  13. 59
      designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java
  14. 2
      designer_form/src/com/fr/design/designer/beans/events/DesignerEvent.java
  15. 5
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  16. 8
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  17. 35
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  18. 3
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  19. 4
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  20. 3
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  21. 4
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  22. 5
      designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java
  23. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  24. 2
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  25. 5
      designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java
  26. 164
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  27. 23
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  28. 44
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  29. 86
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java
  30. 2
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java
  31. 2
      designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java

BIN
designer_base/src/com/fr/design/images/control/to_bottom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
designer_base/src/com/fr/design/images/control/to_top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

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

@ -2149,3 +2149,7 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=Move up
FR-Designer_Move_Down=Move down
FR-Designer_Move_To_Top=Move to top
FR-Designer_Move_To_Bottom=Move to bottom

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

@ -2148,3 +2148,7 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=Move up
FR-Designer_Move_Down=Move down
FR-Designer_Move_To_Top=Move to top
FR-Designer_Move_To_Bottom=Move to bottom

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

@ -2149,3 +2149,7 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570:
FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9
FR-Designer_Env_Des_Https=
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=
FR-Designer_Move_Down=
FR-Designer_Move_To_Top=
FR-Designer_Move_To_Bottom=

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

@ -2149,3 +2149,7 @@ FR-Designer_Export_Background=
FR-Designer_Print_Background=
FR-Designer_Env_Des_Https=
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=
FR-Designer_Move_Down=
FR-Designer_Move_To_Top=
FR-Designer_Move_To_Bottom=

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

@ -2149,3 +2149,7 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002
FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801
FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C42
FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C42
FR-Designer_Move_To_Top=\u7F6E\u4E8E\u9876\u5C42
FR-Designer_Move_To_Bottom=\u7F6E\u4E8E\u5E95\u5C42

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

@ -2148,3 +2148,7 @@ FR-Designer_Provide_Choose_All=
FR-Designer_Decimal_Places=
FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002
FR-Designer_Format_JavaScript=Format Code
FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C64
FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C64
FR-Designer_Move_To_Top=\u7F6E\u65BC\u9802\u5C64
FR-Designer_Move_To_Bottom=\u7F6E\u65BC\u5E95\u5C64

19
designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -5,7 +5,7 @@ package com.fr.design.designer.beans.actions;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.general.Inter;
@ -26,7 +26,15 @@ public class FormDeleteAction extends FormUndoableAction {
this.setMnemonic('D');
// Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
}
@Override
public JComponent createToolBarComponent() {
JComponent comp = super.createToolBarComponent();
// 除了 BACKSPACE 之外,DELETE 键也要能删除(直接在此处添加绑定,没有按钮提示)
comp.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
return comp;
}
/**
@ -50,13 +58,6 @@ public class FormDeleteAction extends FormUndoableAction {
@Override
public void update() {
// FormDesigner f = this.getEditingComponent();
// if (f == null) {
// this.setEnabled(false);
// return;
// }
// SelectionModel selection = f.getSelectionModel();
// this.setEnabled(selection.hasSelectionComponent());
this.setEnabled(true);
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 下移一层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveDownAction extends FormEditAction {
public MoveDownAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_Down"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentZOrder(creator) + 1;
if (targetIndex >= container.getComponentCount()) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
}

60
designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java

@ -0,0 +1,60 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 置于底层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveToBottomAction extends FormEditAction {
public MoveToBottomAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_To_Bottom"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_bottom.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentCount() - 1;
if (container.getComponentZOrder(creator) >= targetIndex) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableDown());
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 置于顶层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveToTopAction extends FormEditAction {
public MoveToTopAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_To_Top"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_top.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
if (container.getComponentZOrder(creator) == 0) {
return false;
}
container.setComponentZOrder(creator, 0);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
}

59
designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java

@ -0,0 +1,59 @@
package com.fr.design.designer.beans.actions;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 同级上移一层控件树内
* Created by plough on 2017/12/4.
*/
public class MoveUpAction extends FormEditAction {
public MoveUpAction(FormDesigner t) {
super(t);
this.setName(Inter.getLocText("FR-Designer_Move_Up"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER));
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
Container container = creator.getParent();
int targetIndex = container.getComponentZOrder(creator) - 1;
if (targetIndex < 0) {
return false;
}
container.setComponentZOrder(creator, targetIndex);
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED);
return true;
}
@Override
public void update() {
FormDesigner designer = getEditingComponent();
if (designer == null) {
this.setEnabled(false);
return;
}
this.setEnabled(designer.isCurrentComponentMovableUp());
}
}

2
designer_form/src/com/fr/design/designer/beans/events/DesignerEvent.java

@ -23,6 +23,8 @@ public class DesignerEvent {
public static final int CREATOR_RENAMED = 8;
public static final int CREATOR_ORDER_CHANGED = 9;
private int eventID;
private XComponent affectedXCreator;

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

@ -62,13 +62,16 @@ public class SelectionModel {
* @param e 鼠标事件
*/
public void selectACreatorAtMouseEvent(MouseEvent e) {
if (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown()) {
if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
selection.reset();
}
// 获取e所在的组件
XCreator comp = designer.getComponentAt(e);
selectACreator(comp);
}
public void selectACreator(XCreator comp) {
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if (topLayout != null && !topLayout.isEditable()) {

8
designer_form/src/com/fr/design/designer/creator/XChartEditor.java

@ -76,6 +76,11 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return true;
}
@Override
public void stopEditing() {
isEditing = false;
}
/**
* 得到属性名
* @return 属性名
@ -201,7 +206,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR;
isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR);
displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e);

35
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -4,8 +4,10 @@
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.actions.*;
import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.fun.WidgetPropertyUIProvider;
@ -47,6 +49,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
private Rectangle backupBound;
private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性
private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上
private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置
public XCreator(Widget ob, Dimension initSize) {
this.data = ob;
@ -653,7 +656,39 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
*
*/
public void firePropertyChange(){
// do nothing
}
/**
* 有的控件是有编辑状态的给一个退出编辑的接口
*
*/
public void stopEditing() {
// do nothing
}
/**
* 创建右击弹出菜单
*
*/
public JPopupMenu createPopupMenu(FormDesigner formDesigner) {
UpdateAction[] actions = formDesigner.getActions();
JPopupMenu popup = new JPopupMenu();
for (int i = 0; i < actions.length; i++) {
if (i == SHORTS_SEPARATOR_POS) {
popup.addSeparator();
}
popup.add(actions[i].createMenuItem());
}
return popup;
}
/**
* 是否支持上移一层下移一层等操作
*
*/
public boolean isMovable() {
return true;
}
}

3
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -302,7 +302,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){
FormDesigner designer = editingMouseListener.getDesigner();
if (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR){
if (e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){
FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e);
//切换设计器
designer.switchTab(component);

4
designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -107,5 +107,9 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
initStyle();
}
@Override
public boolean isMovable() {
return false;
}
}

3
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -467,7 +467,8 @@ public class XWAbsoluteLayout extends XLayoutContainer {
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
boolean isEditing = isEditable() ||
e.getButton() == MouseEvent.BUTTON1 && (designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);

4
designer_form/src/com/fr/design/designer/creator/XWFitLayout.java

@ -1181,4 +1181,8 @@ public class XWFitLayout extends XLayoutContainer {
return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)};
}
@Override
public boolean isMovable() {
return false;
}
}

5
designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java

@ -227,4 +227,9 @@ public class XWParameterLayout extends XWAbsoluteLayout {
}
@Override
public boolean isMovable() {
return false;
}
}

3
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -246,7 +246,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2;
boolean isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);

2
designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -36,7 +36,7 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
return this;
}

5
designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java

@ -22,6 +22,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.parameter.ParameterUI;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
@ -322,9 +323,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
*
* @return 同上
*/
public Action[] getActions() {
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
}
return designerActions;

164
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -1,10 +1,16 @@
package com.fr.design.mainframe;
import java.awt.Component;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.DropMode;
import javax.swing.JTree;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
@ -12,16 +18,23 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import com.fr.web.core.A.M;
public class ComponentTree extends JTree {
private FormDesigner designer;
private ComponentTreeModel model;
private UITreeUI uiTreeUI = new UITreeUI();
private PopupPreviewPane previewPane;
private static final int PADDING_LEFT = 10;
private static final int PADDING_TOP = 8;
public ComponentTree(FormDesigner designer) {
this.designer = designer;
this.setBackground(UIConstants.NORMAL_BACKGROUND);
this.setBackground(UIConstants.TREE_BACKGROUND);
setRootVisible(true);
setCellRenderer(new ComponentTreeCellRenderer());
getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
@ -30,7 +43,10 @@ public class ComponentTree extends JTree {
this.setTransferHandler(new TreeTransferHandler());
this.refreshTreeRoot();
addTreeSelectionListener(designer);
addMouseMotionListener(new ComponetTreeMouseListener(this));
setEditable(true);
setUI(uiTreeUI);
setBorder(BorderFactory.createEmptyBorder(PADDING_TOP, PADDING_LEFT, 0, 0));
}
public FormDesigner getDesigner() {
@ -48,32 +64,42 @@ public class ComponentTree extends JTree {
this.setModel(model);
}
public void setSelectionPath(TreePath path) {
// 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块)
designer.stopEditing(path);
super.setSelectionPath(path);
}
@Override
public void removeAll() {
if (previewPane != null) {
previewPane.setVisible(false);
previewPane.removeAll();
}
super.removeAll();
}
/**
* 是否可编辑
*
* @param path 树路径
* @return 是则返回true
*/
@Override
public boolean isPathEditable(TreePath path) {
Object object = path.getLastPathComponent();
if (object == designer.getRootComponent()) {
return false;
}
return super.isPathEditable(path);
}
/**
* 将值转换为文本
*
* @param value
* @param selected 是否选中
* @param expanded 扩展
* @param leaf 是否叶子
* @param row
* @param hasFocus 是否焦点
*
* @return 返回文本
*/
@Override
@ -96,12 +122,10 @@ public class ComponentTree extends JTree {
*/
public void refreshUI() {
updateUI();
setUI(uiTreeUI);
}
public TreePath[] getSelectedTreePath() {
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators();
TreePath[] paths = new TreePath[creators.length];
@ -112,8 +136,6 @@ public class ComponentTree extends JTree {
}
/**
* 搜索指定名称的路径
*
@ -210,4 +232,118 @@ public class ComponentTree extends JTree {
return new TreePath(components);
}
private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) {
if (previewPane == null) {
previewPane = new PopupPreviewPane();
}
if (previewPane.isVisible() && previewPane.getLocationOnScreen().y != popupPosYOnScreen) {
previewPane.setVisible(false);
}
if (!previewPane.isVisible()) {
previewPane.setComp(comp);
int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y;
GUICoreUtils.showPopupMenu(previewPane, FormHierarchyTreePane.getInstance(), -previewPane.getPreferredSize().width, popupPosY);
}
}
private void hidePreviewPane() {
if (previewPane != null && previewPane.isVisible()) {
previewPane.setVisible(false);
}
}
private final class ComponetTreeMouseListener extends MouseAdapter {
private final JTree tree;
private ComponetTreeMouseListener(JTree tree) {
this.tree = tree;
}
@Override
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int selRow = tree.getRowForLocation(p.x, p.y);
TreeCellRenderer r = tree.getCellRenderer();
if (selRow != -1 && r != null) {
TreePath path = tree.getPathForRow(selRow);
Point point = tree.getPathBounds(path).getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
popupPreviewPane(point.y, comp);
} else {
hidePreviewPane();
}
}
}
private class PopupPreviewPane extends JPopupMenu {
private Container contentPane;
private BufferedImage compImage;
private static final int MAX_WIDTH = 360;
private static final int MAX_HEIGHT = 280;
PopupPreviewPane() {
contentPane = new JPanel();
contentPane.setBackground(Color.white);
this.setLayout(new BorderLayout());
this.add(contentPane, BorderLayout.CENTER);
this.setOpaque(false);
setPreferredSize(new Dimension(MAX_WIDTH, MAX_HEIGHT));
setBorder(BorderFactory.createLineBorder(UIConstants.LINE_COLOR));
}
public void setComp(XCreator comp) {
try {
this.compImage = componentToImage(comp);
this.updateSize();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (compImage != null) {
g.drawImage(compImage, 0, 0, getWidth(), getHeight(), null);
}
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
}
public void menuSelectionChanged(boolean isIncluded) {
}
public Container getContentPane() {
return contentPane;
}
private BufferedImage componentToImage(Component comp) throws IOException
{
BufferedImage im = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_ARGB);
comp.paint(im.getGraphics());
return im;
}
// 根据控件内容,更新弹出框大小
private void updateSize() {
int width = compImage.getWidth();
int height = compImage.getHeight();
double aspectRatio = (double)width / height;
if (width > MAX_WIDTH) {
width = MAX_WIDTH;
height = (int)(width / aspectRatio);
}
if (height > MAX_HEIGHT) {
height = MAX_HEIGHT;
width = (int)(height * aspectRatio);
}
this.setPreferredSize(new Dimension(width, height));
}
}
}

23
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -11,11 +11,13 @@ import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
@ -489,7 +491,16 @@ public class EditingMouseListener extends MouseInputAdapter {
return false;
}
private XCreator processTopLayoutMouseClick(XCreator creator) {
// 点击控件树,会触发此方法。如果在设计器中选中组件,则直接走 processTopLayoutMouseClick
public void stopEditTopLayout(XCreator creator) {
boolean isTabpaneSelected = creator instanceof XWCardLayout && creator.getParent().equals(clickTopLayout);
if (clickTopLayout != null && (isTabpaneSelected || clickTopLayout.equals(creator))) {
clickTopLayout.setEditable(false);
}
processTopLayoutMouseClick(creator);
}
public XCreator processTopLayoutMouseClick(XCreator creator) {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if (topLayout != null) {
if (clickTopLayout != null && !clickTopLayout.equals(topLayout) && !isCreatorInLayout(clickTopLayout,
@ -518,8 +529,9 @@ public class EditingMouseListener extends MouseInputAdapter {
*/
public void mouseClicked(MouseEvent e) {
XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
if (e.getButton() != MouseEvent.BUTTON1 && !creator.acceptType(XCardSwitchButton.class)) {
if (!isValidButton && !creator.acceptType(XCardSwitchButton.class)) {
return;
}
@ -527,6 +539,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (creator != null) {
creator.respondClick(this, e);
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu cellPopupMenu = creator.createPopupMenu(designer);
if (cellPopupMenu != null) {
GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY());
}
}
}
creator.doLayout();
LayoutUtils.layoutRootContainer(designer.getRootComponent());
@ -589,6 +607,7 @@ public class EditingMouseListener extends MouseInputAdapter {
}
designer.invalidate();
designer.repaint();
currentXCreator.stopEditing();
currentXCreator = null;
currentEditor = null;
return true;

44
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -4,13 +4,11 @@ import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.Painter;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.actions.*;
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter;
import com.fr.design.designer.beans.events.CreatorEventListenerTable;
import com.fr.design.designer.beans.events.DesignerEditListener;
@ -108,7 +106,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
protected Action[] designerActions;
protected UpdateAction[] designerActions;
private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer;
@ -216,7 +214,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
}
}
/**
* 是否有查询按钮
*
@ -672,6 +669,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
setParameterArray(getNoRepeatParas(getTarget().getParameters()));
refreshParameter();
}
} else {
for( UpdateAction action : getActions()) {
action.update();
}
}
}
@ -1126,14 +1127,29 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*
* @return 同上
*/
public Action[] getActions() {
public UpdateAction[] getActions() {
if (designerActions == null) {
designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this)};
designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this),
new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this),
new MoveUpAction(this), new MoveDownAction(this)};
}
return designerActions;
}
// 当前选中控件可以上移一层吗?
public boolean isCurrentComponentMovableUp() {
XCreator creator = getSelectionModel().getSelection().getSelectedCreator();
Container container = creator.getParent();
return creator.isMovable() && container.getComponentZOrder(creator) > 0;
}
// 当前选中控件可以下移一层吗?
public boolean isCurrentComponentMovableDown() {
XCreator creator = getSelectionModel().getSelection().getSelectedCreator();
Container container = creator.getParent();
return creator.isMovable() && container.getComponentZOrder(creator) < container.getComponentCount() - 1;
}
protected Border getOuterBorder() {
return XCreatorConstants.AREA_BORDER;
}
@ -1238,6 +1254,16 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// do nothing
}
public void stopEditing(TreePath path) {
// do nothing
XCreator comp = (XCreator) path.getLastPathComponent();
editingMouseListener.stopEditing();
editingMouseListener.stopEditTopLayout(comp);
editingMouseListener.getSelectionModel().reset();
editingMouseListener.getSelectionModel().selectACreator(comp);
}
/**
* 返回表单控件权限编辑pane
*

86
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -1,35 +1,27 @@
package com.fr.design.mainframe;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UndoableAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.actions.ChangeNameAction;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.widget.UITreeComboBox;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.parameter.HierarchyTreePane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.base.BaseUtils;
import com.fr.general.Inter;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
/**
@ -37,14 +29,13 @@ import com.fr.design.layout.FRGUIPaneFactory;
*/
public class FormHierarchyTreePane extends FormDockView implements HierarchyTreePane {
public static final int NODE_LENGTH = 2;
public static final int PARA = 0;
public static final int BODY = 1;
private static final int NODE_LENGTH = 2;
private static final int PARA = 0;
private static final int BODY = 1;
private static final int SHORTS_SEPARATOR_POS = 4;
private ShortCut4JControlPane[] shorts;
private ComponentTree componentTree;
private UITreeComboBox treeComboBox;
private ChangeNameAction changeVarNameAction;
public static FormHierarchyTreePane getInstance() {
return HOLDER.singleton;
@ -92,18 +83,21 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
public void refreshDockingView() {
FormDesigner formDesigner = this.getEditingFormDesigner();
removeAll();
changeVarNameAction = null;
if(this.componentTree != null) {
this.componentTree.removeAll();
}
if(this.treeComboBox != null) {
this.treeComboBox.removeAll();
}
if (formDesigner == null) {
clearDockingView();
return;
}
componentTree = new ComponentTree(formDesigner);
formDesigner.addDesignerEditListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath());
componentTree.refreshUI();
}
});
ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel();
XCreator root = (XCreator)treeModel.getRoot();
@ -120,25 +114,18 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
shorts = createShortcuts();
JPanel widgetPane = new JPanel();
widgetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
widgetPane.setBorder(BorderFactory.createLineBorder(UIConstants.RULER_LINE_COLOR));
widgetPane.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel headPane = new JPanel(new BorderLayout());
headPane.add(new UILabel(Inter.getLocText("FR-Designer-Selected_Widget") + " ",
SwingConstants.HORIZONTAL), BorderLayout.WEST);
headPane.add(getToolBarPane(), BorderLayout.EAST);
widgetPane.add(headPane, BorderLayout.CENTER);
treeComboBox = new UITreeComboBox(componentTree);
widgetPane.add(treeComboBox, BorderLayout.SOUTH);
widgetPane.add(getToolBarPane(), BorderLayout.CENTER);
UIScrollPane scrollPane = new UIScrollPane(componentTree);
scrollPane.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.RULER_LINE_COLOR));
scrollPane.setPreferredSize(new Dimension(210, 170));
widgetPane.add(scrollPane, BorderLayout.SOUTH);
return widgetPane;
}
private JPanel getToolBarPane() {
ToolBarDef toolbarDef = new ToolBarDef();
for (ShortCut4JControlPane sj : shorts) {
toolbarDef.addShortCut(sj.getShortCut());
}
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolBar.setUI(new UIToolBarUI(){
@Override
@ -148,7 +135,13 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
g2.fillRect(0, 0, c.getWidth(), c.getHeight());
}
});
toolbarDef.updateToolBar(toolBar);
for (int i = 0; i < shorts.length; i++) {
if (i == SHORTS_SEPARATOR_POS) {
toolBar.addSeparator(new Dimension(2, 16));
}
shorts[i].getShortCut().intoJToolBar(toolBar);
}
JPanel toolBarPane = new JPanel(new BorderLayout());
toolBarPane.add(toolBar, BorderLayout.CENTER);
return toolBarPane;
@ -157,10 +150,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
protected ShortCut4JControlPane[] createShortcuts() {
ArrayList<ShortCut4JControlPane> shortCutList = new ArrayList<>();
FormDesigner designer = getEditingFormDesigner();
if (changeVarNameAction == null) {
changeVarNameAction = new ChangeNameAction(designer);
}
shortCutList.add(new WidgetEnableShortCut(changeVarNameAction));
for (Action action : designer.getActions()) {
shortCutList.add(new WidgetEnableShortCut((UndoableAction)action));
}

2
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -395,7 +395,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope
*/
public void fireCreatorModified(DesignerEvent evt) {
int[] validEventIds = {DesignerEvent.CREATOR_RESIZED, DesignerEvent.CREATOR_EDITED,
DesignerEvent.CREATOR_SELECTED, DesignerEvent.CREATOR_ADDED};
DesignerEvent.CREATOR_SELECTED, DesignerEvent.CREATOR_ADDED, DesignerEvent.CREATOR_ORDER_CHANGED};
boolean isValid = false;
for (int validEventId : validEventIds) {
if (evt.getCreatorEventID() == validEventId) {

2
designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java

@ -118,7 +118,7 @@ public class ParameterPropertyPane extends JPanel{
private void setEditor(FormDesigner editor) {
if (formHierarchyTreePaneWrapper == null) {
formHierarchyTreePaneWrapper = new JPanel(new BorderLayout());
formHierarchyTreePaneWrapper.setBorder(BorderFactory.createEmptyBorder(0, PADDING_MIDDLE, 0, PADDING_LARGE));
formHierarchyTreePaneWrapper.setBorder(BorderFactory.createEmptyBorder(PADDING_MIDDLE, PADDING_MIDDLE, 0, PADDING_MIDDLE));
this.add(formHierarchyTreePaneWrapper, BorderLayout.SOUTH);
}
formHierarchyTreePaneWrapper.remove(FormHierarchyTreePane.getInstance());

Loading…
Cancel
Save