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 / Test7ButtonsPanel.java @ 40558
History | View | Annotate | Download (4.18 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40558 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | * 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 | 40435 | jjdelcerro | */
|
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.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 TreePanel TreePanel}, and a non resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
|
||
42 | *
|
||
43 | * @version 22/10/2007
|
||
44 | * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
||
45 | */
|
||
46 | public class Test7ButtonsPanel { |
||
47 | /**
|
||
48 | * <p>Element for the interface.</p>
|
||
49 | */
|
||
50 | private static JFrame jFrame; |
||
51 | private static TreePanel panelGroup; |
||
52 | |||
53 | /**
|
||
54 | * <p>Test method for the Test7ButtonsPanel.</p>
|
||
55 | *
|
||
56 | * @param args optional arguments
|
||
57 | */
|
||
58 | public static void main(String[] args) { |
||
59 | try {
|
||
60 | jFrame = new JFrame(); |
||
61 | |||
62 | PanelGroupManager manager = PanelGroupManager.getManager(); |
||
63 | manager.registerPanelGroup(TreePanel.class); |
||
64 | manager.setDefaultType(TreePanel.class); |
||
65 | |||
66 | panelGroup = (TreePanel) 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 a tree 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 | } catch (BaseException bE) {
|
||
108 | System.out.println(bE.getLocalizedMessageStack());
|
||
109 | } catch (Exception e) { |
||
110 | e.printStackTrace(); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | /**
|
||
115 | * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
|
||
116 | */
|
||
117 | private static void hideJFrame() { |
||
118 | jFrame.setVisible(false);
|
||
119 | } |
||
120 | } |