|
|
@ -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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|