OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 153 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 153 Rev 181
Line 56... Line 56...
56
        c.weightx = 1;
56
        c.weightx = 1;
57
        c.weighty = 1;
57
        c.weighty = 1;
58
        c.gridwidth = 2;
58
        c.gridwidth = 2;
59
        c.fill = GridBagConstraints.BOTH;
59
        c.fill = GridBagConstraints.BOTH;
60
 
60
 
61
        panel = new GroupEditor(n, extension);
61
        this.panel = new GroupEditor(n, extension);
62
        final String mainTable = n.getTable();
62
        final String mainTable = n.getTable();
63
        if (mainTable == null && comboTable.getModel().getSize() > 0) {
63
        if (mainTable == null && comboTable.getModel().getSize() > 0) {
64
            comboTable.setSelectedIndex(0);
64
            comboTable.setSelectedIndex(0);
65
            panel.setMainTable((String) comboTable.getModel().getElementAt(0));
65
            this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
66
        } else {
66
        } else {
67
            comboTable.setSelectedItem(mainTable);
67
            comboTable.setSelectedItem(mainTable);
68
            panel.setMainTable(mainTable);
68
            this.panel.setMainTable(mainTable);
69
        }
69
        }
70
        this.add(panel, c);
70
        this.add(this.panel, c);
71
 
71
 
72
        final JButton previewButton = new JButton("Prévisualiser");
72
        final JButton previewButton = new JButton("Prévisualiser");
73
        c.gridy++;
73
        c.gridy++;
74
        c.weighty = 0;
74
        c.weighty = 0;
75
        c.fill = GridBagConstraints.NONE;
75
        c.fill = GridBagConstraints.NONE;
Line 80... Line 80...
80
 
80
 
81
        comboTable.addActionListener(new ActionListener() {
81
        comboTable.addActionListener(new ActionListener() {
82
 
82
 
83
            @Override
83
            @Override
84
            public void actionPerformed(ActionEvent e) {
84
            public void actionPerformed(ActionEvent e) {
85
                panel.setMainTable((String) comboTable.getSelectedItem());
85
                ComponentCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
86
 
86
 
87
            }
87
            }
88
        });
88
        });
89
        previewButton.addActionListener(new ActionListener() {
89
        previewButton.addActionListener(new ActionListener() {
90
 
90
 
Line 94... Line 94...
94
                final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
94
                final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
95
                if (t == null) {
95
                if (t == null) {
96
                    JOptionPane.showMessageDialog(ComponentCreatePanel.this, "La table doit être créée avant de pouvoir prévisualiser.");
96
                    JOptionPane.showMessageDialog(ComponentCreatePanel.this, "La table doit être créée avant de pouvoir prévisualiser.");
97
                    return;
97
                    return;
98
                }
98
                }
99
                final Group group = panel.getFilteredGroup();
99
                final Group group = ComponentCreatePanel.this.panel.getFilteredGroup();
100
 
100
 
101
                final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
101
                final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
102
                if (element == null) {
102
                if (element == null) {
103
                    Log.get().warning("No element for table: " + t.getName());
103
                    Log.get().warning("No element for table: " + t.getName());
104
                }
104
                }
105
                final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
105
                final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
106
                oldGroup = group;
106
                ComponentCreatePanel.this.oldGroup = group;
107
                if (previewFrame == null || !previewFrame.isVisible()) {
107
                if (ComponentCreatePanel.this.previewFrame == null || !ComponentCreatePanel.this.previewFrame.isVisible()) {
108
                    previewFrame = new JFrame();
108
                    ComponentCreatePanel.this.previewFrame = new JFrame();
109
                    previewFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
109
                    ComponentCreatePanel.this.previewFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
110
                    previewFrame.setTitle("Preview: " + group.getId());
110
                    ComponentCreatePanel.this.previewFrame.setTitle("Preview: " + group.getId());
111
                }
111
                }
112
                final EditPanel panel = new EditPanel(gComponent, EditMode.CREATION);
112
                final EditPanel panel = new EditPanel(gComponent, EditMode.CREATION);
113
                previewFrame.setContentPane(panel);
113
                ComponentCreatePanel.this.previewFrame.setContentPane(panel);
114
                previewFrame.pack();
114
                ComponentCreatePanel.this.previewFrame.pack();
115
                if (!previewFrame.isVisible()) {
115
                if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
116
                    FrameUtil.show(previewFrame);
116
                    FrameUtil.show(ComponentCreatePanel.this.previewFrame);
117
                }
117
                }
118
 
118
 
119
            };
119
            };
120
 
120
 
121
        });
121
        });
122
        n.addGroupChangeListener(new ChangeListener() {
122
        n.addGroupChangeListener(new ChangeListener() {
123
 
123
 
124
            @Override
124
            @Override
125
            public void stateChanged(ChangeEvent e) {
125
            public void stateChanged(ChangeEvent e) {
126
                if (previewFrame == null || !previewFrame.isVisible()) {
126
                if (ComponentCreatePanel.this.previewFrame == null || !ComponentCreatePanel.this.previewFrame.isVisible()) {
127
                    return;
127
                    return;
128
                }
128
                }
129
                final Group group = panel.getFilteredGroup();
129
                final Group group = ComponentCreatePanel.this.panel.getFilteredGroup();
130
                if (group.equalsDesc(oldGroup)) {
130
                if (group.equalsDesc(ComponentCreatePanel.this.oldGroup)) {
131
                    // Avoid refresh when group doesn't change
131
                    // Avoid refresh when group doesn't change
132
                    return;
132
                    return;
133
                }
133
                }
134
                oldGroup = group;
134
                ComponentCreatePanel.this.oldGroup = group;
135
                final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
135
                final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
136
                if (t == null) {
136
                if (t == null) {
137
                    return;
137
                    return;
138
                }
138
                }
139
                final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
139
                final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
140
                final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
140
                final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
141
                previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
141
                ComponentCreatePanel.this.previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
142
                previewFrame.pack();
142
                ComponentCreatePanel.this.previewFrame.pack();
143
                if (!previewFrame.isVisible()) {
143
                if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
144
                    FrameUtil.show(previewFrame);
144
                    FrameUtil.show(ComponentCreatePanel.this.previewFrame);
145
                }
145
                }
146
 
146
 
147
            }
147
            }
148
        });
148
        });
149
    }
149
    }