Browse Source

REPORT-6868 设计器数据列单元格切换频繁弹出sql参数对话框

master
yaoh.wu 7 years ago
parent
commit
5c7c5acef3
  1. 48
      designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java
  2. 17
      designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java
  3. 338
      designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java
  4. 70
      designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java
  5. 156
      designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java

48
designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java

@ -1,34 +1,37 @@
package com.fr.design.gui.demo; package com.fr.design.gui.demo;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
import javax.swing.DefaultListCellRenderer;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.ListCellRenderer;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.icombobox.filter.Filter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.icombobox.ComboCheckBox; import com.fr.design.gui.icombobox.ComboCheckBox;
import com.fr.design.gui.icombobox.DictionaryComboBox; import com.fr.design.gui.icombobox.DictionaryComboBox;
import com.fr.design.gui.icombobox.ExtendedComboBox; import com.fr.design.gui.icombobox.ExtendedComboBox;
import com.fr.design.gui.icombobox.FRTreeComboBox; import com.fr.design.gui.icombobox.FRTreeComboBox;
import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.icombobox.LazyComboBox; import com.fr.design.gui.icombobox.LazyComboBox;
import com.fr.design.gui.icombobox.filter.Filter;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.ListCellRenderer;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: Richer * User: Richer
@ -42,12 +45,12 @@ public class ComboBoxDemo extends JPanel {
double f = TableLayout.FILL; double f = TableLayout.FILL;
Component[][] coms = new Component[][]{ Component[][] coms = new Component[][]{
{new UILabel(Inter.getLocText("Form-ComboCheckBox")+":"), createComboCheckBox()}, {new UILabel(Inter.getLocText("Form-ComboCheckBox") + ":"), createComboCheckBox()},
{new UILabel(Inter.getLocText(new String[]{"DS-Dictionary", "Form-ComboBox"})+":"), createDictComboBox()}, {new UILabel(Inter.getLocText(new String[]{"DS-Dictionary", "Form-ComboBox"}) + ":"), createDictComboBox()},
{new UILabel(Inter.getLocText("long_data_can_not_show_fully")+":"), createExtendedComboBox()}, {new UILabel(Inter.getLocText("long_data_can_not_show_fully") + ":"), createExtendedComboBox()},
{new UILabel(Inter.getLocText(new String[]{"Filter", "Form-ComboBox"})+":"), createFilterComboBox()}, {new UILabel(Inter.getLocText(new String[]{"Filter", "Form-ComboBox"}) + ":"), createFilterComboBox()},
{new UILabel(Inter.getLocText("Form-ComboBox")+":"), createTreeComboBox()}, {new UILabel(Inter.getLocText("Form-ComboBox") + ":"), createTreeComboBox()},
{new UILabel(Inter.getLocText(new String[]{"Delay", "Load", "Form-ComboBox"})+":"), createLazyComboBox()} {new UILabel(Inter.getLocText(new String[]{"Delay", "Load", "Form-ComboBox"}) + ":"), createLazyComboBox()}
}; };
double[] rowSize = new double[coms.length]; double[] rowSize = new double[coms.length];
double[] columnSize = {p, f}; double[] columnSize = {p, f};
@ -165,6 +168,7 @@ public class ComboBoxDemo extends JPanel {
// 睡5秒 // 睡5秒
try { try {
Thread.sleep(5000); Thread.sleep(5000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }

17
designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java

@ -1,16 +1,15 @@
package com.fr.design.gui.demo; package com.fr.design.gui.demo;
import java.awt.BorderLayout; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import java.awt.BorderLayout;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -19,10 +18,10 @@ import com.fr.design.utils.gui.GUICoreUtils;
* Time: 下午4:54 * Time: 下午4:54
*/ */
public class SwingComponentsDemo extends JFrame { public class SwingComponentsDemo extends JFrame {
public SwingComponentsDemo() { private SwingComponentsDemo() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
init(); init();
JPanel contentPane = (JPanel)getContentPane(); JPanel contentPane = (JPanel) getContentPane();
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout()); contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
JTabbedPane tab = new JTabbedPane(); JTabbedPane tab = new JTabbedPane();
contentPane.add(tab, BorderLayout.CENTER); contentPane.add(tab, BorderLayout.CENTER);
@ -40,12 +39,12 @@ public class SwingComponentsDemo extends JFrame {
public static void main(String[] args) { public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
JFrame f = new SwingComponentsDemo(); JFrame f = new SwingComponentsDemo();
f.setSize(500, 500); f.setSize(500, 500);
f.setVisible(true); f.setVisible(true);
GUICoreUtils.centerWindow(f); GUICoreUtils.centerWindow(f);
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
} }
}); });
} }

