Revision 39252

View differences:

tags/v2_0_0_Build_2058/libraries/libUIComponent/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5

  
6
	<modelVersion>4.0.0</modelVersion>
7
	<artifactId>org.gvsig.ui</artifactId>
8
	<packaging>jar</packaging>
9
	<version>2.0.1-SNAPSHOT</version>
10
	<name>libUIComponent</name>
11
	<description>Swing components collection</description>
12
	<parent>
13
		<groupId>org.gvsig</groupId>
14
		<artifactId>org.gvsig.maven.base.pom</artifactId>
15
		<version>1.0.8-SNAPSHOT</version>
16
	</parent>
17
	<scm>
18
		<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/libUIComponent</connection>
19
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/branches/v2_0_0_prep/libraries/libUIComponent</developerConnection>
20
		<url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/branches/v2_0_0_prep/libraries/libUIComponent</url>
21
	</scm>
22
	<repositories>
23
		<repository>
24
			<id>gvsig-public-http-repository</id>
25
			<name>gvSIG maven public HTTP repository</name>
26
			<url>http://devel.gvsig.org/m2repo/j2se</url>
27
			<releases>
28
				<enabled>true</enabled>
29
				<updatePolicy>daily</updatePolicy>
30
				<checksumPolicy>warn</checksumPolicy>
31
			</releases>
32
			<snapshots>
33
				<enabled>true</enabled>
34
				<updatePolicy>daily</updatePolicy>
35
				<checksumPolicy>warn</checksumPolicy>
36
			</snapshots>
37
		</repository>
38
	</repositories>
39
	<dependencyManagement>
40
		<dependencies>
41
			<dependency>
42
				<groupId>org.gvsig</groupId>
43
				<artifactId>org.gvsig.core.maven.dependencies</artifactId>
44
				<version>2.0.1-SNAPSHOT</version>
45
				<type>pom</type>
46
				<scope>import</scope>
47
			</dependency>
48
		</dependencies>
49
	</dependencyManagement>
50
	<dependencies>
51
		<dependency>
52
			<groupId>org.gvsig</groupId>
53
			<artifactId>org.gvsig.i18n</artifactId>
54
			<scope>compile</scope>
55
		</dependency>
56
		<dependency>
57
			<groupId>org.gvsig</groupId>
58
			<artifactId>org.gvsig.tools.lib</artifactId>
59
			<scope>compile</scope>
60
		</dependency>
61
		<dependency>
62
			<groupId>org.jfree</groupId>
63
			<artifactId>jfreechart</artifactId>
64
			<scope>compile</scope>
65
		</dependency>
66
		<dependency>
67
			<groupId>net.sf</groupId>
68
			<artifactId>flib-jcalendar</artifactId>
69
			<scope>compile</scope>
70
		</dependency>
71
		<dependency>
72
			<groupId>jwizardcomponent</groupId>
73
			<artifactId>jwizardcomponent</artifactId>
74
			<scope>compile</scope>
75
		</dependency>
76
		<dependency>
77
			<groupId>org.slf4j</groupId>
78
			<artifactId>slf4j-api</artifactId>
79
			<scope>compile</scope>
80
		</dependency>
81
		<dependency>
82
			<groupId>org.gvsig.external</groupId>
83
			<artifactId>org.gvsig.external.jump</artifactId>
84
			<scope>compile</scope>
85
			<version>1.0.0-SNAPSHOT</version>
86
		</dependency>
87
	</dependencies>
88
	<build>
89
		<sourceDirectory>src</sourceDirectory>
90
		<testSourceDirectory>src-test-ui</testSourceDirectory>
91
		<resources>
92
			<resource>
93
				<directory>src</directory>
94
				<includes>
95
					<include>**/*.gif</include>
96
					<include>**/*.png</include>
97
					<include>**/*.PNG</include>
98
					<include> **/*.bmp</include>
99
					<include> **/*.jpg</include>
100
					<include> **/*.jpeg</include>
