Browse Source

REPORT-27222 设计器单元格扩展属性接口

feature/big-screen
yaohwu 5 years ago
parent
commit
08f6abaf60
  1. 18
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrProvider.java
  2. 39
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrProvider.java
  3. 81
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  4. 132
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java

18
designer-base/src/main/java/com/fr/design/fun/CellExpandAttrProvider.java

@ -0,0 +1,18 @@
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 CellExpandAttrProvider extends Mutable {
String MARK_STRING = "CellExpandAttrProvider";
int CURRENT_LEVEL = 1;
BasicBeanPane<TemplateCellElement> createPanel();
}

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

@ -0,0 +1,39 @@
package com.fr.design.fun.impl;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrProvider;
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 = CellExpandAttrProvider.CURRENT_LEVEL)
public class AbstractCellExpandAttrProvider implements CellExpandAttrProvider {
/**
* 当前接口的API等级,用于判断是否需要升级插件
*
* @return API等级
*/
@Override
public int currentAPILevel() {
return CellExpandAttrProvider.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; package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane; 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.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
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.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.Icon;
import java.awt.*; 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 layoutPane;
private JPanel basicPane; private JPanel basicPane;
private JPanel seniorPane; private JPanel seniorPane;
private CellExpandExtraAttrPane extraPane;
/** /**
* @return * @return content panel
*/ */
public JPanel createContentPane() { 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 = { Icon[][] iconArray = {
{BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), BaseUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, {IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), IOUtils.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")}, {IOUtils.readIcon("/com/fr/design/images/expand/vertical.png"), IOUtils.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/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}; Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT};
expandDirectionButton = new UIButtonGroup<Byte>(iconArray, valueArray); expandDirectionButton = new UIButtonGroup<Byte>(iconArray, valueArray);
expandDirectionButton.setAllToolTips(nameArray); expandDirectionButton.setAllToolTips(nameArray);
leftFatherPane = new ExpandLeftFatherPane(); leftFatherPane = new ExpandLeftFatherPane();
rightFatherPane = new ExpandUpFatherPane(); rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane(); sortAfterExpand = new SortExpandAttrPane();
initAllNames(); initAllNames();
return layoutPane(); return layoutPane();
} }
private void initAllNames() { private void initAllNames() {
expandDirectionButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction")); expandDirectionButton.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"));
leftFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent")); leftFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_LeftParent"));
rightFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell")); rightFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"));
horizontalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); horizontalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
verticalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); verticalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"));
} }
private JPanel layoutPane() { private JPanel layoutPane() {
layoutPane = new JPanel(new BorderLayout()); layoutPane = new JPanel(new BorderLayout());
basicPane = new JPanel(); basicPane = new JPanel();
seniorPane = new JPanel(); seniorPane = new JPanel();
basicPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane()); basicPane = new UIExpandablePane(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()); seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane());
layoutPane.add(basicPane, BorderLayout.NORTH); layoutPane.add(basicPane, BorderLayout.NORTH);
layoutPane.add(seniorPane, BorderLayout.CENTER); 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() { private JPanel basicPane() {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; 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()); JPanel directionPane = new JPanel(new BorderLayout());
directionPane.add(direction, BorderLayout.NORTH); 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()); JPanel leftPane = new JPanel(new BorderLayout());
leftPane.add(left, BorderLayout.NORTH); 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()); JPanel upPane = new JPanel(new BorderLayout());
upPane.add(up, BorderLayout.NORTH); upPane.add(up, BorderLayout.NORTH);
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
@ -107,7 +119,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() { private JPanel seniorPane() {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; 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()); JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH); expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
@ -118,9 +130,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
new Component[]{verticalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand}, 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}; 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); 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); sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement);
} }
@Override @Override
public String getIconPath() { public String getIconPath() {
// return "com/fr/design/images/expand/cellAttr.gif"; // 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(); cellExpandAttr = new CellExpandAttr();
cellElement.setCellExpandAttr(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()); 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); 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); this.rightFatherPane.update(cellExpandAttr);
} }
// extendable // 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 (horizontalExpandableCheckBox.isSelected()) {
if (verticalExpandableCheckBox.isSelected()) { if (verticalExpandableCheckBox.isSelected()) {
cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); 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); sortAfterExpand.update(cellExpandAttr);
} }
extraPane.update(cellElement);
} }
/** /**
@ -234,10 +249,10 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
} }
/** /**
* @return * @return title
*/ */
public String title4PopupWindow() { 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");
} }

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

@ -0,0 +1,132 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrProvider;
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.AfterActive;
import static com.fr.plugin.observer.PluginEventType.AfterInstall;
import static com.fr.plugin.observer.PluginEventType.AfterRun;
import static com.fr.plugin.observer.PluginEventType.AfterStop;
import static com.fr.plugin.observer.PluginEventType.AfterUpdate;
/**
* @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, CellExpandAttrProvider.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);
EventDispatcher.listen(AfterInstall, listener, filter);
EventDispatcher.listen(AfterUpdate, listener, filter);
EventDispatcher.listen(AfterActive, listener, filter);
EventDispatcher.listen(AfterActive, 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<CellExpandAttrProvider> attrProviders = ExtraDesignClassManager.getInstance().getArray(CellExpandAttrProvider.MARK_STRING);
if (attrProviders != null) {
for (CellExpandAttrProvider 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