diff --git a/designer/src/com/fr/design/actions/CellSelectionAction.java b/designer/src/com/fr/design/actions/CellSelectionAction.java index 8ca67feafc..16bf089c55 100644 --- a/designer/src/com/fr/design/actions/CellSelectionAction.java +++ b/designer/src/com/fr/design/actions/CellSelectionAction.java @@ -5,30 +5,33 @@ import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; public abstract class CellSelectionAction extends ElementCaseAction { - protected CellSelectionAction(ElementCasePane t) { - super(t); - } - - @Override - public boolean executeActionReturnUndoRecordNeeded() { - ElementCasePane ePane = this.getEditingComponent(); - Selection s = ePane.getSelection(); - - // TODO ALEX_SEP instanceof i hate it - if (s instanceof CellSelection) { - return executeActionReturnUndoRecordNeededWithCellSelection((CellSelection)s); - } - - return false; - } - - protected abstract boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs); - - @Override - public void update() { - super.update(); - if (this.isEnabled()) { - this.setEnabled(this.getEditingComponent().getSelection() instanceof CellSelection); - } - } + protected CellSelectionAction() { + } + + protected CellSelectionAction(ElementCasePane t) { + super(t); + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + ElementCasePane ePane = this.getEditingComponent(); + Selection s = ePane.getSelection(); + + // TODO ALEX_SEP instanceof i hate it + if (s instanceof CellSelection) { + return executeActionReturnUndoRecordNeededWithCellSelection((CellSelection) s); + } + + return false; + } + + protected abstract boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs); + + @Override + public void update() { + super.update(); + if (this.isEnabled()) { + this.setEnabled(this.getEditingComponent().getSelection() instanceof CellSelection); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/ElementCaseAction.java b/designer/src/com/fr/design/actions/ElementCaseAction.java index bfc0c8b4e5..09b7848306 100644 --- a/designer/src/com/fr/design/actions/ElementCaseAction.java +++ b/designer/src/com/fr/design/actions/ElementCaseAction.java @@ -3,17 +3,15 @@ package com.fr.design.actions; //ElementCaseAction应该有GridSelectionChangeListener,就从悬浮元素和单元格来讲,就必须有了,用来判断这些ElementCaseAction是否可以编辑,当然还可以做些其他事情 // -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.design.selection.SelectionEvent; -import com.fr.design.selection.SelectionListener; public abstract class ElementCaseAction extends SelectionListenerAction { - protected ElementCaseAction(ElementCasePane t) { - super(t); - t.addSelectionChangeListener(createSelectionListener()); - } + protected ElementCaseAction() { + } + + protected ElementCaseAction(ElementCasePane t) { + super(t); + t.addSelectionChangeListener(createSelectionListener()); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/SelectionListenerAction.java b/designer/src/com/fr/design/actions/SelectionListenerAction.java index 48cd2d4f9a..d150460ec7 100644 --- a/designer/src/com/fr/design/actions/SelectionListenerAction.java +++ b/designer/src/com/fr/design/actions/SelectionListenerAction.java @@ -12,11 +12,14 @@ import com.fr.grid.selection.Selection; */ public abstract class SelectionListenerAction extends TemplateComponentAction { + protected SelectionListenerAction() { + } + protected SelectionListenerAction(ElementCasePane elementCasePane) { super(elementCasePane); } - protected SelectionListener createSelectionListener () { + protected SelectionListener createSelectionListener() { return new SelectionListener() { @Override diff --git a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java index 0036b28060..8143409cfe 100644 --- a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java +++ b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java @@ -1,36 +1,33 @@ package com.fr.design.actions.columnrow; import com.fr.base.BaseUtils; -import com.fr.design.data.DesignTableDataManager; import com.fr.design.actions.cell.AbstractCellElementAction; -import com.fr.design.dscolumn.DSColumnConditionsPane; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; +import com.fr.design.dscolumn.DSColumnConditionsPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; public class DSColumnConditionAction extends AbstractCellElementAction { - private boolean returnValue = false; - private TemplateCellElement editCellElement; - public DSColumnConditionAction(ElementCasePane t) { - super(t); - + super(t); + this.setName(Inter.getLocText("Filter")); this.setMnemonic('E'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif")); } @Override - protected BasicPane populateBasicPane(TemplateCellElement cellElement) { + protected BasicPane populateBasicPane(TemplateCellElement cellElement) { DSColumnConditionsPane dSColumnConditionsPane = new DSColumnConditionsPane(); dSColumnConditionsPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement); return dSColumnConditionsPane; } @Override - protected void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) { + protected void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) { ((DSColumnConditionsPane) bp).update(cellElement); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java b/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java index a8c9ab80fe..1127acf538 100644 --- a/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java @@ -13,12 +13,15 @@ import com.fr.report.elementcase.TemplateElementCase; * Cell. */ public abstract class AbstractCellAction extends CellSelectionAction { - protected AbstractCellAction(ElementCasePane t) { - super(t); - } - + protected AbstractCellAction() { + } + + protected AbstractCellAction(ElementCasePane t) { + super(t); + } + public abstract Class getCellValueClass(); - + /* * TODO ALEX_SEP 这里的返回boolean量表示模板是否改变,导致很多很多的方法的boolean返回值都是这个意思 * @@ -26,8 +29,8 @@ public abstract class AbstractCellAction extends CellSelectionAction { */ @Override protected boolean executeActionReturnUndoRecordNeededWithCellSelection( - CellSelection cs) { - ElementCasePane ePane = this.getEditingComponent(); + CellSelection cs) { + ElementCasePane ePane = this.getEditingComponent(); //got simple cell element from column and row. TemplateElementCase report = ePane.getEditingElementCase(); @@ -35,17 +38,18 @@ public abstract class AbstractCellAction extends CellSelectionAction { if (report != null && this instanceof DSColumnCellAction) { SheetUtils.calculateDefaultParent(report); } - + return ePane.getGrid().startCellEditingAt_DEC( - cs.getColumn(), - cs.getRow(), - this.getCellValueClass(), false + cs.getColumn(), + cs.getRow(), + this.getCellValueClass(), false ); } - @Override - public void update() { - super.update(); - ElementCasePane ePane = this.getEditingComponent(); - this.setEnabled(ePane.isSelectedOneCell()); - } + + @Override + public void update() { + super.update(); + ElementCasePane ePane = this.getEditingComponent(); + this.setEnabled(ePane.isSelectedOneCell()); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java b/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java index e3821f299d..9fc6162881 100644 --- a/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java @@ -3,8 +3,6 @@ */ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; @@ -12,12 +10,23 @@ import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; import com.fr.report.cell.painter.BiasTextPainter; +import javax.swing.KeyStroke; + /** * Bias */ public class BiasCellAction extends AbstractCellAction implements WorkBookSupportable { - public BiasCellAction(ElementCasePane t) { - super(t); + + public BiasCellAction() { + initAction(); + } + + public BiasCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_SLOPE_LINE); this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); diff --git a/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java b/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java index 8f12d287b2..83d8f238ee 100644 --- a/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java @@ -16,11 +16,19 @@ import javax.swing.*; * . */ public class ChartCellAction extends AbstractCellAction implements WorkBookSupportable { + public ChartCellAction(){ + initAction(); + } + public ChartCellAction(ElementCasePane t) { super(t); - this.setMenuKeySet(INSERT_CHART); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); - this.setMnemonic(getMenuKeySet().getMnemonic()); + initAction(); + } + + private void initAction() { + this.setMenuKeySet(INSERT_CHART); + this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png")); } diff --git a/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java b/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java index 90d0ccb8bc..7afd7b4ef7 100644 --- a/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java @@ -8,13 +8,21 @@ import com.fr.general.IOUtils; import com.fr.report.cell.cellattr.core.group.DSColumn; public class DSColumnCellAction extends AbstractCellAction implements WorkBookSupportable { - public DSColumnCellAction(ElementCasePane t) { - super(t); + public DSColumnCellAction() { + initAction(); + } + + public DSColumnCellAction(ElementCasePane t) { + super(t); + initAction(); + this.setSearchText(new DSColumnPane()); + } + + private void initAction() { this.setMenuKeySet(KeySetUtils.INSERT_DATA_COLUMN); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_insert/bindColumn.png")); - this.setSearchText(new DSColumnPane()); } @Override 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 92757d88e0..499b9119df 100644 --- a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java @@ -13,10 +13,18 @@ import com.fr.general.Inter; import javax.swing.*; public class FormulaCellAction extends AbstractCellAction implements WorkBookSupportable { - public FormulaCellAction(ElementCasePane t) { - super(t); + public FormulaCellAction() { + initAction(); + } + + public FormulaCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_FORMULA); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); } @@ -39,7 +47,7 @@ public class FormulaCellAction extends AbstractCellAction implements WorkBookSup }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return Formula.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java b/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java index 7146924673..40aef3198c 100644 --- a/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java @@ -15,10 +15,18 @@ import javax.swing.*; * */ public class GeneralCellAction extends AbstractCellAction implements WorkBookSupportable { - public GeneralCellAction(ElementCasePane t) { - super(t); + public GeneralCellAction() { + initAction(); + } + + public GeneralCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_TEXT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png")); } @@ -41,7 +49,7 @@ public class GeneralCellAction extends AbstractCellAction implements WorkBookSup }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return String.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java b/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java index 594cb771be..e3761909a9 100644 --- a/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java @@ -16,10 +16,18 @@ import java.awt.*; * Image */ public class ImageCellAction extends AbstractCellAction implements WorkBookSupportable { - public ImageCellAction(ElementCasePane t) { - super(t); + public ImageCellAction() { + initAction(); + } + + public ImageCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_IMAGE); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); } @@ -42,7 +50,7 @@ public class ImageCellAction extends AbstractCellAction implements WorkBookSuppo }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return Image.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java b/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java index c8017099f4..c9df15162b 100644 --- a/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java @@ -1,7 +1,5 @@ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; @@ -10,53 +8,64 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.report.cell.cellattr.core.RichText; +import javax.swing.KeyStroke; + public class RichTextCellAction extends AbstractCellAction implements WorkBookSupportable { - public RichTextCellAction(ElementCasePane t) { - super(t); + public RichTextCellAction() { + initAction(); + } + + public RichTextCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_RICHTEXT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon( "/com/fr/design/images/m_insert/richtext.png")); - } - - @Override - public Class getCellValueClass() { - return RichText.class; - } - - /** - * equals 比较 - * @param object - * @return true false - */ - @Override - public boolean equals(Object object) { - if (this == object){ - return true; - } - if (!(object instanceof RichTextCellAction)){ - return false; - } - - return ComparatorUtils.equals(this.getEditingComponent(),((RichTextCellAction)object).getEditingComponent()); - } + } + + @Override + public Class getCellValueClass() { + return RichText.class; + } + + /** + * equals 比较 + * + * @param object + * @return true false + */ + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof RichTextCellAction)) { + return false; + } + + return ComparatorUtils.equals(this.getEditingComponent(), ((RichTextCellAction) object).getEditingComponent()); + } private static final MenuKeySet INSERT_RICHTEXT = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'R'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Designer_RichText"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } + @Override + public char getMnemonic() { + return 'R'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_RichText"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } }; } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java b/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java index 79dc6c6421..a055bcd0d0 100644 --- a/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java @@ -1,7 +1,5 @@ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; @@ -9,54 +7,65 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.report.cell.cellattr.core.SubReport; +import javax.swing.KeyStroke; + public class SubReportCellAction extends AbstractCellAction { - public SubReportCellAction(ElementCasePane t) { - super(t); + public SubReportCellAction() { + initAction(); + } + + public SubReportCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_SUB_REPORT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon( "/com/fr/design/images/m_insert/subReport.png")); - } - - public static final MenuKeySet INSERT_SUB_REPORT = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'S'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("M_Insert-Sub_Report"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - /** - * equals 比较 - * @param object - * @return true false - */ - @Override - public boolean equals(Object object) { - if (this == object){ - return true; - } - if (!(object instanceof SubReportCellAction)){ - return false; - } - - return ComparatorUtils.equals(this.getEditingComponent(),((SubReportCellAction)object).getEditingComponent()); - } - - @Override - public Class getCellValueClass() { - return SubReport.class; - } + } + + public static final MenuKeySet INSERT_SUB_REPORT = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'S'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("M_Insert-Sub_Report"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + /** + * equals 比较 + * + * @param object + * @return true false + */ + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof SubReportCellAction)) { + return false; + } + + return ComparatorUtils.equals(this.getEditingComponent(), ((SubReportCellAction) object).getEditingComponent()); + } + + @Override + public Class getCellValueClass() { + return SubReport.class; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java deleted file mode 100644 index 57af1a340a..0000000000 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fr.design.dscolumn; - -import com.fr.design.mainframe.cell.CellEditorPane; -import com.fr.report.cell.TemplateCellElement; - - -/** - * 单元格元素 数据列 基本设置内容面板 - * - * @author yaoh.wu - * @version 2017年7月25日 - * @since 9.0 - */ -public class DSColumnAdvancedEditorPane extends CellEditorPane { - - - @Override - public String getIconPath() { - return "Advanced"; - } - - @Override - public String title4PopupWindow() { - return "Advanced"; - } - - - @Override - public void update() { - - } - - @Override - public void populate(TemplateCellElement cellElement) { - - } - -} diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java deleted file mode 100644 index ef0c5e0b51..0000000000 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.fr.design.dscolumn; - -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.cell.CellEditorPane; -import com.fr.report.cell.TemplateCellElement; - -import javax.swing.*; -import java.awt.*; - -/** - * 单元格元素 数据列 高级设置内容面板 - * - * @author yaoh.wu - * @version 2017年7月25日 - * @since 9.0 - */ -public class DSColumnBasicEditorPane extends CellEditorPane { - - //数据集和数据列 - private SelectedDataColumnPane dataPane; - //数据分组设置 - private ResultSetGroupDockingPane groupPane; - //当前编辑的单元格 - private TemplateCellElement cellElement; - //条件过滤按钮面板 - private JPanel conditionPane; - - public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane, JPanel conditionPane) { - this.setLayout(new BorderLayout()); - this.cellElement = cellElement; - this.dataPane = dataPane; - this.groupPane = groupPane; - this.conditionPane = conditionPane; - this.add(this.createContentPane(), BorderLayout.CENTER); - } - - - @Override - public String getIconPath() { - return "Basic"; - } - - @Override - public String title4PopupWindow() { - return "Basic"; - } - - - @Override - public void update() { - dataPane.update(this.cellElement); - groupPane.update(); - } - - @Override - public void populate(TemplateCellElement cellElement) { - this.cellElement = cellElement; - dataPane.populate(null, cellElement); - groupPane.populate(cellElement); - } - - - /** - * 创建有内容的面板显示信息 - * - * @return content JPanel - */ - private JPanel createContentPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p, p}; - Component[][] components = new Component[][]{ - //数据集列选择 - new Component[]{this.dataPane}, - //数据分组设置 - new Component[]{this.groupPane}, - //条件过滤 - new Component[]{this.conditionPane} - }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - } -} diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java index 9ba61e5475..603356a882 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java @@ -1,25 +1,23 @@ package com.fr.design.dscolumn; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; - import com.fr.data.TableDataSource; +import com.fr.design.dialog.BasicPane; import com.fr.design.expand.ConditionParentPane; import com.fr.design.expand.ExpandDirectionPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public class DSColumnBasicPane extends BasicPane { @@ -30,54 +28,54 @@ public class DSColumnBasicPane extends BasicPane { private CellElement cellElement; public DSColumnBasicPane() { - this(DSColumnPane.SETTING_ALL); + this(DSColumnPane.SETTING_ALL); } - + public DSColumnBasicPane(int setting) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); if (setting > DSColumnPane.SETTING_DSRELATED) { - selectDataColumnPane = new SelectedDataColumnPane(); + selectDataColumnPane = new SelectedDataColumnPane(); } else { - selectDataColumnPane = new SelectedConfirmedDataColumnPane(); + selectDataColumnPane = new SelectedConfirmedDataColumnPane(); } - + selectDataColumnPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Select_DataColumn"), null)); if (setting > DSColumnPane.SETTING_DSRELATED) { - conditionParentPane = new ConditionParentPane(); - conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null)); + conditionParentPane = new ConditionParentPane(); + conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null)); } - + resultSetGroupPane = new ResultSetGroupPopUpPane(setting > DSColumnPane.SETTING_DSRELATED); resultSetGroupPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Data_Setting"), null)); if (setting > DSColumnPane.SETTING_DSRELATED) { - expandDirectionPane = new ExpandDirectionPane(); - expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null)); + expandDirectionPane = new ExpandDirectionPane(); + expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null)); } - + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.PREFERRED}; + TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnSize = {TableLayout.FILL}; - + Component[][] components = null; - + if (setting > DSColumnPane.SETTING_DSRELATED) { - components = new Component[][]{ - {selectDataColumnPane}, - {conditionParentPane}, - {resultSetGroupPane}, - {expandDirectionPane} - }; + components = new Component[][]{ + {selectDataColumnPane}, + {conditionParentPane}, + {resultSetGroupPane}, + {expandDirectionPane} + }; } else { - components = new Component[][]{ - {selectDataColumnPane}, - {resultSetGroupPane}, - }; + components = new Component[][]{ + {selectDataColumnPane}, + {resultSetGroupPane}, + }; } - + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); this.resultSetGroupPane.addListeners(summary_direction_ActionListener, otherGroup_direction_ActionListener, sdcUpdate_ActionListener); @@ -85,24 +83,24 @@ public class DSColumnBasicPane extends BasicPane { @Override protected String title4PopupWindow() { - return Inter.getLocText("Basic"); + return Inter.getLocText("Basic"); } - + public void populate(TableDataSource source, TemplateCellElement cellElement) { if (cellElement == null) { return; } this.cellElement = cellElement; - + selectDataColumnPane.populate(source, cellElement); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); if (conditionParentPane != null) { - conditionParentPane.populate(cellExpandAttr); + conditionParentPane.populate(cellExpandAttr); } if (expandDirectionPane != null) { - expandDirectionPane.populate(cellExpandAttr); + expandDirectionPane.populate(cellExpandAttr); } resultSetGroupPane.populate(cellElement); @@ -128,27 +126,28 @@ public class DSColumnBasicPane extends BasicPane { } if (conditionParentPane != null) { - conditionParentPane.update(cellExpandAttr); + conditionParentPane.update(cellExpandAttr); } if (expandDirectionPane != null) { - expandDirectionPane.update(cellExpandAttr); + expandDirectionPane.update(cellExpandAttr); } resultSetGroupPane.update(); } + ActionListener summary_direction_ActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(true); - } + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(true); + } } }; ActionListener otherGroup_direction_ActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(false); - } + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(false); + } } }; ActionListener sdcUpdate_ActionListener = new ActionListener() { @@ -157,14 +156,16 @@ public class DSColumnBasicPane extends BasicPane { selectDataColumnPane.update(cellElement); } }; - public void putElementcase(ElementCasePane t){ - if (conditionParentPane != null) { - conditionParentPane.putElementcase(t); - } - } - public void putCellElement(TemplateCellElement tplEC2) { - if (conditionParentPane != null) { - conditionParentPane.putCellElement(tplEC2); - } - } + + public void putElementcase(ElementCasePane t) { + if (conditionParentPane != null) { + conditionParentPane.putElementcase(t); + } + } + + public void putCellElement(TemplateCellElement tplCE) { + if (conditionParentPane != null) { + conditionParentPane.putCellElement(tplCE); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/DSColumnPane.java b/designer/src/com/fr/design/dscolumn/DSColumnPane.java index 74bc681654..68b49b1af3 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnPane.java @@ -148,7 +148,7 @@ public class DSColumnPane extends BasicPane { basicPane.putElementcase(t); } - public void putCellElement(TemplateCellElement tplEC2) { - basicPane.putCellElement(tplEC2); + public void putCellElement(TemplateCellElement tplCE) { + basicPane.putCellElement(tplCE); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index b7cc3b5ae4..b89eec7e7b 100644 --- a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -1,35 +1,31 @@ package com.fr.design.dscolumn; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; - - import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.FunctionComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.report.cell.cellattr.core.group.CustomGrouper; -import com.fr.report.cell.cellattr.core.group.DSColumn; -import com.fr.report.cell.cellattr.core.group.FunctionGrouper; -import com.fr.report.cell.cellattr.core.group.RecordGrouper; -import com.fr.report.cell.cellattr.core.group.SummaryGrouper; +import com.fr.report.cell.cellattr.core.group.*; import com.fr.stable.Constants; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * 这个pane是选中数据列后,在上方QuickRegion处显示的pane * - * @author zhou + * @author zhou, yaoh.wu + * @version 2017年8月2日14点55分 + * @since 8.0 */ public class ResultSetGroupDockingPane extends ResultSetGroupPane { private static final int BIND_GROUP = 0; @@ -42,7 +38,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { private CardLayout cardLayout; private UIComboBox goBox; - ItemListener l; + private ItemListener listener; public ResultSetGroupDockingPane(ElementCasePane ePane) { super(); @@ -58,15 +54,14 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } private JPanel layoutPane() { - double vs = 4; - double vg = 6; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - + UILabel dataSetLabel = new UILabel(Inter.getLocText("Data_Setting")); + dataSetLabel.setPreferredSize(new Dimension(60, 20)); Component[][] components = new Component[][] { - new Component[]{new UILabel(Inter.getLocText("Data_Setting")), goBox}, - new Component[]{cardPane, null} + new Component[]{dataSetLabel, goBox}, + new Component[]{null, cardPane} }; goBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ee) { @@ -74,10 +69,13 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { int i = goBox.getSelectedIndex(); if (i == BIND_GROUP) { cardLayout.show(cardPane, "groupPane"); + cardPane.setPreferredSize(new Dimension(156, 20)); } else if (i == BIND_SELECTED) { cardLayout.show(cardPane, "listPane"); + cardPane.setPreferredSize(new Dimension(0, 0)); } else if (i == BIND_SUMMARY) { cardLayout.show(cardPane, "summaryPane"); + cardPane.setPreferredSize(new Dimension(156, 20)); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); cellExpandAttr.setDirection(Constants.NONE); } @@ -86,7 +84,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { double[] columnSize = {p, f}; double[] rowSize = {p, p}; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 8, 10); } private void initCardPane() { @@ -190,15 +188,15 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } } - public void addListener(ItemListener l) { - goBox.addItemListener(l); - groupComboBox.addItemListener(l); - functionComboBox.addItemListener(l); - this.l = l; + public void addListener(ItemListener listener) { + goBox.addItemListener(listener); + groupComboBox.addItemListener(listener); + functionComboBox.addItemListener(listener); + this.listener = listener; } void fireTargetChanged() { - l.itemStateChanged(null); + listener.itemStateChanged(null); } @Override diff --git a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java index 282367d273..e71f539ebb 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java @@ -1,45 +1,45 @@ package com.fr.design.dscolumn; -import java.awt.Dimension; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Iterator; - import com.fr.data.TableDataSource; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.main.impl.WorkBook; import com.fr.report.cell.TemplateCellElement; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Iterator; + public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { - public SelectedConfirmedDataColumnPane () { - super(false); - } - - protected void initTableNameComboBox() { - tableNameComboBox = new TableDataComboBox(new WorkBook()); - tableNameComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - columnNameComboBox.setLoaded(false); - } - }); - tableNameComboBox.setPreferredSize(new Dimension(100, 20)); - } - - public void populate(TableDataSource source, TemplateCellElement cell) { - tableNameComboBox.refresh(source); - tableNameComboBox.setEditable(false); - tableNameComboBox.setEnabled(false); - super.populate(source, cell); - try { - Iterator it = source.getTableDataNameIterator(); - String name = (String)it.next(); - TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); - tableNameComboBox.setSelectedItem(wrapper); - tableNameComboBox.getModel().setSelectedItem(wrapper); - } catch (Exception e) { - } - } + public SelectedConfirmedDataColumnPane() { + super(false); + } + + protected void initTableNameComboBox() { + tableNameComboBox = new TableDataComboBox(new WorkBook()); + tableNameComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + columnNameComboBox.setLoaded(false); + } + }); + tableNameComboBox.setPreferredSize(new Dimension(100, 20)); + } + + public void populate(TableDataSource source, TemplateCellElement cell) { + tableNameComboBox.refresh(source); + tableNameComboBox.setEditable(false); + tableNameComboBox.setEnabled(false); + super.populate(source, cell); + try { + Iterator it = source.getTableDataNameIterator(); + String name = (String) it.next(); + TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); + tableNameComboBox.setSelectedItem(wrapper); + tableNameComboBox.getModel().setSelectedItem(wrapper); + } catch (Exception e) { + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index dd583e1efe..d672810286 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -17,6 +17,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.data.TableDataColumn; import com.fr.report.cell.CellElement; @@ -39,8 +40,8 @@ import java.util.regex.Pattern; * 数据集列动态参数设置组件 * * @author yaoh.wu - * @version 2017年7月26日 - * 9.0设计器更新,修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示 + * @version 2017年8月3日 + * 复用对话框代码,保留对话框原始布局 * @since 8.0 */ public class SelectedDataColumnPane extends BasicPane { @@ -54,11 +55,20 @@ public class SelectedDataColumnPane extends BasicPane { private UIButton paramButton; public SelectedDataColumnPane() { - this(true); + this(true, false, null, null); } - SelectedDataColumnPane(boolean showParameterButton) { - initComponent(showParameterButton); + + public SelectedDataColumnPane(boolean showParameterButton) { + this(showParameterButton, false, null, null); + } + + public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout, ElementCasePane casePane, TemplateCellElement cellElement) { + if (verticalLayout) { + initComponentVerticalLayout(casePane, cellElement); + } else { + initComponent(showParameterButton); + } } /** @@ -72,33 +82,32 @@ public class SelectedDataColumnPane extends BasicPane { initWithParameterButton(); } columnNameComboBox = new LazyComboBox() { + @Override public Object[] load() { List l = calculateColumnNameList(); return l.toArray(new String[l.size()]); } + }; columnNameComboBox.setEditable(true); - double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel label1 = new UILabel(Inter.getLocText("TableData")); - UILabel label3 = new UILabel(Inter.getLocText("DataColumn")); + UILabel dsLabel = new UILabel(Inter.getLocText("TableData") + ":"); + UILabel dcLabel = new UILabel(Inter.getLocText("DataColumn") + ":"); if (showParameterButton) { - //todo 国际化 - UILabel label2 = new UILabel("param"); - Component[][] components = { - {label1, tableNameComboBox}, - {label2, paramButton}, - {label3, columnNameComboBox} - }; - this.setLayout(new BorderLayout()); - this.add(TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f})); + dsLabel.setPreferredSize(new Dimension(200, 25)); + dcLabel.setPreferredSize(new Dimension(200, 25)); + } + if (showParameterButton) { + Component[][] comps = {{dsLabel, null, dcLabel}, {tableNameComboBox, paramButton, columnNameComboBox}}; + this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); } else { + double f = TableLayout.FILL; double[] columnSize = {p, f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{label1, tableNameComboBox}, - new Component[]{label3, columnNameComboBox} + new Component[]{dsLabel, tableNameComboBox}, + new Component[]{dcLabel, columnNameComboBox} }; JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); @@ -107,6 +116,39 @@ public class SelectedDataColumnPane extends BasicPane { } + /** + * 初始化竖直布局的组件 + */ + public void initComponentVerticalLayout(ElementCasePane casePane, TemplateCellElement cellElement) { + initTableNameComboBox(); + initWithParameterButton(casePane, cellElement); + columnNameComboBox = new LazyComboBox() { + @Override + public Object[] load() { + List l = calculateColumnNameList(); + return l.toArray(new String[l.size()]); + } + }; + columnNameComboBox.setEditable(true); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + UILabel dsLabel = new UILabel(Inter.getLocText("TableData")); + UILabel dpLabel = new UILabel(Inter.getLocText("FR-Designer_Dynamic_Parameter")); + UILabel dcLabel = new UILabel(Inter.getLocText("DataColumn")); + dsLabel.setPreferredSize(new Dimension(60, 20)); + dpLabel.setPreferredSize(new Dimension(60, 20)); + dcLabel.setPreferredSize(new Dimension(60, 20)); + Component[][] components = { + {dsLabel, tableNameComboBox}, + {dpLabel, paramButton}, + {dcLabel, columnNameComboBox} + }; + this.setLayout(new BorderLayout()); + this.add(TableLayoutHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f}, 8, 10)); + + } + + public void populate(TableDataSource source, TemplateCellElement cellElement) { if (cellElement == null) { return; @@ -237,6 +279,27 @@ public class SelectedDataColumnPane extends BasicPane { }); } + private void initWithParameterButton(final ElementCasePane casePane, final TemplateCellElement cellElement) { + final SelectedDataColumnPane that = this; + editorPane = new UITableEditorPane(new ParameterTableModel()); + paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); + paramButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + List parameterList = editorPane.update(); + ps = parameterList.toArray(new Parameter[parameterList.size()]); + that.update(cellElement); + casePane.fireTargetModified(); + } + }); + editorPane.populate(ps == null ? new Parameter[0] : ps); + paramDialog.setVisible(true); + } + }); + } + private boolean isColumnName(String columnExp) { return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); diff --git a/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java b/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java index eeb6657c42..5637a68ca6 100644 --- a/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java +++ b/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java @@ -12,6 +12,7 @@ import com.fr.form.ui.Widget; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.privilege.finegrain.WidgetPrivilegeControl; import com.fr.report.cell.DefaultTemplateCellElement; @@ -68,9 +69,6 @@ public class CellWidgetPropertyPane extends BasicPane { Widget cellWidget = cellElement.getWidget(); - if(cellWidget == null){ - return; - } // 这里进行克隆的原因是为了保留原始的Widget以便和新的Widget做比较来判断是否发生了改变 if (cellWidget != null) { @@ -85,8 +83,7 @@ public class CellWidgetPropertyPane extends BasicPane { } - public void populate(ElementCasePane ePane) { - + public void reInit(ElementCasePane ePane){ cellEditorDefPane = new WidgetPane(ePane); this.removeAll(); this.add(cellEditorDefPane, BorderLayout.CENTER); @@ -102,6 +99,11 @@ public class CellWidgetPropertyPane extends BasicPane { this.populate(editCellElement); } + public void populate(ElementCasePane ePane) { + Selection editingSelection = ePane.getSelection(); + editingSelection.populateWidgetPropertyPane(ePane); + } + public void update() { if (cellElement == null) {// 利用默认的CellElement. return; diff --git a/designer/src/com/fr/design/mainframe/ReportFloatPane.java b/designer/src/com/fr/design/mainframe/ReportFloatPane.java index 85ecc85bf3..227378b715 100644 --- a/designer/src/com/fr/design/mainframe/ReportFloatPane.java +++ b/designer/src/com/fr/design/mainframe/ReportFloatPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; +import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -42,7 +43,14 @@ public class ReportFloatPane extends JPanel { UIToolbar topToolBar = new UIToolbar(); topToolBar.setLayout(new BorderLayout()); insertFloatMenu = createInsertToolBar(); - topToolBar.add(createButtonUI()); + topToolBar.setPreferredSize(new Dimension(155,20)); + topToolBar.add(createButtonUI(), BorderLayout.CENTER); + topToolBar.setBorder(BorderFactory.createEmptyBorder(-1, -1, -1, -1)); + + JPanel toolBarPane = new JPanel(new BorderLayout()); + toolBarPane.add(topToolBar, BorderLayout.CENTER); + toolBarPane.setBorder(BorderFactory.createLineBorder(UIConstants.POP_DIALOG_BORDER)); + toolBarPane.setPreferredSize(new Dimension(155,20)); UILabel emptyLabel = new UILabel(); emptyLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); @@ -51,10 +59,10 @@ public class ReportFloatPane extends JPanel { double[] columnSize = {p, p, p, f}; double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(), new UILabel(Inter.getLocText("FR-Designer_Add_FloatElement")), emptyLabel, topToolBar}, + new Component[]{new UILabel(), new UILabel(Inter.getLocText("FR-Designer_Add_FloatElement")), emptyLabel, toolBarPane}, }; JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - leftTopPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0, 13)); + leftTopPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 15)); this.add(leftTopPane, BorderLayout.NORTH); } diff --git a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java index b0f09af437..48b6d8a179 100644 --- a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java +++ b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.cell; import com.fr.design.dialog.BasicPane; -import com.fr.report.cell.TemplateCellElement; /** * 右侧单元格元素面板抽象类 @@ -24,7 +23,6 @@ public abstract class CellEditorPane extends BasicPane { /** * 更新面板数据 * - * @param cellElement 单元格 */ - public abstract void populate(TemplateCellElement cellElement); + public abstract void populate(); } diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 26f4918ff5..4ace2d6201 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -63,7 +63,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane { // 插入行策略 private UIButtonGroup insertRowPolicy; private ValueEditorPane valueEditor; - + private CardLayout insertRowLayout; + private JPanel insertRowPane; private JPanel southContentPane; private JPanel defaultValuePane; @@ -109,14 +110,41 @@ public class CellOtherSetPane extends AbstractCellAttrPane { defaultValuePane = new JPanel(new BorderLayout(4, 0)); valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(); defaultValuePane.add(valueEditor, BorderLayout.CENTER); - defaultValuePane.setVisible(false); - + insertRowLayout = new CardLayout(); + insertRowPane = new JPanel(insertRowLayout); + insertRowPane.add(new JPanel(), "none"); + insertRowPane.add(defaultValuePane, "content"); + insertRowPane.setPreferredSize(new Dimension(0, 0)); insertRowPolicy.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - defaultValuePane.setVisible(insertRowPolicy.getSelectedIndex() == 1); + if (insertRowPolicy.getSelectedIndex() == 1) { + insertRowPane.setPreferredSize(new Dimension(100, 20)); + insertRowLayout.show(insertRowPane, "content"); + } else { + insertRowLayout.show(insertRowPane, "none"); + insertRowPane.setPreferredSize(new Dimension(0, 0)); + } } }); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize1 = {p, p}; + double[] columnSize1 = {p, f}; + int[][] rowCount1 = {{1, 1}, {1, 1}}; + Component[][] components1 = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_InsertRow_Policy"), SwingConstants.LEFT), insertRowPolicy}, + new Component[]{null, insertRowPane}, + }; + southContentPane = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize1, columnSize1, rowCount1, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + JPanel seniorPane = new JPanel(new BorderLayout()); + seniorPane.add(seniorUpPane(), BorderLayout.NORTH); + seniorPane.add(southContentPane, BorderLayout.CENTER); + southContentPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + return seniorPane; + } + + private JPanel seniorUpPane() { JPanel fileNamePane = createNormal(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; @@ -133,19 +161,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_ToolTip"), SwingConstants.RIGHT), tooltipTextField}, new Component[]{null, null}, }; - JPanel seniorCenterPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); - double[] rowSize1 = {p, p}; - double[] columnSize1 = {p, f}; - int[][] rowCount1 = {{1, 1}, {1, 1}}; - Component[][] components1 = new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_InsertRow_Policy"), SwingConstants.LEFT), insertRowPolicy}, - new Component[]{null, defaultValuePane}, - }; - southContentPane = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize1, columnSize1, rowCount1, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); - JPanel seniorPane = new JPanel(new BorderLayout()); - seniorPane.add(seniorCenterPane, BorderLayout.NORTH); - seniorPane.add(southContentPane, BorderLayout.CENTER); - return seniorPane; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel pagePane() { @@ -305,7 +321,13 @@ public class CellOtherSetPane extends AbstractCellAttrPane { } else { insertRowPolicy.setSelectedIndex(0); } - defaultValuePane.setVisible(insertRowPolicy.getSelectedIndex() == 1); + if (insertRowPolicy.getSelectedIndex() == 1) { + insertRowPane.setPreferredSize(new Dimension(100, 20)); + insertRowLayout.show(insertRowPane, "content"); + } else { + insertRowLayout.show(insertRowPane, "none"); + insertRowPane.setPreferredSize(new Dimension(0, 0)); + } southContentPane.setVisible(true); JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!jTemplate.isJWorkBook()) { //表单中报表块编辑屏蔽掉 插入行策略 diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 1d4f65de53..f01bb669e6 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -6,6 +6,7 @@ import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; import com.fr.general.FRLogLevel; import com.fr.general.FRLogManager; +import com.fr.general.Inter; import com.fr.general.LogDuration; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -75,16 +76,17 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { } private String readLogID(String log) { - int dotIndex = log.lastIndexOf(":"); - if (dotIndex != -1) { - int end = Math.min(dotIndex + ERROR_LEN, log.length()); - String logid = log.substring(dotIndex + 1, end).trim(); - try { - Long.parseLong(logid); - return logid; - } catch (Exception ignore) { + String errorCode = Inter.getLocText("FR-Engine_ErrorCode-Prefix"); + String[] matchs = log.split(errorCode + ".*?:"); + if (matchs.length <= 1) { + return StringUtils.EMPTY; + } + + String includeIDStr = matchs[1].trim(); + try { + return Long.parseLong(includeIDStr.substring(0, ERROR_LEN)) + StringUtils.EMPTY; + } catch (Exception ignore) { - } } return StringUtils.EMPTY; diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 0204d33a96..7865f6d525 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -1,7 +1,9 @@ package com.fr.design.mainframe.errorinfo; +import com.fr.base.FRContext; import com.fr.general.*; import com.fr.general.http.HttpClient; +import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.CodeUtils; import com.fr.stable.EnvChangedListener; @@ -10,6 +12,8 @@ import com.fr.stable.StableUtils; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.HashMap; @@ -45,7 +49,63 @@ public class ErrorInfoUploader { return collector; } + // 从云中心更新最新的解决方案文件 + private void checkUpdateSolution(){ + Thread updateThread = new Thread(new Runnable() { + @Override + public void run() { + String localCacheFilePath = StableUtils.pathJoin(ProductConstants.getEnvHome(), "solution", "solution.zip"); + File localCacheZip = new File(localCacheFilePath); + if (needUpdate(localCacheZip)) { + downloadSolution(localCacheZip); + } + } + }); + updateThread.start(); + } + + private void downloadSolution(File localCacheZip) { + try { + String downloadURL = SiteCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); + HttpClient hc = new HttpClient(downloadURL); + hc.asGet(); + InputStream in = hc.getResponseStream(); + StableUtils.makesureFileExist(localCacheZip); + FileOutputStream out = new FileOutputStream(localCacheZip); + IOUtils.copyBinaryTo(in, out); + out.close(); + in.close(); + + IOUtils.unzip(localCacheZip, localCacheZip.getParent()); + } catch (Exception e) { + FRContext.getLogger().debug(e.getMessage()); + } + + } + + private boolean needUpdate(File localCacheZip){ + if (localCacheZip.exists()) { + // 判断本地文件大小. + String checkURL = SiteCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/checkUpdate"); + HttpClient client = new HttpClient(checkURL); + client.asGet(); + if (client.isServerAlive()){ + try { + JSONObject res = new JSONObject(client.getResponseText()); + // 简单粗暴, 直接判断文件大小. + return res.optLong("version") != localCacheZip.length(); + } catch (JSONException ignore) { + } + } + return false; + } + return true; + } + public void sendErrorInfo(){ + // 判断更新解决方案缓存. + checkUpdateSolution(); + //读取文件夹里的json, 加入上传队列中. File folder = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME)); if (!folder.exists()) { diff --git a/designer/src/com/fr/design/module/DesignerModule.java b/designer/src/com/fr/design/module/DesignerModule.java index 12ada2f027..6cdbea4e5d 100644 --- a/designer/src/com/fr/design/module/DesignerModule.java +++ b/designer/src/com/fr/design/module/DesignerModule.java @@ -111,7 +111,7 @@ public class DesignerModule extends DesignModule { private void registerCellEditor() { ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.class); ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.class); - ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.class); + ActionFactory.registerCellEditor(Formula.class, CellFormulaQuickEditor.class); ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.class); ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.class); ActionFactory.registerCellEditor(DSColumn.class, CellDSColumnEditor.class); @@ -169,7 +169,7 @@ public class DesignerModule extends DesignModule { } @Override - /** + /* * 针对不同的对象,在读取Object对象的xml的时候需要使用不同的对象生成器 * @return 返回对象生成器 */ @@ -212,7 +212,7 @@ public class DesignerModule extends DesignModule { } }); } - + private static abstract class AbstractWorkBookApp implements App { @Override @@ -234,15 +234,15 @@ public class DesignerModule extends DesignModule { public void process() { } - + @Override public void undo() { - + } } @Override - /** + /* * 返回设计器能打开的模板类型的一个数组列表 * @return 可以打开的模板类型的数组 */ @@ -385,7 +385,7 @@ public class DesignerModule extends DesignModule { } public Class[] actionsForInsertCellElement() { - return (Class[])ArrayUtils.addAll(new Class[]{ + return (Class[]) ArrayUtils.addAll(new Class[]{ DSColumnCellAction.class, GeneralCellAction.class, RichTextCellAction.class, diff --git a/designer/src/com/fr/design/present/BarCodePane.java b/designer/src/com/fr/design/present/BarCodePane.java index db894b2037..1966449381 100644 --- a/designer/src/com/fr/design/present/BarCodePane.java +++ b/designer/src/com/fr/design/present/BarCodePane.java @@ -1,376 +1,385 @@ -package com.fr.design.present; - -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icombobox.UIComboBoxRenderer; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UIBasicSpinner; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.report.cell.cellattr.BarcodeAttr; -import com.fr.report.cell.cellattr.BarcodePresent; -import com.fr.report.cell.painter.barcode.BarcodeImpl; -import com.fr.report.cell.painter.barcode.core.BarCodeUtils; -import com.fr.stable.pinyin.ChineseHelper; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -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.awt.font.FontRenderContext; -import java.awt.font.LineBreakMeasurer; -import java.awt.font.TextAttribute; -import java.awt.font.TextLayout; -import java.awt.geom.AffineTransform; -import java.text.AttributedCharacterIterator; -import java.text.AttributedString; -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhou - * @since 2012-6-4下午6:49:59 - */ -public class BarCodePane extends FurtherBasicBeanPane { - private final int NUM16 = 16; - private BarCodePreviewPane barCodePreviewPane; - private UIComboBox typeComboBox; - private UIBasicSpinner barWidthSpinner; - private UIBasicSpinner barHeightSpinner; - private UIBasicSpinner RCodesizespinner; - private UICheckBox drawingTextCheckBox; - private UIComboBox RCodeVersionComboBox; - private UIComboBox RCodeErrorCorrectComboBox; - private UILabel typeSetLabel; - - private String testText = "12345"; - - public BarCodePane() { - this.initComponents(); - addlistener(); - } - - 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 BarCodePane(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(270, 400); - jf.setVisible(true); - } - - private void initComponents() { - barCodePreviewPane = new BarCodePreviewPane(); - this.barWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(10.0, 1, 100, 1.0)); - this.barHeightSpinner = new UIBasicSpinner(new SpinnerNumberModel(30, 1, 100, 1)); - this.barWidthSpinner.setPreferredSize(new Dimension(60, 20)); - this.barHeightSpinner.setPreferredSize(new Dimension(60, 20)); - JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); - borderPane.setBorder(titledBorder); - borderPane.add(barCodePreviewPane, BorderLayout.CENTER); - setTypeComboBox(); - setSome(); - RCodesizespinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 6, 1)); - RCodeVersionComboBox = new UIComboBox(); - RCodeErrorCorrectComboBox = new UIComboBox(); - typeSetLabel = new UILabel(Inter.getLocText("Type_Set") + ":", UILabel.RIGHT); - initVersionComboBox(); - initErrorCorrectComboBox(); - - drawingTextCheckBox = new UICheckBox(Inter.getLocText("BarCodeD-Drawing_Text")); - drawingTextCheckBox.setSelected(true); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - barCodePreviewPane.setPreferredSize(new Dimension(0, 125)); - final JPanel centerPane = new JPanel(new CardLayout()); - - Component[][] components = new Component[][]{ - new Component[]{typeSetLabel, typeComboBox}, - new Component[]{borderPane, null}, - new Component[]{centerPane, null} - }; - JPanel barCode = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - centerPane.add(getNormalPane(), "normal"); - centerPane.add(getSpecialPane(), "special"); - typeComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - CardLayout cardLayout = (CardLayout) centerPane.getLayout(); - cardLayout.show(centerPane, typeComboBox.getSelectedIndex() == NUM16 ? "special" : "normal"); - setTestText(BarCodeUtils.getTestTextByBarCode(typeComboBox.getSelectedIndex())); - repaintPreviewBarCode(); - } - }); - this.setLayout(new BorderLayout()); - this.add(barCode, BorderLayout.CENTER); - } - - private void setTypeComboBox() { - typeComboBox = new UIComboBox(BarCodeUtils.getAllSupportedBarCodeTypeArray()); - typeComboBox.setRenderer(new UIComboBoxRenderer() { - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof Integer) { - this.setText(" " + BarCodeUtils.getBarCodeTypeName(((Integer) value).intValue())); - } - return this; - } - }); - } - - private void setSome() { - JFormattedTextField heightTextField = ((JSpinner.DefaultEditor) barHeightSpinner.getEditor()).getTextField(); - heightTextField.setColumns(2); - - JFormattedTextField widthTextField = ((JSpinner.DefaultEditor) barWidthSpinner.getEditor()).getTextField(); - widthTextField.setColumns(2); - } - - private JPanel getNormalPane() { - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p, p, p, p}; - double[] columnSize1 = {p, f, f}; - JPanel barWidthContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)); - barWidthContainer.add(barWidthSpinner); - JPanel barHeightContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)); - barHeightContainer.add(barHeightSpinner); - UILabel uiLabel = new UILabel(Inter.getLocText("Tree-Width") + ":", UILabel.RIGHT); - uiLabel.setPreferredSize(typeSetLabel.getPreferredSize()); - Component[][] components_normal = new Component[][]{ - new Component[]{new UILabel("条形码大小", UILabel.LEFT), barWidthContainer, barHeightContainer}, - new Component[]{null, new UILabel(Inter.getLocText("Tree-Width"), UILabel.CENTER), new UILabel(Inter.getLocText("Height"), UILabel.CENTER)}, - new Component[]{drawingTextCheckBox, null, null} - }; - - - JPanel normalPane = TableLayoutHelper.createTableLayoutPane(components_normal, rowSize, columnSize1); - return normalPane; - } - - - private JPanel getSpecialPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize1 = {p, p}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - UILabel uiLabel = new UILabel(Inter.getLocText("RCodeVersion") + ":", UILabel.RIGHT); - uiLabel.setPreferredSize(typeSetLabel.getPreferredSize()); - Component[][] components_special = new Component[][]{ - new Component[]{uiLabel, RCodeVersionComboBox}, - new Component[]{new UILabel(Inter.getLocText("RCodeErrorCorrect") + ":", UILabel.RIGHT), RCodeErrorCorrectComboBox}, - new Component[]{new UILabel(Inter.getLocText("RCodeDrawPix") + ":", UILabel.RIGHT), RCodesizespinner} - }; - - JPanel specialPane = TableLayoutHelper.createTableLayoutPane(components_special, rowSize, columnSize1); - return specialPane; - } - - private void addlistener() { - RCodesizespinner.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - repaintPreviewBarCode(); - } - }); - RCodeVersionComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - repaintPreviewBarCode(); - } - }); - RCodeErrorCorrectComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - repaintPreviewBarCode(); - } - }); - this.barWidthSpinner.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - repaintPreviewBarCode(); - } - }); - this.barHeightSpinner.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - repaintPreviewBarCode(); - } - }); - drawingTextCheckBox.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - repaintPreviewBarCode(); - } - }); - repaintPreviewBarCode(); - } - - @Override - /** - * - */ - public String title4PopupWindow() { - return Inter.getLocText("Highlight-Barcode"); - } - - private void initVersionComboBox() { - String[] array = {Inter.getLocText(new String[]{"Auto", "Choose"}), "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}; - initcombobox(this.RCodeVersionComboBox, array, 0); - } - - private void initErrorCorrectComboBox() { - String[] array = {"L" + Inter.getLocText("Level") + "7%", "M" + Inter.getLocText("Level") + "15%", "Q" + Inter.getLocText("Level") + "25%", "H" + Inter.getLocText("Level") + "30%"}; - initcombobox(this.RCodeErrorCorrectComboBox, array, 1); - } - - private void initcombobox(UIComboBox combobox, String[] array, int index) { - combobox.removeAllItems(); - for (int i = 0; i < array.length; i++) { - combobox.addItem(array[i]); - } - combobox.setSelectedIndex(index); - } - - private void repaintPreviewBarCode() { - try { - // carl:不支持中文转条形码 - if (ChineseHelper.containChinese(getTestText()) && this.typeComboBox.getSelectedIndex() != NUM16) { - throw new Exception("Illegal Character."); - } - this.barCodePreviewPane.setObject(BarCodeUtils.getBarcodeImpl(this.updateBean().getBarcode(), getTestText())); - } catch (Exception exp) { - this.barCodePreviewPane.setObject(Inter.getLocText("Error") + ": " + exp.getMessage()); - } - } - - /** - * - */ - public void reset() { - populateBean(new BarcodePresent()); - } - - @Override - public void populateBean(BarcodePresent ob) { - BarcodeAttr barcodeAttr = ob.getBarcode(); - if (barcodeAttr == null) { - barcodeAttr = new BarcodeAttr(); - } - this.setTestText(BarCodeUtils.getTestTextByBarCode(barcodeAttr.getType())); - this.typeComboBox.setSelectedIndex(barcodeAttr.getType()); - this.barWidthSpinner.setValue(new Double(barcodeAttr.getBarWidth())); - this.barHeightSpinner.setValue(new Integer(barcodeAttr.getBarHeight())); - this.drawingTextCheckBox.setSelected(barcodeAttr.isDrawingText()); - this.RCodesizespinner.setValue(new Integer(barcodeAttr.getRcodeDrawPix())); - this.repaintPreviewBarCode(); - } - - @Override - public BarcodePresent updateBean() { - BarcodeAttr barcodeAttr = new BarcodeAttr(); - if ((typeComboBox.getSelectedIndex() == NUM16)) { - barcodeAttr.setRCodeVersion(this.RCodeVersionComboBox.getSelectedIndex()); - barcodeAttr.setRCodeErrorCorrect(this.RCodeErrorCorrectComboBox.getSelectedIndex()); - barcodeAttr.setRcodeDrawPix(((Integer) this.RCodesizespinner.getValue()).intValue()); - } - barcodeAttr.setType(this.typeComboBox.getSelectedIndex()); - barcodeAttr.setBarWidth(((Double) this.barWidthSpinner.getValue()).doubleValue() / 10); - barcodeAttr.setBarHeight(((Integer) this.barHeightSpinner.getValue()).intValue()); - barcodeAttr.setDrawingText(this.drawingTextCheckBox.isSelected()); - return new BarcodePresent(barcodeAttr); - } - - public void setTestText(String testText) { - this.testText = testText; - } - - public String getTestText() { - return testText; - } - - private static class BarCodePreviewPane extends JPanel { - private Object obj; - - public BarCodePreviewPane() { -// setBackground(Color.WHITE); - } - - /** - * BarcodeImpl or Error String. - */ - public void setObject(Object obj) { - this.obj = obj; - GUICoreUtils.repaint(this); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - if (obj == null) { - return; - } - if (obj instanceof BarcodeImpl) { - BarcodeImpl barcodeImpl = (BarcodeImpl) obj; - Dimension size = this.getSize(); - barcodeImpl.draw((Graphics2D) g, (int) (size.getWidth() - barcodeImpl.getWidth()) / 2, (int) (size.getHeight() - barcodeImpl.getHeight()) / 2); - } else { - // 在中央画出字符. - Graphics2D graphics2D = (Graphics2D) g; - graphics2D.setPaint(Color.RED); - Map map = new HashMap(); - map.put(TextAttribute.SIZE, new Float(14.0)); - AttributedString vanGogh = new AttributedString(obj.toString(), map); - AttributedCharacterIterator paragraph = vanGogh.getIterator(); - int paragraphStart = paragraph.getBeginIndex(); - int paragraphEnd = paragraph.getEndIndex(); - // Create a new LineBreakMeasurer from the paragraph. - AffineTransform tx = null; - LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(paragraph, new FontRenderContext(tx, false, false)); - // Set formatting width to width of Component. - Dimension size = getSize(); - float formatWidth = size.width; - float drawPosY = 0; - lineMeasurer.setPosition(paragraphStart); - // Get lines from lineMeasurer until the entire - // paragraph has been displayed. - while (lineMeasurer.getPosition() < paragraphEnd) { - // Retrieve next layout. - TextLayout layout = lineMeasurer.nextLayout(formatWidth); - // Move y-coordinate by the ascent of the layout. - drawPosY += layout.getAscent(); - // Compute pen x position. If the paragraph is - // right-to-left, we want to align the TextLayouts - // to the right edge of the panel. - float drawPosX; - if (layout.isLeftToRight()) { - drawPosX = 0; - } else { - drawPosX = formatWidth - layout.getAdvance(); - } - // Draw the TextLayout at (drawPosX, drawPosY). - layout.draw(graphics2D, drawPosX, drawPosY); - // Move y-coordinate in preparation for next layout. - drawPosY += layout.getDescent() + layout.getLeading(); - } - } - } - } - - @Override - /** - * - */ - public boolean accept(Object ob) { - return ob instanceof BarcodePresent; - } +package com.fr.design.present; + +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.report.cell.cellattr.BarcodeAttr; +import com.fr.report.cell.cellattr.BarcodePresent; +import com.fr.report.cell.painter.barcode.BarcodeImpl; +import com.fr.report.cell.painter.barcode.core.BarCodeUtils; +import com.fr.stable.pinyin.ChineseHelper; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +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.awt.font.FontRenderContext; +import java.awt.font.LineBreakMeasurer; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.geom.AffineTransform; +import java.text.AttributedCharacterIterator; +import java.text.AttributedString; +import java.util.HashMap; +import java.util.Map; + +/** + * @author zhou + * @since 2012-6-4下午6:49:59 + */ +public class BarCodePane extends FurtherBasicBeanPane { + private final int NUM16 = 16; + private BarCodePreviewPane barCodePreviewPane; + private UIComboBox typeComboBox; + private UIBasicSpinner barWidthSpinner; + private UIBasicSpinner barHeightSpinner; + private UIBasicSpinner RCodesizespinner; + private UICheckBox drawingTextCheckBox; + private UIComboBox RCodeVersionComboBox; + private UIComboBox RCodeErrorCorrectComboBox; + private UILabel typeSetLabel; + + private String testText = "12345"; + + public BarCodePane() { + this.initComponents(); + addlistener(); + } + + 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 BarCodePane(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(270, 400); + jf.setVisible(true); + } + + private void initComponents() { + barCodePreviewPane = new BarCodePreviewPane(); + this.barWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(10.0, 1, 100, 1.0)); + this.barHeightSpinner = new UIBasicSpinner(new SpinnerNumberModel(30, 1, 100, 1)); + this.barWidthSpinner.setPreferredSize(new Dimension(60, 20)); + this.barHeightSpinner.setPreferredSize(new Dimension(60, 20)); + JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); + borderPane.setBorder(titledBorder); + borderPane.add(barCodePreviewPane, BorderLayout.CENTER); + setTypeComboBox(); + setSome(); + RCodesizespinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 6, 1)); + RCodeVersionComboBox = new UIComboBox(); + RCodeErrorCorrectComboBox = new UIComboBox(); + typeSetLabel = new UILabel(Inter.getLocText("Type_Set"), UILabel.LEFT); + initVersionComboBox(); + initErrorCorrectComboBox(); + + drawingTextCheckBox = new UICheckBox(Inter.getLocText("BarCodeD-Drawing_Text")); + drawingTextCheckBox.setSelected(true); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p, p, p, p, p}; + int[][] rowCount = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}}; + barCodePreviewPane.setPreferredSize(new Dimension(0, 125)); + typeComboBox.setPreferredSize(new Dimension(155,20)); + final JPanel centerPane = new JPanel(new CardLayout()); + + Component[][] components = new Component[][]{ + new Component[]{typeSetLabel, typeComboBox}, + new Component[]{borderPane, null}, + new Component[]{centerPane, null} + }; + JPanel barCode = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); + centerPane.add(getNormalPane(), "normal"); + centerPane.add(getSpecialPane(), "special"); + typeComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + CardLayout cardLayout = (CardLayout) centerPane.getLayout(); + cardLayout.show(centerPane, typeComboBox.getSelectedIndex() == NUM16 ? "special" : "normal"); + setTestText(BarCodeUtils.getTestTextByBarCode(typeComboBox.getSelectedIndex())); + repaintPreviewBarCode(); + } + }); + this.setLayout(new BorderLayout()); + this.add(barCode, BorderLayout.CENTER); + } + + private void setTypeComboBox() { + typeComboBox = new UIComboBox(BarCodeUtils.getAllSupportedBarCodeTypeArray()); + typeComboBox.setRenderer(new UIComboBoxRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof Integer) { + this.setText(" " + BarCodeUtils.getBarCodeTypeName(((Integer) value).intValue())); + } + return this; + } + }); + } + + private void setSome() { + JFormattedTextField heightTextField = ((JSpinner.DefaultEditor) barHeightSpinner.getEditor()).getTextField(); + heightTextField.setColumns(2); + + JFormattedTextField widthTextField = ((JSpinner.DefaultEditor) barWidthSpinner.getEditor()).getTextField(); + widthTextField.setColumns(2); + } + + private JPanel getNormalPane() { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p, p, p, p}; + double[] columnSize = {p, f, f}; + int[][] rowCount = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}; + JPanel barWidthContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)); + barWidthContainer.add(barWidthSpinner); + JPanel barHeightContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)); + barHeightContainer.add(barHeightSpinner); + UILabel uiLabel = new UILabel(Inter.getLocText("FR-Designer-Tree_Width"), UILabel.RIGHT); + uiLabel.setPreferredSize(typeSetLabel.getPreferredSize()); + drawingTextCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + Component[][] components_normal = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Barcode_Size"), UILabel.LEFT), barWidthContainer, barHeightContainer}, + new Component[]{null, new UILabel(Inter.getLocText("FR-Designer-Tree_Width"), UILabel.CENTER), new UILabel(Inter.getLocText("FR-Designer_Height"), UILabel.CENTER)}, + new Component[]{drawingTextCheckBox, null, null} + }; + + + JPanel normalPane = TableLayoutHelper.createGapTableLayoutPane(components_normal, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); + return normalPane; + } + + + private JPanel getSpecialPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, p}; + double[] rowSize = {p, p, p, p, p, p, p, p}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + UILabel uiLabel = new UILabel(Inter.getLocText("RCodeVersion"), UILabel.LEFT); + uiLabel.setPreferredSize(typeSetLabel.getPreferredSize()); + RCodeVersionComboBox.setPreferredSize(new Dimension(155,20)); + RCodeErrorCorrectComboBox.setPreferredSize(new Dimension(155,20)); + RCodesizespinner.setPreferredSize(new Dimension(155,20)); + Component[][] components_special = new Component[][]{ + new Component[]{uiLabel, RCodeVersionComboBox}, + new Component[]{new UILabel(Inter.getLocText("RCodeErrorCorrect"), UILabel.LEFT), RCodeErrorCorrectComboBox}, + new Component[]{new UILabel(Inter.getLocText("RCodeDrawPix"), UILabel.LEFT), RCodesizespinner} + }; + + JPanel specialPane = TableLayoutHelper.createGapTableLayoutPane(components_special, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); + return specialPane; + } + + private void addlistener() { + RCodesizespinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + repaintPreviewBarCode(); + } + }); + RCodeVersionComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + repaintPreviewBarCode(); + } + }); + RCodeErrorCorrectComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + repaintPreviewBarCode(); + } + }); + this.barWidthSpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + repaintPreviewBarCode(); + } + }); + this.barHeightSpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + repaintPreviewBarCode(); + } + }); + drawingTextCheckBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + repaintPreviewBarCode(); + } + }); + repaintPreviewBarCode(); + } + + @Override + /** + * + */ + public String title4PopupWindow() { + return Inter.getLocText("Highlight-Barcode"); + } + + private void initVersionComboBox() { + String[] array = {Inter.getLocText(new String[]{"Auto", "Choose"}), "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}; + initcombobox(this.RCodeVersionComboBox, array, 0); + } + + private void initErrorCorrectComboBox() { + String[] array = {"L" + Inter.getLocText("Level") + "7%", "M" + Inter.getLocText("Level") + "15%", "Q" + Inter.getLocText("Level") + "25%", "H" + Inter.getLocText("Level") + "30%"}; + initcombobox(this.RCodeErrorCorrectComboBox, array, 1); + } + + private void initcombobox(UIComboBox combobox, String[] array, int index) { + combobox.removeAllItems(); + for (int i = 0; i < array.length; i++) { + combobox.addItem(array[i]); + } + combobox.setSelectedIndex(index); + } + + private void repaintPreviewBarCode() { + try { + // carl:不支持中文转条形码 + if (ChineseHelper.containChinese(getTestText()) && this.typeComboBox.getSelectedIndex() != NUM16) { + throw new Exception("Illegal Character."); + } + this.barCodePreviewPane.setObject(BarCodeUtils.getBarcodeImpl(this.updateBean().getBarcode(), getTestText())); + } catch (Exception exp) { + this.barCodePreviewPane.setObject(Inter.getLocText("Error") + ": " + exp.getMessage()); + } + } + + /** + * + */ + public void reset() { + populateBean(new BarcodePresent()); + } + + @Override + public void populateBean(BarcodePresent ob) { + BarcodeAttr barcodeAttr = ob.getBarcode(); + if (barcodeAttr == null) { + barcodeAttr = new BarcodeAttr(); + } + this.setTestText(BarCodeUtils.getTestTextByBarCode(barcodeAttr.getType())); + this.typeComboBox.setSelectedIndex(barcodeAttr.getType()); + this.barWidthSpinner.setValue(new Double(barcodeAttr.getBarWidth())); + this.barHeightSpinner.setValue(new Integer(barcodeAttr.getBarHeight())); + this.drawingTextCheckBox.setSelected(barcodeAttr.isDrawingText()); + this.RCodesizespinner.setValue(new Integer(barcodeAttr.getRcodeDrawPix())); + this.repaintPreviewBarCode(); + } + + @Override + public BarcodePresent updateBean() { + BarcodeAttr barcodeAttr = new BarcodeAttr(); + if ((typeComboBox.getSelectedIndex() == NUM16)) { + barcodeAttr.setRCodeVersion(this.RCodeVersionComboBox.getSelectedIndex()); + barcodeAttr.setRCodeErrorCorrect(this.RCodeErrorCorrectComboBox.getSelectedIndex()); + barcodeAttr.setRcodeDrawPix(((Integer) this.RCodesizespinner.getValue()).intValue()); + } + barcodeAttr.setType(this.typeComboBox.getSelectedIndex()); + barcodeAttr.setBarWidth(((Double) this.barWidthSpinner.getValue()).doubleValue() / 10); + barcodeAttr.setBarHeight(((Integer) this.barHeightSpinner.getValue()).intValue()); + barcodeAttr.setDrawingText(this.drawingTextCheckBox.isSelected()); + return new BarcodePresent(barcodeAttr); + } + + public void setTestText(String testText) { + this.testText = testText; + } + + public String getTestText() { + return testText; + } + + private static class BarCodePreviewPane extends JPanel { + private Object obj; + + public BarCodePreviewPane() { +// setBackground(Color.WHITE); + } + + /** + * BarcodeImpl or Error String. + */ + public void setObject(Object obj) { + this.obj = obj; + GUICoreUtils.repaint(this); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (obj == null) { + return; + } + if (obj instanceof BarcodeImpl) { + BarcodeImpl barcodeImpl = (BarcodeImpl) obj; + Dimension size = this.getSize(); + barcodeImpl.draw((Graphics2D) g, (int) (size.getWidth() - barcodeImpl.getWidth()) / 2, (int) (size.getHeight() - barcodeImpl.getHeight()) / 2); + } else { + // 在中央画出字符. + Graphics2D graphics2D = (Graphics2D) g; + graphics2D.setPaint(Color.RED); + Map map = new HashMap(); + map.put(TextAttribute.SIZE, new Float(14.0)); + AttributedString vanGogh = new AttributedString(obj.toString(), map); + AttributedCharacterIterator paragraph = vanGogh.getIterator(); + int paragraphStart = paragraph.getBeginIndex(); + int paragraphEnd = paragraph.getEndIndex(); + // Create a new LineBreakMeasurer from the paragraph. + AffineTransform tx = null; + LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(paragraph, new FontRenderContext(tx, false, false)); + // Set formatting width to width of Component. + Dimension size = getSize(); + float formatWidth = size.width; + float drawPosY = 0; + lineMeasurer.setPosition(paragraphStart); + // Get lines from lineMeasurer until the entire + // paragraph has been displayed. + while (lineMeasurer.getPosition() < paragraphEnd) { + // Retrieve next layout. + TextLayout layout = lineMeasurer.nextLayout(formatWidth); + // Move y-coordinate by the ascent of the layout. + drawPosY += layout.getAscent(); + // Compute pen x position. If the paragraph is + // right-to-left, we want to align the TextLayouts + // to the right edge of the panel. + float drawPosX; + if (layout.isLeftToRight()) { + drawPosX = 0; + } else { + drawPosX = formatWidth - layout.getAdvance(); + } + // Draw the TextLayout at (drawPosX, drawPosY). + layout.draw(graphics2D, drawPosX, drawPosY); + // Move y-coordinate in preparation for next layout. + drawPosY += layout.getDescent() + layout.getLeading(); + } + } + } + } + + @Override + /** + * + */ + public boolean accept(Object ob) { + return ob instanceof BarcodePresent; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/present/CurrencyLinePane.java b/designer/src/com/fr/design/present/CurrencyLinePane.java index b6e0ff8530..7922f21867 100644 --- a/designer/src/com/fr/design/present/CurrencyLinePane.java +++ b/designer/src/com/fr/design/present/CurrencyLinePane.java @@ -1,231 +1,231 @@ -package com.fr.design.present; - -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.border.UIRoundedBorder; -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UIBasicSpinner; -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.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.report.cell.cellattr.CurrencyLineAttr; -import com.fr.report.cell.cellattr.CurrencyLinePresent; -import com.fr.report.cell.painter.barcode.BarcodeException; -import com.fr.report.core.CurrencyLineImpl; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import java.awt.*; - -/** - * @author zhou - * @since 2012-6-4下午7:34:52 - */ -public class CurrencyLinePane extends FurtherBasicBeanPane { - private static final int VS_NUM = 4; - private static final int VG_NUM = 6; - private UIBasicSpinner intPartSpinner; - private UIBasicSpinner deciPartSpinner; - private UITextField textField; - private CurrencyLinePreviewPane CurrencyLinePreviewPane; - private int intPart = 9; - private int deciPart = 3; - - private static final int POSITION = 8; - ChangeListener listener2 = new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - CurrencyLinePreviewPane.setObject(textField.getText(), update()); - } - - }; - - DocumentListener listener = new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent e) { - CurrencyLinePreviewPane.setObject(textField.getText(), update()); - } - - @Override - public void removeUpdate(DocumentEvent e) { - CurrencyLinePreviewPane.setObject(textField.getText(), update()); - } - - @Override - public void changedUpdate(DocumentEvent e) { - CurrencyLinePreviewPane.setObject(textField.getText(), update()); - } - }; - - public CurrencyLinePane() { - this.initComponents(); - } - - protected void initComponents() { - // 整数位选择 - intPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(9, 1, 20, 1)); - intPartSpinner.setPreferredSize(new Dimension(135, 20)); - - // 小数位选择 - deciPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 10, 1)); - deciPartSpinner.setPreferredSize(new Dimension(135, 20)); - // 预览区域 - textField = new UITextField(10); - - CurrencyLinePreviewPane = new CurrencyLinePreviewPane(); - CurrencyLinePreviewPane.setPreferredSize(new Dimension(0, 145)); - JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); - borderPane.setBorder(titledBorder); - borderPane.add(CurrencyLinePreviewPane, BorderLayout.CENTER); - - textField.requestFocus(); - - double vs = VS_NUM; - double vg = VG_NUM; - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p}; - - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("Data"), UILabel.LEFT), textField}, - new Component[]{borderPane, null}, - new Component[]{new UILabel(Inter.getLocText("IntPart"), UILabel.LEFT), groupPane(intPartSpinner)}, - new Component[]{new UILabel(Inter.getLocText("DeciPart"), UILabel.LEFT), groupPane(deciPartSpinner)} - - }; - - JPanel linePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(linePane, BorderLayout.CENTER); - - - textField.getDocument().addDocumentListener(listener); - intPartSpinner.addChangeListener(listener2); - deciPartSpinner.addChangeListener(listener2); - textField.setText("123456.78"); - } - - @Override - /** - * 窗口名 - * @return 同上 - */ - public String title4PopupWindow() { - return Inter.getLocText("Currency_Line"); - } - - /** - * - */ - public CurrencyLineAttr update() { - CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); - currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); - currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); - return currencylineAttr; - } - - /** - * - */ - public void setintPart(int intpart) { - this.intPart = intpart; - } - - /** - * - */ - public void setdeciPart(int decipart) { - this.deciPart = decipart; - } - - private class CurrencyLinePreviewPane extends JPanel { - private String text; - CurrencyLineAttr currencyLineAttr; - - public CurrencyLinePreviewPane() { -// setBackground(Color.WHITE); - } - - public void setObject(String text, CurrencyLineAttr currencyLineAttr) { - this.text = text; - this.currencyLineAttr = currencyLineAttr; - GUICoreUtils.repaint(this); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - if (text == null) { - return; - } - Dimension size = this.getSize(); - try { - CurrencyLineImpl currencyLineImpl = new CurrencyLineImpl(text, currencyLineAttr); - currencyLineImpl.draw((Graphics2D) g, (int) (size.getWidth()), (int) (size.getHeight())); - } catch (BarcodeException e) { - Color oldColor = g.getColor(); - g.setColor(Color.red); - g.drawString(e.getMessage(), (int) (size.getWidth() / POSITION), (int) (size.getHeight() / POSITION)); - g.setColor(oldColor); - } - } - - } - - protected static JPanel groupPane(JComponent comp) { - JPanel jp = new JPanel(); - jp.setBorder(null); - jp.setLayout(new FlowLayout(FlowLayout.LEFT)); - jp.add(comp); - return jp; - } - - @Override - /** - * 是否为该类型 - * @param ob 对象 - * @return 同上 - * - */ - public boolean accept(Object ob) { - return ob instanceof CurrencyLinePresent; - } - - /** - * 重置 - */ - public void reset() { - this.intPartSpinner.setValue(9); - this.deciPartSpinner.setValue(3); - } - - @Override - public void populateBean(CurrencyLinePresent ob) { - CurrencyLineAttr currencyLine = ob.getCurrencyLineAttr(); - if (currencyLine == null) { - currencyLine = new CurrencyLineAttr(); - } - this.intPartSpinner.setValue(new Integer(currencyLine.getintPart())); - this.deciPartSpinner.setValue(new Integer(currencyLine.getdeciPart())); - } - - @Override - public CurrencyLinePresent updateBean() { - CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); - currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); - currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); - return new CurrencyLinePresent(currencylineAttr); - } - +package com.fr.design.present; + +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UIBasicSpinner; +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.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.report.cell.cellattr.CurrencyLineAttr; +import com.fr.report.cell.cellattr.CurrencyLinePresent; +import com.fr.report.cell.painter.barcode.BarcodeException; +import com.fr.report.core.CurrencyLineImpl; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.*; + +/** + * @author zhou + * @since 2012-6-4下午7:34:52 + */ +public class CurrencyLinePane extends FurtherBasicBeanPane { + private static final int VS_NUM = 4; + private static final int VG_NUM = 6; + private UIBasicSpinner intPartSpinner; + private UIBasicSpinner deciPartSpinner; + private UITextField textField; + private CurrencyLinePreviewPane CurrencyLinePreviewPane; + private int intPart = 9; + private int deciPart = 3; + + private static final int POSITION = 8; + ChangeListener listener2 = new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + CurrencyLinePreviewPane.setObject(textField.getText(), update()); + } + + }; + + DocumentListener listener = new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + CurrencyLinePreviewPane.setObject(textField.getText(), update()); + } + + @Override + public void removeUpdate(DocumentEvent e) { + CurrencyLinePreviewPane.setObject(textField.getText(), update()); + } + + @Override + public void changedUpdate(DocumentEvent e) { + CurrencyLinePreviewPane.setObject(textField.getText(), update()); + } + }; + + public CurrencyLinePane() { + this.initComponents(); + } + + protected void initComponents() { + // 整数位选择 + intPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(9, 1, 20, 1)); + intPartSpinner.setPreferredSize(new Dimension(158, 20)); + + // 小数位选择 + deciPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 10, 1)); + deciPartSpinner.setPreferredSize(new Dimension(158, 20)); + // 预览区域 + textField = new UITextField(10); + + CurrencyLinePreviewPane = new CurrencyLinePreviewPane(); + CurrencyLinePreviewPane.setPreferredSize(new Dimension(0, 145)); + JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); + borderPane.setBorder(titledBorder); + borderPane.add(CurrencyLinePreviewPane, BorderLayout.CENTER); + + textField.requestFocus(); + + double vs = VS_NUM; + double vg = VG_NUM; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p}; + + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("Data"), UILabel.LEFT), textField}, + new Component[]{borderPane, null}, + new Component[]{new UILabel(Inter.getLocText("IntPart"), UILabel.LEFT), groupPane(intPartSpinner)}, + new Component[]{new UILabel(Inter.getLocText("DeciPart"), UILabel.LEFT), groupPane(deciPartSpinner)} + + }; + + JPanel linePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(linePane, BorderLayout.CENTER); + + + textField.getDocument().addDocumentListener(listener); + intPartSpinner.addChangeListener(listener2); + deciPartSpinner.addChangeListener(listener2); + textField.setText("123456.78"); + } + + @Override + /** + * 窗口名 + * @return 同上 + */ + public String title4PopupWindow() { + return Inter.getLocText("Currency_Line"); + } + + /** + * + */ + public CurrencyLineAttr update() { + CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); + currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); + currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); + return currencylineAttr; + } + + /** + * + */ + public void setintPart(int intpart) { + this.intPart = intpart; + } + + /** + * + */ + public void setdeciPart(int decipart) { + this.deciPart = decipart; + } + + private class CurrencyLinePreviewPane extends JPanel { + private String text; + CurrencyLineAttr currencyLineAttr; + + public CurrencyLinePreviewPane() { +// setBackground(Color.WHITE); + } + + public void setObject(String text, CurrencyLineAttr currencyLineAttr) { + this.text = text; + this.currencyLineAttr = currencyLineAttr; + GUICoreUtils.repaint(this); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (text == null) { + return; + } + Dimension size = this.getSize(); + try { + CurrencyLineImpl currencyLineImpl = new CurrencyLineImpl(text, currencyLineAttr); + currencyLineImpl.draw((Graphics2D) g, (int) (size.getWidth()), (int) (size.getHeight())); + } catch (BarcodeException e) { + Color oldColor = g.getColor(); + g.setColor(Color.red); + g.drawString(e.getMessage(), (int) (size.getWidth() / POSITION), (int) (size.getHeight() / POSITION)); + g.setColor(oldColor); + } + } + + } + + protected static JPanel groupPane(JComponent comp) { + JPanel jp = new JPanel(); + jp.setBorder(null); + jp.setLayout(new FlowLayout(FlowLayout.LEFT)); + jp.add(comp); + return jp; + } + + @Override + /** + * 是否为该类型 + * @param ob 对象 + * @return 同上 + * + */ + public boolean accept(Object ob) { + return ob instanceof CurrencyLinePresent; + } + + /** + * 重置 + */ + public void reset() { + this.intPartSpinner.setValue(9); + this.deciPartSpinner.setValue(3); + } + + @Override + public void populateBean(CurrencyLinePresent ob) { + CurrencyLineAttr currencyLine = ob.getCurrencyLineAttr(); + if (currencyLine == null) { + currencyLine = new CurrencyLineAttr(); + } + this.intPartSpinner.setValue(new Integer(currencyLine.getintPart())); + this.deciPartSpinner.setValue(new Integer(currencyLine.getdeciPart())); + } + + @Override + public CurrencyLinePresent updateBean() { + CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); + currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); + currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); + return new CurrencyLinePresent(currencylineAttr); + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/CellWidgetCardPane.java b/designer/src/com/fr/design/widget/CellWidgetCardPane.java index e3c41d36e0..b6c4c5318d 100644 --- a/designer/src/com/fr/design/widget/CellWidgetCardPane.java +++ b/designer/src/com/fr/design/widget/CellWidgetCardPane.java @@ -3,14 +3,11 @@ package com.fr.design.widget; import com.fr.design.data.DataCreatorUI; import com.fr.design.dialog.BasicPane; import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.gui.frpane.TreeSettingPane; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.present.dict.DictionaryPane; import com.fr.design.widget.ui.BasicWidgetPropertySettingPane; import com.fr.form.event.Listener; -import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.Inter; @@ -36,14 +33,6 @@ public class CellWidgetCardPane extends BasicPane { private JPanel attriCardPane; private CardLayout attriCardLayout; - //数字字典属性容器 - private JPanel dictTabPane; - private JPanel dictCardPane; - private CardLayout dictCardLayout; - - //构建树属性容器 - private JPanel treeTabPane; - //事件属性容器 private JPanel eventTabPane; private WidgetEventPane eventPane; @@ -52,11 +41,6 @@ public class CellWidgetCardPane extends BasicPane { public CellWidgetCardPane(ElementCasePane pane) { this.pane = pane; -// this.initComponents(pane); - } - - public BasicWidgetPropertySettingPane initBasicWidgetPropertyPane() { - return new BasicWidgetPropertySettingPane(); } @@ -88,16 +72,6 @@ public class CellWidgetCardPane extends BasicPane { tabsHeaderIconPane.setNeedLeftRightOutLine(false); this.add(tabsHeaderIconPane, BorderLayout.NORTH); - //数据字典 - dictTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - dictCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - dictTabPane.add(dictCardPane, BorderLayout.CENTER); - dictCardLayout = new CardLayout(); - dictCardPane.setLayout(dictCardLayout); - - //构建树 - treeTabPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - widgetPropertyPane = new BasicWidgetPropertySettingPane(); UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 280, 24, widgetPropertyPane); @@ -124,31 +98,12 @@ public class CellWidgetCardPane extends BasicPane { public void populate(Widget cellWidget) { initComponents(pane); -// super.populate(cellWidget); currentEditorDefinePane = null; - if (cellWidget instanceof NoneWidget) { -// this.tabbedPane.setEnabled(false); - } else { -// this.tabbedPane.setEnabled(true); - } - WidgetDefinePaneFactory.RN rn = WidgetDefinePaneFactory.createWidgetDefinePane(cellWidget, new Operator() { @Override public void did(DataCreatorUI ui, String cardName) { - if (ui == null) { - removeDictAttriPane(); - removeTreeAttriPane(); - } - if (ui instanceof DictionaryPane) { - removeDictAttriPane(); - removeTreeAttriPane(); - showDictPane(ui, cardName); - } else if (ui instanceof TreeSettingPane) { - removeDictAttriPane(); - removeTreeAttriPane(); - showTreePane(ui); - } + //todo } }); DataModify definePane = rn.getDefinePane(); @@ -160,19 +115,6 @@ public class CellWidgetCardPane extends BasicPane { tabsHeaderIconPane.setSelectedIndex(0); } - private void showDictPane(DataCreatorUI ui, String cardName) { - dictCardPane.removeAll(); - dictCardPane.add(ui.toSwingComponent(), cardName); - dictCardLayout.show(dictCardPane, cardName); - addDictAttriPane(); - } - - private void showTreePane(DataCreatorUI ui) { - treeTabPane.removeAll(); - treeTabPane.add(ui.toSwingComponent()); - addTreeAttriPane(); - } - public Widget update() { if (currentEditorDefinePane == null) { return null; @@ -182,7 +124,6 @@ public class CellWidgetCardPane extends BasicPane { return null; } widgetPropertyPane.update(widget); -// super.update(widget); Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); widget.clearListeners(); @@ -203,28 +144,4 @@ public class CellWidgetCardPane extends BasicPane { eventPane.checkValid(); } - - private void addDictAttriPane() { - center.add(this.dictTabPane, Inter.getLocText("FR-Designer_DS_Dictionary")); - reInitHeaderPane(this.dictTabPane); - } - - private void addTreeAttriPane() { - center.add(this.dictTabPane, Inter.getLocText("FR-Designer_Create_Tree")); - reInitHeaderPane(this.treeTabPane); - } - - private void removeDictAttriPane() { - center.remove(this.dictTabPane); - } - - private void removeTreeAttriPane() { - center.remove(this.treeTabPane); - } - - private void reInitHeaderPane(JPanel jPanel) { - paneList.add(jPanel); -// tabsHeaderIconPane = new - } - } diff --git a/designer/src/com/fr/design/widget/DataModify.java b/designer/src/com/fr/design/widget/DataModify.java deleted file mode 100644 index e2fd92b982..0000000000 --- a/designer/src/com/fr/design/widget/DataModify.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fr.design.widget; - -import com.fr.design.data.DataCreatorUI; -import com.fr.design.gui.frpane.TreeSettingPane; -import com.fr.design.present.dict.DictionaryPane; -import com.fr.form.ui.Widget; - -import javax.swing.*; - -public interface DataModify { - - void populateBean(T ob); - - T updateBean(); - - void checkValid() throws Exception; - - DataCreatorUI dataUI(); - - JComponent toSwingComponent(); -} \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/Operator.java b/designer/src/com/fr/design/widget/Operator.java deleted file mode 100644 index f8aad788e8..0000000000 --- a/designer/src/com/fr/design/widget/Operator.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.fr.design.widget; - -import com.fr.design.data.DataCreatorUI; - -/** - * Created by richie on 15/11/16. - */ -public interface Operator { - - void did(DataCreatorUI ui, String cardName); -} \ No newline at end of file diff --git a/designer/src/com/fr/design/widget/WidgetPane.java b/designer/src/com/fr/design/widget/WidgetPane.java index f26b1a19a4..c4ce0f5638 100644 --- a/designer/src/com/fr/design/widget/WidgetPane.java +++ b/designer/src/com/fr/design/widget/WidgetPane.java @@ -120,6 +120,7 @@ public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener public void populate(Widget widget) { if (widget == null) { + editorTypeComboBox.setSelectedIndex(-1); return; } diff --git a/designer/src/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java b/designer/src/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java index 62ec8864b2..5e95a9d09b 100644 --- a/designer/src/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java +++ b/designer/src/com/fr/design/widget/ui/BasicWidgetPropertySettingPane.java @@ -24,13 +24,18 @@ public class BasicWidgetPropertySettingPane extends BasicPane { public BasicWidgetPropertySettingPane() { this.setLayout(new BorderLayout()); enableCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Visible"), true); + enableCheckBox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); visibleCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Widget-Visible"), true); + visibleCheckBox.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); widgetNameComboBox = new ParameterTreeComboBox(); widgetNameComboBox.refreshTree(); + JPanel widgetNamePane = new JPanel(new BorderLayout()); + widgetNamePane.add(widgetNameComboBox, BorderLayout.CENTER); + widgetNamePane.setBorder(BorderFactory.createEmptyBorder(0,20,0,0)); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("FR-Designer_Form-Widget_Name") + " "), widgetNameComboBox}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Form-Widget_Name")), widgetNamePane}, new Component[]{enableCheckBox, null}, new Component[]{visibleCheckBox, null}, }; diff --git a/designer/src/com/fr/design/widget/ui/ButtonDefinePane.java b/designer/src/com/fr/design/widget/ui/ButtonDefinePane.java index b53e003e60..fcb3f2dcc6 100644 --- a/designer/src/com/fr/design/widget/ui/ButtonDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/ButtonDefinePane.java @@ -20,7 +20,6 @@ public class ButtonDefinePane extends AbstractDataModify