OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 86 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 181
Line 111... Line 111...
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
Line 135... Line 135...
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"));
Line 223... Line 223...
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() {
Line 249... Line 249...
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
        });
Line 265... Line 279...
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;
Line 332... Line 365...
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) {
Line 361... Line 394...
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) {
Line 389... Line 422...
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);
Line 425... Line 458...
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);
Line 502... Line 535...
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
        }