Statistics
| Revision:

root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / defaultbuttonspanel / DefaultButtonsPanel.java @ 11042

History | View | Annotate | Download (4.29 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
package org.gvsig.gui.beans.defaultbuttonspanel;
20

    
21
import java.awt.Component;
22
import java.awt.LayoutManager;
23

    
24
import javax.swing.JPanel;
25

    
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
27
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
28
/**
29
 * <code>DefaultButtonsPanel</code> es un Panel que hereda de <code>JPanel</code> con
30
 * el a?adido de poder definir una botonera por defecto.
31
 *
32
 * @version 15/03/2007
33
 * @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
34
 */
35
public class DefaultButtonsPanel extends JPanel {
36
        private static final long serialVersionUID = 1519536113682350563L;
37
        ButtonsPanel bp = null;
38
        JPanel content = null;
39

    
40
        /**
41
         * Crea el <code>DefaultButtonsPanel</code> con los botones por defecto.
42
         */
43
        public DefaultButtonsPanel() {
44
    super.setLayout(new java.awt.BorderLayout(5, 5));
45
                getButtonsPanel().addAccept();
46
                getButtonsPanel().addCancel();
47
                getButtonsPanel().addApply();
48
                super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
49
                super.add(getContent(), java.awt.BorderLayout.CENTER);
50
        }
51
        
52
        /**
53
         * Crea el <code>DialogPanel</code> con los botones que definamos de la clase
54
         * <code>ButtonsPanel</code>
55
         * 
56
         * @param buttons Constante para definir que botones se crear?n
57
         */
58
        public DefaultButtonsPanel(int buttons) {
59
    super.setLayout(new java.awt.BorderLayout(5, 5));                
60
                bp = new ButtonsPanel(buttons);
61
                super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
62
                super.add(getContent(), java.awt.BorderLayout.CENTER);
63
        }
64
        
65
        /**
66
         * Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>.
67
         * En caso de no estar creado, lo crear?.
68
         * 
69
         * @return El componente bp
70
         */
71
        public ButtonsPanel getButtonsPanel() {
72
                if (bp == null)
73
                        bp = new ButtonsPanel();
74
                return bp;
75
        }
76

    
77
        /**
78
         * Obtener el contenido del <code>DialogPanel</code>. En caso de no estar creado,
79
         * lo crear?.
80
         * 
81
         * @return El componente content
82
         */
83
        public JPanel getContent() {
84
                if (content == null)
85
                        content = new JPanel();
86
                return content;
87
        }
88
        
89
        public void addButtonPressedListener(ButtonsPanelListener listener) {
90
          getButtonsPanel().addButtonPressedListener(listener);
91
        }
92

    
93
        public void removeButtonPressedListener(ButtonsPanelListener listener) {
94
          getButtonsPanel().removeButtonPressedListener(listener);
95
        }
96

    
97
        /*
98
         * (non-Javadoc)
99
         * @see java.awt.Container#getLayout()
100
         */
101
        public LayoutManager getLayout() {
102
                return getContent().getLayout();
103
        }
104
        
105
        /*
106
         * (non-Javadoc)
107
         * @see java.awt.Container#setLayout(java.awt.LayoutManager)
108
         */
109
        public void setLayout(LayoutManager mgr) {
110
                getContent().setLayout(mgr);
111
        }
112

    
113
        /*
114
         * (non-Javadoc)
115
         * @see java.awt.Container#add(java.awt.Component)
116
         */
117
        public Component add(Component comp) {
118
                return getContent().add(comp);
119
        }
120

    
121
        /*
122
         * (non-Javadoc)
123
         * @see java.awt.Container#add(java.awt.Component, int)
124
         */
125
        public Component add(Component comp, int index) {
126
                return getContent().add(comp, index);
127
        }
128
  
129
        /*
130
         * (non-Javadoc)
131
         * @see java.awt.Container#add(java.awt.Component, java.lang.Object)
132
         */
133
        public void add(Component comp, Object constraints) {
134
                getContent().add(comp, constraints);
135
        }
136
  
137
        /*
138
         * (non-Javadoc)
139
         * @see java.awt.Container#add(java.awt.Component, java.lang.Object, int)
140
         */
141
        public void add(Component comp, Object constraints, int index) {
142
                getContent().add(comp, constraints, index);
143
        }
144
  
145
        /*
146
         * (non-Javadoc)
147
         * @see java.awt.Container#add(java.lang.String, java.awt.Component)
148
         */
149
        public Component add(String name, Component comp) {
150
                return getContent().add(name, comp);
151
        }
152
}