Revision 41911

View differences:

tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/buildNumber.properties
1
#Mon Dec 29 01:44:36 CET 2014
2
buildNumber=2262
0 3

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/test/Persistence.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.test;
25

  
26
import junit.framework.TestCase;
27

  
28
import org.gvsig.app.extension.ProjectExtension;
29

  
30
/**
31
 * @author Fernando Gonz?lez Cort?s
32
 */
33
//TODO comentado para que compile
34
public class Persistence extends TestCase {
35
	private ProjectExtension pe;
36

  
37
	/*
38
	 * @see TestCase#setUp()
39
	 */
40
	protected void setUp() throws Exception {
41
		pe = new ProjectExtension();
42
//		pe.inicializar();
43
//		LayerFactory.setDriversPath(
44
//		"/root/workspace/Andami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
45
//
46
//		LayerFactory.getDataSourceFactory().addFileDataSource("gdbms dbf driver", "prueba",
47
//				"test/cities.dbf");
48

  
49
	}
50

  
51
	public void testPersist() throws Throwable {
52
//		Project p = new Project();
53
//
54
//		/*
55
//		 * A?adimos una vista con una capa
56
//		 */
57
//		ProjectView v = new ProjectView();
58
//		ViewPort vp = new ViewPort( CRSFactory.getCRS("EPSG:23030"));
59
//		vp.setImageSize(new Dimension(500, 500));
60
//
61
//		MapContext fmap = new MapContext(vp);
62
//		v.setMapContext(fmap);
63
//		FLayer l = LayerFactory.createLayer("Vias",
64
//			(VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
65
//			new File("test/cities.shp"),
66
//			CRSFactory.getCRS("EPSG:23030"));
67
//		fmap.getLayers().addLayer(l);
68
//
69
//		/*
70
//		 * A?adimos la tabla del tema anterior
71
//		 */
72
//		SelectableDataSource sds1 = ((FLyrVect) l).getRecordset();
73
//		EditableAdapter ea1 = new EditableAdapter();
74
//		ea1.setOriginalDataSource(sds1);
75
//
76
//		ProjectTable pt1 = ProjectFactory.createTable("tabla", ea1);
77
//		p.addDocument(pt1);
78
//
79
//		/*
80
//		 * A?adimos otra tabla
81
//		 */
82
//		SelectableDataSource sds2 = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource("prueba", DataSourceFactory.MANUAL_OPENING));
83
//		EditableAdapter ea2 = new EditableAdapter();
84
//		ea2.setOriginalDataSource(sds2);
85
//		ProjectTable pt2 = ProjectFactory.createTable("tabla2", ea2);
86
//		p.addTable(pt2);
87
//
88
//		/*
89
//		 * Creamos un join
90
//		 */
91
//		String sql = "custom com_iver_cit_gvsig_arcjoin tables '"+
92
//		sds1.getName()+"', '"+sds1.getName()+"' values(NAME,NAME);";
93
//
94
//		SelectableDataSource result = new SelectableDataSource(
95
//				LayerFactory.getDataSourceFactory()
96
//				.executeSQL(sql, DataSourceFactory.MANUAL_OPENING));
97
//		EditableAdapter auxea=new EditableAdapter();
98
//		auxea.setOriginalDataSource(result);
99
//
100
//		pt1.replaceDataSource(auxea);
101
//
102
//		/*
103
//		 * Guardamos y cargamos
104
//		 */
105
//		File temp = File.createTempFile("junit-", ".gvp");
106
//		temp.deleteOnExit();
107
//		pe.writeProject(temp, p);
108
//
109
//		Project p2 = pe.readProject(temp);
110
//
111
//		/*
112
//		 * Comprobamos que las dos tablas son id?nticas
113
//		 */
114
//		assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(0)).getModel().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(0)).getModel().getRecordset().getAsString()));
115
//		assertTrue(((ProjectTable)p2.getDocumentsByType(ProjectTableFactory.registerName).get(1)).getModel().getRecordset().getAsString().equals(((ProjectTable)p.getTables().get(1)).getModel().getRecordset().getAsString()));
116
	}
117
}
0 118

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/sqlQueryValidation/TestSQLQueryValidation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.sqlQueryValidation;
25

  
26
import junit.framework.TestCase;
27

  
28
/**
29
 * Tests the methods of the class SQLQueryValidation
30
 *    (This class is made without inner static methods for don't create problems to Zql, in this way,
31
 *     it's possible to add more tests, with or without long queries.)
32
 * 
33
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
34
 */
