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