OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 86 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 181
1
package org.openconcerto.modules.extensionbuilder;
1
package org.openconcerto.modules.extensionbuilder;
2
 
2
 
3
import java.awt.Color;
3
import java.awt.Color;
4
import java.awt.Dimension;
4
import java.awt.Dimension;
5
import java.awt.FileDialog;
5
import java.awt.FileDialog;
6
import java.awt.FlowLayout;
6
import java.awt.FlowLayout;
7
import java.awt.GridBagConstraints;
7
import java.awt.GridBagConstraints;
8
import java.awt.GridBagLayout;
8
import java.awt.GridBagLayout;
9
import java.awt.Insets;
9
import java.awt.Insets;
10
import java.awt.event.ActionEvent;
10
import java.awt.event.ActionEvent;
11
import java.awt.event.ActionListener;
11
import java.awt.event.ActionListener;
12
import java.io.BufferedInputStream;
12
import java.io.BufferedInputStream;
13
import java.io.BufferedOutputStream;
13
import java.io.BufferedOutputStream;
14
import java.io.ByteArrayOutputStream;
14
import java.io.ByteArrayOutputStream;
15
import java.io.File;
15
import java.io.File;
16
import java.io.FileInputStream;
16
import java.io.FileInputStream;
17
import java.io.FileOutputStream;
17
import java.io.FileOutputStream;
18
import java.io.IOException;
18
import java.io.IOException;
19
import java.nio.charset.Charset;
19
import java.nio.charset.Charset;
20
import java.sql.SQLException;
20
import java.sql.SQLException;
21
import java.util.List;
21
import java.util.List;
22
import java.util.zip.GZIPInputStream;
22
import java.util.zip.GZIPInputStream;
23
import java.util.zip.GZIPOutputStream;
23
import java.util.zip.GZIPOutputStream;
24
 
24
 
25
import javax.swing.JButton;
25
import javax.swing.JButton;
26
import javax.swing.JFrame;
26
import javax.swing.JFrame;
27
import javax.swing.JLabel;
27
import javax.swing.JLabel;
28
import javax.swing.JOptionPane;
28
import javax.swing.JOptionPane;
29
import javax.swing.JPanel;
29
import javax.swing.JPanel;
30
import javax.swing.JSeparator;
30
import javax.swing.JSeparator;
31
import javax.swing.SwingUtilities;
31
import javax.swing.SwingUtilities;
32
import javax.swing.event.ChangeEvent;
32
import javax.swing.event.ChangeEvent;
33
import javax.swing.event.ChangeListener;
33
import javax.swing.event.ChangeListener;
34
 
34
 
35
import org.openconcerto.erp.config.ComptaPropsConfiguration;
35
import org.openconcerto.erp.config.ComptaPropsConfiguration;
36
import org.openconcerto.modules.extensionbuilder.component.ComponentCreateMainPanel;
36
import org.openconcerto.modules.extensionbuilder.component.ComponentCreateMainPanel;
37
import org.openconcerto.modules.extensionbuilder.component.ComponentDescritor;
37
import org.openconcerto.modules.extensionbuilder.component.ComponentDescritor;
38
import org.openconcerto.modules.extensionbuilder.list.ListCreateMainPanel;
38
import org.openconcerto.modules.extensionbuilder.list.ListCreateMainPanel;
39
import org.openconcerto.modules.extensionbuilder.list.ListDescriptor;
39
import org.openconcerto.modules.extensionbuilder.list.ListDescriptor;
40
import org.openconcerto.modules.extensionbuilder.menu.MenuMainPanel;
40
import org.openconcerto.modules.extensionbuilder.menu.MenuMainPanel;
41
import org.openconcerto.modules.extensionbuilder.table.TableDescritor;
41
import org.openconcerto.modules.extensionbuilder.table.TableDescritor;
42
import org.openconcerto.modules.extensionbuilder.table.TableMainPanel;
42
import org.openconcerto.modules.extensionbuilder.table.TableMainPanel;
43
import org.openconcerto.modules.extensionbuilder.translation.TranslationMainPanel;
43
import org.openconcerto.modules.extensionbuilder.translation.TranslationMainPanel;
44
import org.openconcerto.sql.model.DBRoot;
44
import org.openconcerto.sql.model.DBRoot;
45
import org.openconcerto.ui.DefaultGridBagConstraints;
45
import org.openconcerto.ui.DefaultGridBagConstraints;
46
import org.openconcerto.ui.FrameUtil;
46
import org.openconcerto.ui.FrameUtil;
47
import org.openconcerto.ui.JLabelBold;
47
import org.openconcerto.ui.JLabelBold;
48
import org.openconcerto.ui.ReloadPanel;
48
import org.openconcerto.ui.ReloadPanel;
49
import org.openconcerto.ui.warning.JLabelWarning;
49
import org.openconcerto.ui.warning.JLabelWarning;
50
import org.openconcerto.utils.ExceptionHandler;
50
import org.openconcerto.utils.ExceptionHandler;
51
import org.openconcerto.utils.StreamUtils;
51
import org.openconcerto.utils.StreamUtils;
52
 
52
 
