Browse Source

Merge pull request #198 in BA/design from ~ZHOUPING/design:dev to dev

* commit '6ccd8301703b7f6655ae3b741ce0f9eaf21ab3f5':
  今天要合到master代码,新功能来不及测试了,先回退
master
superman 8 years ago
parent
commit
468b8d5248
  1. 9
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  2. 7
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  3. 101
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  4. 8
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  5. 26
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  6. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  7. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  8. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  9. 91
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  10. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  11. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  12. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  13. 138
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

9
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -14,7 +14,6 @@ import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter; import com.fr.design.designer.beans.painters.FRFitLayoutPainter;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
@ -164,7 +163,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
return false; return false;
} }
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上
boolean isMatchEdge = matchEdge(x, y); matchEdge(x, y);
int componentHeight = comp.getHeight(); int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth(); int componentWidth = comp.getWidth();
@ -173,12 +172,6 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
//下半部分高度 //下半部分高度
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY();
//布局控件要先判断是不是可编辑
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null && !isMatchEdge && !topLayout.isEditable()){
return false;
}
if (isCrossPointArea(comp, x, y)) { if (isCrossPointArea(comp, x, y)) {
return canAcceptWhileCrossPoint(comp, x, y); return canAcceptWhileCrossPoint(comp, x, y);
} }

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

@ -66,13 +66,6 @@ public class SelectionModel {
// 获取e所在的组件 // 获取e所在的组件
XCreator comp = designer.getComponentAt(e); XCreator comp = designer.getComponentAt(e);
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if(topLayout != null && !topLayout.isEditable()){
comp = topLayout;
}
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的 // 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
XCreator parentContainer = (XCreator) comp.getParent(); XCreator parentContainer = (XCreator) comp.getParent();

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

@ -1,22 +1,20 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.*; import java.awt.Color;
import java.awt.event.MouseEvent; import java.awt.Dimension;
import java.awt.image.BufferedImage; import java.awt.Graphics;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -43,9 +41,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法 //marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false; private boolean isRefreshing = false;
private boolean isEditing = false;
private JPanel coverPanel;
public XChartEditor(BaseChartEditor editor) { public XChartEditor(BaseChartEditor editor) {
this(editor, new Dimension(250, 150)); this(editor, new Dimension(250, 150));
} }
@ -147,22 +142,17 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
} }
}); });
if (isEditing){ final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartWidgetPropertyPane(formDesigner);
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane(); SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeLater(new Runnable() { @Override
@Override public void run() {
public void run() { if (getDesignerEditor().getEditorTarget() != null) {
if (getDesignerEditor().getEditorTarget() != null) { propertyPane.setSupportCellData(true);
propertyPane.setSupportCellData(true); propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
}
} }
}); }
return (JComponent)propertyPane; });
} return (JComponent)propertyPane;
else{
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
} }
private MiddleChartComponent getDesignerEditorTarget() { private MiddleChartComponent getDesignerEditorTarget() {
@ -177,8 +167,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter * 渲染Painter
*/ */
public void paint(Graphics g) { public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize());
super.paint(g); super.paint(g);
designerEditor.paintEditor(g, this.getSize());
} }
/** /**
@ -190,27 +180,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return new Dimension(250, 100); return new Dimension(250, 100);
} }
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
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;
displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
if (editingMouseListener.stopEditing()) {
if (this != (XCreator)designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
@Override @Override
protected JComponent initEditor() { protected JComponent initEditor() {
if (designerEditor == null) { if (designerEditor == null) {
@ -229,36 +198,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}); });
} }
} }
return null;
if (editor == null) {
setBorder(DEFALUTBORDER);
editor = new JPanel();
editor.setBackground(null);
editor.setLayout(null);
editor.setOpaque(false);
coverPanel = new CoverReportPane();
coverPanel.setPreferredSize(this.getPreferredSize());
coverPanel.setBounds(this.getBounds());
editor.add(coverPanel);
coverPanel.setVisible(false);
}
return editor;
}
/**
* 是否展现覆盖的pane
* @param display 是否
*/
public void displayCoverPane(boolean display){
coverPanel.setVisible(display);
coverPanel.setPreferredSize(editor.getPreferredSize());
coverPanel.setBounds(editor.getBounds());
editor.repaint();
}
public JComponent getCoverPane(){
return coverPanel;
} }
} }

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

