Browse Source

Pull request #3087: REPORT-44961 【10.0.12冒烟】附件模板打开设计器卡死,且布局发生变化

Merge in DESIGN/design from ~YVAN/design:REPORT-44961 to release/10.0

* commit 'bc9a93d903fa1fc49f141dfbdd0ef06c2d25bed8':
  REPORT-44961 把TableDataDictPane中的needTableDataChange默认设置为true,在CheckBoxGroupDefinePane中创建DictionaryPane的时候传入一个false,这样就不会影响其它使用了DictionaryPane的地方了
  REPORT-44961 为单元格属性-形态-数据字典中的DictionaryPane也设置needChangeTableData变量为true
  REPORT-44961 修改一些变量名,删去无用导包
  REPORT-44961 这个问题里先不处理二级弹窗
  REPORT-44961 【10.0.12冒烟】附件模板打开设计器卡死,且布局发生变化 【问题原因】带有数据字典的表单控件,在选中的时候会去连接获取字段信息,当系统中有同名数据连接但是无法连接到数据库的时候,会发生假死。如果没有这个数据连接的名字,那么会直接报错不会假死。主要还是这个数据字典获取数据的操作是耗时操作,不应该在UI线程进行耗时操作。 【改动思路】主要分为两部分,第一是将原本的tdChange()方法中的耗时操作放到SwingWorker中的工作线程中,这样的话即使后台数据连接失败,设计器也不会一直阻塞直到重连超时;第二是应产品的要求,将选中控件就会去请求连接并获取属于当前控件的列名这部分逻辑,修改为用户点击右侧面板中的数据字典旁边的button的时候才会去请求连接,并更换当前数据字典中的列名
  REPORT-44961 【10.0.12冒烟】附件模板打开设计器卡死,且布局发生变化 【问题原因】带有数据字典的设计器控件,在选中的时候会去连接获取字段信息,当系统中有同名数据连接但是无法连接到数据库的时候,会发生假死。如果没有这个数据连接的名字,那么会直接报错不会假死。主要还是这个数据字典获取数据的操作是耗时操作,不应该在UI线程进行耗时操作。 【改动方案】主要分为两部分,第一是将原本的tdChange()方法中的耗时操作放到SwingWorker中的工作线程中,这样的话即使后台数据连接失败,设计器也不会一直阻塞直到重连超时;第二是应产品的要求,将选中控件就会去请求连接并获取属于当前控件的列名这部分逻辑,修改为用户点击右侧面板中的数据字典旁边的button,showDictPane的时候才会去请求连接
feature/big-screen
ju|剧浩宇 4 years ago
parent
commit
73d81b94ce
  1. 38
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java
  3. 6
      designer-base/src/main/java/com/fr/design/present/DictPresentPane.java
  4. 7
      designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java
  5. 108
      designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java
  6. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java

38
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java

