Revision 37676

View differences:

tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/gui/filter/TestFilterExpressionFromWhereIsEmpty_Method.java
1
package org.gvsig.app.gui.filter;
2

  
3
import junit.framework.TestCase;
4

  
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46

  
47
/**
48
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
49
 */
50
public class TestFilterExpressionFromWhereIsEmpty_Method extends TestCase {
51
	/*
52
	 *  (non-Javadoc)
53
	 * @see junit.framework.TestCase#setUp()
54
	 */
55
	protected void setUp() throws Exception {
56
		super.setUp();
57
	}
58

  
59
	/*
60
	 *  (non-Javadoc)
61
	 * @see junit.framework.TestCase#tearDown()
62
	 */
63
	protected void tearDown() throws Exception {
64
		super.tearDown();
65
	}	
66

  
67
	/**
68
	 * Test 1 (valid)
69
	 */
70
	public void test1() {
71
		String expression = new String("select * from 'gdbms144426c_10fc90fa1aa__7c18' where ;");
72
		
73
		System.out.println("? Es vac?o el filtro en: " + expression + " ? ");
74

  
75
		if (this.filterExpressionFromWhereIsEmpty(expression))
76
			System.out.println("Si.");
77
		else
78
			System.out.println("No.");
79
	}
80
	
81
	/**
82
	 * Test 2 (invalid)
83
	 */
84
	public void test2() {
85
		String expression = new String("select * from 'gdbms158fd70_10fc92ee61e__7c18' where layer < '61';");
86
		
87
		System.out.println("? Es vac?o el filtro en: " + expression + " ? ");
88

  
89
		if (this.filterExpressionFromWhereIsEmpty(expression))
90
			System.out.println("Si.");
91
		else
92
			System.out.println("No.");
93
	}	
94
	
95
	/**
96
	 * Returns true if the WHERE subconsultation of the filterExpression is empty ("")
97
	 * 
98
	 * @param expression An string
99
	 * @return A boolean value 
100
	 */
101
	private boolean filterExpressionFromWhereIsEmpty(String expression) {
102
		String subExpression = expression.trim();
103
		int pos;	
104
		
105
		// Remove last ';' if exists
106
		if (subExpression.charAt(subExpression.length() -1) == ';')
107
			subExpression = subExpression.substring(0, subExpression.length() -1).trim();
108
		
109
		// If there is no 'where' clause
110
		if ((pos = subExpression.indexOf("where")) == -1)
111
			return false;
112
		
113
		// If there is no subexpression in the WHERE clause -> true
114
		subExpression = subExpression.substring(pos + 5, subExpression.length()).trim(); // + 5 is the length of 'where'
115
		if ( subExpression.length() == 0 )
116
			return true;
117
		else
118
			return false;
119
	}
120
}
0 121

  
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/project/ProjectTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46
* Revision 1.1  2006-11-08 10:57:55  jaume
47
* remove unecessary imports
48
*
49
*
50
*/
51
package org.gvsig.app.project;
52

  
53
import junit.framework.TestCase;
54

  
55
//TODO comentado para que compile
56
public class ProjectTest extends TestCase {
57
	static final String projectFile1 = "test/test.gvp";
58
	static final String projectFile2 = "test/test.gvp";
59
	static final String projectFile3 = null;
60
	static final String projectFile4 = null;
61

  
62
	static final String driversPath = "lib-test/drivers";
63
	Project p1, p2;
64

  
65
	public void setUp() {
66

  
67
//		LayerFactory.setDriversPath(driversPath);
68
//
69
//		Reader reader;
70
//
71
//		// TODO Install drivers support for testing
72
//		try {
73
//			reader = new FileReader(new File(projectFile1));
74
//
75
//			XmlTag tag = (XmlTag) XmlTag.unmarshal(reader);
76
//			XMLEntity xml=new XMLEntity(tag);
77
//			p1 = Project.createFromXML(xml);
78
//			p2 = Project.createFromXML(xml);
79
//		} catch (Exception e) {
80
//			e.printStackTrace();
81
//		}
82

  
83
	}
84

  
85
//	public void testSignature() {
86
//		try {
87
//			assertTrue(p1.computeSignature() == p2.computeSignature());
88
//		} catch (SaveException e) {}
89
////		assertTrue(p1.equals(p2));
90
//	}
91
}
0 92

  
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/AllTests.java
1
package org.gvsig.app;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestSuite;
5

  
6
import org.gvsig.app.gui.filter.TestFilterExpressionFromWhereIsEmpty_Method;
7
import org.gvsig.app.panelGroup.Test2ExceptionsUsingTabbedPanel;
8
import org.gvsig.app.panelGroup.Test2ExceptionsUsingTreePanel;
9
import org.gvsig.app.panelGroup.TestPanelGroupLoaderFromExtensionPoint;
10
import org.gvsig.app.project.ProjectTest;
11
import org.gvsig.app.sqlQueryValidation.TestSQLQueryValidation;
12
import org.gvsig.app.test.Persistence;
13

  
14
public class AllTests {
15

  
16
	public static Test suite() {
17
		TestSuite suite = new TestSuite("Test for org.gvsig.app");
18
		//$JUnit-BEGIN$
19
		suite.addTestSuite(Persistence.class);
20
		suite.addTestSuite(ProjectTest.class);
21
		suite.addTestSuite(TestFilterExpressionFromWhereIsEmpty_Method.class);
22
		suite.addTestSuite(TestSQLQueryValidation.class);
23
		suite.addTestSuite(TestPanelGroupLoaderFromExtensionPoint.class);
24
		suite.addTestSuite(Test2ExceptionsUsingTabbedPanel.class);
25
		suite.addTestSuite(Test2ExceptionsUsingTreePanel.class);
26
		
27
		//$JUnit-END$
28
		return suite;
29
	}
30

  
31
}
0 32

  
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test2ButtonsPanelWithExceptionsMessage.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
29
import org.gvsig.tools.exception.BaseException;
30

  
31
import org.gvsig.andami.ui.mdiManager.WindowInfo;
32
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Test method for the Test2ButtonsPanelWithExceptionsMessage.</p>
37
 * <p>Tests the message dialog caused by the exceptions produced during the loading of panels, using {@link PanelGroupManager PanelGroupManager},
