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 45... Line 45...
45
            c.weightx = 0;
45
            c.weightx = 0;
46
            this.add(new JLabel("Identifiant", SwingConstants.RIGHT), c);
46
            this.add(new JLabel("Identifiant", SwingConstants.RIGHT), c);
47
            c.gridx++;
47
            c.gridx++;
48
            c.weightx = 1;
48
            c.weightx = 1;
49
            c.fill = GridBagConstraints.HORIZONTAL;
49
            c.fill = GridBagConstraints.HORIZONTAL;
50
            textId = new JTextField(30);
50
            this.textId = new JTextField(30);
51
            this.add(textId, c);
51
            this.add(this.textId, c);
52
            c.gridy++;
52
            c.gridy++;
53
        } else {
53
        } else {
54
            // Label du champs
54
            // Label du champs
55
            c.gridwidth = 2;
55
            c.gridwidth = 2;
56
            String label = item.getId();
56
            String label = item.getId();
Line 75... Line 75...
75
            c.fill = GridBagConstraints.HORIZONTAL;
75
            c.fill = GridBagConstraints.HORIZONTAL;
76
            this.add(new JLabel("Type", SwingConstants.RIGHT), c);
76
            this.add(new JLabel("Type", SwingConstants.RIGHT), c);
77
            c.gridx++;
77
            c.gridx++;
78
            c.fill = GridBagConstraints.NONE;
78
            c.fill = GridBagConstraints.NONE;
79
            c.weightx = 1;
79
            c.weightx = 1;
80
            comboType = new JComboBox(new String[] { "normal", "large", "très large" });
80
            this.comboType = new JComboBox(new String[] { "normal", "large", "très large" });
81
            this.add(comboType, c);
81
            this.add(this.comboType, c);
82
            c.gridy++;
82
            c.gridy++;
83
        }
83
        }
84
        c.gridx = 0;
84
        c.gridx = 0;
85
 
85
 
86
        c.fill = GridBagConstraints.HORIZONTAL;
86
        c.fill = GridBagConstraints.HORIZONTAL;
Line 90... Line 90...
90
            labelSep.setText("Dissocier");
90
            labelSep.setText("Dissocier");
91
        }
91
        }
92
        this.add(labelSep, c);
92
        this.add(labelSep, c);
93
        c.gridx++;
93
        c.gridx++;
94
        c.fill = GridBagConstraints.NONE;
94
        c.fill = GridBagConstraints.NONE;
95
        checkSeparated = new JCheckBox();
95
        this.checkSeparated = new JCheckBox();
96
        c.weightx = 1;
96
        c.weightx = 1;
97
        this.add(checkSeparated, c);
97
        this.add(this.checkSeparated, c);
98
        c.gridx = 0;
98
        c.gridx = 0;
99
        c.gridy++;
99
        c.gridy++;
100
        if (!this.isEditingGroup) {
100
        if (!this.isEditingGroup) {
101
            c.fill = GridBagConstraints.HORIZONTAL;
101
            c.fill = GridBagConstraints.HORIZONTAL;
102
            c.weightx = 0;
102
            c.weightx = 0;
103
            this.add(new JLabel("Afficher le label", SwingConstants.RIGHT), c);
103
            this.add(new JLabel("Afficher le label", SwingConstants.RIGHT), c);
104
            c.gridx++;
104
            c.gridx++;
105
            c.weightx = 1;
105
            c.weightx = 1;
106
            c.fill = GridBagConstraints.NONE;
106
            c.fill = GridBagConstraints.NONE;
107
            checkLabel = new JCheckBox();
107
            this.checkLabel = new JCheckBox();
108
 
108
 
109
            this.add(checkLabel, c);
109
            this.add(this.checkLabel, c);
110
 
110
 
111
            c.gridy++;
111
            c.gridy++;
112
 
112
 
113
            c.gridx = 0;
113
            c.gridx = 0;
114
            c.weightx = 0;
114
            c.weightx = 0;
115
            c.fill = GridBagConstraints.HORIZONTAL;
115
            c.fill = GridBagConstraints.HORIZONTAL;
116
            this.add(new JLabel("Maximiser la taille", SwingConstants.RIGHT), c);
116
            this.add(new JLabel("Maximiser la taille", SwingConstants.RIGHT), c);
117
            c.gridx++;
117
            c.gridx++;
118
            c.fill = GridBagConstraints.NONE;
118
            c.fill = GridBagConstraints.NONE;
119
            c.weightx = 1;
119
            c.weightx = 1;
120
            checkFillH = new JCheckBox();
120
            this.checkFillH = new JCheckBox();
121
            this.add(checkFillH, c);
121
            this.add(this.checkFillH, c);
122
            c.gridy++;
122
            c.gridy++;
123
        }
123
        }
124
 
124
 
125
        JPanel spacer = new JPanel();
125
        JPanel spacer = new JPanel();
126
        c.weighty = 1;
126
        c.weighty = 1;
127
 
127
 
128
        this.add(spacer, c);
128
        this.add(spacer, c);
129
        initUIFrom(item);
129
        initUIFrom(item);
130
 
130
 
131
        // Listeners
131
        // Listeners
