Revision 6828 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/panels/FPanelCreateField.java

View differences:

FPanelCreateField.java
60 60
import com.iver.andami.ui.mdiManager.View;
61 61
import com.iver.andami.ui.mdiManager.ViewInfo;
62 62
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
63
import java.awt.GridLayout;
63 64

  
64 65
public class FPanelCreateField extends JPanel implements View {
65 66

  
......
76 77
	private ViewInfo viewInfo;
77 78
	private JPanel jPanel = null;  //  @jve:decl-index=0:visual-constraint="299,27"
78 79
	private AcceptCancelPanel jPanelOkCancel = null;
80
	private JPanel jPnlFields = null;
79 81
	public FPanelCreateField() {
80 82
		super();
81 83
		// TODO Auto-generated constructor stub
......
104 106
		if (viewInfo == null)
105 107
		{
106 108
			viewInfo = new ViewInfo(ViewInfo.MODALDIALOG);
109
			viewInfo.setWidth(this.getWidth()+8);
110
			viewInfo.setHeight(this.getHeight());
111
			viewInfo.setTitle(PluginServices.getText(this, "field_properties"));
107 112
		}
108 113
		return viewInfo;
109 114
	}
110 115

  
111 116
	/**
112 117
	 * This method initializes this
113
	 * 
118
	 *
114 119
	 * @return void
115 120
	 */
116 121
	private void initialize() {
117
		
122

  
118 123
		this.setLayout(new BorderLayout());
119
		this.setSize(300, 250);
120
		this.setPreferredSize(new java.awt.Dimension(400,300));
124
		this.setSize(300, 210);
125
		this.setPreferredSize(new java.awt.Dimension(300,210));
121 126
		this.add(getJPanel(), java.awt.BorderLayout.CENTER);
122 127
		this.add(getJPanelOkCancel(), java.awt.BorderLayout.SOUTH);
123
		
128

  
124 129
	}
125 130

  
126 131
	/**
127
	 * This method initializes jTxtFieldName	
128
	 * 	
129
	 * @return javax.swing.JTextField	
132
	 * This method initializes jTxtFieldName
133
	 *
134
	 * @return javax.swing.JTextField
130 135
	 */
131 136
	private JTextField getJTxtFieldName() {
132 137
		if (jTxtFieldName == null) {
......
137 142
	}
138 143

  
139 144
	/**
140
	 * This method initializes jCboFieldType	
141
	 * 	
142
	 * @return javax.swing.JComboBox	
145
	 * This method initializes jCboFieldType
146
	 *
147
	 * @return javax.swing.JComboBox
143 148
	 */
144 149
	private JComboBox getJCboFieldType() {
145 150
		if (jCboFieldType == null) {
......
150 155
			jCboFieldType.addItem("Integer");
151 156
			jCboFieldType.addItem("Double");
152 157
			jCboFieldType.addItem("String");
153
			
158

  
154 159
			jCboFieldType.setSelectedIndex(4);
155 160
			jCboFieldType.addActionListener(new java.awt.event.ActionListener() {
156 161
				public void actionPerformed(java.awt.event.ActionEvent e) {
......
165 170
					}
166 171
					else
167 172
						getJTxtFieldLength().setEnabled(true);
168
					
173

  
169 174
				}
170 175
			});
171
			
176

  
172 177
		}
173 178
		return jCboFieldType;
174 179
	}
175 180

  
176 181
	/**
177
	 * This method initializes jTxtFieldLength	
178
	 * 	
179
	 * @return javax.swing.JTextField	
182
	 * This method initializes jTxtFieldLength
183
	 *
184
	 * @return javax.swing.JTextField
180 185
	 */
181 186
	private JTextField getJTxtFieldLength() {
182 187
		if (jTxtFieldLength == null) {
......
187 192
	}
188 193

  
189 194
	/**
190
	 * This method initializes jTxtFieldPrecision	
191
	 * 	
192
	 * @return javax.swing.JTextField	
195
	 * This method initializes jTxtFieldPrecision
196
	 *
197
	 * @return javax.swing.JTextField
193 198
	 */
194 199
	private JTextField getJTxtFieldPrecision() {
195 200
		if (jTxtFieldPrecision == null) {
......
201 206
	}
202 207

  
203 208
	/**
204
	 * This method initializes jTxtDefaultValue	
205
	 * 	
206
	 * @return javax.swing.JTextField	
209
	 * This method initializes jTxtDefaultValue
210
	 *
211
	 * @return javax.swing.JTextField
207 212
	 */
208 213
	private JTextField getJTxtDefaultValue() {
209 214
		if (jTxtDefaultValue == null) {
......
213 218
		return jTxtDefaultValue;
214 219
	}
215 220

  
216
	public FieldDescription getFieldDescription() throws ParseException 
221
	public FieldDescription getFieldDescription() throws ParseException
217 222
	{
218 223
		FieldDescription newField = new FieldDescription();
219 224
		newField.setFieldName(getJTxtFieldName().getText());
220 225
		String strType = (String) getJCboFieldType().getModel().getSelectedItem();
221 226
		int fieldType = FieldDescription.stringToType(strType);
222 227
		newField.setFieldType(fieldType);
223
		int fieldLength = Integer.parseInt(getJTxtFieldLength().getText());
224
		newField.setFieldLength(fieldLength);
228
		try {
229
			int fieldLength = Integer.parseInt(getJTxtFieldLength().getText());
230
			newField.setFieldLength(fieldLength);
231
		} catch (Exception e) {
232
			throw new ParseException(e.getMessage(), 0);
233
		}
234

  
225 235
		if (fieldType == Types.DOUBLE)
226 236
		{
227 237
			newField.setFieldDecimalCount(
......
230 240
		}
231 241
		else
232 242
			newField.setFieldDecimalCount(0);
233
		String defaultValue = getJTxtDefaultValue().getText(); 
243
		String defaultValue = getJTxtDefaultValue().getText();
234 244
		if (defaultValue != null)
235 245
		{
236
			
246

  
237 247
			if (defaultValue.compareTo("")==0)
238 248
				newField.setDefaultValue(ValueFactory.createNullValue());
239 249
			else
......
245 255

  
246 256
	public void setOkAction(ActionListener okAction) {
247 257
		getJPanelOkCancel().setOkButtonActionListener(okAction);
248
		
258

  
249 259
	}
250 260

  
251 261
	/**
252
	 * This method initializes jPanel	
253
	 * 	
254
	 * @return javax.swing.JPanel	
262
	 * This method initializes jPanel
263
	 *
264
	 * @return javax.swing.JPanel
255 265
	 */
256 266
	private JPanel getJPanel() {
257 267
		if (jPanel == null) {
258
			jLblDefaultValue = new JLabel();
259
			jLblDefaultValue.setBounds(new java.awt.Rectangle(14,163,125,22));
260
			jLblDefaultValue.setText("default_value");
261
			jLblFieldPrecision = new JLabel();
262
			jLblFieldPrecision.setBounds(new java.awt.Rectangle(14,126,112,22));
263
			jLblFieldPrecision.setText("precision");
264
			jLblFieldLength = new JLabel();
265
			jLblFieldLength.setBounds(new java.awt.Rectangle(14,89,99,22));
266
			jLblFieldLength.setText("field_length");
267
			jLblFieldType = new JLabel();
268
			jLblFieldType.setBounds(new java.awt.Rectangle(14,52,94,22));
269
			jLblFieldType.setText("field_type");
270
			jLblFieldName = new JLabel();
271
			jLblFieldName.setText("field_name");
272
			jLblFieldName.setBounds(new java.awt.Rectangle(14,15,99,22));
273
			
274 268
			jPanel = new JPanel();
275 269
			jPanel.setLayout(null);
276
			
277
			jPanel.add(jLblFieldName, null);
278
			jPanel.add(getJTxtFieldName(), null);
279
			jPanel.add(jLblFieldType, null);
280
			jPanel.add(getJCboFieldType(), null);
281
			jPanel.add(jLblFieldLength, null);
282
			jPanel.add(getJTxtFieldLength(), null);
283
			jPanel.add(jLblFieldPrecision, null);
284
			jPanel.add(getJTxtFieldPrecision(), null);
285
			jPanel.add(jLblDefaultValue, null);
286
			jPanel.add(getJTxtDefaultValue(), null);
287
			
270

  
271
			jPanel.add(getJPnlFields(), null);
288 272
		}
289 273
		return jPanel;
290 274
	}
291 275

  
292 276
	/**
293
	 * This method initializes jPanelOkCancel	
294
	 * 	
295
	 * @return javax.swing.JPanel	
277
	 * This method initializes jPanelOkCancel
278
	 *
279
	 * @return javax.swing.JPanel
296 280
	 */
297 281
	private AcceptCancelPanel getJPanelOkCancel() {
298 282
		if (jPanelOkCancel == null) {
......
301 285
				public void actionPerformed(java.awt.event.ActionEvent e) {
302 286
					PluginServices.getMDIManager().closeView(FPanelCreateField.this);
303 287
				};
304
			});	
288
			});
305 289
			jPanelOkCancel.setPreferredSize(new java.awt.Dimension(10,50));
306 290
		}
307 291
		return jPanelOkCancel;
308 292
	}
309 293

  
294
	/**
295
	 * This method initializes jPnlFields
296
	 *
297
	 * @return javax.swing.JPanel
298
	 */
299
	private JPanel getJPnlFields() {
300
		if (jPnlFields == null) {
301
			GridLayout gridLayout = new GridLayout();
302
			gridLayout.setRows(6);
303
			gridLayout.setVgap(3);
304
			gridLayout.setHgap(5);
305
			gridLayout.setColumns(2);
306
			jPnlFields = new JPanel();
307
			jPnlFields.setLayout(gridLayout);
308
			jPnlFields.setBounds(new java.awt.Rectangle(5,12,290,142));
309
			jLblDefaultValue = new JLabel();
310
			jLblDefaultValue.setBounds(new java.awt.Rectangle(14,163,125,22));
311
			jLblDefaultValue.setText("default_value");
312
			jLblFieldPrecision = new JLabel();
313
			jLblFieldPrecision.setBounds(new java.awt.Rectangle(14,126,112,22));
314
			jLblFieldPrecision.setText("precision");
315
			jLblFieldLength = new JLabel();
316
			jLblFieldLength.setBounds(new java.awt.Rectangle(14,89,99,22));
317
			jLblFieldLength.setText("field_length");
318
			jLblFieldType = new JLabel();
319
			jLblFieldType.setBounds(new java.awt.Rectangle(14,52,94,22));
320
			jLblFieldType.setText("field_type");
321
			jLblFieldName = new JLabel();
322
			jLblFieldName.setText("field_name");
323
			jLblFieldName.setBounds(new java.awt.Rectangle(14,15,99,22));
324
			jPnlFields.add(jLblFieldName, null);
325
			jPnlFields.add(getJTxtFieldName(), null);
326
			jPnlFields.add(jLblFieldType, null);
327
			jPnlFields.add(getJCboFieldType(), null);
328
			jPnlFields.add(jLblFieldLength, null);
329
			jPnlFields.add(getJTxtFieldLength(), null);
330
			jPnlFields.add(jLblFieldPrecision, null);
331
			jPnlFields.add(getJTxtFieldPrecision(), null);
332
			jPnlFields.add(jLblDefaultValue, null);
333
			jPnlFields.add(getJTxtDefaultValue(), null);
334
		}
335
		return jPnlFields;
336
	}
337

  
310 338
}  //  @jve:decl-index=0:visual-constraint="9,10"

Also available in: Unified diff