38
 *  {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}, {@link TabbedPanel TabbedPanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 17/12/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test2ButtonsPanelWithExceptionsMessage {
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private static JFrame jFrame;
48

  
49
	/**
50
	 * <p>Test method for the Test2ButtonsPanelWithExceptionsMessage.</p>
51
	 * 
52
	 * @param args optional arguments
53
	 */
54
	public static void main(String[] args) {
55
		try {
56
			// Objects creation
57
			jFrame = new JFrame();
58

  
59
			Samples_ExtensionPointsOfIPanels.loadSample();
60

  
61
			PanelGroupManager manager = PanelGroupManager.getManager();
62
			manager.registerPanelGroup(TabbedPanel.class);
63
			manager.setDefaultType(TabbedPanel.class);
64

  
65
			TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3);
66

  
67
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT10_NAME);
68

  
69
			// Creates the IWindow
70
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panels with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup);
71
			
72
			// Begin: Test the normal load
73
			panelGroupDialog.loadPanels(loader);
74
			// End: Test the normal load
75

  
76
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
77
				/*
78
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
79
				 */
80
				public void actionButtonPressed(ButtonsPanelEvent e) {
81
					switch (e.getButton()) {
82
						case ButtonsPanel.BUTTON_ACCEPT:
83
							System.out.println("Accept Button pressed.");
84
							hideJFrame();
85
							System.exit(0);
86
							break;
87
						case ButtonsPanel.BUTTON_CANCEL:
88
							System.out.println("Cancel Button pressed.");
89
							hideJFrame();
90
							System.exit(0);
91
							break;
92
						case ButtonsPanel.BUTTON_APPLY:
93
							System.out.println("Apply Button pressed.");
94
							break;
95
					}
96
				}
97
			});
98

  
99
			jFrame.setTitle("Test resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromExtensionPoint");
100
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
101
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
102
		    jFrame.getContentPane().add(panelGroupDialog);
103
		    
104
			jFrame.setVisible(true);
105
			
106
		} catch (BaseException bE) {
107
			System.out.println(bE.getLocalizedMessageStack());
108
		} catch (Exception e) {
109
			e.printStackTrace();
110
		}
111
	}
112
	
113
	/**
114
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
115
	 */
116
	private static void hideJFrame() {
117
		jFrame.setVisible(false);
118
	}
