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 / Test4ButtonsPanelWithExceptionsMessage.java @ 40558
History | View | Annotate | Download (4.47 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.treePanel.TreePanel; |
33 |
import org.gvsig.tools.exception.BaseException; |
34 |
|
35 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
36 |
import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint; |
37 |
import org.gvsig.app.panelGroup.samples.Samples_ExtensionPointsOfIPanels; |
38 |
|
39 |
/**
|
40 |
* <p>Test method for the Test2ButtonsPanelWithExceptionsMessage.</p>
|
41 |
* <p>Tests the message dialog caused by the exceptions produced during the loading of panels, using {@link PanelGroupManager PanelGroupManager},
|
42 |
* {@link PanelGroupLoaderFromExtensionPoint PanelGroupLoaderFromExtensionPoint}, {@link TreePanel TreePanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
|
43 |
*
|
44 |
* @version 17/12/2007
|
45 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
46 |
*/
|
47 |
public class Test4ButtonsPanelWithExceptionsMessage { |
48 |
/**
|
49 |
* <p>Element for the interface.</p>
|
50 |
*/
|
51 |
private static JFrame jFrame; |
52 |
private static TreePanel panelGroup; |
53 |
|
54 |
/**
|
55 |
* <p>Test method for the Test4ButtonsPanelWithExceptionsMessage.</p>
|
56 |
*
|
57 |
* @param args optional arguments
|
58 |
*/
|
59 |
public static void main(String[] args) { |
60 |
try {
|
61 |
// Objects creation
|
62 |
jFrame = new JFrame(); |
63 |
|
64 |
Samples_ExtensionPointsOfIPanels.loadSample(); |
65 |
|
66 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
67 |
manager.registerPanelGroup(TreePanel.class); |
68 |
manager.setDefaultType(TreePanel.class); |
69 |
|
70 |
panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3); |
71 |
|
72 |
PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINT10_NAME);
|
73 |
|
74 |
// Creates the IWindow
|
75 |
PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panel with Buttons", 150, 150, (byte)WindowInfo.RESIZABLE, panelGroup); |
76 |
|
77 |
// Begin: Test the normal load
|
78 |
panelGroupDialog.loadPanels(loader); |
79 |
// End: Test the normal load
|
80 |
|
81 |
panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
|
82 |
/*
|
83 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
84 |
*/
|
85 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
86 |
switch (e.getButton()) {
|
87 |
case ButtonsPanel.BUTTON_ACCEPT:
|
88 |
System.out.println("Accept Button pressed."); |
89 |
hideJFrame(); |
90 |
System.exit(0); |
91 |
break;
|
92 |
case ButtonsPanel.BUTTON_CANCEL:
|
93 |
System.out.println("Cancel Button pressed."); |
94 |
hideJFrame(); |
95 |
System.exit(0); |
96 |
break;
|
97 |
case ButtonsPanel.BUTTON_APPLY:
|
98 |
System.out.println("Apply Button pressed."); |
99 |
break;
|
100 |
} |
101 |
} |
102 |
}); |
103 |
|
104 |
jFrame.setTitle("Test resizable PanelGroupDialog with tree and using PanelGroupLoaderFromExtensionPoint");
|
105 |
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
106 |
jFrame.setSize(panelGroupDialog.getPreferredSize()); |
107 |
jFrame.getContentPane().add(panelGroupDialog); |
108 |
|
109 |
jFrame.setVisible(true);
|
110 |
} catch (BaseException bE) {
|
111 |
System.out.println(bE.getLocalizedMessageStack());
|
112 |
} catch (Exception e) { |
113 |
e.printStackTrace(); |
114 |
} |
115 |
} |
116 |
|
117 |
/**
|
118 |
* <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
|
119 |
*/
|
120 |
private static void hideJFrame() { |
121 |
jFrame.setVisible(false);
|
122 |
} |
123 |
} |