|
|
@ -12,6 +12,7 @@ import com.fr.design.designer.beans.models.SelectionModel; |
|
|
|
import com.fr.design.designer.creator.XButton; |
|
|
|
import com.fr.design.designer.creator.XButton; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
@ -27,17 +28,28 @@ import com.fr.form.ui.container.WTabTextDirection; |
|
|
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
|
|
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
|
|
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
|
|
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
|
|
|
import com.fr.general.Background; |
|
|
|
import com.fr.general.Background; |
|
|
|
import com.fr.general.act.BorderPacker; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
|
|
|
import com.fr.general.act.BorderPacker; |
|
|
|
import com.fr.general.act.TitlePacker; |
|
|
|
import com.fr.general.act.TitlePacker; |
|
|
|
import com.fr.general.cardtag.TemplateStyle; |
|
|
|
import com.fr.general.cardtag.TemplateStyle; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.stable.unit.PT; |
|
|
|
import com.fr.stable.unit.PT; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.Action; |
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.plaf.basic.BasicLabelUI; |
|
|
|
import javax.swing.plaf.basic.BasicLabelUI; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Container; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
import java.awt.FontMetrics; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -243,52 +255,43 @@ public class XCardSwitchButton extends XButton { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
|
|
|
|
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
|
|
|
|
private void initRelateLayout(){ |
|
|
|
private void initRelateLayout() { |
|
|
|
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(); |
|
|
|
this.cardLayout = borderLayout.getCardPart(); |
|
|
|
this.cardLayout = borderLayout.getCardPart(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//是否进入点击关闭按钮区域
|
|
|
|
/** |
|
|
|
private boolean isSelectedClose(MouseEvent e, FormDesigner designer){ |
|
|
|
* <p> 是否进入点击关闭按钮区域 |
|
|
|
|
|
|
|
* <p> 计算逻辑: |
|
|
|
|
|
|
|
* <p> 先得到鼠标的绝对坐标 -> tab布局的绝对坐标 -> 得到鼠标相对tab的坐标(有参数面板时要减去参数面板的高度) |
|
|
|
|
|
|
|
* <p> 再计算删除区域位置的相对坐标,通过对比判定鼠标是否在点击关闭按钮区域内,即,鼠标的位置(ex,ey): |
|
|
|
|
|
|
|
* <li> 当前点击tag删除区域的x坐标 < ex < 当前点击tag删除区域的x坐标 + 偏移量</li> |
|
|
|
|
|
|
|
* <li> 当前点击tag删除区域的y坐标 < ey < 当前点击tag删除区域的y坐标 + 偏移量</li> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param e 鼠标事件 |
|
|
|
|
|
|
|
* @param designer 表单编辑对象 |
|
|
|
|
|
|
|
* @return true/false 在内/不在 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean isSelectedClose(MouseEvent e, FormDesigner designer) { |
|
|
|
|
|
|
|
|
|
|
|
int diff = designer.getHorizontalScaleValue(); |
|
|
|
int diff = designer.getHorizontalScaleValue(); |
|
|
|
|
|
|
|
|
|
|
|
// mouse position
|
|
|
|
// mouse position
|
|
|
|
|
|
|
|
// 这里是鼠标的绝对位置
|
|
|
|
int ex = e.getX() + diff; |
|
|
|
int ex = e.getX() + diff; |
|
|
|
int ey = e.getY(); |
|
|
|
int ey = e.getY(); |
|
|
|
|
|
|
|
// 获取tab布局的位置,鼠标相对于tab按钮的位置
|
|
|
|
//获取tab布局的位置,鼠标相对于tab按钮的位置
|
|
|
|
double[] tabPositionInBody = getTabAbsolutePositionInBody(); |
|
|
|
Container mainLayout = cardLayout.getBackupParent(); |
|
|
|
|
|
|
|
Point point = mainLayout.getLocation(); |
|
|
|
|
|
|
|
int y = 0; |
|
|
|
|
|
|
|
int x = 0; |
|
|
|
|
|
|
|
//遍历一下,不然是相对位置,嵌套后位置不对
|
|
|
|
|
|
|
|
while (mainLayout.getParent() != null){ |
|
|
|
|
|
|
|
if(mainLayout instanceof XWCardLayout){ |
|
|
|
|
|
|
|
y += mainLayout.getY(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainLayout = mainLayout.getParent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(mainLayout instanceof XWCardMainBorderLayout){ |
|
|
|
|
|
|
|
x += mainLayout.getX(); |
|
|
|
|
|
|
|
y += mainLayout.getY(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
double mainX = point.getX() + x; |
|
|
|
|
|
|
|
double mainY = point.getY() + y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 参数界面对坐标的影响
|
|
|
|
// 参数界面对坐标的影响
|
|
|
|
JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
if(jform.getFormDesign().getParaComponent() != null){ |
|
|
|
if (jform.getFormDesign().getParaComponent() != null) { |
|
|
|
ey -= jform.getFormDesign().getParaHeight(); |
|
|
|
ey -= jform.getFormDesign().getParaHeight(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//减掉tab布局的相对位置
|
|
|
|
//减掉tab布局的相对位置
|
|
|
|
ex -= mainX; |
|
|
|
ex -= tabPositionInBody[0]; |
|
|
|
ey -= mainY; |
|
|
|
ey -= tabPositionInBody[1]; |
|
|
|
|
|
|
|
|
|
|
|
XLayoutContainer titleLayout = tagLayout.getBackupParent(); |
|
|
|
XLayoutContainer titleLayout = tagLayout.getBackupParent(); |
|
|
|
Point titlePoint = titleLayout.getLocation(); |
|
|
|
Point titlePoint = titleLayout.getLocation(); |
|
|
@ -298,10 +301,43 @@ public class XCardSwitchButton extends XButton { |
|
|
|
int width = button.getWidth(); |
|
|
|
int width = button.getWidth(); |
|
|
|
|
|
|
|
|
|
|
|
// 鼠标进入按钮右侧删除图标区域
|
|
|
|
// 鼠标进入按钮右侧删除图标区域
|
|
|
|
double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET); |
|
|
|
double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET); |
|
|
|
double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET; |
|
|
|
double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET; |
|
|
|
|
|
|
|
// 比较的是相对位置的偏移量是否在一定距离内
|
|
|
|
|
|
|
|
// 所以要得到鼠标相对于当前tab块的坐标
|
|
|
|
|
|
|
|
return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取tab布局在body内的绝对位置 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private double[] getTabAbsolutePositionInBody() { |
|
|
|
|
|
|
|
// 获取tab布局的位置,鼠标相对于tab按钮的位置
|
|
|
|
|
|
|
|
Container mainLayout = cardLayout.getBackupParent(); |
|
|
|
|
|
|
|
// 这个point是当前tab布局的相对坐标,是相对于父容器的坐标
|
|
|
|
|
|
|
|
// 比如父级是一个absolute块,放在左上角,现在得到的point就是(0,0)
|
|
|
|
|
|
|
|
Point point = mainLayout.getLocation(); |
|
|
|
|
|
|
|
int y = 0; |
|
|
|
|
|
|
|
int x = 0; |
|
|
|
|
|
|
|
// 遍历一下,不然是相对位置,嵌套后位置不对
|
|
|
|
|
|
|
|
// 这里是要得到tab布局的绝对位置,所以要加上父组件的位置
|
|
|
|
|
|
|
|
while (mainLayout.getParent() != null) { |
|
|
|
|
|
|
|
if (mainLayout instanceof XWCardLayout) { |
|
|
|
|
|
|
|
y += mainLayout.getY(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainLayout = mainLayout.getParent(); |
|
|
|
|
|
|
|
|
|
|
|
return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY()); |
|
|
|
if ((mainLayout instanceof XWCardMainBorderLayout) || (mainLayout instanceof XWAbsoluteLayout)) { |
|
|
|
|
|
|
|
x += mainLayout.getX(); |
|
|
|
|
|
|
|
y += mainLayout.getY(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
double mainX = point.getX() + x; |
|
|
|
|
|
|
|
double mainY = point.getY() + y; |
|
|
|
|
|
|
|
return new double[]{mainX, mainY}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将当前switchButton改为选中状态
|
|
|
|
//将当前switchButton改为选中状态
|
|
|
@ -313,7 +349,7 @@ public class XCardSwitchButton extends XButton { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
super.paintComponent(g); |
|
|
|
super.paintComponent(g); |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|