root / tags / v1_1_Build_1004 / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / panels / ChooseWriteDriver.java @ 12319
History | View | Annotate | Download (3.76 KB)
1 |
package com.iver.cit.gvsig.gui.cad.panels; |
---|---|
2 |
|
3 |
import java.awt.event.InputMethodEvent; |
4 |
import java.awt.event.InputMethodListener; |
5 |
import java.beans.PropertyChangeEvent; |
6 |
import java.beans.PropertyChangeListener; |
7 |
|
8 |
import javax.swing.JComboBox; |
9 |
import javax.swing.JLabel; |
10 |
import javax.swing.JTextField; |
11 |
import javax.swing.event.CaretEvent; |
12 |
import javax.swing.event.CaretListener; |
13 |
|
14 |
import jwizardcomponent.JWizardComponents; |
15 |
import jwizardcomponent.JWizardPanel; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
19 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
20 |
|
21 |
/**
|
22 |
* @author fjp
|
23 |
*
|
24 |
* Panel para que el usuario seleccione el driver que va a utilizar para
|
25 |
* crear un tema desde cero.
|
26 |
*
|
27 |
*/
|
28 |
public class ChooseWriteDriver extends JWizardPanel { |
29 |
|
30 |
private JLabel lblSelecDriver = null; |
31 |
private JComboBox jCmbBoxDrivers = null; |
32 |
private String[] driverNames; |
33 |
private JLabel jLabel = null; |
34 |
private JTextField jTextLayerName = null; |
35 |
|
36 |
private class MyInputEventListener implements CaretListener |
37 |
{ |
38 |
public void caretUpdate(CaretEvent arg0) { |
39 |
if (jTextLayerName.getText().length() > 0) |
40 |
setNextButtonEnabled(true);
|
41 |
else
|
42 |
setNextButtonEnabled(false);
|
43 |
|
44 |
} |
45 |
|
46 |
} |
47 |
|
48 |
public ChooseWriteDriver(JWizardComponents wizardComponents, String title, String[] driverNames) { |
49 |
super(wizardComponents, title);
|
50 |
this.driverNames = driverNames;
|
51 |
initialize(); |
52 |
// TODO Auto-generated constructor stub
|
53 |
|
54 |
} |
55 |
|
56 |
public String getSelectedDriver() |
57 |
{ |
58 |
return (String) jCmbBoxDrivers.getSelectedItem(); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* This method initializes this
|
63 |
*
|
64 |
*/
|
65 |
private void initialize() { |
66 |
jLabel = new JLabel(); |
67 |
jLabel.setText(PluginServices.getText(this,"enter_layer_name")); |
68 |
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
69 |
jLabel.setBounds(new java.awt.Rectangle(15,7,241,15)); |
70 |
lblSelecDriver = new JLabel(); |
71 |
lblSelecDriver.setText(PluginServices.getText(this,"select_driver")); |
72 |
lblSelecDriver.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
73 |
lblSelecDriver.setBounds(new java.awt.Rectangle(15,68,245,15)); |
74 |
this.setLayout(null); |
75 |
this.setSize(new java.awt.Dimension(274,167)); |
76 |
this.add(jLabel, null); |
77 |
this.add(lblSelecDriver, null); |
78 |
this.add(getJCmbBoxDrivers(), null); |
79 |
this.add(getJTextLayerName(), null); |
80 |
|
81 |
|
82 |
} |
83 |
|
84 |
/**
|
85 |
* This method initializes jCmbBoxDrivers
|
86 |
*
|
87 |
* @return javax.swing.JComboBox
|
88 |
*/
|
89 |
private JComboBox getJCmbBoxDrivers() { |
90 |
if (jCmbBoxDrivers == null) { |
91 |
jCmbBoxDrivers = new JComboBox(driverNames); |
92 |
jCmbBoxDrivers.setBounds(new java.awt.Rectangle(15,93,240,19)); |
93 |
} |
94 |
return jCmbBoxDrivers;
|
95 |
} |
96 |
|
97 |
/* (non-Javadoc)
|
98 |
* @see jwizardcomponent.JWizardPanel#next()
|
99 |
*/
|
100 |
public void next() { |
101 |
super.next();
|
102 |
try {
|
103 |
JWizardPanel nextPanel = getWizardComponents().getCurrentPanel(); |
104 |
if (nextPanel instanceof ChooseGeometryType) |
105 |
{ |
106 |
ChooseGeometryType panel = (ChooseGeometryType) nextPanel; |
107 |
ISpatialWriter writer = (ISpatialWriter) LayerFactory.getDM().getDriver(getSelectedDriver()); |
108 |
panel.setDriver(writer); |
109 |
} |
110 |
} catch (Exception e) { |
111 |
// TODO Auto-generated catch block
|
112 |
e.printStackTrace(); |
113 |
} |
114 |
} |
115 |
|
116 |
public String getLayerName() { |
117 |
return jTextLayerName.getText();
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* This method initializes jTextLayerName
|
122 |
*
|
123 |
* @return javax.swing.JTextField
|
124 |
*/
|
125 |
private JTextField getJTextLayerName() { |
126 |
if (jTextLayerName == null) { |
127 |
jTextLayerName = new JTextField(); |
128 |
jTextLayerName.setBounds(new java.awt.Rectangle(15,30,244,20)); |
129 |
jTextLayerName.setText(PluginServices.getText(this,"new_layer")); |
130 |
jTextLayerName.setHorizontalAlignment(javax.swing.JTextField.LEFT); |
131 |
jTextLayerName.addCaretListener(new MyInputEventListener());
|
132 |
} |
133 |
return jTextLayerName;
|
134 |
} |
135 |
|
136 |
|
137 |
} // @jve:decl-index=0:visual-constraint="10,10"
|