@ -106,14 +106,6 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
setBackupParent(XCreatorUtils.getParentXLayoutContainer(this)); setBackupParent(XCreatorUtils.getParentXLayoutContainer(this));
} }
/**
* 获取当前布局控件的顶层布局框架如tab布局绝对布局
* @return 封装的顶层布局
*/
public XLayoutContainer getTopLayout(){
return null;
}
/** /**
* 获取当前XCreator的一个封装父容器 * 获取当前XCreator的一个封装父容器
* *

26
designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -41,16 +41,6 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
protected boolean isRefreshing; protected boolean isRefreshing;
protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上 protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上
/**
* 布局是否可编辑不可则显示编辑层
*/
protected boolean editable = false;
//鼠标移动到布局画出编辑层
protected boolean isMouseEnter = false;
public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter;
}
public XLayoutContainer(WLayout widget, Dimension initSize) { public XLayoutContainer(WLayout widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
this.addContainerListener(this); this.addContainerListener(this);
@ -456,20 +446,4 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
public void setBackground(Background background){ public void setBackground(Background background){
} }
/**
* 布局是否可编辑不可则显示编辑蒙层
* @return 可否编辑
*/
public boolean isEditable(){
return this.editable;
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* @param isEditable 可否编辑
*/
public void setEditable(boolean isEditable){
this.editable = isEditable;
}
} }

8
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -12,7 +12,6 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.FormHierarchyTreePane;
@ -150,8 +149,6 @@ public class XCardAddButton extends XButton{
XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout);
titleButton.setCustomStyle(true); titleButton.setCustomStyle(true);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index); this.tagLayout.setTabFitIndex(index);
@ -183,9 +180,4 @@ public class XCardAddButton extends XButton{
} }
return newTextName; return newTextName;
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

5
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -293,9 +293,4 @@ public class XCardSwitchButton extends XButton {
selectionModel.setSelectedCreator(designer.getRootComponent()); selectionModel.setSelectedCreator(designer.getRootComponent());
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

5
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -367,9 +367,4 @@ public class XWCardLayout extends XLayoutContainer {
mainLayout.setBorder(border); mainLayout.setBorder(border);
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

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

@ -3,24 +3,18 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.*; import java.awt.Color;
import java.awt.event.MouseEvent; import java.awt.Component;
import java.awt.image.BufferedImage; import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
/** /**
* card布局主体框架 * card布局主体框架
@ -38,9 +32,6 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
private static final int TITLE_STYLE = 2; private static final int TITLE_STYLE = 2;
private static final int NORMAL_STYLE = 1; private static final int NORMAL_STYLE = 1;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
/** /**
* 构造函数 * 构造函数
*/ */
@ -133,7 +124,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
/** /**
* 重新调整子组件的宽度 * 重新调整子组件的宽度
* @param width 宽度 * @param 宽度
*/ */
public void recalculateChildWidth(int width){ public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
@ -197,72 +188,4 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
} }
} }
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !editable) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h);
//画编辑按钮所在框
g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH);
g2d.drawImage(
image,
(x + w / 2 - 23),
(y + h / 2 - image.getHeight() / 2),
image.getWidth(),
image.getHeight(),
null,
this
);
g2d.setColor(Color.BLACK);
//画编辑文字
g2d.drawString(Inter.getLocText("Edit"), x + w / 2 - 2, y + h / 2 + 5);
}
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
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;
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
designer.repaint();
if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
/**
* XWCardMainBorderLayout是card布局主体框架tab的顶层布局
* @return
*/
@Override
public XLayoutContainer getTopLayout() {
return this;
}
} }

6
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -13,7 +13,6 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWHorizontalBoxLayout; import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
@ -215,9 +214,4 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

6
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -12,7 +12,6 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
@ -147,9 +146,4 @@ public class XWCardTitleLayout extends XWBorderLayout {
} }
} }
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

7
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -188,7 +188,7 @@ public class XWTabFitLayout extends XWFitLayout {
/** /**
* 该布局需要隐藏无需对边框进行操作 * 该布局需要隐藏无需对边框进行操作
* @param border 边框 * @param 边框
* *
*/ */
public void setBorder(Border border) { public void setBorder(Border border) {
@ -362,9 +362,4 @@ public class XWTabFitLayout extends XWFitLayout {
this.hasCalGap = true; this.hasCalGap = true;
} }
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
} }

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

