Revision 37740

View differences:

tags/v2_0_0_Build_2043/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

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

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

  
tags/v2_0_0_Build_2043/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_2043/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_2043/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_2043/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_2043/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_2043/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_2043/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_2043/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/Test1ExceptionsUsingTabbedPanel.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 junit.framework.TestCase;
23

  
24
import org.gvsig.tools.exception.BaseException;
25
import org.gvsig.gui.beans.Messages;
26
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
27
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data;
28
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
29

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

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

  
51
		manager = PanelGroupManager.getManager();
52
		manager.registerPanelGroup(TabbedPanel.class);
53
		manager.setDefaultType(TabbedPanel.class);
54
		panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_Data.REFERENCE3);
55
	}
56

  
57
	/*
58
	 * (non-Javadoc)
59
	 * @see junit.framework.TestCase#tearDown()
60
	 */
61
	protected void tearDown() throws Exception {
62
		super.tearDown();
63
		manager.deregisterPanelGroup(TabbedPanel.class);
64
	}
65
	
66
	/**
67
	 * <p>Test the 'PanelGroup' exceptions </p>
68
	 */
69
	public void test1() {
70
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_list_exception") + "\n  Error cargando un panel: / by zero.";
71
		
72
		try {
73
			System.out.println("----- Test 1 -----");
74
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST4_CLASSES);
75

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

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

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

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

  
132
		try {
133
			System.out.println("----- Test 3 -----");
134
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST6_CLASSES);
135

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

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

  
162
		try {
163
			System.out.println("----- Test 4 -----");
164
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST7_CLASSES);
165

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

  
182
		System.out.println("------------------");
183
		fail();
184
	}
185
	
186
	/**
187
	 * <p>Test the 'PanelGroup' exceptions </p>
188
	 */
189
	public void test5() {
190
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_list_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");
191

  
192
		try {
193
			System.out.println("----- Test 5 -----");
194
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST8_CLASSES);
195

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

  
212
		System.out.println("------------------");
213
		fail();
214
	}
215
	
216
	/**
217
	 * <p>Test the 'PanelGroup' exceptions </p>
218
	 */
219
	public void test6() {
220
		validationText = Messages.getText("couldnt_add_some_panel_exception") + "\n  " + Messages.getText("couldnt_load_panels_from_list_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");
221

  
222
		try {
223
			System.out.println("----- Test 6 -----");
224
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST9_CLASSES);
225

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

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

  
252
		try {
253
			System.out.println("----- Test 7 -----");
254
			loader = new PanelGroupLoaderFromList(Samples_Data.TEST10_CLASSES);
255

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

  
272
		System.out.println("------------------");
273
		fail();
274
	}
275
}
tags/v2_0_0_Build_2043/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_2043/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);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff