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