101
					<include> **/*.properties</include>
102
				</includes>
103
			</resource>
104
			<resource>
105
				<targetPath>org/gvsig/gui/beans/resources/translations</targetPath>
106
				<filtering>false</filtering>
107
				<directory>${basedir}/config</directory>
108
				<includes>
109
					<include>*.properties</include>
110
				</includes>
111
			</resource>
112
		</resources>
113
		<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
114
		<plugins>
115
			<plugin>
116
				<groupId>org.apache.maven.plugins</groupId>
117
				<artifactId>maven-surefire-plugin</artifactId>
118
				<configuration>
119
					<skipTests>true</skipTests>
120
				</configuration>
121
			</plugin>
122
			<plugin>
123
				<groupId>org.apache.maven.plugins</groupId>
124
				<artifactId>maven-compiler-plugin</artifactId>
125
				<configuration>
126
					<testExcludes>
127
						<exclude>**</exclude>
128
					</testExcludes>
129
				</configuration>
130
			</plugin>
131
		</plugins>
132
	</build>
133

  
134
	<profiles>
135
		<profile>
136
			<id>eclipse-project</id>
137
			<build>
138
				<plugins>
139
					<plugin>
140
						<artifactId>maven-antrun-plugin</artifactId>
141
						<configuration>
142
							<tasks>
143
								<ant antfile="${basedir}/../build/ant-tasks/eclipse-tasks.xml"
144
									target="eclipse.eclipse" />
145
							</tasks>
146
						</configuration>
147
						<dependencies>
148
							<dependency>
149
								<groupId>org.apache.ant</groupId>
150
								<artifactId>ant-trax</artifactId>
151
								<version>1.7.1</version>
152
							</dependency>
153
							<dependency>
154
								<groupId>xalan</groupId>
155
								<artifactId>xalan</artifactId>
156
								<version>2.6.0</version>
157
							</dependency>
158
						</dependencies>
159
					</plugin>
160
				</plugins>
161
			</build>
162
		</profile>
163
		<profile>
164
			<id>gvsig-install</id>
165
			<activation>
166
				<activeByDefault>true</activeByDefault>
167
			</activation>
168
			<properties>
169
				<!-- gvSIG installation folder -->
170
				<gvsig.install.dir>${basedir}/../build/product
171
				</gvsig.install.dir>
172
			</properties>
173
		</profile>
174
	</profiles>
175
	<properties>
176
		<eclipse.project.name>libUIComponent</eclipse.project.name>
177
	</properties>
178
</project>
tags/v2_0_0_Build_2058/libraries/libUIComponent/.cvsignore
1
bin
2
bin-test
0 3

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/listview/TestListView.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
package org.gvsig.gui.beans.listview;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
23
import java.awt.GridBagConstraints;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26

  
27
import javax.swing.JButton;
28
import javax.swing.JCheckBox;
29
import javax.swing.JFrame;
30
import javax.swing.JPanel;
31
import javax.swing.JScrollPane;
32
/**
33
 * @version 28/06/2007
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class TestListView implements ActionListener {
37
	private JFrame jFrame = null;
38
	private JScrollPane jScrollPane = null;
39
	private ListViewComponent listViewComponent = null;
40
	JButton botonAdd = null;
41
	JButton botonDel = null;
42
	JCheckBox multiselect = null;
43
	JCheckBox enabled = null;
44

  
45
	public TestListView() {
46
		initialize();
47
	}
48

  
49
	private void initialize() {
50
		jFrame = new JFrame();
51
		jScrollPane = new JScrollPane();
52

  
53
		listViewComponent = new ListViewComponent();
54
		listViewComponent.setEditable(true);
55
		jScrollPane.setViewportView(listViewComponent);
56

  
57
		for (int i=0; i<1000; i++) {
58
			ListViewItem item = new ListViewItem(new RampPainter(), "Prueba-" + i);
59
			listViewComponent.addItem(item, true);
60
		}
61

  
62
		JPanel jpane = new JPanel();
63
		jpane.setLayout(new BorderLayout());
64
		jpane.add(jScrollPane, BorderLayout.CENTER);
65

  
66
		JPanel jPanel1 = new JPanel();
67
		jPanel1.setLayout(new java.awt.GridBagLayout());
68

  
69
		jpane.add(jPanel1, BorderLayout.SOUTH);
70

  
71
		botonAdd = new JButton("Add");
72
		botonAdd.addActionListener(this);
73
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
74
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 2);
75
		jPanel1.add(botonAdd, gridBagConstraints);
76

  
77
		botonDel = new JButton("Del");
78
		botonDel.addActionListener(this);
79
		gridBagConstraints = new java.awt.GridBagConstraints();
80
		gridBagConstraints.gridx = 1;
81
		gridBagConstraints.gridy = 0;
82
		gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 5);
83
		jPanel1.add(botonDel, gridBagConstraints);
84

  
85
		multiselect = new JCheckBox("MultiSelect");
86
		multiselect.addActionListener(this);
87
		gridBagConstraints = new java.awt.GridBagConstraints();
88
		gridBagConstraints.gridx = 0;
89
		gridBagConstraints.gridy = 1;
90
		gridBagConstraints.gridwidth = 2;
91
		gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
92
		jPanel1.add(multiselect, gridBagConstraints);
93

  
94
		enabled = new JCheckBox("Activo");
95
		enabled.addActionListener(this);
96
		enabled.setSelected(true);
97
		gridBagConstraints = new java.awt.GridBagConstraints();
98
		gridBagConstraints.gridx = 0;
99
		gridBagConstraints.gridy = 2;
100
		gridBagConstraints.gridwidth = 2;
101
		gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5);
102
		jPanel1.add(enabled, gridBagConstraints);
103

  
104
		jFrame.setSize(new Dimension(192, 300));
105
		jFrame.setContentPane(jpane);
106

  
107
		jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
108
		jFrame.setVisible(true);
109
	}
110

  
111
	/**
112
	 * @param args
113
	 */
114
	public static void main(String[] args) {
115
		new TestListView();
116
	}
117

  
118
	int id = 0;
119
	/*
120
	 * (non-Javadoc)
121
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
122
	 */
123
	public void actionPerformed(ActionEvent e) {
124
		if (e.getSource() == botonAdd) {
125
			ListViewItem item = new ListViewItem(new RampPainter(), "Prueba");
126
			listViewComponent.addItem(item);
127
			return;
128
		}
129

  
130
		if (e.getSource() == botonDel) {
131
			listViewComponent.removeSelecteds();
132
			return;
133
		}
134

  
135
		if (e.getSource() == multiselect) {
136
			listViewComponent.setMultiSelect(multiselect.isSelected());
137
			return;
138
		}
139

  
140
		if (e.getSource() == enabled) {
141
			listViewComponent.setEnabled(enabled.isSelected());
142
			jScrollPane.setEnabled(enabled.isSelected());
143
			return;
144
		}
145
	}
146
}
0 147

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/listview/RampPainter.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
package org.gvsig.gui.beans.listview;
20

  
21
import java.awt.Color;
22
import java.awt.GradientPaint;
23
import java.awt.Graphics2D;
24
import java.awt.Rectangle;
25
import java.awt.Shape;
26
/**
27
 *
28
 * @version 29/06/2007
29
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
30
 */