35
 public class TestSQLQueryValidation extends TestCase{
36
	
37
	/*
38
	 *  (non-Javadoc)
39
	 * @see junit.framework.TestCase#setUp()
40
	 */
41
	protected void setUp() throws Exception {
42
		super.setUp();
43
	}
44

  
45
	/*
46
	 *  (non-Javadoc)
47
	 * @see junit.framework.TestCase#tearDown()
48
	 */
49
	protected void tearDown() throws Exception {
50
		super.tearDown();
51
	}
52
	
53
	/**
54
	 * A test (Correct)
55
	 */
56
	public void test1() {
57
		String query = "SELECT r.name, f.id FROM room r, flat f WHERE (r.user_name LIKE 'P%') AND (r.flat = f.id) AND (r.color_wall LIKE 'white') AND (r.height < 2.20);";
58
		
59
		System.out.println("?Es v?lida '" + query + "' ?");
60
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, false);
61

  
62
		if (sqlQueryValidation.validateQuery()) {
63
			System.out.println("Yes.");
64
		}
65
		else {
66
			System.out.println("No.");
67
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
68
			System.out.println(sqlQueryValidation.getErrorMessage());
69
			fail();
70
		}
71
	}
72
	
73
	/**
74
	 * A test (Correct)
75
	 */
76
	public void test2() {
77
		String query = "SELECT * FROM House;";
78

  
79
		System.out.println("?Es v?lida '" + query + "' ?");
80
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, false);
81

  
82
		if (sqlQueryValidation.validateQuery()) {
83
			System.out.println("Yes.");
84
		}
85
		else {
86
			System.out.println("No.");
87
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
88
			System.out.println(sqlQueryValidation.getErrorMessage());
89
			fail();
90
		}
91
	}
92

  
93
	/**
94
	 * A test (Incorrect)
95
	 */
96
	public void test3() {
97
		String query = "SELECT a* FROM House;";
98

  
99
		System.out.println("?Es v?lida '" + query + "' ?");
100
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, false);
101

  
102
		if (sqlQueryValidation.validateQuery()) {
103
			System.out.println("Yes.");
104
		}
105
		else {
106
			System.out.println("No.");
107
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
108
			System.out.println(sqlQueryValidation.getErrorMessage());
109
			fail();
110
		}
111
	}
112
	
113
	/**
114
	 * A test (Correct)
115
	 */
116
	public void test4() {
117
		String query = "SELECT * FROM House;";
118

  
119
		System.out.println("?Es v?lida '" + query + "' ?");
120
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, false);
121

  
122
		if (sqlQueryValidation.validateQuery()) {
123
			System.out.println("Yes.");
124
		}
125
		else {
126
			System.out.println("No.");
127
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
128
			System.out.println(sqlQueryValidation.getErrorMessage());
129
			fail();
130
		}
131
	}
132

  
133
	/**
134
	 * A test (Correct)
135
	 */
136
	public void test5() {
137
		String query = "r.level = f.level AND r.user_name LIKE \'P%\';";
138

  
139
		System.out.println("?Es v?lida '" + query + "' ?");
140
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
141

  
142
		if (sqlQueryValidation.validateQuery()) {
143
			System.out.println("Yes.");
144
		}
145
		else {
146
			System.out.println("No.");
147
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
148
			System.out.println(sqlQueryValidation.getErrorMessage());
149
			fail();
150
		}
151
	}
152

  
153
	/**
154
	 * A test (Incorrect)
155
	 */
156
	public void test6() {
157
		String query = "r.level = f.level a e3 w 	q3 	 ?32	9'}97AND r.user_name LIKE \'P%\';";
158

  
159
		System.out.println("?Es v?lida '" + query + "' ?");
160
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
161

  
162
		if (sqlQueryValidation.validateQuery()) {
163
			System.out.println("Yes.");
164
		}
165
		else {
166
			System.out.println("No.");
167
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
168
			System.out.println(sqlQueryValidation.getErrorMessage());			
169
			fail();
170
		}
171
	}
172
	
173
	/**
174
	 * A test (Correct)
175
	 */
176
	public void test7() {
177
		String query = "\"codigo\" = 'Canal d'Elx'";
178

  
179
		System.out.println("?Es v?lida '" + query + "' ?");
180
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
181

  
182
		if (sqlQueryValidation.validateQuery()) {
183
			System.out.println("Yes.");
184
		}
185
		else {
186
			System.out.println("No.");
187
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
188
			System.out.println(sqlQueryValidation.getErrorMessage());			
189
			fail();
190
		}
191
	}
