Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src-test / com / iver / cit / gvsig / panelGroup / Test3ButtonsPanelWithExceptionsMessage.java @ 17544

History | View | Annotate | Download (4.28 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

    
20
package com.iver.cit.gvsig.panelGroup;
21

    
22
import javax.swing.JFrame;
23

    
24
import org.gvsig.exceptions.BaseException;
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
28
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
29
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
30
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
31

    
32
import com.iver.andami.ui.mdiManager.WindowInfo;
33
import com.iver.cit.gvsig.panelGroup.samples.Samples_ExtensionPointsOfIPanels;
34

    
35
/**
36
 * <p>Test method for the Test1ButtonsPanelWithExceptionsMessage.</p>
37
 * <p>Tests the message dialog caused by the exceptions produced during the loading of panels, using {@link PanelGroupManager PanelGroupManager},
38
 *  {@link PanelGroupLoaderFromList PanelGroupLoaderFromList}, {@link TreePanel TreePanel}, and a resizable {@link PanelGroupDialog PanelGroupDialog}.</p>
39
 * 
40
 * @version 17/12/2007
41
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
42
 */
43
public class Test3ButtonsPanelWithExceptionsMessage {
44
        /**
45
         * <p>Element for the interface.</p>
46
         */
47
        private static JFrame jFrame;
48
        private static TreePanel panelGroup;
49

    
50
        /**
51
         * <p>Test method for the Test3ButtonsPanelWithExceptionsMessage.</p>
52
         * 
53
         * @param args optional arguments
54
         */
55
        public static void main(String[] args) {
56
                try {
57
                        // Objects creation
58
                        jFrame = new JFrame();
59

    
60
                        PanelGroupManager manager = PanelGroupManager.getManager();
61
                        manager.registerPanelGroup(TreePanel.class);
62
                        manager.setDefaultType(TreePanel.class);
63

    
64
                        panelGroup = (TreePanel) manager.getPanelGroup(Samples_ExtensionPointsOfIPanels.REFERENCE3);
65
                        
66
                        PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Samples_ExtensionPointsOfIPanels.EXTENSIONPOINTS10_CLASSES);
67

    
68
                        // Creates the IWindow
69
                        PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Samples_ExtensionPointsOfIPanels.REFERENCE3_NAME, "Panel with Buttons", 800, 650, (byte)WindowInfo.RESIZABLE, panelGroup);
70
                        
71
                        // Begin: Test the normal load
72
                        panelGroupDialog.loadPanels(loader);
73
                        // End: Test the normal load
74

    
75
                        panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
76
                                /*
77
                                 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
78
                                 */
79
                                public void actionButtonPressed(ButtonsPanelEvent e) {
80
                                        switch (e.getButton()) {
81
                                                case ButtonsPanel.BUTTON_ACCEPT:
82
                                                        System.out.println("Accept Button pressed.");
83
                                                        hideJFrame();
84
                                                        System.exit(0);
85
                                                        break;
86
                                                case ButtonsPanel.BUTTON_CANCEL:
87
                                                        System.out.println("Cancel Button pressed.");
88
                                                        hideJFrame();
89
                                                        System.exit(0);
90
                                                        break;
91
                                                case ButtonsPanel.BUTTON_APPLY:
92
                                                        System.out.println("Apply Button pressed.");
93
                                                        break;
94
                                        }
95
                                }
96
                        });
97
                        
98
                        jFrame.setTitle("Test resizable PanelGroupDialog with tree and using PanelGroupLoaderFromList");
99
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
100
                    jFrame.setSize(panelGroupDialog.getPreferredSize());
101
                    jFrame.getContentPane().add(panelGroupDialog);
102
                    
103
                        jFrame.setVisible(true);                        
104
                } catch (BaseException bE) {
105
                        System.out.println(bE.getLocalizedMessageStack());
106
                } catch (Exception e) {
107
                        e.printStackTrace();
108
                }
109
        }
110
        
111
        /**
112
         * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
113
         */
114
        private static void hideJFrame() {
115
                jFrame.setVisible(false);
116
        }
117
}