31
public class RampPainter implements IIconPaint {
32

  
33
	public RampPainter() {
34
	}
35

  
36
	public void paint(Graphics2D g, boolean isSelected) {
37
		Shape clip = g.getClip();
38
		Rectangle area = clip.getBounds();
39

  
40
		int x1 = area.x;
41
		int x2 = area.x + area.width - 1;
42

  
43
		Color color1 = Color.green;
44
		Color color2 = Color.red;
45
		g.setPaint(new GradientPaint(area.x, 0, color1, area.x + area.width, 0, color2, false));
46
		g.fillRect(area.x, area.y, area.width, area.height);
47

  
48
		if (isSelected)
49
			g.setColor(Color.black);
50
		else
51
			g.setColor(new Color(96, 96, 96));
52
		g.drawRect(x1, area.y, x2 - x1, area.height - 1);
53
	}
54
}
0 55

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/colorbutton/TestColorButton.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
package org.gvsig.gui.beans.colorbutton;
20

  
21
import java.awt.Dimension;
22

  
23
import javax.swing.JPanel;
24

  
25
import org.gvsig.gui.beans.TestUI;
26
/**
27
* Test del ColorButton
28
*
29
* @version 08/05/2007
30
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
31
*/
32
public class TestColorButton implements ColorButtonListener {
33
	private TestUI       jFrame       = null;
34
	private ColorButton colorButton = null;
35

  
36
	public TestColorButton() {
37
		initialize();
38
	}
39

  
40
	private void initialize() {
41
		colorButton = new ColorButton();
42
		colorButton.setEnabled(true);
43
		colorButton.addValueChangedListener(this);
44
		jFrame = new TestUI("TestColorButton");
45
		JPanel jpanel = new JPanel();
46
		jpanel.add(colorButton);
47
		jFrame.setSize(new Dimension(598, 167));
48
		jFrame.setContentPane(jpanel);
49
		jFrame.pack();
50
		jFrame.setVisible(true);
51
	}
52

  
53
	/**
54
	 * @param args
55
	 */
56
	public static void main(String[] args) {
57
		new TestColorButton();
58
	}
59

  
60
	public void actionValueChanged(ColorButtonEvent e) {
61
		System.out.println("actionValueChanged");
62
	}
63

  
64
	public void actionValueDragged(ColorButtonEvent e) {
65
		System.out.println("actionValueDragged");
66
	}
67
}
0 68

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/propertiespanel/TestPropertiesPanel.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
package org.gvsig.gui.beans.propertiespanel;
20

  
21
import java.awt.Toolkit;
22
import java.util.ArrayList;
23
import java.util.EventObject;
24

  
25
import org.gvsig.gui.beans.TestUI;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
29

  
30
public class TestPropertiesPanel implements ButtonsPanelListener, PropertiesComponentListener {
31
	TestUI frame = null;
32
	PropertiesPanel pd = null;
33

  
34
	public TestPropertiesPanel() {
35
		initialize();
36
	}
37

  
38
	public void initialize() {
39
		Toolkit.getDefaultToolkit().setDynamicLayout(true);
40
		frame = new TestUI("TestPropertiesPanel");
41
		pd = new PropertiesPanel();
42

  
43
		pd.addButtonPressedListener(this);
44
		pd.addValue("Protocolo", "protocolo", "", null);
45
		pd.addValue("Integer", "var1", new Integer(50), null);
46
		{
47
			Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(-255), new Integer(255)};
48
			pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
49
			Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
50
			pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider
51
			Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)};
52
			pd.addValue("Slider", "slider3", new Double(25), types3); // Slider
53
		}
54
		pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
55
		{
56
			ArrayList lista = new ArrayList();
57
			lista.add("Primer elemento");
58
			lista.add("Segundo elemento");
59
			lista.add("Tercer elemento");
60
			PropertyStruct property = new PropertyStruct();
61
			property.setTextLabel("Combo");
62
			property.setKey("combo1");
63
			property.setOldValue(new Integer(1));
64
			Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
65
			property.setExtras(types);
66
			pd.addPropertyStruct(property);
67
		}
68
		frame.getContentPane().add(pd);
69
		frame.pack();
70
		pd.addStateChangedListener(this);
71
		frame.setVisible(true);
72
	}
73

  
74
	public static void main(String[] args) {
75
		new TestPropertiesPanel();
76
	}
77

  
78
	public void actionButtonPressed(ButtonsPanelEvent e) {
79
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
80
			ArrayList values = pd.getValues();
81
			System.out.println("-----");
82
			for (int i=0; i<values.size(); i++) {
83
				System.out.println(((PropertyStruct)values.get(i)).getKey()
84
						+ ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
85
						+ "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'");
86
				System.out.println(pd.getComponentUI(((PropertyStruct)values.get(i)).getKey()).toString());
87
			}
88
		}
89
	}
90

  
91
	public void actionChangeProperties(EventObject e) {
92
		System.out.println("Ha cambiado");
93
		System.out.println(pd.getProperties().get("slider3"));
94
	}