119
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test5ButtonsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
29
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
33

  
34
/**
35
 * <p>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
36
 * <p>Tests {@link PanelGroupManager PanelGroupManager}, {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}, 
37
 *  {@link TabbedPanel TabbedPanel}, and a non resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
38
 * 
39
 * @version 19/10/2007
40
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
41
 */
42
public class Test5ButtonsPanel {
43
	/**
44
	 * <p>Element for the interface.</p>
45
	 */
46
	private static JFrame jFrame;
47

  
48
	/**
49
	 * <p>Test method for the Test5ButtonsPanel.</p>
50
	 * 
51
	 * @param args optional arguments
52
	 */
53
	public static void main(String[] args) {
54
		try {
55
			// Objects creation
56
			jFrame = new JFrame();
57

  
58
			PanelGroupManager manager = PanelGroupManager.getManager();
59
			manager.registerPanelGroup(TabbedPanel.class);
60
			manager.setDefaultType(TabbedPanel.class);
61

  
62
			TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1);
63
			
64
			PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS1_CLASSES);
65
			
66
			// Creates the IWindow
67
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 800, 650, (byte)0, panelGroup);
68

  
69
			// Begin: Test the normal load
70
			panelGroupDialog.loadPanels(loader);
71
			// End: Test the normal load
72
			
73
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
74
				/*
75
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
76
				 */
77
				public void actionButtonPressed(ButtonsPanelEvent e) {
78
					switch (e.getButton()) {
79
						case ButtonsPanel.BUTTON_ACCEPT:
80
							System.out.println("Accept Button pressed.");
81
							hideJFrame();
82
							System.exit(0);
83
							break;
84
						case ButtonsPanel.BUTTON_CANCEL:
85
							System.out.println("Cancel Button pressed.");
86
							hideJFrame();
87
							System.exit(0);
88
							break;
89
						case ButtonsPanel.BUTTON_APPLY:
90
							System.out.println("Apply Button pressed.");
91
							break;
92
					}
93
				}
94
			});
95
			
96
			jFrame.setTitle("Test Non Resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromList");
97
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
98
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
99
		    jFrame.getContentPane().add(panelGroupDialog);
100
		    
101
		    jFrame.setResizable(false);
102
			jFrame.setVisible(true);
103
			
104
		} catch (BaseException bE) {
105
			System.out.println(bE.getLocalizedMessageStack());
106
		} catch (Exception e) {
107
			e.printStackTrace();
108
		}
109
	}
110

  
111
	/**
112
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
113
	 */
114
	private static void hideJFrame() {
115
		jFrame.setVisible(false);
116
	}
117
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test3ButtonsPanelWithExceptionsMessage.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
29
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Test method for the Test1ButtonsPanelWithExceptionsMessage.</p>
37
 * <p>Tests the message dialog caused by the exceptions produced during the loading of panels, using {@link PanelGroupManager PanelGroupManager},
38
 *  {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}, {@link TreePanel TreePanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 17/12/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test3ButtonsPanelWithExceptionsMessage {
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private static JFrame jFrame;
48
	private static TreePanel panelGroup;
49

  
50
	/**
51
	 * <p>Test method for the Test3ButtonsPanelWithExceptionsMessage.</p>
52
	 * 
53
	 * @param args optional arguments
54
	 */
55
	public static void main(String[] args) {
56
		try {
57
			// Objects creation
58
			jFrame = new JFrame();
59

  
60
			PanelGroupManager manager = PanelGroupManager.getManager();
61
			manager.registerPanelGroup(TreePanel.class);
62
			manager.setDefaultType(TreePanel.class);
63

  
64
			panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3);
65
			
66
			PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS10_CLASSES);
67

  
68
			// Creates the IWindow
69
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panel with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup);
70
			
71
			// Begin: Test the normal load
72
			panelGroupDialog.loadPanels(loader);
73
			// End: Test the normal load
74

  
75
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
76
				/*
77
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
78
				 */
79
				public void actionButtonPressed(ButtonsPanelEvent e) {
80
					switch (e.getButton()) {
81
						case ButtonsPanel.BUTTON_ACCEPT:
82
							System.out.println("Accept Button pressed.");
83
							hideJFrame();
84
							System.exit(0);
85
							break;
86
						case ButtonsPanel.BUTTON_CANCEL:
87
							System.out.println("Cancel Button pressed.");
88
							hideJFrame();
89
							System.exit(0);
90
							break;
91
						case ButtonsPanel.BUTTON_APPLY:
92
							System.out.println("Apply Button pressed.");
93
							break;
94
					}
95
				}
96
			});
