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.component;
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
import org.openconcerto.modules.extensionbuilder.list.EditableListPanel;
11
 
12
public class ComponentListPanel extends EditableListPanel {
13
 
14
    private final Extension extension;
15
    private final ComponentCreateMainPanel tableInfoPanel;
16
 
17
    public ComponentListPanel(final Extension extension, final ComponentCreateMainPanel tableInfoPanel) {
18
        super(new CreateComponentListModel(extension), "Interfaces de saisie", "Ajouter une interface");
19
        this.extension = extension;
20
        this.tableInfoPanel = tableInfoPanel;
21
    }
22
 
23
    @Override
24
    public void addNewItem() {
181 ilm 25
        ((CreateComponentListModel) this.dataModel).addComponentList();
74 ilm 26
    }
27
 
28
    @Override
29
    public void renameItem(Object item) {
30
        final ComponentDescritor e = (ComponentDescritor) item;
31
        final Window w = SwingUtilities.windowForComponent(this);
32
        final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer l'interface de saisie", JOptionPane.PLAIN_MESSAGE, null, null, e.getId());
33
        if ((s != null) && (s.length() > 0)) {
34
            e.setId(s);
35
            e.fireGroupChanged();
36
            reload();
37
        }
38
    }
39
 
40
    @Override
41
    public void removeItem(Object item) {
181 ilm 42
        ((CreateComponentListModel) this.dataModel).removeElement(item);
43
        this.extension.removeCreateComponent((ComponentDescritor) item);
74 ilm 44
    }
45
 
46
    @Override
47
    public void itemSelected(Object item) {
48
        if (item != null) {
49
            ComponentDescritor n = (ComponentDescritor) item;
181 ilm 50
            final ComponentCreatePanel p = new ComponentCreatePanel(n, this.extension);
51
            this.tableInfoPanel.setRightPanel(p);
74 ilm 52
        } else {
181 ilm 53
            this.tableInfoPanel.setRightPanel(new JPanel());
74 ilm 54
        }
55
    }
56
}