Browse Source

Pull request #5640: KERNEL-8879 自适应预览下 给报表块增加自适应逻辑接口

Merge in DESIGN/design from ~HENRY.WANG/design:release/11.0 to release/11.0

* commit '658e44fba128db83d9404bd241c9af17df5e93f8':
  KERNEL-8879 自适应预览下 给报表块增加自适应逻辑接口
fix-lag
Henry.Wang 3 years ago
parent
commit
47e53970a0
  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; 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.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.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.DataModify; import com.fr.design.widget.DataModify;
@ -17,23 +20,30 @@ import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/** /**
* Created by kerry on 2020-04-22 * Created by kerry on 2020-04-22
*/ */
public class PcFitExpandablePane extends JPanel { public class PcFitExpandablePane extends JPanel {
UIComboBox comboBox = new UIComboBox( 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 String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit"), new Item(Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit"), 1, Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit"), new Item(Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit"), 3, Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"))};
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit")}); UIComboBox comboBox = new UIComboBox();
UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip")); 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) { public PcFitExpandablePane(DataModify attrPane) {
init(attrPane); init(attrPane);
} }
public void init(final DataModify attrPane) { public void init(final DataModify attrPane) {
initComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pcFitPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel pcFitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); final JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -42,11 +52,11 @@ public class PcFitExpandablePane extends JPanel {
comboBox.addItemListener(new ItemListener() { comboBox.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
tipLabel.setText(ScaleTipType.getScaleTip(comboBox.getSelectedIndex()).getTip()); tipLabel.setText(contentDisplayTip.get(comboBox.getSelectedItem()));
} }
}); });
Component[][] components = new Component[][]{ 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}, new Component[]{tipLabel, null},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_W0); 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); 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() { public ReportFitAttr update() {
ReportFitAttr fitAttr = getReportFitAttr(); ReportFitAttr fitAttr = getDefaultReportFitAttr();
fitAttr.setFitStateInPC(FitStateCompatible.getOldTypeFromNew(comboBox.getSelectedIndex())); String selectType = (String) comboBox.getSelectedItem();
for (Integer key : contentDisplayType.keySet()) {
if (CompareUtils.isEqual(contentDisplayType.get(key), selectType)) {
fitAttr.setFitStateInPC(key);
}
}
return fitAttr; return fitAttr;
} }
public void populate(ReportFitAttr fitAttr) { public void populate(ReportFitAttr fitAttr) {
if (fitAttr == null) { if (fitAttr == null || !contentDisplayType.keySet().contains(fitAttr.fitStateInPC())) {
fitAttr = getReportFitAttr(); 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(); ReportFitAttr fitAttr = new ReportFitAttr();
fitAttr.setFitStateInPC(FitAttrState.NOT_FIT.getState()); fitAttr.setFitStateInPC(FitAttrState.NOT_FIT.getState());
return fitAttr; return fitAttr;
} }
private enum ScaleTipType { class Item {
EC_DOUBLE_FIT(0, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit_Tip")), public String value;
EC_HOR_FIT(1, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")), public int key;
EC_NO_FIT(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip")); public String tip;
private int index;
private String tip;
ScaleTipType(int index, String tip) { Item(String value, int key, String tip) {
this.index = index; this.value = value;
this.key = key;
this.tip = tip; 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