192
	
193
	/**
194
	 * A test (Correct)
195
	 */
196
	public void test8() {
197
		String query = "\"codigo\" = 'Canal de la M?nega'";
198

  
199
		System.out.println("?Es v?lida '" + query + "' ?");
200
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
201

  
202
		if (sqlQueryValidation.validateQuery()) {
203
			System.out.println("Yes.");
204
		}
205
		else {
206
			System.out.println("No.");
207
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
208
			System.out.println(sqlQueryValidation.getErrorMessage());			
209
			fail();
210
		}
211
	}
212
	
213
	/**
214
	 * A test (Correct)
215
	 */
216
	public void test9() {
217
		String query = "\"codigo\" = 'Espa?a'";
218

  
219
		System.out.println("?Es v?lida '" + query + "' ?");
220
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
221

  
222
		if (sqlQueryValidation.validateQuery()) {
223
			System.out.println("Yes.");
224
		}
225
		else {
226
			System.out.println("No.");
227
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
228
			System.out.println(sqlQueryValidation.getErrorMessage());			
229
			fail();
230
		}
231
	}
232
	
233
	/**
234
	 * A test (Correct)
235
	 */
236
	public void test10() {
237
		String query = "\"codigo\" = ('Canal d'Elx')";
238

  
239
		System.out.println("?Es v?lida '" + query + "' ?");
240
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
241

  
242
		if (sqlQueryValidation.validateQuery()) {
243
			System.out.println("Yes.");
244
		}
245
		else {
246
			System.out.println("No.");
247
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
248
			System.out.println(sqlQueryValidation.getErrorMessage());			
249
			fail();
250
		}
251
	}
252
	
253
	/**
254
	 * A test (Correct)
255
	 */
256
	public void test11() {
257
		String query = "\"codigo\" = ( 'Canal d'Elx' )";
258

  
259
		System.out.println("?Es v?lida '" + query + "' ?");
260
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
261

  
262
		if (sqlQueryValidation.validateQuery()) {
263
			System.out.println("Yes.");
264
		}
265
		else {
266
			System.out.println("No.");
267
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
268
			System.out.println(sqlQueryValidation.getErrorMessage());			
269
			fail();
270
		}
271
	}
272
	
273
	/**
274
	 * A test (Correct)
275
	 */
276
	public void test12() {
277
		String query = "\"codigo\" = ( 'Canal d'Elx')";
278

  
279
		System.out.println("?Es v?lida '" + query + "' ?");
280
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
281

  
282
		if (sqlQueryValidation.validateQuery()) {
283
			System.out.println("Yes.");
284
		}
285
		else {
286
			System.out.println("No.");
287
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
288
			System.out.println(sqlQueryValidation.getErrorMessage());			
289
			fail();
290
		}
291
	}
292
	
293
	/**
294
	 * A test (Correct)
295
	 */
296
	public void test13() {
297
		String query = "\"codigo\" = ('Canal d'Elx' )";
298

  
299
		System.out.println("?Es v?lida '" + query + "' ?");
300
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
301

  
302
		if (sqlQueryValidation.validateQuery()) {
303
			System.out.println("Yes.");
304
		}
305
		else {
306
			System.out.println("No.");
307
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
308
			System.out.println(sqlQueryValidation.getErrorMessage());			
309
			fail();
310
		}
311
	}	
312
	
313
	/**
314
	 * A test (Incorrect)
315
	 */
316
	public void test14() {
317
		String query = "\"codigo\" = ('Canal d' Elx' )";
318

  
319
		System.out.println("?Es v?lida '" + query + "' ?");
320
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
321

  
322
		if (sqlQueryValidation.validateQuery()) {
323
			System.out.println("Yes.");
324
		}
325
		else {
326
			System.out.println("No.");
327
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
328
			System.out.println(sqlQueryValidation.getErrorMessage());			
329
			fail();
330
		}
331
	}
332
		
333
	/**
334
	 * A test (Incorrect)
335
	 */