97
			
98
			jFrame.setTitle("Test resizable PanelGroupDialog with tree and using PanelGroupLoaderFromList");
99
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
100
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
101
		    jFrame.getContentPane().add(panelGroupDialog);
102
		    
103
			jFrame.setVisible(true);			
104
		} catch (BaseException bE) {
105
			System.out.println(bE.getLocalizedMessageStack());
106
		} catch (Exception e) {
107
			e.printStackTrace();
108
		}
109
	}
110
	
111
	/**
112
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
113
	 */
114
	private static void hideJFrame() {
115
		jFrame.setVisible(false);
116
	}
117
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test6ButtonsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
29
import org.gvsig.tools.exception.BaseException;
30

  
31
import org.gvsig.andami.ui.mdiManager.WindowInfo;
32
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
37
 * <p>Tests {@link PanelGroupManager PanelGroupManager}, {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}, 
38
 *  {@link TabbedPanel TabbedPanel}, and a non resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 22/10/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test6ButtonsPanel {
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private static JFrame jFrame;
48

  
49
	/**
50
	 * <p>Test method for the Test6ButtonsPanel.</p>
51
	 * 
52
	 * @param args optional arguments
53
	 */
54
	public static void main(String[] args) {
55
		try {
56
			// Objects creation
57
			jFrame = new JFrame();
58

  
59
			Samples_ExtensionPointsOfIPanels.loadSample();
60

  
61
			PanelGroupManager manager = PanelGroupManager.getManager();
62
			manager.registerPanelGroup(TabbedPanel.class);
63
			manager.setDefaultType(TabbedPanel.class);
64

  
65
			TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1);
66
			
67
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT1_NAME);
68
			
69
			// Creates the IWindow
70
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup);
71

  
72
			// Begin: Test the normal load
73
			panelGroupDialog.loadPanels(loader);
74
			// End: Test the normal load
75
			
76
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
77
				/*
78
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
79
				 */
80
				public void actionButtonPressed(ButtonsPanelEvent e) {
81
					switch (e.getButton()) {
82
						case ButtonsPanel.BUTTON_ACCEPT:
83
							System.out.println("Accept Button pressed.");
84
							hideJFrame();
85
							System.exit(0);
86
							break;
87
						case ButtonsPanel.BUTTON_CANCEL:
88
							System.out.println("Cancel Button pressed.");
89
							hideJFrame();
90
							System.exit(0);
91
							break;
92
						case ButtonsPanel.BUTTON_APPLY:
93
							System.out.println("Apply Button pressed.");
94
							break;
95
					}
96
				}
97
			});
98
			
99
			jFrame.setTitle("Test Non Resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromExtensionPoint");
100
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
101
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
102
		    jFrame.getContentPane().add(panelGroupDialog);
103
		    
104
		    jFrame.setResizable(false);
105
			jFrame.setVisible(true);
106
			
107
		} catch (BaseException bE) {
108
			System.out.println(bE.getLocalizedMessageStack());
109
		} catch (Exception e) {
110
			e.printStackTrace();
111
		}
112
	}
113

  
114
	/**
115
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
116
	 */
117
	private static void hideJFrame() {
118
		jFrame.setVisible(false);
119
	}
120
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test4ButtonsPanelWithExceptionsMessage.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
29
import org.gvsig.tools.exception.BaseException;
30

  
31
import org.gvsig.andami.ui.mdiManager.WindowInfo;
32
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Test method for the Test2ButtonsPanelWithExceptionsMessage.</p>
37
 * <p>Tests the message dialog caused by the exceptions produced during the loading of panels, using {@link PanelGroupManager PanelGroupManager},
