diff --git a/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProcessor.java b/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProcessor.java deleted file mode 100644 index 21866a2c32..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProcessor.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fr.design.fun; - -import com.fr.stable.fun.ReportFitAttrProvider; -import com.fr.stable.fun.mark.Immutable; - -import java.beans.PropertyDescriptor; - -/** - * Created by Slpire on 2016/10/28. - */ -public interface FormElementCaseEditorProcessor extends Immutable { - String MARK_STRING = "PropertyEditor"; - - int CURRENT_LEVEL = 1; - - - /** - * 生成属性表 - * @param temp 传入当前操作的class - * @param reportFitAttr 传入的自适应属性 - * @return 返回属性表 - */ - PropertyDescriptor[] createPropertyDescriptor(Class temp, ReportFitAttrProvider reportFitAttr); - - /** - * 返回pc自适应属性值 - * @param fitAttrProvider 传入的自适应属性 - * @return 返回pc自适应属性值 - */ - int getFitStateInPC(ReportFitAttrProvider fitAttrProvider); -} diff --git a/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java b/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java index 92a1a835f4..70aeadd13a 100644 --- a/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java @@ -2,7 +2,6 @@ package com.fr.design.fun; import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditorProvider; -import com.fr.stable.fun.ReportFitAttrProvider; import com.fr.stable.fun.mark.Mutable; import java.beans.PropertyDescriptor; @@ -18,18 +17,4 @@ public interface FormElementCaseEditorProvider extends Mutable { PropertyDescriptor[] createPropertyDescriptor(Class temp, FormProvider formProvider, ElementCaseEditorProvider editor); - /** - * 生成属性表 - * @param temp 传入当前操作的class - * @param reportFitAttr 传入的自适应属性 - * @return 返回属性表 - */ - PropertyDescriptor[] createPropertyDescriptor(Class temp, ReportFitAttrProvider reportFitAttr); - - /** - * 返回pc自适应属性值 - * @param fitAttrProvider 传入的自适应属性 - * @return 返回pc自适应属性值 - */ - int getFitStateInPC(ReportFitAttrProvider fitAttrProvider); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProcessor.java deleted file mode 100644 index 08a5a1606f..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProcessor.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.fr.design.fun.impl; - -import com.fr.design.fun.FormElementCaseEditorProcessor; -import com.fr.stable.fun.ReportFitAttrProvider; -import com.fr.stable.fun.mark.API; - -import java.beans.PropertyDescriptor; - -/** - * Created by zhouping on 2015/9/10. - */ -@API(level = FormElementCaseEditorProcessor.CURRENT_LEVEL) -public abstract class AbstractFormElementCaseEditorProcessor implements FormElementCaseEditorProcessor { - - public int currentAPILevel() { - return CURRENT_LEVEL; - } - - public int layerIndex() { - return DEFAULT_LAYER_INDEX; - } - - - /** - * 生成属性表 - * @param temp 传入当前操作的class - * @param reportFitAttr 传入的自适应属性 - * @return 返回属性表 - */ - @Override - public PropertyDescriptor[] createPropertyDescriptor(Class temp, ReportFitAttrProvider reportFitAttr) { - return new PropertyDescriptor[0]; - } - - /** - * 返回pc自适应属性值 - * @param fitAttrProvider 传入的自适应属性 - * @return 返回pc自适应属性值 - */ - @Override - public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) { - return 0; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java index 8764eaf898..5098894e04 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java @@ -3,7 +3,6 @@ package com.fr.design.fun.impl; import com.fr.design.fun.FormElementCaseEditorProvider; import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditorProvider; -import com.fr.stable.fun.ReportFitAttrProvider; import com.fr.stable.fun.mark.API; import java.beans.PropertyDescriptor; @@ -28,24 +27,4 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme return new PropertyDescriptor[0]; } - /** - * 生成属性表 - * @param temp 传入当前操作的class - * @param reportFitAttr 传入的自适应属性 - * @return 返回属性表 - */ - @Override - public PropertyDescriptor[] createPropertyDescriptor(Class temp, ReportFitAttrProvider reportFitAttr) { - return new PropertyDescriptor[0]; - } - - /** - * 返回pc自适应属性值 - * @param fitAttrProvider 传入的自适应属性 - * @return 返回pc自适应属性值 - */ - @Override - public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) { - return 0; - } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/reportfit/FitType.java b/designer-base/src/main/java/com/fr/design/reportfit/FitType.java new file mode 100644 index 0000000000..6b342240dd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/FitType.java @@ -0,0 +1,76 @@ +package com.fr.design.reportfit; + +import com.fr.design.designer.properties.items.Item; +import com.fr.report.reportfit.ReportFitAttr; +import com.fr.stable.StringUtils; + +/** + * Created by Administrator on 2016/4/13/0013. + */ +public enum FitType { + DEFAULT(0) { + @Override + public String description() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Default"); + } + + }, + // 横向自适应, 纵向根据横向的比例来适配 + HORIZONTAL_FIT(1) { + @Override + public String description() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal"); + } + }, + // 双向自适应, 横纵向都是根据页面宽高来计算 + DOUBLE_FIT(2) { + @Override + public String description() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal_Vertical"); + } + }, + + NOT_FIT(3) { + @Override + public String description() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"); + } + }; + + + private int state; + + + FitType(int state) { + this.state = state; + } + + public static FitType parse(ReportFitAttr attr) { + + if (attr == null) { + return DEFAULT; + } + + for (FitType attrState : values()) { + if (attrState.state == attr.fitStateInPC()) { + return attrState; + } + } + + return DEFAULT; + } + + public int getState() { + return this.state; + } + + + public String description() { + return StringUtils.EMPTY; + } + + public Item propertyItem() { + return new Item(this.description(), this.getState()); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/BrowserFitAttrPane.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/BrowserFitAttrPane.java new file mode 100644 index 0000000000..470a2101bb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/BrowserFitAttrPane.java @@ -0,0 +1,231 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.reportfit.FitType; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.log.FineLoggerFactory; +import com.fr.report.reportfit.ReportFitAttr; +import com.fr.reportfit.ReportFitConfig; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * Created by Administrator on 2016/5/5/0005. + */ +public class BrowserFitAttrPane extends BasicBeanPane { + + protected FontRadioGroup fontRadioGroup; + protected FitRadioGroup fitRadionGroup; + protected UICheckBox globalCheck; + protected FitPreviewPane fitPreviewPane; + protected ReportFitAttr localFitAttr; + protected UIRadioButton defaultRadio; + protected UIRadioButton horizonRadio; + protected UIRadioButton doubleRadio; + protected UIRadioButton notFitRadio; + protected UIRadioButton fontFitRadio; + protected UIRadioButton fontNotFitRadio; + private UIButton editGlobalOps; + private JPanel borderPane; + private JPanel globalOpsPane; + private JPanel fitOpsPane; + + public BrowserFitAttrPane() { + initComponents(ReportFitConfig.getInstance().getFrmFitAttr()); + } + + protected void initComponents(ReportFitAttr globalFitAttr) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + globalOpsPane = initGlobalOpsPane(globalFitAttr); + this.add(globalOpsPane, BorderLayout.NORTH); + fitOpsPane = initFitOpsPane(); + + } + + protected void initBorderPane(String title) { + borderPane = FRGUIPaneFactory.createTitledBorderPaneCenter(title); + borderPane.add(fitOpsPane, BorderLayout.CENTER); + fitPreviewPane = new FitPreviewPane(); + borderPane.add(fitPreviewPane, BorderLayout.SOUTH); + this.add(borderPane, BorderLayout.CENTER); + } + + private JPanel initFitOpsPane() { + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p, p, p, p}; + + ActionListener actionListener = getPreviewActionListener(); + + fontRadioGroup = new FontRadioGroup(); + fontFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit")); + fontFitRadio.setSelected(true); + fontNotFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No")); + addRadioToGroup(fontRadioGroup, fontFitRadio, fontNotFitRadio); + fontRadioGroup.addActionListener(actionListener); + + fitRadionGroup = new FitRadioGroup(); + defaultRadio = new UIRadioButton(FitType.DEFAULT.description()); + horizonRadio = new UIRadioButton(FitType.HORIZONTAL_FIT.description()); + doubleRadio = new UIRadioButton(FitType.DOUBLE_FIT.description()); + notFitRadio = new UIRadioButton(FitType.NOT_FIT.description()); + addRadioToGroup(fitRadionGroup, defaultRadio, horizonRadio, doubleRadio, notFitRadio); + fitRadionGroup.addActionListener(actionListener); + + + JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(initFitComponents(), rowSize, columnSize); + fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); + return fitOpsPane; + } + + protected Component[][] initFitComponents() { + Component[][] components = new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), defaultRadio, horizonRadio, doubleRadio, notFitRadio} + }; + return components; + } + + private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) { + for (UIRadioButton radio : radios) { + buttonGroup.add(radio); + } + } + + private JPanel initGlobalOpsPane(final ReportFitAttr globalFitAttr) { + final JPanel globalOpsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + globalCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-UseGlobal")); + globalOpsPane.add(globalCheck); + globalCheck.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean isLocalConfig = !globalCheck.isSelected(); + //勾选全局时,采用全局保存的自适应属性更新界面 + if (!isLocalConfig) { + ReportFitAttr attr = globalFitAttr; + fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont()); + fitRadionGroup.selectIndexButton(attr.fitStateInPC()); + fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); + remove(BrowserFitAttrPane.this.borderPane); + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global")); + } else { + ReportFitAttr attr = localFitAttr; + fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont()); + fitRadionGroup.selectIndexButton(attr.fitStateInPC()); + fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); + remove(BrowserFitAttrPane.this.borderPane); + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); + } + fontRadioGroup.setEnabled(isLocalConfig); + fitRadionGroup.setEnabled(isLocalConfig); + editGlobalOps.setVisible(!isLocalConfig); + String fitOptions = getCurrentFitOptions(); + fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled()); + } + }); + + editGlobalOps = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-EditGlobal")); + editGlobalOps.setVisible(false); + editGlobalOps.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent evt) { + fontRadioGroup.setEnabled(true); + fitRadionGroup.setEnabled(true); + String fitOptions = getCurrentFitOptions(); + + fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled()); + } + + public void mouseEntered(MouseEvent e) { + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + public void mouseExited(MouseEvent e) { + setCursor(Cursor.getDefaultCursor()); + } + }); + globalOpsPane.add(editGlobalOps); + return globalOpsPane; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-AttrSet"); + } + + @Override + public void populateBean(ReportFitAttr attr) { + if (attr == null) { + //如果为空, 就用全局的 + attr = ReportFitConfig.getInstance().getFrmFitAttr(); + populateGlobalComponents(); + } else { + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); + } + this.localFitAttr = attr; + fontRadioGroup.selectFontFit((attr).isFitFont()); + fitRadionGroup.selectIndexButton(attr.fitStateInPC()); + fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); + } + + protected void populateGlobalComponents() { + globalCheck.setSelected(true); + fontRadioGroup.setEnabled(false); + fitRadionGroup.setEnabled(false); + editGlobalOps.setVisible(true); + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global")); + } + + //有八种组合, 不过有意义的就是6种, 以此为key去缓存里找对应的预览图片 + public String getCurrentFitOptions() { + return fitRadionGroup.getSelectRadioIndex() + "" + fontRadioGroup.getSelectRadioIndex(); + } + + private ActionListener getPreviewActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String fitOptions = getCurrentFitOptions(); + fitPreviewPane.refreshPreview(fitOptions, fontRadioGroup.isEnabled()); + } + }; + } + + @Override + public ReportFitAttr updateBean() { + ReportFitAttr attr = new ReportFitAttr(); + attr.setFitFont(fontRadioGroup.isFontFit()); + attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex()); + + // 直接用全局的 + if (globalCheck.isSelected()) { + updateGlobalConfig(attr); + return null; + } + this.localFitAttr = attr; + return attr; + } + + private void updateGlobalConfig(ReportFitAttr attr) { + try { + ReportFitConfig manager = ReportFitConfig.getInstance(); + manager.setFrmFitAttr(attr); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitPreviewPane.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitPreviewPane.java new file mode 100644 index 0000000000..fe6232c889 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitPreviewPane.java @@ -0,0 +1,74 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.IOUtils; + +import javax.swing.ImageIcon; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Administrator on 2016/5/5/0005. + */ +public class FitPreviewPane extends BasicPane { + private static final String DEFAULT_FONT_TAG = "00"; + private static final String DEFAULT_TAG = "01"; + private static final String HORIZON_FONT_TAG = "10"; + private static final String HORIZON_TAG = "11"; + private static final String DOUBLE_FONT_TAG = "20"; + private static final String DOUBLE_TAG = "21"; + private static final String NOT_FONT_TAG = "30"; + private static final String NOT_TAG = "31"; + + private UILabel imageLabel; + private Map cachedPreviewImage = new HashMap(); + private Map globalCachedPreviewImage = new HashMap(); + + public FitPreviewPane() { + //初始化缓存图片, 有些无意义的组合. + initCacheImage(); + //初始化组件 + initComponents(); + } + + //默认和不自适应时,字体自适应不起效,只有6张图 + private void initCacheImage() { + globalCachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png"))); + globalCachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png"))); + globalCachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_FONT_TAG + ".png"))); + globalCachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_TAG + ".png"))); + globalCachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_FONT_TAG + ".png"))); + globalCachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_TAG + ".png"))); + globalCachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png"))); + globalCachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png"))); + cachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png"))); + cachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png"))); + cachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_FONT_TAG + ".png"))); + cachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_TAG + ".png"))); + cachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_FONT_TAG + ".png"))); + cachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_TAG + ".png"))); + cachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png"))); + cachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png"))); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + imageLabel = new UILabel(); + imageLabel.setIcon(cachedPreviewImage.get(DEFAULT_TAG)); + this.add(imageLabel); + } + + public void refreshPreview(String index, boolean isEditedable) { + ImageIcon newImageIcon = isEditedable ? cachedPreviewImage.get(index) : globalCachedPreviewImage.get(index); + imageLabel.setIcon(newImageIcon); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Preview"); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitRadioGroup.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitRadioGroup.java new file mode 100644 index 0000000000..363ee64f70 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FitRadioGroup.java @@ -0,0 +1,80 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.gui.ibutton.UIRadioButton; + +import javax.swing.AbstractButton; +import javax.swing.ButtonGroup; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * 自适应四个按钮选项的group + *

