From b0d98eaf8ca0f4eb06eaf14773494006c3a1e97d Mon Sep 17 00:00:00 2001 From: zhouping Date: Fri, 10 Feb 2017 12:11:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-1814=20=E8=A1=A8=E5=8D=95tab?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E6=94=B9=E8=89=AFbug=20tab=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E6=94=B9=E8=89=AF=EF=BC=8C=E9=A1=B5=E7=AD=BE=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/locale/designer.properties | 6 +- .../design/locale/designer_en_US.properties | 4 + .../design/locale/designer_ja_JP.properties | 4 + .../design/locale/designer_ko_KR.properties | 6 +- .../design/locale/designer_zh_CN.properties | 4 + .../design/locale/designer_zh_TW.properties | 4 + .../cardlayout/TabMoveCustomAction.java | 32 ++++++++ .../creator/cardlayout/TabMoveEndAction.java | 66 ++++++++++++++++ .../cardlayout/TabMoveFirstAction.java | 65 ++++++++++++++++ .../creator/cardlayout/TabMoveNextAction.java | 64 +++++++++++++++ .../creator/cardlayout/TabMovePrevAction.java | 64 +++++++++++++++ .../creator/cardlayout/XCardAddButton.java | 8 +- .../creator/cardlayout/XCardSwitchButton.java | 78 ++++++++++++------- .../creator/cardlayout/XWCardLayout.java | 14 ++-- .../creator/cardlayout/XWCardTagLayout.java | 14 ++++ .../mainframe/EditingMouseListener.java | 3 - 16 files changed, 395 insertions(+), 41 deletions(-) create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 3f809fb4a..cee4fc345 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -538,4 +538,8 @@ FR-Designer_Allow_Blank=Allow Blank FR-Designer_PageSetup_Page=Page FR-Designer_Custom_Job_Description=Description FR-Designer_Property=Property -FR-Designer_ClassName=Class Name \ No newline at end of file +FR-Designer_ClassName=Class Name +FR-Designer-Move_Tab_First=move to first +FR-Designer-Move_Tab_End=move to end +FR-Designer-Move_Tab_Next=move to next +FR-Designer-Move_Tab_Prev=move to previous \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 30db869a2..c06215bc6 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -539,3 +539,7 @@ FR-Designer_PageSetup_Page=Page FR-Designer_Custom_Job_Description=Description FR-Designer_Property=Property FR-Designer_ClassName=Class Name +FR-Designer-Move_Tab_First=move to first +FR-Designer-Move_Tab_End=move to end +FR-Designer-Move_Tab_Next=move to next +FR-Designer-Move_Tab_Prev=move to previous diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index ba6114955..c2fb91f25 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -518,3 +518,7 @@ FR-Designer_PageSetup_Page=\u30DA\u30FC\u30B8 FR-Designer_Custom_Job_Description=\u8A18\u8FF0 FR-Designer_Property=\u5C5E\u6027 FR-Designer_ClassName=\u985E\u540D +FR-Designer-Move_Tab_First= +FR-Designer-Move_Tab_End= +FR-Designer-Move_Tab_Next= +FR-Designer-Move_Tab_Prev= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 9d540cd01..03d1a11f4 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -512,4 +512,8 @@ FR-Designer_Allow_Blank=\uBE48\uCE78\uD5C8\uC6A9 FR-Designer_PageSetup_Page=\uC6F9\uD398\uC774\uC9C0 FR-Designer_Custom_Job_Description=\uC124\uBA85 FR-Designer_Property=\uC18D\uC131 -FR-Designer_ClassName=\uD074\uB798\uC2A4\uB124\uC784 \ No newline at end of file +FR-Designer_ClassName=\uD074\uB798\uC2A4\uB124\uC784 +FR-Designer-Move_Tab_First= +FR-Designer-Move_Tab_End= +FR-Designer-Move_Tab_Next= +FR-Designer-Move_Tab_Prev= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 54f0ac177..6fdea224d 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -543,4 +543,8 @@ FR-Designer_PageSetup_Page=\u9875\u9762 FR-Designer_Custom_Job_Description=\u63CF\u8FF0 FR-Designer_Property=\u5C5E\u6027 FR-Designer_ClassName=\u7C7B\u540D +FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D +FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E +FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8 +FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 271150729..c47170e57 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -531,3 +531,7 @@ FR-Designer_PageSetup_Page=\u9801\u9762 FR-Designer_Custom_Job_Description=\u63CF\u8FF0 FR-Designer_Property=\u5C6C\u6027 FR-Designer_ClassName=\u985E\u540D +FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D +FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E +FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5 +FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5 diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java new file mode 100644 index 000000000..93a62287e --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java @@ -0,0 +1,32 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.FormUndoableAction; +import com.fr.design.mainframe.FormDesigner; + +/** + * Created by zhouping on 2017/2/9. + */ +public class TabMoveCustomAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMoveCustomAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.setName(""); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + return false; + } + + public XCardSwitchButton getxCardSwitchButton() { + return xCardSwitchButton; + } + + public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { + this.xCardSwitchButton = xCardSwitchButton; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java new file mode 100644 index 000000000..ae101dbe4 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java @@ -0,0 +1,66 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.FormUndoableAction; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.FRLogger; +import com.fr.general.Inter; + +/** + * Created by zhouping on 2017/2/9. + */ +public class TabMoveEndAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMoveEndAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.setName(Inter.getLocText("FR-Designer-Move_Tab_End")); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/rightright.png")); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout(); + XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout(); + CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData(); + try { + int currentIndex = currentButton.getIndex(); + int maxIndex = xwCardTagLayout.getComponentCount(); + XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex); + WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData(); + xwCardTagLayout.setSwitchingTab(true); + //修改当前tab往后所有tab的索引号 + for (int i = currentIndex + 1; i < maxIndex; i++) { + CardSwitchButton tempBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(i).toData(); + tempBtn.setIndex(i - 1); + WTabFitLayout tempTab = (WTabFitLayout) xwCardLayout.getXCreator(i).toData(); + tempTab.setIndex(i - 1); + tempTab.setTabNameIndex(i - 1); + } + xwCardTagLayout.remove(xCardSwitchButton); + xwCardTagLayout.add(xCardSwitchButton); + xwCardLayout.remove(xCurrentTab); + xwCardLayout.add(xCurrentTab); + currentButton.setIndex(maxIndex - 1); + currentTab.setIndex(maxIndex - 1); + currentTab.setTabNameIndex(maxIndex - 1); + xwCardTagLayout.setSwitchingTab(false); + }catch (Exception e){ + xwCardTagLayout.setSwitchingTab(false); + FRLogger.getLogger().error(e.getMessage()); + return false; + } + return true; + } + + public XCardSwitchButton getxCardSwitchButton() { + return xCardSwitchButton; + } + + public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { + this.xCardSwitchButton = xCardSwitchButton; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java new file mode 100644 index 000000000..0d6047636 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java @@ -0,0 +1,65 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.FormUndoableAction; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.FRLogger; +import com.fr.general.Inter; + +/** + * Created by zhouping on 2017/2/9. + */ +public class TabMoveFirstAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMoveFirstAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.setName(Inter.getLocText("FR-Designer-Move_Tab_First")); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/leftleft.png")); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout(); + XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout(); + CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData(); + try { + int currentIndex = currentButton.getIndex(); + XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex); + WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData(); + xwCardTagLayout.setSwitchingTab(true); + //修改当前tab往前所有tab的索引号 + for (int i = currentIndex - 1; i >= 0; i--) { + CardSwitchButton tempBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(i).toData(); + tempBtn.setIndex(i + 1); + WTabFitLayout tempTab = (WTabFitLayout) xwCardLayout.getXCreator(i).toData(); + tempTab.setIndex(i + 1); + tempTab.setTabNameIndex(i + 1); + } + xwCardTagLayout.remove(xCardSwitchButton); + xwCardTagLayout.add(xCardSwitchButton, 0); + xwCardLayout.remove(xCurrentTab); + xwCardLayout.add(xCurrentTab, 0); + currentButton.setIndex(0); + currentTab.setIndex(0); + currentTab.setTabNameIndex(0); + xwCardTagLayout.setSwitchingTab(false); + }catch (Exception e){ + xwCardTagLayout.setSwitchingTab(false); + FRLogger.getLogger().error(e.getMessage()); + return false; + } + return true; + } + + public XCardSwitchButton getxCardSwitchButton() { + return xCardSwitchButton; + } + + public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { + this.xCardSwitchButton = xCardSwitchButton; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java new file mode 100644 index 000000000..15bfa7337 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java @@ -0,0 +1,64 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.FormUndoableAction; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.FRLogger; +import com.fr.general.Inter; + +/** + * Created by zhouping on 2017/2/9. + */ +public class TabMoveNextAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next")); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/right.png")); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout(); + XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout(); + CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData(); + try { + int currentIndex = currentButton.getIndex(); + XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex); + WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData(); + xwCardTagLayout.setSwitchingTab(true); + //修改下一个tab的索引号 + CardSwitchButton nextBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex + 1).toData(); + nextBtn.setIndex(currentIndex); + WTabFitLayout nextTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex + 1).toData(); + nextTab.setIndex(currentIndex); + nextTab.setTabNameIndex(currentIndex); + + xwCardTagLayout.remove(xCardSwitchButton); + xwCardTagLayout.add(xCardSwitchButton, currentIndex + 1); + xwCardLayout.remove(xCurrentTab); + xwCardLayout.add(xCurrentTab, currentIndex + 1); + currentButton.setIndex(currentIndex + 1); + currentTab.setIndex(currentIndex + 1); + currentTab.setTabNameIndex(currentIndex + 1); + xwCardTagLayout.setSwitchingTab(false); + }catch (Exception e){ + xwCardTagLayout.setSwitchingTab(false); + FRLogger.getLogger().error(e.getMessage()); + return false; + } + return true; + } + + public XCardSwitchButton getxCardSwitchButton() { + return xCardSwitchButton; + } + + public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { + this.xCardSwitchButton = xCardSwitchButton; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java new file mode 100644 index 000000000..cac70db82 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java @@ -0,0 +1,64 @@ +package com.fr.design.designer.creator.cardlayout; + +import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.FormUndoableAction; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.FRLogger; +import com.fr.general.Inter; + +/** + * Created by zhouping on 2017/2/9. + */ +public class TabMovePrevAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev")); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/left.png")); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout(); + XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout(); + CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData(); + try { + int currentIndex = currentButton.getIndex(); + XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex); + WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData(); + xwCardTagLayout.setSwitchingTab(true); + //修改上一个tab的索引号 + CardSwitchButton prevBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex - 1).toData(); + prevBtn.setIndex(currentIndex); + WTabFitLayout prevTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex - 1).toData(); + prevTab.setIndex(currentIndex); + prevTab.setTabNameIndex(currentIndex); + + xwCardTagLayout.remove(xCardSwitchButton); + xwCardTagLayout.add(xCardSwitchButton, currentIndex - 1); + xwCardLayout.remove(xCurrentTab); + xwCardLayout.add(xCurrentTab, currentIndex - 1); + currentButton.setIndex(currentIndex - 1); + currentTab.setIndex(currentIndex - 1); + currentTab.setTabNameIndex(currentIndex - 1); + xwCardTagLayout.setSwitchingTab(false); + }catch (Exception e){ + xwCardTagLayout.setSwitchingTab(false); + FRLogger.getLogger().error(e.getMessage()); + return false; + } + return true; + } + + public XCardSwitchButton getxCardSwitchButton() { + return xCardSwitchButton; + } + + public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { + this.xCardSwitchButton = xCardSwitchButton; + } +} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java index fa4c1d4a9..85e26e877 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java @@ -89,12 +89,12 @@ public class XCardAddButton extends XButton{ // addbutton对应的XWCardLayout和XWCardTagLayout暂未存入到xml中,重新打开之后先根据父子层获取 if(cardLayout == null && tagLayout ==null ){ - initRalateLayout(); + initRelateLayout(); } int index = cardLayout.toData().getWidgetCount(); //添加新的tab,并将原来的设为未选中状态 - setTabUnselectd(); + setTabUnselected(); addTab(index); this.tagLayout.adjustComponentWidth(); @@ -110,7 +110,7 @@ public class XCardAddButton extends XButton{ LayoutUtils.layoutRootContainer(designer.getRootComponent()); } - private void initRalateLayout(){ + private void initRelateLayout(){ XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent(); this.tagLayout = titleLayout.getTagPart(); @@ -129,7 +129,7 @@ public class XCardAddButton extends XButton{ } //将原来的tab页设置为未选中状态 - private void setTabUnselectd(){ + private void setTabUnselected(){ for(int i=0;i Date: Fri, 10 Feb 2017 12:53:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-1814=20=E8=A1=A8=E5=8D=95tab?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E6=94=B9=E8=89=AFbug=20pmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EditingMouseListener.java | 126 +++++++++--------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java index f88abfaa4..f1f61b2b2 100644 --- a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java @@ -187,45 +187,48 @@ public class EditingMouseListener extends MouseInputAdapter { designer.selectComponents(e); } if (stateModel.isDragging()) { - // 当前鼠标所在的组件 - XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); - if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){ - XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - if(selectionXCreator != null){ - selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height); - MoveUtils.hideForbidWindow(); - } - } - dragBackupBounds = null; - // 拉伸时鼠标拖动过快,导致所在组件获取会为空 - if (hoveredComponent == null && e.getY() < 0) { - // bug63538 - // 不是拖动过快导致的,而是纵坐标为负值导致的,这时参照横坐标为负值时的做法,取边界位置的组件,为鼠标所在点的组件 - // 如果直接return,界面上已经进行了拖拽不能恢复 - hoveredComponent = designer.getComponentAt(0, 0); - } - // 获取该组件所在的焦点容器 - XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); - - if (container != null) { - boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() - && container.acceptType(XWFitLayout.class); - if ( !formSubmit2Adapt) { - // 如果是处于拖拽状态,则释放组件 - stateModel.releaseDragging(e); - } else { - selectionModel.deleteSelection(); - designer.setPainter(null); - } - cancelPromptWidgetForbidEnter(); - } - + mouseDraggingRelease(e); } } lastPressEvent = null; last_creator = null; } + private void mouseDraggingRelease(MouseEvent e) { + // 当前鼠标所在的组件 + XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); + if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){ + XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if(selectionXCreator != null){ + selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height); + MoveUtils.hideForbidWindow(); + } + } + dragBackupBounds = null; + // 拉伸时鼠标拖动过快,导致所在组件获取会为空 + if (hoveredComponent == null && e.getY() < 0) { + // bug63538 + // 不是拖动过快导致的,而是纵坐标为负值导致的,这时参照横坐标为负值时的做法,取边界位置的组件,为鼠标所在点的组件 + // 如果直接return,界面上已经进行了拖拽不能恢复 + hoveredComponent = designer.getComponentAt(0, 0); + } + // 获取该组件所在的焦点容器 + XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); + + if (container != null) { + boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane() + && container.acceptType(XWFitLayout.class); + if ( !formSubmit2Adapt) { + // 如果是处于拖拽状态,则释放组件 + stateModel.releaseDragging(e); + } else { + selectionModel.deleteSelection(); + designer.setPainter(null); + } + cancelPromptWidgetForbidEnter(); + } + } + /** * 激活上下文菜单,待完善 * 6.56暂时不支持右键 bugid 8777 @@ -286,33 +289,7 @@ public class EditingMouseListener extends MouseInputAdapter { } 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() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); - int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); - if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) { - if (e.getY() + GAP - xElementCase.getInsets().top > minY && e.getY() - GAP - xElementCase.getInsets().top < minY + button.getHeight()) { - designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } - } - xElementCase.setHelpBtnOnFocus(false); - if (xElementCase.getCoverPane().getComponentCount() > 1) { - JComponent button1 = (JComponent) xElementCase.getCoverPane().getComponent(1); - int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); - int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); - if (e.getX() + GAP - xElementCase.getInsets().left > minX1 && e.getX() - GAP - xElementCase.getInsets().left < minX1 + button1.getWidth()) { - if (e.getY() + GAP - xElementCase.getInsets().top > minY1 && e.getY() - GAP - xElementCase.getInsets().top < minY1 + button1.getHeight()) { - designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - xElementCase.setHelpBtnOnFocus(true); - } - } - } - xElementCase.displayCoverPane(true); - xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); - + elementCaseMouseMoved(e, component); designer.repaint(); return; } @@ -322,6 +299,35 @@ public class EditingMouseListener extends MouseInputAdapter { designer.repaint(); } + private void elementCaseMouseMoved(MouseEvent e, XCreator component) { + 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(); + int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); + if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) { + if (e.getY() + GAP - xElementCase.getInsets().top > minY && e.getY() - GAP - xElementCase.getInsets().top < minY + button.getHeight()) { + designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + } + xElementCase.setHelpBtnOnFocus(false); + if (xElementCase.getCoverPane().getComponentCount() > 1) { + JComponent button1 = (JComponent) xElementCase.getCoverPane().getComponent(1); + int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); + int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); + if (e.getX() + GAP - xElementCase.getInsets().left > minX1 && e.getX() - GAP - xElementCase.getInsets().left < minX1 + button1.getWidth()) { + if (e.getY() + GAP - xElementCase.getInsets().top > minY1 && e.getY() - GAP - xElementCase.getInsets().top < minY1 + button1.getHeight()) { + designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + xElementCase.setHelpBtnOnFocus(true); + } + } + } + xElementCase.displayCoverPane(true); + xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); + } + private void setCoverPaneNotDisplay(MouseEvent e, boolean isLinkedHelpDialog) { if (xElementCase != null) { int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue();