OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 86 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
86 ilm 21
    public ListCreatePanel(final ListDescriptor n, final Extension extension) {
74 ilm 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;
181 ilm 41
        this.panel = new FieldDescSelector(n, extension);
74 ilm 42
        final String mainTable = n.getMainTable();
43
        if (mainTable == null && comboTable.getModel().getSize() > 0) {
44
            comboTable.setSelectedIndex(0);
181 ilm 45
            this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
74 ilm 46
        } else {
47
            comboTable.setSelectedItem(mainTable);
181 ilm 48
            this.panel.setMainTable(mainTable);
74 ilm 49
        }
181 ilm 50
        this.add(this.panel, c);
74 ilm 51
 
52
        comboTable.addActionListener(new ActionListener() {
53
 
54
            @Override
55
            public void actionPerformed(ActionEvent e) {
86 ilm 56
                n.removeAllColumns();
181 ilm 57
                ListCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
86 ilm 58
                extension.setChanged();
74 ilm 59
            }
60
        });
61
 
62
    }
63
 
64
}