95
}
0 96

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/propertiespanel/ui/TestSlider.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
package org.gvsig.gui.beans.propertiespanel.ui;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionListener;
24

  
25
import javax.swing.JButton;
26
import javax.swing.JColorChooser;
27
import javax.swing.event.ChangeEvent;
28
import javax.swing.event.ChangeListener;
29

  
30
import org.gvsig.gui.beans.propertiespanel.JPanelProperty;
31
/**
32
 * Panel que ira dentro del panel de propiedades
33
 *
34
 * @version 06/06/2007
35
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class TestSlider extends JPanelProperty implements ChangeListener, ActionListener {
38
	private static final long serialVersionUID = -4936433530376831937L;
39

  
40
	public TestSlider() {
41
		initialize();
42
	}
43

  
44
	private void initialize() {
45
		setLayout(new BorderLayout());
46
		JColorChooser color = new JColorChooser();
47
		add(color, BorderLayout.CENTER);
48
		JButton boton = new JButton("OK");
49
		add(boton, BorderLayout.SOUTH);
50
		boton.addActionListener(this);
51
		color.getSelectionModel().addChangeListener(this);
52
	}
53

  
54
	public void stateChanged(ChangeEvent e) {
55
		this.callStateChanged();
56
	}
57

  
58
	public void actionPerformed(ActionEvent e) {
59
		this.callStateChanged();
60
	}
61
}
0 62

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/propertiespanel/TestPropertiesPanel2.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
package org.gvsig.gui.beans.propertiespanel;
20

  
21
import java.util.ArrayList;
22
import java.util.EventObject;
23

  
24
import org.gvsig.gui.beans.TestUI;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
28

  
29
public class TestPropertiesPanel2 implements ButtonsPanelListener, PropertiesComponentListener {
30
	TestUI frame = null;
31
	PropertiesPanel pd = null;
32

  
33
	public TestPropertiesPanel2() {
34
		initialize();
35
	}
36

  
37
	public void initialize() {
38
		frame = new TestUI("TestPropertiesPanel2");
39
		pd = new PropertiesPanel();
40

  
41
		pd.addButtonPressedListener(this);
42
		pd.addValue("Protocolo", "protocolo", "", null);
43
		pd.addValue("Integer", "var1", new Integer(50), null);
44
		{
45
			Object[] types = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(-255), new Integer(255)};
46
			pd.addValue("Slider", "slider1", new Integer(25), types); // Slider
47
			Object[] types2 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(50)};
48
			pd.addValue("Slider", "slider2", new Integer(25), types2); // Slider
49
			Object[] types3 = {new Integer(PropertiesComponent.TYPE_SLIDER), new Integer(0), new Integer(100)};
50
			pd.addValue("Slider", "slider3", new Integer(25), types3); // Slider
51
		}
52
		pd.addValue("Activo", "check1", new Boolean(true), null); // Slider
53
		{
54
			ArrayList lista = new ArrayList();
55
			lista.add("Primer elemento");
56
			lista.add("Segundo elemento");
57
			lista.add("Tercer elemento");
58
			PropertyStruct property = new PropertyStruct();
59
			property.setTextLabel("Combo");
60
			property.setKey("combo1");
61
			property.setOldValue(new Integer(1));
62
			Object[] types = {new Integer(PropertiesComponent.TYPE_COMBO), lista};
63
			property.setExtras(types);
64
			pd.addPropertyStruct(property);
65

  
66
			pd = new PropertiesPanel(pd.getProperties());
67
		}
68
		frame.getContentPane().add(pd);
69
		frame.pack();
70
		pd.addStateChangedListener(this);
71
		frame.setVisible(true);
72
	}
73

  
74
	public static void main(String[] args) {
75
		new TestPropertiesPanel2();
76
	}
77

  
78
	public void actionButtonPressed(ButtonsPanelEvent e) {
79
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
80
			ArrayList values = pd.getValues();
81
			System.out.println("-----");
82
			for (int i=0; i<values.size(); i++) {
83
				System.out.println(((PropertyStruct)values.get(i)).getKey()
84
						+ ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
85
						+ "', '" + ((PropertyStruct)values.get(i)).getNewValue().toString() + "'");
86
			}
87
		}
88
	}
89

  
90
	public void actionChangeProperties(EventObject e) {
91
		System.out.println("Ha cambiado");
92
	}
93
}
0 94

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/propertiespanel/TestPropertiesPanel_JPanel.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
package org.gvsig.gui.beans.propertiespanel;
20

  
21
import java.util.ArrayList;
22
import java.util.EventObject;
23

  
24
import org.gvsig.gui.beans.TestUI;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
28
import org.gvsig.gui.beans.propertiespanel.ui.TestSlider;
29
/**
30
 * Test para comprobar que se puede integrar un JPanelProperty dentro del
31
 * PropertiesComponent
32
 *
33
 * @version 06/06/2007
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class TestPropertiesPanel_JPanel implements ButtonsPanelListener, PropertiesComponentListener {
37
	private TestUI          jFrame = null;
38
	private PropertiesPanel pd     = null;
39

  
40
	public TestPropertiesPanel_JPanel() {
41
		initialize();
42
	}
43

  
44
	public void initialize() {
45
		jFrame = new TestUI("TestPropertiesPanel_JPanel");
46
		pd = new PropertiesPanel();
47

  
48
		pd.addButtonPressedListener(this);
49
		TestSlider ts = new TestSlider();
50
		pd.addValue("Protocolo", "protocolo", "", null);
51
		pd.addValue("Integer", "var1", new Integer(50), null);
52
		pd.addValue("Mi panel", "mipanel", ts, null);
53

  
54
		jFrame.getContentPane().add(pd);
55
		pd.addStateChangedListener(this);
56
		jFrame.pack();
57
		jFrame.setVisible(true);
58
	}
59

  
60
	public static void main(String[] args) {
61
		new TestPropertiesPanel_JPanel();
62
	}
63

  
64
	public void actionButtonPressed(ButtonsPanelEvent e) {
65
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
66
			ArrayList values = pd.getValues();
67
			System.out.println("-----");
68
			for (int i = 0; i < values.size(); i++) {
69
				System.out.println(((PropertyStruct)values.get(i)).getKey()
70
					+ ": '" + ((PropertyStruct)values.get(i)).getOldValue().toString()
71
					+ "', '" + ((PropertyStruct)values.get(i)).getNewValue() + "'");
72
			}
73
		}
74
	}
75

  
76
	public void actionChangeProperties(EventObject e) {
77
		System.out.println("Ha cambiado");
78
	}
79
}
0 80

  
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/Test1TreePanel.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.gui.beans.panelGroup;
21

  
22
import java.awt.BorderLayout;
23
import java.awt.Dimension;
24
import java.util.ArrayList;
25

  
26
import javax.swing.JFrame;
27
import javax.swing.JTree;
28
import javax.swing.event.TreeSelectionEvent;
29
import javax.swing.event.TreeSelectionListener;
30

  
31
import org.gvsig.tools.exception.BaseException;
32
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
33
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
34
import org.gvsig.gui.beans.panelGroup.panels.IPanel;
35
import org.gvsig.gui.beans.panelGroup.samples.SampleInfoPanel;
36
import org.gvsig.gui.beans.panelGroup.samples.SamplePanelWithoutGroupLabel;
37
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data;
38
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
39

  
40
/**
41
 * <p>Tests the creation of a {@link TreePanel TreePanel} object using {@link PanelGroupLoaderFromList PanelGroupLoaderFromList} .</p>
42
 * 
43
 * @version 17/10/2007
44
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
45
 */
