Browse Source

REPORT-5668 单元格元素和悬浮元素编辑器频繁初始化导致的内存激增问题

master
yaoh.wu 7 years ago
parent
commit
237666902f
  1. 22
      designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java
  2. 20
      designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java
  3. 14
      designer/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java
  4. 86
      designer/src/com/fr/design/module/DesignerModule.java
  5. 97
      designer/src/com/fr/quickeditor/CellQuickEditor.java
  6. 9
      designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java
  7. 44
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  8. 11
      designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java
  9. 10
      designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java
  10. 10
      designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java
  11. 9
      designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java
  12. 8
      designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java
  13. 2
      designer/src/com/fr/quickeditor/cellquick/layout/CellElementBarLayout.java
  14. 170
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

22
designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java

@ -1,10 +1,10 @@
package com.fr.design.actions.cell;
import com.fr.design.actions.CellSelectionAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection;
@ -14,8 +14,17 @@ import com.fr.report.core.SheetUtils;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.stable.ReportConstants;
// TODO ALEX_SEP 这个类与AbstractCellAction有什么关系?
/**
* TODO ALEX_SEP 这个类与AbstractCellAction有什么关系?
*
* @author null
*/
public abstract class AbstractCellElementAction extends CellSelectionAction {
protected AbstractCellElementAction() {
super();
}
protected AbstractCellElementAction(ElementCasePane t) {
super(t);
}
@ -29,9 +38,7 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
editCellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow());
tplEC.addCellElement(editCellElement);
}
if (tplEC != null) {
SheetUtils.calculateDefaultParent(tplEC);
}
final CellSelection finalCS = cs;
final BasicPane bp = populateBasicPane(editCellElement);
BasicDialog dialog = bp.showWindow(DesignerContext.getDesignerFrame());
@ -76,16 +83,15 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
/**
* 初始化对话框
*
* @param cellElement
* @return
* @param cellElement 单元格
* @return 对话框
*/
protected abstract BasicPane populateBasicPane(TemplateCellElement cellElement);
/**
* 更新对话框之后改变值
*
* @param cellElement
* @return
* @param cellElement 单元格
*/
protected abstract void updateBasicPane(BasicPane basicPane, TemplateCellElement cellElement);

20
designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java

