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