|
|
@ -2,16 +2,14 @@ package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
|
|
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
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.XWBorderLayout; |
|
|
|
import com.fr.design.designer.creator.XWBorderLayout; |
|
|
|
import com.fr.design.designer.creator.XWFitLayout; |
|
|
|
import com.fr.design.designer.creator.XWFitLayout; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.fun.FormAdaptiveConfigUIProcessor; |
|
|
|
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ispinner.UIBasicSpinner; |
|
|
|
|
|
|
|
import com.fr.design.gui.itextfield.UINumberField; |
|
|
|
import com.fr.design.gui.itextfield.UINumberField; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
@ -28,8 +26,10 @@ import com.fr.general.FRScreen; |
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import javax.swing.KeyStroke; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
@ -46,13 +46,18 @@ import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
import java.awt.event.FocusAdapter; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
|
|
|
|
|
|
|
|
public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
private static final double SLIDER_FLOAT = 400.0; |
|
|
|
private static final double SLIDER_FLOAT = 400.0; |
|
|
|
private static final double SLIDER_MIN = 10.0; |
|
|
|
private static final double SLIDER_MIN = 10.0; |
|
|
|
|
|
|
|
private static final String SCALE_PLUS_COMMAND = "scale_plus"; |
|
|
|
|
|
|
|
private static final String SCALE_MINUS_COMMAND = "scale_minus"; |
|
|
|
public static final double DEFAULT_SLIDER = 100.0; |
|
|
|
public static final double DEFAULT_SLIDER = 100.0; |
|
|
|
private static final int ROTATIONS = 50; |
|
|
|
private static final int ROTATIONS = 50; |
|
|
|
private static final int SHOWVALMAX = 400; |
|
|
|
private static final int SHOWVALMAX = 400; |
|
|
@ -112,16 +117,32 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
addFormRuler(); |
|
|
|
addFormRuler(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.setFocusTraversalKeysEnabled(false); |
|
|
|
this.setFocusTraversalKeysEnabled(false); |
|
|
|
this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener); |
|
|
|
this.addMouseWheelListener(showValSpinnerMouseWheelListener); |
|
|
|
|
|
|
|
registerShortCutKey(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean openSliderZoom(){ |
|
|
|
/** |
|
|
|
FormAdaptiveConfigUIProcessor adaptiveConfigUI = ExtraDesignClassManager.getInstance().getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING); |
|
|
|
* 注册缩放快捷键 |
|
|
|
if (adaptiveConfigUI != null) { |
|
|
|
* mac: command + 和 command - |
|
|
|
return adaptiveConfigUI.openFormSliderZoom(); |
|
|
|
* windows: ctr + 和 ctr - |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void registerShortCutKey() { |
|
|
|
|
|
|
|
this.registerKeyboardAction(new AbstractAction() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
int old_resolution = slidePane.getShowValue(); |
|
|
|
|
|
|
|
slidePane.setShowValue(old_resolution + SHOWVALMIN); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, SCALE_PLUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW); |
|
|
|
|
|
|
|
this.registerKeyboardAction(new AbstractAction() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
int old_resolution = slidePane.getShowValue(); |
|
|
|
|
|
|
|
slidePane.setShowValue(old_resolution - SHOWVALMIN); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
}, SCALE_MINUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void onMobileAttrModified() { |
|
|
|
public void onMobileAttrModified() { |
|
|
|
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr(); |
|
|
|
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr(); |
|
|
|
if (formMobileAttr.isMobileOnly()) { |
|
|
|
if (formMobileAttr.isMobileOnly()) { |
|
|
@ -138,12 +159,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
public void mouseWheelMoved(MouseWheelEvent e) { |
|
|
|
public void mouseWheelMoved(MouseWheelEvent e) { |
|
|
|
if (InputEventBaseOnOS.isControlDown(e)) { |
|
|
|
if (InputEventBaseOnOS.isControlDown(e)) { |
|
|
|
int dir = e.getWheelRotation(); |
|
|
|
int dir = e.getWheelRotation(); |
|
|
|
int old_resolution = (int) slidePane.getShowVal().getValue(); |
|
|
|
int old_resolution = slidePane.getShowValue(); |
|
|
|
slidePane.getShowVal().setValue(old_resolution - (dir * SHOWVALMIN)); |
|
|
|
slidePane.setShowValue(old_resolution - (dir * SHOWVALMIN)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 增加表单的页面大小控制界面,包括手动修改和滑块拖动 |
|
|
|
* 增加表单的页面大小控制界面,包括手动修改和滑块拖动 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -151,35 +174,34 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double[] rowSize = {f}; |
|
|
|
double[] rowSize = {f}; |
|
|
|
double[] columnSize = {p, f, p, p, p, p, p, p}; |
|
|
|
double[] columnSize = {p, f, p, p, p, p, p, f, p}; |
|
|
|
UILabel tipsPane = new UILabel("form"); |
|
|
|
UILabel tipsPane = new UILabel("form"); |
|
|
|
tipsPane.setPreferredSize(new Dimension(200, 0)); |
|
|
|
tipsPane.setPreferredSize(new Dimension(265, 0)); |
|
|
|
widthPane = new UINumberField(); |
|
|
|
widthPane = new UINumberField(); |
|
|
|
widthPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
widthPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
heightPane = new UINumberField(); |
|
|
|
heightPane = new UINumberField(); |
|
|
|
heightPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
heightPane.setPreferredSize(new Dimension(60, 0)); |
|
|
|
|
|
|
|
|
|
|
|
slidePane = JFormSliderPane.getInstance(); |
|
|
|
slidePane = JFormSliderPane.getInstance(); |
|
|
|
slidePane.setPreferredSize(new Dimension(375, 20)); |
|
|
|
slidePane.setPreferredSize(new Dimension(326, 20)); |
|
|
|
|
|
|
|
|
|
|
|
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( |
|
|
|
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( |
|
|
|
new JComponent[][]{{tipsPane, new UILabel(), widthPane, |
|
|
|
new JComponent[][]{{tipsPane, new UILabel(), widthPane, |
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
new UILabel("x"), heightPane, |
|
|
|
new UILabel("x"), heightPane, |
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
|
|
|
|
new UILabel(), |
|
|
|
slidePane}}, rowSize, columnSize, RESIZE_PANE_GAP); |
|
|
|
slidePane}}, rowSize, columnSize, RESIZE_PANE_GAP); |
|
|
|
this.add(FormRulerLayout.BOTTOM, resizePane); |
|
|
|
this.add(FormRulerLayout.BOTTOM, resizePane); |
|
|
|
setWidgetsConfig(); |
|
|
|
setWidgetsConfig(); |
|
|
|
boolean needOpenSliderZoom = openSliderZoom(); |
|
|
|
|
|
|
|
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
|
|
|
|
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
|
|
|
|
slidePane.setEnabled(needOpenSliderZoom); |
|
|
|
slidePane.setEnabled(true); |
|
|
|
slidePane.setVisible(needOpenSliderZoom); |
|
|
|
slidePane.setVisible(true); |
|
|
|
if (needOpenSliderZoom) { |
|
|
|
|
|
|
|
initTransparent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
initCalculateSize(); |
|
|
|
initCalculateSize(); |
|
|
|
|
|
|
|
slidePane.addValueChangeListener(showValSpinnerChangeListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setWidgetsConfig() { |
|
|
|
private void setWidgetsConfig() { |
|
|
|
widthPane.setHorizontalAlignment(widthPane.CENTER); |
|
|
|
widthPane.setHorizontalAlignment(widthPane.CENTER); |
|
|
|
heightPane.setHorizontalAlignment(heightPane.CENTER); |
|
|
|
heightPane.setHorizontalAlignment(heightPane.CENTER); |
|
|
@ -192,21 +214,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
addHeightPaneListener(); |
|
|
|
addHeightPaneListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTransparent() { |
|
|
|
|
|
|
|
initCalculateSize(); |
|
|
|
|
|
|
|
slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChangeListener showValSpinnerChangeListener = new ChangeListener() { |
|
|
|
ChangeListener showValSpinnerChangeListener = new ChangeListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); |
|
|
|
double value = slidePane.getShowValue(); |
|
|
|
value = value > SHOWVALMAX ? SHOWVALMAX : value; |
|
|
|
value = value > SHOWVALMAX ? SHOWVALMAX : value; |
|
|
|
value = value < SHOWVALMIN ? SHOWVALMIN : value; |
|
|
|
value = value < SHOWVALMIN ? SHOWVALMIN : value; |
|
|
|
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
scale((int) value); |
|
|
|
jf.getFormDesign().setResolution((int) value); |
|
|
|
|
|
|
|
jf.getFormDesign().getArea().resolution = (int) value; |
|
|
|
|
|
|
|
reCalculateRoot(value, true); |
|
|
|
|
|
|
|
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
if (form != null) { |
|
|
|
if (form != null) { |
|
|
|
form.fireTargetModified(); |
|
|
|
form.fireTargetModified(); |
|
|
@ -214,6 +229,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void scale(int value){ |
|
|
|
|
|
|
|
this.designer.setScale(value / DEFAULT_SLIDER); |
|
|
|
|
|
|
|
FormArea.this.validate(); |
|
|
|
|
|
|
|
this.designer.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 返回当前的屏幕分辨率对应的百分比值 |
|
|
|
* 返回当前的屏幕分辨率对应的百分比值 |
|
|
|
* |
|
|
|
* |
|
|
@ -555,9 +577,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
layout(); |
|
|
|
layout(); |
|
|
|
if (isValid) { |
|
|
|
if (isValid) { |
|
|
|
XLayoutContainer root = designer.getRootComponent(); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -723,9 +745,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
* @return 百分比值 |
|
|
|
* @return 百分比值 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public double getSlideValue() { |
|
|
|
public double getSlideValue() { |
|
|
|
// return slidePane.updateBean();
|
|
|
|
return slidePane.getShowValue(); |
|
|
|
//7.1.1不加缩放滑块
|
|
|
|
|
|
|
|
return this.screenValue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -766,9 +786,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
START_VALUE = DEFAULT_SLIDER; |
|
|
|
START_VALUE = DEFAULT_SLIDER; |
|
|
|
reCalculateRoot(slide, true); |
|
|
|
reCalculateRoot(slide, true); |
|
|
|
// slidePane.populateBean(slide);
|
|
|
|
// slidePane.populateBean(slide);
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.slidePane.setShowValue((int) slide); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 计算滚动条的值和max |
|
|
|
* 计算滚动条的值和max |
|
|
|
* |
|
|
|
* |
|
|
@ -835,12 +858,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
if (hbarPreferredSize == null) { |
|
|
|
if (hbarPreferredSize == null) { |
|
|
|
throw new IllegalArgumentException("hbarPreferredSize can not be null!"); |
|
|
|
throw new IllegalArgumentException("hbarPreferredSize can not be null!"); |
|
|
|
} |
|
|
|
} |
|
|
|
int maxHeight = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; |
|
|
|
DESIGNERHEIGHT = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; |
|
|
|
int maxWidth = right - vbarPreferredSize.width; |
|
|
|
DESIGNERWIDTH = right - vbarPreferredSize.width; |
|
|
|
DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH; |
|
|
|
|
|
|
|
DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; |
|
|
|
|
|
|
|
int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2; |
|
|
|
int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2; |
|
|
|
rec = new Rectangle(designerLeft, TOPGAP, DESIGNERWIDTH, DESIGNERHEIGHT); |
|
|
|
int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2; |
|
|
|
|
|
|
|
rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT); |
|
|
|
} |
|
|
|
} |
|
|
|
// designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。
|
|
|
|
// designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。
|
|
|
|
designer.setBounds(rec); |
|
|
|
designer.setBounds(rec); |
|
|
|