@ -35,18 +35,18 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 获取数据集的所有列名list * 获取数据集的所有列名list
* *
* @return 数据集的所有列名list * @return 数据集的所有列名list
* *
* *
* @date 2014-11-24-下午3:51:41 * @date 2014-11-24-下午3:51:41
* *
*/ */
public List<String> calculateColumnNameList() { public List<String> calculateColumnNameList() {
if(columnNameList != null){ if(columnNameList != null){
return columnNameList; return columnNameList;
} }
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataSource tds = adapter == null ? null : adapter.getBook(); TableDataSource tds = adapter == null ? null : adapter.getBook();
String[] colNames = tabledata.getColumnNames(tds); String[] colNames = tabledata.getColumnNames(tds);
@ -56,13 +56,13 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
} else if (ArrayUtils.isNotEmpty(colNamesInCache)) { } else if (ArrayUtils.isNotEmpty(colNamesInCache)) {
return toColumnNameList(colNamesInCache); return toColumnNameList(colNamesInCache);
} }
EmbeddedTableData embeddedTableData = null; EmbeddedTableData embeddedTableData = null;
try { try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false); embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false);
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage()!=null) { if (e.getMessage()!=null) {
DesignUtils.errorMessage(e.getMessage()); DesignUtils.errorMessage(e.getMessage());
} }
} }
columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData);
@ -78,12 +78,12 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 生成子节点 * 生成子节点
* *
* @return 生成子节点 * @return 生成子节点
* *
* *
* @date 2014-11-24-下午3:51:17 * @date 2014-11-24-下午3:51:17
* *
*/ */
public ExpandMutableTreeNode[] load() { public ExpandMutableTreeNode[] load() {
List<String> namelist = calculateColumnNameList(); List<String> namelist = calculateColumnNameList();
@ -97,10 +97,10 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 预览数据集 * 预览数据集
* *
* *
* @date 2014-11-24-下午3:50:20 * @date 2014-11-24-下午3:50:20
* *
*/ */
public void previewData() { public void previewData() {
PreviewTablePane.previewTableData(tabledata); PreviewTablePane.previewTableData(tabledata);
@ -108,30 +108,30 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 预览数据集,带有显示值和实际值的标记结果 * 预览数据集,带有显示值和实际值的标记结果
* *
* @param keyIndex 实际值 * @param keyIndex 实际值
* @param valueIndex 显示值 * @param valueIndex 显示值
* *
* *
* @date 2014-11-24-下午3:50:20 * @date 2014-11-24-下午3:50:20
* *
*/ */
public void previewData(final int keyIndex,final int valueIndex){ public void previewData(final int keyIndex,final int valueIndex){
PreviewTablePane.previewTableData(tabledata, keyIndex, valueIndex); PreviewTablePane.previewTableData(tabledata, keyIndex, valueIndex);
} }
@Override @Override
public String getTableDataName(){ public String getTableDataName(){
return name; return name;
} }
/** /**
* 获取数据集的面板 * 获取数据集的面板
* *
* @return 数据集面板 * @return 数据集面板
* *
* *
* @date 2014-11-24-下午3:50:00 * @date 2014-11-24-下午3:50:00
* *
*/ */
public AbstractTableDataPane<?> creatTableDataPane() { public AbstractTableDataPane<?> creatTableDataPane() {
return TableDataFactory.creatTableDataPane(tabledata, name); return TableDataFactory.creatTableDataPane(tabledata, name);
@ -143,4 +143,4 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
&& ComparatorUtils.equals(this.tabledata, ((AbstractTableDataWrapper) obj).getTableData()); && ComparatorUtils.equals(this.tabledata, ((AbstractTableDataWrapper) obj).getTableData());
} }
} }

2
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleDictionaryEditor.java

@ -58,4 +58,4 @@ public class AccessibleDictionaryEditor extends UneditableAccessibleEditor {
public Dictionary updateBean() { public Dictionary updateBean() {
return (Dictionary) this.getValue(); return (Dictionary) this.getValue();
} }
} }

6
designer-base/src/main/java/com/fr/design/present/DictPresentPane.java

@ -10,7 +10,7 @@ import com.fr.design.present.dict.DictionaryPane;
/** /**
* *
* @author zhou * @author zhou
* @since 2012-5-31上午10:54:20 * @since 2012-5-31上午10:54:20
*/ */
@ -42,7 +42,7 @@ public class DictPresentPane extends FurtherBasicBeanPane<DictPresent> implement
public boolean accept(Object ob) { public boolean accept(Object ob) {
return ob instanceof DictPresent; return ob instanceof DictPresent;
} }
public void addTabChangeListener(ItemListener l){ public void addTabChangeListener(ItemListener l){
dictionaryPane.addTabChangeListener(l); dictionaryPane.addTabChangeListener(l);
} }
@ -55,4 +55,4 @@ public class DictPresentPane extends FurtherBasicBeanPane<DictPresent> implement
public void registerDSChangeListener() { public void registerDSChangeListener() {
dictionaryPane.registerDSChangeListener(); dictionaryPane.registerDSChangeListener();
} }
} }

7
designer-base/src/main/java/com/fr/design/present/dict/DictionaryPane.java

