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