|
|
@ -1,7 +1,6 @@ |
|
|
|
package com.fr.design.mainframe; |
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.design.beans.location.MoveUtils; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
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.events.DesignerEditor; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEditor; |
|
|
@ -31,7 +30,6 @@ import java.awt.event.MouseEvent; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
private static final int INDEX = 0; |
|
|
|
|
|
|
|
private FormDesigner designer; |
|
|
|
private FormDesigner designer; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -56,6 +54,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
* 选择模型,存储当前选择的组件和剪切板 |
|
|
|
* 选择模型,存储当前选择的组件和剪切板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private SelectionModel selectionModel; |
|
|
|
private SelectionModel selectionModel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取选择模型 |
|
|
|
* 获取选择模型 |
|
|
|
* |
|
|
|
* |
|
|
@ -65,10 +64,10 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
return selectionModel; |
|
|
|
return selectionModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private XCreator last_creator; |
|
|
|
private XCreator lastXCreator; |
|
|
|
private MouseEvent lastPressEvent; |
|
|
|
private MouseEvent lastPressEvent; |
|
|
|
private DesignerEditor<? extends JComponent> current_editor; |
|
|
|
private DesignerEditor<? extends JComponent> currentEditor; |
|
|
|
private XCreator current_creator; |
|
|
|
private XCreator currentXCreator; |
|
|
|
|
|
|
|
|
|
|
|
//备份开始拖动的位置和大小
|
|
|
|
//备份开始拖动的位置和大小
|
|
|
|
private Rectangle dragBackupBounds; |
|
|
|
private Rectangle dragBackupBounds; |
|
|
@ -103,25 +102,25 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
this.promptWindow.add(promptButton); |
|
|
|
this.promptWindow.add(promptButton); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void promptUser(int x, int y, XLayoutContainer container){ |
|
|
|
private void promptUser(int x, int y, XLayoutContainer container) { |
|
|
|
if (!selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)){ |
|
|
|
if (!selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)) { |
|
|
|
promptWidgetForbidEnter(x ,y , container); |
|
|
|
promptWidgetForbidEnter(x, y, container); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
cancelPromptWidgetForbidEnter(); |
|
|
|
cancelPromptWidgetForbidEnter(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void promptWidgetForbidEnter(int x,int y, XLayoutContainer container){ |
|
|
|
private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) { |
|
|
|
container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM)); |
|
|
|
container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM)); |
|
|
|
int screen_X = (int)designer.getArea().getLocationOnScreen().getX(); |
|
|
|
int screenX = (int) designer.getArea().getLocationOnScreen().getX(); |
|
|
|
int screen_Y = (int)designer.getArea().getLocationOnScreen().getY(); |
|
|
|
int screenY = (int) designer.getArea().getLocationOnScreen().getY(); |
|
|
|
this.promptWindow.setSize(promptWindow.getPreferredSize()); |
|
|
|
this.promptWindow.setSize(promptWindow.getPreferredSize()); |
|
|
|
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize()); |
|
|
|
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize()); |
|
|
|
promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP); |
|
|
|
promptWindow.setLocation(screenX + x + GAP, screenY + y + GAP); |
|
|
|
promptWindow.setVisible(true); |
|
|
|
promptWindow.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void cancelPromptWidgetForbidEnter(){ |
|
|
|
private void cancelPromptWidgetForbidEnter() { |
|
|
|
designer.getRootComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN)); |
|
|
|
designer.getRootComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN)); |
|
|
|
promptWindow.setVisible(false); |
|
|
|
promptWindow.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -129,6 +128,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 按下 |
|
|
|
* 按下 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
@ -139,9 +139,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
// 获取焦点,以便获取热键
|
|
|
|
// 获取焦点,以便获取热键
|
|
|
|
designer.requestFocus(); |
|
|
|
designer.requestFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (e.isPopupTrigger()) { |
|
|
|
if (e.getButton() == MouseEvent.BUTTON1) { |
|
|
|
// 为触发上下文菜单预留
|
|
|
|
|
|
|
|
} else if (e.getButton() == MouseEvent.BUTTON1) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Direction dir = selectionModel.getDirectionAt(e); |
|
|
|
Direction dir = selectionModel.getDirectionAt(e); |
|
|
|
if (!BaseUtils.isAuthorityEditing()) { |
|
|
|
if (!BaseUtils.isAuthorityEditing()) { |
|
|
@ -157,7 +155,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
designer.getArea().getHorizontalValue() + e.getX(), |
|
|
|
designer.getArea().getHorizontalValue() + e.getX(), |
|
|
|
designer.getArea().getVerticalValue() + e.getY())) { |
|
|
|
designer.getArea().getVerticalValue() + e.getY())) { |
|
|
|
lastPressEvent = e; |
|
|
|
lastPressEvent = e; |
|
|
|
last_creator = selectionModel.getSelection().getSelectedCreator(); |
|
|
|
lastXCreator = selectionModel.getSelection().getSelectedCreator(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
stateModel.startSelecting(e); |
|
|
|
stateModel.startSelecting(e); |
|
|
|
} |
|
|
|
} |
|
|
@ -170,6 +168,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 释放 |
|
|
|
* 释放 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
@ -192,17 +191,16 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
lastPressEvent = null; |
|
|
|
lastPressEvent = null; |
|
|
|
last_creator = null; |
|
|
|
lastXCreator = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void mouseDraggingRelease(MouseEvent e) { |
|
|
|
private void mouseDraggingRelease(MouseEvent e) { |
|
|
|
// 当前鼠标所在的组件
|
|
|
|
// 当前鼠标所在的组件
|
|
|
|
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); |
|
|
|
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); |
|
|
|
if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){ |
|
|
|
if (designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null) { |
|
|
|
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
if(selectionXCreator != null){ |
|
|
|
if (selectionXCreator != null) { |
|
|
|
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height); |
|
|
|
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height); |
|
|
|
// MoveUtils.hideForbidWindow();
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
dragBackupBounds = null; |
|
|
|
dragBackupBounds = null; |
|
|
@ -219,7 +217,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
if (container != null) { |
|
|
|
if (container != null) { |
|
|
|
boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() |
|
|
|
boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() |
|
|
|
&& container.acceptType(XWFitLayout.class); |
|
|
|
&& container.acceptType(XWFitLayout.class); |
|
|
|
if ( !formSubmit2Adapt) { |
|
|
|
if (!formSubmit2Adapt) { |
|
|
|
// 如果是处于拖拽状态,则释放组件
|
|
|
|
// 如果是处于拖拽状态,则释放组件
|
|
|
|
stateModel.releaseDragging(e); |
|
|
|
stateModel.releaseDragging(e); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -231,17 +229,14 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 激活上下文菜单,待完善 |
|
|
|
* TODO 激活上下文菜单,待完善 |
|
|
|
* 6.56暂时不支持右键 bugid 8777 |
|
|
|
* 6.56暂时不支持右键 bugid 8777 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void trigger_popup(MouseEvent e) { |
|
|
|
private void triggerPopup(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
|
|
|
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
|
|
|
|
|
|
|
|
|
|
|
if (creator == null) { |
|
|
|
if (creator == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JPopupMenu popupMenu = null; |
|
|
|
JPopupMenu popupMenu = null; |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, creator); |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, creator); |
|
|
|
popupMenu = adapter.getContextPopupMenu(e); |
|
|
|
popupMenu = adapter.getContextPopupMenu(e); |
|
|
@ -255,6 +250,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 移动 |
|
|
|
* 移动 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
@ -262,7 +258,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
setCoverPaneNotDisplay(e, false); |
|
|
|
setCoverPaneNotDisplay(e, false); |
|
|
|
|
|
|
|
|
|
|
|
if(processTopLayoutMouseMove(component, e)){ |
|
|
|
if (processTopLayoutMouseMove(component, e)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (component instanceof XEditorHolder) { |
|
|
|
if (component instanceof XEditorHolder) { |
|
|
@ -301,9 +297,9 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void elementCaseMouseMoved(MouseEvent e, XCreator component) { |
|
|
|
private void elementCaseMouseMoved(MouseEvent e, XCreator component) { |
|
|
|
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() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); |
|
|
@ -337,12 +333,12 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
if (rect.contains(e.getPoint())) { |
|
|
|
if (rect.contains(e.getPoint())) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(isLinkedHelpDialog){ |
|
|
|
if (isLinkedHelpDialog) { |
|
|
|
xElementCase.destroyHelpDialog(); |
|
|
|
xElementCase.destroyHelpDialog(); |
|
|
|
} |
|
|
|
} |
|
|
|
xElementCase.displayCoverPane(false); |
|
|
|
xElementCase.displayCoverPane(false); |
|
|
|
} |
|
|
|
} |
|
|
|
if (xChartEditor != null){ |
|
|
|
if (xChartEditor != null) { |
|
|
|
xChartEditor.displayCoverPane(false); |
|
|
|
xChartEditor.displayCoverPane(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -352,13 +348,13 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
designer.repaint(); |
|
|
|
designer.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean processTopLayoutMouseMove(XCreator component, MouseEvent e){ |
|
|
|
private boolean processTopLayoutMouseMove(XCreator component, MouseEvent e) { |
|
|
|
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout(); |
|
|
|
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout(); |
|
|
|
if (parent != null){ |
|
|
|
if (parent != null) { |
|
|
|
xTopLayoutContainer = parent; |
|
|
|
xTopLayoutContainer = parent; |
|
|
|
xTopLayoutContainer.setMouseEnter(true); |
|
|
|
xTopLayoutContainer.setMouseEnter(true); |
|
|
|
designer.repaint(); |
|
|
|
designer.repaint(); |
|
|
|
if(!xTopLayoutContainer.isEditable()) { |
|
|
|
if (!xTopLayoutContainer.isEditable()) { |
|
|
|
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)); |
|
|
|
} |
|
|
|
} |
|
|
@ -377,17 +373,17 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void processChartEditorMouseMove(XCreator component, MouseEvent e){ |
|
|
|
private void processChartEditorMouseMove(XCreator component, MouseEvent e) { |
|
|
|
if (component instanceof XChartEditor) { |
|
|
|
if (component instanceof XChartEditor) { |
|
|
|
xChartEditor = (XChartEditor)component; |
|
|
|
xChartEditor = (XChartEditor) component; |
|
|
|
UIButton button = (UIButton)xChartEditor.getCoverPane().getComponent(0); |
|
|
|
UIButton button = (UIButton) xChartEditor.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)); |
|
|
|
} |
|
|
|
} |
|
|
|
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); |
|
|
|
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); |
|
|
|
int minY = button.getY() + getParentPositionY(component, 0) - 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)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -397,9 +393,9 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int getParentPositionX(XCreator comp, int x){ |
|
|
|
private int getParentPositionX(XCreator comp, int x) { |
|
|
|
return comp.getParent() == null ? |
|
|
|
return comp.getParent() == null ? |
|
|
|
x : getParentPositionX((XCreator)comp.getParent(), comp.getParent().getX() + x); |
|
|
|
x : getParentPositionX((XCreator) comp.getParent(), comp.getParent().getX() + x); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int getParentPositionY(XCreator comp, int y) { |
|
|
|
private int getParentPositionY(XCreator comp, int y) { |
|
|
@ -409,6 +405,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 拖拽 |
|
|
|
* 拖拽 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
@ -423,9 +420,9 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
stateModel.dragging(e); |
|
|
|
stateModel.dragging(e); |
|
|
|
// 获取e所在的焦点组件
|
|
|
|
// 获取e所在的焦点组件
|
|
|
|
XCreator hotspot = designer.getComponentAt(e.getX(), e.getY()); |
|
|
|
XCreator hotspot = designer.getComponentAt(e.getX(), e.getY()); |
|
|
|
if(dragBackupBounds == null) { |
|
|
|
if (dragBackupBounds == null) { |
|
|
|
XCreator selectingXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
XCreator selectingXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
if(selectingXCreator != null){ |
|
|
|
if (selectingXCreator != null) { |
|
|
|
dragBackupBounds = new Rectangle(selectingXCreator.getX(), selectingXCreator.getY(), selectingXCreator.getWidth(), selectingXCreator.getHeight()); |
|
|
|
dragBackupBounds = new Rectangle(selectingXCreator.getX(), selectingXCreator.getY(), selectingXCreator.getWidth(), selectingXCreator.getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -446,13 +443,13 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
// 如果是拖拽选择区域状态,则更新选择区域
|
|
|
|
// 如果是拖拽选择区域状态,则更新选择区域
|
|
|
|
stateModel.changeSelection(e); |
|
|
|
stateModel.changeSelection(e); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if ((lastPressEvent == null) || (last_creator == null)) { |
|
|
|
if ((lastPressEvent == null) || (lastXCreator == null)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (e.getPoint().distance(lastPressEvent.getPoint()) > minDragSize) { |
|
|
|
if (e.getPoint().distance(lastPressEvent.getPoint()) > minDragSize) { |
|
|
|
//参数面板和自适应布局不支持拖拽
|
|
|
|
//参数面板和自适应布局不支持拖拽
|
|
|
|
if (last_creator.isSupportDrag()){ |
|
|
|
if (lastXCreator.isSupportDrag()) { |
|
|
|
designer.startDraggingComponent(last_creator, lastPressEvent, e.getX(), e.getY()); |
|
|
|
designer.startDraggingComponent(lastXCreator, lastPressEvent, e.getX(), e.getY()); |
|
|
|
} |
|
|
|
} |
|
|
|
e.consume(); |
|
|
|
e.consume(); |
|
|
|
lastPressEvent = null; |
|
|
|
lastPressEvent = null; |
|
|
@ -462,50 +459,50 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//当前编辑的组件是在布局中,鼠标点击布局外部,需要一次性将布局及其父布局都置为不可编辑
|
|
|
|
//当前编辑的组件是在布局中,鼠标点击布局外部,需要一次性将布局及其父布局都置为不可编辑
|
|
|
|
private void setTopLayoutUnEditable(XLayoutContainer clickedTopLayout, XLayoutContainer clickingTopLayout){ |
|
|
|
private void setTopLayoutUnEditable(XLayoutContainer clickedTopLayout, XLayoutContainer clickingTopLayout) { |
|
|
|
//双击的前后点击click为相同对象,过滤掉
|
|
|
|
//双击的前后点击click为相同对象,过滤掉
|
|
|
|
if (clickedTopLayout == null || clickedTopLayout == clickingTopLayout){ |
|
|
|
if (clickedTopLayout == null || clickedTopLayout == clickingTopLayout) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//位于同一层级的控件,父布局相同,过滤掉
|
|
|
|
//位于同一层级的控件,父布局相同,过滤掉
|
|
|
|
if (clickingTopLayout != null && clickedTopLayout.getParent() == clickingTopLayout.getParent()){ |
|
|
|
if (clickingTopLayout != null && clickedTopLayout.getParent() == clickingTopLayout.getParent()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//前后点击的位于不同层级,要置为不可编辑
|
|
|
|
//前后点击的位于不同层级,要置为不可编辑
|
|
|
|
XLayoutContainer xLayoutContainer = (XLayoutContainer)clickedTopLayout.getParent(); |
|
|
|
XLayoutContainer xLayoutContainer = (XLayoutContainer) clickedTopLayout.getParent(); |
|
|
|
if (xLayoutContainer == clickingTopLayout){ |
|
|
|
if (xLayoutContainer == clickingTopLayout) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (xLayoutContainer != null){ |
|
|
|
if (xLayoutContainer != null) { |
|
|
|
xLayoutContainer.setEditable(false); |
|
|
|
xLayoutContainer.setEditable(false); |
|
|
|
setTopLayoutUnEditable((XLayoutContainer) clickedTopLayout.getParent(), clickingTopLayout); |
|
|
|
setTopLayoutUnEditable((XLayoutContainer) clickedTopLayout.getParent(), clickingTopLayout); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isCreatorInLayout(XCreator creator, XCreator layout){ |
|
|
|
private boolean isCreatorInLayout(XCreator creator, XCreator layout) { |
|
|
|
if (creator == layout){ |
|
|
|
if (creator.equals(layout)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
if(layout.getParent() != null){ |
|
|
|
if (layout.getParent() != null) { |
|
|
|
return isCreatorInLayout(creator, (XCreator)layout.getParent()); |
|
|
|
return isCreatorInLayout(creator, (XCreator) layout.getParent()); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private XCreator processTopLayoutMouseClick(XCreator creator){ |
|
|
|
private XCreator processTopLayoutMouseClick(XCreator creator) { |
|
|
|
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout(); |
|
|
|
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout(); |
|
|
|
if(topLayout != null){ |
|
|
|
if (topLayout != null) { |
|
|
|
if (clickTopLayout != null && clickTopLayout != topLayout && !isCreatorInLayout(clickTopLayout, topLayout)){ |
|
|
|
if (clickTopLayout != null && !clickTopLayout.equals(topLayout) && !isCreatorInLayout(clickTopLayout, |
|
|
|
|
|
|
|
topLayout)) { |
|
|
|
clickTopLayout.setEditable(false); |
|
|
|
clickTopLayout.setEditable(false); |
|
|
|
setTopLayoutUnEditable(clickTopLayout, topLayout); |
|
|
|
setTopLayoutUnEditable(clickTopLayout, topLayout); |
|
|
|
} |
|
|
|
} |
|
|
|
clickTopLayout = topLayout; |
|
|
|
clickTopLayout = topLayout; |
|
|
|
if(!topLayout.isEditable()) { |
|
|
|
if (!topLayout.isEditable()) { |
|
|
|
creator = topLayout; |
|
|
|
creator = topLayout; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
if (clickTopLayout != null) { |
|
|
|
if(clickTopLayout != null){ |
|
|
|
|
|
|
|
clickTopLayout.setEditable(false); |
|
|
|
clickTopLayout.setEditable(false); |
|
|
|
setTopLayoutUnEditable(clickTopLayout, null); |
|
|
|
setTopLayoutUnEditable(clickTopLayout, null); |
|
|
|
} |
|
|
|
} |
|
|
@ -513,8 +510,10 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
return creator; |
|
|
|
return creator; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 点击 |
|
|
|
* 点击 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
@ -526,7 +525,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
creator = processTopLayoutMouseClick(creator); |
|
|
|
creator = processTopLayoutMouseClick(creator); |
|
|
|
|
|
|
|
|
|
|
|
if(creator != null){ |
|
|
|
if (creator != null) { |
|
|
|
creator.respondClick(this, e); |
|
|
|
creator.respondClick(this, e); |
|
|
|
} |
|
|
|
} |
|
|
|
creator.doLayout(); |
|
|
|
creator.doLayout(); |
|
|
@ -534,9 +533,9 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 离开 |
|
|
|
* 离开 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
@ -551,6 +550,7 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 开始编辑 |
|
|
|
* 开始编辑 |
|
|
|
|
|
|
|
* |
|
|
|
* @param creator 容器 |
|
|
|
* @param creator 容器 |
|
|
|
* @param designerEditor 设计器 |
|
|
|
* @param designerEditor 设计器 |
|
|
|
* @param adapter 适配器 |
|
|
|
* @param adapter 适配器 |
|
|
@ -558,8 +558,8 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
public void startEditing(XCreator creator, DesignerEditor<? extends JComponent> designerEditor, ComponentAdapter adapter) { |
|
|
|
public void startEditing(XCreator creator, DesignerEditor<? extends JComponent> designerEditor, ComponentAdapter adapter) { |
|
|
|
if (designerEditor != null) { |
|
|
|
if (designerEditor != null) { |
|
|
|
Rectangle rect = ComponentUtils.getRelativeBounds(creator); |
|
|
|
Rectangle rect = ComponentUtils.getRelativeBounds(creator); |
|
|
|
current_editor = designerEditor; |
|
|
|
currentEditor = designerEditor; |
|
|
|
current_creator = creator; |
|
|
|
currentXCreator = creator; |
|
|
|
Rectangle bounds = new Rectangle(1, 1, creator.getWidth() - 2, creator.getHeight() - 2); |
|
|
|
Rectangle bounds = new Rectangle(1, 1, creator.getWidth() - 2, creator.getHeight() - 2); |
|
|
|
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); |
|
|
|
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); |
|
|
|
bounds.y += (rect.y - designer.getArea().getVerticalValue()); |
|
|
|
bounds.y += (rect.y - designer.getArea().getVerticalValue()); |
|
|
@ -574,22 +574,23 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 停止编辑 |
|
|
|
* 停止编辑 |
|
|
|
|
|
|
|
* |
|
|
|
* @return 是否编辑成功 |
|
|
|
* @return 是否编辑成功 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean stopEditing() { |
|
|
|
public boolean stopEditing() { |
|
|
|
if (current_editor != null) { |
|
|
|
if (currentEditor != null) { |
|
|
|
designer.remove(current_editor.getEditorTarget()); |
|
|
|
designer.remove(currentEditor.getEditorTarget()); |
|
|
|
current_editor.fireEditStoped(); |
|
|
|
currentEditor.fireEditStoped(); |
|
|
|
|
|
|
|
|
|
|
|
Container container = current_creator.getParent(); |
|
|
|
Container container = currentXCreator.getParent(); |
|
|
|
|
|
|
|
|
|
|
|
if (container != null) { |
|
|
|
if (container != null) { |
|
|
|
LayoutUtils.layoutRootContainer(container); |
|
|
|
LayoutUtils.layoutRootContainer(container); |
|
|
|
} |
|
|
|
} |
|
|
|
designer.invalidate(); |
|
|
|
designer.invalidate(); |
|
|
|
designer.repaint(); |
|
|
|
designer.repaint(); |
|
|
|
current_creator = null; |
|
|
|
currentXCreator = null; |
|
|
|
current_editor = null; |
|
|
|
currentEditor = null; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -599,22 +600,22 @@ public class EditingMouseListener extends MouseInputAdapter { |
|
|
|
* 重置编辑控件大小 |
|
|
|
* 重置编辑控件大小 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void resetEditorComponentBounds() { |
|
|
|
public void resetEditorComponentBounds() { |
|
|
|
if (current_editor == null) { |
|
|
|
if (currentEditor == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (current_creator.getParent() == null) { |
|
|
|
if (currentXCreator.getParent() == null) { |
|
|
|
stopEditing(); |
|
|
|
stopEditing(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Rectangle rect = ComponentUtils.getRelativeBounds(current_creator); |
|
|
|
Rectangle rect = ComponentUtils.getRelativeBounds(currentXCreator); |
|
|
|
Rectangle bounds = new Rectangle(1, 1, current_creator.getWidth() - 2, current_creator.getHeight() - 2); |
|
|
|
Rectangle bounds = new Rectangle(1, 1, currentXCreator.getWidth() - 2, currentXCreator.getHeight() - 2); |
|
|
|
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); |
|
|
|
bounds.x += (rect.x - designer.getArea().getHorizontalValue()); |
|
|
|
bounds.y += (rect.y - designer.getArea().getVerticalValue()); |
|
|
|
bounds.y += (rect.y - designer.getArea().getVerticalValue()); |
|
|
|
if (current_creator instanceof XEditorHolder) { |
|
|
|
if (currentXCreator instanceof XEditorHolder) { |
|
|
|
ToolTipEditor.getInstance().resetBounds((XEditorHolder) current_creator, bounds, current_editor.getEditorTarget().getBounds()); |
|
|
|
ToolTipEditor.getInstance().resetBounds((XEditorHolder) currentXCreator, bounds, currentEditor.getEditorTarget().getBounds()); |
|
|
|
} |
|
|
|
} |
|
|
|
current_editor.getEditorTarget().setBounds(bounds); |
|
|
|
currentEditor.getEditorTarget().setBounds(bounds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |