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 42... Line 42...
42
        this.add(new JLabel("Identifiant", SwingConstants.RIGHT), c);
42
        this.add(new JLabel("Identifiant", SwingConstants.RIGHT), c);
43
        c.gridx++;
43
        c.gridx++;
44
 
44
 
45
        c.weightx = 1;
45
        c.weightx = 1;
46
 
46
 
47
        textId = new JTextField();
47
        this.textId = new JTextField();
48
        this.add(textId, c);
48
        this.add(this.textId, c);
49
 
49
 
50
        //
50
        //
51
        final List<ComponentDescritor> l = extension.getCreateComponentList();
51
        final List<ComponentDescritor> l = extension.getCreateComponentList();
52
        final Vector<ComponentDescritor> v = new Vector<ComponentDescritor>(l);
52
        final Vector<ComponentDescritor> v = new Vector<ComponentDescritor>(l);
53
        Collections.sort(v, new Comparator<ComponentDescritor>() {
53
        Collections.sort(v, new Comparator<ComponentDescritor>() {
Line 61... Line 61...
61
        c.gridy++;
61
        c.gridy++;
62
        c.weightx = 0;
62
        c.weightx = 0;
63
        c.fill = GridBagConstraints.HORIZONTAL;
63
        c.fill = GridBagConstraints.HORIZONTAL;
64
        this.add(new JLabel("Composant", SwingConstants.RIGHT), c);
64
        this.add(new JLabel("Composant", SwingConstants.RIGHT), c);
65
        c.gridx++;
65
        c.gridx++;
66
        comboComponent = new JComboBox(v);
66
        this.comboComponent = new JComboBox(v);
67
        comboComponent.setRenderer(new DefaultListCellRenderer() {
67
        this.comboComponent.setRenderer(new DefaultListCellRenderer() {
68
            @Override
68
            @Override
69
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
69
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
-
 
70
                if (value != null) {
70
                value = ((ComponentDescritor) value).getId();
71
                    value = ((ComponentDescritor) value).getId();
-
 
72
                }
71
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
73
                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
72
            }
74
            }
73
        });
75
        });
74
        c.fill = GridBagConstraints.NONE;
76
        c.fill = GridBagConstraints.NONE;
75
        this.add(comboComponent, c);
77
        this.add(this.comboComponent, c);
76
 
78
 
77
        c.gridx = 0;
79
        c.gridx = 0;
78
        c.gridy++;
80
        c.gridy++;
79
        c.weightx = 0;
81
        c.weightx = 0;
80
        c.fill = GridBagConstraints.HORIZONTAL;
82
        c.fill = GridBagConstraints.HORIZONTAL;
81
        this.add(new JLabel("Table", SwingConstants.RIGHT), c);
83
        this.add(new JLabel("Table", SwingConstants.RIGHT), c);
82
        c.gridx++;
84
        c.gridx++;
83
        c.fill = GridBagConstraints.NONE;
85
        c.fill = GridBagConstraints.NONE;
84
        textTable = new JTextField(30);
86
        this.textTable = new JTextField(30);
85
        textTable.setEnabled(false);
87
        this.textTable.setEnabled(false);
86
        this.add(textTable, c);
88
        this.add(this.textTable, c);
87
        // Location
89
        // Location
88
        c.gridx = 0;
90
        c.gridx = 0;
89
        c.gridy++;
91
        c.gridy++;
90
        c.weightx = 0;
92
        c.weightx = 0;
91
        c.fill = GridBagConstraints.HORIZONTAL;
93
        c.fill = GridBagConstraints.HORIZONTAL;
92
        this.add(new JLabel("Emplacement", SwingConstants.RIGHT), c);
94
        this.add(new JLabel("Emplacement", SwingConstants.RIGHT), c);
93
        c.gridx++;
95
        c.gridx++;
94
        c.fill = GridBagConstraints.NONE;
96
        c.fill = GridBagConstraints.NONE;
95
        comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
97
        this.comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
96
        this.add(comboLocation, c);
98
        this.add(this.comboLocation, c);
97
        c.gridy++;
99
        c.gridy++;
98
        c.weighty = 1;
100
        c.weighty = 1;
99
        this.add(new JPanel(), c);
101
        this.add(new JPanel(), c);
100
 
102
 
101
        initUIFrom(actionDescriptor);
103
        initUIFrom(actionDescriptor);
102
 
104
 
103
        comboComponent.addActionListener(new ActionListener() {
105
        this.comboComponent.addActionListener(new ActionListener() {
104
 
106
 
105
            @Override
107
            @Override
106
            public void actionPerformed(ActionEvent e) {
108
            public void actionPerformed(ActionEvent e) {
107
                final ComponentDescritor componentDescritor = getComponentDescritor(comboComponent.getSelectedItem().toString());
109
                final ComponentDescritor componentDescritor = getComponentDescritor(ActionItemEditor.this.comboComponent.getSelectedItem().toString());
108
                if (componentDescritor != null) {
110
                if (componentDescritor != null) {
109
                    textTable.setText(componentDescritor.getTable());
111
                    ActionItemEditor.this.textTable.setText(componentDescritor.getTable());
110
                    actionDescriptor.setComponentId(componentDescritor.getId());
112
                    actionDescriptor.setComponentId(componentDescritor.getId());
111
                    actionDescriptor.setTable(componentDescritor.getTable());
113
                    actionDescriptor.setTable(componentDescritor.getTable());
112
                } else {
114
                } else {
113
                    textTable.setText("");
115
                    ActionItemEditor.this.textTable.setText("");
114
                }
116
                }
115
            }
117
            }
116
        });
118
        });
117
        comboLocation.addActionListener(new ActionListener() {
119
        this.comboLocation.addActionListener(new ActionListener() {
118
 
120
 
119
            @Override
121
            @Override
120
            public void actionPerformed(ActionEvent e) {
122
            public void actionPerformed(ActionEvent e) {
121
                int index = comboLocation.getSelectedIndex();
123
                int index = ActionItemEditor.this.comboLocation.getSelectedIndex();
122
                if (index == 0) {
124
                if (index == 0) {
123
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER_POPUP);
125
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER_POPUP);
124
                } else if (index == 1) {
126
                } else if (index == 1) {
125
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_POPUP);
127
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_POPUP);
126
                } else {
128
                } else {
127
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER);
129
                    actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER);
128
                }
130
                }
129
 
131
 
130
            }
132
            }