@ -18,7 +18,12 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location; import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel; import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XEditorHolder;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor; import com.fr.design.gui.xpane.ToolTipEditor;
@ -41,10 +46,6 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
private StateModel stateModel; private StateModel stateModel;
private XLayoutContainer xTopLayoutContainer;
private XLayoutContainer clickTopLayout;
/** /**
* 获取表单设计器 * 获取表单设计器
* *
@ -83,14 +84,10 @@ public class EditingMouseListener extends MouseInputAdapter {
private int minDragSize = 5; private int minDragSize = 5;
private int minMoveSize = 8; private int minMoveSize = 8;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
//报表块的编辑按钮不灵敏,范围扩大一点 //报表块的编辑按钮不灵敏,范围扩大一点
private static final int GAP = 10; private static final int GAP = 10;
private XElementCase xElementCase; private XElementCase xElementCase;
private XChartEditor xChartEditor;
private JWindow promptWindow = new JWindow(); private JWindow promptWindow = new JWindow();
@ -247,12 +244,6 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
XCreator component = designer.getComponentAt(e); XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay();
if(processTopLayoutMouseMove(component, e)){
return;
}
if (component instanceof XEditorHolder) { if (component instanceof XEditorHolder) {
XEditorHolder xcreator = (XEditorHolder) component; XEditorHolder xcreator = (XEditorHolder) component;
Rectangle rect = xcreator.getBounds(); Rectangle rect = xcreator.getBounds();
@ -276,15 +267,17 @@ public class EditingMouseListener extends MouseInputAdapter {
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
stateModel.setDirection(dir); stateModel.setDirection(dir);
} }
if(xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (component.isReport()) { if (component.isReport()) {
xElementCase = (XElementCase)component; xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0); UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) { if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout } // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); int minX = button.getX() + component.getX() + component.getParent().getX() - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); int minY = button.getY() + component.getY() + component.getParent().getY() + designer.getParaHeight() - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){ if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){ if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@ -292,84 +285,16 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
xElementCase.displayCoverPane(true); xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint(); designer.repaint();
return; } else {
if(xElementCase != null){
xElementCase.displayCoverPane(false);
designer.repaint();
}
} }
processChartEditorMouseMove(component, e);
designer.repaint();
}
private void setCoverPaneNotDisplay(){
if (xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (xChartEditor != null){
xChartEditor.displayCoverPane(false);
}
if (xTopLayoutContainer != null) {
xTopLayoutContainer.setMouseEnter(false);
}
designer.repaint();
}
private boolean processTopLayoutMouseMove(XCreator component, MouseEvent e){
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout();
if (parent != null){
xTopLayoutContainer = parent;
xTopLayoutContainer.setMouseEnter(true);
designer.repaint();
if(!xTopLayoutContainer.isEditable()) {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
if (e.getX() > (parent.getX() + parent.getWidth() / 2 - EDIT_BTN_WIDTH / 2 - GAP)
&& e.getX() < (parent.getX() + parent.getWidth() / 2 + EDIT_BTN_WIDTH / 2 + GAP)) {
if (e.getY() > (parent.getY() + parent.getHeight() / 2 - EDIT_BTN_HEIGHT / 2 - GAP)
&& e.getY() < (parent.getY() + parent.getHeight() / 2 + EDIT_BTN_HEIGHT / 2 + GAP + designer.getParaHeight())) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
return true;
}
}
return false;
}
private void processChartEditorMouseMove(XCreator component, MouseEvent e){
if (component instanceof XChartEditor) {
xChartEditor = (XChartEditor)component;
UIButton button = (UIButton)xChartEditor.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
xChartEditor.displayCoverPane(true);
xChartEditor.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint();
}
}
private int getParentPositionX(XCreator comp, int x){
return comp.getParent() == null ?
x : getParentPositionX((XCreator)comp.getParent(), comp.getParent().getX() + x);
}
private int getParentPositionY(XCreator comp, int y) {
return comp.getParent() == null ?
y : getParentPositionY((XCreator) comp.getParent(), comp.getParent().getY() + y);
} }
/** /**
* 拖拽 * 拖拽
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
@ -417,25 +342,6 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint(); designer.repaint();
} }
private XCreator processTopLayoutMouseClick(XCreator creator){
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if(topLayout != null){
if (clickTopLayout != null && clickTopLayout != topLayout){
clickTopLayout.setEditable(false);
}
clickTopLayout = topLayout;
if(!topLayout.isEditable()) {
creator = topLayout;
}
}
else{
if(clickTopLayout != null){
clickTopLayout.setEditable(false);
}
}
return creator;
}
/** /**
* 点击 * 点击
* @param e 鼠标事件 * @param e 鼠标事件
@ -445,9 +351,6 @@ public class EditingMouseListener extends MouseInputAdapter {
return; return;
} }
XCreator creator = designer.getComponentAt(e); XCreator creator = designer.getComponentAt(e);
creator = processTopLayoutMouseClick(creator);
if(creator != null){ if(creator != null){
creator.respondClick(this, e); creator.respondClick(this, e);
} }
@ -465,9 +368,10 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) { if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
designer.setCursor(Cursor.getDefaultCursor()); designer.setCursor(Cursor.getDefaultCursor());
} }
if (xElementCase != null){
setCoverPaneNotDisplay(); xElementCase.displayCoverPane(false);
designer.repaint();
}
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
} }

Loading…
Cancel
Save