74 |
ilm |
1 |
package org.openconcerto.modules.extensionbuilder.list;
|
|
|
2 |
|
|
|
3 |
import java.awt.GridBagConstraints;
|
|
|
4 |
import java.awt.GridBagLayout;
|
|
|
5 |
import java.awt.event.ActionEvent;
|
|
|
6 |
import java.awt.event.ActionListener;
|
|
|
7 |
|
|
|
8 |
import javax.swing.JComboBox;
|
|
|
9 |
import javax.swing.JLabel;
|
|
|
10 |
import javax.swing.JPanel;
|
|
|
11 |
import javax.swing.SwingConstants;
|
|
|
12 |
|
|
|
13 |
import org.openconcerto.modules.extensionbuilder.Extension;
|
|
|
14 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
15 |
import org.openconcerto.ui.JLabelBold;
|
|
|
16 |
|
|
|
17 |
public class ListCreatePanel extends JPanel {
|
|
|
18 |
|
|
|
19 |
private FieldDescSelector panel;
|
|
|
20 |
|
|
|
21 |
public ListCreatePanel(ListDescriptor n, Extension extension) {
|
|
|
22 |
this.setLayout(new GridBagLayout());
|
|
|
23 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
24 |
c.gridwidth = 2;
|
|
|
25 |
|
|
|
26 |
this.add(new JLabelBold(n.getId()), c);
|
|
|
27 |
c.gridy++;
|
|
|
28 |
c.gridwidth = 1;
|
|
|
29 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
30 |
this.add(new JLabel("Table principale", SwingConstants.RIGHT), c);
|
|
|
31 |
c.gridx++;
|
|
|
32 |
c.fill = GridBagConstraints.NONE;
|
|
|
33 |
final JComboBox comboTable = new JComboBox(new AllTablesComboBoxModel(extension));
|
|
|
34 |
this.add(comboTable, c);
|
|
|
35 |
c.gridx = 0;
|
|
|
36 |
c.gridy++;
|
|
|
37 |
c.weightx = 1;
|
|
|
38 |
c.weighty = 1;
|
|
|
39 |
c.gridwidth = 2;
|
|
|
40 |
c.fill = GridBagConstraints.BOTH;
|
|
|
41 |
panel = new FieldDescSelector(n, extension);
|
|
|
42 |
final String mainTable = n.getMainTable();
|
|
|
43 |
if (mainTable == null && comboTable.getModel().getSize() > 0) {
|
|
|
44 |
comboTable.setSelectedIndex(0);
|
|
|
45 |
panel.setMainTable((String) comboTable.getModel().getElementAt(0));
|
|
|
46 |
} else {
|
|
|
47 |
comboTable.setSelectedItem(mainTable);
|
|
|
48 |
panel.setMainTable(mainTable);
|
|
|
49 |
}
|
|
|
50 |
this.add(panel, c);
|
|
|
51 |
|
|
|
52 |
comboTable.addActionListener(new ActionListener() {
|
|
|
53 |
|
|
|
54 |
@Override
|
|
|
55 |
public void actionPerformed(ActionEvent e) {
|
|
|
56 |
panel.setMainTable((String) comboTable.getSelectedItem());
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
});
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
}
|