46
public class Test1TreePanel {
47
	private static JFrame jFrame;
48
	private static TreePanel panelGroup;
49
	
50
	/**
51
	 * <p>Test method for the Test1TreePanel.</p>
52
	 * 
53
	 * @param args optional arguments
54
	 */
55
	public static void main(String[] args) {
56
		try {
57
			PanelGroupManager manager = PanelGroupManager.getManager();
58
			manager.registerPanelGroup(TreePanel.class);
59
			manager.setDefaultType(TreePanel.class);
60

  
61
			// Use the defined  samples 
62
//			Class[] panelClass = new Class[Samples_Data.TEST1_CLASSES.length];
63
//			int i;
64
//			
65
//			for (i = 0; i < Samples_Data.TEST1_CLASSES.length; i ++) {
66
//				panelClass[i] = Samples_Data.TEST1_CLASSES[i];
67
//			}
68

  
69
			panelGroup = (TreePanel) manager.getPanelGroup(Samples_Data.REFERENCE1);
70
			PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_Data.TEST1_CLASSES);
71

  
72
			// Begin: Test the normal load
73
			panelGroup.loadPanels(loader);
74
			// End: Test the normal load
75
			
76
			// Begin: Other tests
77
			ArrayList<IPanel> panels = new ArrayList<IPanel>();
78

  
79
			loader.loadPanels(panels);
80

  
81
			// Begin: Initialise sample classes
82
//			i = 0;
83
//
84
//			for (AbstractPanel panel: panels) {
85
//				panel.setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT));
86
//				panel.setReference(Samples_Data.REFERENCE1);
87
//				
88
//				panel.setID(Samples_Data.PANELS1_IDS[i]);
89
//				panel.setLabel(Samples_Data.PANELS1_LABELS[i]);
90
//				panel.setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[i++]);
91
//				
92
//				panelGroup.addPanel(panel);
93
//			}
94
			// End: Initialise sample classes
95
			
96
			// Begin: Tests adding and removing a panel without "label" -> this shoudn't add that panel
97
			panels = new ArrayList<IPanel>();
98
			loader = new PanelGroupLoaderFromList(new Class[]{SampleInfoPanel.class, SampleInfoPanel.class, SamplePanelWithoutGroupLabel.class});
99
			loader.loadPanels(panels);
100
			((AbstractPanel)panels.get(0)).setPreferredSize(new Dimension(600, 700));
101
			panels.get(0).setReference(Samples_Data.REFERENCE1);
102
			panels.get(0).setID("ID");
103
			panels.get(0).setLabel(null);
104
			panels.get(0).setLabelGroup("LABEL_GROUP");
105
			panelGroup.addPanel(panels.get(0));
106
			AbstractPanel incorrectAPanel = (AbstractPanel) panels.get(0);
107
			//panelGroup.removePanel(panels.get(0));
108
			// End: Tests adding and removing a panel without "label" -> this shoudn't add that panel
109

  
110
			// Begin: Tests adding and removing a panel
111
			((AbstractPanel)panels.get(1)).setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT));
112
			panels.get(1).setReference(Samples_Data.REFERENCE1);
113
			panels.get(1).setID("ID");
114
			panels.get(1).setLabel("LABEL_TEST_REPEATED_GROUP");
115
			panels.get(1).setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[0]);
116
			panelGroup.addPanel(panels.get(1));
117
			AbstractPanel repeatedGroupAPanel = (AbstractPanel) panels.get(1);
118
			//panelGroup.removePanel(panels.get(0));
119
			// End: Tests adding and removing a panel
120
			
121
			// Begin: Tests adding and removing a panel without "labelGroup"
122
			((AbstractPanel)panels.get(2)).setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT));
123
			panels.get(2).setReference(Samples_Data.REFERENCE1);
124
			panelGroup.addPanel(panels.get(2));
125
			//panelGroup.removePanel(panels.get(1));
126
			// End: Tests adding and removing a panel without "labelGroup"
127
			
128
			// Begin: Test visibility			
129
			Object[] oPanels = panelGroup.values().toArray();			
130
			panelGroup.setPanelInGUI(repeatedGroupAPanel, false);// test set false a panel with a repeated group
131
			panelGroup.setPanelInGUI((IPanel)oPanels[1], false); // intermediate element
132
			 ((AbstractPanel)oPanels[1]).setInGroupGUI(true);    // test change the visibility from a panel child
133
			 ((AbstractPanel)oPanels[1]).setInGroupGUI(false);    // test change the visibility from a panel child
134
			 ((AbstractPanel)oPanels[1]).setInGroupGUI(true);    // test change the visibility from a panel child
135
			panelGroup.setPanelInGUI((IPanel)oPanels[0], false); // first element
136
			panelGroup.setPanelInGUI(incorrectAPanel, false);	 // incorrect element
137
			panelGroup.setPanelInGUI(panels.get(2), false);			 // last element (and labelGroup = null)
138
			panelGroup.setPanelInGUI((IPanel)oPanels[2], false); // intermediate element
139
			panelGroup.setPanelInGUI((IPanel)oPanels[2], false); // test set false two times the same node
140
			panelGroup.setPanelInGUI((IPanel)oPanels[0], true);  // first element
141
			panelGroup.setPanelInGUI(incorrectAPanel, true);	 // incorrect element
142
			panelGroup.setPanelInGUI((IPanel)oPanels[1], true);  // intermediate element
143
			panelGroup.setPanelInGUI((IPanel)oPanels[1], true);  // test set true two times the same node
144
			panelGroup.setPanelInGUI((IPanel)oPanels[2], true);  // intermediate element
145
			panelGroup.setPanelInGUI(panels.get(2), true); 			 // last element (and labelGroup = null)
146
			panelGroup.setPanelInGUI(repeatedGroupAPanel, true); // test set false a panel with a repeated group
