Revision 37780 branches/v2_0_0_prep/libraries/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.impl/src/main/java/org/gvsig/exportto/swing/impl/panel/ExportFilterPanel.java

View differences:

ExportFilterPanel.java
43 43
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel;
44 44
import org.gvsig.exportto.swing.impl.panel.ExportFiltersListModel.Filter;
45 45

  
46

  
47 46
/**
48 47
 * @author gvSIG Team
49 48
 * @version $Id$
50
 *
49
 * 
51 50
 */
52
public class ExportFilterPanel extends AbstractExporttoPanel implements ListSelectionListener, ItemListener{
51
public class ExportFilterPanel extends AbstractExporttoPanel implements
52
    ListSelectionListener, ItemListener {
53

  
53 54
    private static final long serialVersionUID = -7108159123965667106L;
54 55

  
55
    private static final ExporttoManager EXPORTTO_MANAGER = ExporttoLocator.getManager();
56
    
56
    private static final ExporttoManager EXPORTTO_MANAGER = ExporttoLocator
57
        .getManager();
58

  
57 59
    private ButtonGroup selectionButtonGroup;
58 60
    private JRadioButton allLayerRadioButton;
59 61
    private JRadioButton selectedFeaturesRabioButton;
60 62
    private JRadioButton personalizedFilterRabioButton;
61
    
63

  
62 64
    private JPanel filterPanel;
63 65

  
64 66
    private JPanel predefinedFilterPanel;
......
79 81
        GridBagConstraints gridBagConstraints;
80 82
        setLayout(new GridBagLayout());
81 83

  
82
        //Adding the radio buttons to the button group        
83
        allLayerRadioButton = new JRadioButton();       
84
        allLayerRadioButton.setSelected(true);        
84
        // Adding the radio buttons to the button group
85
        allLayerRadioButton = new JRadioButton();
86
        allLayerRadioButton.setSelected(true);
85 87
        selectedFeaturesRabioButton = new JRadioButton();
86 88
        personalizedFilterRabioButton = new JRadioButton();
87
        
89

  
88 90
        allLayerRadioButton.addItemListener(this);
89 91
        selectedFeaturesRabioButton.addItemListener(this);
90 92
        personalizedFilterRabioButton.addItemListener(this);
91
        
93

  
92 94
        selectionButtonGroup = new ButtonGroup();
93 95
        selectionButtonGroup.add(allLayerRadioButton);
94
        selectionButtonGroup.add(selectedFeaturesRabioButton);    
95
        selectionButtonGroup.add(personalizedFilterRabioButton);    
96
        selectionButtonGroup.add(selectedFeaturesRabioButton);
97
        selectionButtonGroup.add(personalizedFilterRabioButton);
96 98

  
97
        allLayerRadioButton.setText(exporttoServicePanel.getExporttoSwingManager().getTranslation("all_layer"));
99
        allLayerRadioButton.setText(exporttoServicePanel
100
            .getExporttoSwingManager().getTranslation("all_layer"));
98 101
        gridBagConstraints = new GridBagConstraints();
99 102
        gridBagConstraints.gridx = 0;
100 103
        gridBagConstraints.gridy = 0;
......
103 106
        gridBagConstraints.weightx = 1.0;
104 107
        add(allLayerRadioButton, gridBagConstraints);
105 108

  
106
        selectedFeaturesRabioButton.setText(exporttoServicePanel.getExporttoSwingManager().getTranslation("selected_features"));
109
        selectedFeaturesRabioButton.setText(exporttoServicePanel
110
            .getExporttoSwingManager().getTranslation("selected_features"));
107 111
        gridBagConstraints = new GridBagConstraints();
108 112
        gridBagConstraints.gridx = 0;
109 113
        gridBagConstraints.gridy = 1;
......
111 115
        gridBagConstraints.anchor = GridBagConstraints.WEST;
112 116
        gridBagConstraints.weightx = 1.0;
113 117
        add(selectedFeaturesRabioButton, gridBagConstraints);
114
        
115
        personalizedFilterRabioButton.setText(exporttoServicePanel.getExporttoSwingManager().getTranslation("filter"));
118

  
119
        personalizedFilterRabioButton.setText(exporttoServicePanel
120
            .getExporttoSwingManager().getTranslation("filter"));
116 121
        gridBagConstraints = new GridBagConstraints();
117 122
        gridBagConstraints.gridx = 0;
118 123
        gridBagConstraints.gridy = 2;
......
121 126
        gridBagConstraints.weightx = 1.0;
122 127
        add(personalizedFilterRabioButton, gridBagConstraints);
123 128

  
124
        //Create the filter panel
129
        // Create the filter panel
125 130
        filterPanel = new JPanel();
126 131
        filterPanel.setLayout(new GridBagLayout());
127
        
128
        //Create the predefined filter panel
132

  
133
        // Create the predefined filter panel
129 134
        predefinedFilterPanel = new JPanel();
130 135
        predefinedFilterScrollPane = new JScrollPane();
131
        predefinedFilterPanel.setBorder(new TitledBorder(exporttoServicePanel.getExporttoSwingManager().getTranslation("predefined_filters")));
136
        predefinedFilterPanel.setBorder(new TitledBorder(exporttoServicePanel
137
            .getExporttoSwingManager().getTranslation("predefined_filters")));
132 138
        predefinedFilterList = new JList();
133
        predefinedFilterList.setModel(new ExportFiltersListModel(exporttoServicePanel));
139
        predefinedFilterList.setModel(new ExportFiltersListModel(
140
            exporttoServicePanel));
134 141
        predefinedFilterList.addListSelectionListener(this);
135
        
142

  
136 143
        predefinedFilterPanel.setLayout(new GridBagLayout());
137 144
        predefinedFilterScrollPane.setViewportView(predefinedFilterList);
138 145

  
......
142 149
        gridBagConstraints.fill = GridBagConstraints.BOTH;
143 150
        gridBagConstraints.weightx = 1.0;
144 151
        gridBagConstraints.weighty = 1.0;
145
        predefinedFilterPanel.add(predefinedFilterScrollPane, gridBagConstraints);
152
        predefinedFilterPanel.add(predefinedFilterScrollPane,
153
            gridBagConstraints);
146 154

  
147 155
        gridBagConstraints = new GridBagConstraints();
148 156
        gridBagConstraints.gridx = 0;
......
151 159
        gridBagConstraints.weightx = 1.0;
152 160
        gridBagConstraints.weighty = 1.0;
153 161
        filterPanel.add(predefinedFilterPanel, gridBagConstraints);
154
        
155
        //Create the free filter panel        
162

  
163
        // Create the free filter panel
156 164
        freeFilterPanel = new JPanel();
157 165
        freeFilterScrollPane = new JScrollPane();
158
        freeFilterPanel.setBorder(new TitledBorder(exporttoServicePanel.getExporttoSwingManager().getTranslation("free_filter")));
159
        freeFilterTextArea = new JTextArea();     
166
        freeFilterPanel.setBorder(new TitledBorder(exporttoServicePanel
167
            .getExporttoSwingManager().getTranslation("free_filter")));
168
        freeFilterTextArea = new JTextArea();
160 169

  
161 170
        freeFilterPanel.setLayout(new GridBagLayout());
162 171
        freeFilterScrollPane.setViewportView(freeFilterTextArea);
163
        
172

  
164 173
        gridBagConstraints = new GridBagConstraints();
165 174
        gridBagConstraints.gridx = 0;
166 175
        gridBagConstraints.gridy = 0;
......
175 184
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
176 185
        gridBagConstraints.weightx = 1.0;
177 186
        gridBagConstraints.weighty = 1.0;
178
        filterPanel.add(freeFilterPanel, gridBagConstraints);       
187
        filterPanel.add(freeFilterPanel, gridBagConstraints);
179 188

  
180
        //Add the filter panel
189
        // Add the filter panel
181 190
        gridBagConstraints = new GridBagConstraints();
182 191
        gridBagConstraints.gridx = 0;
183 192
        gridBagConstraints.gridy = 3;
......
186 195
        gridBagConstraints.weightx = 1.0;
187 196
        gridBagConstraints.weighty = 1.0;
188 197
        add(filterPanel, gridBagConstraints);
189
       
198

  
190 199
    }
191
    
192
    public boolean isFullLayerSelected(){
200

  
201
    public boolean isFullLayerSelected() {
193 202
        return allLayerRadioButton.isSelected();
194 203
    }
195
    
196
    public boolean isSelectedFeaturesSelected(){
204

  
205
    public boolean isSelectedFeaturesSelected() {
197 206
        return selectedFeaturesRabioButton.isSelected();
198 207
    }
199
    
200
    public boolean isPersonalizedFilterSelected(){
208

  
209
    public boolean isPersonalizedFilterSelected() {
201 210
        return personalizedFilterRabioButton.isSelected();
202 211
    }
203
    
204
    public String getFreeFilter(){
205
        if ((freeFilterTextArea.getText() != null) && (!freeFilterTextArea.getText().equals(""))){
212

  
213
    public String getFreeFilter() {
214
        if ((freeFilterTextArea.getText() != null)
215
            && (!freeFilterTextArea.getText().equals(""))) {
206 216
            return freeFilterTextArea.getText();
207 217
        }
208 218
        return null;
209 219
    }
210 220

  
211 221
    public void valueChanged(ListSelectionEvent e) {
212
       Object obj = predefinedFilterList.getSelectedValue();
213
       if (obj != null){
214
           Filter filter = (Filter)obj;
215
           this.freeFilterTextArea.setText(EXPORTTO_MANAGER.getFilter(filter.getFilterKey()));
216
       }
222
        Object obj = predefinedFilterList.getSelectedValue();
223
        if (obj != null) {
224
            Filter filter = (Filter) obj;
225
            this.freeFilterTextArea.setText(EXPORTTO_MANAGER.getFilter(filter
226
                .getFilterKey()));
227
        }
217 228
    }
218 229

  
219 230
    public void stateChanged(ChangeEvent e) {
220 231
        // TODO Auto-generated method stub
221
        
232

  
222 233
    }
223 234

  
224 235
    public void itemStateChanged(ItemEvent e) {
225
       predefinedFilterList.setEnabled(isPersonalizedFilterSelected());     
226
       freeFilterTextArea.setEnabled(isPersonalizedFilterSelected());
227
    }       
236
        predefinedFilterList.setEnabled(isPersonalizedFilterSelected());
237
        freeFilterTextArea.setEnabled(isPersonalizedFilterSelected());
238
    }
228 239
}

Also available in: Unified diff