338
designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java

@ -3,212 +3,190 @@
*/ */
package com.fr.design.gui.icombobox; package com.fr.design.gui.icombobox;
import java.awt.Dimension; import com.fr.general.FRLogger;
import java.util.ArrayList; import com.fr.general.Inter;
import java.util.List;
import javax.swing.*; import javax.swing.DefaultComboBoxModel;
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.basic.BasicComboPopup; import java.awt.Dimension;
import java.util.concurrent.ExecutionException;
import com.fr.general.Inter;
/** /**
* @author richer * @author richer
* @version 2018年2月6日14点43分 by @yaoh.wu
* @since 6.5.5 创建于2011-6-15 延迟加载的下拉框 * @since 6.5.5 创建于2011-6-15 延迟加载的下拉框
*/ */
public abstract class LazyComboBox extends UIComboBox implements PopupMenuListener { public abstract class LazyComboBox extends UIComboBox implements PopupMenuListener {
protected boolean loaded = false;
private List<EventListener> ls = new ArrayList<EventListener>(); private static final int NUM = 80;
private Object initialSelected = null; private static final String[] PENDING_CONTENT = new String[]{"", Inter.getLocText("Loading") + "..."};
private static final int NUM=80;
/**
public static final Object PENDING = new Object() { * 是否加载完成
*/
@Override protected boolean loaded = false;
public String toString() {
return Inter.getLocText("Loading") + "..."; /**
} * 初始化选项
}; */
private Object initialSelected = null;
public LazyComboBox() {
super();
this.setEditor(new FilterComboBoxEditor()); protected LazyComboBox() {
addPopupMenuListener(this); super();
// updateUI(); this.setEditor(new FilterComboBoxEditor());
} addPopupMenuListener(this);
}
public void setLoaded(boolean loaded) {
this.loaded = loaded; public void setLoaded(boolean loaded) {
} this.loaded = loaded;
}
public abstract Object[] load();
/**
public void setSelectedItem(Object anObject) { * 加载下拉框中的选项
initialSelected = anObject; *
if (loaded) { * @return 下拉框中的选项
super.setSelectedItem(anObject); */
} else { public abstract Object[] load();
setModel(new DefaultComboBoxModel(new Object[] { anObject })); @Override
super.setSelectedItem(anObject); public void setSelectedItem(Object anObject) {
} initialSelected = anObject;
} if (loaded) {
super.setSelectedItem(anObject);
/** } else {
* 通过调用该方法在点击下拉框按钮之前就加载好数据 this.setModel(new DefaultComboBoxModel<>(new Object[]{anObject}));
*/ super.setSelectedItem(anObject);
public void loadInstant() { }
if (loaded) { }
return;
} @Override
setModel(new DefaultComboBoxModel(load())); public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
loaded = true;
}
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
if (loaded) { if (loaded) {
return; return;
} }
DefaultComboBoxModel loadingModel = new DefaultComboBoxModel(new String[]{"", Inter.getLocText("Loading") + "..."}); DefaultComboBoxModel<String> loadingModel = new DefaultComboBoxModel<>(PENDING_CONTENT);
LazyComboBox.this.setModel(loadingModel); this.setModel(loadingModel);
new SwingWorker<Void, Void>() { new SwingWorker<Object[], Void>() {
@Override @Override
protected Void doInBackground() throws Exception { protected Object[] doInBackground() {
final Object selectedObj = getSelectedItem(); return load();
loadList();
return null;
} }
@Override @Override
public void done() { public void done() {
LazyComboBox.this.updateUI(); try {
LazyComboBox.this.fireEvent(); LazyComboBox.this.loadList(get());
} catch (InterruptedException | ExecutionException exception) {
FRLogger.getLogger().debug(exception.getMessage());
}
LazyComboBox.this.showPopup(); LazyComboBox.this.showPopup();
} }
}.execute(); }.execute();
}
/**
* 加载下拉列表
*/
public void loadList() {
DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(load());
model.setSelectedItem(initialSelected);
this.setModel(model);
this.selectedItemReminder = initialSelected;
loaded = true;
} }
/** /**
* 计算加载下拉列表 * 加载下拉列表
*/ *
public void loadList() { * @param contents 下拉列表内容
DefaultComboBoxModel model = new DefaultComboBoxModel(load()); */
private void loadList(Object[] contents) {
DefaultComboBoxModel<Object> model = new DefaultComboBoxModel<>(contents);
model.setSelectedItem(initialSelected); model.setSelectedItem(initialSelected);
LazyComboBox.this.setModel(model); this.setModel(model);
LazyComboBox.this.selectedItemReminder = initialSelected ; this.selectedItemReminder = initialSelected;
loaded = true; loaded = true;
} }
@Override @Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
} }
@Override @Override
public void popupMenuCanceled(PopupMenuEvent e) { public void popupMenuCanceled(PopupMenuEvent e) {
} }
public void addClickListener(EventListener l) { @Override
if (ls == null) { public Dimension getPreferredSize() {
ls = new ArrayList<LazyComboBox.EventListener>(); Dimension dim = super.getPreferredSize();
} dim.width = NUM;
ls.add(l); return dim;
} }
public void fireEvent() { class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
for (int i = 0, n = ls.size(); i < n; i++) { private Object item;
ls.get(i).fireEvent(); private volatile boolean filtering = false;
} private volatile boolean setting = false;
}
public FilterComboBoxEditor() {
@Override super();
public Dimension getPreferredSize() { textField.getDocument().addDocumentListener(this);
Dimension dim = super.getPreferredSize(); }
dim.width = NUM;
return dim; @Override
} public void setItem(Object item) {
if (filtering) {
private static class LazyPopMenu extends BasicComboPopup { return;
}
public LazyPopMenu(final JComboBox combo) { this.item = item;
super(combo); this.setting = true;
LazyComboBox comboc = (LazyComboBox) combo; textField.setSetting(true);
comboc.addClickListener(new EventListener() { String newText = (item == null) ? "" : item.toString();
textField.setText(newText);
@Override textField.setSetting(false);
public void fireEvent() { this.setting = false;
LazyPopMenu.this.show(); }
combo.showPopup();
} @Override
}); public Object getItem() {
} return this.item;
} }
private interface EventListener { @Override
void fireEvent(); public void insertUpdate(DocumentEvent e) {
} handleChange();
}
class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
private Object item; @Override
private volatile boolean filtering = false; public void removeUpdate(DocumentEvent e) {
private volatile boolean setting = false; handleChange();
}
public FilterComboBoxEditor() {
super(); @Override
textField.getDocument().addDocumentListener(this); public void changedUpdate(DocumentEvent e) {
} handleChange();
}
public void setItem(Object item) {
if (filtering) { void handleChange() {
return; if (setting) {
} return;
this.item = item; }
filtering = true;
this.setting = true; String xx = textField.getText();
textField.setSetting(true); LazyComboBox.this.setSelectedItem(xx);
String newText = (item == null) ? "" : item.toString(); this.item = textField.getText();
textField.setText(newText);
textField.setSetting(false); setPopupVisible(true);
this.setting = false; filtering = false;
} }
}
public Object getItem() {
return this.item;
}
public void insertUpdate(DocumentEvent e) {
handleChange();
}
public void removeUpdate(DocumentEvent e) {
handleChange();
}
public void changedUpdate(DocumentEvent e) {
handleChange();
}
protected void handleChange() {
if (setting) {
return;
}
filtering = true;
String xx = textField.getText();
LazyComboBox.this.setSelectedItem(xx);
this.item = textField.getText();
setPopupVisible(true);
filtering = false;
}
}
} }

