Revision 10626 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/panels/annotation/SelectAnnotationLayerNameAndField.java

View differences:

SelectAnnotationLayerNameAndField.java
14 14
import jwizardcomponent.JWizardComponents;
15 15
import jwizardcomponent.JWizardPanel;
16 16

  
17
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
17 18
import com.iver.andami.PluginServices;
18
import com.iver.cit.gvsig.fmap.DriverException;
19 19
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
20 20
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
21 21

  
22 22
public class SelectAnnotationLayerNameAndField extends JWizardPanel {
23 23
	private FLyrAnnotation layer;
24
	
24

  
25 25
	private JLabel lblDescription = null;
26 26
	private JLabel lblStep1 = null;
27 27
	private JLabel lblNewLayerName = null;
28 28
	private JLabel lblStep2 = null;
29
	private JLabel lblField = null;	
30
	
29
	private JLabel lblField = null;
30

  
31 31
	private JTextField txtNewLayerName = null;
32 32
	private JComboBox cmbField = null;
33
	
34
	
33

  
34

  
35 35
	private static final Rectangle lblDescriptionPosition = new Rectangle(4,4,355,75);
36 36

  
37 37
	private static final Rectangle lblStep1Position = new Rectangle(4,90,15,15);
38 38
	private static final Rectangle lblNewLayerNamePosition = new Rectangle(30,90,355,15);
39 39
	private static final Rectangle txtNewLayerNamePosition = new Rectangle(30,109,250,18);
40
	
41
	
40

  
41

  
42 42
	private static final Rectangle lblStep2Position = new Rectangle(4,135,15,12);
43 43
	private static final Rectangle lblFieldPosition = new Rectangle(30,135,355,30);
44 44
	private static final Rectangle cmbFieldPosition = new Rectangle(30,169,170,18);
45 45

  
46
	
47
	
48
	
46

  
47

  
48

  
49 49
	private class EventsListener implements CaretListener,ItemListener
50 50
	{
51 51
		public void caretUpdate(CaretEvent arg0) {
52 52
			updateButtonsState();
53 53
		}
54
		
54

  
55 55
		public void itemStateChanged(ItemEvent e) {
56 56
			updateButtonsState();
57 57
		}
58 58

  
59 59
	}
60
	
61
	
60

  
61

  
62 62
	private void updateButtonsState() {
63 63
		setBackButtonEnabled(false);
64 64
		boolean enabled =checkIsOkPanelData();
65 65
		setNextButtonEnabled(enabled);
66 66
		setFinishButtonEnabled(enabled);
67 67
	}
68
	
69
	
68

  
69

  
70 70
	private EventsListener eventsListener = new EventsListener();
71 71

  
72
	
72

  
73 73
	protected boolean checkIsOkPanelData() {
74 74
		if (txtNewLayerName.getText().trim().length() < 1) {
75 75
			return false;
......
79 79
		}
80 80
		return true;
81 81
	}
82
		
83
	
82

  
83

  
84 84
	public SelectAnnotationLayerNameAndField(JWizardComponents arg0,FLyrAnnotation layer) {
85
		super(arg0);	
85
		super(arg0);
86 86
		this.layer =layer;
87
		this.initialize();		
87
		this.initialize();
88 88
	}
89
	
89

  
90 90
	protected void initialize() {
91 91
		this.setLayout(null);
92 92
		this.setSize(new Dimension(358,263));
93
		this.addLabels();			
94
		
95
		this.add(getTxtNewLayerName(),null);		
93
		this.addLabels();
94

  
95
		this.add(getTxtNewLayerName(),null);
96 96
		this.add(getCmbField(),null);
97
		
97

  
98 98
		checkIsOkPanelData();
99 99
	}
100
	
100

  
101 101
	private JTextField getTxtNewLayerName() {
102 102
		if (this.txtNewLayerName == null) {
103 103
			this.txtNewLayerName = new JTextField();
......
107 107
		}
108 108
		return this.txtNewLayerName;
109 109
	}
110
	
110

  
111 111
	public String getNewLayerName() {
112 112
		return this.getTxtNewLayerName().getText();
113 113
	}
114
	
115
	
114

  
115

  
116 116
	private JComboBox getCmbField() {
117 117
		if (this.cmbField == null) {
118 118
			this.cmbField = new JComboBox();
......
120 120
			this.cmbField.setBounds(cmbFieldPosition);
121 121
			this.cmbField.addItemListener(this.eventsListener);
122 122
			this.cmbField.addItem("");
123
			
124
		
123

  
124

  
125 125
			try {
126 126
				SelectableDataSource dataSource = this.layer.getRecordset();
127
				
127

  
128 128
				String[] fieldsNames = dataSource.getFieldNames();
129
				
129

  
130 130
				for (int i=0; i < fieldsNames.length; i++) {
131 131
					this.cmbField.addItem(fieldsNames[i]);
132 132
				}
133
				
134
			} catch (DriverException e) {
133

  
134
			} catch (ReadDriverException e) {
135 135
				// TODO Auto-generated catch block
136 136
				e.printStackTrace();
137
			} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
138
				// TODO Auto-generated catch block
139
				e.printStackTrace();
140
			}			
141
			
137
			}
138

  
142 139
		}
143 140
		return this.cmbField;
144 141
	}
145
	
142

  
146 143
	public String getField() {
147 144
		return (String)this.getCmbField().getSelectedItem();
148 145
	}
149 146

  
150
	
151
	protected void addLabels() {		
147

  
148
	protected void addLabels() {
152 149
		this.lblDescription = new JLabel();
153 150
		this.lblStep1 = new JLabel();
154 151
		this.lblNewLayerName = new JLabel();
155 152
		this.lblStep2 = new JLabel();
156 153
		this.lblField= new JLabel();
157
		
158
		this.lblDescription.setText(PluginServices.getText(this,"descripcion_de_crear_capa_de_anotaciones"));		
154

  
155
		this.lblDescription.setText(PluginServices.getText(this,"descripcion_de_crear_capa_de_anotaciones"));
159 156
		this.lblStep1.setText("1.");
160 157
		this.lblNewLayerName.setText(PluginServices.getText(this,"introduzca_el_nombre_de_la_nueva_capa_de_anotaciones"));
161 158
		this.lblStep2.setText("2.");
162 159
		this.lblField.setText(PluginServices.getText(this,"seleccione_el_campo_de_texto_que_desea_que_se_utilize_para_mostrar_la_nueva_capa_virtual"));
163
		
160

  
164 161
		this.lblDescription.setBounds(lblDescriptionPosition);
165 162
		this.lblStep1.setBounds(lblStep1Position);
166 163
		this.lblNewLayerName.setBounds(lblNewLayerNamePosition);
167 164
		this.lblStep2.setBounds(lblStep2Position);
168
		this.lblField.setBounds(lblFieldPosition);		
169
		
170
		
165
		this.lblField.setBounds(lblFieldPosition);
166

  
167

  
171 168
		this.add(lblDescription,null);
172 169
		this.add(lblStep1,null);
173 170
		this.add(lblNewLayerName,null);
174 171
		this.add(lblStep2,null);
175
		this.add(lblField,null);		
176
		
172
		this.add(lblField,null);
173

  
177 174
	}
178
	
179
	
180 175

  
176

  
177

  
181 178
}

Also available in: Unified diff