From 95532609161c441ef57685609c527b73fda782cf Mon Sep 17 00:00:00 2001 From: zhouping Date: Thu, 16 Feb 2017 16:19:41 +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=20=E8=BD=AE=E6=92=ADbug?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E9=A1=B5=E7=AD=BE=E6=8B=96=E5=8A=A8=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/locale/designer_en_US.properties | 6 +++--- .../creator/cardlayout/TabMoveEndAction.java | 2 ++ .../cardlayout/TabMoveFirstAction.java | 2 ++ .../creator/cardlayout/TabMoveNextAction.java | 2 ++ .../creator/cardlayout/TabMovePrevAction.java | 2 ++ .../creator/cardlayout/XWCardLayout.java | 4 ++-- ...bsoluteBodyLayoutPropertiesGroupModel.java | 20 ++++++++++--------- .../mainframe/EditingMouseListener.java | 5 +++++ 8 files changed, 29 insertions(+), 14 deletions(-) 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 24c7a87c7..a871d47aa 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 @@ -525,9 +525,9 @@ FR-Designer_Background_Gradient_Color=Gradient Color FR-Designer_Background_Image=Image FR-Designer_Background_Clear=Clear FR-Designer_Background_Image_Select=Select Picture -FR-Designer_Tab_carousel= -FR-Designer_setCarousel= -FR-Designer_carouselInterval= +FR-Designer_Tab_carousel=tab carousel +FR-Designer_setCarousel=set carousel +FR-Designer_carouselInterval=interval FR-Designer_Initial_Background_Tips=Initial background of the button FR-Designer_Mouse_Move_Tips=Move the mouse to the button on the background, in the absence of not changing the background FR-Designer_Mouse_Click_Tips=The background of the mouse to click the button, in the absence of not changing the background 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 index ae101dbe4..b2a5214c4 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java @@ -47,6 +47,8 @@ public class TabMoveEndAction extends FormUndoableAction { currentButton.setIndex(maxIndex - 1); currentTab.setIndex(maxIndex - 1); currentTab.setTabNameIndex(maxIndex - 1); + xwCardLayout.toData().setShowIndex(maxIndex - 1); + xwCardLayout.showCard(); xwCardTagLayout.setSwitchingTab(false); }catch (Exception e){ xwCardTagLayout.setSwitchingTab(false); 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 index 0d6047636..c9034d04b 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java @@ -46,6 +46,8 @@ public class TabMoveFirstAction extends FormUndoableAction { currentButton.setIndex(0); currentTab.setIndex(0); currentTab.setTabNameIndex(0); + xwCardLayout.toData().setShowIndex(0); + xwCardLayout.showCard(); xwCardTagLayout.setSwitchingTab(false); }catch (Exception e){ xwCardTagLayout.setSwitchingTab(false); 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 index 15bfa7337..e7806a7ae 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java @@ -45,6 +45,8 @@ public class TabMoveNextAction extends FormUndoableAction { currentButton.setIndex(currentIndex + 1); currentTab.setIndex(currentIndex + 1); currentTab.setTabNameIndex(currentIndex + 1); + xwCardLayout.toData().setShowIndex(currentIndex + 1); + xwCardLayout.showCard(); xwCardTagLayout.setSwitchingTab(false); }catch (Exception e){ xwCardTagLayout.setSwitchingTab(false); 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 index cac70db82..e92852c6c 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java @@ -45,6 +45,8 @@ public class TabMovePrevAction extends FormUndoableAction { currentButton.setIndex(currentIndex - 1); currentTab.setIndex(currentIndex - 1); currentTab.setTabNameIndex(currentIndex - 1); + xwCardLayout.toData().setShowIndex(currentIndex - 1); + xwCardLayout.showCard(); xwCardTagLayout.setSwitchingTab(false); }catch (Exception e){ xwCardTagLayout.setSwitchingTab(false); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 32a7134ad..7597a4579 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -295,9 +295,9 @@ public class XWCardLayout extends XLayoutContainer { * 判断当前tab组件是不是嵌套的 * @return 嵌套与否 */ - private boolean isNested(){ + private boolean isNested() { XLayoutContainer xLayoutContainer = this.getBackupParent().getBackupParent(); - return xLayoutContainer != null && xLayoutContainer.acceptType(XWTabFitLayout.class); + return xLayoutContainer == null || xLayoutContainer.acceptType(XWTabFitLayout.class); } public CRPropertyDescriptor[] getisCarousel() throws IntrospectionException { diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index b290bcccf..eb4b31154 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -26,8 +26,11 @@ import java.util.Comparator; public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPropertiesGroupModel { private LayoutTypeEditor layoutTypeEditor; private LayoutTypeRenderer layoutTypeRenderer; + //默认body是0,自适应布局;1,绝对布局. private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE; + private static final int EACH_ROW_COUNT = 4; + public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) { super(xwAbsoluteBodyLayout); } @@ -180,9 +183,8 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr // 把绝对布局中的元素按规则移动到自适应布局中 // 规则:各元素按顺序放置,其中每行最多4个元素,超出则换行,各元素均分body的高度和宽度 private void moveComponents2FitLayout(XWFitLayout xwFitLayout) { - int eachRowCount = 4; Component[] components = xwFitLayout.getComponents(); - if (components.length <= 1){ + if (components.length == 0){ xwFitLayout.updateBoundsWidget(); return; } @@ -191,17 +193,17 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr int leftMargin = xwFitLayout.toData().getMargin().getLeft(); int topMargin = xwFitLayout.toData().getMargin().getTop(); xwFitLayout.toData().setCompInterval(0); - int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1); + int row = (components.length / EACH_ROW_COUNT) + (components.length % EACH_ROW_COUNT == 0 ? 0 : 1); //最后一行的列数不定 - int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount; - int componentWidth = layoutWidth / eachRowCount; + int column = components.length % EACH_ROW_COUNT == 0 ? EACH_ROW_COUNT : components.length % EACH_ROW_COUNT; + int componentWidth = layoutWidth / EACH_ROW_COUNT; int componentHeight = layoutHeight / row; for(int i = 0;i < row - 1;i++){ - for(int j = 0;j < eachRowCount;j++){ - components[eachRowCount * i + j].setBounds( + for(int j = 0;j < EACH_ROW_COUNT;j++){ + components[EACH_ROW_COUNT * i + j].setBounds( leftMargin + componentWidth * j, topMargin + componentHeight * i, - j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount - 1) : componentWidth, + j == EACH_ROW_COUNT - 1 ? layoutWidth - componentWidth * (EACH_ROW_COUNT - 1) : componentWidth, componentHeight ); } @@ -210,7 +212,7 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr int lastRowWidth = layoutWidth / column; int lastRowHeight = layoutHeight - componentHeight * (row - 1); for (int i = 0;i < column;i++) { - components[eachRowCount * (row - 1) + i].setBounds( + components[EACH_ROW_COUNT * (row - 1) + i].setBounds( leftMargin + lastRowWidth * i, topMargin + componentHeight * (row - 1), i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth, diff --git a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java index f1f61b2b2..88dc9268f 100644 --- a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java @@ -11,6 +11,7 @@ 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.*; +import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.xpane.ToolTipEditor; @@ -519,6 +520,10 @@ public class EditingMouseListener extends MouseInputAdapter { public void mouseClicked(MouseEvent e) { XCreator creator = designer.getComponentAt(e); + if (e.getButton() != MouseEvent.BUTTON1 && !creator.acceptType(XCardSwitchButton.class)) { + return; + } + creator = processTopLayoutMouseClick(creator); if(creator != null){ From 4abace6d53aa2a50138f44b20351cc4cb68b33bc Mon Sep 17 00:00:00 2001 From: zhouping Date: Fri, 17 Feb 2017 14:17:25 +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=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=EF=BC=8C=E6=8A=BD=E5=87=BA=E7=88=B6=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../creator/cardlayout/TabMoveAction.java | 80 +++++++++++++++++++ .../cardlayout/TabMoveCustomAction.java | 23 +----- .../creator/cardlayout/TabMoveEndAction.java | 64 ++++----------- .../cardlayout/TabMoveFirstAction.java | 61 ++++---------- .../creator/cardlayout/TabMoveNextAction.java | 60 ++++---------- .../creator/cardlayout/TabMovePrevAction.java | 60 ++++---------- 6 files changed, 143 insertions(+), 205 deletions(-) create mode 100644 designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java new file mode 100644 index 000000000..354846d91 --- /dev/null +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java @@ -0,0 +1,80 @@ +package com.fr.design.designer.creator.cardlayout; + +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; + +/** + * Created by zhouping on 2017/2/17. + */ +public class TabMoveAction extends FormUndoableAction { + private XCardSwitchButton xCardSwitchButton; + + public TabMoveAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { + super(t); + this.xCardSwitchButton = xCardSwitchButton; + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + XCardSwitchButton xCardSwitchButton = getxCardSwitchButton(); + 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); + + changeTabIndex(xwCardTagLayout, xwCardLayout, currentIndex, maxIndex); + + moveTabAction(xwCardTagLayout, currentButton, xCurrentTab, currentTab); + + xwCardTagLayout.setSwitchingTab(false); + }catch (Exception e){ + xwCardTagLayout.setSwitchingTab(false); + FRLogger.getLogger().error(e.getMessage()); + return false; + } + return true; + } + + private void moveTabAction(XWCardTagLayout xwCardTagLayout, CardSwitchButton currentButton, XWTabFitLayout xCurrentTab, WTabFitLayout currentTab) { + int move2Index = getTabMoveIndex(currentButton); + XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout(); + xwCardTagLayout.remove(xCardSwitchButton); + xwCardTagLayout.add(xCardSwitchButton, move2Index); + xwCardLayout.remove(xCurrentTab); + xwCardLayout.add(xCurrentTab, move2Index); + currentButton.setIndex(move2Index); + currentTab.setIndex(move2Index); + currentTab.setTabNameIndex(move2Index); + xwCardLayout.toData().setShowIndex(move2Index); + xwCardLayout.showCard(); + } + + //改变Tab的索引号 + protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { + } + + /** + * 获取tab移动的目的索引:首位,末尾,下一个,上一个 + * @param currentButton 当前按钮 + * @return 索引 + */ + protected int getTabMoveIndex(CardSwitchButton currentButton) { + return currentButton.getIndex(); + } + + 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/TabMoveCustomAction.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java index 93a62287e..8930c686c 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java @@ -1,32 +1,17 @@ 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.general.IOUtils; /** * Created by zhouping on 2017/2/9. */ -public class TabMoveCustomAction extends FormUndoableAction { - private XCardSwitchButton xCardSwitchButton; +public class TabMoveCustomAction extends TabMoveAction { public TabMoveCustomAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { - super(t); + super(t, xCardSwitchButton); this.setName(""); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); - this.xCardSwitchButton = xCardSwitchButton; + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/control/refresh.png")); } - @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 index b2a5214c4..5da5dd1c7 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java @@ -1,68 +1,36 @@ 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.IOUtils; import com.fr.general.Inter; /** * Created by zhouping on 2017/2/9. */ -public class TabMoveEndAction extends FormUndoableAction { - private XCardSwitchButton xCardSwitchButton; +public class TabMoveEndAction extends TabMoveAction { public TabMoveEndAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { - super(t); + super(t, xCardSwitchButton); this.setName(Inter.getLocText("FR-Designer-Move_Tab_End")); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/rightright.png")); - this.xCardSwitchButton = xCardSwitchButton; + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/rightright.png")); } - @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); - xwCardLayout.toData().setShowIndex(maxIndex - 1); - xwCardLayout.showCard(); - xwCardTagLayout.setSwitchingTab(false); - }catch (Exception e){ - xwCardTagLayout.setSwitchingTab(false); - FRLogger.getLogger().error(e.getMessage()); - return false; + //改变Tab的索引号 + protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { + //修改当前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); } - return true; - } - - public XCardSwitchButton getxCardSwitchButton() { - return xCardSwitchButton; } - public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { - this.xCardSwitchButton = xCardSwitchButton; + @Override + protected int getTabMoveIndex(CardSwitchButton btn) { + return getxCardSwitchButton().getTagLayout().getComponentCount() - 1; } } 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 index c9034d04b..26195b946 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java @@ -1,67 +1,36 @@ 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.IOUtils; import com.fr.general.Inter; /** * Created by zhouping on 2017/2/9. */ -public class TabMoveFirstAction extends FormUndoableAction { - private XCardSwitchButton xCardSwitchButton; +public class TabMoveFirstAction extends TabMoveAction { public TabMoveFirstAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { - super(t); + super(t, xCardSwitchButton); this.setName(Inter.getLocText("FR-Designer-Move_Tab_First")); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/leftleft.png")); - this.xCardSwitchButton = xCardSwitchButton; + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/leftleft.png")); } @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); - xwCardLayout.toData().setShowIndex(0); - xwCardLayout.showCard(); - xwCardTagLayout.setSwitchingTab(false); - }catch (Exception e){ - xwCardTagLayout.setSwitchingTab(false); - FRLogger.getLogger().error(e.getMessage()); - return false; + protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { + //修改当前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); } - return true; } - public XCardSwitchButton getxCardSwitchButton() { - return xCardSwitchButton; - } - - public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { - this.xCardSwitchButton = xCardSwitchButton; + @Override + protected int getTabMoveIndex(CardSwitchButton btn) { + return 0; } } 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 index e7806a7ae..10e796abc 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java @@ -1,66 +1,34 @@ 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.IOUtils; import com.fr.general.Inter; /** * Created by zhouping on 2017/2/9. */ -public class TabMoveNextAction extends FormUndoableAction { - private XCardSwitchButton xCardSwitchButton; +public class TabMoveNextAction extends TabMoveAction { public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { - super(t); + super(t, xCardSwitchButton); this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next")); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/right.png")); - this.xCardSwitchButton = xCardSwitchButton; + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/right.png")); } @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); - xwCardLayout.toData().setShowIndex(currentIndex + 1); - xwCardLayout.showCard(); - xwCardTagLayout.setSwitchingTab(false); - }catch (Exception e){ - xwCardTagLayout.setSwitchingTab(false); - FRLogger.getLogger().error(e.getMessage()); - return false; - } - return true; - } - - public XCardSwitchButton getxCardSwitchButton() { - return xCardSwitchButton; + protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { + //修改下一个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); } - public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { - this.xCardSwitchButton = xCardSwitchButton; + @Override + protected int getTabMoveIndex(CardSwitchButton currentButton) { + return currentButton.getIndex() + 1; } } 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 index e92852c6c..859a27eea 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java @@ -1,66 +1,34 @@ 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.IOUtils; import com.fr.general.Inter; /** * Created by zhouping on 2017/2/9. */ -public class TabMovePrevAction extends FormUndoableAction { - private XCardSwitchButton xCardSwitchButton; +public class TabMovePrevAction extends TabMoveAction { public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { - super(t); + super(t, xCardSwitchButton); this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev")); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/left.png")); - this.xCardSwitchButton = xCardSwitchButton; + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/left.png")); } @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); - xwCardLayout.toData().setShowIndex(currentIndex - 1); - xwCardLayout.showCard(); - xwCardTagLayout.setSwitchingTab(false); - }catch (Exception e){ - xwCardTagLayout.setSwitchingTab(false); - FRLogger.getLogger().error(e.getMessage()); - return false; - } - return true; - } - - public XCardSwitchButton getxCardSwitchButton() { - return xCardSwitchButton; + protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { + //修改上一个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); } - public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { - this.xCardSwitchButton = xCardSwitchButton; + @Override + protected int getTabMoveIndex(CardSwitchButton currentButton) { + return currentButton.getIndex() - 1; } }