147
			
148
			panels.get(1).setInGroupGUI(false);    // test change the visibility from a panel child
149
			if (!panels.get(1).isInGroupGUI()) {
150
				System.out.println("Test OK: the panel isn't in the GUI");
151
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
152
			}
153
			else {
154
				System.out.println("Test FAILED: the panel is in the GUI");
155
			}
156
			
157
			panels.get(1).setInGroupGUI(true);     // test change the visibility from a panel child
158
			if (panels.get(1).isInGroupGUI()) {
159
				System.out.println("Test OK: the panel is in the GUI");
160
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
161
			}
162
			else {
163
				System.out.println("Test FAILED: the panel isn't in the GUI");
164
			}
165
			
166
			panelGroup.setPanelInGUI(panels.get(1), false);
167
			if (!panelGroup.isPanelInGUI(panels.get(1))) {
168
				System.out.println("Test OK: the panel isn't in the GUI");
169
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
170
			}
171
			else {
172
				System.out.println("Test FAILED: the panel is in the GUI");
173
			}
174
			
175
			panelGroup.setPanelInGUI(panels.get(1), true);
176
			if (panelGroup.isPanelInGUI(panels.get(1))) {
177
				System.out.println("Test OK: the panel is in the GUI");
178
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
179
			}
180
			else {
181
				System.out.println("Test FAILED: the panel isn't in the GUI");
182
			}
183
			// End: Test visibility -> True or False
184
			
185
			jFrame = new JFrame();
186
			jFrame.setTitle("Test TreePanel using PanelGroupLoaderFromList");
187
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
188
		    jFrame.setSize(panelGroup.getPreferredSize());
189
		    jFrame.getContentPane().setLayout(new BorderLayout());
190
		    jFrame.getContentPane().add(panelGroup, BorderLayout.CENTER);
191
		    
192
			jFrame.setVisible(true);
193
			
194
			// Begin: Test the method 'getSelectedIndex()':
195
			panelGroup.addTreeSelectionListener(new TreeSelectionListener() {
196
				/*
197
				 * (non-Javadoc)
198
				 * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
199
				 */
200
				public void valueChanged(TreeSelectionEvent e) {
201
		        	JTree jTree = (JTree) e.getSource();
202
		        	
203
		        	System.out.println("Selection changed. New selection path: " + jTree.getSelectionPath());
204

  
205
		        	showActivePanelInformation();
206
				}
207
			});
208
			// End: Test the method 'getSelectedIndex()':
209
				
210
			// Begin: Test the methods: 'getDividerLocation()' and 'setDividerLocation(int)'
211
			System.out.println("Divider location before setting it to the position 250 : " + panelGroup.getDividerLocation());
212
			panelGroup.setDividerLocation(250);
213
			System.out.println("Divider location after setting it to the position 250 : " + panelGroup.getDividerLocation());
214
			// End: Test the methods: 'getDividerLocation()' and 'setDividerLocation(int)'
215

  
216
			// Begin: Test the methods: 'getDividerSize()' and 'setDividerSize(int)'
217
			System.out.println("Divider size before setting it to the position 10 : " + panelGroup.getDividerSize());
218
			panelGroup.setDividerSize(10);
219
			System.out.println("Divider size after setting it to the position 10 : " + panelGroup.getDividerSize());
220
			// End: Test the methods: 'getDividerSize()' and 'setDividerSize(int)'
221
			
222
			// End: Other tests
223
		} catch (BaseException e) {
224
			System.out.println(e.getLocalizedMessageStack());
225
		} catch (Exception e) {
226
			e.printStackTrace();
227
		}
228
	}
229
	
230
	/**
231
	 * <p>Shows information about the current active panel using the standard output.</p>
232
	 */
233
	private static void showActivePanelInformation() {
234
		// Test the method 'getActivePanel()'
235
		IPanel panel = panelGroup.getActivePanel();
236

  
237
		if (panel == null) {
238
			System.out.println("The node selected of the JTree in the TreePanel object isn't a IPanel .");
239
		}
240
		else {
241
			System.out.println("New active panel:\n\tID: " + panel.getID() + "\n\tLABEL_GROUP: " + panel.getLabelGroup() + "\n\tLABEL: " + panel.getLabel() + "\n\tCLASS: " + panel.getClass());
242
		}
243
	}
244
}
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/Test1TabbedPanel.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.gui.beans.panelGroup;
21

  
22
import java.awt.Dimension;
23
import java.util.ArrayList;
24

  
25
import javax.swing.JFrame;
26
import javax.swing.JTabbedPane;
27
import javax.swing.event.ChangeEvent;
28
import javax.swing.event.ChangeListener;
29

  
30
import org.gvsig.tools.exception.BaseException;
31
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
32
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
33
import org.gvsig.gui.beans.panelGroup.panels.IPanel;
34
import org.gvsig.gui.beans.panelGroup.samples.SampleInfoPanel;
35
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data;
36
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
37

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

  
58
			panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_Data.REFERENCE1);
59
			PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_Data.TEST1_CLASSES);
60

  
61
			// Begin: Test the normal load
62
			System.out.println("----------> Begin: Test the normal load");
63

  
64
			panelGroup.loadPanels(loader);
65

  
66
			System.out.println("End: Test the normal load <----------");
67
			// End: Test the normal load
68
			
69
			// Begin: Other tests
70
			ArrayList<IPanel> panels = new ArrayList<IPanel>();
71

  
72
			// Begin: Initialize sample classes
73
//			int i = 0;
74
//
75
//			for (AbstractPanel panel: panels) {
76
//				panel.setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT));
77
//				panel.setReference(Samples_Data.REFERENCE1);
78
//				
79
//				panel.setID(Samples_Data.PANELS1_IDS[i]);
80
//				panel.setLabel(Samples_Data.PANELS1_LABELS[i]);
81
//				panel.setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[i++]);
82
//				
83
//				panelGroup.addPanel(panel);
84
//			}
85
			// End: Initialize sample classes