@ -24,6 +24,13 @@ import java.util.List;
public class DictionaryPane extends UIComboBoxPane<Dictionary> implements DataCreatorUI, Prepare4DataSourceChange { public class DictionaryPane extends UIComboBoxPane<Dictionary> implements DataCreatorUI, Prepare4DataSourceChange {
private TableDataDictPane tableDataDictPane; private TableDataDictPane tableDataDictPane;
public DictionaryPane() {
}
public DictionaryPane(boolean needTableDataChange) {
this.tableDataDictPane.setNeedTableDataChange(needTableDataChange);
}
@Override @Override
protected void initLayout() { protected void initLayout() {
this.setLayout(new BorderLayout(0, 4)); this.setLayout(new BorderLayout(0, 4));

108
designer-base/src/main/java/com/fr/design/present/dict/TableDataDictPane.java

@ -31,17 +31,20 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.JFrame;
import javax.swing.event.ChangeEvent; import javax.swing.JPanel;
import javax.swing.event.ChangeListener; import javax.swing.SwingWorker;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException;
/** /**
* 数据字典的数据查询面板 * 数据字典的数据查询面板
@ -60,6 +63,8 @@ public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary>
private DoubleDeckValueEditorPane valueDictPane; private DoubleDeckValueEditorPane valueDictPane;
private ItemListener itemListener; private ItemListener itemListener;
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private FormulaEditor localFormulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula"));
private boolean needTableDataChange = true;
public TableDataDictPane() { public TableDataDictPane() {
initBasicComponets(); initBasicComponets();
@ -67,6 +72,14 @@ public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary>
iniListener(); iniListener();
} }
/**
* 设置为true后一旦触发TableDataComboBox的itemChange就会通过数据连接更换当前数据字典的列名List
* @param needTableDataChange
*/
public void setNeedTableDataChange(boolean needTableDataChange) {
this.needTableDataChange = needTableDataChange;
}
public static void main(String[] args) { public static void main(String[] args) {
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -80,11 +93,9 @@ public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary>
private void initBasicComponets() { private void initBasicComponets() {
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableDataNameComboBox.addItemListener(new ItemListener() { tableDataNameComboBox.addItemListener(e -> {
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) {
if (e.getStateChange() == ItemEvent.SELECTED) { tdChange(e);
tdChange(e);
}
} }
}); });
// keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); // keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
@ -158,39 +169,58 @@ public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary>
if (tableDataWrappe == null) { if (tableDataWrappe == null) {
return; return;
} }
if (itemListener != null) {
List<String> namelist = tableDataWrappe.calculateColumnNameList(); itemListener.itemStateChanged(e);
String[] columnNames = null; localFormulaEditor.addChangeListener(event -> itemListener.itemStateChanged(e));
if (!namelist.isEmpty()) { }
columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); if (isNeedTableDataChange()) {
} else { changeColumnsName();
columnNames = new String[]{""};
} }
ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); }
columnNameEditor1.addItemListener(itemListener);
ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length);
columnIndexEditor1.addItemListener(itemListener);
keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]);
FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula")); private void changeColumnsName() {
formulaEditor.setEnabled(true); TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem();
formulaEditor.addChangeListener(new ChangeListener() { SwingWorker<List<String>, Object> worker = new SwingWorker<List<String>, Object>() {
@Override
protected List<String> doInBackground() {
if (tableDataWrappe == null) {
return new ArrayList<>();
}
return tableDataWrappe.calculateColumnNameList();
}
@Override @Override
public void stateChanged(ChangeEvent ee) { protected void done() {
if (itemListener != null) { try {
itemListener.itemStateChanged(e); List<String> namelist = get();
String[] columnNames = null;
if (!namelist.isEmpty()) {
columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} else {
columnNames = new String[]{StringUtils.EMPTY};
}
// 实际值列名
ColumnNameEditor actualColumnNameEditor = new ColumnNameEditor(columnNames);
actualColumnNameEditor.addItemListener(itemListener);
// 实际值列序号
ColumnIndexEditor actualColumnIndexEditor = new ColumnIndexEditor(columnNames.length);
actualColumnIndexEditor.addItemListener(itemListener);
keyColumnPane.setEditors(new Editor[]{actualColumnNameEditor, actualColumnIndexEditor}, columnNames[0]);
localFormulaEditor.setEnabled(true);
// 显示值列名
ColumnNameEditor displayColumnNameEditor = new ColumnNameEditor(columnNames);
displayColumnNameEditor.addItemListener(itemListener);
// 显示值列序号
ColumnIndexEditor displayColumnIndexEditor = new ColumnIndexEditor(columnNames.length);
displayColumnIndexEditor.addItemListener(itemListener);
valueDictPane.setEditors(new Editor[]{displayColumnNameEditor, displayColumnIndexEditor, localFormulaEditor}, columnNames[0]);
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
}); };
ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); worker.execute();
columnNameEditor2.addItemListener(itemListener);
ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length);
columnIndexEditor2.addItemListener(itemListener);
valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]);
if (itemListener != null) {
itemListener.itemStateChanged(e);
}
} }
@Override @Override
@ -374,4 +404,8 @@ public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary>
public void registerDSChangeListener() { public void registerDSChangeListener() {
tableDataNameComboBox.registerGlobalDSChangeListener(); tableDataNameComboBox.registerGlobalDSChangeListener();
} }
public boolean isNeedTableDataChange() {
return needTableDataChange;
}
} }

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java

@ -29,9 +29,9 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane<CheckBoxGroup
protected void initComponents() { protected void initComponents() {
super.initComponents(); super.initComponents();
dictPane = new DictionaryPane(); dictPane = new DictionaryPane(false);
} }
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return "CheckBoxGroup"; return "CheckBoxGroup";

Loading…
Cancel
Save