131
        });
133
        });
132
        textId.getDocument().addDocumentListener(new DocumentListener() {
134
        this.textId.getDocument().addDocumentListener(new DocumentListener() {
133
 
135
 
134
            @Override
136
            @Override
135
            public void removeUpdate(DocumentEvent e) {
137
            public void removeUpdate(DocumentEvent e) {
136
                changedUpdate(e);
138
                changedUpdate(e);
137
 
139
 
Line 143... Line 145...
143
 
145
 
144
            }
146
            }
145
 
147
 
146
            @Override
148
            @Override
147
            public void changedUpdate(DocumentEvent e) {
149
            public void changedUpdate(DocumentEvent e) {
148
                actionDescriptor.setId(textId.getText());
150
                actionDescriptor.setId(ActionItemEditor.this.textId.getText());
149
            }
151
            }
150
        });
152
        });
151
 
153
 
152
    }
154
    }
153
 
155
 
154
    private void initUIFrom(ActionDescriptor item) {
156
    private void initUIFrom(ActionDescriptor item) {
155
 
157
 
156
        textId.setText(item.getId());
158
        this.textId.setText(item.getId());
157
        final ComponentDescritor componentDescritor = getComponentDescritor(item.getComponentId());
159
        final ComponentDescritor componentDescritor = getComponentDescritor(item.getComponentId());
158
        if (componentDescritor != null) {
160
        if (componentDescritor != null) {
159
            comboComponent.setSelectedItem(componentDescritor);
161
            this.comboComponent.setSelectedItem(componentDescritor);
160
        }
162
        }
161
        textTable.setText(item.getTable());
163
        this.textTable.setText(item.getTable());
162
        String loc = item.getLocation();
164
        String loc = item.getLocation();
163
        if (loc.equals(ActionDescriptor.LOCATION_HEADER_POPUP)) {
165
        if (loc.equals(ActionDescriptor.LOCATION_HEADER_POPUP)) {
164
            comboLocation.setSelectedIndex(0);
166
            this.comboLocation.setSelectedIndex(0);
165
        } else if (loc.equals(ActionDescriptor.LOCATION_HEADER)) {
167
        } else if (loc.equals(ActionDescriptor.LOCATION_HEADER)) {
166
            comboLocation.setSelectedIndex(2);
168
            this.comboLocation.setSelectedIndex(2);
167
        } else {
169
        } else {
168
            comboLocation.setSelectedIndex(1);
170
            this.comboLocation.setSelectedIndex(1);
169
        }
171
        }
170
    }
172
    }
171
 
173
 
172
    private ComponentDescritor getComponentDescritor(String componentId) {
174
    private ComponentDescritor getComponentDescritor(String componentId) {
173
        List<ComponentDescritor> l = extension.getCreateComponentList();
175
        List<ComponentDescritor> l = this.extension.getCreateComponentList();
174
        for (ComponentDescritor componentDescritor : l) {
176
        for (ComponentDescritor componentDescritor : l) {
175
            if (componentDescritor.getId().equals(componentId)) {
177
            if (componentDescritor.getId().equals(componentId)) {
176
                return componentDescritor;
178
                return componentDescritor;
177
            }
179
            }
178
        }
180
        }