53
public class ExtensionInfoPanel extends JPanel implements ChangeListener {
53
public class ExtensionInfoPanel extends JPanel implements ChangeListener {
54
    private Extension extension;
54
    private Extension extension;
55
 
55
 
56
    private JFrame frameTableEditor;
56
    private JFrame frameTableEditor;
57
 
57
 
58
    private JFrame frameListEditor;
58
    private JFrame frameListEditor;
59
    private JFrame frameMenuEditor;
59
    private JFrame frameMenuEditor;
60
    private JFrame frameTranslationEditor;
60
    private JFrame frameTranslationEditor;
61
 
61
 
62
    ExtensionInfoPanel(Extension extension, ExtensionListPanel moduleListPanel) {
62
    ExtensionInfoPanel(Extension extension, ExtensionListPanel moduleListPanel) {
63
        this.extension = extension;
63
        this.extension = extension;
64
        this.extension.addChangeListener(this);
64
        this.extension.addChangeListener(this);
65
        reloadUI();
65
        reloadUI();
66
    }
66
    }
67
 
67
 
68
    @Override
68
    @Override
69
    public void stateChanged(ChangeEvent e) {
69
    public void stateChanged(ChangeEvent e) {
70
        SwingUtilities.invokeLater(new Runnable() {
70
        SwingUtilities.invokeLater(new Runnable() {
71
 
71
 
72
            @Override
72
            @Override
73
            public void run() {
73
            public void run() {
74
                reloadUI();
74
                reloadUI();
75
 
75
 
76
            }
76
            }
77
        });
77
        });
78
 
78
 
79
    }
79
    }
80
 
80
 
81
    private void reloadUI() {
81
    private void reloadUI() {
82
        if (!SwingUtilities.isEventDispatchThread()) {
82
        if (!SwingUtilities.isEventDispatchThread()) {
83
            throw new IllegalStateException("Not in AWT");
83
            throw new IllegalStateException("Not in AWT");
84
        }
84
        }
85
        System.out.println("ExtensionInfoPanel.reloadUI()");
85
        System.out.println("ExtensionInfoPanel.reloadUI()");
86
        this.setBackground(Color.WHITE);
86
        this.setBackground(Color.WHITE);
87
        this.invalidate();
87
        this.invalidate();
88
        this.removeAll();
88
        this.removeAll();
89
 
89
 
90
        this.setLayout(new GridBagLayout());
90
        this.setLayout(new GridBagLayout());
91
        GridBagConstraints c = new DefaultGridBagConstraints();
91
        GridBagConstraints c = new DefaultGridBagConstraints();
92
        c.insets = new Insets(0, 0, 0, 0);
92
        c.insets = new Insets(0, 0, 0, 0);
93
 
93
 
94
        this.add(createToolbar(), c);
94
        this.add(createToolbar(), c);
95
        c.gridy++;
95
        c.gridy++;
96
 
96
 
97
        this.add(new JSeparator(JSeparator.HORIZONTAL), c);
97
        this.add(new JSeparator(JSeparator.HORIZONTAL), c);
98
        c.gridy++;
98
        c.gridy++;
99
        c.weightx = 1;
99
        c.weightx = 1;
100
        c.weighty = 1;
100
        c.weighty = 1;
101
        c.fill = GridBagConstraints.BOTH;
101
        c.fill = GridBagConstraints.BOTH;
102
 
102
 
103
        this.add(createInfoPanel(), c);
103
        this.add(createInfoPanel(), c);
104
        this.revalidate();
104
        this.revalidate();
105
    }
105
    }
106
 
106
 
107
    private JPanel createToolbar() {
107
    private JPanel createToolbar() {
108
        JPanel panel = new JPanel();
108
        JPanel panel = new JPanel();
109
        panel.setLayout(new FlowLayout(FlowLayout.LEADING));
109
        panel.setLayout(new FlowLayout(FlowLayout.LEADING));
110
        panel.add(new JLabelBold(this.extension.getName()));
110
        panel.add(new JLabelBold(this.extension.getName()));
111
        final ReloadPanel reload = new ReloadPanel();
111
        final ReloadPanel reload = new ReloadPanel();
112
        panel.add(reload);
112
        panel.add(reload);
113
        final JButton startButton = new JButton("Démarrer");
113
        final JButton startButton = new JButton("Démarrer");
114
 
114
 
115
        panel.add(startButton);
115
        panel.add(startButton);
116
        startButton.setEnabled(!extension.isStarted());
116
        startButton.setEnabled(!this.extension.isStarted());
117
        final JButton stopButton = new JButton("Arrêter");
117
        final JButton stopButton = new JButton("Arrêter");
118
        panel.add(stopButton);
118
        panel.add(stopButton);
119
        stopButton.setEnabled(extension.isStarted());
119
        stopButton.setEnabled(this.extension.isStarted());
120
        final JButton saveButton = new JButton("Enregister");
120
        final JButton saveButton = new JButton("Enregister");
121
        saveButton.addActionListener(new ActionListener() {
121
        saveButton.addActionListener(new ActionListener() {
122
 
122
 
123
            @Override
123
            @Override
124
            public void actionPerformed(ActionEvent e) {
124
            public void actionPerformed(ActionEvent e) {
125
                extension.save();
125
                ExtensionInfoPanel.this.extension.save();
126
 
126
 
127
            }
127
            }
128
        });
128
        });
129
        panel.add(saveButton);
129
        panel.add(saveButton);
130
        // TODO: a mettre en clic droit sur la liste gauche
130
        // TODO: a mettre en clic droit sur la liste gauche
131
        final JButton exportButton = new JButton("Exporter");
131
        final JButton exportButton = new JButton("Exporter");
132
        panel.add(exportButton);
132
        panel.add(exportButton);
133
        final JButton importButton = new JButton("Importer");
133
        final JButton importButton = new JButton("Importer");
134
        panel.add(importButton);
134
        panel.add(importButton);
135
 
135
 
136
        exportButton.addActionListener(new ActionListener() {
136
        exportButton.addActionListener(new ActionListener() {
137
 
137
 
138
            @Override
138
            @Override
139
            public void actionPerformed(ActionEvent e) {
139
            public void actionPerformed(ActionEvent e) {
140
                String xml = extension.toXML();
140
                String xml = ExtensionInfoPanel.this.extension.toXML();
141
                System.out.println(xml);
141
                System.out.println(xml);
142
                FileDialog fDialog = new FileDialog(new JFrame(), "Export", FileDialog.SAVE);
142
                FileDialog fDialog = new FileDialog(new JFrame(), "Export", FileDialog.SAVE);
143
                fDialog.setFile(extension.getName() + ".ocext");
143
                fDialog.setFile(ExtensionInfoPanel.this.extension.getName() + ".ocext");
144
                fDialog.setVisible(true);
144
                fDialog.setVisible(true);
145
                String fileName = fDialog.getFile();
145
                String fileName = fDialog.getFile();
146
                if (fileName != null) {
146
                if (fileName != null) {
147
                    File file = new File(fDialog.getDirectory(), fDialog.getFile());
147
                    File file = new File(fDialog.getDirectory(), fDialog.getFile());
148
                    byte[] bytes = xml.getBytes(Charset.forName("UTF-8"));
148
                    byte[] bytes = xml.getBytes(Charset.forName("UTF-8"));
149
                    byte[] open = "openconcerto".getBytes();
149
                    byte[] open = "openconcerto".getBytes();
150
                    final int length = bytes.length;
150
                    final int length = bytes.length;
151
                    for (int i = 0; i < length; i++) {
151
                    for (int i = 0; i < length; i++) {
152
                        bytes[i] = (byte) (bytes[i] ^ open[i % 12]);
152
                        bytes[i] = (byte) (bytes[i] ^ open[i % 12]);
153
                    }
153
                    }
154
                    BufferedOutputStream out = null;
154
                    BufferedOutputStream out = null;
155
                    try {
155
                    try {
156
                        out = new BufferedOutputStream(new FileOutputStream(file));
156
                        out = new BufferedOutputStream(new FileOutputStream(file));
157
                        GZIPOutputStream gZ = new GZIPOutputStream(out);
157
                        GZIPOutputStream gZ = new GZIPOutputStream(out);
158
                        gZ.write(bytes);
158
                        gZ.write(bytes);
159
                        gZ.close();
159
                        gZ.close();
160
                    } catch (Exception e1) {
160
                    } catch (Exception e1) {
161
                        ExceptionHandler.handle("Unable to save extension " + file.getAbsolutePath(), e1);
161
                        ExceptionHandler.handle("Unable to save extension " + file.getAbsolutePath(), e1);
162
                    } finally {
162
                    } finally {
163
                        if (out != null) {
163
                        if (out != null) {
164
                            try {
164
                            try {
165
                                out.close();
165
                                out.close();
166
                            } catch (IOException e1) {
166
                            } catch (IOException e1) {
167
                                // Nothing
167
                                // Nothing
168
                            }
168
                            }
169
                        }
169
                        }
170
                    }
170
                    }
171
 
171
 
172
                }
172
                }
173
 
173
 
174
            }
174
            }
175
        });
175
        });
176
        importButton.addActionListener(new ActionListener() {
176
        importButton.addActionListener(new ActionListener() {
177
 
177
 
178
            @Override
178
            @Override
179
            public void actionPerformed(ActionEvent e) {
179
            public void actionPerformed(ActionEvent e) {
180
                final FileDialog fDialog = new FileDialog(new JFrame(), "Import", FileDialog.LOAD);
180
                final FileDialog fDialog = new FileDialog(new JFrame(), "Import", FileDialog.LOAD);
181
                fDialog.setVisible(true);
181
                fDialog.setVisible(true);
182
                final String fileName = fDialog.getFile();
182
                final String fileName = fDialog.getFile();
183
                String xml = "";
183
                String xml = "";
184
                if (fileName != null && fileName.endsWith(".ocext")) {
184
                if (fileName != null && fileName.endsWith(".ocext")) {
185
                    File file = new File(fDialog.getDirectory(), fDialog.getFile());
185
                    File file = new File(fDialog.getDirectory(), fDialog.getFile());
186
                    if (file.exists()) {
186
                    if (file.exists()) {
187
                        FileInputStream fIn = null;
187
                        FileInputStream fIn = null;
188
                        GZIPInputStream gIn = null;
188
                        GZIPInputStream gIn = null;
189
                        try {
189
                        try {
190
                            fIn = new FileInputStream(file);
190
                            fIn = new FileInputStream(file);
191
                            BufferedInputStream bIn = new BufferedInputStream(fIn);
191
                            BufferedInputStream bIn = new BufferedInputStream(fIn);
192
                            gIn = new GZIPInputStream(bIn);
192
                            gIn = new GZIPInputStream(bIn);
193
                            final ByteArrayOutputStream out = new ByteArrayOutputStream();
193
                            final ByteArrayOutputStream out = new ByteArrayOutputStream();
194
                            StreamUtils.copy(gIn, out);
194
                            StreamUtils.copy(gIn, out);
195
                            out.close();
195
                            out.close();
196
                            // decode
196
                            // decode
197
                            byte[] bytes = out.toByteArray();
197
                            byte[] bytes = out.toByteArray();
198
                            byte[] open = "openconcerto".getBytes();
198
                            byte[] open = "openconcerto".getBytes();
199
                            final int length = bytes.length;
199
                            final int length = bytes.length;
200
                            for (int i = 0; i < length; i++) {
200
                            for (int i = 0; i < length; i++) {
201
                                bytes[i] = (byte) (bytes[i] ^ open[i % 12]);
201
                                bytes[i] = (byte) (bytes[i] ^ open[i % 12]);
202
                            }
202
                            }
203
                            xml = new String(bytes, Charset.forName("UTF-8"));
203
                            xml = new String(bytes, Charset.forName("UTF-8"));
204
                        } catch (Exception ex) {
204
                        } catch (Exception ex) {
205
                            ex.printStackTrace();
205
                            ex.printStackTrace();
206
                            JOptionPane.showMessageDialog(new JFrame(), "Invalid extension");
206
                            JOptionPane.showMessageDialog(new JFrame(), "Invalid extension");
207
                        } finally {
207
                        } finally {
208
                            if (gIn != null) {
208
                            if (gIn != null) {
209
                                try {
209
                                try {
210
                                    gIn.close();
210
                                    gIn.close();
211
                                } catch (IOException e1) {
211
                                } catch (IOException e1) {
212
                                    e1.printStackTrace();
212
                                    e1.printStackTrace();
213
                                }
213
                                }
214
                            }
214
                            }
215
                            if (fIn != null) {
215
                            if (fIn != null) {
216
                                try {
216
                                try {
217
                                    fIn.close();
217
                                    fIn.close();
218
                                } catch (IOException e1) {
218
                                } catch (IOException e1) {
219
                                    e1.printStackTrace();
219
                                    e1.printStackTrace();
220
                                }
220
                                }
221
                            }
221
                            }
222
                        }
222
                        }
223
 
223
 
224
                    }
224
                    }
225
 
225
 
226
                }
226
                }
227
                // Create extension from XML
227
                // Create extension from XML
228
                extension.stop();
228
                ExtensionInfoPanel.this.extension.stop();
229
                if (!xml.isEmpty()) {
229
                if (!xml.isEmpty()) {
230
                    if (!extension.isEmpty()) {
230
                    if (!ExtensionInfoPanel.this.extension.isEmpty()) {
231
                        int result = JOptionPane.showConfirmDialog(ExtensionInfoPanel.this, "Attention l'extension actuelle sera écrasée.\nContinuer l'importation?");
231
                        int result = JOptionPane.showConfirmDialog(ExtensionInfoPanel.this, "Attention l'extension actuelle sera écrasée.\nContinuer l'importation?");
232
                        if (result != JOptionPane.YES_OPTION) {
232
                        if (result != JOptionPane.YES_OPTION) {
233
                            return;
233
                            return;
234
                        }
234
                        }
235
                    }
235
                    }
236
                    extension.clearAll();
236
                    ExtensionInfoPanel.this.extension.clearAll();
237
                    extension.importFromXML(xml);
237
                    ExtensionInfoPanel.this.extension.importFromXML(xml);
238
                    extension.setChanged();
238
                    ExtensionInfoPanel.this.extension.setChanged();
239
                }
239
                }
240
 
240
 
241
            }
241
            }
242
        });
242
        });
243
        startButton.addActionListener(new ActionListener() {
243
        startButton.addActionListener(new ActionListener() {
244
 
244
 
245
            @Override
245
            @Override
246
            public void actionPerformed(ActionEvent e) {
246
            public void actionPerformed(ActionEvent e) {
247
                reload.setMode(ReloadPanel.MODE_ROTATE);
247
                reload.setMode(ReloadPanel.MODE_ROTATE);
248
                new Thread(new Runnable() {
248
                new Thread(new Runnable() {
249
 
249
 
250
                    @Override
250
                    @Override
251
                    public void run() {
251
                    public void run() {
252
                        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
252
                        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
253
                        try {
253
                        try {
254
                            extension.start(root, false);
254
                            ExtensionInfoPanel.this.extension.start(root, false);
-
 
255
                            SwingUtilities.invokeLater(new Runnable() {
-
 
256
 
-
 
257
                                @Override
-
 
258
                                public void run() {
-
 
259
                                    reload.setMode(ReloadPanel.MODE_EMPTY);
-
 
260
                                }
-
 
261
                            });
255
                        } catch (SQLException e1) {
262
                        } catch (SQLException e) {
-
 
263
                            SwingUtilities.invokeLater(new Runnable() {
-
 
264
 
-
 
265
                                @Override
256
                            e1.printStackTrace();
266
                                public void run() {
-
 
267
                                    reload.setMode(ReloadPanel.MODE_BLINK);
-
 
268
                                }
-
 
269
                            });
-
 
270
                            ExceptionHandler.handle("Start error", e);
257
                        }
271
                        }
258
                    }
272
                    }
259
                }).start();
273
                }).start();
260
            }
274
            }
261
        });
275
        });
262
        stopButton.addActionListener(new ActionListener() {
276
        stopButton.addActionListener(new ActionListener() {
263
 
277
 
264
            @Override
278
            @Override
265
            public void actionPerformed(ActionEvent e) {
279
            public void actionPerformed(ActionEvent e) {
266
                reload.setMode(ReloadPanel.MODE_ROTATE);
280
                reload.setMode(ReloadPanel.MODE_ROTATE);
267
                new Thread(new Runnable() {
281
                new Thread(new Runnable() {
268
                    @Override
282
                    @Override
269
                    public void run() {
283
                    public void run() {
-
 
284
                        try {
-
 
285
                            ExtensionInfoPanel.this.extension.stop();
-
 
286
                            SwingUtilities.invokeLater(new Runnable() {
-
 
287
 
-
 
288
                                @Override
-
 
289
                                public void run() {
-
 
290
                                    reload.setMode(ReloadPanel.MODE_EMPTY);
-
 
291
                                }
270
                        extension.stop();
292
                            });
-
 
293
                        } catch (Exception e) {
-
 
294
                            SwingUtilities.invokeLater(new Runnable() {
-
 
295
 
-
 
296
                                @Override
-
 
297
                                public void run() {
-
 
298
                                    reload.setMode(ReloadPanel.MODE_BLINK);
-
 
299
                                }
-
 
300
                            });
-
 
301
                            ExceptionHandler.handle("Stop error", e);
-
 
302
                        }
-
 
303
 
271
                    }
304
                    }
272
                }).start();
305
                }).start();
273
            }
306
            }
274
        });
307
        });
275
        return panel;
308
        return panel;
276
    }
309
    }
277
 
310
 
278
    private JPanel createInfoPanel() {
311
    private JPanel createInfoPanel() {
279
        final JPanel panel = new JPanel();
312
        final JPanel panel = new JPanel();
280
        panel.setOpaque(false);
313
        panel.setOpaque(false);
281
        final GridBagConstraints c = new DefaultGridBagConstraints();
314
        final GridBagConstraints c = new DefaultGridBagConstraints();
282
        panel.setLayout(new GridBagLayout());
315
        panel.setLayout(new GridBagLayout());
283
        c.fill = GridBagConstraints.NONE;
316
        c.fill = GridBagConstraints.NONE;
284
        c.gridy++;
317
        c.gridy++;
285
        // --------- TABLES
318
        // --------- TABLES
286
        panel.add(new JLabelBold("Tables et champs de la base de données"), c);
319
        panel.add(new JLabelBold("Tables et champs de la base de données"), c);
287
        c.gridy++;
320
        c.gridy++;
288
        final List<TableDescritor> createTableList = this.extension.getCreateTableList();
321
        final List<TableDescritor> createTableList = this.extension.getCreateTableList();
289
        if (createTableList.size() > 0) {
322
        if (createTableList.size() > 0) {
290
 
323
 
291
            panel.add(new JLabel("Cette extension crée " + createTableList.size() + " tables :"), c);
324
            panel.add(new JLabel("Cette extension crée " + createTableList.size() + " tables :"), c);
292
            c.gridy++;
325
            c.gridy++;
293
            c.gridwidth = 1;
326
            c.gridwidth = 1;
294
            for (final TableDescritor sqlCreateTable : createTableList) {
327
            for (final TableDescritor sqlCreateTable : createTableList) {
295
                c.gridx = 0;
328
                c.gridx = 0;
296
                c.weightx = 0;
329
                c.weightx = 0;
297
                JPanel line = new JPanel();
330
                JPanel line = new JPanel();
298
                line.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
331
                line.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
299
                line.setOpaque(false);
332
                line.setOpaque(false);
300
                line.add(new JLabel("- " + sqlCreateTable.getName()));
333
                line.add(new JLabel("- " + sqlCreateTable.getName()));
301
                if (sqlCreateTable.getFields().size() > 0) {
334
                if (sqlCreateTable.getFields().size() > 0) {
302
                    line.add(new JLabel(" " + sqlCreateTable.getFields().size() + " champs"));
335
                    line.add(new JLabel(" " + sqlCreateTable.getFields().size() + " champs"));
303
                } else {
336
                } else {
304
                    line.add(new JLabelWarning(" " + "aucun champ"));
337
                    line.add(new JLabelWarning(" " + "aucun champ"));
305
                }
338
                }
306
                panel.add(line, c);
339
                panel.add(line, c);
307
                c.gridy++;
340
                c.gridy++;
308
            }
341
            }
309
 
342
 
310
        }
343
        }
311
        final List<TableDescritor> modifyTableList = this.extension.getModifyTableList();
344
        final List<TableDescritor> modifyTableList = this.extension.getModifyTableList();
312
        if (modifyTableList.size() > 0) {
345
        if (modifyTableList.size() > 0) {
313
            String tables = "";
346
            String tables = "";
314
            for (int i = 0; i < modifyTableList.size(); i++) {
347
            for (int i = 0; i < modifyTableList.size(); i++) {
315
                String tableName = modifyTableList.get(i).getName();
348
                String tableName = modifyTableList.get(i).getName();
316
                if (i < modifyTableList.size() - 1) {
349
                if (i < modifyTableList.size() - 1) {
317
                    tables += tableName + ", ";
350
                    tables += tableName + ", ";
318
                } else {
351
                } else {
319
                    tables += tableName;
352
                    tables += tableName;
320
                }
353
                }
321
            }
354
            }
322
            if (modifyTableList.size() > 1) {
355
            if (modifyTableList.size() > 1) {
323
                panel.add(new JLabel("Tables modifiées : " + tables), c);
356
                panel.add(new JLabel("Tables modifiées : " + tables), c);
324
            } else {
357
            } else {
325
                panel.add(new JLabel("Table modifiée : " + tables), c);
358
                panel.add(new JLabel("Table modifiée : " + tables), c);
326
            }
359
            }
327
            c.gridy++;
360
            c.gridy++;
328
        }
361
        }
329
        final JButton buttonCreateTable = new JButton("Afficher les tables");
362
        final JButton buttonCreateTable = new JButton("Afficher les tables");
330
        panel.add(buttonCreateTable, c);
363
        panel.add(buttonCreateTable, c);
331
        c.gridy++;
364
        c.gridy++;
332
        panel.add(new JLabel(" "), c);
365
        panel.add(new JLabel(" "), c);
333
        c.gridy++;
366
        c.gridy++;
334
        // --------- UI
367
        // --------- UI
335
        panel.add(new JLabelBold("Interfaces de saisie"), c);
368
        panel.add(new JLabelBold("Interfaces de saisie"), c);
336
        c.gridy++;
369
        c.gridy++;
337
        List<ComponentDescritor> createComponentList = extension.getCreateComponentList();
370
        List<ComponentDescritor> createComponentList = this.extension.getCreateComponentList();
338
        if (createComponentList.size() > 0) {
371
        if (createComponentList.size() > 0) {
339
            String components = "";
372
            String components = "";
340
            for (int i = 0; i < createComponentList.size(); i++) {
373
            for (int i = 0; i < createComponentList.size(); i++) {
341
                String tableName = createComponentList.get(i).getId();
374
                String tableName = createComponentList.get(i).getId();
342
                if (i < createComponentList.size() - 1) {
375
                if (i < createComponentList.size() - 1) {
343
                    components += tableName + ", ";
376
                    components += tableName + ", ";
344
                } else {
377
                } else {
345
                    components += tableName;
378
                    components += tableName;
346
                }
379
                }
347
            }
380
            }
348
 
381
 
349
            if (createComponentList.size() > 1) {
382
            if (createComponentList.size() > 1) {
350
                panel.add(new JLabel("Interfaces créées : " + components), c);
383
                panel.add(new JLabel("Interfaces créées : " + components), c);
351
            } else {
384
            } else {
352
                panel.add(new JLabel("Interface créée : " + components), c);
385
                panel.add(new JLabel("Interface créée : " + components), c);
353
            }
386
            }
354
            c.gridy++;
387
            c.gridy++;
355
        }
388
        }
356
 
389
 
357
        final JButton buttonCreateComponent = new JButton("Afficher les interfaces");
390
        final JButton buttonCreateComponent = new JButton("Afficher les interfaces");
358
        panel.add(buttonCreateComponent, c);
391
        panel.add(buttonCreateComponent, c);
359
        c.gridy++;
392
        c.gridy++;
360
        panel.add(new JLabel(" "), c);
393
        panel.add(new JLabel(" "), c);
361
        c.gridy++;
394
        c.gridy++;
362
 
395
 
363
        // --------- LIST
396
        // --------- LIST
364
        panel.add(new JLabelBold("Listes"), c);
397
        panel.add(new JLabelBold("Listes"), c);
365
        c.gridy++;
398
        c.gridy++;
366
        List<ListDescriptor> createListList = extension.getCreateListList();
399
        List<ListDescriptor> createListList = this.extension.getCreateListList();
367
        if (createListList.size() > 0) {
400
        if (createListList.size() > 0) {
368
            String components = "";
401
            String components = "";
369
            for (int i = 0; i < createListList.size(); i++) {
402
            for (int i = 0; i < createListList.size(); i++) {
370
                String tableName = createListList.get(i).getId();
403
                String tableName = createListList.get(i).getId();
371
                if (i < createListList.size() - 1) {
404
                if (i < createListList.size() - 1) {
372
                    components += tableName + ", ";
405
                    components += tableName + ", ";
373
                } else {
406
                } else {
374
                    components += tableName;
407
                    components += tableName;
375
                }
408
                }
376
            }
409
            }
377
 
410
 
378
            if (createListList.size() > 1) {
411
            if (createListList.size() > 1) {
379
                panel.add(new JLabel("Listes créées : " + components), c);
412
                panel.add(new JLabel("Listes créées : " + components), c);
380
            } else {
413
            } else {
381
                panel.add(new JLabel("Liste créée : " + components), c);
414
                panel.add(new JLabel("Liste créée : " + components), c);
382
            }
415
            }
383
            c.gridy++;
416
            c.gridy++;
384
        }
417
        }
385
 
418
 
386
        final JButton buttonCreateList = new JButton("Afficher les listes");
419
        final JButton buttonCreateList = new JButton("Afficher les listes");
387
        panel.add(buttonCreateList, c);
420
        panel.add(buttonCreateList, c);
388
        c.gridy++;
421
        c.gridy++;
389
        panel.add(new JLabel(" "), c);
422
        panel.add(new JLabel(" "), c);
390
        c.gridy++;
423
        c.gridy++;
391
        // --------- MENUS
424
        // --------- MENUS
392
        panel.add(new JLabelBold("Menus et actions"), c);
425
        panel.add(new JLabelBold("Menus et actions"), c);
393
        c.gridy++;
426
        c.gridy++;
394
        final int actionCount = extension.getActionDescriptors().size();
427
        final int actionCount = this.extension.getActionDescriptors().size();
395
        final int menuCount = extension.getCreateMenuList().size();
428
        final int menuCount = this.extension.getCreateMenuList().size();
396
        final int menuCount2 = extension.getRemoveMenuList().size();
429
        final int menuCount2 = this.extension.getRemoveMenuList().size();
397
        if (actionCount > 0) {
430
        if (actionCount > 0) {
398
            if (actionCount > 1)
431
            if (actionCount > 1)
399
                panel.add(new JLabel(actionCount + " actions"), c);
432
                panel.add(new JLabel(actionCount + " actions"), c);
400
            else
433
            else
401
                panel.add(new JLabel(actionCount + " action"), c);
434
                panel.add(new JLabel(actionCount + " action"), c);
402
 
435
 
403
            c.gridy++;
436
            c.gridy++;
404
        }
437
        }
405
        if (menuCount > 0) {
438
        if (menuCount > 0) {
406
            if (menuCount > 1)
439
            if (menuCount > 1)
407
                panel.add(new JLabel(menuCount + " ajouts de menu"), c);
440
                panel.add(new JLabel(menuCount + " ajouts de menu"), c);
408
            else
441
            else
409
                panel.add(new JLabel(menuCount + " ajout de menu"), c);
442
                panel.add(new JLabel(menuCount + " ajout de menu"), c);
410
            c.gridy++;
443
            c.gridy++;
411
        }
444
        }
412
        if (menuCount2 > 0) {
445
        if (menuCount2 > 0) {
413
            if (menuCount2 > 1)
446
            if (menuCount2 > 1)
414
                panel.add(new JLabel(menuCount2 + " suppressions de menu"), c);
447
                panel.add(new JLabel(menuCount2 + " suppressions de menu"), c);
415
            else
448
            else
416
                panel.add(new JLabel(menuCount2 + " suppression de menu"), c);
449
                panel.add(new JLabel(menuCount2 + " suppression de menu"), c);
417
            c.gridy++;
450
            c.gridy++;
418
        }
451
        }
419
        final JButton buttonCreateMenu = new JButton("Afficher les menus");
452
        final JButton buttonCreateMenu = new JButton("Afficher les menus");
420
        panel.add(buttonCreateMenu, c);
453
        panel.add(buttonCreateMenu, c);
421
        c.gridy++;
454
        c.gridy++;
422
        panel.add(new JLabel(" "), c);
455
        panel.add(new JLabel(" "), c);
423
 
456
 
424
        c.gridy++;
457
        c.gridy++;
425
 
458
 
426
        // --------- TRANSLATIONS
459
        // --------- TRANSLATIONS
427
        panel.add(new JLabelBold("Traductions et renommage de labels"), c);
460
        panel.add(new JLabelBold("Traductions et renommage de labels"), c);
428
        c.gridy++;
461
        c.gridy++;
429
 
462
 
430
        int actionTranslationCount = extension.getActionTranslations().size();
463
        int actionTranslationCount = this.extension.getActionTranslations().size();
431
        int menuTranslationCount = extension.getMenuTranslations().size();
464
        int menuTranslationCount = this.extension.getMenuTranslations().size();
432
        int fieldTranslationCount = extension.getFieldTranslations().size();
465
        int fieldTranslationCount = this.extension.getFieldTranslations().size();
433
        if (fieldTranslationCount > 0) {
466
        if (fieldTranslationCount > 0) {
434
            if (fieldTranslationCount > 1)
467
            if (fieldTranslationCount > 1)
435
                panel.add(new JLabel(fieldTranslationCount + " traductions de champs"), c);
468
                panel.add(new JLabel(fieldTranslationCount + " traductions de champs"), c);
436
            else
469
            else
437
                panel.add(new JLabel(fieldTranslationCount + " traduction de champs"), c);
470
                panel.add(new JLabel(fieldTranslationCount + " traduction de champs"), c);
438
 
471
 
439
            c.gridy++;
472
            c.gridy++;
440
        }
473
        }
441
        if (menuTranslationCount > 0) {
474
        if (menuTranslationCount > 0) {
442
            if (menuTranslationCount > 1)
475
            if (menuTranslationCount > 1)
443
                panel.add(new JLabel(menuTranslationCount + " traductions de menu"), c);
476
                panel.add(new JLabel(menuTranslationCount + " traductions de menu"), c);
444
            else
477
            else
445
                panel.add(new JLabel(menuTranslationCount + " traduction de menu"), c);
478
                panel.add(new JLabel(menuTranslationCount + " traduction de menu"), c);
446
            c.gridy++;
479
            c.gridy++;
447
        }
480
        }
448
 
481
 
449
        if (actionTranslationCount > 0) {
482
        if (actionTranslationCount > 0) {
450
            if (actionTranslationCount > 1)
483
            if (actionTranslationCount > 1)
451
                panel.add(new JLabel(actionTranslationCount + " traductions d'action"), c);
484
                panel.add(new JLabel(actionTranslationCount + " traductions d'action"), c);
452
            else
485
            else
453
                panel.add(new JLabel(actionTranslationCount + " traduction d'action"), c);
486
                panel.add(new JLabel(actionTranslationCount + " traduction d'action"), c);
454
            c.gridy++;
487
            c.gridy++;
455
        }
488
        }
456
 
489
 
457
        final JButton buttonCreateTranslation = new JButton("Afficher les traductions");
490
        final JButton buttonCreateTranslation = new JButton("Afficher les traductions");
458
        panel.add(buttonCreateTranslation, c);
491
        panel.add(buttonCreateTranslation, c);
459
        c.gridy++;
492
        c.gridy++;
460
        panel.add(new JLabel(" "), c);
493
        panel.add(new JLabel(" "), c);
461
        c.gridy++;
494
        c.gridy++;
462
        c.weighty = 1;
495
        c.weighty = 1;
463
        c.gridwidth = 2;
496
        c.gridwidth = 2;
464
        c.weightx = 1;
497
        c.weightx = 1;
465
        panel.add(new JLabel(" "), c);
498
        panel.add(new JLabel(" "), c);
466
        c.gridy++;
499
        c.gridy++;
467
        //
500
        //
468
        buttonCreateTable.addActionListener(new ActionListener() {
501
        buttonCreateTable.addActionListener(new ActionListener() {
469
 
502
 
470
            @Override
503
            @Override
471
            public void actionPerformed(ActionEvent e) {
504
            public void actionPerformed(ActionEvent e) {
472
                openTableEditor();
505
                openTableEditor();
473
            }
506
            }
474
        });
507
        });
475
        buttonCreateList.addActionListener(new ActionListener() {
508
        buttonCreateList.addActionListener(new ActionListener() {
476
 
509
 
477
            @Override
510
            @Override
478
            public void actionPerformed(ActionEvent e) {
511
            public void actionPerformed(ActionEvent e) {
479
                openListEditor();
512
                openListEditor();
480
            }
513
            }
481
        });
514
        });
482
        buttonCreateComponent.addActionListener(new ActionListener() {
515
        buttonCreateComponent.addActionListener(new ActionListener() {
483
 
516
 
484
            @Override
517
            @Override
485
            public void actionPerformed(ActionEvent e) {
518
            public void actionPerformed(ActionEvent e) {
486
                openComponentEditor();
519
                openComponentEditor();
487
            }
520
            }
488
        });
521
        });
489
        buttonCreateMenu.addActionListener(new ActionListener() {
522
        buttonCreateMenu.addActionListener(new ActionListener() {
490
 
523
 
491
            @Override
524
            @Override
492
            public void actionPerformed(ActionEvent e) {
525
            public void actionPerformed(ActionEvent e) {
493
                openMenuEditor();
526
                openMenuEditor();
494
            }
527
            }
495
        });
528
        });
496
        buttonCreateTranslation.addActionListener(new ActionListener() {
529
        buttonCreateTranslation.addActionListener(new ActionListener() {
497
 
530
 
498
            @Override
531
            @Override
499
            public void actionPerformed(ActionEvent e) {
532
            public void actionPerformed(ActionEvent e) {
500
                openTranslationEditor();
533
                openTranslationEditor();
501
            }
534
            }
502
        });
535
        });
503
        return panel;
536
        return panel;
504
    }
537
    }
505
 
538
 
506
    private void openTableEditor() {
539
    private void openTableEditor() {
507
        final TableMainPanel contentPane = new TableMainPanel(extension);
540
        final TableMainPanel contentPane = new TableMainPanel(this.extension);
508
        openEditor(frameTableEditor, contentPane, "Tables dans la base de données");
541
        openEditor(this.frameTableEditor, contentPane, "Tables dans la base de données");
509
 
542
 
510
    }
543
    }
511
 
544
 
512
    private void openListEditor() {
545
    private void openListEditor() {
513
        final ListCreateMainPanel contentPane = new ListCreateMainPanel(extension);
546
        final ListCreateMainPanel contentPane = new ListCreateMainPanel(this.extension);
514
        openEditor(frameListEditor, contentPane, "Listes personnalisées");
547
        openEditor(this.frameListEditor, contentPane, "Listes personnalisées");
515
 
548
 
516
    }
549
    }
517
 
550
 
518
    protected void openComponentEditor() {
551
    protected void openComponentEditor() {
519
        final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(extension);
552
        final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(this.extension);
520
        openEditor(frameListEditor, contentPane, "Interfaces personnalisées");
553
        openEditor(this.frameListEditor, contentPane, "Interfaces personnalisées");
521
 
554
 
522
    }
555
    }
523
 
556
 
524
    protected void openMenuEditor() {
557
    protected void openMenuEditor() {
525
        final MenuMainPanel contentPane = new MenuMainPanel(extension);
558
        final MenuMainPanel contentPane = new MenuMainPanel(this.extension);
526
        openEditor(frameMenuEditor, contentPane, "Menus et actions");
559
        openEditor(this.frameMenuEditor, contentPane, "Menus et actions");
527
 
560
 
528
    }
561
    }
529
 
562
 
530
    protected void openTranslationEditor() {
563
    protected void openTranslationEditor() {
531
        final TranslationMainPanel contentPane = new TranslationMainPanel(extension);
564
        final TranslationMainPanel contentPane = new TranslationMainPanel(this.extension);
532
        openEditor(frameTranslationEditor, contentPane, "Traductions");
565
        openEditor(this.frameTranslationEditor, contentPane, "Traductions");
533
 
566
 
534
    }
567
    }
535
 
568
 
536
    private void openEditor(JFrame frame, JPanel mainPanel, String title) {
569
    private void openEditor(JFrame frame, JPanel mainPanel, String title) {
537
        if (frame == null) {
570
        if (frame == null) {
538
            frame = new JFrame();
571
            frame = new JFrame();
539
            frame.setTitle(extension.getName() + " - " + title);
572
            frame.setTitle(this.extension.getName() + " - " + title);
540
            frame.setContentPane(mainPanel);
573
            frame.setContentPane(mainPanel);
541
            frame.setMinimumSize(new Dimension(796, 560));
574
            frame.setMinimumSize(new Dimension(796, 560));
542
            frame.pack();
575
            frame.pack();
543
            frame.setLocationRelativeTo(ExtensionInfoPanel.this);
576
            frame.setLocationRelativeTo(ExtensionInfoPanel.this);
544
        }
577
        }
545
        FrameUtil.show(frame);
578
        FrameUtil.show(frame);
546
    }
579
    }
547
}
580
}