|
|
|
@ -2,6 +2,7 @@ package com.fr.design.mainframe;
|
|
|
|
|
|
|
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
|
|
|
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
|
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
@ -46,6 +47,7 @@ import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
|
|
|
|
|
@ -75,6 +77,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
private UINumberField heightPane; |
|
|
|
|
private JFormSliderPane slidePane; |
|
|
|
|
private boolean isValid = true; |
|
|
|
|
// 初始时滑块值为100,托动后的值设为START_VALUE;
|
|
|
|
|
private double START_VALUE = DEFAULT_SLIDER; |
|
|
|
|
private int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
private double screenValue; |
|
|
|
|
|
|
|
|
@ -115,7 +119,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
this.setFocusTraversalKeysEnabled(false); |
|
|
|
|
this.addMouseWheelListener(showValSpinnerMouseWheelListener); |
|
|
|
|
registerShortCutKey(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -173,14 +176,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
double[] rowSize = {f}; |
|
|
|
|
double[] columnSize = {p, f, p, p, p, p, p, f, p}; |
|
|
|
|
UILabel tipsPane = new UILabel("form"); |
|
|
|
|
tipsPane.setPreferredSize(new Dimension(375, 0)); |
|
|
|
|
tipsPane.setPreferredSize(new Dimension(265, 0)); |
|
|
|
|
widthPane = new UINumberField(); |
|
|
|
|
widthPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
|
heightPane = new UINumberField(); |
|
|
|
|
heightPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
|
|
|
|
|
|
slidePane = JFormSliderPane.getInstance(); |
|
|
|
|
slidePane.setPreferredSize(new Dimension(375, 20)); |
|
|
|
|
slidePane.setPreferredSize(new Dimension(326, 20)); |
|
|
|
|
|
|
|
|
|
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( |
|
|
|
|
new JComponent[][]{{tipsPane, new UILabel(), widthPane, |
|
|
|
@ -198,6 +201,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
slidePane.addValueChangeListener(showValSpinnerChangeListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setWidgetsConfig() { |
|
|
|
|
widthPane.setHorizontalAlignment(widthPane.CENTER); |
|
|
|
|
heightPane.setHorizontalAlignment(heightPane.CENTER); |
|
|
|
@ -218,19 +222,16 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
value = value > SHOWVALMAX ? SHOWVALMAX : value; |
|
|
|
|
value = value < SHOWVALMIN ? SHOWVALMIN : value; |
|
|
|
|
scale((int) value); |
|
|
|
|
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (form != null) { |
|
|
|
|
form.fireTargetModified(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
private void scale(int value){ |
|
|
|
|
this.designer.setResolution(value); |
|
|
|
|
this.designer.getArea().resolution = value; |
|
|
|
|
reCalculateRoot(value, true); |
|
|
|
|
this.designer.setScale(value / DEFAULT_SLIDER); |
|
|
|
|
FormArea.this.validate(); |
|
|
|
|
this.designer.repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 返回当前的屏幕分辨率对应的百分比值 |
|
|
|
|
* |
|
|
|
@ -255,6 +256,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); |
|
|
|
|
XLayoutContainer root = FormArea.this.designer.getRootComponent(); |
|
|
|
|
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
|
|
|
|
|
// slidePane.populateBean(screenValue);
|
|
|
|
|
if (root.acceptType(XWFitLayout.class)) { |
|
|
|
|
XWFitLayout layout = (XWFitLayout) root; |
|
|
|
|
if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { |
|
|
|
@ -262,7 +264,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
} else { |
|
|
|
|
// 组件间隔啊
|
|
|
|
|
// REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题
|
|
|
|
|
reCalculateDefaultRoot(); |
|
|
|
|
reCalculateDefaultRoot(screenValue, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
LayoutUtils.layoutContainer(root); |
|
|
|
@ -382,14 +384,16 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
* 修改大小后,再根据屏幕分辨率调整下 |
|
|
|
|
*/ |
|
|
|
|
private void doReCalculateRoot(int width, int height, XWFitLayout layout) { |
|
|
|
|
// double value = slidePane.updateBean();
|
|
|
|
|
//重置滑块的值为默认值100
|
|
|
|
|
START_VALUE = DEFAULT_SLIDER; |
|
|
|
|
if ( AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { |
|
|
|
|
layout.getParent().setSize(width, height + designer.getParaHeight()); |
|
|
|
|
FormArea.this.validate(); |
|
|
|
|
} else { |
|
|
|
|
layout.setBackupGap(screenValue / DEFAULT_SLIDER); |
|
|
|
|
reCalculateRoot(screenValue, false); |
|
|
|
|
} |
|
|
|
|
reCalculateRoot(slidePane.getShowValue(), true); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -399,60 +403,71 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
* @param value |
|
|
|
|
*/ |
|
|
|
|
private void reCalculateRoot(double value, boolean needCalculateParaHeight) { |
|
|
|
|
double percent = (value - DEFAULT_SLIDER) / DEFAULT_SLIDER; |
|
|
|
|
double scale = value / DEFAULT_SLIDER; |
|
|
|
|
if ( AssistUtils.equals(value, START_VALUE) ) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
double percent = (value - START_VALUE) / START_VALUE; |
|
|
|
|
XLayoutContainer root = FormArea.this.designer.getRootComponent(); |
|
|
|
|
if (root.acceptType(XWFitLayout.class)) { |
|
|
|
|
XWFitLayout layout = (XWFitLayout) root; |
|
|
|
|
layout.setContainerPercent(scale); |
|
|
|
|
layout.adjustCompSize(percent); |
|
|
|
|
layout.setContainerPercent(value / DEFAULT_SLIDER); |
|
|
|
|
traverAndAdjust(layout, percent); |
|
|
|
|
layout.adjustCreatorsWhileSlide(percent); |
|
|
|
|
|
|
|
|
|
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
|
|
|
|
|
|
|
|
|
|
Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); |
|
|
|
|
XWBorderLayout parent = (XWBorderLayout) layout.getParent(); |
|
|
|
|
root.setScale(scale); |
|
|
|
|
// 自适应布局的父层是border
|
|
|
|
|
if (parent != null) { |
|
|
|
|
parent.setScale(scale); |
|
|
|
|
int paraHeight = parent.toData().getNorthSize(); |
|
|
|
|
XLayoutContainer paraComponent = designer.getParaComponent(); |
|
|
|
|
if (needCalculateParaHeight && paraComponent != null) { |
|
|
|
|
paraComponent.setScale(scale); |
|
|
|
|
this.designer.setParaHeight(paraHeight); |
|
|
|
|
paraComponent.setPreferredSize(new Dimension(d.width, this.designer.getParaHeight())); |
|
|
|
|
paraComponent.adjustCompSize( percent); |
|
|
|
|
if (layout.getParent() != null) { |
|
|
|
|
int paraHeight = designer.getParaHeight(); |
|
|
|
|
if (needCalculateParaHeight && paraHeight > 0) { |
|
|
|
|
designer.setParaHeight(paraHeight); |
|
|
|
|
XWBorderLayout parent = (XWBorderLayout) layout.getParent(); |
|
|
|
|
parent.toData().setNorthSize(paraHeight); |
|
|
|
|
parent.removeAll(); |
|
|
|
|
parent.add(paraComponent, WBorderLayout.NORTH); |
|
|
|
|
parent.add(root, WBorderLayout.CENTER); |
|
|
|
|
root.setBounds(0, this.designer.getParaHeight(), d.width, d.height); |
|
|
|
|
parent.add(designer.getParaComponent(), WBorderLayout.NORTH); |
|
|
|
|
parent.add(designer.getRootComponent(), WBorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
parent.setSize(d.width, d.height + this.designer.getParaHeight()); |
|
|
|
|
|
|
|
|
|
layout.getParent().setSize(d.width, d.height + paraHeight); |
|
|
|
|
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
|
|
|
|
|
FormArea.this.validate(); |
|
|
|
|
LayoutUtils.layoutRootContainer(designer.getRootComponent()); |
|
|
|
|
} |
|
|
|
|
START_VALUE = value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 按照界面大小的百分比值调整root大小 |
|
|
|
|
* |
|
|
|
|
* @param needCalculateParaHeight 是否需要调整参数界面高度 |
|
|
|
|
* @param value |
|
|
|
|
*/ |
|
|
|
|
private void reCalculateDefaultRoot() { |
|
|
|
|
private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) { |
|
|
|
|
XLayoutContainer root = FormArea.this.designer.getRootComponent(); |
|
|
|
|
if (root.acceptType(XWFitLayout.class)) { |
|
|
|
|
XWFitLayout layout = (XWFitLayout) root; |
|
|
|
|
Dimension dimension = layout.getSize(); |
|
|
|
|
double widthScale = 960D / dimension.width; |
|
|
|
|
double heightScale = 960D / dimension.height; |
|
|
|
|
final double scaleValue = Math.min(widthScale, heightScale); |
|
|
|
|
int value = (int) (scaleValue * 100); |
|
|
|
|
slidePane.setShowValue(value); |
|
|
|
|
if (value == 100) { |
|
|
|
|
return; |
|
|
|
|
layout.setContainerPercent(1.0); |
|
|
|
|
traverAndAdjust(layout, 0.0); |
|
|
|
|
layout.adjustCreatorsWhileSlide(0.0); |
|
|
|
|
|
|
|
|
|
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
|
|
|
|
|
|
|
|
|
|
Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); |
|
|
|
|
// 自适应布局的父层是border
|
|
|
|
|
if (layout.getParent() != null) { |
|
|
|
|
int paraHeight = designer.getParaHeight(); |
|
|
|
|
if (needCalculateParaHeight && paraHeight > 0) { |
|
|
|
|
designer.setParaHeight(paraHeight); |
|
|
|
|
XWBorderLayout parent = (XWBorderLayout) layout.getParent(); |
|
|
|
|
parent.toData().setNorthSize(paraHeight); |
|
|
|
|
parent.removeAll(); |
|
|
|
|
parent.add(designer.getParaComponent(), WBorderLayout.NORTH); |
|
|
|
|
parent.add(designer.getRootComponent(), WBorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
layout.getParent().setSize(d.width, d.height + paraHeight); |
|
|
|
|
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
|
|
|
|
|
FormArea.this.validate(); |
|
|
|
|
} |
|
|
|
|
scale(value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -462,7 +477,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
Object object = creator.getComponent(i); |
|
|
|
|
if (object instanceof XCreator) { |
|
|
|
|
XCreator temp = (XCreator) object; |
|
|
|
|
temp.setScale(1 + percent); |
|
|
|
|
temp.adjustCompSize(percent); |
|
|
|
|
traverAndAdjust(temp, percent); |
|
|
|
|
} |
|
|
|
@ -484,17 +498,17 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
* 鼠标滚轮事件 |
|
|
|
|
* 由于表单设计界面要求: 容器大小大于界面时,滚动条才可以拖动,所以不支持滚动无限往下滚 |
|
|
|
|
*/ |
|
|
|
|
// @Override
|
|
|
|
|
// protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) {
|
|
|
|
|
// int id = evt.getID();
|
|
|
|
|
// switch (id) {
|
|
|
|
|
// case MouseEvent.MOUSE_WHEEL: {
|
|
|
|
|
// onMouseWheelScroll(evt);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// default:
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
@Override |
|
|
|
|
protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) { |
|
|
|
|
int id = evt.getID(); |
|
|
|
|
switch (id) { |
|
|
|
|
case MouseEvent.MOUSE_WHEEL: { |
|
|
|
|
onMouseWheelScroll(evt); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onMouseWheelScroll(MouseWheelEvent evt) { |
|
|
|
|
int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS; |
|
|
|
@ -559,9 +573,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
layout(); |
|
|
|
|
if (isValid) { |
|
|
|
|
XLayoutContainer root = designer.getRootComponent(); |
|
|
|
|
setScrollBarProperties(root.getWidth() - designer.getWidth(), horScrollBar, horizontalValue); |
|
|
|
|
setScrollBarProperties((int) (root.getWidth()*designer.getScale() - designer.getWidth()), horScrollBar, horizontalValue); |
|
|
|
|
//计算滚动条值的时候应该算上参数面板的高度
|
|
|
|
|
setScrollBarProperties(designer.getParaHeight() + root.getHeight() - designer.getHeight(), verScrollBar, verticalValue); |
|
|
|
|
setScrollBarProperties((int) (designer.getParaHeight() + root.getHeight()*designer.getScale() - designer.getHeight()), verScrollBar, verticalValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -765,10 +779,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
layout.moveContainerMargin(); |
|
|
|
|
layout.addCompInterval(layout.getAcualInterval()); |
|
|
|
|
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { |
|
|
|
|
reCalculateRoot(slide, true); |
|
|
|
|
START_VALUE = DEFAULT_SLIDER; |
|
|
|
|
reCalculateRoot(screenValue, true); |
|
|
|
|
// slidePane.populateBean(slide);
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.slidePane.setShowValue((int) slide); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算滚动条的值和max |
|
|
|
@ -836,10 +854,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
if (hbarPreferredSize == null) { |
|
|
|
|
throw new IllegalArgumentException("hbarPreferredSize can not be null!"); |
|
|
|
|
} |
|
|
|
|
int maxHeight = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; |
|
|
|
|
int maxWidth = right - vbarPreferredSize.width; |
|
|
|
|
DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH; |
|
|
|
|
DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; |
|
|
|
|
DESIGNERHEIGHT = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; |
|
|
|
|
DESIGNERWIDTH = right - vbarPreferredSize.width; |
|
|
|
|
int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2; |
|
|
|
|
int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2; |
|
|
|
|
rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT); |
|
|
|
|