70
designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java

@ -4,12 +4,13 @@ import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*; import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.ListCellRenderer;
import javax.swing.plaf.ComboBoxUI; import javax.swing.plaf.ComboBoxUI;
import javax.swing.plaf.basic.ComboPopup; import javax.swing.plaf.basic.ComboPopup;
import java.awt.*; import java.awt.Dimension;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -112,8 +113,6 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
public void setRenderer(ListCellRenderer aRenderer) { public void setRenderer(ListCellRenderer aRenderer) {
if (aRenderer instanceof UIComboBoxRenderer) { if (aRenderer instanceof UIComboBoxRenderer) {
super.setRenderer(aRenderer); super.setRenderer(aRenderer);
} else {
//throw new IllegalArgumentException("Must be UIComboBoxRenderer");
} }
} }
@ -121,13 +120,15 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
return null; return null;
} }
@Override
public void setGlobalName(String name) { public void setGlobalName(String name) {
comboBoxName = name; comboBoxName = name;
} }
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);//加5的原因在于:render里,每一个项前面了空了一格,要多几像素 //加5的原因在于:render里,每一个项前面了空了一格,要多几像素
return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);
} }
/** /**
@ -144,70 +145,53 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
} }
/** /**
* *
*/ */
@Override
public void updateUI() { public void updateUI() {
setUI(getUIComboBoxUI()); setUI(getUIComboBoxUI());
} }
/** /**
* * @param listener 观察者监听事件
* @param listener 观察者监听事件 */
*/ @Override
public void registerChangeListener(UIObserverListener listener) { public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener; uiObserverListener = listener;
} }
public void removeChangeListener(){ public void removeChangeListener() {
uiObserverListener = null; uiObserverListener = null;
} }
public UIObserverListener getUiObserverListener(){ public UIObserverListener getUiObserverListener() {
return uiObserverListener; return uiObserverListener;
} }
/** /**
* @return * @return 是否响应变更事件
*/ */
@Override
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return true; return true;
} }
/** /**
* * @param listener 观察者监听事件
* @param listener 观察者监听事件 */
*/ @Override
public void registerNameListener(GlobalNameListener listener) { public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener; globalNameListener = listener;
} }
/**
*
* @return
*/
public boolean shouldResponseNameListener() {
return true;
}
/** /**
* @param args * @return 是否响应名称事件
*/ */
public static void main(String... args) { @Override
LayoutManager layoutManager = null; public boolean shouldResponseNameListener() {
JFrame jf = new JFrame("test"); return true;
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(layoutManager);
UIComboBox bb = new UIComboBox(new String[]{"", "jerry", "kunsnat", "richer"});
bb.setEditable(true);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
} }

