|
|
|
@ -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; |
|
|
|
@ -46,6 +41,10 @@ public class EditingMouseListener extends MouseInputAdapter {
|
|
|
|
|
*/ |
|
|
|
|
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,14 +292,82 @@ public class EditingMouseListener extends MouseInputAdapter {
|
|
|
|
|
} |
|
|
|
|
xElementCase.displayCoverPane(true); |
|
|
|
|
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); |
|
|
|
|
|
|
|
|
|
designer.repaint(); |
|
|
|
|
} else { |
|
|
|
|
if(xElementCase != null){ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 拖拽 |
|
|
|
@ -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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|