|
|
|
@ -2,16 +2,14 @@ package com.fr.design.mainframe;
|
|
|
|
|
|
|
|
|
|
import com.fr.base.ScreenResolution; |
|
|
|
|
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.creator.XCreator; |
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
import com.fr.design.designer.creator.XWBorderLayout; |
|
|
|
|
import com.fr.design.designer.creator.XWFitLayout; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
|
import com.fr.design.fun.FormAdaptiveConfigUIProcessor; |
|
|
|
|
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.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
@ -28,8 +26,10 @@ import com.fr.general.FRScreen;
|
|
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.KeyStroke; |
|
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
@ -46,13 +46,18 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
|
|
|
|
|
|
public class FormArea extends JComponent implements ScrollRulerComponent { |
|
|
|
|
private static final double SLIDER_FLOAT = 400.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; |
|
|
|
|
private static final int ROTATIONS = 50; |
|
|
|
|
private static final int SHOWVALMAX = 400; |
|
|
|
@ -112,16 +117,32 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
addFormRuler(); |
|
|
|
|
} |
|
|
|
|
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) { |
|
|
|
|
return adaptiveConfigUI.openFormSliderZoom(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
/** |
|
|
|
|
* 注册缩放快捷键 |
|
|
|
|
* mac: command + 和 command - |
|
|
|
|
* 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); |
|
|
|
|
} |
|
|
|
|
}, SCALE_MINUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void onMobileAttrModified() { |
|
|
|
|
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr(); |
|
|
|
|
if (formMobileAttr.isMobileOnly()) { |
|
|
|
@ -138,12 +159,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
public void mouseWheelMoved(MouseWheelEvent e) { |
|
|
|
|
if (InputEventBaseOnOS.isControlDown(e)) { |
|
|
|
|
int dir = e.getWheelRotation(); |
|
|
|
|
int old_resolution = (int) slidePane.getShowVal().getValue(); |
|
|
|
|
slidePane.getShowVal().setValue(old_resolution - (dir * SHOWVALMIN)); |
|
|
|
|
int old_resolution = slidePane.getShowValue(); |
|
|
|
|
slidePane.setShowValue(old_resolution - (dir * SHOWVALMIN)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 增加表单的页面大小控制界面,包括手动修改和滑块拖动 |
|
|
|
|
*/ |
|
|
|
@ -151,35 +174,34 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
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"); |
|
|
|
|
tipsPane.setPreferredSize(new Dimension(200, 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, |
|
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
|
new UILabel("x"), heightPane, |
|
|
|
|
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), |
|
|
|
|
new UILabel(), |
|
|
|
|
slidePane}}, rowSize, columnSize, RESIZE_PANE_GAP); |
|
|
|
|
this.add(FormRulerLayout.BOTTOM, resizePane); |
|
|
|
|
setWidgetsConfig(); |
|
|
|
|
boolean needOpenSliderZoom = openSliderZoom(); |
|
|
|
|
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
|
|
|
|
|
slidePane.setEnabled(needOpenSliderZoom); |
|
|
|
|
slidePane.setVisible(needOpenSliderZoom); |
|
|
|
|
if (needOpenSliderZoom) { |
|
|
|
|
initTransparent(); |
|
|
|
|
} |
|
|
|
|
slidePane.setEnabled(true); |
|
|
|
|
slidePane.setVisible(true); |
|
|
|
|
initCalculateSize(); |
|
|
|
|
slidePane.addValueChangeListener(showValSpinnerChangeListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setWidgetsConfig() { |
|
|
|
|
widthPane.setHorizontalAlignment(widthPane.CENTER); |
|
|
|
|
heightPane.setHorizontalAlignment(heightPane.CENTER); |
|
|
|
@ -192,21 +214,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
addHeightPaneListener(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initTransparent() { |
|
|
|
|
initCalculateSize(); |
|
|
|
|
slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ChangeListener showValSpinnerChangeListener = new ChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); |
|
|
|
|
double value = slidePane.getShowValue(); |
|
|
|
|
value = value > SHOWVALMAX ? SHOWVALMAX : value; |
|
|
|
|
value = value < SHOWVALMIN ? SHOWVALMIN : value; |
|
|
|
|
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
jf.getFormDesign().setResolution((int) value); |
|
|
|
|
jf.getFormDesign().getArea().resolution = (int) value; |
|
|
|
|
reCalculateRoot(value, true); |
|
|
|
|
scale((int) value); |
|
|
|
|
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (form != null) { |
|
|
|
|
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(); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -723,9 +745,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
* @return 百分比值 |
|
|
|
|
*/ |
|
|
|
|
public double getSlideValue() { |
|
|
|
|
// return slidePane.updateBean();
|
|
|
|
|
//7.1.1不加缩放滑块
|
|
|
|
|
return this.screenValue; |
|
|
|
|
return slidePane.getShowValue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -766,9 +786,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
|
|
|
|
|
START_VALUE = DEFAULT_SLIDER; |
|
|
|
|
reCalculateRoot(slide, true); |
|
|
|
|
// slidePane.populateBean(slide);
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
this.slidePane.setShowValue((int) slide); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算滚动条的值和max |
|
|
|
|
* |
|
|
|
@ -835,12 +858,11 @@ 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; |
|
|
|
|
rec = new Rectangle(designerLeft, TOPGAP, DESIGNERWIDTH, DESIGNERHEIGHT); |
|
|
|
|
int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2; |
|
|
|
|
rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT); |
|
|
|
|
} |
|
|
|
|
// designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。
|
|
|
|
|
designer.setBounds(rec); |
|
|
|
|