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 / Test3ButtonsPanel.java @ 40558
History | View | Annotate | Download (4.24 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.treePanel.TreePanel; |
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>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
|
41 |
* <p>Tests {@link PanelGroupManager PanelGroupManager}, {@link PanelGroupLoaderFromList PanelGroupLoaderFromList},
|
42 |
* {@link TreePanel TreePanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
|
43 |
*
|
44 |
* @version 22/10/2007
|
45 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
46 |
*/
|
47 |
public class Test3ButtonsPanel { |
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 Test3ButtonsPanel.</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 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
65 |
manager.registerPanelGroup(TreePanel.class); |
66 |
manager.setDefaultType(TreePanel.class); |
67 |
|
68 |
panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1); |
69 |
|
70 |
PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS1_CLASSES);
|
71 |
|
72 |
// Creates the IWindow
|
73 |
PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup); |
74 |
|
75 |
// Begin: Test the normal load
|
76 |
panelGroupDialog.loadPanels(loader); |
77 |
// End: Test the normal load
|
78 |
|
79 |
panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
|
80 |
/*
|
81 |
* @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
|
82 |
*/
|
83 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
84 |
switch (e.getButton()) {
|
85 |
case ButtonsPanel.BUTTON_ACCEPT:
|
86 |
System.out.println("Accept Button pressed."); |
87 |
hideJFrame(); |
88 |
System.exit(0); |
89 |
break;
|
90 |
case ButtonsPanel.BUTTON_CANCEL:
|
91 |
System.out.println("Cancel Button pressed."); |
92 |
hideJFrame(); |
93 |
System.exit(0); |
94 |
break;
|
95 |
case ButtonsPanel.BUTTON_APPLY:
|
96 |
System.out.println("Apply Button pressed."); |
97 |
break;
|
98 |
} |
99 |
} |
100 |
}); |
101 |
|
102 |
jFrame.setTitle("Test resizable PanelGroupDialog with tree and using PanelGroupLoaderFromList");
|
103 |
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
104 |
jFrame.setSize(panelGroupDialog.getPreferredSize()); |
105 |
jFrame.getContentPane().add(panelGroupDialog); |
106 |
|
107 |
jFrame.setVisible(true);
|
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 |
} |