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