svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / test / java / org / gvsig / app / panelGroup / Test1ButtonsPanelWithExceptionsMessage.java @ 40558
History | View | Annotate | Download (4.39 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.panelGroup; |
25 |
|
26 |
import javax.swing.JFrame; |
27 |
|
28 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
29 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
30 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
31 |
import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
32 |
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList; |
33 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
34 |
import org.gvsig.tools.exception.BaseException; |
35 |
|
36 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
37 |
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels; |
38 |
|
39 |
/**
|
40 |
* <p>
|
41 |
* Test method for the Test1ButtonsPanelWithExceptionsMessage.
|
42 |
* </p>
|
43 |
* <p>
|
44 |
* Tests the message dialog caused by the exceptions produced during the loading
|
45 |
* of panels, using {@link PanelGroupManager PanelGroupManager},
|
46 |
* {@link PanelGroupLoaderFromList PanelGroupLoaderFromList},
|
47 |
* {@link TabbedPanel TabbedPanel}, and a resizable {@link PanelGroupDialog
|
48 |
* PanelGroupDialog}.
|
49 |
* </p>
|
50 |
*
|
51 |
* @version 17/12/2007
|
52 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
53 |
*/
|
54 |
public class Test1ButtonsPanelWithExceptionsMessage { |
55 |
/**
|
56 |
* <p>Element for the interface.</p>
|
57 |
*/
|
58 |
private static JFrame jFrame; |
59 |
|
60 |
/**
|
61 |
* <p>
|
62 |
* Test method for the Test1ButtonsPanelWithExceptionsMessage.
|
63 |
* </p>
|
64 |
*
|
65 |
* @param args
|
66 |
* optional arguments
|
67 |
*/
|
68 |
public static void main(String[] args) { |
69 |
try {
|
70 |
// Objects creation
|
71 |
jFrame = new JFrame(); |
72 |
|
73 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
74 |
manager.registerPanelGroup(TabbedPanel.class); |
75 |
manager.setDefaultType(TabbedPanel.class); |
76 |
|
77 |
TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3); |
78 |
|
79 |
PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS10_CLASSES);
|
80 |
|
81 |
// Creates the IWindow
|
82 |
PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panels with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup); |
83 |
|
84 |
// Begin: Test the normal load
|
85 |
panelGroupDialog.loadPanels(loader); |
86 |
// End: Test the normal load
|
87 |
|
88 |
panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
|
89 |
/*
|
90 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
91 |
*/
|
92 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
93 |
switch (e.getButton()) {
|
94 |
case ButtonsPanel.BUTTON_ACCEPT:
|
95 |
System.out.println("Accept Button pressed."); |
96 |
hideJFrame(); |
97 |
System.exit(0); |
98 |
break;
|
99 |
case ButtonsPanel.BUTTON_CANCEL:
|
100 |
System.out.println("Cancel Button pressed."); |
101 |
hideJFrame(); |
102 |
System.exit(0); |
103 |
break;
|
104 |
case ButtonsPanel.BUTTON_APPLY:
|
105 |
System.out.println("Apply Button pressed."); |
106 |
break;
|
107 |
} |
108 |
} |
109 |
}); |
110 |
|
111 |
jFrame.setTitle("Test resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromList");
|
112 |
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
113 |
jFrame.setSize(panelGroupDialog.getPreferredSize()); |
114 |
jFrame.getContentPane().add(panelGroupDialog); |
115 |
|
116 |
jFrame.setVisible(true);
|
117 |
|
118 |
} catch (BaseException bE) {
|
119 |
System.out.println(bE.getLocalizedMessageStack());
|
120 |
} catch (Exception e) { |
121 |
e.printStackTrace(); |
122 |
} |
123 |
} |
124 |
|
125 |
/**
|
126 |
* <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
|
127 |
*/
|
128 |
private static void hideJFrame() { |
129 |
jFrame.setVisible(false);
|
130 |
} |
131 |
} |