OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
74 ilm 1
package org.openconcerto.modules.extensionbuilder.meu.actions;
2
 
3
import java.awt.Component;
4
import java.awt.Window;
5
 
6
import javax.swing.DefaultListCellRenderer;
7
import javax.swing.JList;
8
import javax.swing.JOptionPane;
9
import javax.swing.JPanel;
10
import javax.swing.JScrollPane;
11
import javax.swing.SwingUtilities;
12
 
13
import org.openconcerto.modules.extensionbuilder.Extension;
14
import org.openconcerto.modules.extensionbuilder.list.EditableListPanel;
15
 
16
public class ActionListPanel extends EditableListPanel {
17
 
18
    private ActionMainPanel tableTranslationPanel;
19
    private Extension extension;
20
 
21
    public ActionListPanel(Extension extension, ActionMainPanel tableTranslationPanel) {
22
        super(new AllKnownActionsListModel(extension), "Actions", "", true, true);
23
        this.extension = extension;
24
        this.tableTranslationPanel = tableTranslationPanel;
25
        list.setCellRenderer(new DefaultListCellRenderer() {
26
            @Override
27
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
28
                value = ((ActionDescriptor) value).getId();
29
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
30
            }
31
        });
32
    }
33
 
34
    @Override
35
    public void addNewItem() {
36
    }
37
 
38
    @Override
39
    public void renameItem(Object item) {
40
        final ActionDescriptor e = (ActionDescriptor) item;
41
        final Window w = SwingUtilities.windowForComponent(this);
42
        final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la liste", JOptionPane.PLAIN_MESSAGE, null, null, e.getId());
43
        if ((s != null) && (s.length() > 0)) {
44
            e.setId(s);
45
        }
46
    }
47
 
48
    @Override
49
    public void removeItem(Object item) {
50
    }
51
 
52
    @Override
53
    public void itemSelected(Object item) {
54
        if (item != null) {
55
            tableTranslationPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, extension)));
56
        } else {
57
            tableTranslationPanel.setRightPanel(new JPanel());
58
        }
59
    }
60
 
61
}