+ * Created by Administrator on 2016/5/5/0005. + */ +public class FitRadioGroup extends ButtonGroup { + + private List radioButtons = new ArrayList(); + + @Override + public void add(AbstractButton button) { + super.add(button); + + UIRadioButton radioButton = (UIRadioButton) button; + radioButtons.add(radioButton); + } + + /** + * 设置按钮状态 + */ + public boolean isEnabled() { + return radioButtons.get(0).isEnabled(); + } + + /** + * 设置按钮状态 + */ + public void setEnabled(boolean enabled) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.setEnabled(enabled); + } + } + + /** + * 获取当前选中的按钮index + * + * @return 按钮index + */ + public int getSelectRadioIndex() { + for (int i = 0, len = radioButtons.size(); i < len; i++) { + if (radioButtons.get(i).isSelected()) { + return i; + } + } + + return 0; + } + + /** + * 选中指定index的按钮 + */ + public void selectIndexButton(int index) { + if (index < 0 || index > radioButtons.size() - 1) { + return; + } + + UIRadioButton button = radioButtons.get(index); + button.setSelected(true); + } + + /** + * 给所有的按钮加上监听 + */ + public void addActionListener(ActionListener actionListener) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/FontRadioGroup.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FontRadioGroup.java new file mode 100644 index 0000000000..f0c313b5cd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/FontRadioGroup.java @@ -0,0 +1,17 @@ +package com.fr.design.reportfit.menupane; + +/** + * 字体的两个选项组成的group + *

+ * Created by Administrator on 2016/5/5/0005. + */ +public class FontRadioGroup extends FitRadioGroup { + + public void selectFontFit(boolean isFontFit) { + selectIndexButton(isFontFit ? 0 : 1); + } + + public boolean isFontFit() { + return getSelectRadioIndex() == 0; + } +} diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrAction.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrAction.java new file mode 100644 index 0000000000..dc41879565 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrAction.java @@ -0,0 +1,107 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.base.BaseUtils; +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.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.MenuKeySet; +import com.fr.report.reportfit.FitProvider; +import com.fr.report.reportfit.ReportFitAttr; + +import javax.swing.KeyStroke; +import java.awt.Dimension; +import java.awt.event.ActionEvent; + +/** + * Created by Administrator on 2015/7/6 0006. + */ +public class ReportFitAttrAction extends JTemplateAction { + private static final Dimension MEDIUM = new Dimension(430, 400); + private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'T'; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Template"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + private static final MenuKeySet REPORT_FIT_ATTR_ELEMENTCASE = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'T'; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Elementcase"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + public ReportFitAttrAction(JTemplate jTemplate) { + super(jTemplate); + initMenuStyle(); + } + + private void initMenuStyle() { + JTemplate jTemplate = getEditingComponent(); + if (jTemplate.isJWorkBook()) { + this.setMenuKeySet(REPORT_FIT_ATTR); + } else { + this.setMenuKeySet(REPORT_FIT_ATTR_ELEMENTCASE); + } + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/reportfit/fit.png")); + } + + /** + * Action触发事件 + * + * @param e 事件 + */ + public void actionPerformed(ActionEvent e) { + final JTemplate jwb = getEditingComponent(); + if (jwb == null) { + return; + } + final FitProvider wbTpl = (FitProvider) jwb.getTarget(); + ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); + if (jwb.isJWorkBook()) { + final TemplateFitAttrPane attrPane = new TemplateFitAttrPane(); + showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); + } else { + final ReportFitAttrPane attrPane = new ReportFitAttrPane(); + showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); + } + } + + private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { + attrPane.populateBean(fitAttr); + UIDialog dialog = attrPane.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + wbTpl.setReportFitAttr(attrPane.updateBean()); + jwb.fireTargetModified(); + } + }); + dialog.setSize(MEDIUM); + dialog.setVisible(true); + } + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrPane.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrPane.java new file mode 100644 index 0000000000..983ff21ab2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/ReportFitAttrPane.java @@ -0,0 +1,56 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.report.reportfit.ReportFitAttr; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; + +/** + * Created by Administrator on 2015/7/6 0006. + */ +public class ReportFitAttrPane extends BasicBeanPane { + + private BrowserFitAttrPane attrPane; + + + public ReportFitAttrPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + attrPane = new BrowserFitAttrPane(); + this.add(attrPane); + + } + + /** + * 展示界面 + * + * @param fitAttr 自适应属性 + */ + public void populateBean(ReportFitAttr fitAttr) { + attrPane.populateBean(fitAttr); + } + + /** + * 提交数据 + * + * @return 界面上的更新数据 + */ + public ReportFitAttr updateBean() { + return attrPane.updateBean(); + } + + /** + * 标题 + * + * @return 标题 + */ + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); + } + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateBrowserFitAttrPane.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateBrowserFitAttrPane.java new file mode 100644 index 0000000000..de8108ace3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateBrowserFitAttrPane.java @@ -0,0 +1,76 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.log.FineLoggerFactory; +import com.fr.report.reportfit.ReportFitAttr; +import com.fr.reportfit.ReportFitConfig; + +import java.awt.Component; + +/** + * Created by 夏翔 on 2016/6/24. + */ +public class TemplateBrowserFitAttrPane extends BrowserFitAttrPane { + + public TemplateBrowserFitAttrPane() { + initComponents(ReportFitConfig.getInstance().getCptFitAttr()); + } + + + @Override + protected Component[][] initFitComponents() { + Component[][] components = new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), horizonRadio, doubleRadio, notFitRadio} + }; + return components; + } + + @Override + public void populateBean(ReportFitAttr attr) { + //模板界面,自适应选项去掉了默认,这边的判断为了兼容之前的设置 + if (attr != null && attr.fitStateInPC() == 0) { + attr.setFitStateInPC(3); + } + ReportFitAttr fitAttr = ReportFitConfig.getInstance().getCptFitAttr(); + if (attr == null) { + //如果为空, 就用全局的 + attr = fitAttr; + populateGlobalComponents(); + } else if (fitAttr.fitStateInPC() == 0) { + attr = new ReportFitAttr(); + attr.setFitStateInPC(3); + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); + } else { + initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); + } + this.localFitAttr = attr; + fontRadioGroup.selectFontFit((attr).isFitFont()); + fitRadionGroup.selectIndexButton(attr.fitStateInPC()); + fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); + } + + @Override + public ReportFitAttr updateBean() { + ReportFitAttr attr = new ReportFitAttr(); + attr.setFitFont(fontRadioGroup.isFontFit()); + attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex()); + + // 直接用全局的 + if (globalCheck.isSelected()) { + updateGlobalConfig(attr); + return null; + } + this.localFitAttr = attr; + return attr; + } + + private void updateGlobalConfig(ReportFitAttr attr) { + try { + ReportFitConfig manager = ReportFitConfig.getInstance(); + manager.setCptFitAttr(attr); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateFitAttrPane.java b/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateFitAttrPane.java new file mode 100644 index 0000000000..e78259af6f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/reportfit/menupane/TemplateFitAttrPane.java @@ -0,0 +1,55 @@ +package com.fr.design.reportfit.menupane; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.report.reportfit.ReportFitAttr; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; + +/** + * Created by 夏翔 on 2016/6/24. + */ +public class TemplateFitAttrPane extends BasicBeanPane { + private TemplateBrowserFitAttrPane attrPane; + + + public TemplateFitAttrPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + attrPane = new TemplateBrowserFitAttrPane(); + this.add(attrPane); + + } + + /** + * 展示界面 + * + * @param fitAttr 自适应属性 + */ + public void populateBean(ReportFitAttr fitAttr) { + attrPane.populateBean(fitAttr); + } + + + /** + * 提交数据 + * + * @return 界面上的更新数据 + */ + public ReportFitAttr updateBean() { + return attrPane.updateBean(); + } + + /** + * 标题 + * + * @return 标题 + */ + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 240176eef7..77173cebb5 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -65,12 +65,12 @@ public class DesignUtils { * @return 启动了返回true */ public static boolean isStarted() { - try { - new Socket("localhost", port); - return true; - } catch (Exception exp) { - - } +// try { +// new Socket("localhost", port); +// return true; +// } catch (Exception exp) { +// +// } return false; } diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/fit.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/fit.png new file mode 100644 index 0000000000..9f6dd87b94 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/fit.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/00.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/00.png new file mode 100644 index 0000000000..58033c96a2 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/00.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/10.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/10.png new file mode 100644 index 0000000000..4b8cf56c22 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/10.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/11.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/11.png new file mode 100644 index 0000000000..e949933f0c Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/11.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/20.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/20.png new file mode 100644 index 0000000000..7a39d66d58 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/20.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/21.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/21.png new file mode 100644 index 0000000000..b8165ae99c Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/21.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/30.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/30.png new file mode 100644 index 0000000000..c2e6267289 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/30.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/00.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/00.png new file mode 100644 index 0000000000..cc90692cca Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/00.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/10.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/10.png new file mode 100644 index 0000000000..603b9dbcda Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/10.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/11.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/11.png new file mode 100644 index 0000000000..68a63b0423 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/11.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/20.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/20.png new file mode 100644 index 0000000000..ac11df1caf Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/20.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/21.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/21.png new file mode 100644 index 0000000000..97234d0d6d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/21.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/30.png b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/30.png new file mode 100644 index 0000000000..c6f452a8a0 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/reportfit/preview/gray/30.png differ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index 1797ce9fbd..1b30af7719 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -4,7 +4,6 @@ import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.properties.mobile.ElementCasePropertyUI; import com.fr.design.form.util.XCreatorConstants; -import com.fr.design.fun.FormElementCaseEditorProcessor; import com.fr.design.fun.FormElementCaseEditorProvider; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; @@ -13,17 +12,18 @@ import com.fr.design.mainframe.*; import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.design.mainframe.widget.propertypane.BrowserFitPropertyEditor; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.report.reportfit.ReportFitAttr; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.stable.fun.FitProvider; -import com.fr.stable.fun.ReportFitAttrProvider; +import com.fr.report.reportfit.FitProvider; import javax.swing.*; import java.awt.*; @@ -104,35 +104,39 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class) .setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") + + }; CRPropertyDescriptor[] extraTableEditor = getExtraTableEditor(); - return (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraTableEditor); + return ArrayUtils.addAll(propertyTableEditor, extraTableEditor); } + public CRPropertyDescriptor[] getExtraTableEditor(){ CRPropertyDescriptor[] extraTableEditor = resolveCompatible(); - FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(FormElementCaseEditorProcessor.MARK_STRING); - if (processor == null) { - return extraTableEditor; - } + return ArrayUtils.addAll(extraTableEditor, new CRPropertyDescriptor[] {getReportFitEditor()}); + } + + private CRPropertyDescriptor getReportFitEditor() { this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - FitProvider wbTpl = (FitProvider) designer.getTarget(); - ReportFitAttrProvider fitAttr = wbTpl.getFitAttr(); + FitProvider wbTpl = designer.getTarget(); + ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); ElementCaseEditor editor = this.toData(); //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) if (editor.getFitStateInPC() == 0) { editor.setReportFitAttr(null); } - ReportFitAttrProvider reportFit = editor.getReportFitAttr(); + ReportFitAttr reportFit = editor.getReportFitAttr(); if(fitAttr != null){ reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; } - ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; - PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr); + ReportFitAttr reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; + BrowserFitPropertyEditor browserFitPropertyEditor = new BrowserFitPropertyEditor(); + CRPropertyDescriptor extraEditor = browserFitPropertyEditor.createPropertyDescriptor(this.data.getClass(), reportFitAttr); if (editor.getReportFitAttr() == null) { - editor.setReportFitInPc(processor.getFitStateInPC(fitAttr)); + editor.setReportFitInPc(browserFitPropertyEditor.getFitStateInPC(fitAttr)); } - return (CRPropertyDescriptor[]) ArrayUtils.addAll(extraTableEditor, extraEditor); + return extraEditor; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 2fb5febd3c..5f043c6983 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -32,10 +32,10 @@ import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.actions.EmbeddedFormExportExportAction; -import com.fr.design.mainframe.actions.FormMobileAttrAction; import com.fr.design.mainframe.actions.TemplateParameterAction; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; +import com.fr.design.reportfit.menupane.ReportFitAttrAction; import com.fr.design.mainframe.templateinfo.JFormProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; @@ -503,9 +503,9 @@ public class JForm extends JTemplate implements BaseJForm { @Override public ShortCut[] shortcut4TemplateMenu() { if (this.index == FORM_TAB) { - return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this)}, new ShortCut[0]); + return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, new ShortCut[0]); } else { - return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu()); + return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu()); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitAlignmentItems.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitAlignmentItems.java new file mode 100644 index 0000000000..27669e8aba --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitAlignmentItems.java @@ -0,0 +1,21 @@ +package com.fr.design.mainframe.widget.propertypane; + +import com.fr.design.reportfit.FitType; +import com.fr.design.designer.properties.items.Item; +import com.fr.design.designer.properties.items.ItemProvider; + +public class BrowserFitAlignmentItems implements ItemProvider { + + private static Item[] VALUE_ITEMS = { + FitType.HORIZONTAL_FIT.propertyItem(), + FitType.DOUBLE_FIT.propertyItem(), + FitType.NOT_FIT.propertyItem(), + }; + + @Override + public Item[] getItems() { + return VALUE_ITEMS; + } + + +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitEditor.java new file mode 100644 index 0000000000..4b3a7488ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitEditor.java @@ -0,0 +1,47 @@ +package com.fr.design.mainframe.widget.propertypane; + +import com.fr.design.designer.properties.items.Item; +import com.fr.design.designer.properties.items.ItemProvider; +import com.fr.design.mainframe.widget.editors.ComboEditor; + +import java.util.Vector; + +public class BrowserFitEditor extends ComboEditor { + public BrowserFitEditor() { + this(new BrowserFitAlignmentItems()); + } + + public BrowserFitEditor(ItemProvider provider) { + this(provider.getItems()); + } + + public BrowserFitEditor(Item[] items) { + super(items); + } + + public BrowserFitEditor(Vector items) { + super(items); + } + + @Override + public Object getValue() { + Item item = (Item) comboBox.getSelectedItem(); + return item.getValue(); + } + + @Override + public void setValue(Object value) { + Item item = new Item("", value); + comboBox.setSelectedItem(item); + } + + /** + * 是否立即刷新 + * + * @return 是或者否 + */ + @Override + public boolean refreshInTime() { + return false; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitPropertyEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitPropertyEditor.java new file mode 100644 index 0000000000..cdbc0c1a18 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitPropertyEditor.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe.widget.propertypane; + +import com.fr.design.designer.creator.CRPropertyDescriptor; +import com.fr.design.form.util.XCreatorConstants; +import com.fr.report.reportfit.ReportFitAttr; +import com.fr.reportfit.ReportFitConfig; + +import java.beans.IntrospectionException; + +/** + * Created by zhouping on 2015/9/10. + */ +public class BrowserFitPropertyEditor { + + /** + * 生成属性表 + * + * @param temp 传入当前操作的class + * @param reportFitAttr 传入的自适应属性 + * @return 返回属性表 + */ + public CRPropertyDescriptor createPropertyDescriptor(Class temp, ReportFitAttr reportFitAttr) { + if (getFitStateInPC(reportFitAttr) == 0) { + return null; + } + try { + CRPropertyDescriptor propertyDescriptors = new CRPropertyDescriptor("fitStateInPC", temp).setEditorClass(BrowserFitEditor.class) + .setRendererClass(BrowserFitRender.class).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-In-Web")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"); + return propertyDescriptors; + } catch (IntrospectionException e) { + return null; + } + } + + public int getFitStateInPC(ReportFitAttr fitAttrProvider) { + if (fitAttrProvider != null) { + return fitAttrProvider.fitStateInPC(); + } + return ReportFitConfig.getInstance().getFrmFitAttr().fitStateInPC(); + + } + + +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitRender.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitRender.java new file mode 100644 index 0000000000..f8dce2acc1 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitRender.java @@ -0,0 +1,10 @@ +package com.fr.design.mainframe.widget.propertypane; + +import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; + +public class BrowserFitRender extends EncoderCellRenderer { + + public BrowserFitRender() { + super(new BrowserFitWrapper()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitWrapper.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitWrapper.java new file mode 100644 index 0000000000..7e1f63b8ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/propertypane/BrowserFitWrapper.java @@ -0,0 +1,9 @@ +package com.fr.design.mainframe.widget.propertypane; + +import com.fr.design.designer.properties.ItemWrapper; + +public class BrowserFitWrapper extends ItemWrapper { + public BrowserFitWrapper() { + super(new BrowserFitAlignmentItems()); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index bfc01d0bf9..7072c55dd2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -41,6 +41,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.mainframe.cell.QuickEditorRegion; +import com.fr.design.reportfit.menupane.ReportFitAttrAction; import com.fr.design.mainframe.templateinfo.JWorkBookProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; @@ -698,6 +699,7 @@ public class JWorkBook extends JTemplate { new ReportWebAttrAction(this), new ReportExportAttrAction(this), new ReportParameterAction(this), + new ReportFitAttrAction(this), new ReportMobileAttrAction(this), new ReportPrintSettingAction(this), new ReportWatermarkAction(this),