Browse Source

Merge pull request #1631 in DESIGN/design from ~YAOH.WU/design:release/10.0 to release/10.0

* commit 'a6b812b0d21d774e135916433aebf29fc8d04bf2':
  删除无需的监听
  rename
  REPORT-27222 设计器单元格扩展属性接口
feature/big-screen
yaoh.wu 5 years ago
parent
commit
f567b28b03
  1. 21
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java
  2. 39
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java
  3. 81
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  4. 125
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java

21
designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java

@ -0,0 +1,21 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.Mutable;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 15:50
*/
public interface CellExpandAttrPanelProvider extends Mutable {
String MARK_STRING = "CellExpandAttrPanelProvider";
int CURRENT_LEVEL = 1;
/**
* @return 创建单元格属性-扩展设置中的额外面板
*/
BasicBeanPane<TemplateCellElement> createPanel();
}

39
designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java

@ -0,0 +1,39 @@
package com.fr.design.fun.impl;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrPanelProvider;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.API;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 16:08
*/
@API(level = CellExpandAttrPanelProvider.CURRENT_LEVEL)
public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelProvider {
/**
* 当前接口的API等级,用于判断是否需要升级插件
*
* @return API等级
*/
@Override
public int currentAPILevel() {
return CellExpandAttrPanelProvider.CURRENT_LEVEL;
}
/**
* 获取当前provider的标记可以使用类路径保证唯一以避免provider的重复加载
*
* @return 当前provider的标记
*/
@Override
public String mark4Provider() {
return null;
}
@Override
public BasicBeanPane<TemplateCellElement> createPanel() {
return null;
}
}

