Statistics
| Revision:

root / trunk / applications / appgvSIG / src-test / com / iver / cit / gvsig / panelGroup / Test6ButtonsPanel.java @ 15734

History | View | Annotate | Download (6.04 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 java.awt.Color;
23
import java.awt.Dimension;
24

    
25
import javax.swing.JFrame;
26

    
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
29
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
30
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
31
import org.gvsig.gui.beans.panelGroup.loaders.PanelGroupLoaderFromList;
32
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
33
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
34

    
35
import com.iver.andami.ui.mdiManager.WindowInfo;
36
import com.iver.cit.gvsig.panelGroup.PanelGroupDialog;
37
import com.iver.cit.gvsig.panelGroup.samples.Sample_ExtensionPointsOfIPanels;
38

    
39
/**
40
 * <p>Tests {@link PanelGroupDialog PanelGroupDialog}.</p>
41
 * <p>Tests the G.U.I. behaviour adding panels with different dimensions, to a resizable {@link PanelGroupDialog PanelGroupDialog}
42
 *  with a {@link TabbedPanel TabbedPanel}.</p>
43
 * 
44
 * @version 22/10/2007
45
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
46
 */
47
public class Test6ButtonsPanel {
48
        /**
49
         * <p>Element for the interface.</p>
50
         */
51
        private static JFrame jFrame;
52

    
53
        /**
54
         * <p>Test method for the Test6ButtonsPanel.</p>
55
         * <p>Tests the G.U.I. when adds panels with different dimensions, to a resizable <code>PanelGroupDialog</code>.</p>
56
         * 
57
         * @param args optional arguments
58
         */
59
        public static void main(String[] args) {
60
                try {
61
                        // Objects creation
62
                        jFrame = new JFrame();
63

    
64
                        PanelGroupManager manager = PanelGroupManager.getManager();
65
                        manager.setDefaultType(TabbedPanel.class);
66

    
67
                        TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(Sample_ExtensionPointsOfIPanels.REFERENCE1);
68
                        
69
                        PanelGroupLoaderFromList loader = new PanelGroupLoaderFromList(Sample_ExtensionPointsOfIPanels.EXTENSIONPOINTS1_CLASSES);
70
                        AbstractPanel[] panels = loader.loadPanels();
71

    
72
                        AbstractPanel panel;
73
                        
74
                        // Creates the IWindow
75
                        PanelGroupDialog panelGroupDialog = new PanelGroupDialog(Sample_ExtensionPointsOfIPanels.REFERENCE1_NAME, "Panel with Buttons", 800, 800, (byte)WindowInfo.RESIZABLE, panelGroup);
76
                        
77
                        // First panel
78
                        panel = panels[0];
79
                        panel.setPreferredSize(new Dimension(Sample_ExtensionPointsOfIPanels.PANELS_DEFAULT_WIDTH, Sample_ExtensionPointsOfIPanels.PANELS_DEFAULT_HEIGHT));
80
                        panel.setReference(Sample_ExtensionPointsOfIPanels.REFERENCE1);
81
                        panel.setID(Sample_ExtensionPointsOfIPanels.PANELS1_IDS[0]);
82
                        panel.setLabel(Sample_ExtensionPointsOfIPanels.PANELS1_LABELS[0]);
83
                        panel.setLabelGroup(Sample_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[0]);
84
                        panel.setBackground(Color.GRAY);
85
                        panelGroupDialog.addPanel(panel);
86

    
87
                        // Second panel
88
                        panel = panels[1];
89
                        panel.setPreferredSize(new Dimension(200, 200));
90
                        panel.setReference(Sample_ExtensionPointsOfIPanels.REFERENCE1);
91
                        panel.setID(Sample_ExtensionPointsOfIPanels.PANELS1_IDS[1]);
92
                        panel.setLabel(Sample_ExtensionPointsOfIPanels.PANELS1_LABELS[1]);
93
                        panel.setLabelGroup(Sample_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[1]);
94
                        panel.setBackground(Color.GRAY);
95
                        panelGroupDialog.addPanel(panel);
96

    
97
                        // Third panel
98
                        panel = panels[2];
99
                        panel.setPreferredSize(new Dimension(600, 500));
100
                        panel.setReference(Sample_ExtensionPointsOfIPanels.REFERENCE1);
101
                        panel.setID(Sample_ExtensionPointsOfIPanels.PANELS1_IDS[2]);
102
                        panel.setLabel(Sample_ExtensionPointsOfIPanels.PANELS1_LABELS[2]);
103
                        panel.setLabelGroup(Sample_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[2]);
104
                        panel.setBackground(Color.GRAY);
105
                        panelGroupDialog.addPanel(panel);
106

    
107
                        // Fourth panel
108
                        panel = panels[3];
109
                        panel.setPreferredSize(new Dimension(300, 400));
110
                        panel.setReference(Sample_ExtensionPointsOfIPanels.REFERENCE1);
111
                        panel.setID(Sample_ExtensionPointsOfIPanels.PANELS1_IDS[3]);
112
                        panel.setLabel(Sample_ExtensionPointsOfIPanels.PANELS1_LABELS[3]);
113
                        panel.setLabelGroup(Sample_ExtensionPointsOfIPanels.PANELS1_LABELGROUPS[3]);
114
                        panel.setBackground(Color.GRAY);
115
                        panelGroupDialog.addPanel(panel);
116
                        
117
                        panelGroupDialog.addButtonPressedListener(new ButtonsPanelListener() {
118
                                /*
119
                                 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
120
                                 */
121
                                public void actionButtonPressed(ButtonsPanelEvent e) {
122
                                        switch (e.getButton()) {
123
                                                case ButtonsPanel.BUTTON_ACCEPT:
124
                                                        System.out.println("Accept Button pressed.");
125
                                                        hideJFrame();
126
                                                        System.exit(0);
127
                                                        break;
128
                                                case ButtonsPanel.BUTTON_CANCEL:
129
                                                        System.out.println("Cancel Button pressed.");
130
                                                        hideJFrame();
131
                                                        System.exit(0);
132
                                                        break;
133
                                                case ButtonsPanel.BUTTON_APPLY:
134
                                                        System.out.println("Apply Button pressed.");
135
                                                        break;
136
                                        }
137
                                }
138
                        });
139
                        
140
                        jFrame.setTitle("Test Resizable PanelGroupDialog with tabs and using PanelGroupLoaderFromList");
141
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
142
                    jFrame.setSize(panelGroupDialog.getPreferredSize());
143
                    jFrame.getContentPane().add(panelGroupDialog);
144
                    
145
                    jFrame.setResizable(false);
146
                        jFrame.setVisible(true);
147
                        
148
                } catch (Exception e) {
149
                        e.printStackTrace();
150
                }
151
        }
152

    
153
        /**
154
         * <p>Hides the {@link JFrame JFrame}, hiding the graphical interface.</p>
155
         */
156
        private static void hideJFrame() {
157
                jFrame.setVisible(false);
158
        }
159
}