38
 *  {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}, {@link TreePanel TreePanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 17/12/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test4ButtonsPanelWithExceptionsMessage {
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private static JFrame jFrame;
48
	private static TreePanel panelGroup;
49

  
50
	/**
51
	 * <p>Test method for the Test4ButtonsPanelWithExceptionsMessage.</p>
52
	 * 
53
	 * @param args optional arguments
54
	 */
55
	public static void main(String[] args) {
56
		try {
57
			// Objects creation
58
			jFrame = new JFrame();
59

  
60
			Samples_ExtensionPointsOfIPanels.loadSample();
61

  
62
			PanelGroupManager manager = PanelGroupManager.getManager();
63
			manager.registerPanelGroup(TreePanel.class);
64
			manager.setDefaultType(TreePanel.class);
65

  
66
			panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3);
67

  
68
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT10_NAME);
69
			
70
			// Creates the IWindow
71
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panel with Buttons", 150, 150, (byte)WindowInfo.RESIZABLE, panelGroup);
72

  
73
			// Begin: Test the normal load
74
			panelGroupDialog.loadPanels(loader);
75
			// End: Test the normal load
76
			
77
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
78
				/*
79
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
80
				 */
81
				public void actionButtonPressed(ButtonsPanelEvent e) {
82
					switch (e.getButton()) {
83
						case ButtonsPanel.BUTTON_ACCEPT:
84
							System.out.println("Accept Button pressed.");
85
							hideJFrame();
86
							System.exit(0);
87
							break;
88
						case ButtonsPanel.BUTTON_CANCEL:
89
							System.out.println("Cancel Button pressed.");
90
							hideJFrame();
91
							System.exit(0);
92
							break;
93
						case ButtonsPanel.BUTTON_APPLY:
94
							System.out.println("Apply Button pressed.");
95
							break;
96
					}
97
				}
98
			});
99

  
100
			jFrame.setTitle("Test resizable PanelGroupDialog with tree and using PanelGroupLoaderFromExtensionPoint");
101
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
102
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
103
		    jFrame.getContentPane().add(panelGroupDialog);
104
		    
105
			jFrame.setVisible(true);	
106
		} catch (BaseException bE) {
107
			System.out.println(bE.getLocalizedMessageStack());
108
		} catch (Exception e) {
109
			e.printStackTrace();
110
		}
111
	}
112
	
113
	/**
114
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
115
	 */
116
	private static void hideJFrame() {
117
		jFrame.setVisible(false);
118
	}
119
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test7ButtonsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
29
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
33

  
34
/**
35
 * <p>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
36
 * <p>Tests {@link PanelGroupManager PanelGroupManager}, {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}, 
37
 *  {@link TreePanel TreePanel}, and a non resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
38
 * 
39
 * @version 22/10/2007
40
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
41
 */
42
public class Test7ButtonsPanel {
43
	/**
44
	 * <p>Element for the interface.</p>
45
	 */
46
	private static JFrame jFrame;
47
	private static TreePanel panelGroup;
48

  
49
	/**
50
	 * <p>Test method for the Test7ButtonsPanel.</p>
51
	 * 
52
	 * @param args optional arguments
53
	 */
54
	public static void main(String[] args) {
55
		try {
56
			jFrame = new JFrame();
57

  
58
			PanelGroupManager manager = PanelGroupManager.getManager();
59
			manager.registerPanelGroup(TreePanel.class);
60
			manager.setDefaultType(TreePanel.class);
61

  
62
			panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1);
63
			
64
			PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS1_CLASSES);
65
			
66
			// Creates the IWindow
67
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 800, 650, (byte)0, panelGroup);
68

  
69
			// Begin: Test the normal load
70
			panelGroupDialog.loadPanels(loader);
71
			// End: Test the normal load
72

  
73
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
74
				/*
75
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
76
				 */
77
				public void actionButtonPressed(ButtonsPanelEvent e) {
78
					switch (e.getButton()) {
79
						case ButtonsPanel.BUTTON_ACCEPT:
80
							System.out.println("Accept Button pressed.");
81
							hideJFrame();
82
							System.exit(0);
83
							break;
84
						case ButtonsPanel.BUTTON_CANCEL:
85
							System.out.println("Cancel Button pressed.");
86
							hideJFrame();
87
							System.exit(0);
88
							break;
89
						case ButtonsPanel.BUTTON_APPLY:
90
							System.out.println("Apply Button pressed.");
91
							break;
92
					}
93
				}
94
			});
95

  
96
			jFrame.setTitle("Test non resizable PanelGroupDialog with a tree and using PanelGroupLoaderFromList");
97
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
98
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
99
		    jFrame.getContentPane().add(panelGroupDialog);
100
		    
101
		    jFrame.setResizable(false);
