Browse Source

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

* commit '858ee92d4c8904edd5961cb3d83462baa9ea2d47':
  表单交互统一 1.图表控件加上编辑层 2.tab组件加上编辑层
master
superman 9 years ago
parent
commit
2c844afe45
  1. 11
      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. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  6. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  7. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  8. 91
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  9. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  10. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  11. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  12. 138
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

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

@ -14,6 +14,7 @@ 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;
@ -163,7 +164,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
return false; return false;
} }
//如果当前处于边缘地带, 那么就把他贴到父容器上 //如果当前处于边缘地带, 那么就把他贴到父容器上
matchEdge(x, y); boolean isMatchEdge = matchEdge(x, y);
int componentHeight = comp.getHeight(); int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth(); int componentWidth = comp.getWidth();
@ -171,7 +172,13 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY();
//下半部分高度 //下半部分高度
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,6 +66,13 @@ 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,20 +1,22 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Color; import java.awt.*;
import java.awt.Dimension; import java.awt.event.MouseEvent;
import java.awt.Graphics; import java.awt.image.BufferedImage;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import javax.swing.BorderFactory; import javax.swing.*;
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.mainframe.BaseJForm; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.*;
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;
@ -41,6 +43,9 @@ 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));
} }
@ -142,17 +147,22 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
} }
}); });
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartWidgetPropertyPane(formDesigner); if (isEditing){
SwingUtilities.invokeLater(new Runnable() { final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane();
@Override SwingUtilities.invokeLater(new Runnable() {
public void run() { @Override
if (getDesignerEditor().getEditorTarget() != null) { public void run() {
propertyPane.setSupportCellData(true); if (getDesignerEditor().getEditorTarget() != null) {
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner); propertyPane.setSupportCellData(true);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
}
} }
} });
}); return (JComponent)propertyPane;
return (JComponent)propertyPane; }
else{
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
} }
private MiddleChartComponent getDesignerEditorTarget() { private MiddleChartComponent getDesignerEditorTarget() {
@ -167,8 +177,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter * 渲染Painter
*/ */
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g);
designerEditor.paintEditor(g, this.getSize()); designerEditor.paintEditor(g, this.getSize());
super.paint(g);
} }
/** /**
@ -180,6 +190,27 @@ 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) {
@ -198,6 +229,36 @@ 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

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

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

@ -12,6 +12,7 @@ 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;
@ -149,6 +150,8 @@ 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);
@ -180,4 +183,9 @@ 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

@ -292,5 +292,10 @@ public class XCardSwitchButton extends XButton {
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
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,4 +367,9 @@ 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,18 +3,24 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.Color; import java.awt.*;
import java.awt.Component; import java.awt.event.MouseEvent;
import java.awt.Dimension; import java.awt.image.BufferedImage;
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布局主体框架
@ -31,6 +37,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
private static final int LAYOUT_INDEX = 0; private static final int LAYOUT_INDEX = 0;
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;
/** /**
* 构造函数 * 构造函数
@ -124,7 +133,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
/** /**
* 重新调整子组件的宽度 * 重新调整子组件的宽度
* @param 宽度 * @param width 宽度
*/ */
public void recalculateChildWidth(int width){ public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList(); ArrayList<?> childrenList = this.getTargetChildrenList();
@ -188,4 +197,72 @@ 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,6 +13,7 @@ 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;
@ -214,4 +215,9 @@ 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,6 +12,7 @@ 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;
@ -146,4 +147,9 @@ 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 边框 * @param border 边框
* *
*/ */
public void setBorder(Border border) { public void setBorder(Border border) {
@ -362,4 +362,9 @@ 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,12 +18,7 @@ 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.XCreator; import com.fr.design.designer.creator.*;
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;
@ -45,6 +40,10 @@ public class EditingMouseListener extends MouseInputAdapter {
* 普通模式下对应的model * 普通模式下对应的model
*/ */
private StateModel stateModel; private StateModel stateModel;
private XLayoutContainer xTopLayoutContainer;
private XLayoutContainer clickTopLayout;
/** /**
* 获取表单设计器 * 获取表单设计器
@ -84,10 +83,14 @@ 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();
@ -244,6 +247,12 @@ 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();
@ -267,17 +276,15 @@ 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() + component.getX() + component.getParent().getX() - designer.getArea().getHorizontalValue(); int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + component.getY() + component.getParent().getY() + designer.getParaHeight() - designer.getArea().getVerticalValue(); int minY = button.getY() + getParentPositionY(component, 0) - 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));
@ -285,16 +292,84 @@ 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();
} else { return;
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 鼠标事件
*/ */
@ -342,6 +417,25 @@ 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 鼠标事件
@ -351,6 +445,9 @@ 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);
} }
@ -368,10 +465,9 @@ 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){
xElementCase.displayCoverPane(false); setCoverPaneNotDisplay();
designer.repaint();
}
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
} }

Loading…
Cancel
Save