Browse Source

KERNEL-8879 自适应预览下 给报表块增加自适应逻辑接口

fix-lag
Henry.Wang 3 years ago
parent
commit
658e44fba1
  1. 19
      designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java
  2. 19
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java
  3. 95
      designer-form/src/main/java/com/fr/design/fit/attrpane/PcFitExpandablePane.java

19
designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java

@ -0,0 +1,19 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
public interface PcFitProvider extends Mutable {
String XML_TAG = "PcFitProvider";
int CURRENT_LEVEL = 1;
//设计器上看到的选项
String getContentDisplayValue();
//返回给前端的值
int getContentDisplayKey();
//设计器上的提示信息
String getContentDisplayTip();
}

19
designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java

@ -0,0 +1,19 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.PcFitProvider;
import com.fr.stable.fun.mark.API;
@API(level = PcFitProvider.CURRENT_LEVEL)
public abstract class AbstractPcFitProvider implements PcFitProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

95
designer-form/src/main/java/com/fr/design/fit/attrpane/PcFitExpandablePane.java

@ -1,9 +1,12 @@
package com.fr.design.fit.attrpane;
import com.finebi.cbb.utils.CompareUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.fit.FitStateCompatible;
import com.fr.design.fun.PcFitProvider;
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.widget.DataModify;
@ -17,23 +20,30 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Created by kerry on 2020-04-22
*/
public class PcFitExpandablePane extends JPanel {
UIComboBox comboBox = new UIComboBox(
new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit")});
UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"));
Item[] defaultItems = new Item[]{new Item(Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit"), 2, Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit_Tip")),
new Item(Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit"), 1, Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")),
new Item(Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit"), 3, Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"))};
UIComboBox comboBox = new UIComboBox();
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"));
Map<Integer, String> contentDisplayType = new HashMap<>();
Map<String, String> contentDisplayTip = new HashMap<>();
public PcFitExpandablePane(DataModify attrPane) {
init(attrPane);
}
public void init(final DataModify attrPane) {
initComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pcFitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -42,11 +52,11 @@ public class PcFitExpandablePane extends JPanel {
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
tipLabel.setText(ScaleTipType.getScaleTip(comboBox.getSelectedIndex()).getTip());
tipLabel.setText(contentDisplayTip.get(comboBox.getSelectedItem()));
}
});
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Content_Display_Type")), comboBox},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Designer_Fit_Ec_Content_Display_Type")), comboBox},
new Component[]{tipLabel, null},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_W0);
@ -58,50 +68,61 @@ public class PcFitExpandablePane extends JPanel {
this.add(pcFitPane, BorderLayout.CENTER);
}
private void initComboBox() {
for (Item item : defaultItems) {
comboBox.addItem(item.value);
contentDisplayType.put(item.key, item.value);
contentDisplayTip.put(item.value, item.tip);
}
Set<PcFitProvider> pcFitProviders = ExtraDesignClassManager.getInstance().getArray(PcFitProvider.XML_TAG);
for (PcFitProvider pcFitProvider : pcFitProviders) {
comboBox.addItem(pcFitProvider.getContentDisplayValue());
contentDisplayType.put(pcFitProvider.getContentDisplayKey(), pcFitProvider.getContentDisplayValue());
contentDisplayTip.put(pcFitProvider.getContentDisplayValue(), pcFitProvider.getContentDisplayTip());
}
}
public ReportFitAttr update() {
ReportFitAttr fitAttr = getReportFitAttr();
fitAttr.setFitStateInPC(FitStateCompatible.getOldTypeFromNew(comboBox.getSelectedIndex()));
ReportFitAttr fitAttr = getDefaultReportFitAttr();
String selectType = (String) comboBox.getSelectedItem();
for (Integer key : contentDisplayType.keySet()) {
if (CompareUtils.isEqual(contentDisplayType.get(key), selectType)) {
fitAttr.setFitStateInPC(key);
}
}
return fitAttr;
}
public void populate(ReportFitAttr fitAttr) {
if (fitAttr == null) {
fitAttr = getReportFitAttr();
if (fitAttr == null || !contentDisplayType.keySet().contains(fitAttr.fitStateInPC())) {
fitAttr = getDefaultReportFitAttr();
}
String selectType = contentDisplayType.get(fitAttr.fitStateInPC());
for (int i = 0; i < comboBox.getItemCount(); i++) {
if (CompareUtils.isEqual(selectType, comboBox.getItemAt(i))) {
comboBox.setSelectedIndex(i);
tipLabel.setText(contentDisplayTip.get(selectType));
}
}
int selectIndex = FitStateCompatible.getNewTypeFromOld(fitAttr.fitStateInPC());
comboBox.setSelectedIndex(selectIndex);
tipLabel.setText(ScaleTipType.getScaleTip(selectIndex).getTip());
}
private ReportFitAttr getReportFitAttr() {
private ReportFitAttr getDefaultReportFitAttr() {
ReportFitAttr fitAttr = new ReportFitAttr();
fitAttr.setFitStateInPC(FitAttrState.NOT_FIT.getState());
return fitAttr;
}
private enum ScaleTipType {
EC_DOUBLE_FIT(0, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit_Tip")),
EC_HOR_FIT(1, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")),
EC_NO_FIT(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"));
private int index;
private String tip;
class Item {
public String value;
public int key;
public String tip;
ScaleTipType(int index, String tip) {
this.index = index;
Item(String value, int key, String tip) {
this.value = value;
this.key = key;
this.tip = tip;
}
public String getTip() {
return tip;
}
public static ScaleTipType getScaleTip(int selectIndex) {
for (ScaleTipType tipType : values()) {
if (selectIndex == tipType.index) {
return tipType;
}
}
return EC_NO_FIT;
}
}
}

Loading…
Cancel
Save