OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 151
Line 56... Line 56...
56
import java.awt.Toolkit;
56
import java.awt.Toolkit;
57
import java.awt.event.AWTEventListener;
57
import java.awt.event.AWTEventListener;
58
import java.awt.event.HierarchyEvent;
58
import java.awt.event.HierarchyEvent;
59
import java.awt.event.WindowAdapter;
59
import java.awt.event.WindowAdapter;
60
import java.awt.event.WindowEvent;
60
import java.awt.event.WindowEvent;
-
 
61
import java.beans.PropertyChangeEvent;
-
 
62
import java.beans.PropertyChangeListener;
61
import java.io.BufferedReader;
63
import java.io.BufferedReader;
62
import java.io.ByteArrayOutputStream;
64
import java.io.ByteArrayOutputStream;
63
import java.io.File;
65
import java.io.File;
64
import java.io.IOException;
66
import java.io.IOException;
65
import java.io.InputStreamReader;
67
import java.io.InputStreamReader;
Line 75... Line 77...
75
import java.security.Policy;
77
import java.security.Policy;
76
import java.security.ProtectionDomain;
78
import java.security.ProtectionDomain;
77
import java.sql.SQLException;
79
import java.sql.SQLException;
78
import java.util.ArrayList;
80
import java.util.ArrayList;
79
import java.util.Enumeration;
81
import java.util.Enumeration;
-
 
82
import java.util.HashSet;
80
import java.util.List;
83
import java.util.List;
-
 
84
import java.util.Set;
81
 
85
 
82
import javax.swing.ImageIcon;
86
import javax.swing.ImageIcon;
83
import javax.swing.JDialog;
87
import javax.swing.JDialog;
84
import javax.swing.JFrame;
88
import javax.swing.JFrame;
85
import javax.swing.JOptionPane;
89
import javax.swing.JOptionPane;
Line 382... Line 386...
382
                IListe.setForceAlternateCellRenderer(true);
386
                IListe.setForceAlternateCellRenderer(true);
383
                // ITableModel.setDefaultCellsEditable(false);
387
                // ITableModel.setDefaultCellsEditable(false);
384
                // ITableModel.setDefaultOrderEditable(true);
388
                // ITableModel.setDefaultOrderEditable(true);
385
 
389
 
386
                AWTEventListener awtListener = new AWTEventListener() {
390
                AWTEventListener awtListener = new AWTEventListener() {
-
 
391
                    Set<Integer> frames = new HashSet<Integer>();
-
 
392
                    String prefix;
-
 
393
 
387
                    @Override
394
                    @Override
388
                    public final void eventDispatched(final AWTEvent event) {
395
                    public final void eventDispatched(final AWTEvent event) {
389
                        assert event != null;
396
                        assert event != null;
390
                        if (event instanceof HierarchyEvent && event.getID() == HierarchyEvent.HIERARCHY_CHANGED) {
397
                        if (event instanceof HierarchyEvent && event.getID() == HierarchyEvent.HIERARCHY_CHANGED) {
391
                            // This event represents a change in the containment hierarcy.
398
                            // This event represents a change in the containment hierarcy.
392
                            // Now let's figure out what kind.
399
                            // Now let's figure out what kind.
393
                            final HierarchyEvent hevent = (HierarchyEvent) event;
400
                            final HierarchyEvent hevent = (HierarchyEvent) event;
394
                            final Component changed = hevent.getChanged();
401
                            final Component changed = hevent.getChanged();
395
                            if (changed instanceof JFrame && ((hevent.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) && changed.isDisplayable()) {
402
                            if (changed instanceof JFrame && ((hevent.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) && changed.isDisplayable()) {
396
                                JFrame frame = (JFrame) changed;
403
                                final JFrame frame = (JFrame) changed;
397
                                frame.setIconImages(getFrameIcon());
404
                                frame.setIconImages(getFrameIcon());
-
 
405
                                if (!frames.contains(frame.hashCode())) {
-
 
406
                                    frames.add(frame.hashCode());
-
 
407
                                    frame.addPropertyChangeListener(new PropertyChangeListener() {
-
 
408
 
-
 
409
                                        @Override
-
 
410
                                        public void propertyChange(PropertyChangeEvent evt) {
-
 
411
                                            if (prefix == null) {
-
 
412
                                                if (ComptaPropsConfiguration.getInstance() != null && ComptaPropsConfiguration.getInstanceCompta().getRowSociete() != null) {
-
 
413
                                                    prefix = "[" + ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getString("NOM") + "] ";
-
 
414
                                                } else {
-
 
415
                                                    return;
-
 
416
                                                }
-
 
417
                                            }
-
 
418
                                            String title = frame.getTitle();
-
 
419
                                            if (title != null && !title.startsWith(prefix)) {
-
 
420
                                                frame.setTitle(prefix + title);
-
 
421
                                            }
-
 
422
                                        }
-
 
423
                                    });
-
 
424
                                }
398
                            }
425
                            }
399
                        }
426
                        }
400
                    }
427
                    }
401
                };
428
                };
402
 
-
 
403
                final Toolkit toolkit = Toolkit.getDefaultToolkit();
429
                final Toolkit toolkit = Toolkit.getDefaultToolkit();
404
                assert toolkit != null;
430
                assert toolkit != null;
405
                toolkit.addAWTEventListener(awtListener, AWTEvent.HIERARCHY_EVENT_MASK);
431
                toolkit.addAWTEventListener(awtListener, AWTEvent.HIERARCHY_EVENT_MASK);
406
                if (logRequests) {
432
                if (logRequests) {
407
                    SQLRequestLog.showFrame();
433
                    SQLRequestLog.showFrame();