Statistics
| Revision:

root / library / trunk / org.gvsig.chart / org.gvsig.chart.swing / org.gvsig.chart.swing.impl / src / main / java / org / gvsig / chart / swing / impl / editors / panels / DefaultChartServiceDataPanel.java @ 24

History | View | Annotate | Download (19.3 KB)

1
package org.gvsig.chart.swing.impl.editors.panels;
2

    
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.Font;
6
import java.awt.GridBagConstraints;
7
import java.awt.GridBagLayout;
8
import java.awt.Insets;
9
import java.awt.event.ActionEvent;
10
import java.awt.event.ActionListener;
11
import java.util.ArrayList;
12
import java.util.Iterator;
13
import java.util.List;
14

    
15
import javax.swing.ButtonGroup;
16
import javax.swing.DefaultComboBoxModel;
17
import javax.swing.JButton;
18
import javax.swing.JCheckBox;
19
import javax.swing.JComboBox;
20
import javax.swing.JLabel;
21
import javax.swing.JPanel;
22
import javax.swing.JRadioButton;
23
import javax.swing.JScrollPane;
24
import javax.swing.JTable;
25
import javax.swing.ListSelectionModel;
26
import javax.swing.table.DefaultTableModel;
27

    
28
import org.gvsig.chart.ChartProperties;
29
import org.gvsig.chart.ChartService;
30
import org.gvsig.chart.model.variables.RequiredField;
31
import org.gvsig.chart.renderer.ChartSerieEntity;
32
import org.gvsig.chart.swing.ChartSwingLocator;
33
import org.gvsig.chart.swing.ChartSwingManager;
34
import org.gvsig.chart.swing.editors.panels.ChartServiceDataPanel;
35
import org.gvsig.chart.swing.impl.editors.DefaultEditorChartServicePanel;
36
import org.gvsig.chart.swing.impl.utils.ColorEditor;
37
import org.gvsig.chart.swing.impl.utils.ColorRenderer;
38
import org.gvsig.tools.observer.Observable;
39
import org.gvsig.tools.observer.Observer;
40

    
41
public class DefaultChartServiceDataPanel extends JPanel implements ChartServiceDataPanel{
42

    
43
        /**
44
         * 
45
         */
46
        private static final long serialVersionUID = 3973104135478200344L;
47
        
48
        private List<JComboBox> cbos = new ArrayList<JComboBox>();
49
        
50
        private JComboBox cboTable;
51

    
52
        protected List<Observer> observers = new ArrayList<Observer>();
53

    
54
        public static final int MAIN_PANEL_WIDTH = 680;
55
        public static final int MAIN_PANEL_HEIGHT = 410;
56
        public static final int TABLE_WIDTH = 270;
57
        public static final int TABLE_HEIGHT = 150;
58
        
59
        private DefaultEditorChartServicePanel parentPanel;
60

    
61
        private JCheckBox chckbxUseSelectedRows;
62
        private JButton editSeriesButton;
63
        private JTable editSeriesTable;
64

    
65
        private DefaultTableModel editSeriesTableModel;
66
        private JLabel lblDataOrigin;
67

    
68
        private ChartSwingManager swingManager = ChartSwingLocator.getSwingManager().getChartSwingManager();
69

    
70
        private JRadioButton nullGroupIgnoredRb;
71

    
72
        private JRadioButton addInSpecialCategory;
73

    
74
        private JCheckBox cbSortedField;
75

    
76
        private boolean hasSortedField = false;
77

    
78
        private boolean allowOnlySelectedData;
79
        
80
        public DefaultChartServiceDataPanel(DefaultEditorChartServicePanel parent) {
81
                
82
                this.parentPanel = parent;
83
                
84
                ChartProperties cp = getChartProperties();
85
                GridBagLayout gridBagLayout = new GridBagLayout();
86
                /*gridBagLayout.columnWidths = new int[]{0, 0, 0, TABLE_WIDTH, 0, 0, 0, 0, 0,0};
87
                gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
88
                gridBagLayout.rowHeights = new int[8 + cp.getRequiredFields().size()+1];
89
                gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
90
                */setLayout(gridBagLayout);
91
                
92
                /*for(int i=0; i< 8 + cp.getRequiredFields().size()+1; i++){
93
                        gridBagLayout.rowHeights[i]=0;
94
                }
95
                gridBagLayout.rowHeights[8 + cp.getRequiredFields().size()]=TABLE_HEIGHT;
96
                */
97
                lblDataOrigin = new JLabel(this.swingManager.getTranslation("Data_origin"));
98
                GridBagConstraints gbc_lblDataOrigin = new GridBagConstraints();
99
                gbc_lblDataOrigin.anchor = GridBagConstraints.WEST;
100
                gbc_lblDataOrigin.gridwidth = 3;
101
                gbc_lblDataOrigin.insets = new Insets(0, 0, 5, 5);
102
                gbc_lblDataOrigin.gridx = 1;
103
                gbc_lblDataOrigin.gridy = 0;
104
                add(lblDataOrigin, gbc_lblDataOrigin);
105
                
106
                JLabel lblTable = new JLabel(this.swingManager.getTranslation("Table"));
107
                lblTable.setFont(new Font("Dialog", Font.PLAIN, 12));
108
                GridBagConstraints gbc_lblTable = new GridBagConstraints();
109
                gbc_lblTable.anchor = GridBagConstraints.WEST;
110
                gbc_lblTable.insets = new Insets(0, 0, 5, 5);
111
                gbc_lblTable.gridx = 1;
112
                gbc_lblTable.gridy = 1;
113
                add(lblTable, gbc_lblTable);
114
                
115
                cboTable = new JComboBox();
116
                cboTable.addActionListener(new ActionListener() {
117
                        public void actionPerformed(ActionEvent arg0) {
118
                                String tableName = (String) cboTable.getSelectedItem();
119
                                notifyObservers(DefaultChartServiceDataPanel.this, tableName);
120
                        }
121
                });
122
                GridBagConstraints gbc_cboTable = new GridBagConstraints();
123
                gbc_cboTable.gridwidth = 4;
124
                gbc_cboTable.insets = new Insets(0, 0, 5, 5);
125
                gbc_cboTable.fill = GridBagConstraints.HORIZONTAL;
126
                gbc_cboTable.gridx = 3;
127
                gbc_cboTable.gridy = 1;
128
                add(cboTable, gbc_cboTable);
129
                
130
                JLabel lblChartDataDefinition = new JLabel(this.swingManager.getTranslation("Chart_Data_Definition"));
131
                GridBagConstraints gbc_lblChartDataDefinition = new GridBagConstraints();
132
                gbc_lblChartDataDefinition.insets = new Insets(0, 0, 5, 0);
133
                gbc_lblChartDataDefinition.gridwidth = 6;
134
                gbc_lblChartDataDefinition.anchor = GridBagConstraints.WEST;
135
                gbc_lblChartDataDefinition.gridx = 1;
136
                gbc_lblChartDataDefinition.gridy = 3;
137
                add(lblChartDataDefinition, gbc_lblChartDataDefinition);
138
                
139
                this.initialize();
140
                
141
                chckbxUseSelectedRows = new JCheckBox(this.swingManager.getTranslation("use_selected_rows"));
142
                chckbxUseSelectedRows.addActionListener(new ActionListener() {
143
                        
144
                        public void actionPerformed(ActionEvent e) {
145
                                List<Color> colors = new ArrayList<Color>();
146
                                for(int index=0; index< editSeriesTable.getRowCount(); index++){
147
                                        colors.add((Color)editSeriesTable.getModel().getValueAt(index, 0));
148
                                }
149
                                refreshData();
150
                                if(colors.size()==editSeriesTable.getRowCount()){
151
                                        for(int index=0; index< editSeriesTable.getRowCount(); index++){
152
                                                editSeriesTable.getModel().setValueAt(colors.get(index), index, 0);
153
                                        }
154
                                }
155
                        }
156
                });
157
                chckbxUseSelectedRows.setFont(new Font("Dialog", Font.PLAIN, 12));
158
                if (cp.getUseSelectedFeatures())
159
                        chckbxUseSelectedRows.setSelected(true);
160
                
161
                GridBagConstraints gbc_chckbxUseSelectedRows = new GridBagConstraints();
162
                gbc_chckbxUseSelectedRows.anchor = GridBagConstraints.WEST;
163
                gbc_chckbxUseSelectedRows.gridwidth = 3;
164
                gbc_chckbxUseSelectedRows.insets = new Insets(0, 0, 5, 5);
165
                gbc_chckbxUseSelectedRows.gridx = 1;
166
                gbc_chckbxUseSelectedRows.gridy = 5 + cp.getRequiredFields().size();
167
                add(chckbxUseSelectedRows, gbc_chckbxUseSelectedRows);
168
                
169
                JLabel groupedOptionslabel = new JLabel(this.swingManager.getTranslation("grouped_options"));
170
                
171
                GridBagConstraints gbc_chckbxUseSelectedRows15 = new GridBagConstraints();
172
                gbc_chckbxUseSelectedRows15.anchor = GridBagConstraints.WEST;
173
                gbc_chckbxUseSelectedRows15.gridwidth = 3;
174
                gbc_chckbxUseSelectedRows15.insets = new Insets(0, 0, 5, 5);
175
                gbc_chckbxUseSelectedRows15.gridx = 1;
176
                gbc_chckbxUseSelectedRows15.gridy = 6 + cp.getRequiredFields().size();
177
                add(groupedOptionslabel, gbc_chckbxUseSelectedRows15);
178
                
179
                nullGroupIgnoredRb = new JRadioButton(this.swingManager.getTranslation("ignore_null_groups"));
180
                nullGroupIgnoredRb.addActionListener(new ActionListener() {
181
                        
182
                        public void actionPerformed(ActionEvent e) {
183
                                getChartProperties().setNullGroupIgnored(true);
184
                                refreshData();
185
                        }
186
                });
187
                nullGroupIgnoredRb.setFont(new Font("Dialog", Font.PLAIN, 12));
188

    
189
                
190
                GridBagConstraints gbc_chckbxUseSelectedRows2 = new GridBagConstraints();
191
                gbc_chckbxUseSelectedRows2.anchor = GridBagConstraints.WEST;
192
                gbc_chckbxUseSelectedRows2.gridwidth = 3;
193
                gbc_chckbxUseSelectedRows2.insets = new Insets(0, 0, 5, 5);
194
                gbc_chckbxUseSelectedRows2.gridx = 2;
195
                gbc_chckbxUseSelectedRows2.gridy = 6 + cp.getRequiredFields().size();
196
                add(nullGroupIgnoredRb, gbc_chckbxUseSelectedRows2);
197
                
198
                addInSpecialCategory = new JRadioButton(this.swingManager.getTranslation("add_null_in_special_category"));
199
                addInSpecialCategory.addActionListener(new ActionListener() {
200
                        
201
                        public void actionPerformed(ActionEvent e) {
202
                                getChartProperties().setNullGroupIgnored(false);
203
                                refreshData();
204
                        }
205
                });
206
                addInSpecialCategory.setFont(new Font("Dialog", Font.PLAIN, 12));
207

    
208
                
209
                GridBagConstraints gbc_chckbxUseSelectedRows3 = new GridBagConstraints();
210
                gbc_chckbxUseSelectedRows3.anchor = GridBagConstraints.WEST;
211
                gbc_chckbxUseSelectedRows3.gridwidth = 3;
212
                gbc_chckbxUseSelectedRows3.insets = new Insets(0, 0, 5, 5);
213
                gbc_chckbxUseSelectedRows3.gridx = 2;
214
                gbc_chckbxUseSelectedRows3.gridy = 7 + cp.getRequiredFields().size();
215
                add(addInSpecialCategory, gbc_chckbxUseSelectedRows3);
216
                
217
                ButtonGroup group = new ButtonGroup();
218
                group.add(nullGroupIgnoredRb);
219
                group.add(addInSpecialCategory);
220
                
221
                if (cp.getNullGroupIgnored()){
222
                        nullGroupIgnoredRb.setSelected(true);
223
                }else{
224
                        addInSpecialCategory.setSelected(true);
225
                }
226
                
227
                
228
//                editSeriesButton = new JButton(this.swingManager.getTranslation("Edit_Series_Values"));
229
//                editSeriesButton.addActionListener(new ActionListener() {
230
//                        public void actionPerformed(ActionEvent arg0) {
231
//                                listSeries();
232
//                        }
233
//                });
234
//                GridBagConstraints gbc_editSeriesButton = new GridBagConstraints();
235
//                gbc_editSeriesButton.anchor = GridBagConstraints.EAST;
236
//                gbc_editSeriesButton.gridwidth = 3;
237
//                gbc_editSeriesButton.insets = new Insets(0, 0, 5, 5);
238
//                gbc_editSeriesButton.gridx = 3;
239
//                gbc_editSeriesButton.gridy = 5 + getChartProperties().getRequiredFields().size();
240
//                add(editSeriesButton, gbc_editSeriesButton);
241
                
242
                editSeriesTable = new JTable(){
243
                                /**
244
                         * 
245
                         */
246
                        private static final long serialVersionUID = -7016858079737088567L;
247

    
248
                                public boolean isCellEditable(int rowIndex, int colIndex) {
249
                                        if (colIndex == 0)
250
                                                return true;
251
                                        return false; // Disallow the editing of any cell
252
                                }
253

    
254
                        };
255
                editSeriesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
256
                editSeriesTable.setColumnSelectionAllowed(false);
257
                editSeriesTable.setCellSelectionEnabled(false);
258
                JScrollPane editSeriesTableScroll = new JScrollPane(editSeriesTable);
259
                GridBagConstraints gbc_editSeriesTable = new GridBagConstraints();
260
                gbc_editSeriesTable.insets = new Insets(0, 0, 5, 0);
261
                gbc_editSeriesTable.gridheight = 3;
262
                gbc_editSeriesTable.gridwidth = 5;
263
                gbc_editSeriesTable.fill = GridBagConstraints.BOTH;
264
                gbc_editSeriesTable.weightx = 1.0;
265
                gbc_editSeriesTable.weighty = 1.0;
266
                gbc_editSeriesTable.gridx = 1;
267
                gbc_editSeriesTable.gridy = 8 + cp.getRequiredFields().size();
268
                add(editSeriesTableScroll, gbc_editSeriesTable);
269

    
270
                this.initializeTable();
271
                
272
                setPreferredSize(new Dimension(680, 478));
273
        }
274
        
275
        protected void refreshData() {
276
                getChartProperties().setUseSelectedFeatures(chckbxUseSelectedRows.isSelected());
277
                listSeries();
278
        }
279

    
280
        public void listSeries(){
281
                if(!parentPanel.getNewChartService().getChartLegendItems().isEmpty()){
282
                        fillTableData();
283
                }
284
                
285
                List<RequiredField> rfields = parentPanel.getNewChartService().getChartProperties().getRequiredFields();
286
                int index = -1;
287
                String previousSeriesField = null;
288
                Iterator<RequiredField> it = rfields.iterator();
289
                while(it.hasNext()){
290
                        RequiredField req = (RequiredField)it.next();
291
                        if(req.getName()== parentPanel.getNewChartService().getChartDataSet().getKeyField()){
292
                                index = rfields.indexOf((RequiredField)req);
293
                                previousSeriesField = req.getValue();
294
                        }
295
                }
296
                String currentSeriesField = null;
297
                if(index != -1){
298
                        if(cbos.get(index).getSelectedItem()!= null)
299
                                currentSeriesField = cbos.get(index).getSelectedItem().toString();
300
                }
301
                
302
                /*
303
                 * Si se ha cambiado el campo, o las series est?n por cargar
304
                 */
305
//                if((currentSeriesField != null && 
306
//                                !(currentSeriesField.equals(previousSeriesField))) ||
307
//                                parentPanel.getNewChartService().getChartLegendItems().isEmpty()){
308
                        registerParameters();
309
                        notifyObservers(DefaultChartServiceDataPanel.this, parentPanel.getNewChartService());
310
                        parentPanel.getNewChartService().update();
311
                        parentPanel.getNewChartService().createChartLegendItems();
312
                        fillTableData();
313
//                }
314
        }
315
        
316
        private void initialize() {
317
                ChartProperties chartProperties = getChartProperties();
318
                int i = 0;
319
                int j = 0;
320
                for (i = 0; i < chartProperties.getRequiredFields().size(); i++) {
321
                        RequiredField f = chartProperties.getRequiredFields().get(i);
322
                        
323
                        String name = f.getDescription();
324
                        if(f.isOptional()){
325
                                name += " ("+this.swingManager.getTranslation("optional")+")";
326
                        }
327
                        
328
                        JLabel lblNewLabel = new JLabel(name);
329
                        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
330
                        gbc_lblNewLabel.fill = GridBagConstraints.BOTH;
331
                        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
332
                        gbc_lblNewLabel.gridx = 1;
333
                        gbc_lblNewLabel.gridy = 4+i+j;
334
                        add(lblNewLabel, gbc_lblNewLabel);
335
                        
336
                        
337
                        JComboBox cboTableField = new JComboBox();
338
                        cboTableField.addActionListener(new ActionListener() {
339
                                public void actionPerformed(ActionEvent arg0) {
340
                                        listSeries();                        
341
                                        parentPanel.getChartServiceFormatPanel().refreshContent();
342
                                }
343
                        });
344
                        GridBagConstraints gbc_cboTable = new GridBagConstraints();
345
                        gbc_cboTable.gridwidth = 4;
346
                        gbc_cboTable.insets = new Insets(0, 0, 5, 5);
347
                        gbc_cboTable.fill = GridBagConstraints.HORIZONTAL;
348
                        gbc_cboTable.gridx = 3;
349
                        gbc_cboTable.gridy = 4+i+j;
350
                        add(cboTableField, gbc_cboTable);
351
                        
352
                        if(f.canBeSorted()){
353
                                cbSortedField = new JCheckBox(this.swingManager.getTranslation("ordered_field"));
354
                                GridBagConstraints gbc_cboSorted = new GridBagConstraints();
355
                                gbc_cboSorted.insets = new Insets(0, 0, 5, 5);
356
                                gbc_cboSorted.fill = GridBagConstraints.HORIZONTAL;
357
                                gbc_cboSorted.gridx = 3;
358
                                gbc_cboSorted.gridy = 5+i+j;
359
                                add(cbSortedField, gbc_cboSorted);
360
                                cbSortedField.setSelected(
361
                                                getParentPanel().getNewChartService().getChartDataSet().getIsSorted());
362
                                
363
                                this.hasSortedField = true;
364
                                j++;
365
                        }
366
                        
367
                        cbos.add(cboTableField);
368
                }
369

    
370
        }
371
        
372
        private void initializeTable() {
373
                String[] colName = { this.swingManager.getTranslation("Symbol"), 
374
                                this.swingManager.getTranslation("Series_name")};
375

    
376
                editSeriesTableModel = (DefaultTableModel) editSeriesTable.getModel();
377
                editSeriesTableModel.setColumnIdentifiers(colName);
378

    
379
                editSeriesTable.getColumnModel().getColumn(0).setPreferredWidth(50);
380
                
381
                editSeriesTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
382
                editSeriesTable.setDefaultEditor(Color.class, new ColorEditor());
383
                
384
                editSeriesTable.getColumnModel().getColumn(0)
385
                                .setCellEditor(editSeriesTable.getDefaultEditor(Color.class));
386
                editSeriesTable.getColumnModel().getColumn(0)
387
                                .setCellRenderer(editSeriesTable.getDefaultRenderer(Color.class));
388
                
389
        }
390

    
391
        public void fillTableData() {
392
                ChartService service = parentPanel.getNewChartService();
393
                List<ChartSerieEntity> legendItems = service.getChartLegendItems();
394
                
395
                if(legendItems!=null){
396
                        removeTable();
397
                        for(int k=0; k<legendItems.size(); k++){
398
                                if(legendItems.get(k)!=null){
399
                                        Object[] data = {
400
                                                        legendItems.get(k).getSeriePaint(),
401
                                                        legendItems.get(k).getSeriesName()
402
                                        };
403
                                        //renderer.setSeriesPaint(series, paint)
404
                                        ((DefaultTableModel) editSeriesTableModel).addRow(data);
405
                                }
406
                        }
407
                }
408
        //        List<ChartService> chartServices = getGroupedChart().getChartServices();
409
                
410
                editSeriesTable.revalidate();
411
                editSeriesTable.repaint();
412
        }
413
        
414
        public void removeTable() {
415
                int numRows = editSeriesTableModel.getRowCount();
416
                for (int i = numRows - 1; i >= 0; i--) {
417
                        editSeriesTableModel.removeRow(i);
418
                }
419
        }
420
        
421
        /**
422
         * TODO Check if the values have the correct format
423
         * @return boolean
424
         */
425
        public boolean validateValues() {
426
                // TODO Auto-generated method stub
427
                return true;
428
        }
429
        
430
        public void acceptForm(){
431
                
432
                ChartService service = parentPanel.getNewChartService();
433
                if(service.getChartDataSet().getSeries().isEmpty()){
434
                        listSeries();
435
                }
436
                if(this.hasSortedField ){
437
                        service.getChartDataSet().setIsSorted(cbSortedField.isSelected());
438
                }
439
                service.getChartProperties().setNullGroupIgnored(nullGroupIgnoredRb.isSelected());
440
                registerParameters();
441
        }
442
        
443
        /**
444
         * Stores the information from swing controls to ChartProperties
445
         * in order to be usable by chart services.
446
         */
447
        public void registerParameters(){
448
                ChartProperties chartProperties = getChartProperties();
449
                //Rellenamos los datos del panel actual
450
                chartProperties.setChartTableName((String)cboTable.getSelectedItem());
451
                for (int i = 0; i < chartProperties.getRequiredFields().size(); i++) {
452
                        RequiredField f = chartProperties.getRequiredFields().get(i);
453
                        JComboBox cbo = cbos.get(i);
454
                        f.setValue((String) cbo.getSelectedItem());
455
                }
456
                chartProperties.setUseSelectedFeatures(chckbxUseSelectedRows.isSelected());
457
                
458
                ChartService service = parentPanel.getNewChartService();
459
                if(service.getChartLegendItems().size() == editSeriesTableModel.getRowCount()){
460
                        for(int j=0; j<service.getChartLegendItems().size();j++){
461
                                Color color = (Color) editSeriesTableModel.getValueAt(j, 0);
462
                                service.getChartLegendItems().get(j).setSeriePaint(color);
463
                        }
464
                }
465
        }
466

    
467
        public synchronized void deleteObserver(Observer o) {
468
                this.observers.remove(o);
469
        }
470

    
471
        public synchronized void deleteObservers() {
472
                this.observers = new ArrayList<Observer>();
473
        }
474

    
475
        public synchronized void notifyObservers(Observable observable, Object tableName) {
476
                for(int i =0; i<this.observers.size(); i++ ) {
477
                        Observer o = (Observer) this.observers.get(i);
478
                        o.update(this, tableName);
479
                }
480
        }
481

    
482
        public void addObserver(Observer o) {
483
                this.observers.add(o);
484
        }
485

    
486
        public void setTableNameModel(List<String> model) {
487
                DefaultComboBoxModel cboModel = new DefaultComboBoxModel(model.toArray());
488
                cboTable.setModel(cboModel);
489
        }
490

    
491
        public void setSelectedTableName(String tableName) {
492
                cboTable.setSelectedItem(tableName);
493
        }
494

    
495
        public void setRequiredFieldModel(List<RequiredField> rFields, RequiredField rf, List<String> model, boolean active) {
496
                int index = rFields.indexOf(rf);
497
                DefaultComboBoxModel cboModel = new DefaultComboBoxModel(model.toArray());
498
                cbos.get(index).setEnabled(active);
499
                nullGroupIgnoredRb.setEnabled(active);
500
                chckbxUseSelectedRows.setEnabled(active);
501
                addInSpecialCategory.setEnabled(active);
502
                if(allowOnlySelectedData){
503
                        setOnlySelectedRows(allowOnlySelectedData);
504
                }
505
                if(cbSortedField != null){
506
                        cbSortedField.setEnabled(active);
507
                }
508
                editSeriesTable.setEnabled(active);
509
                
510
                if(cbos.size()>=index){
511
                        cbos.get(index).setModel(cboModel);
512
                }
513
        }
514

    
515
        public void setSelectedRequiredField(List<RequiredField> rFields, RequiredField rf, String name, boolean active) {
516
                int index = rFields.indexOf(rf);
517
                if(cbos.size()>=index){
518
                        ActionListener[] listeners = cbos.get(index).getActionListeners();
519
                        for(int l=0; l<listeners.length;l++){
520
                                cbos.get(index).removeActionListener(listeners[l]);
521
                        }
522
                        cbos.get(index).setSelectedItem(name);
523
                        cbos.get(index).setEnabled(active);
524
                        nullGroupIgnoredRb.setEnabled(active);
525
                        chckbxUseSelectedRows.setEnabled(active);
526
                        addInSpecialCategory.setEnabled(active);
527
                        if(allowOnlySelectedData){
528
                                setOnlySelectedRows(allowOnlySelectedData);
529
                        }
530
                        if(cbSortedField != null){
531
                                cbSortedField.setEnabled(active); 
532
                        }
533
                        editSeriesTable.setEnabled(active);
534
                        if(active){
535
                                cbos.get(index).addActionListener(new ActionListener() {
536
                                        public void actionPerformed(ActionEvent arg0) {
537
                                                listSeries();                                        
538
                                        }
539
                                });
540
                        }
541
                }
542
        }
543

    
544
        public DefaultEditorChartServicePanel getParentPanel() {
545
                return parentPanel;
546
        }
547

    
548

    
549
        public ChartProperties getChartProperties() {
550
                return getParentPanel().getNewChartService().getChartProperties();
551
        }
552
        
553
        public ChartProperties getPreviousChartProperties(){
554
                if(getParentPanel().getPreviousChartService() == null){
555
                        return this.getChartProperties();
556
                }
557
                return getParentPanel().getPreviousChartService().getChartProperties();
558
        }
559

    
560
        public boolean getOnlySelectedRows() {
561
                return chckbxUseSelectedRows.isSelected();
562
        }
563

    
564
        public void setOnlySelectedRows(boolean selected) {
565
                if(selected){
566
                        chckbxUseSelectedRows.setSelected(selected);
567
                }
568
                this.allowOnlySelectedData = selected;
569
                chckbxUseSelectedRows.setEnabled(!selected);
570
        }
571

    
572
}