336
	public void test15() {
337
		String query = "\"codigo\" = ('Canal d'Elx d'Alacant' )";
338

  
339
		System.out.println("?Es v?lida '" + query + "' ?");
340
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
341

  
342
		if (sqlQueryValidation.validateQuery()) {
343
			System.out.println("Yes.");
344
		}
345
		else {
346
			System.out.println("No.");
347
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
348
			System.out.println(sqlQueryValidation.getErrorMessage());			
349
			fail();
350
		}
351
	}	
352
	
353
	/**
354
	 * A test (Incorrect)
355
	 */
356
	public void test16() {
357
		String query = "\"fecha\" = Date(11-ene-2004)";
358

  
359
		System.out.println("?Es v?lida '" + query + "' ?");
360
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
361

  
362
		if (sqlQueryValidation.validateQuery()) {
363
			System.out.println("Yes.");
364
		}
365
		else {
366
			System.out.println("No.");
367
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
368
			System.out.println(sqlQueryValidation.getErrorMessage());			
369
			fail();
370
		}
371
	}
372
	
373
	/**
374
	 * A test (Correct)
375
	 */
376
	public void test17() {
377
		String query = "\"fecha\" = 11-ene-2004";
378

  
379
		System.out.println("?Es v?lida '" + query + "' ?");
380
		SQLQueryValidation sqlQueryValidation = new SQLQueryValidation(query, true);
381

  
382
		if (sqlQueryValidation.validateQuery()) {
383
			System.out.println("Yes.");
384
		}
385
		else {
386
			System.out.println("No.");
387
			System.out.println(sqlQueryValidation.getErrorPositionAsMessage());
388
			System.out.println(sqlQueryValidation.getErrorMessage());			
389
			fail();
390
		}
391
	}
392
 }
0 393

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/gui/filter/TestFilterExpressionFromWhereIsEmpty_Method.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.gui.filter;
25

  
26
import junit.framework.TestCase;
27

  
28

  
29
/**
30
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
31
 */
32
public class TestFilterExpressionFromWhereIsEmpty_Method extends TestCase {
33
	/*
34
	 *  (non-Javadoc)
35
	 * @see junit.framework.TestCase#setUp()
36
	 */
37
	protected void setUp() throws Exception {
38
		super.setUp();
39
	}
40

  
41
	/*
42
	 *  (non-Javadoc)
43
	 * @see junit.framework.TestCase#tearDown()
44
	 */
45
	protected void tearDown() throws Exception {
46
		super.tearDown();
47
	}	
48

  
49
	/**
50
	 * Test 1 (valid)
51
	 */
52
	public void test1() {
53
		String expression = new String("select * from 'gdbms144426c_10fc90fa1aa__7c18' where ;");
54
		
55
		System.out.println("? Es vac?o el filtro en: " + expression + " ? ");
56

  
57
		if (this.filterExpressionFromWhereIsEmpty(expression))
58
			System.out.println("Si.");
59
		else
60
			System.out.println("No.");
61
	}
62
	
63
	/**
64
	 * Test 2 (invalid)
65
	 */
66
	public void test2() {
67
		String expression = new String("select * from 'gdbms158fd70_10fc92ee61e__7c18' where layer < '61';");
68
		
69
		System.out.println("? Es vac?o el filtro en: " + expression + " ? ");
70

  
71
		if (this.filterExpressionFromWhereIsEmpty(expression))
72
			System.out.println("Si.");
73
		else
74
			System.out.println("No.");
75
	}	
76
	
77
	/**
78
	 * Returns true if the WHERE subconsultation of the filterExpression is empty ("")
79
	 * 
80
	 * @param expression An string
81
	 * @return A boolean value 
82
	 */
83
	private boolean filterExpressionFromWhereIsEmpty(String expression) {
84
		String subExpression = expression.trim();
85
		int pos;	
86
		
87
		// Remove last ';' if exists
88
		if (subExpression.charAt(subExpression.length() -1) == ';')
89
			subExpression = subExpression.substring(0, subExpression.length() -1).trim();
90
		
91
		// If there is no 'where' clause
92
		if ((pos = subExpression.indexOf("where")) == -1)
93
			return false;
94
		
95
		// If there is no subexpression in the WHERE clause -> true
96
		subExpression = subExpression.substring(pos + 5, subExpression.length()).trim(); // + 5 is the length of 'where'
97
		if ( subExpression.length() == 0 )
98
			return true;
99
		else
100
			return false;
101
	}
102
}
0 103

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/project/ProjectTest.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: ProjectTest.java 29595 2009-06-29 15:57:45Z jpiera $
27
* $Log$
28
* Revision 1.1  2006-11-08 10:57:55  jaume
29
* remove unecessary imports
30
*
31
*
32
*/
33
package org.gvsig.app.project;
34

  
35
import junit.framework.TestCase;
36

  
37
//TODO comentado para que compile
38
public class ProjectTest extends TestCase {
39
	static final String projectFile1 = "test/test.gvp";
40
	static final String projectFile2 = "test/test.gvp";
41
	static final String projectFile3 = null;
42
	static final String projectFile4 = null;
43

  
44
	static final String driversPath = "lib-test/drivers";
45
	Project p1, p2;
46

  
47
	public void setUp() {
48

  
49
//		LayerFactory.setDriversPath(driversPath);
50
//
51
//		Reader reader;
52
//
53
//		// TODO Install drivers support for testing
54
//		try {
55
//			reader = new FileReader(new File(projectFile1));
56
//
57
//			XmlTag tag = (XmlTag) XmlTag.unmarshal(reader);
58
//			XMLEntity xml=new XMLEntity(tag);
59
//			p1 = Project.createFromXML(xml);
60
//			p2 = Project.createFromXML(xml);
61
//		} catch (Exception e) {
62
//			e.printStackTrace();
63
//		}
64

  
65
	}
66

  
67
//	public void testSignature() {
68
//		try {
69
//			assertTrue(p1.computeSignature() == p2.computeSignature());
70
//		} catch (SaveException e) {}
71
////		assertTrue(p1.equals(p2));
72
//	}
73
}
0 74

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/AllTests.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app;
25

  
26
import junit.framework.Test;
27
import junit.framework.TestSuite;
28

  
29
import org.gvsig.app.gui.filter.TestFilterExpressionFromWhereIsEmpty_Method;
30
import org.gvsig.app.panelGroup.Test2ExceptionsUsingTabbedPanel;
31
import org.gvsig.app.panelGroup.Test2ExceptionsUsingTreePanel;
32
import org.gvsig.app.panelGroup.TestPanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.project.ProjectTest;
34
import org.gvsig.app.sqlQueryValidation.TestSQLQueryValidation;
35
import org.gvsig.app.test.Persistence;
36

  
37
public class AllTests {
38

  
39
	public static Test suite() {
40
		TestSuite suite = new TestSuite("Test for org.gvsig.app");
41
		//$JUnit-BEGIN$
42
		suite.addTestSuite(Persistence.class);
43
		suite.addTestSuite(ProjectTest.class);
44
		suite.addTestSuite(TestFilterExpressionFromWhereIsEmpty_Method.class);
45
		suite.addTestSuite(TestSQLQueryValidation.class);
46
		suite.addTestSuite(TestPanelGroupLoaderFromExtensionPoint.class);
47
		suite.addTestSuite(Test2ExceptionsUsingTabbedPanel.class);
48
		suite.addTestSuite(Test2ExceptionsUsingTreePanel.class);
49
		
50
		//$JUnit-END$
51
		return suite;
52
	}
53

  
54
}
0 55

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/panelGroup/Test2TabbedPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.panelGroup;
25

  
26
import javax.swing.JFrame;
27

  
28
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
29
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Tests the creation of a {@link TabbedPanel TabbedPanel} object using {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint} .</p>
37
 * 
38
 * @version 16/10/2007
39
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
40
 */
41
public class Test2TabbedPanel {
42
	/**
43
	 * <p>Test method for the Test2TabbedPanel.</p>
44
	 * 
45
	 * @param args optional arguments
46
	 */
47
	public static void main(String[] args) {
48
		try {
49
			Samples_ExtensionPointsOfIPanels.loadSample();
50
			
51
			PanelGroupManager manager = PanelGroupManager.getManager();
52
			manager.registerPanelGroup(TabbedPanel.class);
53
			manager.setDefaultType(TabbedPanel.class);
54

  
55
			TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE2);
56
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT2_NAME);
57

  
58
			// Begin: Test the normal load
59
			panelGroup.loadPanels(loader);
60
			// End: Test the normal load
61

  
62
			// Objects creation
63
			JFrame jFrame = new JFrame();
64
			jFrame.setTitle("Test TabbedPanel using PanelGroupLoaderFromExtensionPoint");
65
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
66
		    jFrame.setSize(panelGroup.getPreferredSize());
67
		    jFrame.getContentPane().add(panelGroup);
68
		    
69
			jFrame.setVisible(true);
70
			
71
		} catch (BaseException bE) {
72
			System.out.println(bE.getLocalizedMessageStack());
73
		} catch (Exception e) {
74
			e.printStackTrace();
75
		}
76
	}
77
}
0 78

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/panelGroup/samples/SamplePanelGroupLabelRepeated.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.panelGroup.samples;
25

  
26
import java.awt.Color;
27
import java.awt.Dimension;
28
import java.io.Serializable;
29

  
30
import javax.swing.JScrollPane;
31
import javax.swing.JTextArea;
32

  
33
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
34

  
35
/**
36
 * <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
37
 * 
38
 * @version 23/10/2007
39
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
40
 */
41
public class SamplePanelGroupLabelRepeated extends AbstractPanel implements Serializable {
42
	private static final long serialVersionUID = 1857806149242138609L;
43

  
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private JTextArea jTextArea = null;
48

  
49
	/**
50
	 * @see AbstractPanel#AbstractPanel()
51
	 */
52
	public SamplePanelGroupLabelRepeated() {
53
		super();
54
		initialize();
55
	}
56

  
57
	/**
58
	 * @see AbstractPanel#AbstractPanel(String, String, String)
59
	 */
60
	public SamplePanelGroupLabelRepeated(String id, String label, String labelGroup) {
61
		super(id, label, labelGroup);
62
		initialize();
63
	}
64

  
65
	@Override
66
	protected void initialize() {
67
		add(new JScrollPane(getJTextArea()));
68
		setToolTipText(getID());
69

  
70
		setID(Samples_ExtensionPointsOfIPanels.PANELS3_IDS[1]);
71
		setLabel(Samples_ExtensionPointsOfIPanels.PANELS3_LABELS[1]);
72
		setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS3_LABELGROUPS[1]);
73
		setPreferredSize(new Dimension(Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_WIDTH, Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_HEIGHT));
74
		resetChangedStatus();
75
	}
76
	
77
	/**
78
	 * This method initializes jTextArea
79
	 *
80
	 * @return JTextArea
81
	 */
82
	private JTextArea getJTextArea() {
83
		if (jTextArea == null) {
84
			jTextArea = new JTextArea(5, 40);
85
			jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
86
			jTextArea.setEditable(false);
87
			jTextArea.setBackground(Color.GRAY);
88
		}
89

  
90
		return jTextArea;
91
	}
92

  
93
	@Override
94
	public void setID(String id) {
95
		super.setID(id);
96

  
97
		setToolTipText(getID());
98
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
99
	}
100

  
101
	@Override
102
	public void setLabel(String label) {
103
		super.setLabel(label);
104
		
105
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
106
	}
107

  
108
	@Override
109
	public void setLabelGroup(String labelGroup) {
110
		super.setLabelGroup(labelGroup);
111
		
112
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
113
	}
114

  
115
	public void accept() {
116
	}
117

  
118
	public void apply() {
119
	}
120

  
121
	public void cancel() {
122
	}
123

  
124
	public void selected() {
125
		System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " +
126
				 "\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() +
127
				 "\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize());
128
	}
129
}
130

  
0 131

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/panelGroup/samples/SampleScalePanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.panelGroup.samples;
25

  
26
import java.awt.Color;
27
import java.awt.Dimension;
28
import java.awt.event.MouseAdapter;
29
import java.awt.event.MouseEvent;
30
import java.io.Serializable;
31

  
32
import javax.swing.JScrollPane;
33
import javax.swing.JTextArea;
34

  
35
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
36

  
37
/**
38
 * <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
39
 * 
40
 * @version 16/10/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class SampleScalePanel extends AbstractPanel implements Serializable {
44
	private static final long serialVersionUID = -4160464669737958732L;
45

  
46
	/**
47
	 * <p>Element for the interface.</p>
48
	 */
49
	private JTextArea jTextArea = null;
50
	
51
	/**
52
	 * @see AbstractPanel#AbstractPanel()
53
	 */
54
	public SampleScalePanel() {
55
		super();
56
		initialize();
57
	}
58
	
59
	/**
60
	 * @see AbstractPanel#AbstractPanel(String, String, String)
61
	 */
62
	public SampleScalePanel(String id, String label, String labelGroup) {
63
		super(id, label, labelGroup);
64
		initialize();
65
	}
66
	
67
	@Override