102
			jFrame.setVisible(true);
103
		} catch (BaseException bE) {
104
			System.out.println(bE.getLocalizedMessageStack());
105
		} catch (Exception e) {
106
			e.printStackTrace();
107
		}
108
	}
109

  
110
	/**
111
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
112
	 */
113
	private static void hideJFrame() {
114
		jFrame.setVisible(false);
115
	}
116
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test8ButtonsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
28
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
29
import org.gvsig.tools.exception.BaseException;
30

  
31
import org.gvsig.andami.ui.mdiManager.WindowInfo;
32
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
33
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

  
35
/**
36
 * <p>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
37
 * <p>Tests {@link PanelGroupManager PanelGroupManager}, {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}, 
38
 *  {@link TreePanel TreePanel}, and a non resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 22/10/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test8ButtonsPanel {
44
	/**
45
	 * <p>Element for the interface.</p>
46
	 */
47
	private static JFrame jFrame;
48
	private static TreePanel panelGroup;
49

  
50
	/**
51
	 * <p>Test method for the Test8ButtonsPanel.</p>
52
	 * <p>Tests the G.U.I. when adds panels with different dimensions, to a resizable <code>PanelGroupDialog</code>.</p>
53
	 * 
54
	 * @param args optional arguments
55
	 */
56
	public static void main(String[] args) {
57
		try {
58
			jFrame = new JFrame();
59

  
60
			PanelGroupManager manager = PanelGroupManager.getManager();
61
			manager.registerPanelGroup(TreePanel.class);
62
			manager.setDefaultType(TreePanel.class);
63

  
64
			Samples_ExtensionPointsOfIPanels.loadSample();
65

  
66
			panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1);
67
			
68
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT1_NAME);
69
			
70
			// Creates the IWindow
71
			PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 150, 150, (byte)WindowInfo.RESIZABLE, panelGroup);
72

  
73
			// Begin: Test the normal load
74
			panelGroupDialog.loadPanels(loader);
75
			// End: Test the normal load
76
			
77
			panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
78
				/*
79
				 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
80
				 */
81
				public void actionButtonPressed(ButtonsPanelEvent e) {
82
					switch (e.getButton()) {
83
						case ButtonsPanel.BUTTON_ACCEPT:
84
							System.out.println("Accept Button pressed.");
85
							hideJFrame();
86
							System.exit(0);
87
							break;
88
						case ButtonsPanel.BUTTON_CANCEL:
89
							System.out.println("Cancel Button pressed.");
90
							hideJFrame();
91
							System.exit(0);
92
							break;
93
						case ButtonsPanel.BUTTON_APPLY:
94
							System.out.println("Apply Button pressed.");
95
							break;
96
					}
97
				}
98
			});
99
			
100
			jFrame.setTitle("Test non resizable PanelGroupDialog with a tree and using PanelGroupLoaderFromExtensionPoint");
101
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
102
		    jFrame.setSize(panelGroupDialog.getPreferredSize());
103
		    jFrame.getContentPane().add(panelGroupDialog);
104
		    
105
		    jFrame.setResizable(false);
106
			jFrame.setVisible(true);
107
		} catch (BaseException bE) {
108
			System.out.println(bE.getLocalizedMessageStack());
109
		} catch (Exception e) {
110
			e.printStackTrace();
111
		}
112
	}
113

  
114
	/**
115
	 * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
116
	 */
117
	private static void hideJFrame() {
118
		jFrame.setVisible(false);
119
	}
120
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test2ExceptionsUsingTreePanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import junit.framework.TestCase;
23

  
24
import org.gvsig.gui.beans.Messages;
25
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
26
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
27
import org.gvsig.tools.exception.BaseException;
28

  
29
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
30
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
31

  
32
/**
33
 * <p>Tests the loading of layers using a {@link TreePanel TreePanel} object and a {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint} loader
34
 * Tests also the managing of the different kind of exceptions which could be launched during this process.</p>
35
 * 
36
 * @version 11/12/2007
37
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
38
 */
