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