From 9e68e1210d0fac847396c852b0b8b39346be6a08 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 Aug 2017 18:39:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/locale/designer.properties | 5 +++-- .../src/com/fr/design/locale/designer_en_US.properties | 5 +++-- .../src/com/fr/design/locale/designer_ja_JP.properties | 1 + .../src/com/fr/design/locale/designer_ko_KR.properties | 3 ++- .../src/com/fr/design/locale/designer_zh_CN.properties | 3 ++- .../src/com/fr/design/locale/designer_zh_TW.properties | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index c048d29c5..96949d4e5 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -71,7 +71,7 @@ FR-Designer_Button-Icon= FR-Designer_Button-Name= FR-Designer_Button-Type= FR-Designer_CardLayout= -FR-Designer_Cell= +FR-Designer_Cell=Cell FR-Designer_Chart_Cell= FR-Designer_Chart_Float= FR-Designer_Chart_Float_chart= @@ -2131,4 +2131,5 @@ FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color FR-Designer-Basic_Dynamic_Parameter_Injection=Injection FR-Designer_Label= -FR-Designer_Widgetname=Widget Name \ No newline at end of file +FR-Designer_Widgetname=Widget Name +FR-Designer_Insert_Cell_Element=Insert Cell Element \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 4a87f1620..a28a02936 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -71,7 +71,7 @@ FR-Designer_Button-Icon=Button Icon FR-Designer_Button-Name=Button Name FR-Designer_Button-Type=Button Type FR-Designer_CardLayout=TabLayout -FR-Designer_Cell=cell +FR-Designer_Cell=Cell FR-Designer_Chart_Cell=Chart Hyperlink-Link Cell FR-Designer_Chart_Float=Chart Hyperlink-Floating Element FR-Designer_Chart_Float_chart=Chart Hyperlink-Floating Chart @@ -2127,4 +2127,5 @@ FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color FR-Designer-Basic_Dynamic_Parameter_Injection=Injection FR-Designer_Label=Label -FR-Designer_Widgetname=Widget Name \ No newline at end of file +FR-Designer_Widgetname=Widget Name +FR-Designer_Insert_Cell_Element=Insert Cell Element \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 05783bc7b..501932da0 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2126,3 +2126,4 @@ FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\ FR-Designer_Label=\u30E9\u30D9\u30EBa FR-Designer_Widgetname=\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u540D +FR-Designer_Insert_Cell_Element=\ diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 6a660743d..2d9828719 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2126,4 +2126,5 @@ FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection= FR-Designer_Label=\uB808\uC774\uBE14 -FR-Designer_Widgetname=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984 \ No newline at end of file +FR-Designer_Widgetname=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984 +FR-Designer_Insert_Cell_Element=\ \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 4e7b87973..1be9234d4 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2139,4 +2139,5 @@ FR-Designer-Download_Online_Sources=\u56FE\u8868\u9700\u8981\u4E0B\u8F7D\u6700\u FR-Designer_Select_Color=\u9009\u62E9\u989C\u8272 FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 FR-Designer_Label=\u6807\u7B7E -FR-Designer_Widgetname=\u63A7\u4EF6\u540D \ No newline at end of file +FR-Designer_Widgetname=\u63A7\u4EF6\u540D +FR-Designer_Insert_Cell_Element=\u63D2\u5165\u5143\u7D20 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 95c67c32a..518d8d949 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2131,3 +2131,4 @@ FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 FR-Designer_Label=\u6A19\u7C3D FR-Designer_Widgetname=\u63A7\u5236\u9805\u540D +FR-Designer_Insert_Cell_Element=\u63D2\u5165\u5143\u7D20 From a9863134a5a8c4848c8f9d151065bfd1ca016217 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 31 Aug 2017 12:17:14 +0800 Subject: [PATCH 2/3] REPORT-3348 --- .../com/fr/quickeditor/CellQuickEditor.java | 23 +++++++++++-------- .../cellquick/CellBiasTextPainterEditor.java | 2 +- .../cellquick/CellDSColumnEditor.java | 16 ++++++------- .../cellquick/CellFormulaQuickEditor.java | 2 +- .../cellquick/CellImageQuickEditor.java | 2 +- .../cellquick/CellRichTextEditor.java | 2 +- .../cellquick/CellSubReportEditor.java | 2 +- .../src/com/fr/file/FILEChooserPane.java | 1 - 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 6f0530a70..683f17bc7 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -43,6 +43,15 @@ public abstract class CellQuickEditor extends QuickEditor { /*面板配置*/ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; + /*占位label*/ + protected static final Dimension LABEL_DIMENSION = new Dimension(60, 20); + protected static final UILabel EMPTY_LABEL = new UILabel(); + + static { + EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); + } + + protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; private UIComboBox comboBox; private UpdateAction[] cellInsertActions; private int selectedIndex; @@ -53,12 +62,6 @@ public abstract class CellQuickEditor extends QuickEditor { private int currentSelectedIndex; - static { - emptyLabel.setPreferredSize(new Dimension(60, 20)); - } - - protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; - public CellQuickEditor() { scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) { @@ -117,10 +120,10 @@ public abstract class CellQuickEditor extends QuickEditor { double f = TableLayout.FILL; double[] columnSize = {p, f}; double[] rowSize = {p, p}; - UILabel cellLabel = new UILabel(Inter.getLocText("Cell")); - cellLabel.setPreferredSize(new Dimension(60, 20)); - UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content")); - insertContentLabel.setPreferredSize(new Dimension(60, 20)); + UILabel cellLabel = new UILabel(Inter.getLocText("FR-Designer_Cell")); + cellLabel.setPreferredSize(LABEL_DIMENSION); + UILabel insertContentLabel = new UILabel(Inter.getLocText("FR-Designer_Insert_Cell_Element")); + insertContentLabel.setPreferredSize(LABEL_DIMENSION); UIComboBox cellElementEditComboBox = initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, diff --git a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java index c17ac8678..d5d8e1f80 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java @@ -35,7 +35,7 @@ public class CellBiasTextPainterEditor extends CellQuickEditor { }); editButton.setOpaque(false); content.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{emptyLabel, editButton}}, + new Component[]{EMPTY_LABEL, editButton}}, new double[]{TableLayout.PREFERRED}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP), BorderLayout.CENTER); return content; diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 2c1a30c11..d7c6ddbd4 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -217,7 +217,7 @@ public class CellDSColumnEditor extends CellQuickEditor { double[] rowSize = {P}, columnSize = {P, F}; UILabel uiLabel = new UILabel(Inter.getLocText("FR-Designer_Filter_Conditions")); - uiLabel.setPreferredSize(new Dimension(60, 20)); + uiLabel.setPreferredSize(LABEL_DIMENSION); UIButton uiButton = new UIButton(); if (tc != null) { //第一次初始化时tc为空,会引发NullPointerException @@ -481,14 +481,13 @@ public class CellDSColumnEditor extends CellQuickEditor { multiNumSpinner = new UISpinner(1, 10000, 1, 1); //数据倍数 UILabel multipleLabel = new UILabel(Inter.getLocText("Column_Multiple")); - multipleLabel.setPreferredSize(new Dimension(60, 20)); multiPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ new Component[]{ multipleLabel, multiNumSpinner } }, new double[]{P}, new double[]{P, F}, HGAP, VGAP ); - multiPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + multiPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); multiNumPane.add(multiPane); useMultiplyNumCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -563,7 +562,7 @@ public class CellDSColumnEditor extends CellQuickEditor { centerPane.add(new JPanel(), "none"); centerPane.add(formulaField, "content"); UILabel sortLabel = new UILabel(Inter.getLocText("Sort-Sort_Order")); - sortLabel.setPreferredSize(new Dimension(60, 20)); + sortLabel.setPreferredSize(LABEL_DIMENSION); sortTypePane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -982,7 +981,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public CustomValuePane() { this.setLayout(new BorderLayout()); UILabel customValueLabel = new UILabel(Inter.getLocText("FR-Designer_Display_Value")); - customValueLabel.setPreferredSize(new Dimension(60, 20)); + customValueLabel.setPreferredSize(LABEL_DIMENSION); formulaField = new JFormulaField(DEFAULT_VALUE); this.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ new Component[]{customValueLabel, formulaField}, @@ -994,14 +993,13 @@ public class CellDSColumnEditor extends CellQuickEditor { Object value = cellElement.getValue(); if (value != null && value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; - //formula String valueFormula = dSColumn.getResult(); - if (valueFormula == null) { - valueFormula = DEFAULT_VALUE; + if (valueFormula != null) { + formulaField.populate(valueFormula); } formulaField.populateElement(cellElement); - formulaField.populate(valueFormula); + } } } diff --git a/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java index fcd16a676..7429b146e 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java @@ -121,7 +121,7 @@ public class CellFormulaQuickEditor extends CellQuickEditor { content.add(pane, BorderLayout.NORTH); return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{emptyLabel, content}}, + new Component[]{EMPTY_LABEL, content}}, new double[]{TableLayout.PREFERRED}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP); } diff --git a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java index 51b7417ac..25818e79f 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java @@ -43,7 +43,7 @@ public class CellImageQuickEditor extends CellQuickEditor { }); editButton.setOpaque(false); content.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{emptyLabel, editButton}}, + new Component[]{EMPTY_LABEL, editButton}}, new double[]{TableLayout.PREFERRED}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP), BorderLayout.CENTER); return content; diff --git a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index 8f8afbeed..75ef442da 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -30,7 +30,7 @@ public class CellRichTextEditor extends CellQuickEditor { richTextButton = new UIButton(); richTextButton.setOpaque(false); content.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{emptyLabel, richTextButton}}, + new Component[]{EMPTY_LABEL, richTextButton}}, new double[]{TableLayout.PREFERRED}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP), BorderLayout.CENTER); return content; diff --git a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index e28bdbf39..70d8c51ea 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -31,7 +31,7 @@ public class CellSubReportEditor extends CellQuickEditor { subReportButton = new UIButton(); subReportButton.setOpaque(false); content.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{emptyLabel, subReportButton}}, + new Component[]{EMPTY_LABEL, subReportButton}}, new double[]{TableLayout.PREFERRED}, new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP), BorderLayout.CENTER); return content; diff --git a/designer_base/src/com/fr/file/FILEChooserPane.java b/designer_base/src/com/fr/file/FILEChooserPane.java index 02c92f646..09e911421 100644 --- a/designer_base/src/com/fr/file/FILEChooserPane.java +++ b/designer_base/src/com/fr/file/FILEChooserPane.java @@ -475,7 +475,6 @@ public class FILEChooserPane extends BasicPane { this.type = type; this.suffix = suffix; - dialog = showWindow(parent instanceof DesignerFrame ? (Window) parent : SwingUtilities.getWindowAncestor(parent), false); JPanel contentPane = (JPanel) dialog.getContentPane(); contentPane.setLayout(FRGUIPaneFactory.createM_BorderLayout()); From 244e9a06c87acc84eba796405818e01a028d7fc3 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 31 Aug 2017 13:57:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-3348=20=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BD=BF=E7=94=A8=E5=8D=95=E7=8B=AC=E7=9A=84?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/cell/CellEditorPane.java | 97 ++++++- .../com/fr/quickeditor/CellQuickEditor.java | 256 +++++++++--------- .../cellquick/CellBiasTextPainterEditor.java | 5 + .../cellquick/CellDSColumnEditor.java | 18 +- .../cellquick/CellElementBarLayout.java | 41 +++ .../cellquick/CellFormulaQuickEditor.java | 5 + .../cellquick/CellImageQuickEditor.java | 5 + .../cellquick/CellRichTextEditor.java | 5 + .../cellquick/CellStringQuickEditor.java | 5 + .../cellquick/CellSubReportEditor.java | 4 + 10 files changed, 300 insertions(+), 141 deletions(-) create mode 100644 designer/src/com/fr/quickeditor/cellquick/CellElementBarLayout.java diff --git a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java index 48b6d8a17..6fbf73dc0 100644 --- a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java +++ b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java @@ -1,6 +1,15 @@ package com.fr.design.mainframe.cell; -import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.design.mainframe.CellElementPropertyPane; +import com.fr.quickeditor.cellquick.CellElementBarLayout; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; /** * 右侧单元格元素面板抽象类 @@ -9,7 +18,20 @@ import com.fr.design.dialog.BasicPane; * @version 2017年7月25日 * @since 9.0 */ -public abstract class CellEditorPane extends BasicPane { +public abstract class CellEditorPane extends JPanel { + + /*滚动条相关配置*/ + private static final int MAXVALUE = 100; + private static final int TITLE_HEIGHT = 95; + private static final int CONTENT_PANE_WIDTH_GAP = 3; + private static final int SCROLLBAR_WIDTH = 7; + private static final int MOUSE_WHEEL_SPEED = 5; + private int maxHeight = 280; + + private JPanel leftContentPane; + private UIScrollBar scrollBar; + + protected abstract JPanel createContentPane(); public abstract String getIconPath(); @@ -22,7 +44,76 @@ public abstract class CellEditorPane extends BasicPane { /** * 更新面板数据 - * */ public abstract void populate(); + + protected void createScrollPane() { + leftContentPane = this.createContentPane(); + this.prepareScrollBar(); + leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); + + this.setLayout(new CellElementBarLayout(leftContentPane) { + @Override + public void layoutContainer(Container parent) { + maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT; + int beginY; + if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) { + beginY = 0; + } else { + int preferredHeight = leftContentPane.getPreferredSize().height; + int value = scrollBar.getValue(); + beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); + } + int width = parent.getWidth(); + int height = parent.getHeight(); + if (leftContentPane.getPreferredSize().height > maxHeight) { + leftContentPane.setBounds(0, -beginY, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height + beginY); + scrollBar.setBounds(width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, 0, SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, height); + } else { + leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height); + } + } + }); + this.add(scrollBar); + this.add(leftContentPane); + } + + + private void prepareScrollBar() { + scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) { + @Override + public int getVisibleAmount() { + int preferredHeight = leftContentPane.getPreferredSize().height; + int e = MAXVALUE * (maxHeight) / preferredHeight; + setVisibleAmount(e); + return e; + } + + @Override + public int getMaximum() { + return MAXVALUE; + } + }; + + scrollBar.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + doLayout(); + } + }); + this.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + int value = scrollBar.getValue(); + value += MOUSE_WHEEL_SPEED * e.getWheelRotation(); + scrollBar.setValue(value); + doLayout(); + } + }); + scrollBar.setPreferredSize(new Dimension(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, this.getHeight())); + scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP); + scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground())); + } } diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 683f17bc7..a3cd54643 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -18,6 +18,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.selection.QuickEditor; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; +import com.fr.quickeditor.cellquick.CellElementBarLayout; import com.fr.report.cell.TemplateCellElement; import com.fr.stable.ColumnRow; @@ -33,37 +34,145 @@ import java.util.ArrayList; */ public abstract class CellQuickEditor extends QuickEditor { - /*滚动条相关配置*/ - private static final int MAXVALUE = 100; - private static final int TITLE_HEIGHT = 50; - private static final int MOUSE_WHEEL_SPEED = 5; - private static final int CONTENT_PANE_WIDTH_GAP = 4; - private static final int SCROLLBAR_WIDTH = 8; - private int maxHeight = 280; + /*面板配置*/ protected UITextField columnRowTextField; protected TemplateCellElement cellElement; /*占位label*/ protected static final Dimension LABEL_DIMENSION = new Dimension(60, 20); protected static final UILabel EMPTY_LABEL = new UILabel(); + protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; static { EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); } - protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; + /*滚动条相关配置*/ + private static final int MAXVALUE = 100; + private static final int CONTENT_PANE_WIDTH_GAP = 3; + private static final int MOUSE_WHEEL_SPEED = 5; + private static final int SCROLLBAR_WIDTH = 7; + private int maxHeight = 280; + private static final int TITLE_HEIGHT = 50; + private UIComboBox comboBox; private UpdateAction[] cellInsertActions; private int selectedIndex; + private int currentSelectedIndex; private JPanel leftContentPane; private UIScrollBar scrollBar; - /*占位label*/ - protected static UILabel emptyLabel = new UILabel(); - - private int currentSelectedIndex; public CellQuickEditor() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + JComponent centerBody = createCenterBody(); + JPanel topContent = initTopContent(); + if (isScrollAll()) { + prepareScrollBar(); + topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); + centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); + Component[][] components = new Component[][]{ + new Component[]{topContent, null}, + new Component[]{centerBody, null} + }; + leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + this.setLayout(new CellElementBarLayout(leftContentPane) { + @Override + public void layoutContainer(Container parent) { + maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT; + int beginY; + if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) { + beginY = 0; + } else { + int preferredHeight = leftContentPane.getPreferredSize().height; + int value = scrollBar.getValue(); + beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); + } + int width = parent.getWidth(); + int height = parent.getHeight(); + if (leftContentPane.getPreferredSize().height > maxHeight) { + leftContentPane.setBounds(0, -beginY, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height + beginY); + scrollBar.setBounds(width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, 0, SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, height); + } else { + leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height); + } + leftContentPane.validate(); + } + }); + this.add(scrollBar); + this.add(leftContentPane); + } else { + topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); + centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); + Component[][] components = new Component[][]{ + new Component[]{topContent, null}, + new Component[]{centerBody, null} + }; + this.setLayout(new BorderLayout()); + this.add(TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); + } + } + + /** + * 初始化详细信息面板 + * + * @return JComponent 待显示的详细信息面板 + */ + public abstract JComponent createCenterBody(); + + /** + * 是否全局具有滚动条 + * + * @return boolean 是否全局具有滚动条 + */ + public abstract boolean isScrollAll(); + + + /** + * 初始化下拉框中的类型 + * + * @return JComponent 待显示的详细信息面板 + */ + public abstract Object getComboBoxSelected(); + + /** + * 刷新 + */ + @Override + protected void refresh() { + CellSelection cs = (CellSelection) tc.getSelection(); + ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); + columnRowTextField.setText(columnRow.toString()); + cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); + refreshDetails(); + } + + /** + * 刷新详细信息 + */ + protected abstract void refreshDetails(); + + + private JPanel initTopContent() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + UILabel cellLabel = new UILabel(Inter.getLocText("FR-Designer_Cell")); + cellLabel.setPreferredSize(LABEL_DIMENSION); + UILabel insertContentLabel = new UILabel(Inter.getLocText("FR-Designer_Insert_Cell_Element")); + insertContentLabel.setPreferredSize(LABEL_DIMENSION); + UIComboBox cellElementEditComboBox = initCellElementEditComboBox(); + Component[][] components = new Component[][]{ + new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, + new Component[]{insertContentLabel, cellElementEditComboBox}, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + } + private void prepareScrollBar() { scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) { @Override public int getVisibleAmount() { @@ -77,7 +186,6 @@ public abstract class CellQuickEditor extends QuickEditor { public int getMaximum() { return MAXVALUE; } - }; scrollBar.addAdjustmentListener(new AdjustmentListener() { @@ -98,43 +206,11 @@ public abstract class CellQuickEditor extends QuickEditor { } }); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p}; - JComponent centerBody = createCenterBody(); - centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); - Component[][] components = new Component[][]{ - new Component[]{initTopContent(), null}, - new Component[]{centerBody, null} - }; - leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.setLayout(new BarLayout()); - this.add(scrollBar); - this.add(leftContentPane); - } - - - private JPanel initTopContent() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p}; - UILabel cellLabel = new UILabel(Inter.getLocText("FR-Designer_Cell")); - cellLabel.setPreferredSize(LABEL_DIMENSION); - UILabel insertContentLabel = new UILabel(Inter.getLocText("FR-Designer_Insert_Cell_Element")); - insertContentLabel.setPreferredSize(LABEL_DIMENSION); - UIComboBox cellElementEditComboBox = initCellElementEditComboBox(); - Component[][] components = new Component[][]{ - new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, cellElementEditComboBox}, - }; - JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); - return topContent; + scrollBar.setPreferredSize(new Dimension(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, this.getHeight())); + scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP); + scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground())); } - /** * 初始化添加按钮 * @@ -209,88 +285,4 @@ public abstract class CellQuickEditor extends QuickEditor { }); return columnRowTextField; } - - - /** - * 初始化详细信息面板 - * - * @return JComponent 待显示的详细信息面板 - */ - public abstract JComponent createCenterBody(); - - - /** - * 初始化下拉框中的类型 - * - * @return JComponent 待显示的详细信息面板 - */ - public abstract Object getComboBoxSelected(); - - /** - * 刷新 - */ - @Override - protected void refresh() { - CellSelection cs = (CellSelection) tc.getSelection(); - ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); - columnRowTextField.setText(columnRow.toString()); - cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); - refreshDetails(); - } - - /** - * 刷新详细信息 - */ - protected abstract void refreshDetails(); - - /** - * 属性面板的滚动条和内容区域的布局管理类 - * yaoh.wu 由于这边不能继承{@link com.fr.design.mainframe.AbstractAttrPane.BarLayout},所以冗余了一份滚动条代码进来 - * - * @see com.fr.design.mainframe.AbstractAttrPane.BarLayout - */ - protected class BarLayout implements LayoutManager { - - @Override - public void addLayoutComponent(String name, Component comp) { - - } - - @Override - public void removeLayoutComponent(Component comp) { - - } - - @Override - public Dimension preferredLayoutSize(Container parent) { - return leftContentPane.getPreferredSize(); - } - - @Override - public Dimension minimumLayoutSize(Container parent) { - return leftContentPane.getMinimumSize(); - } - - @Override - public void layoutContainer(Container parent) { - maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT; - int beginY; - if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) { - beginY = 0; - } else { - int preferredHeight = leftContentPane.getPreferredSize().height; - int value = scrollBar.getValue(); - beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); - } - int width = parent.getWidth(); - int height = parent.getHeight(); - if (leftContentPane.getPreferredSize().height > maxHeight) { - leftContentPane.setBounds(0, -beginY, width - scrollBar.getWidth() - CONTENT_PANE_WIDTH_GAP, height + beginY); - scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, scrollBar.getWidth(), height); - } else { - leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height); - } - leftContentPane.validate(); - } - } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java index d5d8e1f80..8347f6d0d 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java @@ -68,4 +68,9 @@ public class CellBiasTextPainterEditor extends CellQuickEditor { protected void refreshDetails() { } + @Override + public boolean isScrollAll() { + return true; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index d7c6ddbd4..4ea7a138c 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -98,6 +98,11 @@ public class CellDSColumnEditor extends CellQuickEditor { return centerPane; } + @Override + public boolean isScrollAll() { + return false; + } + /** * 内容全部重新动态生成,不然容易出错 * 刷新详细信息面板 @@ -158,9 +163,11 @@ public class CellDSColumnEditor extends CellQuickEditor { paneList = new ArrayList<>(); /*基本设置面板*/ DSColumnBasicEditorPane cellDSColumnBasicPane = new DSColumnBasicEditorPane(); + paneList.add(cellDSColumnBasicPane); /*高级设置面板*/ cellDSColumnAdvancedPane = new DSColumnAdvancedEditorPane(); + paneList.add(cellDSColumnAdvancedPane); } @@ -209,7 +216,6 @@ public class CellDSColumnEditor extends CellQuickEditor { }; DSColumnBasicEditorPane() { - this.setLayout(new BorderLayout()); dataPane = new SelectedDataColumnPane(true, true, tc, cellElement); groupPane = new ResultSetGroupDockingPane(tc); dataPane.addListener(dataListener); @@ -231,8 +237,9 @@ public class CellDSColumnEditor extends CellQuickEditor { new Component[]{uiLabel, uiButton} }; conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.add(this.createContentPane(), BorderLayout.CENTER); + this.createScrollPane(); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + } @@ -265,7 +272,7 @@ public class CellDSColumnEditor extends CellQuickEditor { * * @return content JPanel */ - private JPanel createContentPane() { + protected JPanel createContentPane() { double[] columnSize = {F}; double[] rowSize = {P, P, P}; @@ -303,9 +310,8 @@ public class CellDSColumnEditor extends CellQuickEditor { public DSColumnAdvancedEditorPane() { - this.setLayout(new BorderLayout()); - this.add(this.createContentPane(), BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + this.createScrollPane(); } @@ -415,7 +421,7 @@ public class CellDSColumnEditor extends CellQuickEditor { * * @return 内容面板 */ - private JPanel createContentPane() { + protected JPanel createContentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); //结果集排序 sortPane = new ResultSetSortConfigPane(); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellElementBarLayout.java b/designer/src/com/fr/quickeditor/cellquick/CellElementBarLayout.java new file mode 100644 index 000000000..c9714bc46 --- /dev/null +++ b/designer/src/com/fr/quickeditor/cellquick/CellElementBarLayout.java @@ -0,0 +1,41 @@ +package com.fr.quickeditor.cellquick; + +import javax.swing.*; +import java.awt.*; + +/** + * 单元格元素面板的滚动条 + * + * @see com.fr.design.mainframe.AbstractAttrPane.BarLayout + */ +public abstract class CellElementBarLayout implements LayoutManager { + + private JPanel leftContentPane; + + protected CellElementBarLayout(JPanel leftContentPane) { + this.leftContentPane = leftContentPane; + } + + @Override + public void addLayoutComponent(String name, Component comp) { + + } + + @Override + public void removeLayoutComponent(Component comp) { + + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + return leftContentPane.getPreferredSize(); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return leftContentPane.getMinimumSize(); + } + + @Override + public abstract void layoutContainer(Container parent); +} \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java index 7429b146e..7d245434c 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java @@ -203,4 +203,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor { formulaTextField.getDocument().addDocumentListener(documentListener); } + @Override + public boolean isScrollAll() { + return true; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java index 25818e79f..d33ff1828 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java @@ -72,6 +72,11 @@ public class CellImageQuickEditor extends CellQuickEditor { } + @Override + public boolean isScrollAll() { + return true; + } + @Override public Object getComboBoxSelected() { return ActionFactory.createAction(ImageCellAction.class); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index 75ef442da..1c0bdd04d 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -49,4 +49,9 @@ public class CellRichTextEditor extends CellQuickEditor { richTextButton.setAction(subReportCellAction); } + @Override + public boolean isScrollAll() { + return true; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index c82a3883d..bd5ea60d1 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -90,6 +90,11 @@ public class CellStringQuickEditor extends CellQuickEditor { return content; } + @Override + public boolean isScrollAll() { + return true; + } + private void changeReportPaneCell(String tmpText) { isEditing = true; diff --git a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index 70d8c51ea..be34789f9 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -50,4 +50,8 @@ public class CellSubReportEditor extends CellQuickEditor { return ActionFactory.createAction(SubReportCellAction.class); } + @Override + public boolean isScrollAll() { + return true; + } } \ No newline at end of file