Statistics
| Revision:

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 / Test1ButtonsPanel.java @ 40558

History | View | Annotate | Download (4.48 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.tabbedPanel.TabbedPanel;
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>
41
 * Tests {@link PanelGroupDialog PanelGroupDialog}.
42
 * </p>
43
 * <p>
44
 * Tests {@link PanelGroupManager PanelGroupManager},
45
 * {@link PanelGroupLoaderFromList PanelGroupLoaderFromList},
46
 * {@link TabbedPanel TabbedPanel}, and a resizable {@link PanelGroupDialog
47
 * PanelGroupDialog}.
48
 * </p>
49
 * 
50
 * @version 16/10/2007
51
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
52
 */
53
public class Test1ButtonsPanel {
54
        /**
55
         * <p>Element for the interface.</p>
56
         */
57
        private static JFrame jFrame;
58

    
59
        /**
60
         * <p>
61
         * Test method for the Test1ButtonsPanel.
62
         * </p>
63
         * <p>
64
         * Tests {@link PanelGroupManager PanelGroupManager},
65
         * {@link PanelGroupLoaderFromList PanelGroupLoaderFromList},
66
         * {@link TabbedPanel TabbedPanel}, and a resizable {@link PanelGroupDialog
67
         * PanelGroupDialog}.
68
         * </p>
69
         * 
70
         * @param args
71
         *            optional arguments
72
         */
73
        public static void main(String[] args) {
74
                try {
75
                        // Objects creation
76
                        jFrame = new JFrame();
77

    
78
                        PanelGroupManager manager = PanelGroupManager.getManager();
79
                        manager.registerPanelGroup(TabbedPanel.class);
80
                        manager.setDefaultType(TabbedPanel.class);
81

    
82
                        TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE1);
83

    
84
                        PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS1_CLASSES);
85

    
86
                        // Creates the IWindow
87
                        PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panels with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup);
88

    
89
                        // Begin: Test the normal load
90
                        panelGroupDialog.loadPanels(loader);
91
                        // End: Test the normal load
92

    
93
                        panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
94
                                /*
95
                                 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
96
                                 */
97
                                public void actionButtonPressed(ButtonsPanelEvent e) {
98
                                        switch (e.getButton()) {
99
                                                case ButtonsPanel.BUTTON_ACCEPT:
100
                                                        System.out.println("Accept Button pressed.");
101
                                                        hideJFrame();
102
                                                        System.exit(0);
103
                                                        break;
104
                                                case ButtonsPanel.BUTTON_CANCEL:
105
                                                        System.out.println("Cancel Button pressed.");
106
                                                        hideJFrame();
107
                                                        System.exit(0);
108
                                                        break;
109
                                                case ButtonsPanel.BUTTON_APPLY:
110
                                                        System.out.println("Apply Button pressed.");
111
                                                        break;
112
                                        }
113
                                }
114
                        });
115

    
116
                        jFrame.setTitle("Test resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromList");
117
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
118
                    jFrame.setSize(panelGroupDialog.getPreferredSize());
119
                    jFrame.getContentPane().add(panelGroupDialog);
120

    
121
                        jFrame.setVisible(true);
122

    
123
                } catch (BaseException bE) {
124
                        System.out.println(bE.getLocalizedMessageStack());
125
                } catch (Exception e) {
126
                        e.printStackTrace();
127
                }
128
        }
129

    
130
        /**
131
         * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
132
         */
133
        private static void hideJFrame() {
134
                jFrame.setVisible(false);
135
        }
136
}