|
|
@ -3,13 +3,6 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package com.fr.design.designer.creator.cardlayout; |
|
|
|
package com.fr.design.designer.creator.cardlayout; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
import com.fr.base.ScreenResolution; |
|
|
@ -25,6 +18,7 @@ import com.fr.design.mainframe.EditingMouseListener; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.mainframe.FormHierarchyTreePane; |
|
|
|
import com.fr.design.mainframe.FormHierarchyTreePane; |
|
|
|
import com.fr.design.mainframe.JForm; |
|
|
|
import com.fr.design.mainframe.JForm; |
|
|
|
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
import com.fr.form.ui.CardSwitchButton; |
|
|
|
import com.fr.form.ui.CardSwitchButton; |
|
|
|
import com.fr.form.ui.LayoutBorderStyle; |
|
|
|
import com.fr.form.ui.LayoutBorderStyle; |
|
|
@ -34,6 +28,13 @@ import com.fr.general.Background; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
@ -42,11 +43,11 @@ import com.fr.general.Inter; |
|
|
|
public class XCardSwitchButton extends XButton { |
|
|
|
public class XCardSwitchButton extends XButton { |
|
|
|
|
|
|
|
|
|
|
|
private static final int LEFT_GAP = 16; |
|
|
|
private static final int LEFT_GAP = 16; |
|
|
|
private static Icon MOUSE_COLSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); |
|
|
|
private static Icon MOUSE_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); |
|
|
|
|
|
|
|
|
|
|
|
//设置的图片类型
|
|
|
|
//设置的图片类型
|
|
|
|
private static final String COLORBACKGROUNDTYPE = "ColorBackground"; |
|
|
|
private static final String COLOR_BACKGROUND_TYPE = "ColorBackground"; |
|
|
|
private static final String DEFAULTTYPE = "default"; |
|
|
|
private static final String DEFAULT_TYPE = "default"; |
|
|
|
private static final String DEFAULT_FONT_NAME = "SimSun"; |
|
|
|
private static final String DEFAULT_FONT_NAME = "SimSun"; |
|
|
|
|
|
|
|
|
|
|
|
//默认颜色
|
|
|
|
//默认颜色
|
|
|
@ -75,7 +76,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
private boolean isCustomStyle; |
|
|
|
private boolean isCustomStyle; |
|
|
|
private UILabel label; |
|
|
|
private UILabel label; |
|
|
|
|
|
|
|
|
|
|
|
private Icon closeIcon = MOUSE_COLSE; |
|
|
|
private Icon closeIcon = MOUSE_CLOSE; |
|
|
|
|
|
|
|
|
|
|
|
public XWCardTagLayout getTagLayout() { |
|
|
|
public XWCardTagLayout getTagLayout() { |
|
|
|
return tagLayout; |
|
|
|
return tagLayout; |
|
|
@ -144,16 +145,17 @@ public class XCardSwitchButton extends XButton { |
|
|
|
|
|
|
|
|
|
|
|
//关闭重新打开,相关的layout未存到xml中,初始化
|
|
|
|
//关闭重新打开,相关的layout未存到xml中,初始化
|
|
|
|
if(cardLayout == null){ |
|
|
|
if(cardLayout == null){ |
|
|
|
initRalateLayout(this); |
|
|
|
initRelateLayout(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取当前tab的index
|
|
|
|
//获取当前tab的index
|
|
|
|
XCardSwitchButton button = this; |
|
|
|
XCardSwitchButton button = this; |
|
|
|
CardSwitchButton currentButton = (CardSwitchButton) button.toData(); |
|
|
|
CardSwitchButton currentButton = (CardSwitchButton) button.toData(); |
|
|
|
int index = currentButton.getIndex(); |
|
|
|
int index = currentButton.getIndex(); |
|
|
|
|
|
|
|
int maxIndex = cardLayout.getComponentCount() - 1; |
|
|
|
|
|
|
|
|
|
|
|
//点击删除图标时
|
|
|
|
//点击删除图标时
|
|
|
|
if (isSeletectedClose(e,designer)) { |
|
|
|
if (isSelectedClose(e, designer)) { |
|
|
|
//当删除到最后一个tab时,删除整个tab布局
|
|
|
|
//当删除到最后一个tab时,删除整个tab布局
|
|
|
|
if(tagLayout.getComponentCount() <= MIN_SIZE){ |
|
|
|
if(tagLayout.getComponentCount() <= MIN_SIZE){ |
|
|
|
deleteTabLayout(selectionModel, designer); |
|
|
|
deleteTabLayout(selectionModel, designer); |
|
|
@ -169,22 +171,44 @@ public class XCardSwitchButton extends XButton { |
|
|
|
|
|
|
|
|
|
|
|
//将当前tab按钮改为选中状态
|
|
|
|
//将当前tab按钮改为选中状态
|
|
|
|
changeButtonState(index); |
|
|
|
changeButtonState(index); |
|
|
|
|
|
|
|
|
|
|
|
// 切换到当前tab按钮对应的tabFitLayout
|
|
|
|
// 切换到当前tab按钮对应的tabFitLayout
|
|
|
|
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index); |
|
|
|
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index); |
|
|
|
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index); |
|
|
|
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index); |
|
|
|
tabFitLayout.setxCardSwitchButton(xCardSwitchButton); |
|
|
|
tabFitLayout.setxCardSwitchButton(xCardSwitchButton); |
|
|
|
selectionModel.setSelectedCreator(tabFitLayout); |
|
|
|
selectionModel.setSelectedCreator(tabFitLayout); |
|
|
|
|
|
|
|
|
|
|
|
if (editingMouseListener.stopEditing()) { |
|
|
|
if (editingMouseListener.stopEditing()) { |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); |
|
|
|
this); |
|
|
|
editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); |
|
|
|
editingMouseListener.startEditing(this, |
|
|
|
|
|
|
|
adapter.getDesignerEditor(), adapter); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
setTabsAndAdjust(); |
|
|
|
setTabsAndAdjust(); |
|
|
|
|
|
|
|
if(SwingUtilities.isRightMouseButton(e)){ |
|
|
|
|
|
|
|
showPopupMenu(editingMouseListener, e, index, maxIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showPopupMenu(EditingMouseListener editingMouseListener, MouseEvent e, int index, int maxIndex) { |
|
|
|
|
|
|
|
JPopupMenu jPopupMenu = new JPopupMenu(); |
|
|
|
|
|
|
|
Action first = new TabMoveFirstAction(editingMouseListener.getDesigner(), this); |
|
|
|
|
|
|
|
Action prev = new TabMovePrevAction(editingMouseListener.getDesigner(), this); |
|
|
|
|
|
|
|
Action next = new TabMoveNextAction(editingMouseListener.getDesigner(), this); |
|
|
|
|
|
|
|
Action end = new TabMoveEndAction(editingMouseListener.getDesigner(), this); |
|
|
|
|
|
|
|
if (index == 0){ |
|
|
|
|
|
|
|
first.setEnabled(false); |
|
|
|
|
|
|
|
prev.setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (index == maxIndex){ |
|
|
|
|
|
|
|
next.setEnabled(false); |
|
|
|
|
|
|
|
end.setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
jPopupMenu.add(first); |
|
|
|
|
|
|
|
jPopupMenu.add(prev); |
|
|
|
|
|
|
|
jPopupMenu.add(next); |
|
|
|
|
|
|
|
jPopupMenu.add(end); |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), e.getX(), e.getY()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//删除card,同时修改其他switchbutton和tabfit的index
|
|
|
|
//删除card,同时修改其他switchbutton和tabfit的index
|
|
|
|
private void deleteCard(XCardSwitchButton button,int index){ |
|
|
|
private void deleteCard(XCardSwitchButton button,int index){ |
|
|
|
String titleName = button.getContentLabel().getText(); |
|
|
|
String titleName = button.getContentLabel().getText(); |
|
|
@ -216,7 +240,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
|
|
|
|
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
|
|
|
|
private void initRalateLayout(XCardSwitchButton button){ |
|
|
|
private void initRelateLayout(XCardSwitchButton button){ |
|
|
|
this.tagLayout = (XWCardTagLayout)this.getBackupParent(); |
|
|
|
this.tagLayout = (XWCardTagLayout)this.getBackupParent(); |
|
|
|
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent(); |
|
|
|
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent(); |
|
|
|
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); |
|
|
|
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); |
|
|
@ -224,7 +248,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//是否进入点击关闭按钮区域
|
|
|
|
//是否进入点击关闭按钮区域
|
|
|
|
private boolean isSeletectedClose(MouseEvent e,FormDesigner designer){ |
|
|
|
private boolean isSelectedClose(MouseEvent e, FormDesigner designer){ |
|
|
|
|
|
|
|
|
|
|
|
int diff = designer.getArea().getHorScrollBar().getValue(); |
|
|
|
int diff = designer.getArea().getHorScrollBar().getValue(); |
|
|
|
|
|
|
|
|
|
|
@ -276,7 +300,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
super.paintComponent(g); |
|
|
|
super.paintComponent(g); |
|
|
|
setTabsAndAdjust(); |
|
|
|
setTabsAndAdjust(); |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
drawBackgorund(); |
|
|
|
drawBackground(); |
|
|
|
drawTitle(); |
|
|
|
drawTitle(); |
|
|
|
Dimension panelSize = this.getContentLabel().getSize(); |
|
|
|
Dimension panelSize = this.getContentLabel().getSize(); |
|
|
|
this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); |
|
|
|
this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); |
|
|
@ -289,13 +313,13 @@ public class XCardSwitchButton extends XButton { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//画背景
|
|
|
|
//画背景
|
|
|
|
private void drawBackgorund(){ |
|
|
|
private void drawBackground(){ |
|
|
|
CardSwitchButton button = (CardSwitchButton)this.toData(); |
|
|
|
CardSwitchButton button = (CardSwitchButton)this.toData(); |
|
|
|
Background currentBackground; |
|
|
|
Background currentBackground; |
|
|
|
currentBackground = this.getSelectBackground(); |
|
|
|
currentBackground = this.getSelectBackground(); |
|
|
|
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断
|
|
|
|
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断
|
|
|
|
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULTTYPE; |
|
|
|
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULT_TYPE; |
|
|
|
if (type.equals(COLORBACKGROUNDTYPE) || type.equals(DEFAULTTYPE)) { |
|
|
|
if (type.equals(COLOR_BACKGROUND_TYPE) || type.equals(DEFAULT_TYPE)) { |
|
|
|
ColorBackground background; |
|
|
|
ColorBackground background; |
|
|
|
if(button.isShowButton()){ |
|
|
|
if(button.isShowButton()){ |
|
|
|
this.rebuid(); |
|
|
|
this.rebuid(); |
|
|
@ -314,7 +338,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
CardSwitchButton button = (CardSwitchButton) this.toData(); |
|
|
|
CardSwitchButton button = (CardSwitchButton) this.toData(); |
|
|
|
this.setButtonText(button.getText()); |
|
|
|
this.setButtonText(button.getText()); |
|
|
|
if (this.cardLayout == null) { |
|
|
|
if (this.cardLayout == null) { |
|
|
|
initRalateLayout(this); |
|
|
|
initRelateLayout(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); |
|
|
|
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); |
|
|
|