39
public class Test2ExceptionsUsingTreePanel extends TestCase {
40
	private TreePanel panelGroup;
41
	private PanelGroupManager manager;
42
	private PanelGroupLoaderFromExtensionPoint loader;
43
	private String validationText;
44
	private String localizedMessage;
45

  
46
	/*
47
	 * (non-Javadoc)
48
	 * @see junit.framework.TestCase#setUp()
49
	 */
50
	protected void setUp() throws Exception {
51
		super.setUp();
52

  
53
		manager = PanelGroupManager.getManager();
54
		manager.registerPanelGroup(TreePanel.class);
55
		manager.setDefaultType(TreePanel.class);
56
		panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3);
57
	}
58

  
59
	/*
60
	 * (non-Javadoc)
61
	 * @see junit.framework.TestCase#tearDown()
62
	 */
63
	protected void tearDown() throws Exception {
64
		super.tearDown();
65
		manager.deregisterPanelGroup(TreePanel.class);
66
	}
67
	
68
	/**
69
	 * <p>Test the 'PanelGroup' exceptions </p>
70
	 */
71
	public void test1() {
72
		Samples_ExtensionPointsOfIPanels.loadSample();
73

  
74
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n  Error cargando un panel: / by zero.";
75

  
76
		try {
77
			System.out.println("----- Test 1 -----");
78
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT4_NAME);
79

  
80
			// Begin: Test the normal load
81
			panelGroup.loadPanels(loader);
82
			// End: Test the normal load
83
		} catch (BaseException bE) {
84
			localizedMessage = bE.getLocalizedMessageStack();
85
			System.out.println(localizedMessage);
86
			System.out.println("------------------");
87
			assertEquals(localizedMessage, validationText);
88
			return;
89
		} catch (Exception e) {
90
			e.printStackTrace();
91
			System.out.println("------------------");
92
			fail();
93
			return;
94
		}
95

  
96
		System.out.println("------------------");
97
		fail();
98
	}
99
	
100
	/**
101
	 * <p>Test the 'PanelGroup' exceptions </p>
102
	 */
103
	public void test2() {
104
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  Panel de etiqueta Information_LABEL sin tama?o inicial definido.";
105

  
106
		try {
107
			System.out.println("----- Test 2 -----");
108
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT5_NAME);
109

  
110
			// Begin: Test the normal load
111
			panelGroup.loadPanels(loader);
112
			// End: Test the normal load
113
		} catch (BaseException bE) {
114
			localizedMessage = bE.getLocalizedMessageStack().trim();
115
			System.out.println(localizedMessage);
116
			System.out.println("------------------");
117
			assertEquals(localizedMessage, validationText);
118
			return;
119
		} catch (Exception e) {
120
			e.printStackTrace();
121
			System.out.println("------------------");
122
			fail();
123
			return;
124
		}
125

  
126
		System.out.println("------------------");
127
		fail();
128
	}
129
	
130
	/**
131
	 * <p>Test the 'PanelGroup' exceptions </p>
132
	 */
133
	public void test3() {
134
		validationText = Messages.getText("empty_panel_group_exception");
135

  
136
		try {
137
			System.out.println("----- Test 3 -----");
138
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT6_NAME);
139

  
140
			// Begin: Test the normal load
141
			panelGroup.loadPanels(loader);
142
			// End: Test the normal load
143
		} catch (BaseException bE) {
144
			localizedMessage = bE.getLocalizedMessageStack().trim();
145
			System.out.println(localizedMessage);
146
			System.out.println("------------------");
147
			assertEquals(localizedMessage, validationText);
148
			return;
149
		} catch (Exception e) {
150
			e.printStackTrace();
151
			System.out.println("------------------");
152
			fail();
153
			return;
154
		}
155

  
156
		System.out.println("------------------");
157
		fail();
158
	}
159
	
160
	/**
161
	 * <p>Test the 'PanelGroup' exceptions </p>
162
	 */
163
	public void test4() {
164
		validationText = Messages.getText("empty_panel_group_gui_exception");
165

  
166
		try {
167
			System.out.println("----- Test 4 -----");
168
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT7_NAME);
169

  
170
			// Begin: Test the normal load
171
			panelGroup.loadPanels(loader);
172
			// End: Test the normal load
173
		} catch (BaseException bE) {
174
			localizedMessage = bE.getLocalizedMessageStack().trim();
175
			System.out.println(localizedMessage);
176
			System.out.println("------------------");
177
			assertEquals(localizedMessage, validationText);
178
			return;
179
		} catch (Exception e) {
180
			e.printStackTrace();
181
			System.out.println("------------------");
182
			fail();
183
			return;
184
		}