68
	protected void initialize() {
69
		add(new JScrollPane(getJTextArea()));
70
		setToolTipText(getID());
71
		
72
		setID(Samples_ExtensionPointsOfIPanels.PANELS1_IDS[5]);
73
		setLabel(Samples_ExtensionPointsOfIPanels.PANELS1_LABELS[5]);
74
		setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[5]);
75
		setPreferredSize(new Dimension(Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_WIDTH, Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_HEIGHT));
76
		resetChangedStatus();
77
	}
78
	
79
	/**
80
	 * This method initializes jTextArea
81
	 *
82
	 * @return JTextArea
83
	 */
84
	private JTextArea getJTextArea() {
85
		if (jTextArea == null) {
86
			jTextArea = new JTextArea(5, 40);
87
			jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
88
			jTextArea.setEditable(false);
89
			jTextArea.setBackground(Color.YELLOW);
90
			jTextArea.addMouseListener(new MouseAdapter() {
91
				
92
				public void mouseClicked(MouseEvent e) {
93
					if (getPanelGroup() != null) {
94
						getPanelGroup().setEnabledApplyButton(! getPanelGroup().isEnabledApplyButton());
95
						getPanelGroup().setEnabledCancelButton(! getPanelGroup().isEnabledCancelButton());
96
					}	
97
				}
98
			});
99
		}
100

  
101
		return jTextArea;
102
	}
103
	
104
	@Override
105
	public void setID(String id) {
106
		super.setID(id);
107
		
108
		setToolTipText(getID());
109
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
110
	}
111

  
112
	@Override
113
	public void setLabel(String label) {
114
		super.setLabel(label);
115
		
116
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
117
	}
118

  
119
	@Override
120
	public void setLabelGroup(String labelGroup) {
121
		super.setLabelGroup(labelGroup);
122
		
123
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
124
	}
125

  
126
	public void accept() {
127
	}
128

  
129
	public void apply() {
130
	}
131

  
132
	public void cancel() {
133
	}
134

  
135
	public void selected() {
136
		System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " +
137
				 "\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() +
138
				 "\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize());
139
	}
140
}
0 141

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/panelGroup/samples/SampleInitializingExcetionPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.panelGroup.samples;
25

  
26
import java.awt.Color;
27
import java.io.Serializable;
28

  
29
import javax.swing.JScrollPane;
30
import javax.swing.JTextArea;
31

  
32
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
33

  
34
/**
35
 * <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
36
 * 
37
 * @version 16/10/2007
38
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
39
 */
40
public class SampleInitializingExcetionPanel extends AbstractPanel implements Serializable {
41
	private static final long serialVersionUID = -876907003975432865L;
42

  
43
	/**
44
	 * <p>Element for the interface.</p>
45
	 */
46
	private JTextArea jTextArea = null;
47

  
48
	/**
49
	 * @see AbstractPanel#AbstractPanel()
50
	 */
51
	public SampleInitializingExcetionPanel() {
52
		super();
53
		initialize();
54
	}
55

  
56
	/**
57
	 * @see AbstractPanel#AbstractPanel(String, String, String)
58
	 */
59
	public SampleInitializingExcetionPanel(String id, String label, String labelGroup) {
60
		super(id, label, labelGroup);
61
		
62
		initialize();
63
	}
64

  
65
	@Override
66
	protected void initialize() {
67
		add(new JScrollPane(getJTextArea()));
68
		setToolTipText(getID());
69
		
70
		setID(Samples_ExtensionPointsOfIPanels.PANELS1_IDS[0]);
71
		setLabel(Samples_ExtensionPointsOfIPanels.PANELS1_LABELS[0]);
72
		setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[0]);
73
		
74
		// Force to generate an exception
75
		double badValue = 2 / 0;
76

  
77
		resetChangedStatus();
78
	}
79
	
80
	/**
81
	 * This method initializes jTextArea
82
	 *
83
	 * @return JTextArea
84
	 */
85
	private JTextArea getJTextArea() {
86
		if (jTextArea == null) {
87
			jTextArea = new JTextArea(5, 40);
88
			jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
89
			jTextArea.setEditable(false);
90
			jTextArea.setBackground(Color.GREEN);
91
		}
92

  
93
		return jTextArea;
94
	}
95

  
96
	@Override
97
	public void setID(String id) {
98
		super.setID(id);
99

  
100
		setToolTipText(getID());
101
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
102
		hasChanged = true;
103
	}
104

  
105
	@Override
106
	public void setLabel(String label) {
107
		super.setLabel(label);
108
		
109
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
110
		hasChanged = true;
111
	}