81
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane;
@ -10,18 +9,23 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Rectangle;
/**
* 单元格扩展属性面板是属性表面板的一个种类
@ -38,58 +42,66 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel layoutPane;
private JPanel basicPane;
private JPanel seniorPane;
private CellExpandExtraAttrPane extraPane;
/**
* @return
* @return content panel
*/
public JPanel createContentPane() {
String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Not_Expand"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom"), com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right")};
String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_ExpandD_Not_Expand"), Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom"), Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right")};
Icon[][] iconArray = {
{BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), BaseUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")},
{BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), BaseUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")},
{BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png"), BaseUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")}
{IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), IOUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")},
{IOUtils.readIcon("/com/fr/design/images/expand/vertical.png"), IOUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")},
{IOUtils.readIcon("/com/fr/design/images/expand/landspace.png"), IOUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")}
};
Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT};
expandDirectionButton = new UIButtonGroup<Byte>(iconArray, valueArray);
expandDirectionButton.setAllToolTips(nameArray);
leftFatherPane = new ExpandLeftFatherPane();
rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames();
return layoutPane();
}
private void initAllNames() {
expandDirectionButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"));
leftFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent"));
rightFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"));
horizontalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
verticalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
expandDirectionButton.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"));
leftFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_LeftParent"));
rightFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"));
horizontalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
verticalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
}
private JPanel layoutPane() {
layoutPane = new JPanel(new BorderLayout());
basicPane = new JPanel();
seniorPane = new JPanel();
basicPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane());
seniorPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane());
basicPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane());
seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane());
layoutPane.add(basicPane, BorderLayout.NORTH);
layoutPane.add(seniorPane, BorderLayout.CENTER);
return layoutPane;
extraPane = CellExpandExtraAttrPane.getInstance();
JPanel content = new JPanel(new BorderLayout());
content.add(layoutPane, BorderLayout.NORTH);
content.add(extraPane, BorderLayout.CENTER);
return content;
}
private JPanel basicPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel direction = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"), SwingConstants.LEFT);
UILabel direction = new UILabel(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"), SwingConstants.LEFT);
JPanel directionPane = new JPanel(new BorderLayout());
directionPane.add(direction, BorderLayout.NORTH);
UILabel left = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent"), SwingConstants.LEFT);
UILabel left = new UILabel(Toolkit.i18nText("Fine-Design_Report_LeftParent"), SwingConstants.LEFT);
JPanel leftPane = new JPanel(new BorderLayout());
leftPane.add(left, BorderLayout.NORTH);
UILabel up = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"), SwingConstants.LEFT);
UILabel up = new UILabel(Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"), SwingConstants.LEFT);
JPanel upPane = new JPanel(new BorderLayout());
upPane.add(up, BorderLayout.NORTH);
Component[][] components = new Component[][]{
@ -107,7 +119,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel expendSort = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
@ -118,9 +130,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
};
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 3}, {1, 3}};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, SENIOR_HORIZONTAL_GAP, LayoutConstants.VGAP_LARGE);
}
@ -158,13 +170,15 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement);
}
@Override
public String getIconPath() {
// return "com/fr/design/images/expand/cellAttr.gif";
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Expand");
return Toolkit.i18nText("Fine-Design_Report_Expand");
}
@ -175,19 +189,19 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
cellExpandAttr = new CellExpandAttr();
cellElement.setCellExpandAttr(cellExpandAttr);
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"))) {
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"))) {
cellExpandAttr.setDirection(expandDirectionButton.getSelectedItem());
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent"))) {
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_LeftParent"))) {
this.leftFatherPane.update(cellExpandAttr);
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"))) {
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"))) {
this.rightFatherPane.update(cellExpandAttr);
}
// extendable
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"))) {
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"))) {
if (horizontalExpandableCheckBox.isSelected()) {
if (verticalExpandableCheckBox.isSelected()) {
cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE);
@ -203,10 +217,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
sortAfterExpand.update(cellExpandAttr);
}
extraPane.update(cellElement);
}
/**
@ -234,10 +249,10 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
/**
* @return
* @return title
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Attribute");
return Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Attribute");
}

125
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java

@ -0,0 +1,125 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrPanelProvider;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.event.EventDispatcher;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.cell.TemplateCellElement;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import static com.fr.plugin.observer.PluginEventType.AfterRun;
import static com.fr.plugin.observer.PluginEventType.AfterStop;
/**
* @author yaohwu
* created by yaohwu at 2020/4/28 10:01
*/
public class CellExpandExtraAttrPane extends JPanel {
private static final double V_GAP = 5;
private static final double H_GAP = 0;
private static final int DEFAULT_COMPONENT_SIZE = 2;
private List<BasicBeanPane<TemplateCellElement>> extras = null;
private TemplateCellElement cellElement = null;
private static final class Holder {
private static final CellExpandExtraAttrPane INSTANCE = new CellExpandExtraAttrPane();
}
static {
PluginFilter filter = new PluginFilter() {
@Override
public boolean accept(PluginContext pluginContext) {
return pluginContext.contain(PluginModule.ExtraDesign, CellExpandAttrPanelProvider.MARK_STRING);
}
};
PluginEventListener listener = new PluginEventListener() {
@Override
public void on(PluginEvent event) {
CellExpandExtraAttrPane.getInstance().refresh();
}
};
EventDispatcher.listen(AfterRun, listener, filter);
EventDispatcher.listen(AfterStop, listener, filter);
}
public static CellExpandExtraAttrPane getInstance() {
return Holder.INSTANCE;
}
/**
* Creates a new <code>JPanel</code> with a double buffer
* and a flow layout.
*/
private CellExpandExtraAttrPane() {
this.setBorder(null);
this.setLayout(new BorderLayout());
}
public void populate(TemplateCellElement cellElement) {
this.cellElement = cellElement;
if (extras != null) {
for (BasicBeanPane<TemplateCellElement> extra : extras) {
extra.populateBean(cellElement);
}
}
}
public void update(TemplateCellElement cellElement) {
this.cellElement = cellElement;
if (extras != null) {
for (BasicBeanPane<TemplateCellElement> extra : extras) {
extra.updateBean(cellElement);
}
}
}
private void refresh() {
this.removeAll();
if (extras == null) {
extras = new ArrayList<>();
}
extras.clear();
Set<CellExpandAttrPanelProvider> attrProviders = ExtraDesignClassManager.getInstance().getArray(CellExpandAttrPanelProvider.MARK_STRING);
if (attrProviders != null) {
for (CellExpandAttrPanelProvider attrProvider : attrProviders) {
BasicBeanPane<TemplateCellElement> extra = attrProvider.createPanel();
if (extra != null) {
extras.add(extra);
}
}
}
Component[][] components = new Component[extras.size()][DEFAULT_COMPONENT_SIZE];
for (int i = 0; i < extras.size(); i++) {
components[i] = new Component[]{extras.get(i), null};
}
double[] rowSize = new double[extras.size()];
Arrays.fill(rowSize, TableLayout.PREFERRED);
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL};
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, H_GAP, V_GAP);
this.add(content, BorderLayout.CENTER);
if (this.cellElement != null) {
this.populate(cellElement);
}
this.validate();
this.repaint();
}
}
Loading…
Cancel
Save