132
        if (isEditingGroup) {
132
        if (this.isEditingGroup) {
133
            textId.getDocument().addDocumentListener(new DocumentListener() {
133
            this.textId.getDocument().addDocumentListener(new DocumentListener() {
134
 
134
 
135
                @Override
135
                @Override
136
                public void removeUpdate(DocumentEvent e) {
136
                public void removeUpdate(DocumentEvent e) {
137
                    changedUpdate(e);
137
                    changedUpdate(e);
138
 
138
 
Line 144... Line 144...
144
 
144
 
145
                }
145
                }
146
 
146
 
147
                @Override
147
                @Override
148
                public void changedUpdate(DocumentEvent e) {
148
                public void changedUpdate(DocumentEvent e) {
149
                    item.setId(textId.getText());
149
                    item.setId(ItemEditor.this.textId.getText());
150
                    component.fireGroupChanged();
150
                    component.fireGroupChanged();
151
 
151
 
152
                }
152
                }
153
            });
153
            });
154
        }
154
        }
155
        checkSeparated.addActionListener(new ActionListener() {
155
        this.checkSeparated.addActionListener(new ActionListener() {
156
 
156
 
157
            @Override
157
            @Override
158
            public void actionPerformed(ActionEvent e) {
158
            public void actionPerformed(ActionEvent e) {
159
                item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(checkSeparated.isSelected()).build());
159
                item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(ItemEditor.this.checkSeparated.isSelected()).build());
160
                component.fireGroupChanged();
160
                component.fireGroupChanged();
161
            }
161
            }
162
        });
162
        });
163
 
163
 
164
        if (!isEditingGroup) {
164
        if (!this.isEditingGroup) {
165
            checkLabel.addActionListener(new ActionListener() {
165
            this.checkLabel.addActionListener(new ActionListener() {
166
 
166
 
167
                @Override
167
                @Override
168
                public void actionPerformed(ActionEvent e) {
168
                public void actionPerformed(ActionEvent e) {
169
                    item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(checkLabel.isSelected()).build());
169
                    item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(ItemEditor.this.checkLabel.isSelected()).build());
170
                    component.fireGroupChanged();
170
                    component.fireGroupChanged();
171
                }
171
                }
172
            });
172
            });
173
            checkFillH.addActionListener(new ActionListener() {
173
            this.checkFillH.addActionListener(new ActionListener() {
174
 
174
 
175
                @Override
175
                @Override
176
                public void actionPerformed(ActionEvent e) {
176
                public void actionPerformed(ActionEvent e) {
177
                    item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(checkFillH.isSelected()).build());
177
                    item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(ItemEditor.this.checkFillH.isSelected()).build());
178
                    component.fireGroupChanged();
178
                    component.fireGroupChanged();
179
                }
179
                }
180
            });
180
            });
181
 
181
 
182
            comboType.addActionListener(new ActionListener() {
182
            this.comboType.addActionListener(new ActionListener() {
183
 
183
 
184
                @Override
184
                @Override
185
                public void actionPerformed(ActionEvent e) {
185
                public void actionPerformed(ActionEvent e) {
186
                    int i = comboType.getSelectedIndex();
186
                    int i = ItemEditor.this.comboType.getSelectedIndex();
187
                    final LayoutHintsBuilder h = item.getLocalHint().getBuilder();
187
                    final LayoutHintsBuilder h = item.getLocalHint().getBuilder();
188
                    if (i == 0) {
188
                    if (i == 0) {
189
                        h.setFillWidth(false);
189
                        h.setFillWidth(false);
190
                        h.setLargeWidth(false);
190
                        h.setLargeWidth(false);
191
                    } else if (i == 1) {
191
                    } else if (i == 1) {
Line 206... Line 206...
206
 
206
 
207
    private void initUIFrom(Item item) {
207
    private void initUIFrom(Item item) {
208
 
208
 
209
        final LayoutHints localHint = item.getLocalHint();
209
        final LayoutHints localHint = item.getLocalHint();
210
 
210
 
211
        checkSeparated.setSelected(localHint.isSeparated());
211
        this.checkSeparated.setSelected(localHint.isSeparated());
212
 
212
 
213
        if (!isEditingGroup) {
213
        if (!this.isEditingGroup) {
214
            if (localHint.fillWidth() && localHint.largeWidth()) {
214
            if (localHint.fillWidth() && localHint.largeWidth()) {
215
                comboType.setSelectedIndex(2);
215
                this.comboType.setSelectedIndex(2);
216
            } else if (localHint.fillWidth()) {
216
            } else if (localHint.fillWidth()) {
217
                comboType.setSelectedIndex(1);
217
                this.comboType.setSelectedIndex(1);
218
            } else {
218
            } else {
219
                comboType.setSelectedIndex(0);
219
                this.comboType.setSelectedIndex(0);
220
            }
220
            }
221
            checkFillH.setSelected(localHint.fillHeight());
221
            this.checkFillH.setSelected(localHint.fillHeight());
222
            checkLabel.setSelected(localHint.showLabel());
222
            this.checkLabel.setSelected(localHint.showLabel());
223
        } else {
223
        } else {
224
            textId.setText(item.getId());
224
            this.textId.setText(item.getId());
225
 
225
 
226
        }
226
        }
227
    }
227
    }
228
}
228
}