svn-gvsig-desktop / tags / v1_0_2_Build_911 / extensions / extRasterTools / src / org / gvsig / rasterTools / saveRaster / ui / properties / SaveRasterPropsDialog.java @ 11388
History | View | Annotate | Download (3.75 KB)
1 |
/*
|
---|---|
2 |
* Creado el 7-marzo-2005
|
3 |
*/
|
4 |
package org.gvsig.rasterTools.saveRaster.ui.properties; |
5 |
|
6 |
import java.awt.Container; |
7 |
import java.awt.event.ActionEvent; |
8 |
|
9 |
import javax.swing.JDialog; |
10 |
|
11 |
import org.cresques.io.CXMLParser; |
12 |
import org.cresques.io.GeoRasterWriter; |
13 |
import org.gvsig.rasterTools.saveRaster.ui.main.SaveRasterDefaultPanel; |
14 |
|
15 |
|
16 |
|
17 |
/**
|
18 |
* Dialogo para abrir fichero.
|
19 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
20 |
*/
|
21 |
public class SaveRasterPropsDialog extends JDialog { |
22 |
|
23 |
//Ancho y alto ventana de propiedades de salvar a raster
|
24 |
private int widthWindow=386; |
25 |
private int heightWindow=310; |
26 |
|
27 |
private SaveRasterPropsDialogPanel contentPane = null; |
28 |
private GeoRasterWriter writer=null; |
29 |
private String formato = null; |
30 |
private String[] properties = null; |
31 |
private SaveRasterDefaultPanel parentDialog = null; |
32 |
|
33 |
/**
|
34 |
* Constructor
|
35 |
* @param writer
|
36 |
*/
|
37 |
public SaveRasterPropsDialog(GeoRasterWriter writer) {
|
38 |
super();
|
39 |
super.setModal(true); |
40 |
this.writer = writer;
|
41 |
this.formato = writer.getIdent();
|
42 |
//Obtenemos el tama?o de la ventana del XML generado por el driver
|
43 |
String xml = writer.getXMLPropertiesDialog();
|
44 |
if(xml!=null){ |
45 |
CXMLParser parser = new CXMLParser(xml);
|
46 |
widthWindow = Integer.parseInt(parser.getAttr("window","sizex")); |
47 |
heightWindow = Integer.parseInt(parser.getAttr("window","sizey")); |
48 |
} |
49 |
initialize(); |
50 |
} |
51 |
|
52 |
/**
|
53 |
* Inicializaci?n del dialogo
|
54 |
*
|
55 |
* @return javax.swing.JDialog
|
56 |
*/
|
57 |
private void initialize() { |
58 |
setBounds(0, 0, widthWindow, heightWindow); //Size Ventana |
59 |
setResizable(false);
|
60 |
setName("saveRasterProps");
|
61 |
setTitle("Propiedades de "+formato);
|
62 |
setContentPane(getContentPane()); |
63 |
//contentPane.getAcceptButton().setEnabled(false);
|
64 |
contentPane.getAcceptButton().addActionListener(new java.awt.event.ActionListener() {
|
65 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
66 |
acceptButtonActionPerformed(evt); |
67 |
closeJDialog(); |
68 |
} |
69 |
}); |
70 |
contentPane.getCancelButton().addActionListener(new java.awt.event.ActionListener() {
|
71 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
72 |
closeJDialog(); |
73 |
} |
74 |
}); |
75 |
contentPane.getApplyButton().addActionListener(new java.awt.event.ActionListener() {
|
76 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
77 |
acceptButtonActionPerformed(evt); |
78 |
} |
79 |
}); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* Asigna el dialogo padre a una variable.
|
84 |
* @param parentDialog Cuadro de dialogo padre.
|
85 |
*/
|
86 |
public void setParentDialog(SaveRasterDefaultPanel parentDialog){ |
87 |
this.parentDialog = parentDialog;
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* Inicializa contenPane
|
92 |
* @return Container
|
93 |
*/
|
94 |
public Container getContentPane() { |
95 |
if (contentPane == null) { |
96 |
contentPane = new SaveRasterPropsDialogPanel(writer);
|
97 |
} |
98 |
return contentPane;
|
99 |
} |
100 |
|
101 |
public void closeJDialog() { |
102 |
this.hide();
|
103 |
} |
104 |
|
105 |
|
106 |
/**
|
107 |
* Cuando se acepta se obtienen las propiedades seleccionadas
|
108 |
* @param e
|
109 |
*/
|
110 |
private void acceptButtonActionPerformed(ActionEvent e) { |
111 |
if(((SaveRasterPropsDialogPanel)getContentPane()).getListener().getProperties() != null){ |
112 |
properties = ((SaveRasterPropsDialogPanel)getContentPane()).getListener().getProperties(); |
113 |
//Salvamos las propiedades seleccionadas en el DriverProperties
|
114 |
parentDialog.driverProps.setProperties(writer.getIdent(), properties); |
115 |
for(int i = 0; i < properties.length; i++){ |
116 |
try{
|
117 |
if(properties[i].startsWith("BLOCKSIZE")) |
118 |
parentDialog.setSizeBlock(Integer.parseInt(properties[i].substring(properties[i].lastIndexOf("=") + 1, properties[i].length()))); |
119 |
}catch(NumberFormatException ex){ |
120 |
//No se ha podido parsear el dato. No asignar? el tama?o de bloque
|
121 |
} |
122 |
} |
123 |
} |
124 |
} |
125 |
} |