156
designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java

@ -1,26 +1,30 @@
package com.fr.design.dscolumn; package com.fr.design.dscolumn;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.general.Inter;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* @author null
* @version 2018年2月9日13点47分
* @since 8.0
*/
public class DSColumnPane extends BasicPane { public class DSColumnPane extends BasicPane {
private TableDataSource tplEC; private TableDataSource tplEC;
@ -29,17 +33,56 @@ public class DSColumnPane extends BasicPane {
private DSColumnConditionsPane conditionPane = null; private DSColumnConditionsPane conditionPane = null;
private DSColumnAdvancedPane advancedPane = null; private DSColumnAdvancedPane advancedPane = null;
private TemplateCellElement cellElement; private TemplateCellElement cellElement;
protected Component lastSelectedComponent; private Component lastSelectedComponent;
public static final int SETTING_ALL = 2; public static final int SETTING_ALL = 2;
public static final int SETTING_DSRELATED = 1; public static final int SETTING_DSRELATED = 1;
private ChangeListener appliedWizardTabChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
try {
if (lastSelectedComponent == null) {
lastSelectedComponent = basicPane;
}
// selectTabComponent是正要切换到的那个Pane
Component selectTabComponent = tabbedPane.getSelectedComponent();
// denny: 如果切换Tab时上一个Pane是basicPane, 则刷新一下其他Pane,
// 因为选择的数据列可能改变, 导致后面过滤和使用公式用到的数据项改变
if (lastSelectedComponent == basicPane) {
basicPane.update(cellElement);
// denny_GUI: 刷新其他面板
refreshOtherTabs();
}
// 切换标签的时候就,确认是否有没有添加到列表中的条件
lastSelectedComponent = selectTabComponent;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
};
/**
* cellElement 改变时刷新一下
* 比如上边切换Tab时basicPane Update了一下可能会改变Field cellElement的值
*/
private PropertyChangeListener myPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshOtherTabs();
}
};
public DSColumnPane() { public DSColumnPane() {
this.initComponents(SETTING_ALL); this(SETTING_ALL);
} }
public DSColumnPane(int setting) { public DSColumnPane(int setting) {
this.initComponents(setting); this.initComponents(setting);
} }
protected void initComponents(int setting) { protected void initComponents(int setting) {
@ -65,18 +108,22 @@ public class DSColumnPane extends BasicPane {
this.setPreferredSize(new Dimension(610, 400)); this.setPreferredSize(new Dimension(610, 400));
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("ExpandD-Data_Column"); return Inter.getLocText("ExpandD-Data_Column");
} }
/* /**
* populate * 更新面板信息
*
* @param tds 数据源
* @param cellElement 单元格
* @throws Exception e
*/ */
public void populate(TableDataSource tds, TemplateCellElement cellElement) throws Exception { public void populate(TableDataSource tds, TemplateCellElement cellElement) throws Exception {
this.tplEC = tds; this.tplEC = tds;
if (tds == null || cellElement == null) { if (tds == null || cellElement == null) {
// _denny: 我不认为这种情况应该出现,以防万一 // _denny: 我不认为这种情况应该出现,以防万一
this.cellElement = new DefaultTemplateCellElement(); this.cellElement = new DefaultTemplateCellElement();
@ -85,15 +132,18 @@ public class DSColumnPane extends BasicPane {
// _denny: 这边需要克隆一下,因为在设置时,可能改变字段cellElement,但改变真实值是不被期望的 // _denny: 这边需要克隆一下,因为在设置时,可能改变字段cellElement,但改变真实值是不被期望的
try { try {
this.cellElement = (TemplateCellElement) cellElement.clone(); this.cellElement = (TemplateCellElement) cellElement.clone();
} catch (CloneNotSupportedException ce) { } catch (CloneNotSupportedException ignored) {
} }
//REPORT-7744 9.0里面过滤条件和高级设置可以通过其他地方设置,populate的时候需要更新所有面板的信息,防止设置丢失
this.basicPane.populate(tds, this.cellElement); this.basicPane.populate(tds, this.cellElement);
this.conditionPane.populate(tds, this.cellElement); this.conditionPane.populate(tds, this.cellElement);
this.advancedPane.populate(this.cellElement); this.advancedPane.populate(this.cellElement);
} }
/* /**
* update * update 保存
*
* @return 单元格信息
*/ */
public CellElement update() { public CellElement update() {
this.basicPane.update(cellElement); this.basicPane.update(cellElement);
@ -101,54 +151,24 @@ public class DSColumnPane extends BasicPane {
this.advancedPane.update(cellElement); this.advancedPane.update(cellElement);
return cellElement; return cellElement;
} }
public ChangeListener appliedWizardTabChangeListener = new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
try {
if (lastSelectedComponent == null) {
lastSelectedComponent = basicPane;
}
//selectTabComponent是正要切换到的那个Pane
Component selectTabComponent = tabbedPane.getSelectedComponent();
// _denny: 如果切换Tab时上一个Pane是basicPane, 则刷新一下其他Pane,
// 因为选择的数据列可能改变, 导致后面过滤和使用公式用到的数据项改变
if (lastSelectedComponent == basicPane) {
basicPane.update(cellElement);
// denny_GUI: 刷新其他面板
refrushOtherTabs();
}
// 切换标签的时候就,确认是否有没有添加到列表中的条件
lastSelectedComponent = selectTabComponent;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
} /**
}; * denny:当数据tab中的数据发生变化的时候刷新后面的tab
// cellElement 改变时,刷新一下 */
// 比如:上边切换Tab时,basicPane Update了一下,可能会改变Field cellElement的值 private void refreshOtherTabs() {
PropertyChangeListener myPropertyChangeListener = new PropertyChangeListener() { // deny:当JTabPane中加入一个Pane时,后面的Pane可能还没有初始化
public void propertyChange(PropertyChangeEvent evt) {
refrushOtherTabs();
}
};
//_denny:当数据tab中的数据发生变化的时候刷新后面的tab
public void refrushOtherTabs() {
// ——deny:当JTabPane中加入一个Pane时,后面的Pane可能还没有初始化
if (conditionPane == null || advancedPane == null) { if (conditionPane == null || advancedPane == null) {
return; return;
} }
this.conditionPane.populate(tplEC, cellElement); this.conditionPane.populate(tplEC, cellElement);
this.advancedPane.populate(cellElement); this.advancedPane.populate(cellElement);
} }
public void putElementcase(ElementCasePane t){
basicPane.putElementcase(t); public void putElementcase(ElementCasePane t) {
basicPane.putElementcase(t);
} }
public void putCellElement(TemplateCellElement tplCE) { public void putCellElement(TemplateCellElement tplCE) {
basicPane.putCellElement(tplCE); basicPane.putCellElement(tplCE);
} }
} }
Loading…
Cancel
Save