86

  
87
			// Begin: Tests adding and removing a panel without "label" -> this shoudn't add that panel
88
			System.out.println("----------> Begin: Tests adding and removing a panel without \"label\" -> this shoudn't add that panel");
89
			loader = new PanelGroupLoaderFromList(new Class[]{SampleInfoPanel.class});
90
			loader.loadPanels(panels);
91

  
92
			panels.get(0).setReference(Samples_Data.REFERENCE1);
93
			panels.get(0).setID("ID");
94
			panels.get(0).setLabel(null);
95
			panels.get(0).setLabelGroup("LABEL_GROUP");
96
			panelGroup.addPanel(panels.get(0));
97
			panelGroup.removePanel(panels.get(0));
98
			System.out.println("End: Tests adding and removing a panel without \"label\" -> this shoudn't add that panel <----------");
99
			// End: Tests adding and removing a panel without "label" -> this shoudn't add that panel
100

  
101
			// Begin: Tests: has changed?
102
			System.out.println("----------> Begin: Tests: has changed?");
103
			Object[] oPanels = panelGroup.values().toArray();
104

  
105
			((AbstractPanel)oPanels[0]).setPreferredSize(new Dimension(700, 600));
106
			System.out.println("Has the new panel '" + ((AbstractPanel)oPanels[0]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[0]).hasChanged());
107

  
108
			String old_Label = ((AbstractPanel)oPanels[0]).getLabel();
109
			((AbstractPanel)oPanels[0]).setLabel(((AbstractPanel)oPanels[0]).getLabel() + " modified");
110
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[0]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[0]).hasChanged());
111

  
112
			((AbstractPanel)oPanels[0]).setLabel(old_Label);
113
			((AbstractPanel)oPanels[0]).resetChangedStatus();
114
			((AbstractPanel)oPanels[0]).setID(((AbstractPanel)oPanels[0]).getID() + " modified");
115
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[0]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[0]).hasChanged());
116

  
117
			((AbstractPanel)oPanels[0]).resetChangedStatus();
118
			((AbstractPanel)oPanels[0]).setLabelGroup(((AbstractPanel)oPanels[0]).getLabelGroup() + " modified");
119
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[0]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[0]).hasChanged());
120

  
121
			((AbstractPanel)oPanels[0]).resetChangedStatus();
122
			System.out.println("Has the panel reseted '" + ((AbstractPanel)oPanels[0]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[0]).hasChanged());
123
			System.out.println("End: Tests: has changed? <----------");
124
			// End: Tests: has changed?
125

  
126
			// Begin: Test visibility
127
			System.out.println("----------> Begin: Test visibility");
128
			((AbstractPanel)oPanels[0]).setID("ID");
129
			((AbstractPanel)oPanels[0]).setLabel("LABEL_TEST_VISIBILITY");
130
			((AbstractPanel)oPanels[0]).setLabelGroup("LABEL_GROUP");
131

  
132
			panelGroup.addPanel(((AbstractPanel)oPanels[0]));
133
			
134
			((AbstractPanel)oPanels[0]).setInGroupGUI(false);    // test change the visibility from a panel child
135
			if (!((AbstractPanel)oPanels[0]).isInGroupGUI()) {
136
				System.out.println("Test OK: the panel isn't in the GUI");
137
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
138
			}
139
			else {
140
				System.out.println("Test FAILED: the panel is in the GUI");
141
			}
142
			
143
			((AbstractPanel)oPanels[0]).setInGroupGUI(true);     // test change the visibility from a panel child
144
			if (((AbstractPanel)oPanels[0]).isInGroupGUI()) {
145
				System.out.println("Test OK: the panel is in the GUI");
146
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
147
			}
148
			else {
149
				System.out.println("Test FAILED: the panel isn't in the GUI");
150
			}
151
			
152
			panelGroup.setPanelInGUI(((AbstractPanel)oPanels[0]), false);
153
			if (!panelGroup.isPanelInGUI(((AbstractPanel)oPanels[0]))) {
154
				System.out.println("Test OK: the panel isn't in the GUI");
155
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
156
			}
157
			else {
158
				System.out.println("Test FAILED: the panel is in the GUI");
159
			}
160
			
161
			panelGroup.setPanelInGUI(((AbstractPanel)oPanels[0]), true);
162
			if (panelGroup.isPanelInGUI(((AbstractPanel)oPanels[0]))) {
163
				System.out.println("Test OK: the panel is in the GUI");
164
				System.out.println("Hay " + panelGroup.getPanelInGUICount() + " paneles en GUI, de los " + panelGroup.getPanelCount() + " registrados.");
165
			}
166
			else {
167
				System.out.println("Test FAILED: the panel isn't in the GUI");
168
			}
169
			System.out.println("End: Test visibility <----------");
170
			// End: Test visibility
171

  
172
			// Begin: Tests: Is a panel enabled?
173
			System.out.println("----------> Begin: Tests: Is a panel enabled?");
174
			panelGroup.setEnabledAt(0, false); // test change the enable status to a panel
175
			if (!panelGroup.isEnabledAt(0)) {
176
				System.out.println("Test OK: the panel isn't enabled.");
177
			}
178
			else {
179
				System.out.println("Test FAILED: the panel is enabled.");
180
			}
181
			
182
			panelGroup.setEnabledAt(0, true); // test change the enable status to a panel
183
			if (panelGroup.isEnabledAt(0)) {
184
				System.out.println("Test OK: the panel is enabled.");
185
			}
186
			else {
187
				System.out.println("Test FAILED: the panel isn't enabled.");
188
			}
189
			
190
			panelGroup.setEnabledAt(3, false); // test change the enable status to a panel
191
			if (!panelGroup.isEnabledAt(3)) {
192
				System.out.println("Test OK: the panel isn't enabled.");
193
			}
194
			else {
195
				System.out.println("Test FAILED: the panel is enabled.");
196
			}
