OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 74 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74 Rev 181
Line 13... Line 13...
13
import org.openconcerto.modules.extensionbuilder.Extension;
13
import org.openconcerto.modules.extensionbuilder.Extension;
14
import org.openconcerto.modules.extensionbuilder.list.EditableListPanel;
14
import org.openconcerto.modules.extensionbuilder.list.EditableListPanel;
15
 
15
 
16
public class ActionListPanel extends EditableListPanel {
16
public class ActionListPanel extends EditableListPanel {
17
 
17
 
18
    private ActionMainPanel tableTranslationPanel;
18
    private ActionMainPanel actionPanel;
19
    private Extension extension;
19
    private Extension extension;
20
 
20
 
21
    public ActionListPanel(Extension extension, ActionMainPanel tableTranslationPanel) {
21
    public ActionListPanel(Extension extension, ActionMainPanel actionPanel) {
22
        super(new AllKnownActionsListModel(extension), "Actions", "", true, true);
22
        super(new AllKnownActionsListModel(extension), "Actions", "Ajouter une action", true, true);
23
        this.extension = extension;
23
        this.extension = extension;
24
        this.tableTranslationPanel = tableTranslationPanel;
24
        this.actionPanel = actionPanel;
25
        list.setCellRenderer(new DefaultListCellRenderer() {
25
        this.list.setCellRenderer(new DefaultListCellRenderer() {
26
            @Override
26
            @Override
27
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
27
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
28
                value = ((ActionDescriptor) value).getId();
28
                value = ((ActionDescriptor) value).getId();
29
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
29
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
30
            }
30
            }
31
        });
31
        });
32
    }
32
    }
33
 
33
 
34
    @Override
34
    @Override
35
    public void addNewItem() {
35
    public void addNewItem() {
-
 
36
        ((AllKnownActionsListModel) this.dataModel).addAction();
-
 
37
    }
-
 
38
 
-
 
39
    @Override
-
 
40
    public void removeItem(Object item) {
-
 
41
        ((AllKnownActionsListModel) this.dataModel).removeElement(item);
-
 
42
        this.extension.removeCreateAction((ActionDescriptor) item);
36
    }
43
    }
37
 
44
 
38
    @Override
45
    @Override
39
    public void renameItem(Object item) {
46
    public void renameItem(Object item) {
40
        final ActionDescriptor e = (ActionDescriptor) item;
47
        final ActionDescriptor e = (ActionDescriptor) item;
41
        final Window w = SwingUtilities.windowForComponent(this);
48
        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());
49
        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)) {
50
        if ((s != null) && (s.length() > 0)) {
44
            e.setId(s);
51
            e.setId(s);
-
 
52
            reload();
45
        }
53
        }
46
    }
54
    }
47
 
55
 
48
    @Override
56
    @Override
49
    public void removeItem(Object item) {
-
 
50
    }
-
 
51
 
-
 
52
    @Override
-
 
53
    public void itemSelected(Object item) {
57
    public void itemSelected(Object item) {
54
        if (item != null) {
58
        if (item != null) {
55
            tableTranslationPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, extension)));
59
            this.actionPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, this.extension)));
56
        } else {
60
        } else {
57
            tableTranslationPanel.setRightPanel(new JPanel());
61
            this.actionPanel.setRightPanel(new JPanel());
58
        }
62
        }
59
    }
63
    }
60
 
64
 
61
}
65
}
62
66