diff --git a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index 4889d250c1..61ac3bd361 100644 --- a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -23,7 +23,7 @@ import java.awt.event.ItemListener; * 这个pane是选中数据列后,在上方QuickRegion处显示的pane * * @author zhou, yaoh.wu - * @version 2017年8月2日14点55分 + * @version 2017年9月26日17点22分 * @since 8.0 */ public class ResultSetGroupDockingPane extends ResultSetGroupPane { @@ -115,13 +115,13 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { @Override public void populate(TemplateCellElement cellElement) { + //更新面板信息时可能会触发绑定在组件上的事件,先移除这些事件 + this.removeListener(); this.cellElement = cellElement; - - if (isNPE(cellElement)) return; + if (isNPE(cellElement)) { + return; + } DSColumn dSColumn = (DSColumn) cellElement.getValue(); - - // populate groupPane - // RecordGrouper recordGrouper = dSColumn.getGrouper(); if (recordGrouper instanceof FunctionGrouper && !((FunctionGrouper) recordGrouper).isCustom()) { int mode = recordGrouper.getDivideMode(); @@ -153,13 +153,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { this.groupComboBox.setSelectedIndex(ADVANCED); } checkButtonEnabled(); + //加上面板组件的交互事件监听 + this.addListener(); } @Override public void update() { - if (isNPE(cellElement)) return; + if (isNPE(cellElement)) { + return; + } DSColumn dSColumn = (DSColumn) cellElement.getValue(); - if (this.goBox.getSelectedIndex() == BIND_GROUP) { recordGrouper = updateGroupCombox(); } else if (this.goBox.getSelectedIndex() == BIND_SELECTED) { @@ -206,10 +209,8 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { cardPane.repaint(); } - public void addListener(ItemListener listener) { - goBox.addItemListener(listener); - groupComboBox.addItemListener(listener); - functionComboBox.addItemListener(listener); + + public void setListener(ItemListener listener) { this.listener = listener; } @@ -221,4 +222,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { public void setRecordGrouper(RecordGrouper recordGrouper) { this.recordGrouper = recordGrouper; } + + private void addListener() { + goBox.addItemListener(this.listener); + groupComboBox.addItemListener(this.listener); + functionComboBox.addItemListener(this.listener); + } + + private void removeListener() { + goBox.removeItemListener(this.listener); + groupComboBox.removeItemListener(this.listener); + functionComboBox.removeItemListener(this.listener); + } } \ 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 1399ad2eb6..e7ccd77108 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -219,7 +219,7 @@ public class CellDSColumnEditor extends CellQuickEditor { dataPane = new SelectedDataColumnPane(true, true, tc, cellElement); groupPane = new ResultSetGroupDockingPane(); dataPane.addListener(dataListener); - groupPane.addListener(groupListener); + groupPane.setListener(groupListener); double[] rowSize = {P}, columnSize = {P, F}; UILabel uiLabel = new UILabel(Inter.getLocText("FR-Designer_Filter_Conditions"));