197
			
198
			panelGroup.setEnabledAt(3, true); // test change the enable status to a panel
199
			if (panelGroup.isEnabledAt(3)) {
200
				System.out.println("Test OK: the panel is enabled.");
201
			}
202
			else {
203
				System.out.println("Test FAILED: the panel isn't enabled.");
204
			}
205
			System.out.println("End: Tests: Is a panel enabled? <----------");
206
			// End: Tests: Is a panel enabled?
207
			
208
			// Begin: Test: accept, apply or cancel, after request if has changed?
209
			System.out.println("----------> Begin: Test: accept, apply or cancel, after request if has changed?");
210
//			Object[] obj_panels = (((Collection<IPanel>) panelGroup.values()).toArray());
211
			
212
			// First part:
213
			System.out.println("First part:");
214
			System.out.println("Is the new panel '" + ((AbstractPanel)oPanels[1]).getLabel() + "' always applicable?: " + ((AbstractPanel)oPanels[1]).isAlwaysApplicable());
215
			System.out.println("Has the new panel '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
216

  
217
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
218
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
219
			panelGroup.accept();
220
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after accept?: " + ((AbstractPanel)oPanels[1]).hasChanged());
221

  
222
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
223
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
224
			panelGroup.apply();
225
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after apply?: " + ((AbstractPanel)oPanels[1]).hasChanged());
226

  
227
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
228
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
229
			panelGroup.cancel();
230
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after cancel?: " + ((AbstractPanel)oPanels[1]).hasChanged());
231

  
232
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
233
			panelGroup.accept();
234
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after accept?: " + ((AbstractPanel)oPanels[1]).hasChanged());
235

  
236
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
237
			panelGroup.apply();
238
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after apply?: " + ((AbstractPanel)oPanels[1]).hasChanged());
239

  
240
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
241
			panelGroup.cancel();
242
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after cancel?: " + ((AbstractPanel)oPanels[1]).hasChanged());
243

  
244
			// Second part:
245
			System.out.println("Second part:");
246
			((AbstractPanel)oPanels[1]).setAlwaysApplicable(false);
247
			System.out.println("Is the new panel '" + ((AbstractPanel)oPanels[1]).getLabel() + "' always applicable?: " + ((AbstractPanel)oPanels[1]).isAlwaysApplicable());
248
			System.out.println("Has the new panel '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
249

  
250
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
251
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
252
			panelGroup.accept();
253
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after accept?: " + ((AbstractPanel)oPanels[1]).hasChanged());
254

  
255
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
256
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
257
			panelGroup.apply();
258
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after apply?: " + ((AbstractPanel)oPanels[1]).hasChanged());
259

  
260
			((AbstractPanel)oPanels[1]).setLabel(((AbstractPanel)oPanels[1]).getLabel() + " modified");
261
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
262
			panelGroup.cancel();
263
			System.out.println("Has the panel modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after cancel?: " + ((AbstractPanel)oPanels[1]).hasChanged());
264

  
265
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
266
			panelGroup.accept();
267
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after accept?: " + ((AbstractPanel)oPanels[1]).hasChanged());
268

  
269
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
270
			panelGroup.apply();
271
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after apply?: " + ((AbstractPanel)oPanels[1]).hasChanged());
272

  
273
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed?: " + ((AbstractPanel)oPanels[1]).hasChanged());
274
			panelGroup.cancel();
275
			System.out.println("Has the panel not modified '" + ((AbstractPanel)oPanels[1]).getLabel() + "' changed after cancel?: " + ((AbstractPanel)oPanels[1]).hasChanged());
276
			System.out.println("End: Test: accept, apply or cancel, after request if has changed? <----------");
277
			// End: Test: accept, apply or cancel, after request if has changed?
278
			
279
			JFrame jFrame = new JFrame();
280
			jFrame.setTitle("Test TabbedPanel using PanelGroupLoaderFromList");
281
		    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
282
		    jFrame.setSize(panelGroup.getPreferredSize());
283
		    jFrame.getContentPane().add(panelGroup);
284
			jFrame.setVisible(true);
285
			
286
			// Test the methods 'getSelectedIndex()' and 'getActivePanel()'
287
			// Register a change listener
288
			panelGroup.addChangeListener(new ChangeListener() {
289
		        // This method is called whenever the selected tab changes
290
		        public void stateChanged(ChangeEvent evt) {
291
		        	JTabbedPane jTabbedPanel = (JTabbedPane) evt.getSource();
292
		        	
293
		        	System.out.println("Selection changed. New selection index: " + jTabbedPanel.getSelectedIndex());
294

  
295
		        	showActivePanelInformation();
296
		        }
297
		    });
298
			
299
			// Test the method 'getSelectedIndex()':
300
			panelGroup.setSelectedIndex(2);
301
			
302
			// Test the change of the reference of the group
303
			panelGroup.updateReference("NEW REFERENCE");
304

  
305
		// End: Other tests
306
		} catch (BaseException e) {
307
			System.out.println(e.getLocalizedMessageStack());
308
		} catch (Exception e) {
309
			e.printStackTrace();
310
		}
311
	}
312
	
313
	/**
314
	 * <p>Shows information about the current active panel using the standard output.</p>
315
	 */
316
	private static void showActivePanelInformation() {
317
		// Test the method 'getActivePanel()'
318
		IPanel panel = panelGroup.getActivePanel();
319
		
320
    	System.out.println("New active panel:\n\tID: " + panel.getID() + "\n\tLABEL_GROUP: " + panel.getLabelGroup() + "\n\tLABEL: " + panel.getLabel() + "\n\tCLASS: " + panel.getClass());
321
	}
322
}
tags/v2_0_0_Build_2058/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/TestPanelGroupLoaderFromList.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.gui.beans.panelGroup;
21

  
22
import java.util.ArrayList;
23

  
24
import junit.framework.TestCase;
25

  
26
import org.gvsig.tools.exception.BaseException;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff