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.list;
2
 
3
import java.awt.Window;
4
 
5
import javax.swing.JOptionPane;
6
import javax.swing.JPanel;
7
import javax.swing.SwingUtilities;
8
 
9
import org.openconcerto.modules.extensionbuilder.Extension;
10
 
11
public class ListListPanel extends EditableListPanel {
12
 
13
    private final Extension extension;
14
    private final ListCreateMainPanel tableInfoPanel;
15
 
16
    public ListListPanel(final Extension extension, final ListCreateMainPanel tableInfoPanel) {
17
        super(new CreateListListModel(extension), "Listes", "Ajouter une liste");
18
        this.extension = extension;
19
        this.tableInfoPanel = tableInfoPanel;
20
    }
21
 
22
    @Override
23
    public void addNewItem() {
181 ilm 24
        ((CreateListListModel) this.dataModel).addNewList();
74 ilm 25
    }
26
 
27
    @Override
28
    public void renameItem(Object item) {
29
        final ListDescriptor e = (ListDescriptor) item;
30
        final Window w = SwingUtilities.windowForComponent(this);
31
        final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la liste", JOptionPane.PLAIN_MESSAGE, null, null, e.getId());
32
        if ((s != null) && (s.length() > 0)) {
33
            e.setId(s);
34
        }
35
    }
36
 
37
    @Override
38
    public void removeItem(Object item) {
181 ilm 39
        ((CreateListListModel) this.dataModel).removeElement(item);
40
        this.extension.removeCreateList((ListDescriptor) item);
74 ilm 41
    }
42
 
43
    @Override
44
    public void itemSelected(Object item) {
45
        if (item != null) {
46
            ListDescriptor n = (ListDescriptor) item;
181 ilm 47
            final ListCreatePanel p = new ListCreatePanel(n, this.extension);
48
            this.tableInfoPanel.setRightPanel(p);
74 ilm 49
        } else {
181 ilm 50
            this.tableInfoPanel.setRightPanel(new JPanel());
74 ilm 51
        }
52
    }
53
}