@ -9,16 +9,34 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.general.Inter;
import com.fr.report.cell.TemplateCellElement;
/**
* 数据列过滤条件Action
*
* @author null
* @version 2017年11月17日15点11分
* @since 8.0
*/
public class DSColumnConditionAction extends AbstractCellElementAction {
public DSColumnConditionAction() {
super();
this.setName(Inter.getLocText("Filter"));
this.setMnemonic('E');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif"));
}
public DSColumnConditionAction(ElementCasePane t) {
super(t);
this.setName(Inter.getLocText("Filter"));
this.setMnemonic('E');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif"));
}
@Override
public void setEditingComponent(ElementCasePane casePane) {
super.setEditingComponent(casePane);
}
@Override
protected BasicPane populateBasicPane(TemplateCellElement cellElement) {
DSColumnConditionsPane dSColumnConditionsPane = new DSColumnConditionsPane();

14
designer/src/com/fr/design/mainframe/cell/CellEditorPane.java → designer/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java

@ -2,10 +2,12 @@ package com.fr.design.mainframe.cell;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.quickeditor.cellquick.CellElementBarLayout;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent;
@ -18,9 +20,11 @@ import java.awt.event.MouseWheelListener;
* @version 2017年7月25日
* @since 9.0
*/
public abstract class CellEditorPane extends JPanel {
public abstract class AbstractDSCellEditorPane extends JPanel {
/*滚动条相关配置*/
/**
* 滚动条相关配置
*/
private static final int MAXVALUE = 100;
private static final int TITLE_HEIGHT = 95;
private static final int CONTENT_PANE_WIDTH_GAP = 3;

86
designer/src/com/fr/design/module/DesignerModule.java

@ -1,13 +1,27 @@
package com.fr.design.module;
import com.fr.base.*;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.FRContext;
import com.fr.base.Formula;
import com.fr.base.MultiFieldParameter;
import com.fr.base.Style;
import com.fr.base.TempNameStyle;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.base.process.ProcessOperator;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.*;
import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.actions.insert.cell.ChartCellAction;
import com.fr.design.actions.insert.cell.DSColumnCellAction;
import com.fr.design.actions.insert.cell.FormulaCellAction;
import com.fr.design.actions.insert.cell.GeneralCellAction;
import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.actions.insert.flot.ChartFloatAction;
import com.fr.design.actions.insert.flot.FormulaFloatAction;
import com.fr.design.actions.insert.flot.ImageFloatAction;
@ -17,7 +31,11 @@ import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.javascript.ProcessTransitionAdapter;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
@ -27,14 +45,24 @@ import com.fr.design.mainframe.loghandler.DesignerLogImpl;
import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FILE;
import com.fr.general.*;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.ModuleContext;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.io.importer.ExcelReportImporter;
import com.fr.main.impl.WorkBook;
import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor;
import com.fr.quickeditor.cellquick.CellDSColumnEditor;
import com.fr.quickeditor.cellquick.CellFormulaQuickEditor;
import com.fr.quickeditor.cellquick.CellImageQuickEditor;
import com.fr.quickeditor.cellquick.CellRichTextEditor;
import com.fr.quickeditor.cellquick.CellStringQuickEditor;
import com.fr.quickeditor.cellquick.CellSubReportEditor;
import com.fr.quickeditor.chartquick.BasicChartQuickEditor;
import com.fr.quickeditor.chartquick.FloatChartQuickEditor;
import com.fr.quickeditor.cellquick.*;
import com.fr.quickeditor.floatquick.FloatImageQuickEditor;
import com.fr.quickeditor.floatquick.FloatStringQuickEditor;
import com.fr.report.cell.CellElementValueConverter;
@ -56,8 +84,11 @@ import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider;
import com.fr.xml.ReportXMLUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
@ -108,23 +139,27 @@ public class DesignerModule extends DesignModule {
/**
* kunsnat:注册单元格选中Editor
*/
private void registerCellEditor() {
ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(BaseFormula.class, CellFormulaQuickEditor.class);
ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.class);
ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.class);
ActionFactory.registerCellEditor(DSColumn.class, CellDSColumnEditor.class);
ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.class);
ActionFactory.registerCellEditor(BiasTextPainter.class, CellBiasTextPainterEditor.class);
ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.class);
ActionFactory.registerChartCellEditorInEditor(BasicChartQuickEditor.class);
ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor());
ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor());
ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor());
ActionFactory.registerCellEditor(SubReport.class, new CellSubReportEditor());
ActionFactory.registerCellEditor(RichText.class, new CellRichTextEditor());
ActionFactory.registerCellEditor(DSColumn.class, new CellDSColumnEditor());
ActionFactory.registerCellEditor(Image.class, new CellImageQuickEditor());
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor());
ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor());
ActionFactory.registerChartCellEditorInEditor(new BasicChartQuickEditor());
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) {
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor());
try {
ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance());
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
}
@ -138,12 +173,13 @@ public class DesignerModule extends DesignModule {
* kunnat: 注册悬浮选中Editor
*/
private void registerFloatEditor() {
ActionFactory.registerFloatEditor(String.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditor(Formula.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditor(Image.class, FloatImageQuickEditor.class);
ActionFactory.registerFloatEditor(BufferedImage.class, FloatImageQuickEditor.class);
ActionFactory.registerChartFloatEditorInEditor(FloatChartQuickEditor.class);
ActionFactory.registerFloatEditor(String.class, new FloatStringQuickEditor());
ActionFactory.registerFloatEditor(Formula.class, new FloatStringQuickEditor());
ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor());
ActionFactory.registerFloatEditor(BufferedImage.class, new FloatImageQuickEditor());
ActionFactory.registerChartFloatEditorInEditor(new FloatChartQuickEditor());
}
/**

97
designer/src/com/fr/quickeditor/CellQuickEditor.java

@ -18,13 +18,25 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.selection.QuickEditor;
import com.fr.general.Inter;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.cellquick.CellElementBarLayout;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
/**
@ -35,19 +47,22 @@ import java.util.ArrayList;
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
/*面板配置*/
/**
* 面板配置
*/
protected UITextField columnRowTextField;
protected TemplateCellElement cellElement;
/*占位label*/
protected static final Dimension LABEL_DIMENSION = new Dimension(60, 20);
protected static final UILabel EMPTY_LABEL = new UILabel();
/**
* 占位label
*/
protected final Dimension LABEL_DIMENSION = new Dimension(60, 20);
protected final UILabel EMPTY_LABEL = new UILabel();
protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3;
static {
EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION);
}
/*滚动条相关配置*/
/**
* 滚动条相关配置
*/
private static final int MAXVALUE = 100;
private static final int CONTENT_PANE_WIDTH_GAP = 3;
private static final int MOUSE_WHEEL_SPEED = 5;
@ -61,8 +76,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private int currentSelectedIndex;
private JPanel leftContentPane;
private UIScrollBar scrollBar;
private ActionListener comboBoxActionListener;
public CellQuickEditor() {
EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
@ -147,7 +164,39 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow());
columnRowTextField.setText(columnRow.toString());
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow());
comboBox.removeActionListener(comboBoxActionListener);
comboBox.removeAllItems();
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
String[] items = getDefaultComboBoxItems();
for (String item : items) {
comboBox.addItem(item);
}
}
Object comboBoxSelected = getComboBoxSelected();
if (comboBoxSelected != null) {
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName());
} else {
comboBox.setSelectedIndex(1);
}
currentSelectedIndex = comboBox.getSelectedIndex();
comboBoxActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex();
comboBox.setPopupVisible(false);
comboBox.repaint();
if (selectedIndex < cellInsertActions.length) {
cellInsertActions[selectedIndex].actionPerformed(e);
}
comboBox.setSelectedIndex(currentSelectedIndex);
}
};
comboBox.addActionListener(comboBoxActionListener);
refreshDetails();
}
/**
@ -165,10 +214,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
cellLabel.setPreferredSize(LABEL_DIMENSION);
UILabel insertContentLabel = new UILabel(Inter.getLocText("FR-Designer_Insert_Cell_Element"));
insertContentLabel.setPreferredSize(LABEL_DIMENSION);
UIComboBox cellElementEditComboBox = initCellElementEditComboBox();
initCellElementEditComboBox();
Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()},
new Component[]{insertContentLabel, cellElementEditComboBox},
new Component[]{insertContentLabel, comboBox},
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
}
@ -214,13 +263,12 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
/**
* 初始化添加按钮
*
* @return UIButton
*/
private UIComboBox initCellElementEditComboBox() {
private void initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
return comboBox = new UIComboBox();
comboBox = new UIComboBox();
return;
}
final String[] items = getDefaultComboBoxItems();
comboBox = new UIComboBox(items);
@ -231,18 +279,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
comboBox.setSelectedIndex(1);
}
currentSelectedIndex = comboBox.getSelectedIndex();
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex();
comboBox.setPopupVisible(false);
comboBox.repaint();
cellInsertActions[selectedIndex].actionPerformed(e);
comboBox.setSelectedIndex(currentSelectedIndex);
}
});
return comboBox;
comboBox.addActionListener(comboBoxActionListener);
}
private String[] getDefaultComboBoxItems() {

9
designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java

@ -13,8 +13,10 @@ import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.painter.BiasTextPainter;
import javax.swing.*;
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -22,6 +24,9 @@ import java.awt.event.ActionListener;
* 单元格元素斜线编辑器
*/
public class CellBiasTextPainterEditor extends CellQuickEditor {
public CellBiasTextPainterEditor() {
super();
}
@Override
public JComponent createCenterBody() {

44
designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -1,7 +1,6 @@
package com.fr.quickeditor.cellquick;
import com.fr.base.BaseFormula;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.columnrow.DSColumnConditionAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.DSColumnCellAction;
@ -26,7 +25,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.design.mainframe.cell.AbstractDSCellEditorPane;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor;
@ -71,7 +70,6 @@ import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.UNDEFINE;
* @since 9.0
*/
public class CellDSColumnEditor extends CellQuickEditor {
private static final double P = TableLayout.PREFERRED, F = TableLayout.FILL;
private static final Color TIP_FONT_COLOR = new Color(0x7F333334, true);
@ -82,7 +80,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
/**
* 基本和高级设置
*/
private ArrayList<CellEditorPane> paneList;
private ArrayList<AbstractDSCellEditorPane> paneList;
/**
* 基本和高级设置 卡片布局
*/
@ -106,7 +104,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/
private DSColumnAdvancedEditorPane cellDSColumnAdvancedPane;
private CellDSColumnEditor() {
public CellDSColumnEditor() {
super();
}
@ -146,6 +144,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
/**
* 关闭时候释放
*/
@Override
public void release() {
super.release();
dsColumnRegion = null;
@ -161,7 +160,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
card = new CardLayout();
cardContainer = new JPanel(card);
for (int i = 0; i < paneList.size(); i++) {
CellEditorPane pane = paneList.get(i);
AbstractDSCellEditorPane pane = paneList.get(i);
iconArray[i] = pane.getIconPath();
cardContainer.add(pane, pane.title4PopupWindow());
}
@ -196,7 +195,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
* @version 2017年7月25日
* @since 9.0
*/
class DSColumnBasicEditorPane extends CellEditorPane {
class DSColumnBasicEditorPane extends AbstractDSCellEditorPane {
/**
* 数据集和数据列
@ -211,6 +210,16 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/
private JPanel conditionPane;
/**
* 条件过滤按钮触发动作
*/
private DSColumnConditionAction condition;
/**
* 条件过滤按钮
*/
private UIButton conditionUIButton;
/**
* 分组设置监听器
*/
@ -251,17 +260,16 @@ public class CellDSColumnEditor extends CellQuickEditor {
double[] rowSize = {P}, columnSize = {P, F};
UILabel uiLabel = new UILabel(Inter.getLocText("FR-Designer_Filter_Conditions"));
uiLabel.setPreferredSize(LABEL_DIMENSION);
UIButton uiButton = new UIButton();
condition = new DSColumnConditionAction();
if (tc != null) {
//第一次初始化时tc为空,会引发NullPointerException
UpdateAction condition = new DSColumnConditionAction(tc);
condition.setEditingComponent(tc);
}
//丢掉icon,修改按钮名称为编辑
condition.setSmallIcon(null);
condition.setName(Inter.getLocText("FR-Designer_Edit"));
uiButton = new UIButton(condition);
}
conditionUIButton = new UIButton(condition);
Component[][] components = new Component[][]{
new Component[]{uiLabel, uiButton}
new Component[]{uiLabel, conditionUIButton}
};
conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
this.createScrollPane();
@ -291,6 +299,9 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populate() {
dataPane.populate(null, cellElement);
groupPane.populate(cellElement);
if (tc != null) {
condition.setEditingComponent(tc);
}
}
@ -299,6 +310,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
*
* @return content JPanel
*/
@Override
protected JPanel createContentPane() {
double[] columnSize = {F};
@ -316,7 +328,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
class DSColumnAdvancedEditorPane extends CellEditorPane {
class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane {
/**
* 排列顺序
@ -464,6 +476,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
*
* @return 内容面板
*/
@Override
protected JPanel createContentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//结果集排序
@ -539,6 +552,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
multiPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
multiNumPane.add(multiPane);
useMultiplyNumCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkButtonEnabled();
cellDSColumnAdvancedPane.updateMultipleConfig();
@ -712,6 +726,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
private JFormulaField bottomFormulaPane;
private ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
int selectIndex = rsComboBox.getSelectedIndex();
CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout();
@ -1015,6 +1030,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
private ActionListener formulaButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
String text = formulaTextField.getText();

11
designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -22,10 +23,14 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@ -69,7 +74,7 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
};
private CellFormulaQuickEditor() {
public CellFormulaQuickEditor() {
super();
}

10
designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java

@ -5,6 +5,7 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
@ -14,8 +15,11 @@ import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.cellattr.CellImage;
import javax.swing.*;
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -27,7 +31,7 @@ import java.awt.event.ActionListener;
*/
public class CellImageQuickEditor extends CellQuickEditor {
private CellImageQuickEditor() {
public CellImageQuickEditor() {
super();
}

10
designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java

@ -3,13 +3,17 @@ package com.fr.quickeditor.cellquick;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor;
import javax.swing.*;
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* 单元格元素富文本编辑器
@ -20,7 +24,7 @@ import java.awt.*;
public class CellRichTextEditor extends CellQuickEditor {
private UIButton richTextButton;
private CellRichTextEditor() {
public CellRichTextEditor() {
super();
}

9
designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

@ -3,6 +3,7 @@ package com.fr.quickeditor.cellquick;
import com.fr.base.BaseFormula;
import com.fr.base.Style;
import com.fr.base.TextFormat;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.grid.GridKeyListener;
import com.fr.grid.selection.CellSelection;
@ -12,10 +13,12 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
@ -50,7 +53,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
};
private CellStringQuickEditor() {
public CellStringQuickEditor() {
super();
}

8
designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java

@ -8,8 +8,10 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor;
import javax.swing.*;
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* 单元格元素子报表编辑器
@ -21,7 +23,7 @@ public class CellSubReportEditor extends CellQuickEditor {
private UIButton subReportButton;
private CellSubReportEditor() {
public CellSubReportEditor() {
super();
}

2
designer/src/com/fr/quickeditor/cellquick/CellElementBarLayout.java → designer/src/com/fr/quickeditor/cellquick/layout/CellElementBarLayout.java

@ -1,4 +1,4 @@
package com.fr.quickeditor.cellquick;
package com.fr.quickeditor.cellquick.layout;
import javax.swing.*;
import java.awt.*;

170
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -7,68 +7,72 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.selection.QuickEditor;
import com.fr.general.FRLogger;
import javax.swing.*;
import javax.swing.Action;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* 插入单元格元素和插入悬浮元素的一些集合方法
*
* @author null
* @version 2017年11月17日14点39分
*/
public class ActionFactory {
private static LinkedHashSet<Class<?>> actionClasses = new LinkedHashSet<>();
private static LinkedHashSet<Class<?>> floatActionClasses = new LinkedHashSet<>();
private ActionFactory() {
}
private static Map<Class, Class<? extends QuickEditor>> floatEditor = new HashMap<>();
/**
* 悬浮元素编辑器
*/
private static ConcurrentMap<Class, QuickEditor> floatEditor = new ConcurrentHashMap<>();
private static Class chartCollectionClass = null;
private static Map<Class, Class<? extends QuickEditor>> cellEditor = new HashMap<>();
/**
* 单元格元素编辑器
*/
private static ConcurrentMap<Class, QuickEditor> cellEditor = new ConcurrentHashMap<>();
private static UpdateAction chartPreStyleAction = null;
private static UpdateAction chartMapEditorAction = null;
private ActionFactory() {
}
/**
* 待说明
* 注册单元格编辑器
*
* @param clazz 待说明
* @param editor 待说明
* @param clazz 单元格属性类型
* @param editor 单元格编辑器实例
*/
public static void registerCellEditor(Class clazz, Class<? extends QuickEditor> editor) {
public static void registerCellEditor(Class clazz, QuickEditor editor) {
cellEditor.put(clazz, editor);
}
/**
* 待说明
* 注册悬浮元素编辑器
*
* @param clazz 待说明
* @param editor 待说明
* @param clazz 悬浮元素类型
* @param editor 悬浮元素编辑器实例
*/
public static void registerFloatEditor(Class clazz, Class<? extends QuickEditor> editor) {
public static void registerFloatEditor(Class clazz, QuickEditor editor) {
floatEditor.put(clazz, editor);
}
/**
* 注册图表的 预定义样式.
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
*
* @param action 注册的图表预定义样式action
*/
public static void registerChartPreStyleAction(UpdateAction action) {
chartPreStyleAction = action;
}
/**
* 返回 图表预定义样式Action
* @param clazz 待说明
*/
public static UpdateAction getChartPreStyleAction() {
return chartPreStyleAction;
public static void registerChartCollection(Class clazz) {
chartCollectionClass = clazz;
}
/**
@ -80,21 +84,14 @@ public class ActionFactory {
chartMapEditorAction = action;
}
public static UpdateAction getChartMapEditorAction() {
return chartMapEditorAction;
}
/**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* 注册图表的 预定义样式.
*
* @param clazz 待说明
* @param action 注册的图表预定义样式action
*/
public static void registerChartCollection(Class clazz) {
chartCollectionClass = clazz;
}
public static Class getChartCollectionClass() {
return chartCollectionClass;
public static void registerChartPreStyleAction(UpdateAction action) {
chartPreStyleAction = action;
}
/**
@ -102,7 +99,7 @@ public class ActionFactory {
*
* @param editor 待说明
*/
public static void registerChartFloatEditorInEditor(Class<? extends QuickEditor> editor) {
public static void registerChartFloatEditorInEditor(QuickEditor editor) {
if (chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor);
}
@ -113,46 +110,58 @@ public class ActionFactory {
*
* @param editor 待说明
*/
public static void registerChartCellEditorInEditor(Class<? extends QuickEditor> editor) {
public static void registerChartCellEditorInEditor(QuickEditor editor) {
if (chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor);
}
}
/**
* 返回 悬浮元素选中的Editor
* 图表预定义样式Action
*
* @return 图表预定义样式Action
*/
public static QuickEditor getFloatEditor(Class clazz) {
return createEditor(clazz, floatEditor);
public static UpdateAction getChartPreStyleAction() {
return chartPreStyleAction;
}
private static QuickEditor createEditor(Class clazz, Map<Class, Class<? extends QuickEditor>> editorMap) {
Class<? extends QuickEditor> c = findQuickEditorClass(clazz, editorMap);
if (c == null) {
return null;
}
try {
Constructor<? extends QuickEditor> constructor = c.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return null;
}
private static Class<? extends QuickEditor> findQuickEditorClass(Class clazz, Map<Class, Class<? extends QuickEditor>> editorMap) {
Class<? extends QuickEditor> c = editorMap.get(clazz);
if (c == null) {
Class superClazz = clazz.getSuperclass();
if (superClazz == null) {
return null;
/**
* 图表编辑器Action
*
* @return 图表编辑器Action
*/
public static UpdateAction getChartMapEditorAction() {
return chartMapEditorAction;
}
return findQuickEditorClass(superClazz, editorMap);
/**
* 获取图表集合类
*
* @return 获取图表集合类
*/
public static Class getChartCollectionClass() {
return chartCollectionClass;
}
return c;
/**
* 选中的悬浮元素的编辑器
*
* @param clazz 选中的悬浮元素类型
* @return 编辑器实例
*/
public static QuickEditor getFloatEditor(Class clazz) {
return createEditor(clazz, floatEditor);
}
/**
* 选中的单元格元素编辑器
*
* @param clazz 选中的单元格元素类型
* @return 编辑器实例
*/
public static QuickEditor getCellEditor(Class clazz) {
return createEditor(clazz, cellEditor);
}
@ -289,4 +298,25 @@ public class ActionFactory {
}
return actions.toArray(new UpdateAction[actions.size()]);
}
private static QuickEditor createEditor(Class clazz, Map<Class, QuickEditor> editorMap) {
QuickEditor c = findQuickEditorClass(clazz, editorMap);
if (c == null) {
FRLogger.getLogger().error("No Such Editor");
return null;
}
return c;
}
private static QuickEditor findQuickEditorClass(Class clazz, Map<Class, QuickEditor> editorMap) {
QuickEditor c = editorMap.get(clazz);
if (c == null) {
Class superClazz = clazz.getSuperclass();
if (superClazz == null) {
return null;
}
return findQuickEditorClass(superClazz, editorMap);
}
return c;
}
}
Loading…
Cancel
Save