From 4e84525854eb8214d9f79de6a8e49927afec9887 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 26 Oct 2017 17:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=85=A8=E9=83=A8Formula?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../insert/cell/FormulaCellAction.java | 4 +- .../insert/flot/FormulaFloatAction.java | 262 +++---- .../design/cell/editor/RichTextToolBar.java | 24 +- .../headerfooter/HFAttributesEditDialog.java | 11 +- .../fr/design/report/RichTextEditingPane.java | 1 - .../design/editor/ValueEditorPaneFactory.java | 6 +- .../design/editor/editor/ConstantsEditor.java | 3 +- .../FormulaPaneWhenReserveFormula.java | 1 - .../fr/design/formula/TinyFormulaPane.java | 4 - .../src/com/fr/design/formula/UIFormula.java | 1 - .../design/present/dict/DatabaseDictPane.java | 4 +- .../present/dict/TableDataDictPane.java | 740 +++++++++--------- .../com/fr/design/chart/ChartSwingUtils.java | 1 - .../chart/axis/ChartAlertValuePane.java | 1 - .../CategoryPlotReportDataContentPane.java | 1 - .../chart/gui/style/axis/ChartValuePane.java | 1 - .../style/axis/VanChartValueAxisPane.java | 1 - .../design/gui/xpane/JTreeAutoBuildPane.java | 4 +- .../com/fr/design/gui/xtable/TableUtils.java | 36 +- .../accessibles/AccessibleFormulaEditor.java | 1 - .../widget/wrappers/FormulaWrapper.java | 5 +- .../ui/designer/DateEditorDefinePane.java | 8 +- 22 files changed, 562 insertions(+), 558 deletions(-) diff --git a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java index 499b9119df..56abd1e351 100644 --- a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java @@ -3,8 +3,8 @@ */ package com.fr.design.actions.insert.cell; +import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; -import com.fr.base.Formula; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; @@ -48,6 +48,6 @@ public class FormulaCellAction extends AbstractCellAction implements WorkBookSup @Override public Class getCellValueClass() { - return Formula.class; + return BaseFormula.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java index 63dad86a27..99f0b3157e 100644 --- a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java @@ -1,136 +1,128 @@ -/* - * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. - */ -package com.fr.design.actions.insert.flot; - -import com.fr.base.BaseFormula; -import com.fr.base.BaseUtils; -import com.fr.base.DynamicUnitList; -import com.fr.base.Formula; -import com.fr.design.actions.ElementCaseAction; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.formula.FormulaFactory; -import com.fr.design.formula.UIFormula; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.menu.MenuKeySet; -import com.fr.design.report.SelectImagePane; -import com.fr.general.Inter; -import com.fr.grid.Grid; -import com.fr.grid.selection.FloatSelection; -import com.fr.report.ReportHelper; -import com.fr.report.cell.FloatElement; -import com.fr.report.cell.cellattr.CellImage; -import com.fr.report.elementcase.TemplateElementCase; -import com.fr.stable.CoreGraphHelper; -import com.fr.stable.StringUtils; -import com.fr.stable.unit.FU; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.io.File; - -/** - * Insert formula. - */ -public class FormulaFloatAction extends ElementCaseAction { - - private boolean returnValue = false; - - public FormulaFloatAction(ElementCasePane t) { - super(t); - this.setMenuKeySet(FLOAT_INSERT_FORMULA); - this.setName(getMenuKeySet().getMenuKeySetName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); - } - - public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'F'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Designer_Insert_Formula"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - private void doWithDrawingFloatElement() { - ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - Grid grid = jws.getGrid(); - - ElementCasePane reportPane = grid.getElementCasePane(); - TemplateElementCase report = reportPane.getEditingElementCase(); - DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); - DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); - - int horizentalScrollValue = grid.getHorizontalValue(); - int verticalScrollValue = grid.getVerticalValue(); - - int resolution = grid.getResolution(); - int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); - int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); - - FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); - FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); - - FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); - FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); - - grid.getDrawingFloatElement().setLeftDistance(leftDistance); - grid.getDrawingFloatElement().setTopDistance(topDistance); - - report.addFloatElement(grid.getDrawingFloatElement()); - reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); - } - - /** - * 执行动作 - * - * @return 成功返回true - */ - @Override - public boolean executeActionReturnUndoRecordNeeded() { - final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - if (reportPane == null) { - return false; - } - - reportPane.stopEditing(); - final FloatElement floatElement = new FloatElement(); - final UIFormula formulaPane = FormulaFactory.createFormulaPane(); - formulaPane.populate(BaseFormula.createFormulaBuilder().build()); - - BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - - @Override - public void doOk() { - floatElement.setValue(formulaPane.update()); - if (reportPane == null) { - return; - } - reportPane.getGrid().setDrawingFloatElement(floatElement); - doWithDrawingFloatElement(); - returnValue = true; - } - - @Override - public void doCancel() { - returnValue = false; - } - }); - dialog.setVisible(true); - return returnValue; - } - +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.actions.insert.flot; + +import com.fr.base.BaseFormula; +import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; +import com.fr.design.actions.ElementCaseAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.UIFormula; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.menu.MenuKeySet; +import com.fr.general.Inter; +import com.fr.grid.Grid; +import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; +import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.unit.FU; + +import javax.swing.*; + +/** + * Insert formula. + */ +public class FormulaFloatAction extends ElementCaseAction { + + private boolean returnValue = false; + + public FormulaFloatAction(ElementCasePane t) { + super(t); + this.setMenuKeySet(FLOAT_INSERT_FORMULA); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); + } + + public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'F'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_Insert_Formula"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + private void doWithDrawingFloatElement() { + ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + Grid grid = jws.getGrid(); + + ElementCasePane reportPane = grid.getElementCasePane(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int resolution = grid.getResolution(); + int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); + int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); + + FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); + FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + grid.getDrawingFloatElement().setLeftDistance(leftDistance); + grid.getDrawingFloatElement().setTopDistance(topDistance); + + report.addFloatElement(grid.getDrawingFloatElement()); + reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); + } + + /** + * 执行动作 + * + * @return 成功返回true + */ + @Override + public boolean executeActionReturnUndoRecordNeeded() { + final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (reportPane == null) { + return false; + } + + reportPane.stopEditing(); + final FloatElement floatElement = new FloatElement(); + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build()); + + BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + floatElement.setValue(formulaPane.update()); + if (reportPane == null) { + return; + } + reportPane.getGrid().setDrawingFloatElement(floatElement); + doWithDrawingFloatElement(); + returnValue = true; + } + + @Override + public void doCancel() { + returnValue = false; + } + }); + dialog.setVisible(true); + return returnValue; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java index 2fc9ff2005..d480703718 100644 --- a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java @@ -6,7 +6,6 @@ package com.fr.design.cell.editor; import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.base.Formula; import com.fr.base.Utils; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; @@ -28,10 +27,27 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.Element; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; /** diff --git a/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java b/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java index fb68157271..f432c39f7b 100644 --- a/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java +++ b/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java @@ -4,8 +4,15 @@ package com.fr.design.headerfooter; import com.fr.base.BaseFormula; -import com.fr.base.Formula; -import com.fr.base.headerfooter.*; +import com.fr.base.headerfooter.DateHFElement; +import com.fr.base.headerfooter.FormulaHFElement; +import com.fr.base.headerfooter.HFElement; +import com.fr.base.headerfooter.ImageHFElement; +import com.fr.base.headerfooter.NewLineHFElement; +import com.fr.base.headerfooter.NumberOfPageHFElement; +import com.fr.base.headerfooter.PageNumberHFElement; +import com.fr.base.headerfooter.TextHFElement; +import com.fr.base.headerfooter.TimeHFElement; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; diff --git a/designer/src/com/fr/design/report/RichTextEditingPane.java b/designer/src/com/fr/design/report/RichTextEditingPane.java index 6999f26a7b..57c5fad2e6 100644 --- a/designer/src/com/fr/design/report/RichTextEditingPane.java +++ b/designer/src/com/fr/design/report/RichTextEditingPane.java @@ -5,7 +5,6 @@ package com.fr.design.report; import com.fr.base.BaseFormula; import com.fr.base.FRContext; -import com.fr.base.Formula; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; diff --git a/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java b/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java index 7d03162731..bd71b300a0 100644 --- a/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java +++ b/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java @@ -1,6 +1,6 @@ package com.fr.design.editor; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.design.editor.editor.BooleanEditor; import com.fr.design.editor.editor.ColumnRowEditor; import com.fr.design.editor.editor.ColumnRowGroupEditor; @@ -471,9 +471,9 @@ public class ValueEditorPaneFactory { if (hyperLinkEditorMap == null) { return lists; } - Iterator> entries = hyperLinkEditorMap.entrySet().iterator(); + Iterator> entries = hyperLinkEditorMap.entrySet().iterator(); while (entries.hasNext()) { - Map.Entry entry = entries.next(); + Map.Entry entry = entries.next(); ConstantsEditor editor = new ConstantsEditor(entry.getKey(), entry.getValue()); editor.setEnabled(false); lists.add(editor); diff --git a/designer_base/src/com/fr/design/editor/editor/ConstantsEditor.java b/designer_base/src/com/fr/design/editor/editor/ConstantsEditor.java index ec12015211..31f99e58c1 100644 --- a/designer_base/src/com/fr/design/editor/editor/ConstantsEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ConstantsEditor.java @@ -1,7 +1,6 @@ package com.fr.design.editor.editor; import com.fr.base.BaseFormula; -import com.fr.base.Formula; public class ConstantsEditor extends FormulaEditor { @@ -19,6 +18,6 @@ public class ConstantsEditor extends FormulaEditor { } public boolean accept(Object object) { - return object instanceof Formula && object.equals(this.getValue()); + return object instanceof BaseFormula && object.equals(this.getValue()); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/formula/FormulaPaneWhenReserveFormula.java b/designer_base/src/com/fr/design/formula/FormulaPaneWhenReserveFormula.java index ecd89c0101..40ace6a483 100644 --- a/designer_base/src/com/fr/design/formula/FormulaPaneWhenReserveFormula.java +++ b/designer_base/src/com/fr/design/formula/FormulaPaneWhenReserveFormula.java @@ -1,7 +1,6 @@ package com.fr.design.formula; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.general.Inter; diff --git a/designer_base/src/com/fr/design/formula/TinyFormulaPane.java b/designer_base/src/com/fr/design/formula/TinyFormulaPane.java index 5c67eaff14..0f19e219d9 100644 --- a/designer_base/src/com/fr/design/formula/TinyFormulaPane.java +++ b/designer_base/src/com/fr/design/formula/TinyFormulaPane.java @@ -2,18 +2,14 @@ package com.fr.design.formula; import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; -import com.fr.base.Formula; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import javax.swing.*; diff --git a/designer_base/src/com/fr/design/formula/UIFormula.java b/designer_base/src/com/fr/design/formula/UIFormula.java index 23f380a870..9eec6f14b8 100644 --- a/designer_base/src/com/fr/design/formula/UIFormula.java +++ b/designer_base/src/com/fr/design/formula/UIFormula.java @@ -1,7 +1,6 @@ package com.fr.design.formula; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionListener; diff --git a/designer_base/src/com/fr/design/present/dict/DatabaseDictPane.java b/designer_base/src/com/fr/design/present/dict/DatabaseDictPane.java index 5cd4e41ea0..72def6f055 100644 --- a/designer_base/src/com/fr/design/present/dict/DatabaseDictPane.java +++ b/designer_base/src/com/fr/design/present/dict/DatabaseDictPane.java @@ -1,6 +1,6 @@ package com.fr.design.present.dict; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.base.TableData; import com.fr.data.core.db.DBUtils; import com.fr.data.impl.DatabaseDictionary; @@ -205,7 +205,7 @@ public class DatabaseDictPane extends FurtherBasicBeanPane i dbDict.setValueColumnIndex(valueColumnIndex); dbDict.setValueColumnName(valueColumnName); } else { - dbDict.setFormula(((Formula) value)); + dbDict.setFormula(((BaseFormula) value)); } return dbDict; diff --git a/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java b/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java index fd7c14da1c..343de54d4c 100644 --- a/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java +++ b/designer_base/src/com/fr/design/present/dict/TableDataDictPane.java @@ -1,371 +1,371 @@ -package com.fr.design.present.dict; - -import com.fr.base.Formula; -import com.fr.base.TableData; -import com.fr.data.TableDataSource; -import com.fr.data.impl.DBTableData; -import com.fr.data.impl.DynamicSQLDict; -import com.fr.data.impl.NameTableData; -import com.fr.data.impl.TableDataDictionary; -import com.fr.design.DesignModelAdapter; -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.constants.UIConstants; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.datapane.TableDataComboBox; -import com.fr.design.data.datapane.TableDataTreePane; -import com.fr.design.data.datapane.preview.PreviewLabel; -import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; -import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; -import com.fr.design.editor.DoubleDeckValueEditorPane; -import com.fr.design.editor.editor.ColumnIndexEditor; -import com.fr.design.editor.editor.ColumnNameEditor; -import com.fr.design.editor.editor.Editor; -import com.fr.design.editor.editor.FormulaEditor; -import com.fr.design.event.UIObserver; -import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.List; - -/** - * 数据字典的数据查询面板 - * - * @editor zhou - * @since 2012-3-29下午1:49:24 - */ -public class TableDataDictPane extends FurtherBasicBeanPane implements Previewable, UIObserver { - private static final int BEGIN = 1; - private static final int END = 10; - private static final int VGAP = 24; - private static final long serialVersionUID = -5469742115988153206L; - private static final int SELECTED_NO_TABLEDATA = -2; - public TableDataComboBox tableDataNameComboBox; - private DoubleDeckValueEditorPane keyColumnPane; - private DoubleDeckValueEditorPane valueDictPane; - private ItemListener itemListener; - private UIObserverListener uiObserverListener; - - public TableDataDictPane() { - initBasicComponets(); - initComponents(); - iniListener(); - } - - public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(new TableDataDictPane(), BorderLayout.NORTH); - GUICoreUtils.centerWindow(jf); - jf.setSize(290, 400); - jf.setVisible(true); - } - - private void initBasicComponets() { - tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); - tableDataNameComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - tdChange(e); - } - } - }); -// keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); - keyColumnPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); - FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); - formulaEditor.setEnabled(true); -// valueDictPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); - valueDictPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); - } - - private void initComponents() { - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p, p}; - int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}}; - - JPanel firstLine = new JPanel(new BorderLayout(4, 0)); - firstLine.add(tableDataNameComboBox, BorderLayout.CENTER); - firstLine.add(new PreviewLabel(this), BorderLayout.EAST); - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("FR-Designer_DS_TableData") + " ", UILabel.LEFT), firstLine}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value") + " ", UILabel.LEFT), keyColumnPane}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value") + " ", UILabel.LEFT), valueDictPane}, - }; - - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, VGAP, LayoutConstants.VGAP_MEDIUM); - this.setLayout(new BorderLayout()); - this.add(panel, BorderLayout.CENTER); - } - - - private void iniListener() { - if (shouldResponseChangeListener()) { - this.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (uiObserverListener == null) { - return; - } - if (e.getStateChange() == ItemEvent.SELECTED) { - uiObserverListener.doChange(); - } - } - }); - } - } - - /** - * 增加Listener - * - * @param aListener 将本对象的Listener指向该listener - */ - public void addItemListener(ItemListener aListener) { - this.itemListener = aListener; - } - - /** - * 该面板标题 - * - * @return 返回是窗口显示的标题 - */ - public String title4PopupWindow() { - return Inter.getLocText("FR-Designer_Dic_Data_Query"); - } - - private void tdChange(final ItemEvent e) { - TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); - if (tableDataWrappe == null) { - return; - } - - List namelist = tableDataWrappe.calculateColumnNameList(); - String[] columnNames = null; - if (!namelist.isEmpty()) { - columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); - } else { - columnNames = new String[]{""}; - } - ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); - columnNameEditor1.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor1.addItemListener(itemListener); - keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); - - FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); - formulaEditor.setEnabled(true); - formulaEditor.addChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent ee) { - if (itemListener != null) { - itemListener.itemStateChanged(e); - } - } - }); - ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); - columnNameEditor2.addItemListener(itemListener); - ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); - columnIndexEditor2.addItemListener(itemListener); - valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); - if (itemListener != null) { - itemListener.itemStateChanged(e); - } - } - - @Override - /** - * - */ - public void populateBean(TableDataDictionary tableDataDict) { - populate(tableDataDict, ""); - } - - private void populate(TableDataDictionary tableDataDict, String name) { - if (tableDataDict == null || tableDataDict.getTableData() == TableData.EMPTY_TABLEDATA) { - this.tableDataNameComboBox.setSelectedIndex(-1); - this.keyColumnPane.populate(StringUtils.EMPTY); - this.valueDictPane.populate(StringUtils.EMPTY); - return; - } - if (tableDataDict.getTableData() instanceof DBTableData && !"".equals(name)) { - this.tableDataNameComboBox.putTableDataIntoMap(name, new TemplateTableDataWrapper( - (DBTableData) tableDataDict.getTableData(), name)); - this.tableDataNameComboBox.setSelectedTableDataByName(name); - } else if (tableDataDict.getTableData() instanceof NameTableData) { - this.tableDataNameComboBox.setSelectedTableDataByName(((NameTableData) tableDataDict.getTableData()) - .getName()); - } - // alex:因为显示到界面上的index是以1为始的,所以要加1 - - TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); - if (tableDataWrappe == null) { - keyColumnPane.resetComponets(); - valueDictPane.resetComponets(); - } else { - if (StringUtils.isNotEmpty(tableDataDict.getKeyColumnName())) { - this.keyColumnPane.populate(tableDataDict.getKeyColumnName()); - } else { - this.keyColumnPane.populate(tableDataDict.getKeyColumnIndex() + 1); - } - - Object value = null; - if (tableDataDict.getFormula() != null) { - value = tableDataDict.getFormula(); - } else { - if (StringUtils.isNotEmpty(tableDataDict.getValueColumnName())) { - value = tableDataDict.getValueColumnName(); - } else { - value = tableDataDict.getValueColumnIndex() + 1; - } - } - - this.valueDictPane.populate(value); - } - } - - /** - * @param dsql - */ - public void populateBean(DynamicSQLDict dsql) { - DBTableData db = new DBTableData(dsql.getDatabaseConnection(), dsql.getSqlFormula()); - String name = ""; - TableDataSource dataSource = DesignTableDataManager.getEditingTableDataSource(); - if (dataSource != null) { - for (int i = BEGIN; i < END; i++) { - TableData td = dataSource.getTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i); - if (td == null) { - name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; - dataSource.putTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i, db); - break; - } else { - if (ComparatorUtils.equals(td, db)) { - name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; - break; - } else { - continue; - } - } - } - } - - TableDataDictionary tdd = new TableDataDictionary(db, dsql.getKeyColumnIndex(), dsql.getValueColumnIndex()); - if (dsql.getFormula() != null) { - tdd.setFormula(dsql.getFormula()); - } - this.populate(tdd, name); - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); - } - - /** - * @return - */ - public TableDataDictionary updateBean() { - TableDataDictionary tableDataDict = new TableDataDictionary(); - Object object = this.valueDictPane.update(); - // alex:因为显示到界面上的index是以1为始的,所以要减1 - // carl:假如这里的序号要变,请考虑6.2的兼容 - if (object instanceof Integer) { - int valuleColumnIndex = (Integer) object - 1; - String valueColumnName = StringUtils.EMPTY; - - if (this.valueDictPane.getCurrentEditor() instanceof ColumnNameEditor) { - valueColumnName = ((ColumnNameEditor) this.valueDictPane.getCurrentEditor()).getColumnName(); - valuleColumnIndex = -1; - } - tableDataDict.setValueColumnIndex(valuleColumnIndex); - tableDataDict.setValueColumnName(valueColumnName); - } else { - tableDataDict.setFormula(((Formula) object)); - } - TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); - if (tableDataWrappe != null) { - tableDataDict.setTableData(new NameTableData(tableDataWrappe.getTableDataName())); - int keyColumnIndex = (Integer) this.keyColumnPane.update() - 1; - String keyColumnName = StringUtils.EMPTY; - - if (keyColumnPane.getCurrentEditor() instanceof ColumnNameEditor) { - keyColumnName = ((ColumnNameEditor) this.keyColumnPane.getCurrentEditor()).getColumnName(); - keyColumnIndex = -1; - } - - tableDataDict.setKeyColumnIndex(keyColumnIndex); - tableDataDict.setKeyColumnName(keyColumnName); - } - - return tableDataDict; - } - - /** - * 预览 - */ - public void preview() { - TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem(); - if (tableDataWrappe == null) { - return; - } - Object object = this.valueDictPane.update(); - if (object instanceof Integer) { - tableDataWrappe.previewData((Integer) this.keyColumnPane.update() - 1, (Integer) object - 1); - } - - } - - /** - * 判断ob是否是TableDataDictionary类型 - * - * @param ob 用于判断的Object - * @return 如果是TableDataDictionary类型,则返回true - */ - public boolean accept(Object ob) { - return ob instanceof TableDataDictionary; - } - - @Override - /** - *重置 - */ - public void reset() { - GUICoreUtils.setSelectedItemQuietly(tableDataNameComboBox, UIConstants.PENDING); - keyColumnPane.clearComponentsData(); - valueDictPane.clearComponentsData(); - } - - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; - } - - /** - * 是否应该相应listener事件 - * - * @return 要是响应listener事件,则返回true - */ - public boolean shouldResponseChangeListener() { - return true; - } +package com.fr.design.present.dict; + +import com.fr.base.BaseFormula; +import com.fr.base.TableData; +import com.fr.data.TableDataSource; +import com.fr.data.impl.DBTableData; +import com.fr.data.impl.DynamicSQLDict; +import com.fr.data.impl.NameTableData; +import com.fr.data.impl.TableDataDictionary; +import com.fr.design.DesignModelAdapter; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.TableDataComboBox; +import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.data.datapane.preview.PreviewLabel; +import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; +import com.fr.design.editor.DoubleDeckValueEditorPane; +import com.fr.design.editor.editor.ColumnIndexEditor; +import com.fr.design.editor.editor.ColumnNameEditor; +import com.fr.design.editor.editor.Editor; +import com.fr.design.editor.editor.FormulaEditor; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.List; + +/** + * 数据字典的数据查询面板 + * + * @editor zhou + * @since 2012-3-29下午1:49:24 + */ +public class TableDataDictPane extends FurtherBasicBeanPane implements Previewable, UIObserver { + private static final int BEGIN = 1; + private static final int END = 10; + private static final int VGAP = 24; + private static final long serialVersionUID = -5469742115988153206L; + private static final int SELECTED_NO_TABLEDATA = -2; + public TableDataComboBox tableDataNameComboBox; + private DoubleDeckValueEditorPane keyColumnPane; + private DoubleDeckValueEditorPane valueDictPane; + private ItemListener itemListener; + private UIObserverListener uiObserverListener; + + public TableDataDictPane() { + initBasicComponets(); + initComponents(); + iniListener(); + } + + public static void main(String[] args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(new TableDataDictPane(), BorderLayout.NORTH); + GUICoreUtils.centerWindow(jf); + jf.setSize(290, 400); + jf.setVisible(true); + } + + private void initBasicComponets() { + tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); + tableDataNameComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + tdChange(e); + } + } + }); +// keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); + keyColumnPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); + FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); + formulaEditor.setEnabled(true); +// valueDictPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); + valueDictPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); + } + + private void initComponents() { + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p, p}; + int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}}; + + JPanel firstLine = new JPanel(new BorderLayout(4, 0)); + firstLine.add(tableDataNameComboBox, BorderLayout.CENTER); + firstLine.add(new PreviewLabel(this), BorderLayout.EAST); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer_DS_TableData") + " ", UILabel.LEFT), firstLine}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value") + " ", UILabel.LEFT), keyColumnPane}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value") + " ", UILabel.LEFT), valueDictPane}, + }; + + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, VGAP, LayoutConstants.VGAP_MEDIUM); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (uiObserverListener == null) { + return; + } + if (e.getStateChange() == ItemEvent.SELECTED) { + uiObserverListener.doChange(); + } + } + }); + } + } + + /** + * 增加Listener + * + * @param aListener 将本对象的Listener指向该listener + */ + public void addItemListener(ItemListener aListener) { + this.itemListener = aListener; + } + + /** + * 该面板标题 + * + * @return 返回是窗口显示的标题 + */ + public String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Dic_Data_Query"); + } + + private void tdChange(final ItemEvent e) { + TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); + if (tableDataWrappe == null) { + return; + } + + List namelist = tableDataWrappe.calculateColumnNameList(); + String[] columnNames = null; + if (!namelist.isEmpty()) { + columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); + } else { + columnNames = new String[]{""}; + } + ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); + columnNameEditor1.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor1.addItemListener(itemListener); + keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); + + FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); + formulaEditor.setEnabled(true); + formulaEditor.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent ee) { + if (itemListener != null) { + itemListener.itemStateChanged(e); + } + } + }); + ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); + columnNameEditor2.addItemListener(itemListener); + ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); + columnIndexEditor2.addItemListener(itemListener); + valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); + if (itemListener != null) { + itemListener.itemStateChanged(e); + } + } + + @Override + /** + * + */ + public void populateBean(TableDataDictionary tableDataDict) { + populate(tableDataDict, ""); + } + + private void populate(TableDataDictionary tableDataDict, String name) { + if (tableDataDict == null || tableDataDict.getTableData() == TableData.EMPTY_TABLEDATA) { + this.tableDataNameComboBox.setSelectedIndex(-1); + this.keyColumnPane.populate(StringUtils.EMPTY); + this.valueDictPane.populate(StringUtils.EMPTY); + return; + } + if (tableDataDict.getTableData() instanceof DBTableData && !"".equals(name)) { + this.tableDataNameComboBox.putTableDataIntoMap(name, new TemplateTableDataWrapper( + (DBTableData) tableDataDict.getTableData(), name)); + this.tableDataNameComboBox.setSelectedTableDataByName(name); + } else if (tableDataDict.getTableData() instanceof NameTableData) { + this.tableDataNameComboBox.setSelectedTableDataByName(((NameTableData) tableDataDict.getTableData()) + .getName()); + } + // alex:因为显示到界面上的index是以1为始的,所以要加1 + + TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); + if (tableDataWrappe == null) { + keyColumnPane.resetComponets(); + valueDictPane.resetComponets(); + } else { + if (StringUtils.isNotEmpty(tableDataDict.getKeyColumnName())) { + this.keyColumnPane.populate(tableDataDict.getKeyColumnName()); + } else { + this.keyColumnPane.populate(tableDataDict.getKeyColumnIndex() + 1); + } + + Object value = null; + if (tableDataDict.getFormula() != null) { + value = tableDataDict.getFormula(); + } else { + if (StringUtils.isNotEmpty(tableDataDict.getValueColumnName())) { + value = tableDataDict.getValueColumnName(); + } else { + value = tableDataDict.getValueColumnIndex() + 1; + } + } + + this.valueDictPane.populate(value); + } + } + + /** + * @param dsql + */ + public void populateBean(DynamicSQLDict dsql) { + DBTableData db = new DBTableData(dsql.getDatabaseConnection(), dsql.getSqlFormula()); + String name = ""; + TableDataSource dataSource = DesignTableDataManager.getEditingTableDataSource(); + if (dataSource != null) { + for (int i = BEGIN; i < END; i++) { + TableData td = dataSource.getTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i); + if (td == null) { + name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; + dataSource.putTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i, db); + break; + } else { + if (ComparatorUtils.equals(td, db)) { + name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; + break; + } else { + continue; + } + } + } + } + + TableDataDictionary tdd = new TableDataDictionary(db, dsql.getKeyColumnIndex(), dsql.getValueColumnIndex()); + if (dsql.getFormula() != null) { + tdd.setFormula(dsql.getFormula()); + } + this.populate(tdd, name); + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); + } + + /** + * @return + */ + public TableDataDictionary updateBean() { + TableDataDictionary tableDataDict = new TableDataDictionary(); + Object object = this.valueDictPane.update(); + // alex:因为显示到界面上的index是以1为始的,所以要减1 + // carl:假如这里的序号要变,请考虑6.2的兼容 + if (object instanceof Integer) { + int valuleColumnIndex = (Integer) object - 1; + String valueColumnName = StringUtils.EMPTY; + + if (this.valueDictPane.getCurrentEditor() instanceof ColumnNameEditor) { + valueColumnName = ((ColumnNameEditor) this.valueDictPane.getCurrentEditor()).getColumnName(); + valuleColumnIndex = -1; + } + tableDataDict.setValueColumnIndex(valuleColumnIndex); + tableDataDict.setValueColumnName(valueColumnName); + } else { + tableDataDict.setFormula(((BaseFormula) object)); + } + TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); + if (tableDataWrappe != null) { + tableDataDict.setTableData(new NameTableData(tableDataWrappe.getTableDataName())); + int keyColumnIndex = (Integer) this.keyColumnPane.update() - 1; + String keyColumnName = StringUtils.EMPTY; + + if (keyColumnPane.getCurrentEditor() instanceof ColumnNameEditor) { + keyColumnName = ((ColumnNameEditor) this.keyColumnPane.getCurrentEditor()).getColumnName(); + keyColumnIndex = -1; + } + + tableDataDict.setKeyColumnIndex(keyColumnIndex); + tableDataDict.setKeyColumnName(keyColumnName); + } + + return tableDataDict; + } + + /** + * 预览 + */ + public void preview() { + TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem(); + if (tableDataWrappe == null) { + return; + } + Object object = this.valueDictPane.update(); + if (object instanceof Integer) { + tableDataWrappe.previewData((Integer) this.keyColumnPane.update() - 1, (Integer) object - 1); + } + + } + + /** + * 判断ob是否是TableDataDictionary类型 + * + * @param ob 用于判断的Object + * @return 如果是TableDataDictionary类型,则返回true + */ + public boolean accept(Object ob) { + return ob instanceof TableDataDictionary; + } + + @Override + /** + *重置 + */ + public void reset() { + GUICoreUtils.setSelectedItemQuietly(tableDataNameComboBox, UIConstants.PENDING); + keyColumnPane.clearComponentsData(); + valueDictPane.clearComponentsData(); + } + + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + /** + * 是否应该相应listener事件 + * + * @return 要是响应listener事件,则返回true + */ + public boolean shouldResponseChangeListener() { + return true; + } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/ChartSwingUtils.java b/designer_chart/src/com/fr/design/chart/ChartSwingUtils.java index 92f5dda5c3..0a7ebd5833 100644 --- a/designer_chart/src/com/fr/design/chart/ChartSwingUtils.java +++ b/designer_chart/src/com/fr/design/chart/ChartSwingUtils.java @@ -1,7 +1,6 @@ package com.fr.design.chart; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.base.Utils; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; diff --git a/designer_chart/src/com/fr/design/chart/axis/ChartAlertValuePane.java b/designer_chart/src/com/fr/design/chart/axis/ChartAlertValuePane.java index c0fa135c1d..a9dbf91a8b 100644 --- a/designer_chart/src/com/fr/design/chart/axis/ChartAlertValuePane.java +++ b/designer_chart/src/com/fr/design/chart/axis/ChartAlertValuePane.java @@ -1,7 +1,6 @@ package com.fr.design.chart.axis; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.base.Utils; import com.fr.chart.chartattr.ChartAlertValue; import com.fr.design.beans.BasicBeanPane; diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java index 3c1d576bde..0433ad922a 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.chart.gui.data.report; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java index 28737b0a1c..602e7ddcad 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.chart.gui.style.axis; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.base.Utils; import com.fr.chart.base.ChartBaseUtils; import com.fr.chart.base.ChartConstants; diff --git a/designer_chart/src/com/fr/plugin/chart/designer/style/axis/VanChartValueAxisPane.java b/designer_chart/src/com/fr/plugin/chart/designer/style/axis/VanChartValueAxisPane.java index be5bc4c7b0..dbd9e28538 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/style/axis/VanChartValueAxisPane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/style/axis/VanChartValueAxisPane.java @@ -1,7 +1,6 @@ package com.fr.plugin.chart.designer.style.axis; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.chart.base.ChartBaseUtils; import com.fr.design.chart.ChartSwingUtils; import com.fr.design.gui.icheckbox.UICheckBox; diff --git a/designer_form/src/com/fr/design/gui/xpane/JTreeAutoBuildPane.java b/designer_form/src/com/fr/design/gui/xpane/JTreeAutoBuildPane.java index 52433d6bb4..d0bbcbdad8 100644 --- a/designer_form/src/com/fr/design/gui/xpane/JTreeAutoBuildPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/JTreeAutoBuildPane.java @@ -1,6 +1,6 @@ package com.fr.design.gui.xpane; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.data.impl.NameTableData; import com.fr.data.impl.RecursionTableData; import com.fr.data.impl.TableDataDictionary; @@ -144,7 +144,7 @@ public class JTreeAutoBuildPane extends BasicPane implements Previewable, Editab if (object instanceof Integer) { tableDataDict.setValueColumnIndex((Integer) object - 1); } else { - tableDataDict.setFormula(((Formula) object)); + tableDataDict.setFormula(((BaseFormula) object)); } TableDataWrapper tableDataWrappe = this.treeTableDataComboBox.getSelectedItem(); if (tableDataWrappe != null) { diff --git a/designer_form/src/com/fr/design/gui/xtable/TableUtils.java b/designer_form/src/com/fr/design/gui/xtable/TableUtils.java index 413c1d1ee8..fd2d00619c 100644 --- a/designer_form/src/com/fr/design/gui/xtable/TableUtils.java +++ b/designer_form/src/com/fr/design/gui/xtable/TableUtils.java @@ -3,16 +3,7 @@ */ package com.fr.design.gui.xtable; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; -import java.util.HashMap; - -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; - -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.ColorEditor; import com.fr.design.mainframe.widget.editors.DimensionEditor; @@ -31,6 +22,11 @@ import com.fr.design.mainframe.widget.renderer.PointCellRenderer; import com.fr.design.mainframe.widget.renderer.RectangleCellRenderer; import com.fr.third.com.lowagie.text.Rectangle; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.util.HashMap; + /** * @author richer * @since 6.5.3 @@ -56,7 +52,7 @@ public class TableUtils { propertyEditorClasses.put(double.class, DoubleEditor.class); propertyEditorClasses.put(Double.class, IntegerPropertyEditor.class); - propertyEditorClasses.put(Formula.class, FormulaEditor.class); + propertyEditorClasses.put(BaseFormula.class, FormulaEditor.class); // TODO ALEX_SEP // propertyEditorClasses.put(DSColumn.class, DSColumnEditor.class); @@ -78,10 +74,24 @@ public class TableUtils { } public static Class getPropertyEditorClass(Class propType) { - return propertyEditorClasses.get(propType); + Class clazz = propertyEditorClasses.get(propType); + if (clazz == null) { + Class superClazz = propType.getSuperclass(); + if (superClazz != null) { + return getPropertyEditorClass(superClazz); + } + } + return clazz; } public static Class getTableCellRendererClass(Class propType) { - return cellRendererClasses.get(propType); + Class clazz = cellRendererClasses.get(propType); + if (clazz == null) { + Class superClazz = propType.getSuperclass(); + if (superClazz != null) { + return getTableCellRendererClass(superClazz); + } + } + return clazz; } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleFormulaEditor.java b/designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleFormulaEditor.java index 8c810dd05d..17074d0fa9 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleFormulaEditor.java +++ b/designer_form/src/com/fr/design/mainframe/widget/accessibles/AccessibleFormulaEditor.java @@ -4,7 +4,6 @@ package com.fr.design.mainframe.widget.accessibles; import com.fr.base.BaseFormula; -import com.fr.base.Formula; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; diff --git a/designer_form/src/com/fr/design/mainframe/widget/wrappers/FormulaWrapper.java b/designer_form/src/com/fr/design/mainframe/widget/wrappers/FormulaWrapper.java index 9a87c9adc1..f66e438be1 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/wrappers/FormulaWrapper.java +++ b/designer_form/src/com/fr/design/mainframe/widget/wrappers/FormulaWrapper.java @@ -4,12 +4,11 @@ package com.fr.design.mainframe.widget.wrappers; import com.fr.base.BaseFormula; -import com.fr.base.Formula; -import com.fr.general.Inter; -import com.fr.stable.StringUtils; import com.fr.design.Exception.ValidationException; import com.fr.design.designer.properties.Decoder; import com.fr.design.designer.properties.Encoder; +import com.fr.general.Inter; +import com.fr.stable.StringUtils; /** * @author richer diff --git a/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java index b797594670..99d1c6d2b2 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java @@ -1,7 +1,6 @@ package com.fr.design.widget.ui.designer; import com.fr.base.FRContext; -import com.fr.base.Formula; import com.fr.data.core.FormatField; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; @@ -15,15 +14,10 @@ import com.fr.design.widget.component.DateValuePane; import com.fr.design.widget.component.UIComboBoxNoArrow; import com.fr.design.widget.ui.designer.component.FormWidgetValuePane; import com.fr.form.ui.DateEditor; -import com.fr.general.DateUtils; import com.fr.general.Inter; -import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; -import com.fr.stable.UtilEvalError; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*;