112

  
113
	@Override
114
	public void setLabelGroup(String labelGroup) {
115
		super.setLabelGroup(labelGroup);
116
		
117
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
118
		hasChanged = true;
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
124
	 */
125
	public void accept() {
126
		System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method.");
127
	}
128

  
129
	/*
130
	 * (non-Javadoc)
131
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply()
132
	 */
133
	public void apply() {
134
		System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method.");
135
	}
136

  
137
	/*
138
	 * (non-Javadoc)
139
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel()
140
	 */
141
	public void cancel() {
142
		System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method.");
143
	}
144

  
145
	/*
146
	 * (non-Javadoc)
147
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected()
148
	 */
149
	public void selected() {
150
		System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " +
151
		 "\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() +
152
		 "\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize());
153
	}
154
}
0 155

  
tags/org.gvsig.desktop-2.0.75/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/test/java/org/gvsig/app/panelGroup/samples/SampleTransparencyPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.panelGroup.samples;
25

  
26
import java.awt.Color;
27
import java.awt.Dimension;
28
import java.awt.event.MouseAdapter;
29
import java.awt.event.MouseEvent;
30
import java.io.Serializable;
31

  
32
import javax.swing.JScrollPane;
33
import javax.swing.JTextArea;
34

  
35
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
36

  
37

  
38
/**
39
 * <p>Sample of {@link AbstractPanel AbstractPanel}.</p>
40
 * 
41
 * @version 16/10/2007
42
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
43
 */
44
public class SampleTransparencyPanel extends AbstractPanel implements Serializable {
45
	private static final long serialVersionUID = -4145789119404234621L;
46

  
47
	/**
48
	 * <p>Element for the interface.</p>
49
	 */
50
	private JTextArea jTextArea = null;
51
	
52
	/**
53
	 * @see AbstractPanel#AbstractPanel()
54
	 */
55
	public SampleTransparencyPanel() {
56
		super();
57
		initialize();
58
	}
59
	
60
	/**
61
	 * @see AbstractPanel#AbstractPanel(String, String, String)
62
	 */
63
	public SampleTransparencyPanel(String id, String label, String labelGroup) {
64
		super(id, label, labelGroup);
65
		initialize();
66
	}
67
	
68
	@Override
69
	protected void initialize() {
70
		add(new JScrollPane(getJTextArea()));
71
		setToolTipText(getID());
72
		
73
		setID(Samples_ExtensionPointsOfIPanels.PANELS1_IDS[2]);
74
		setLabel(Samples_ExtensionPointsOfIPanels.PANELS1_LABELS[2]);
75
		setLabelGroup(Samples_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[2]);
76
		setPreferredSize(new Dimension(Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_WIDTH, Samples_ExtensionPointsOfIPanels.PANELS_DEFAULT_HEIGHT));
77
		resetChangedStatus();
78
	}
79
	
80
	/**
81
	 * This method initializes jTextArea
82
	 *
83
	 * @return JTextArea
84
	 */
85
	private JTextArea getJTextArea() {
86
		if (jTextArea == null) {
87
			jTextArea = new JTextArea(5, 40);
88
			jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
89
			jTextArea.setEditable(false);
90
			jTextArea.setBackground(Color.BLUE);
91
			jTextArea.addMouseListener(new MouseAdapter() {
92
				
93
				public void mouseClicked(MouseEvent e) {
94
					if (getPanelGroup() != null) {
95
						getPanelGroup().setEnabledApplyButton(! getPanelGroup().isEnabledApplyButton());
96
					}	
97
				}
98
			});
99
		}
100

  
101
		return jTextArea;
102
	}
103
	
104
	@Override
105
	public void setID(String id) {
106
		super.setID(id);
107
		
108
		setToolTipText(getID());
109
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
110
	}
111

  
112
	@Override
113
	public void setLabel(String label) {
114
		super.setLabel(label);
115
		
116
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
117
	}
118

  
119
	@Override
120
	public void setLabelGroup(String labelGroup) {
121
		super.setLabelGroup(labelGroup);
122
		
123
		getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup());
124
	}
125

  
126
	public void accept() {
127
	}
128

  
129
	public void apply() {
130
	}
131

  
132
	public void cancel() {
133
	}
134

  
135
	public void selected() {
136
		System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " +
137
				 "\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() +
138
				 "\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize());
139
	}
140
}
0 141

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff