Revision 8127 trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationNadgridsPanel.java

View differences:

TransformationNadgridsPanel.java
6 6
import java.awt.FlowLayout;
7 7
import java.awt.GridLayout;
8 8
import java.awt.event.ActionEvent;
9
import java.awt.event.ActionListener;
9 10
import java.io.File;
10 11

  
11 12
import javax.swing.BorderFactory;
......
29 30
import com.iver.andami.ui.mdiManager.IWindow;
30 31
import com.iver.andami.ui.mdiManager.WindowInfo;
31 32

  
32
public class TransformationNadgridsPanel extends DefaultDialogPanel implements IWindow {
33
public class TransformationNadgridsPanel extends DefaultDialogPanel implements IWindow, ActionListener {
33 34
	
34 35
	private static final long serialVersionUID = 1L;
35 36
	
......
98 99
			sourceRadioButton = new JRadioButton();
99 100
			sourceRadioButton.setText(PluginServices.getText(this,"Aplicar a fuente"));//setText("By Code EPSG");
100 101
			sourceRadioButton.setSelected(true);
101
			sourceRadioButton.addActionListener(new java.awt.event.ActionListener() { 
102
				public void actionPerformed(java.awt.event.ActionEvent e) {    
103
					sourceRadioButton_actionPerformed(e);
104
				}
105
			});
102
			sourceRadioButton.addActionListener(this);
106 103
		}
107 104
		return sourceRadioButton;
108 105
	}
109 106
	
110
	private void sourceRadioButton_actionPerformed(ActionEvent e) {		
111
		sourceRadioButton.setSelected(true);
112
		targetRadioButton.setSelected(false);
113
	}
114 107
	
115 108
	private JRadioButton getNadgridsTarget() {		
116 109
		if (targetRadioButton == null) {
117 110
			targetRadioButton = new JRadioButton();
118 111
			targetRadioButton.setText(PluginServices.getText(this,"Aplicar a destino"));//setText("By Code EPSG");
119 112
			targetRadioButton.setSelected(false);
120
			targetRadioButton.addActionListener(new java.awt.event.ActionListener() { 
121
				public void actionPerformed(java.awt.event.ActionEvent e) {    
122
					targetRadioButton_actionPerformed(e);
123
				}
124
			});
113
			targetRadioButton.addActionListener(this);
125 114
		}
126 115
		return targetRadioButton;
127
	}
116
	}	
128 117
	
129
	private void targetRadioButton_actionPerformed(ActionEvent e) {		
130
		targetRadioButton.setSelected(true);
131
		sourceRadioButton.setSelected(false);
132
	}
133
	
134 118
	private JLabel getJLabel(){
135 119
		chooserLabel = new JLabel();
136 120
		chooserLabel.setPreferredSize(new Dimension(400, 20));
......
221 205
			jButtonOpen = new JButton();
222 206
			jButtonOpen.setText("");
223 207
			jButtonOpen.setPreferredSize(new Dimension(20,20));
224
			jButtonOpen.addActionListener(new java.awt.event.ActionListener() { 
225
				public void actionPerformed(java.awt.event.ActionEvent e) {    
226
					Open_actionPerformed(e);
227
				}
228
			});
208
			jButtonOpen.addActionListener(this);
229 209
		}
230 210
		return jButtonOpen;
231 211
	}
232 212
	
233
	private void Open_actionPerformed(ActionEvent e){
234
		jPaneOpen.add(getOpen(), null);
235
		openChooser.setCurrentDirectory(f);
236
		int returnVal = openChooser.showOpenDialog(TransformationNadgridsPanel.this);
237
        if (returnVal == JFileChooser.APPROVE_OPTION) {
238
            File file = openChooser.getSelectedFile();
239
            jTextOpen.setText(file.getAbsolutePath());
240
        }
241
    }
242
	
243 213
	public ICrs getProjection() {
244 214
		ICrs crs;
245 215
		if (sourceRadioButton.isSelected()){
......
302 272
   		m_viewinfo.setTitle(PluginServices.getText(this,"Nadgrids"));
303 273
		return m_viewinfo;
304 274
	}
275

  
276
	public void actionPerformed(ActionEvent e) {
277
		// TODO Auto-generated method stub
278
		if (e.getSource() == this.getNadgridsSource()){
279
			sourceRadioButton.setSelected(true);
280
			targetRadioButton.setSelected(false);
281
		}
282
		
283
		if (e.getSource() == this.getNadgridsTarget()){
284
			targetRadioButton.setSelected(true);
285
			sourceRadioButton.setSelected(false);
286
		}
287
		
288
		if (e.getSource() == this.getButtonOpen()){
289
			jPaneOpen.add(getOpen(), null);
290
			openChooser.setCurrentDirectory(f);
291
			int returnVal = openChooser.showOpenDialog(TransformationNadgridsPanel.this);
292
	        if (returnVal == JFileChooser.APPROVE_OPTION) {
293
	            File file = openChooser.getSelectedFile();
294
	            jTextOpen.setText(file.getAbsolutePath());
295
	        }
296
		}
297
	}
305 298
}
299

  
300
class FiltroNadgrids extends FileFilter {
301

  
302
	 final static String gsb = "gsb";
303
	
304
	public boolean accept(File f) {
305
		if (f.isDirectory()) {
306
           return true;
307
       }
308

  
309
       String s = f.getName();
310
       int i = s.lastIndexOf('.');
311

  
312
       if (i > 0 &&  i < s.length() - 1) {
313
           String extension = s.substring(i+1).toLowerCase();
314
           if (gsb.equals(extension)){
315
                   return true;
316
           } else {
317
               return false;
318
           }
319
       }
320

  
321
       return false;
322
	}
323

  
324
	public String getDescription() {
325
		 return "Archivos .gsb";
326
	}
327

  
328
}

Also available in: Unified diff