* commit '0c07b5851256f174dc464c2e593ebc2831d5fb69': 修改包名, 移除ReportFitAttrProvider接口 REPORT-10591 自适应插件内置 设计器部分 REPORT-10591 自适应插件内置 设计器部分 修改下接口 REPORT-10591 自适应插件内置 设计器部分 REPORT-10591 自适应插件内置 设计器部分 REPORT-10591 自适应插件内置 国际化 REPORT-10591 自适应插件内置 设计器部分research/10.0
@ -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); |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
|
||||
} |
@ -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<ReportFitAttr> { |
||||
|
||||
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()); |
||||
} |
||||
} |
||||
} |
@ -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<String, ImageIcon> cachedPreviewImage = new HashMap<String, ImageIcon>(); |
||||
private Map<String, ImageIcon> globalCachedPreviewImage = new HashMap<String, ImageIcon>(); |
||||
|
||||
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"); |
||||
} |
||||
|
||||
|
||||
} |
@ -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 |
||||
* <p> |
||||
* Created by Administrator on 2016/5/5/0005. |
||||
*/ |
||||
public class FitRadioGroup extends ButtonGroup { |
||||
|
||||
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>(); |
||||
|
||||
@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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.design.reportfit.menupane; |
||||
|
||||
/** |
||||
* 字体的两个选项组成的group |
||||
* <p> |
||||
* 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; |
||||
} |
||||
} |
@ -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<ReportFitAttr> 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); |
||||
} |
||||
|
||||
} |
@ -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<ReportFitAttr> { |
||||
|
||||
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"); |
||||
} |
||||
|
||||
} |
@ -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()); |
||||
} |
||||
} |
||||
} |
@ -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<ReportFitAttr> { |
||||
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"); |
||||
} |
||||
} |
After Width: | Height: | Size: 976 B |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 788 B |
After Width: | Height: | Size: 788 B |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 782 B |
After Width: | Height: | Size: 783 B |
@ -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; |
||||
} |
||||
|
||||
|
||||
} |
@ -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<Item> 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; |
||||
} |
||||
} |
@ -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(); |
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -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()); |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |