OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
74 ilm 1
package org.openconcerto.modules.extensionbuilder.table;
2
 
3
import java.awt.Window;
4
 
5
import javax.swing.JOptionPane;
6
import javax.swing.JPanel;
7
import javax.swing.JScrollPane;
8
import javax.swing.SwingUtilities;
9
 
10
import org.openconcerto.modules.extensionbuilder.Extension;
11
import org.openconcerto.modules.extensionbuilder.list.EditableListPanel;
12
 
13
public class TableListPanel extends EditableListPanel {
14
 
15
    private final Extension extension;
16
    private final TableCreateMainPanel tableInfoPanel;
17
 
18
    public TableListPanel(final Extension extension, final TableCreateMainPanel tableInfoPanel) {
19
        super(new CreateTableListModel(extension), "Tables", "Ajouter une table");
20
        this.extension = extension;
21
        this.tableInfoPanel = tableInfoPanel;
22
    }
23
 
24
    @Override
25
    public void addNewItem() {
181 ilm 26
        ((CreateTableListModel) this.dataModel).addNewTable();
74 ilm 27
    }
28
 
29
    @Override
30
    public void renameItem(Object item) {
31
        final TableDescritor e = (TableDescritor) item;
32
        final Window w = SwingUtilities.windowForComponent(this);
181 ilm 33
        final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la table", JOptionPane.PLAIN_MESSAGE, null, null, e.getName());
74 ilm 34
        if ((s != null) && (s.length() > 0)) {
35
            e.setName(s);
36
        }
37
    }
38
 
39
    @Override
40
    public void removeItem(Object item) {
181 ilm 41
        ((CreateTableListModel) this.dataModel).removeElement(item);
42
        this.extension.removeCreateTable((TableDescritor) item);
74 ilm 43
    }
44
 
45
    @Override
46
    public void itemSelected(Object item) {
47
        if (item != null) {
48
            TableDescritor n = (TableDescritor) item;
49
            System.out.println("TableListPanel..valueChanged():" + n);
181 ilm 50
            final TableCreatePanel p = new TableCreatePanel(n, this.extension);
51
            this.tableInfoPanel.setRightPanel(new JScrollPane(p));
74 ilm 52
        } else {
181 ilm 53
            this.tableInfoPanel.setRightPanel(new JPanel());
74 ilm 54
        }
55
    }
56
}