Statistics
| Revision:

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

History | View | Annotate | Download (4.45 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(0, 0));                
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
    this.setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11));
51
        }
52
        
53
        /**
54
         * Crea el <code>DialogPanel</code> con los botones que definamos de la clase
55
         * <code>ButtonsPanel</code>
56
         * 
57
         * @param buttons Constante para definir que botones se crear?n
58
         */
59
        public DefaultButtonsPanel(int buttons) {
60
    super.setLayout(new java.awt.BorderLayout(0, 0));                
61
                bp = new ButtonsPanel(buttons);
62
                super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
63
                super.add(getContent(), java.awt.BorderLayout.CENTER);
64
    this.setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11));
65
        }
66
        
67
        /**
68
         * Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>.
69
         * En caso de no estar creado, lo crear?.
70
         * 
71
         * @return El componente bp
72
         */
73
        public ButtonsPanel getButtonsPanel() {
74
                if (bp == null)
75
                        bp = new ButtonsPanel();
76
                return bp;
77
        }
78

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

    
95
        public void removeButtonPressedListener(ButtonsPanelListener listener) {
96
          getButtonsPanel().removeButtonPressedListener(listener);
97
        }
98

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

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

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