Revision 38348
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/controls/dnd/JDnDTableTest.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.2 2007-08-21 09:58:04 bsanchez |
|
47 |
* - Quitados imports innecesarios |
|
48 |
* - Quitado codigo no usado |
|
49 |
* - Cambio de deprecated show por setVisible(true) |
|
50 |
* |
|
51 |
* Revision 1.1 2007/08/20 08:34:46 evercher |
|
52 |
* He fusionado LibUI con LibUIComponents |
|
53 |
* |
|
54 |
* Revision 1.1 2006/09/27 13:34:57 jaume |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
package controls.dnd; |
|
60 |
|
|
61 |
import java.awt.Dimension; |
|
62 |
|
|
63 |
import javax.swing.JFrame; |
|
64 |
import javax.swing.JPanel; |
|
65 |
|
|
66 |
import org.gvsig.gui.beans.TestUI; |
|
67 |
import org.gvsig.gui.beans.controls.dnd.JDnDList; |
|
68 |
import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
|
69 |
import org.gvsig.gui.beans.controls.dnd.JDnDTable; |
|
70 |
import org.gvsig.gui.beans.controls.dnd.JDnDTableModel; |
|
71 |
/** |
|
72 |
* El model que ha de suportar les funcions d'una JDnDTable. Encara est? en |
|
73 |
* proves. |
|
74 |
* |
|
75 |
* @author jaume |
|
76 |
*/ |
|
77 |
public class JDnDTableTest { |
|
78 |
static String[] colNames = new String[] {"1234", "abcd", "qwerty"}; |
|
79 |
static String[][] values = new String[][] {new String[] {"a1", "a2", "a3"}, |
|
80 |
new String[] {"b1", "b2", "b3"}, |
|
81 |
new String[] {"c1", "c2", "c3"}}; |
|
82 |
|
|
83 |
public static void main(String args[]) { |
|
84 |
JFrame f = new TestUI("JDnDTableTest"); |
|
85 |
JPanel content = new JPanel(); |
|
86 |
content.setPreferredSize(new Dimension(500,400)); |
|
87 |
|
|
88 |
JDnDTableModel model = new JDnDTableModel(values, colNames); |
|
89 |
JDnDListModel listModel = new JDnDListModel(); |
|
90 |
listModel.addElement("a"); |
|
91 |
listModel.addElement("b"); |
|
92 |
listModel.addElement("c"); |
|
93 |
|
|
94 |
JDnDTable tbl = new JDnDTable(); |
|
95 |
|
|
96 |
tbl.setModel(model); |
|
97 |
tbl.setSize(new Dimension(450, 350)); |
|
98 |
JDnDList list = new JDnDList(); |
|
99 |
list.setModel(listModel); |
|
100 |
content.add(tbl); |
|
101 |
content.add(list); |
|
102 |
f.setContentPane(content); |
|
103 |
f.pack(); |
|
104 |
f.setVisible(true); |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/AllTests.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestSuite; |
|
5 |
|
|
6 |
import org.gvsig.gui.beans.panelGroup.Test1ExceptionsUsingTabbedPanel; |
|
7 |
import org.gvsig.gui.beans.panelGroup.Test1ExceptionsUsingTreePanel; |
|
8 |
import org.gvsig.gui.beans.panelGroup.TestPanelGroupLoaderFromList; |
|
9 |
import org.gvsig.gui.beans.panelGroup.TestPanelGroupManager; |
|
10 |
|
|
11 |
public class AllTests { |
|
12 |
|
|
13 |
public static Test suite() { |
|
14 |
TestSuite suite = new TestSuite("Test for org.gvsig.gui.beans"); |
|
15 |
//$JUnit-BEGIN$ |
|
16 |
suite.addTestSuite(TestPanelGroupLoaderFromList.class); |
|
17 |
suite.addTestSuite(TestPanelGroupManager.class); |
|
18 |
suite.addTestSuite(Test1ExceptionsUsingTabbedPanel.class); |
|
19 |
suite.addTestSuite(Test1ExceptionsUsingTreePanel.class); |
|
20 |
//$JUnit-END$ |
|
21 |
return suite; |
|
22 |
} |
|
23 |
|
|
24 |
} |
|
0 | 25 |
tags/v2_0_0_Build_2047/libraries/libUIComponent/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_2047/libraries/libUIComponent/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_2047/libraries/libUIComponent/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; |
|
27 |
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList; |
|
28 |
import org.gvsig.gui.beans.panelGroup.panels.IPanel; |
|
29 |
import org.gvsig.gui.beans.panelGroup.samples.Samples_Data; |
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Tests {@link PanelGroupLoaderUtilities PanelGroupLoaderUtilities} and {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}.</p> |
|
33 |
* |
|
34 |
* @version 16/10/2007 |
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
36 |
*/ |
|
37 |
public class TestPanelGroupLoaderFromList extends TestCase { |
|
38 |
|
|
39 |
/* |
|
40 |
* (non-Javadoc) |
|
41 |
* @see junit.framework.TestCase#setUp() |
|
42 |
*/ |
|
43 |
protected void setUp() throws Exception { |
|
44 |
super.setUp(); |
|
45 |
} |
|
46 |
|
|
47 |
/* |
|
48 |
* (non-Javadoc) |
|
49 |
* @see junit.framework.TestCase#tearDown() |
|
50 |
*/ |
|
51 |
protected void tearDown() throws Exception { |
|
52 |
super.tearDown(); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* <p>Test, results must be valid.</p> |
|
57 |
*/ |
|
58 |
public void test() { |
|
59 |
try { |
|
60 |
PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_Data.TEST2_CLASSES); |
|
61 |
ArrayList<IPanel> panels = new ArrayList<IPanel>(); |
|
62 |
|
|
63 |
loader.loadPanels(panels); |
|
64 |
|
|
65 |
// Check that has loaded all panels |
|
66 |
assertEquals(Samples_Data.TEST2_CLASSES.length, panels.size()); |
|
67 |
|
|
68 |
int i = 0; |
|
69 |
|
|
70 |
while (i < Samples_Data.TEST2_CLASSES.length) { |
|
71 |
// Check order and class types |
|
72 |
assertTrue(panels.get(i).getClass() == (Samples_Data.TEST2_CLASSES[i++])); |
|
73 |
} |
|
74 |
} catch (BaseException e) { |
|
75 |
System.out.println(e.getLocalizedMessageStack()); |
|
76 |
fail(); |
|
77 |
} catch (Exception e) { |
|
78 |
e.printStackTrace(); |
|
79 |
fail(); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/samples/SampleInfoPanel.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.samples; |
|
21 |
|
|
22 |
import java.awt.Color; |
|
23 |
import java.awt.Dimension; |
|
24 |
import java.io.Serializable; |
|
25 |
|
|
26 |
import javax.swing.JScrollPane; |
|
27 |
import javax.swing.JTextArea; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Sample of {@link AbstractPanel AbstractPanel}.</p> |
|
33 |
* |
|
34 |
* @version 16/10/2007 |
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
36 |
*/ |
|
37 |
public class SampleInfoPanel extends AbstractPanel implements Serializable { |
|
38 |
private static final long serialVersionUID = -1629511810619122126L; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p>Element for the interface.</p> |
|
42 |
*/ |
|
43 |
private JTextArea jTextArea = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* @see AbstractPanel#AbstractPanel() |
|
47 |
*/ |
|
48 |
public SampleInfoPanel() { |
|
49 |
super(); |
|
50 |
initialize(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see AbstractPanel#AbstractPanel(String, String, String) |
|
55 |
*/ |
|
56 |
public SampleInfoPanel(String id, String label, String labelGroup) { |
|
57 |
super(id, label, labelGroup); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void initialize() { |
|
63 |
add(new JScrollPane(getJTextArea())); |
|
64 |
setToolTipText(getID()); |
|
65 |
|
|
66 |
setID(Samples_Data.PANELS1_IDS[0]); |
|
67 |
setLabel(Samples_Data.PANELS1_LABELS[0]); |
|
68 |
setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[0]); |
|
69 |
setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT)); |
|
70 |
resetChangedStatus(); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* This method initializes jTextArea |
|
75 |
* |
|
76 |
* @return JTextArea |
|
77 |
*/ |
|
78 |
private JTextArea getJTextArea() { |
|
79 |
if (jTextArea == null) { |
|
80 |
jTextArea = new JTextArea(5, 40); |
|
81 |
jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
82 |
jTextArea.setEditable(false); |
|
83 |
jTextArea.setBackground(Color.RED); |
|
84 |
} |
|
85 |
|
|
86 |
return jTextArea; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void setID(String id) { |
|
91 |
super.setID(id); |
|
92 |
|
|
93 |
setToolTipText(getID()); |
|
94 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
95 |
hasChanged = true; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public void setLabel(String label) { |
|
100 |
super.setLabel(label); |
|
101 |
|
|
102 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
103 |
hasChanged = true; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public void setLabelGroup(String labelGroup) { |
|
108 |
super.setLabelGroup(labelGroup); |
|
109 |
|
|
110 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
111 |
hasChanged = true; |
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept() |
|
117 |
*/ |
|
118 |
public void accept() { |
|
119 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method."); |
|
120 |
} |
|
121 |
|
|
122 |
/* |
|
123 |
* (non-Javadoc) |
|
124 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply() |
|
125 |
*/ |
|
126 |
public void apply() { |
|
127 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method."); |
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* (non-Javadoc) |
|
132 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel() |
|
133 |
*/ |
|
134 |
public void cancel() { |
|
135 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method."); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected() |
|
141 |
*/ |
|
142 |
public void selected() { |
|
143 |
System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " + |
|
144 |
"\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() + |
|
145 |
"\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize()); |
|
146 |
} |
|
147 |
} |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/samples/Samples_Data.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.samples; |
|
21 |
|
|
22 |
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList; |
|
23 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
24 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
|
25 |
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel; |
|
26 |
|
|
27 |
/** |
|
28 |
* <p>This class has information to create samples to test {@link PanelGroupManagerDePablo PanelGroupManagerDePablo}, |
|
29 |
* {@link TabbedPanel TabbedPanel}, {@link TreePanel TreePanel}, |
|
30 |
* {@link AbstractPanel AbstractPanel}, {@link PanelGroupLoaderUtilities PanelGroupLoaderUtilities}, |
|
31 |
* {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}, {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}.</p> |
|
32 |
* |
|
33 |
* @version 16/10/2007 |
|
34 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
35 |
*/ |
|
36 |
public class Samples_Data { |
|
37 |
public final static short PANELS_DEFAULT_WIDTH = 500; |
|
38 |
public final static short PANELS_DEFAULT_HEIGHT = 400; |
|
39 |
|
|
40 |
public final static Class[] TEST1_CLASSES = {SampleInfoPanel.class, SampleBandSetupPanel.class, SampleTransparencyPanel.class, SampleEnhancedPanel.class, SamplePanSharpeningPanel.class, SampleScalePanel.class}; |
|
41 |
public final static Class[] TEST2_CLASSES = {SampleInfoPanel.class, SampleTransparencyPanel.class, SampleScalePanel.class}; |
|
42 |
public final static Class[] TEST3_CLASSES = {SamplePanelWithoutGroupLabel.class, SamplePanelGroupLabelRepeated.class}; |
|
43 |
public final static Class[] TEST4_CLASSES = {SampleInitializingExcetionPanel.class, SampleInfoPanel.class}; // Test 'ListCouldntLoadPanelFromListException' with any 'Exception' |
|
44 |
public final static Class[] TEST5_CLASSES = {SampleInfoPanel.class, SampleUndefinedPreferredSizeExceptionPanel.class}; // Test 'ListCouldntAddPanelException' with a 'PanelWithNoPreferredSizeDefinedException' |
|
45 |
public final static Class[] TEST6_CLASSES = {}; // Test 'ListCouldntAddPanelException' with a 'EmptyPanelGroupException' |
|
46 |
public final static Class[] TEST7_CLASSES = {SampleInvisiblePanel.class}; // Test 'ListCouldntAddPanelException' with a 'EmptyPanelGroupGUIException' |
|
47 |
public final static Class[] TEST8_CLASSES = {SampleInitializingExcetionPanel.class, SampleUndefinedPreferredSizeExceptionPanel.class}; // Test 'ListCouldntAddPanelException' with a 'PanelWithNoPreferredSizeDefinedException', a 'EmptyPanelGroupException' and a 'ListCouldntLoadPanelFromListException' with any 'Exception' |
|
48 |
public final static Class[] TEST9_CLASSES = {SampleInvisiblePanel.class, SampleInitializingExcetionPanel.class, SampleUndefinedPreferredSizeExceptionPanel.class}; // Test 'ListCouldntAddPanelException' with a 'PanelWithNoPreferredSizeDefinedException', a 'EmptyPanelGroupGUIException' and a 'ListCouldntLoadPanelFromListException' with any 'Exception' |
|
49 |
public final static Class[] TEST10_CLASSES = {SampleBandSetupPanel.class, SampleInvisiblePanel.class, SampleInitializingExcetionPanel.class, SampleUndefinedPreferredSizeExceptionPanel.class}; // Test 'ListCouldntAddPanelException' with a 'PanelWithNoPreferredSizeDefinedException', a EmptyPanelGroupGUIException and a 'ListCouldntLoadPanelFromListException' with any 'Exception' |
|
50 |
public final static Object REFERENCE1 = new String("Raster Layer"); |
|
51 |
public final static Object REFERENCE2 = new String("Imaginary Layer"); |
|
52 |
public final static Object REFERENCE3 = new String("Other tests"); |
|
53 |
public final static String REFERENCE1_NAME = "Raster Layer reference"; |
|
54 |
public final static String REFERENCE2_NAME = "Imaginary Layer reference"; |
|
55 |
public final static String REFERENCE3_NAME = "Other tests reference"; |
|
56 |
public final static String PANELGROUP1_ID = "RPG1_ID"; |
|
57 |
public final static String PANELGROUP2_ID = "RPG2_ID"; |
|
58 |
public final static String PANELGROUP3_ID = "RPG3_ID"; |
|
59 |
public final static String[] PANELS1_IDS = {"Information_ID", "Bands_ID", "Transparency_ID", "Enhanced_ID", "PanSharpening_ID", "Scale_ID"}; |
|
60 |
public final static String[] PANELS2_IDS = {"Information_ID", "Transparency_ID", "Scale_ID"}; |
|
61 |
public final static String[] PANELS3_IDS = {"WithoutGroup_ID", "GroupLabelRepeated_ID"}; |
|
62 |
public final static String[] PANELS1_LABELS = {"Information_LABEL", "Bands_LABEL", "Transparency_LABEL", "Enhanced_LABEL", "PanSharpening_LABEL", "Scale_LABEL"}; |
|
63 |
public final static String[] PANELS2_LABELS = {"Information_LABEL", "Transparency_LABEL", "Scale_LABEL"}; |
|
64 |
public final static String[] PANELS3_LABELS = {"WithoutGroup_LABEL", "GroupLabelRepeated_LABEL"}; |
|
65 |
public final static String[] PANELS1_LABELGROUPS = {"Information_LABELGROUP", "Bands_LABELGROUP", "Transparency_LABELGROUP", "Enhanced_LABELGROUP", "PanSharpening_LABELGROUP", "Scale_LABELGROUP"}; |
|
66 |
public final static String[] PANELS2_LABELGROUPS = {"Information_LABELGROUP", "Transparency_LABELGROUP", "Scale_LABELGROUP"}; |
|
67 |
public final static String[] PANELS3_LABELGROUPS = {"WithoutGroup_LABELGROUP", "GroupLabelRepeated_LABELGROUP"}; |
|
68 |
} |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/samples/SamplePanSharpeningPanel.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.samples; |
|
21 |
|
|
22 |
import java.awt.Color; |
|
23 |
import java.awt.Dimension; |
|
24 |
import java.io.Serializable; |
|
25 |
|
|
26 |
import javax.swing.JScrollPane; |
|
27 |
import javax.swing.JTextArea; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Sample of {@link AbstractPanel AbstractPanel}.</p> |
|
33 |
* |
|
34 |
* @version 16/10/2007 |
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
36 |
*/ |
|
37 |
public class SamplePanSharpeningPanel extends AbstractPanel implements Serializable { |
|
38 |
private static final long serialVersionUID = 648806623810248226L; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p>Element for the interface.</p> |
|
42 |
*/ |
|
43 |
private JTextArea jTextArea = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* @see AbstractPanel#AbstractPanel() |
|
47 |
*/ |
|
48 |
public SamplePanSharpeningPanel() { |
|
49 |
super(); |
|
50 |
initialize(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see AbstractPanel#AbstractPanel(String, String, String) |
|
55 |
*/ |
|
56 |
public SamplePanSharpeningPanel(String id, String label, String labelGroup) { |
|
57 |
super(id, label, labelGroup); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void initialize() { |
|
63 |
add(new JScrollPane(getJTextArea())); |
|
64 |
setToolTipText(getID()); |
|
65 |
|
|
66 |
setID(Samples_Data.PANELS1_IDS[4]); |
|
67 |
setLabel(Samples_Data.PANELS1_LABELS[4]); |
|
68 |
setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[4]); |
|
69 |
setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT)); |
|
70 |
resetChangedStatus(); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* This method initializes jTextArea |
|
75 |
* |
|
76 |
* @return JTextArea |
|
77 |
*/ |
|
78 |
private JTextArea getJTextArea() { |
|
79 |
if (jTextArea == null) { |
|
80 |
jTextArea = new JTextArea(5, 40); |
|
81 |
jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
82 |
jTextArea.setEditable(false); |
|
83 |
jTextArea.setBackground(Color.MAGENTA); |
|
84 |
} |
|
85 |
|
|
86 |
return jTextArea; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void setID(String id) { |
|
91 |
super.setID(id); |
|
92 |
|
|
93 |
setToolTipText(getID()); |
|
94 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
95 |
hasChanged = true; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public void setLabel(String label) { |
|
100 |
super.setLabel(label); |
|
101 |
|
|
102 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
103 |
hasChanged = true; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public void setLabelGroup(String labelGroup) { |
|
108 |
super.setLabelGroup(labelGroup); |
|
109 |
|
|
110 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
111 |
hasChanged = true; |
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept() |
|
117 |
*/ |
|
118 |
public void accept() { |
|
119 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method."); |
|
120 |
} |
|
121 |
|
|
122 |
/* |
|
123 |
* (non-Javadoc) |
|
124 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply() |
|
125 |
*/ |
|
126 |
public void apply() { |
|
127 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method."); |
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* (non-Javadoc) |
|
132 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel() |
|
133 |
*/ |
|
134 |
public void cancel() { |
|
135 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method."); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected() |
|
141 |
*/ |
|
142 |
public void selected() { |
|
143 |
System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " + |
|
144 |
"\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() + |
|
145 |
"\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize()); |
|
146 |
} |
|
147 |
} |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/samples/SamplePanelWithoutGroupLabel.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.samples; |
|
21 |
|
|
22 |
import java.awt.Color; |
|
23 |
import java.awt.Dimension; |
|
24 |
import java.io.Serializable; |
|
25 |
|
|
26 |
import javax.swing.JScrollPane; |
|
27 |
import javax.swing.JTextArea; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Sample of {@link AbstractPanel AbstractPanel}.</p> |
|
33 |
* |
|
34 |
* @version 23/10/2007 |
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
36 |
*/ |
|
37 |
public class SamplePanelWithoutGroupLabel extends AbstractPanel implements Serializable { |
|
38 |
private static final long serialVersionUID = -5449402170753829090L; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p>Element for the interface.</p> |
|
42 |
*/ |
|
43 |
private JTextArea jTextArea = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* @see AbstractPanel#AbstractPanel() |
|
47 |
*/ |
|
48 |
public SamplePanelWithoutGroupLabel() { |
|
49 |
super(); |
|
50 |
initialize(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see AbstractPanel#AbstractPanel(String, String, String) |
|
55 |
*/ |
|
56 |
public SamplePanelWithoutGroupLabel(String id, String label, String labelGroup) { |
|
57 |
super(id, label, labelGroup); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void initialize() { |
|
63 |
add(new JScrollPane(getJTextArea())); |
|
64 |
setToolTipText(getID()); |
|
65 |
|
|
66 |
setID(Samples_Data.PANELS3_IDS[0]); |
|
67 |
setLabel(Samples_Data.PANELS3_LABELS[0]); |
|
68 |
setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT)); |
|
69 |
resetChangedStatus(); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* This method initializes jTextArea |
|
74 |
* |
|
75 |
* @return JTextArea |
|
76 |
*/ |
|
77 |
private JTextArea getJTextArea() { |
|
78 |
if (jTextArea == null) { |
|
79 |
jTextArea = new JTextArea(5, 40); |
|
80 |
jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
81 |
jTextArea.setEditable(false); |
|
82 |
jTextArea.setBackground(Color.WHITE); |
|
83 |
} |
|
84 |
|
|
85 |
return jTextArea; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public void setID(String id) { |
|
90 |
super.setID(id); |
|
91 |
|
|
92 |
setToolTipText(getID()); |
|
93 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
94 |
hasChanged = true; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void setLabel(String label) { |
|
99 |
super.setLabel(label); |
|
100 |
|
|
101 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
102 |
hasChanged = true; |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public void setLabelGroup(String labelGroup) { |
|
107 |
super.setLabelGroup(labelGroup); |
|
108 |
|
|
109 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
110 |
hasChanged = true; |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* (non-Javadoc) |
|
115 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept() |
|
116 |
*/ |
|
117 |
public void accept() { |
|
118 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method."); |
|
119 |
} |
|
120 |
|
|
121 |
/* |
|
122 |
* (non-Javadoc) |
|
123 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply() |
|
124 |
*/ |
|
125 |
public void apply() { |
|
126 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method."); |
|
127 |
} |
|
128 |
|
|
129 |
/* |
|
130 |
* (non-Javadoc) |
|
131 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel() |
|
132 |
*/ |
|
133 |
public void cancel() { |
|
134 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method."); |
|
135 |
} |
|
136 |
|
|
137 |
/* |
|
138 |
* (non-Javadoc) |
|
139 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected() |
|
140 |
*/ |
|
141 |
public void selected() { |
|
142 |
System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " + |
|
143 |
"\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() + |
|
144 |
"\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize()); |
|
145 |
} |
|
146 |
} |
tags/v2_0_0_Build_2047/libraries/libUIComponent/libUIComponent/src-test-ui/org/gvsig/gui/beans/panelGroup/samples/SampleInvisiblePanel.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.samples; |
|
21 |
|
|
22 |
import java.awt.Color; |
|
23 |
import java.awt.Dimension; |
|
24 |
import java.io.Serializable; |
|
25 |
|
|
26 |
import javax.swing.JScrollPane; |
|
27 |
import javax.swing.JTextArea; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
30 |
|
|
31 |
/** |
|
32 |
* <p>Sample of {@link AbstractPanel AbstractPanel}.</p> |
|
33 |
* |
|
34 |
* @version 10/12/2007 |
|
35 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
36 |
*/ |
|
37 |
public class SampleInvisiblePanel extends AbstractPanel implements Serializable { |
|
38 |
private static final long serialVersionUID = -1629511810619122126L; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p>Element for the interface.</p> |
|
42 |
*/ |
|
43 |
private JTextArea jTextArea = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* @see AbstractPanel#AbstractPanel() |
|
47 |
*/ |
|
48 |
public SampleInvisiblePanel() { |
|
49 |
super(); |
|
50 |
initialize(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see AbstractPanel#AbstractPanel(String, String, String) |
|
55 |
*/ |
|
56 |
public SampleInvisiblePanel(String id, String label, String labelGroup) { |
|
57 |
super(id, label, labelGroup); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void initialize() { |
|
63 |
add(new JScrollPane(getJTextArea())); |
|
64 |
setToolTipText(getID()); |
|
65 |
|
|
66 |
setID(Samples_Data.PANELS1_IDS[0]); |
|
67 |
setLabel(Samples_Data.PANELS1_LABELS[0]); |
|
68 |
setLabelGroup(Samples_Data.PANELS1_LABELGROUPS[0]); |
|
69 |
setPreferredSize(new Dimension(Samples_Data.PANELS_DEFAULT_WIDTH, Samples_Data.PANELS_DEFAULT_HEIGHT)); |
|
70 |
resetChangedStatus(); |
|
71 |
setVisible(false); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* This method initializes jTextArea |
|
76 |
* |
|
77 |
* @return JTextArea |
|
78 |
*/ |
|
79 |
private JTextArea getJTextArea() { |
|
80 |
if (jTextArea == null) { |
|
81 |
jTextArea = new JTextArea(5, 40); |
|
82 |
jTextArea.setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
83 |
jTextArea.setEditable(false); |
|
84 |
jTextArea.setBackground(Color.RED); |
|
85 |
} |
|
86 |
|
|
87 |
return jTextArea; |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void setID(String id) { |
|
92 |
super.setID(id); |
|
93 |
|
|
94 |
setToolTipText(getID()); |
|
95 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
96 |
hasChanged = true; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void setLabel(String label) { |
|
101 |
super.setLabel(label); |
|
102 |
|
|
103 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
104 |
hasChanged = true; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public void setLabelGroup(String labelGroup) { |
|
109 |
super.setLabelGroup(labelGroup); |
|
110 |
|
|
111 |
getJTextArea().setText("I\'m a JTextArea object in the \"Panel\" with:\n\nID: " + getID() + "\nLabel: " + getLabel() + "\nLabelGroup: " + getLabelGroup()); |
|
112 |
hasChanged = true; |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept() |
|
118 |
*/ |
|
119 |
public void accept() { |
|
120 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'accept' method."); |
|
121 |
} |
|
122 |
|
|
123 |
/* |
|
124 |
* (non-Javadoc) |
|
125 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply() |
|
126 |
*/ |
|
127 |
public void apply() { |
|
128 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing an 'apply' method."); |
|
129 |
} |
|
130 |
|
|
131 |
/* |
|
132 |
* (non-Javadoc) |
|
133 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel() |
|
134 |
*/ |
|
135 |
public void cancel() { |
|
136 |
System.out.println("I'm the IPanel: " + toString() + "\n and I'm executing a 'cancel' method."); |
|
137 |
} |
|
138 |
|
|
139 |
/* |
|
140 |
* (non-Javadoc) |
|
141 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected() |
|
142 |
*/ |
|
143 |
public void selected() { |
|
144 |
System.out.println("I'm the IPanel: " + toString() + "\n and I've been selected. My information is: " + |
|
145 |
"\n\tID: " + getID() + "\n\tLABEL_GROUP: " + getLabelGroup() + "\n\tLABEL: " + getLabel() + "\n\tCLASS: " + getClass() + |
|
146 |
"\n\tMy Preferred Size: " + getPreferredSize() + "\n\tAnd My size: " + getSize()); |
Also available in: Unified diff