Browse Source

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

* commit 'dff8443a0c8ca8f6df4e98999a768945fd487a5e':
  之前因为周三合master回退的,发布后再重新上传一下
master
superman 8 years ago
parent
commit
d1295f9c6b
  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. 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

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.painters.FRFitLayoutPainter;
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.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
@ -163,7 +164,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
return false;
}
//如果当前处于边缘地带, 那么就把他贴到父容器上
matchEdge(x, y);
boolean isMatchEdge = matchEdge(x, y);
int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth();
@ -171,7 +172,13 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
int upHeight = (int) (componentHeight * TOP_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)) {
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所在的组件
XCreator comp = designer.getComponentAt(e);
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if(topLayout != null && !topLayout.isEditable()){
comp = topLayout;
}
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
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;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChart;
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.MiddleChartComponent;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.module.DesignModuleFactory;
@ -41,6 +43,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false;
private boolean isEditing = false;
private JPanel coverPanel;
public XChartEditor(BaseChartEditor editor) {
this(editor, new Dimension(250, 150));
}
@ -142,17 +147,22 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}
});
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartWidgetPropertyPane(formDesigner);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (getDesignerEditor().getEditorTarget() != null) {
propertyPane.setSupportCellData(true);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
if (isEditing){
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (getDesignerEditor().getEditorTarget() != null) {
propertyPane.setSupportCellData(true);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
}
}
}
});
return (JComponent)propertyPane;
});
return (JComponent)propertyPane;
}
else{
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
}
private MiddleChartComponent getDesignerEditorTarget() {
@ -167,8 +177,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter
*/
public void paint(Graphics g) {
super.paint(g);
designerEditor.paintEditor(g, this.getSize());
super.paint(g);
}
/**
@ -180,6 +190,27 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
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
protected JComponent initEditor() {
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() {
setBackupParent(XCreatorUtils.getParentXLayoutContainer(this));
}
/**
* 获取当前布局控件的顶层布局框架如tab布局绝对布局
* @return 封装的顶层布局
*/
public XLayoutContainer getTopLayout(){
return null;
}
/**
* 获取当前XCreator的一个封装父容器

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

@ -41,6 +41,16 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
protected boolean isRefreshing;
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) {
super(widget, initSize);
this.addContainerListener(this);
@ -446,4 +456,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
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,6 +12,7 @@ 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.XButton;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
@ -149,6 +150,8 @@ public class XCardAddButton extends XButton{
XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout);
titleButton.setCustomStyle(true);
titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index);
@ -180,4 +183,9 @@ public class XCardAddButton extends XButton{
}
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();
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);
}
}
@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;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
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.XLayoutContainer;
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.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
/**
* card布局主体框架
@ -31,6 +37,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
private static final int LAYOUT_INDEX = 0;
private static final int TITLE_STYLE = 2;
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){
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.models.SelectionModel;
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.XWidgetCreator;
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.models.SelectionModel;
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.XWidgetCreator;
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) {
@ -362,4 +362,9 @@ public class XWTabFitLayout extends XWFitLayout {
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.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel;
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.designer.creator.*;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor;
@ -45,6 +40,10 @@ public class EditingMouseListener extends MouseInputAdapter {
* 普通模式下对应的model
*/
private StateModel stateModel;
private XLayoutContainer xTopLayoutContainer;
private XLayoutContainer clickTopLayout;
/**
* 获取表单设计器
@ -84,10 +83,14 @@ public class EditingMouseListener extends MouseInputAdapter {
private int minDragSize = 5;
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 XElementCase xElementCase;
private XChartEditor xChartEditor;
private JWindow promptWindow = new JWindow();
@ -244,6 +247,12 @@ public class EditingMouseListener extends MouseInputAdapter {
*/
public void mouseMoved(MouseEvent e) {
XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay();
if(processTopLayoutMouseMove(component, e)){
return;
}
if (component instanceof XEditorHolder) {
XEditorHolder xcreator = (XEditorHolder) component;
Rectangle rect = xcreator.getBounds();
@ -267,17 +276,15 @@ public class EditingMouseListener extends MouseInputAdapter {
if (!BaseUtils.isAuthorityEditing()) {
stateModel.setDirection(dir);
}
if(xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (component.isReport()) {
xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + component.getX() + component.getParent().getX() - designer.getArea().getHorizontalValue();
int minY = button.getY() + component.getY() + component.getParent().getY() + designer.getParaHeight() - designer.getArea().getVerticalValue();
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));
@ -285,16 +292,84 @@ public class EditingMouseListener extends MouseInputAdapter {
}
xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint();
} else {
if(xElementCase != null){
xElementCase.displayCoverPane(false);
designer.repaint();
}
return;
}
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 鼠标事件
*/
@ -342,6 +417,25 @@ public class EditingMouseListener extends MouseInputAdapter {
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 鼠标事件
@ -351,6 +445,9 @@ public class EditingMouseListener extends MouseInputAdapter {
return;
}
XCreator creator = designer.getComponentAt(e);
creator = processTopLayoutMouseClick(creator);
if(creator != null){
creator.respondClick(this, e);
}
@ -368,10 +465,9 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
designer.setCursor(Cursor.getDefaultCursor());
}
if (xElementCase != null){
xElementCase.displayCoverPane(false);
designer.repaint();
}
setCoverPaneNotDisplay();
cancelPromptWidgetForbidEnter();
}

Loading…
Cancel
Save