185

  
186
		System.out.println("------------------");
187
		fail();
188
	}
189
	
190
	/**
191
	 * <p>Test the 'PanelGroup' exceptions </p>
192
	 */
193
	public void test5() {
194
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n  Error cargando un panel: / by zero.\n  Panel de etiqueta Information_LABEL sin tama?o inicial definido.\n  " + Messages.getText("empty_panel_group_exception");
195

  
196
		try {
197
			System.out.println("----- Test 5 -----");
198
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT8_NAME);
199

  
200
			// Begin: Test the normal load
201
			panelGroup.loadPanels(loader);
202
			// End: Test the normal load
203
		} catch (BaseException bE) {
204
			localizedMessage = bE.getLocalizedMessageStack().trim();
205
			System.out.println(localizedMessage);
206
			System.out.println("------------------");
207
			assertEquals(localizedMessage, validationText);
208
			return;
209
		} catch (Exception e) {
210
			e.printStackTrace();
211
			System.out.println("------------------");
212
			fail();
213
			return;
214
		}
215

  
216
		System.out.println("------------------");
217
		fail();
218
	}
219
	
220
	/**
221
	 * <p>Test the 'PanelGroup' exceptions </p>
222
	 */
223
	public void test6() {
224
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n  Error cargando un panel: / by zero.\n  Panel de etiqueta Information_LABEL sin tama?o inicial definido.\n  " + Messages.getText("empty_panel_group_gui_exception");
225

  
226
		try {
227
			System.out.println("----- Test 6 -----");
228
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT9_NAME);
229

  
230
			// Begin: Test the normal load
231
			panelGroup.loadPanels(loader);
232
			// End: Test the normal load
233
		} catch (BaseException bE) {
234
			localizedMessage = bE.getLocalizedMessageStack().trim();
235
			System.out.println(localizedMessage);
236
			System.out.println("------------------");
237
			assertEquals(localizedMessage, validationText);
238
			return;
239
		} catch (Exception e) {
240
			e.printStackTrace();
241
			System.out.println("------------------");
242
			fail();
243
			return;
244
		}
245

  
246
		System.out.println("------------------");
247
		fail();
248
	}
249
	
250
	/**
251
	 * <p>Test the 'PanelGroup' exceptions </p>
252
	 */
253
	public void test7() {
254
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_extension_point_exception") + "\n  Error cargando un panel: / by zero.\n  Panel de etiqueta Information_LABEL sin tama?o inicial definido.";
255

  
256
		try {
257
			System.out.println("----- Test 7 -----");
258
			loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT10_NAME);
259

  
260
			// Begin: Test the normal load
261
			panelGroup.loadPanels(loader);
262
			// End: Test the normal load
263
		} catch (BaseException bE) {
264
			localizedMessage = bE.getLocalizedMessageStack().trim();
265
			System.out.println(localizedMessage);
266
			System.out.println("------------------");
267
			assertEquals(localizedMessage, validationText);
268
			return;
269
		} catch (Exception e) {
270
			e.printStackTrace();
271
			System.out.println("------------------");
272
			fail();
273
			return;
274
		}
275

  
276
		System.out.println("------------------");
277
		fail();
278
	}
279
}
tags/v_2_0_0_Build_2043/applications/appgvSIG/appgvSIG/src-test/org/gvsig/app/panelGroup/Test2TabbedPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.app.panelGroup;
21

  
22
import javax.swing.JFrame;
23

  
24
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
25
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
26
import org.gvsig.tools.exception.BaseException;
27

  
28
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
29
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
30

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

  
51
			TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE2);
52
			PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT2_NAME);
53

  
54
			// Begin: Test the normal load
55
			panelGroup.loadPanels(loader);
56
			// End: Test the normal load
57

  
58
			// Objects creation
59
			JFrame jFrame = new JFrame();
60
			jFrame.setTitle("Test TabbedPanel using PanelGroupLoaderFromExtensionPoint");
61
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
62
		    jFrame.setSize(panelGroup.getPreferredSize());
63
		    jFrame.getContentPane().add(panelGroup);
64
		    
65
			jFrame.setVisible(true);
66
			
67
		} catch (BaseException bE) {
68
			System.out.println(bE.getLocalizedMessageStack());
69
		} catch (Exception e) {
70
			e.printStackTrace();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff