plough
8 years ago
12 changed files with 183 additions and 215 deletions
@ -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; |
||||||
|
} |
||||||
|
} |
@ -1,32 +1,17 @@ |
|||||||
package com.fr.design.designer.creator.cardlayout; |
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.design.mainframe.FormDesigner; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by zhouping on 2017/2/9. |
* Created by zhouping on 2017/2/9. |
||||||
*/ |
*/ |
||||||
public class TabMoveCustomAction extends FormUndoableAction { |
public class TabMoveCustomAction extends TabMoveAction { |
||||||
private XCardSwitchButton xCardSwitchButton; |
|
||||||
|
|
||||||
public TabMoveCustomAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
public TabMoveCustomAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
||||||
super(t); |
super(t, xCardSwitchButton); |
||||||
this.setName(""); |
this.setName(""); |
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); |
this.setSmallIcon(IOUtils.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; |
|
||||||
} |
|
||||||
} |
} |
||||||
|
@ -1,64 +1,34 @@ |
|||||||
package com.fr.design.designer.creator.cardlayout; |
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.design.mainframe.FormDesigner; |
||||||
import com.fr.form.ui.CardSwitchButton; |
import com.fr.form.ui.CardSwitchButton; |
||||||
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
||||||
import com.fr.general.FRLogger; |
import com.fr.general.IOUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by zhouping on 2017/2/9. |
* Created by zhouping on 2017/2/9. |
||||||
*/ |
*/ |
||||||
public class TabMoveNextAction extends FormUndoableAction { |
public class TabMoveNextAction extends TabMoveAction { |
||||||
private XCardSwitchButton xCardSwitchButton; |
|
||||||
|
|
||||||
public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
||||||
super(t); |
super(t, xCardSwitchButton); |
||||||
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next")); |
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next")); |
||||||
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/right.png")); |
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/right.png")); |
||||||
this.xCardSwitchButton = xCardSwitchButton; |
|
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { |
||||||
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的索引号
|
||||||
CardSwitchButton nextBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex + 1).toData(); |
CardSwitchButton nextBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex + 1).toData(); |
||||||
nextBtn.setIndex(currentIndex); |
nextBtn.setIndex(currentIndex); |
||||||
WTabFitLayout nextTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex + 1).toData(); |
WTabFitLayout nextTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex + 1).toData(); |
||||||
nextTab.setIndex(currentIndex); |
nextTab.setIndex(currentIndex); |
||||||
nextTab.setTabNameIndex(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() { |
@Override |
||||||
return xCardSwitchButton; |
protected int getTabMoveIndex(CardSwitchButton currentButton) { |
||||||
} |
return currentButton.getIndex() + 1; |
||||||
|
|
||||||
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { |
|
||||||
this.xCardSwitchButton = xCardSwitchButton; |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,64 +1,34 @@ |
|||||||
package com.fr.design.designer.creator.cardlayout; |
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.design.mainframe.FormDesigner; |
||||||
import com.fr.form.ui.CardSwitchButton; |
import com.fr.form.ui.CardSwitchButton; |
||||||
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
||||||
import com.fr.general.FRLogger; |
import com.fr.general.IOUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by zhouping on 2017/2/9. |
* Created by zhouping on 2017/2/9. |
||||||
*/ |
*/ |
||||||
public class TabMovePrevAction extends FormUndoableAction { |
public class TabMovePrevAction extends TabMoveAction { |
||||||
private XCardSwitchButton xCardSwitchButton; |
|
||||||
|
|
||||||
public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) { |
||||||
super(t); |
super(t, xCardSwitchButton); |
||||||
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev")); |
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev")); |
||||||
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/left.png")); |
this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/control/left.png")); |
||||||
this.xCardSwitchButton = xCardSwitchButton; |
|
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
protected void changeTabIndex(XWCardTagLayout xwCardTagLayout, XWCardLayout xwCardLayout, int currentIndex, int maxIndex) { |
||||||
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的索引号
|
||||||
CardSwitchButton prevBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex - 1).toData(); |
CardSwitchButton prevBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex - 1).toData(); |
||||||
prevBtn.setIndex(currentIndex); |
prevBtn.setIndex(currentIndex); |
||||||
WTabFitLayout prevTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex - 1).toData(); |
WTabFitLayout prevTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex - 1).toData(); |
||||||
prevTab.setIndex(currentIndex); |
prevTab.setIndex(currentIndex); |
||||||
prevTab.setTabNameIndex(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() { |
@Override |
||||||
return xCardSwitchButton; |
protected int getTabMoveIndex(CardSwitchButton currentButton) { |
||||||
} |
return currentButton.getIndex() - 1; |
||||||
|
|
||||||
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) { |
|
||||||
this.xCardSwitchButton = xCardSwitchButton; |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue