forked from fanruan/design
16 changed files with 399 additions and 1032 deletions
@ -1,78 +0,0 @@ |
|||||||
package com.fr.design.gui.ilable; |
|
||||||
|
|
||||||
import javax.swing.JLabel; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.FontMetrics; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
public class UIAutoChangeLineLabel extends JLabel { |
|
||||||
private final String text; |
|
||||||
private final int width; |
|
||||||
|
|
||||||
|
|
||||||
public UIAutoChangeLineLabel(String text, int width) { |
|
||||||
super(text); |
|
||||||
this.text = text; |
|
||||||
this.width = width; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void doLayout() { |
|
||||||
super.doLayout(); |
|
||||||
this.setText(wrapperHtmlText()); |
|
||||||
} |
|
||||||
|
|
||||||
private String wrapperHtmlText() { |
|
||||||
List<String> stringList = autoChangeLine(this.getWidth()); |
|
||||||
StringBuilder builder = new StringBuilder("<html>"); |
|
||||||
for (String s : stringList) { |
|
||||||
//用THML标签进行拼接,以实现自动换行
|
|
||||||
builder.append(s).append("<br/>"); |
|
||||||
} |
|
||||||
builder.append("</html>"); |
|
||||||
return builder.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
private List<String> autoChangeLine(int width) { |
|
||||||
List<String> result = new ArrayList<>(); |
|
||||||
if (width <= 0) { |
|
||||||
result.add(this.text); |
|
||||||
} else { |
|
||||||
|
|
||||||
char[] chars = this.text.toCharArray(); |
|
||||||
//获取字体计算大小
|
|
||||||
FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); |
|
||||||
int start = 0; |
|
||||||
int len = 0; |
|
||||||
while (start + len < this.text.length()) { |
|
||||||
while (true) { |
|
||||||
len++; |
|
||||||
if (start + len > this.text.length()) |
|
||||||
break; |
|
||||||
if (fontMetrics.charsWidth(chars, start, len) |
|
||||||
> width) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
result.add(String.copyValueOf(chars, start, len - 1)); |
|
||||||
start = start + len - 1; |
|
||||||
len = 0; |
|
||||||
} |
|
||||||
if (this.text.length() - start > 0) { |
|
||||||
result.add(String.copyValueOf(chars, start, this.text.length() - start)); |
|
||||||
} |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public Dimension getPreferredSize() { |
|
||||||
Dimension preferredSize = super.getPreferredSize(); |
|
||||||
List<String> stringList = autoChangeLine(width); |
|
||||||
FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); |
|
||||||
return new Dimension(preferredSize.width, fontMetrics.getHeight() * stringList.size()); |
|
||||||
} |
|
||||||
} |
|
@ -1,128 +0,0 @@ |
|||||||
package com.fr.design.report.fit; |
|
||||||
|
|
||||||
|
|
||||||
import com.fr.design.designer.properties.items.Item; |
|
||||||
import com.fr.form.fit.common.LightTool; |
|
||||||
import com.fr.form.main.BodyScaleAttrTransformer; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
|
||||||
import com.fr.form.ui.container.WBodyLayoutType; |
|
||||||
import com.fr.form.ui.container.WFitLayout; |
|
||||||
|
|
||||||
public enum FormFitAttrModelType { |
|
||||||
PLAIN_FORM_FIT_ATTR_MODEL { |
|
||||||
@Override |
|
||||||
public FitAttrModel getFitAttrModel() { |
|
||||||
return new FrmFitAttrModel(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Item[] getFitLayoutScaleAttr() { |
|
||||||
return new Item[]{ |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN)}; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Item[] getAbsoluteLayoutSaleAttr() { |
|
||||||
return new Item[]{ |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED) |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public int getScaleAttrShowIndex(WFitLayout wFitLayout) { |
|
||||||
int scale = wFitLayout.getScaleAttr(); |
|
||||||
if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.FIT) { |
|
||||||
return BodyScaleAttrTransformer.getFitBodyCompStateFromScaleAttr(scale); |
|
||||||
} else { |
|
||||||
return BodyScaleAttrTransformer.getAbsoluteBodyCompStateFromScaleAttr(scale); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { |
|
||||||
if (wBodyLayoutType == WBodyLayoutType.FIT) { |
|
||||||
if (showIndex == 0) { |
|
||||||
return WFitLayout.SCALE_FULL; |
|
||||||
} else { |
|
||||||
return WFitLayout.SCALE_HOR; |
|
||||||
} |
|
||||||
} else { |
|
||||||
if (showIndex == 0) { |
|
||||||
return WFitLayout.SCALE_FULL; |
|
||||||
} else { |
|
||||||
return WFitLayout.SCALE_NO; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
}, |
|
||||||
NEW_FORM_FIT_ATTR_MODEL { |
|
||||||
@Override |
|
||||||
public FitAttrModel getFitAttrModel() { |
|
||||||
return new AdaptiveFrmFitAttrModel(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Item[] getFitLayoutScaleAttr() { |
|
||||||
return new Item[]{ |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Item[] getAbsoluteLayoutSaleAttr() { |
|
||||||
return new Item[]{ |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), |
|
||||||
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public int getScaleAttrShowIndex(WFitLayout wFitLayout) { |
|
||||||
int scale = wFitLayout.getScaleAttr(); |
|
||||||
if (scale == WFitLayout.SCALE_NO) { |
|
||||||
return 2; |
|
||||||
} else if (scale == WFitLayout.SCALE_HOR) { |
|
||||||
return 1; |
|
||||||
} else { |
|
||||||
return 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { |
|
||||||
if (showIndex == 0) { |
|
||||||
return WFitLayout.SCALE_FULL; |
|
||||||
} else if (showIndex == 1) { |
|
||||||
return WFitLayout.SCALE_HOR; |
|
||||||
} else { |
|
||||||
return WFitLayout.SCALE_NO; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
public abstract FitAttrModel getFitAttrModel(); |
|
||||||
|
|
||||||
public abstract Item[] getFitLayoutScaleAttr(); |
|
||||||
|
|
||||||
public abstract Item[] getAbsoluteLayoutSaleAttr(); |
|
||||||
|
|
||||||
public abstract int getScaleAttrShowIndex(WFitLayout wFitLayout); |
|
||||||
|
|
||||||
public abstract int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType); |
|
||||||
|
|
||||||
|
|
||||||
public static FormFitAttrModelType parse(Form form) { |
|
||||||
return LightTool.containNewFormFlag(form) ? NEW_FORM_FIT_ATTR_MODEL : PLAIN_FORM_FIT_ATTR_MODEL; |
|
||||||
} |
|
||||||
} |
|
@ -1,59 +0,0 @@ |
|||||||
package com.fr.design.report.fit; |
|
||||||
|
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.report.fit.ReportFitAttr; |
|
||||||
|
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Color; |
|
||||||
import java.awt.Component; |
|
||||||
|
|
||||||
public class FormFitConfigPane extends ReportFitConfigPane { |
|
||||||
private static final int DEFAULT_ITEM = 0; |
|
||||||
private static final int CUSTOM_ITEM = 1; |
|
||||||
|
|
||||||
public FormFitConfigPane(FitAttrModel fitAttrModel) { |
|
||||||
this(fitAttrModel, false); |
|
||||||
} |
|
||||||
|
|
||||||
public FormFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { |
|
||||||
super(fitAttrModel, globalConfig); |
|
||||||
} |
|
||||||
|
|
||||||
protected JPanel initECConfigPane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
if (fitAttrModel.getFitTypeNames().length != 0) { |
|
||||||
Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; |
|
||||||
initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); |
|
||||||
jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); |
|
||||||
jPanel.add(createTipPane(), BorderLayout.SOUTH); |
|
||||||
} |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
private JPanel createTipPane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); |
|
||||||
UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip1")); |
|
||||||
jPanel.add(label1); |
|
||||||
label1.setForeground(Color.lightGray); |
|
||||||
UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip2")); |
|
||||||
jPanel.add(label2); |
|
||||||
label2.setForeground(Color.lightGray); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
protected void refreshPreviewJPanel() { |
|
||||||
previewJPanel.refreshPreview(fontRadioGroup.isFontFit()); |
|
||||||
} |
|
||||||
|
|
||||||
protected void populateECConfigRadioGroup(int fitStateInPC) { |
|
||||||
ecConfigRadioGroup.selectIndexButton(fitStateInPC == 0 ? DEFAULT_ITEM : CUSTOM_ITEM); |
|
||||||
} |
|
||||||
|
|
||||||
protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr) { |
|
||||||
reportFitAttr.setFitStateInPC(ecConfigRadioGroup.getSelectRadioIndex()); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,71 +0,0 @@ |
|||||||
package com.fr.design.report.fit; |
|
||||||
|
|
||||||
import com.fr.base.GraphHelper; |
|
||||||
import com.fr.general.FRFont; |
|
||||||
|
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.Color; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.Font; |
|
||||||
import java.awt.FontMetrics; |
|
||||||
import java.awt.Graphics; |
|
||||||
|
|
||||||
|
|
||||||
public class NewFitPreviewPane extends JPanel { |
|
||||||
private boolean fitFont = false; |
|
||||||
private FitType fitType = FitType.DOUBLE_FIT; |
|
||||||
private static final Color DEFAULT_PAINT_COLOR = Color.decode("#419BF9"); |
|
||||||
private static final int FIT_FONT_SIZE = 15; |
|
||||||
private static final int NO_FIT_FONT_SIZE = 9; |
|
||||||
private static final Dimension NO_FIT_CONTAINER_DIMENSION = new Dimension(200, 136); |
|
||||||
|
|
||||||
@Override |
|
||||||
public void paint(Graphics g) { |
|
||||||
super.paint(g); |
|
||||||
g.setColor(Color.GRAY); |
|
||||||
GraphHelper.drawRect(g, 1, 1, this.getWidth() - 2, this.getHeight() - 2); |
|
||||||
g.setColor(DEFAULT_PAINT_COLOR); |
|
||||||
FRFont textFont = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, fitFont ? FIT_FONT_SIZE : NO_FIT_FONT_SIZE); |
|
||||||
g.setFont(textFont); |
|
||||||
Dimension dimension = calculateCellDimension(); |
|
||||||
GraphHelper.drawLine(g, 1, dimension.height, dimension.width * 2 - 1, dimension.height); |
|
||||||
GraphHelper.drawLine(g, dimension.width, 1, dimension.width, dimension.height * 2 - 1); |
|
||||||
GraphHelper.drawRect(g, 1, 1, dimension.width * 2 - 2, dimension.height * 2 - 2); |
|
||||||
double startX = calculateTextDrawStartX(dimension.width, this.getFontMetrics(textFont), "text1"); |
|
||||||
double startY = calculateTextDrawStartY(dimension.height); |
|
||||||
GraphHelper.drawString(g, "text1", startX, startY); |
|
||||||
GraphHelper.drawString(g, "text2", dimension.width + startX, startY); |
|
||||||
GraphHelper.drawString(g, "text3", startX, dimension.height + startY); |
|
||||||
GraphHelper.drawString(g, "text4", dimension.width + startX, dimension.height + startY); |
|
||||||
} |
|
||||||
|
|
||||||
private Dimension calculateCellDimension() { |
|
||||||
if (fitType == FitType.DOUBLE_FIT) { |
|
||||||
return new Dimension(this.getWidth() / 2, this.getHeight() / 2); |
|
||||||
} else if (fitType == FitType.NOT_FIT) { |
|
||||||
return new Dimension(NO_FIT_CONTAINER_DIMENSION.width / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); |
|
||||||
} else { |
|
||||||
return new Dimension(this.getWidth() / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private double calculateTextDrawStartX(int containerWidth, FontMetrics fontMetrics, String text) { |
|
||||||
return (containerWidth - fontMetrics.stringWidth(text)) / 2.0D; |
|
||||||
} |
|
||||||
|
|
||||||
private double calculateTextDrawStartY(int containerHeight) { |
|
||||||
return containerHeight / 2.0D; |
|
||||||
} |
|
||||||
|
|
||||||
public void refreshPreview(boolean fitFont, FitType fitType) { |
|
||||||
this.fitFont = fitFont; |
|
||||||
this.fitType = fitType; |
|
||||||
repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
public void refreshPreview(boolean fitFont) { |
|
||||||
this.fitFont = fitFont; |
|
||||||
repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,172 +0,0 @@ |
|||||||
package com.fr.design.report.fit; |
|
||||||
|
|
||||||
import com.fr.design.gui.ibutton.UIRadioButton; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.i18n.DesignSizeI18nManager; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.report.fit.menupane.FitRadioGroup; |
|
||||||
import com.fr.design.report.fit.menupane.FontRadioGroup; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.report.fit.ReportFitAttr; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.FlowLayout; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
|
|
||||||
import static com.fr.design.i18n.Toolkit.i18nText; |
|
||||||
|
|
||||||
public class ReportFitConfigPane extends JPanel { |
|
||||||
public FontRadioGroup fontRadioGroup; |
|
||||||
public FitRadioGroup ecConfigRadioGroup; |
|
||||||
protected NewFitPreviewPane previewJPanel; |
|
||||||
protected FitAttrModel fitAttrModel; |
|
||||||
protected boolean globalConfig; |
|
||||||
|
|
||||||
|
|
||||||
public ReportFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { |
|
||||||
this.fitAttrModel = fitAttrModel; |
|
||||||
this.globalConfig = globalConfig; |
|
||||||
initComponent(); |
|
||||||
} |
|
||||||
|
|
||||||
private void initComponent() { |
|
||||||
JPanel contentJPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(false, FlowLayout.LEFT, 0, 0); |
|
||||||
this.add(contentJPanel); |
|
||||||
fontRadioGroup = new FontRadioGroup(); |
|
||||||
ecConfigRadioGroup = new FitRadioGroup(); |
|
||||||
contentJPanel.add(initAttrJPanel()); |
|
||||||
contentJPanel.add(initPreviewJPanel()); |
|
||||||
} |
|
||||||
|
|
||||||
private JPanel initAttrJPanel() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
Component[] fontComponents = new Component[3]; |
|
||||||
initRadioGroup(fontRadioGroup, i18nText("Fine-Designer_Fit-Font"), new String[]{i18nText("Fine-Designer_Fit"), i18nText("Fine-Designer_Fit-No")}, fontComponents); |
|
||||||
jPanel.add(createSubAttrPane(fontComponents), BorderLayout.NORTH); |
|
||||||
jPanel.add(initECConfigPane(), BorderLayout.CENTER); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
protected JPanel initECConfigPane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; |
|
||||||
initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); |
|
||||||
jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected JPanel createSubAttrPane(Component[] components) { |
|
||||||
double[] rowSize = new double[]{20}; |
|
||||||
double[] columnSize = new double[components.length]; |
|
||||||
for (int i = 0; i < columnSize.length; i++) { |
|
||||||
if (i == 0) { |
|
||||||
columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth(); |
|
||||||
} else { |
|
||||||
columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.column").getWidth(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
JPanel attrJPanel = TableLayoutHelper.createTableLayoutPane(new Component[][]{components}, rowSize, columnSize); |
|
||||||
attrJPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); |
|
||||||
return attrJPanel; |
|
||||||
} |
|
||||||
|
|
||||||
protected void initRadioGroup(FitRadioGroup fitRadioGroup, String name, String[] options, Component[] components) { |
|
||||||
components[0] = new UILabel(name); |
|
||||||
for (int i = 0; i < options.length; i++) { |
|
||||||
|
|
||||||
if (options[i] != null) { |
|
||||||
UIRadioButton fontFitRadio = new UIRadioButton(options[i]); |
|
||||||
fitRadioGroup.add(fontFitRadio); |
|
||||||
components[i + 1] = fontFitRadio; |
|
||||||
} else { |
|
||||||
components[i + 1] = null; |
|
||||||
} |
|
||||||
} |
|
||||||
fitRadioGroup.addActionListener(getPreviewActionListener()); |
|
||||||
} |
|
||||||
|
|
||||||
private ActionListener getPreviewActionListener() { |
|
||||||
return new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
refreshPreviewJPanel(); |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
public void refreshPreviewJPanel(FitType fitType) { |
|
||||||
previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), fitType); |
|
||||||
} |
|
||||||
|
|
||||||
protected void refreshPreviewJPanel() { |
|
||||||
previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), FitType.parse(updateBean())); |
|
||||||
} |
|
||||||
|
|
||||||
private JPanel initPreviewJPanel() { |
|
||||||
JPanel wrapperPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
previewJPanel = new NewFitPreviewPane(); |
|
||||||
wrapperPane.add(previewJPanel, BorderLayout.CENTER); |
|
||||||
int leftIndent = globalConfig ? (int) DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth() : 0; |
|
||||||
wrapperPane.setBorder(BorderFactory.createEmptyBorder(0, leftIndent, 0, 0)); |
|
||||||
wrapperPane.setPreferredSize(new Dimension(300 + leftIndent, 204)); |
|
||||||
return wrapperPane; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void populateBean(ReportFitAttr ob) { |
|
||||||
fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1); |
|
||||||
populateECConfigRadioGroup(ob.fitStateInPC()); |
|
||||||
refreshPreviewJPanel(); |
|
||||||
} |
|
||||||
|
|
||||||
protected void populateECConfigRadioGroup(int fitStateInPC){ |
|
||||||
ecConfigRadioGroup.selectIndexButton(getOptionIndex(fitStateInPC)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr){ |
|
||||||
reportFitAttr.setFitStateInPC(getStateInPC(ecConfigRadioGroup.getSelectRadioIndex())); |
|
||||||
} |
|
||||||
|
|
||||||
public ReportFitAttr updateBean() { |
|
||||||
ReportFitAttr reportFitAttr = new ReportFitAttr(); |
|
||||||
reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); |
|
||||||
updateECConfigRadioGroup(reportFitAttr); |
|
||||||
return reportFitAttr; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected int getStateInPC(int index) { |
|
||||||
FitType[] fitTypes = fitAttrModel.getFitTypes(); |
|
||||||
if (index > fitTypes.length - 1) { |
|
||||||
return index; |
|
||||||
} |
|
||||||
return fitTypes[index].getState(); |
|
||||||
} |
|
||||||
|
|
||||||
protected int getOptionIndex(int state) { |
|
||||||
FitType[] fitTypes = fitAttrModel.getFitTypes(); |
|
||||||
for (int i = 0; i < fitTypes.length; i++) { |
|
||||||
if (ComparatorUtils.equals(state, fitTypes[i].getState())) { |
|
||||||
return i; |
|
||||||
} |
|
||||||
} |
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) { |
|
||||||
super.setEnabled(enabled); |
|
||||||
fontRadioGroup.setEnabled(enabled); |
|
||||||
ecConfigRadioGroup.setEnabled(enabled); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,85 +0,0 @@ |
|||||||
package com.fr.design.fit; |
|
||||||
|
|
||||||
import com.fr.design.actions.JTemplateAction; |
|
||||||
import com.fr.design.beans.BasicBeanPane; |
|
||||||
import com.fr.design.dialog.DialogActionAdapter; |
|
||||||
import com.fr.design.dialog.UIDialog; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.mainframe.DesignerContext; |
|
||||||
import com.fr.design.mainframe.JForm; |
|
||||||
import com.fr.design.mainframe.JTemplate; |
|
||||||
import com.fr.design.menu.MenuKeySet; |
|
||||||
import com.fr.design.report.fit.FormFitAttrModelType; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.report.fit.FitProvider; |
|
||||||
import com.fr.report.fit.ReportFitAttr; |
|
||||||
|
|
||||||
import javax.swing.KeyStroke; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
|
|
||||||
public class FormFitAttrAction extends JTemplateAction { |
|
||||||
private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { |
|
||||||
@Override |
|
||||||
public char getMnemonic() { |
|
||||||
return 'T'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getMenuName() { |
|
||||||
return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public KeyStroke getKeyStroke() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
public FormFitAttrAction(JTemplate jTemplate) { |
|
||||||
super(jTemplate); |
|
||||||
initMenuStyle(); |
|
||||||
} |
|
||||||
|
|
||||||
private void initMenuStyle() { |
|
||||||
this.setMenuKeySet(REPORT_FIT_ATTR); |
|
||||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
|
||||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
|
||||||
this.setSmallIcon("/com/fr/design/images/reportfit/fit"); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Action触发事件 |
|
||||||
* |
|
||||||
* @param e 事件 |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
final JTemplate jwb = getEditingComponent(); |
|
||||||
if (jwb == null || !(jwb.getTarget() instanceof Form)) { |
|
||||||
return; |
|
||||||
} |
|
||||||
JForm jForm = (JForm) jwb; |
|
||||||
Form wbTpl = jForm.getTarget(); |
|
||||||
ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); |
|
||||||
FormFitAttrPane formFitAttrPane = new FormFitAttrPane(jForm, FormFitAttrModelType.parse(wbTpl)); |
|
||||||
showReportFitDialog(fitAttr, jwb, wbTpl, formFitAttrPane); |
|
||||||
} |
|
||||||
|
|
||||||
private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) { |
|
||||||
attrPane.populateBean(fitAttr); |
|
||||||
UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
|
||||||
@Override |
|
||||||
public void doOk() { |
|
||||||
fireEditingOk(jwb, wbTpl, attrPane.updateBean(), fitAttr); |
|
||||||
} |
|
||||||
}, new Dimension(660, 600)); |
|
||||||
dialog.setVisible(true); |
|
||||||
} |
|
||||||
|
|
||||||
private void fireEditingOk(final JTemplate jwb, final FitProvider wbTpl, ReportFitAttr newReportFitAttr, ReportFitAttr oldReportFitAttr) { |
|
||||||
wbTpl.setReportFitAttr(newReportFitAttr); |
|
||||||
jwb.fireTargetModified(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,377 +0,0 @@ |
|||||||
package com.fr.design.fit; |
|
||||||
|
|
||||||
import com.fr.design.beans.BasicBeanPane; |
|
||||||
import com.fr.design.designer.IntervalConstants; |
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
|
||||||
import com.fr.design.designer.creator.XOccupiedLayout; |
|
||||||
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
||||||
import com.fr.design.designer.creator.XWFitLayout; |
|
||||||
import com.fr.design.designer.creator.XWScaleLayout; |
|
||||||
import com.fr.design.designer.properties.items.FRLayoutTypeItems; |
|
||||||
import com.fr.design.designer.properties.items.Item; |
|
||||||
import com.fr.design.dialog.FineJOptionPane; |
|
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.mainframe.FormDesigner; |
|
||||||
import com.fr.design.mainframe.FormSelectionUtils; |
|
||||||
import com.fr.design.mainframe.JForm; |
|
||||||
import com.fr.design.mainframe.WidgetPropertyPane; |
|
||||||
import com.fr.design.report.fit.FitType; |
|
||||||
import com.fr.design.report.fit.FormFitAttrModelType; |
|
||||||
import com.fr.design.report.fit.FormFitConfigPane; |
|
||||||
import com.fr.design.report.fit.ReportFitConfigPane; |
|
||||||
import com.fr.design.widget.FRWidgetFactory; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.form.ui.Widget; |
|
||||||
import com.fr.form.ui.container.WAbsoluteBodyLayout; |
|
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
|
||||||
import com.fr.form.ui.container.WBodyLayoutType; |
|
||||||
import com.fr.form.ui.container.WFitLayout; |
|
||||||
import com.fr.form.ui.container.WSortLayout; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.act.BorderPacker; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
import com.fr.report.fit.ReportFitAttr; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.DefaultComboBoxModel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import javax.swing.SwingConstants; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
import java.awt.event.ItemEvent; |
|
||||||
import java.awt.event.ItemListener; |
|
||||||
|
|
||||||
import static com.fr.design.i18n.Toolkit.i18nText; |
|
||||||
import static javax.swing.JOptionPane.*; |
|
||||||
|
|
||||||
public class FormFitAttrPane extends BasicBeanPane<ReportFitAttr> { |
|
||||||
|
|
||||||
private UIComboBox layoutComboBox; |
|
||||||
private UIComboBox scaleComboBox; |
|
||||||
private FormFitAttrModelType fitAttrModelType; |
|
||||||
|
|
||||||
protected UIComboBox itemChoose; |
|
||||||
|
|
||||||
private JForm jForm; |
|
||||||
private ReportFitConfigPane fitConfigPane; |
|
||||||
|
|
||||||
public FormFitAttrPane(JForm jForm, FormFitAttrModelType fitAttrModelType) { |
|
||||||
this.fitAttrModelType = fitAttrModelType; |
|
||||||
this.jForm = jForm; |
|
||||||
initComponents(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private void initComponents() { |
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
this.setBorder(BorderFactory.createEmptyBorder(12, 5, 0, 5)); |
|
||||||
this.add(createReportFitSettingPane(), BorderLayout.CENTER); |
|
||||||
this.add(createReportLayoutSettingPane(), BorderLayout.NORTH); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private JPanel createReportLayoutSettingPane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Layout")); |
|
||||||
jPanel.add(createAreaScalePane(), BorderLayout.CENTER); |
|
||||||
jPanel.setPreferredSize(new Dimension(640, 84)); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
protected String[] getItemNames() { |
|
||||||
return new String[]{Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings"), |
|
||||||
Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single")}; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private JPanel createReportFitSettingPane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Content_Attr")); |
|
||||||
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
jPanel.add(contentPane, BorderLayout.CENTER); |
|
||||||
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Settings")); |
|
||||||
label.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
|
||||||
contentPane.add(label, BorderLayout.WEST); |
|
||||||
label.setPreferredSize(new Dimension(100, 0)); |
|
||||||
label.setVerticalAlignment(SwingConstants.TOP); |
|
||||||
itemChoose = new UIComboBox(getItemNames()); |
|
||||||
itemChoose.setPreferredSize(new Dimension(160, 20)); |
|
||||||
Form form = jForm.getTarget(); |
|
||||||
itemChoose.addItemListener(new ItemListener() { |
|
||||||
@Override |
|
||||||
public void itemStateChanged(ItemEvent e) { |
|
||||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
||||||
if (isTemplateSingleSet()) { |
|
||||||
if (form != null) { |
|
||||||
ReportFitAttr fitAttr = form.getReportFitAttr(); |
|
||||||
populate(fitAttr); |
|
||||||
} |
|
||||||
} else { |
|
||||||
populate(fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
JPanel centerPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); |
|
||||||
centerPane.add(itemChoose); |
|
||||||
centerPane.add(fitConfigPane = new FormFitConfigPane(this.fitAttrModelType.getFitAttrModel())); |
|
||||||
contentPane.add(centerPane, BorderLayout.CENTER); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
public void populate(ReportFitAttr reportFitAttr) { |
|
||||||
if (reportFitAttr == null) { |
|
||||||
reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); |
|
||||||
} |
|
||||||
|
|
||||||
this.setEnabled(isTemplateSingleSet()); |
|
||||||
fitConfigPane.populateBean(reportFitAttr); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public ReportFitAttr updateBean() { |
|
||||||
updateLayoutType(); |
|
||||||
if (!isTemplateSingleSet()) { |
|
||||||
return null; |
|
||||||
} else { |
|
||||||
return fitConfigPane.updateBean(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void updateLayoutType() { |
|
||||||
XLayoutContainer xLayoutContainer = this.jForm.getRootComponent(); |
|
||||||
if (xLayoutContainer == null || !xLayoutContainer.acceptType(XWFitLayout.class)) { |
|
||||||
return; |
|
||||||
} |
|
||||||
XWFitLayout xwFitLayout = (XWFitLayout) xLayoutContainer; |
|
||||||
WFitLayout wFitLayout = xwFitLayout.toData(); |
|
||||||
int state = layoutComboBox.getSelectedIndex(); |
|
||||||
WBodyLayoutType selectType = WBodyLayoutType.parse(state); |
|
||||||
if (selectType != wFitLayout.getBodyLayoutType()) { |
|
||||||
wFitLayout.setLayoutType(selectType); |
|
||||||
//从自适应布局切换到绝对布局
|
|
||||||
if (selectType == WBodyLayoutType.ABSOLUTE) { |
|
||||||
switchLayoutFromFit2Absolute(xwFitLayout); |
|
||||||
} else { |
|
||||||
//从绝对布局切换到自适应布局
|
|
||||||
switchLayoutFromAbsolute2Fit(xwFitLayout); |
|
||||||
} |
|
||||||
} |
|
||||||
wFitLayout.setCompatibleScaleAttr(fitAttrModelType.parseScaleAttrFromShowIndex(this.scaleComboBox.getSelectedIndex(), wFitLayout.getBodyLayoutType())); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private void switchLayoutFromFit2Absolute(XWFitLayout xWFitLayout) { |
|
||||||
try { |
|
||||||
WFitLayout layout = xWFitLayout.toData(); |
|
||||||
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); |
|
||||||
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); |
|
||||||
// 切换布局类型时,保留body背景样式
|
|
||||||
wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); |
|
||||||
wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone())); |
|
||||||
Component[] components = xWFitLayout.getComponents(); |
|
||||||
Rectangle[] backupBounds = getBackupBoundsFromFitLayout(xWFitLayout); |
|
||||||
xWFitLayout.removeAll(); |
|
||||||
layout.resetStyle(); |
|
||||||
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); |
|
||||||
xWFitLayout.setFixLayout(false); |
|
||||||
xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); |
|
||||||
for (int i = 0; i < components.length; i++) { |
|
||||||
XCreator xCreator = (XCreator) components[i]; |
|
||||||
xCreator.setBounds(backupBounds[i]); |
|
||||||
//部分控件被ScaleLayout包裹着,绝对布局里面要放出来
|
|
||||||
if (xCreator.acceptType(XWScaleLayout.class)) { |
|
||||||
if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { |
|
||||||
Component component = xCreator.getComponent(0); |
|
||||||
component.setBounds(xCreator.getBounds()); |
|
||||||
} |
|
||||||
} |
|
||||||
if (!xCreator.acceptType(XOccupiedLayout.class)) { |
|
||||||
xwAbsoluteBodyLayout.add(xCreator); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
copyLayoutAttr(layout, xwAbsoluteBodyLayout.toData()); |
|
||||||
xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); |
|
||||||
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
|
||||||
formDesigner.getSelectionModel().setSelectedCreators( |
|
||||||
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); |
|
||||||
if (xwAbsoluteBodyLayout.toData() != null) { |
|
||||||
xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); |
|
||||||
xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); |
|
||||||
} |
|
||||||
xwAbsoluteBodyLayout.refreshStylePreviewEffect(); |
|
||||||
if (xWFitLayout.toData() != null) { |
|
||||||
xWFitLayout.toData().resetStyle(); |
|
||||||
} |
|
||||||
xWFitLayout.refreshStylePreviewEffect(); |
|
||||||
formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); |
|
||||||
} catch (Exception e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private Rectangle[] getBackupBoundsFromFitLayout(XWFitLayout xWFitLayout) { |
|
||||||
int count = xWFitLayout.getComponentCount(); |
|
||||||
Rectangle[] rectangles = new Rectangle[count]; |
|
||||||
for (int i = 0; i < count; i++) { |
|
||||||
rectangles[i] = xWFitLayout.getComponent(i).getBounds(); |
|
||||||
} |
|
||||||
return rectangles; |
|
||||||
} |
|
||||||
|
|
||||||
protected void copyLayoutAttr(WSortLayout srcLayout, WSortLayout destLayout) { |
|
||||||
destLayout.clearListeners(); |
|
||||||
destLayout.clearMobileWidgetList(); |
|
||||||
for (int i = 0, len = srcLayout.getMobileWidgetListSize(); i < len; i++) { |
|
||||||
destLayout.addMobileWidget(srcLayout.getMobileWidget(i)); |
|
||||||
} |
|
||||||
destLayout.setSorted(true); |
|
||||||
for (int i = 0, len = srcLayout.getListenerSize(); i < len; i++) { |
|
||||||
destLayout.addListener(srcLayout.getListener(i)); |
|
||||||
} |
|
||||||
srcLayout.clearListeners(); |
|
||||||
srcLayout.clearMobileWidgetList(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private void switchLayoutFromAbsolute2Fit(XWFitLayout xwFitLayout) { |
|
||||||
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = getAbsoluteBodyLayout(xwFitLayout); |
|
||||||
if (xwAbsoluteBodyLayout == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
WAbsoluteBodyLayout layout = xwAbsoluteBodyLayout.toData(); |
|
||||||
WFitLayout wFitLayout = xwFitLayout.toData(); |
|
||||||
wFitLayout.resetStyle(); |
|
||||||
xwFitLayout.switch2FitBodyLayout(xwAbsoluteBodyLayout); |
|
||||||
// 切换布局类型时,保留body背景样式
|
|
||||||
if (wFitLayout != null) { |
|
||||||
wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); |
|
||||||
wFitLayout.setBorderStyle(layout.getBorderStyle()); |
|
||||||
} |
|
||||||
copyLayoutAttr(layout, xwFitLayout.toData()); |
|
||||||
|
|
||||||
copyLayoutAttr(layout, xwFitLayout.toData()); |
|
||||||
xwFitLayout.refreshStylePreviewEffect(); |
|
||||||
} |
|
||||||
|
|
||||||
private XWAbsoluteBodyLayout getAbsoluteBodyLayout(XWFitLayout xwFitLayout) { |
|
||||||
if (xwFitLayout != null && xwFitLayout.getComponentCount() > 0) { |
|
||||||
Component component = xwFitLayout.getComponent(0); |
|
||||||
if (component instanceof XWAbsoluteBodyLayout) { |
|
||||||
return (XWAbsoluteBodyLayout) component; |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
private JPanel createAreaScalePane() { |
|
||||||
initLayoutComboBox(); |
|
||||||
|
|
||||||
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); |
|
||||||
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Scale_Setting")); |
|
||||||
Component[][] components = new Component[][]{ |
|
||||||
{layoutTypeLabel, layoutComboBox}, |
|
||||||
{scaleModeLabel, scaleComboBox} |
|
||||||
}; |
|
||||||
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, |
|
||||||
TableLayoutHelper.FILL_LASTCOLUMN, 20, IntervalConstants.INTERVAL_L1); |
|
||||||
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
containerPane.add(contentPane, BorderLayout.CENTER); |
|
||||||
|
|
||||||
return containerPane; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void initLayoutComboBox() { |
|
||||||
Item[] items = FRLayoutTypeItems.ITEMS; |
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
|
||||||
for (Item item : items) { |
|
||||||
model.addElement(item); |
|
||||||
} |
|
||||||
scaleComboBox = new UIComboBox(model); |
|
||||||
scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); |
|
||||||
layoutComboBox = new UIComboBox(model); |
|
||||||
layoutComboBox.setPreferredSize(new Dimension(160, 20)); |
|
||||||
scaleComboBox.setPreferredSize(new Dimension(160, 20)); |
|
||||||
WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); |
|
||||||
layoutComboBox.addActionListener(new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
int selectIndex = layoutComboBox.getSelectedIndex(); |
|
||||||
if (selectIndex == 0) { |
|
||||||
if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.ABSOLUTE) { |
|
||||||
int selVal = FineJOptionPane.showConfirmDialog( |
|
||||||
FormFitAttrPane.this, |
|
||||||
Toolkit.i18nText("Fine-Design_Form_Layout_Switch_Tip"), |
|
||||||
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
|
||||||
OK_CANCEL_OPTION, |
|
||||||
WARNING_MESSAGE |
|
||||||
); |
|
||||||
if (OK_OPTION != selVal) { |
|
||||||
layoutComboBox.setSelectedIndex(1); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); |
|
||||||
} else { |
|
||||||
scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getAbsoluteLayoutSaleAttr())); |
|
||||||
} |
|
||||||
scaleComboBox.setSelectedIndex(0); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
scaleComboBox.addActionListener(new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
WBodyLayoutType selectBodyType = WBodyLayoutType.parse(layoutComboBox.getSelectedIndex()); |
|
||||||
int state = fitAttrModelType.parseScaleAttrFromShowIndex(scaleComboBox.getSelectedIndex(), selectBodyType); |
|
||||||
fitConfigPane.refreshPreviewJPanel(FitType.parseByFitState(state)); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void populateBean(ReportFitAttr reportFitAttr) { |
|
||||||
WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); |
|
||||||
layoutComboBox.setSelectedIndex(wFitLayout.getBodyLayoutType().getTypeValue()); |
|
||||||
scaleComboBox.setSelectedIndex(fitAttrModelType.getScaleAttrShowIndex(wFitLayout)); |
|
||||||
|
|
||||||
if (reportFitAttr == null) { |
|
||||||
itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings")); |
|
||||||
} else { |
|
||||||
itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single")); |
|
||||||
} |
|
||||||
if (reportFitAttr == null) { |
|
||||||
reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); |
|
||||||
} |
|
||||||
setEnabled(isTemplateSingleSet()); |
|
||||||
fitConfigPane.populateBean(reportFitAttr); |
|
||||||
} |
|
||||||
|
|
||||||
private boolean isTemplateSingleSet() { |
|
||||||
return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem()); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) { |
|
||||||
super.setEnabled(enabled); |
|
||||||
fitConfigPane.setEnabled(enabled); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String title4PopupWindow() { |
|
||||||
return i18nText("Fine-Designer_PC_Fit_Attr"); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
Loading…
Reference in new issue