Statistics
| Revision:

svn-gvsig-desktop / branches / libProjection_v2_0_prep / libraries / libProjection / src / org / cresques / impl / ui / DefaultDialogPanel.java @ 27135

History | View | Annotate | Download (8.07 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.impl.ui;
25

    
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.event.ComponentEvent;
30
import java.awt.event.ComponentListener;
31

    
32
import javax.swing.JButton;
33
import javax.swing.JPanel;
34

    
35
import org.cresques.impl.cts.Messages;
36

    
37

    
38
/**
39
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
40
 */
41
public class DefaultDialogPanel extends JPanel implements ComponentListener{
42
    final private static long serialVersionUID = -3370601314380922368L;
43
    protected JPanel contentPane = null;
44
    private JPanel tabPane = null;
45
    protected JPanel buttonPane = null;
46
    private JButton acceptButton = null;
47
    private JButton cancelButton = null;
48
    private JButton applyButton = null;
49
    private int flag = 0;
50
    protected int cWidth = 0, difWidth = 0;
51
    protected int cHeight = 0, difHeight = 0;
52
        protected JPanel pButton = null;
53

    
54
    /**
55
     * Constructor
56
     * @param init
57
     */
58
    public DefaultDialogPanel(boolean init){
59
            if(init)
60
                    initialize();
61
    }
62

    
63
    /**
64
     * Constructor
65
     */
66
    public DefaultDialogPanel() {
67
        super();
68
        this.initialize();
69
    }
70

    
71
    /**
72
     * This method initializes this
73
     *
74
     * @return void
75
     */
76
    public void initialize() {
77
        //setBounds(0,0,321,230);
78
        //javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
79
        //jContentPane.setLayout(new java.awt.GridLayout(2,1));
80
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
81
        gridBagConstraints11.gridx = 0;
82
        gridBagConstraints11.insets = new java.awt.Insets(4,0,0,0);
83
        gridBagConstraints11.gridy = 1;
84
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
85
        gridBagConstraints.insets = new java.awt.Insets(5,0,2,0);
86
        gridBagConstraints.gridy = 0;
87
        gridBagConstraints.gridx = 0;
88
        setLayout(new GridBagLayout());
89
        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
90

    
91
        //jContentPane.setSize(30, 24);
92
        this.setPreferredSize(new java.awt.Dimension(320, 165));
93
        this.add(getTabPanel(), gridBagConstraints);
94
        this.add(getPButton(), gridBagConstraints11);
95
        this.addComponentListener(this);
96

    
97
    }
98

    
99
    /**
100
     * Obtiene el panel general
101
     * @return
102
     */
103
    protected JPanel getContentPanel() {
104
        if (contentPane == null) {
105
            contentPane = new JPanel();
106
            contentPane.setLayout(new GridBagLayout());
107
            contentPane.setBounds(6, 200, 310, 125);
108
            contentPane.setPreferredSize(new java.awt.Dimension(310, 100));
109
        }
110

    
111
        return contentPane;
112
    }
113

    
114
    public JPanel getTabPanel() {
115
        if (tabPane == null) {
116
            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
117
            gridBagConstraints2.insets = new java.awt.Insets(5,0,0,0);
118
            gridBagConstraints2.gridy = 0;
119
            gridBagConstraints2.gridx = 0;
120
            tabPane = new JPanel();
121
            tabPane.setLayout(new GridBagLayout());
122

    
123

    
124
            //tabPane.setBounds(6, 7, 309, 189);
125
            tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
126
            tabPane.add(getContentPanel(), gridBagConstraints2);
127
        }
128

    
129
        return tabPane;
130
    }
131

    
132
    /**
133
         * This method initializes jPanel
134
         *
135
         * @return javax.swing.JPanel
136
         */
137
        private JPanel getPButton() {
138
                if (pButton == null) {
139
                        FlowLayout flowLayout1 = new FlowLayout();
140
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
141
                        flowLayout1.setHgap(0);
142
                        flowLayout1.setVgap(0);
143
                        pButton = new JPanel();
144
                        pButton.setPreferredSize(new java.awt.Dimension(320,25));
145
                        pButton.setLayout(flowLayout1);
146
                        pButton.add(getButtonPanel(), null);
147
                }
148
                return pButton;
149
        }
150

    
151

    
152
    /**
153
     * Obtiene el panel que contiene los botones de Aceptar, Cancelar y Aplicar
154
     * @return
155
     */
156
    protected JPanel getButtonPanel() {
157
        if (buttonPane == null) {
158
            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
159
            gridBagConstraints4.gridx = 2;
160
            gridBagConstraints4.insets = new java.awt.Insets(0,3,0,0);
161
            gridBagConstraints4.gridy = 0;
162
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
163
            gridBagConstraints3.gridx = 1;
164
            gridBagConstraints3.insets = new java.awt.Insets(0,3,0,3);
165
            gridBagConstraints3.gridy = 0;
166
            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
167
            gridBagConstraints1.insets = new java.awt.Insets(0,0,0,3);
168
            gridBagConstraints1.gridy = 0;
169
            gridBagConstraints1.gridx = 0;
170
            buttonPane = new JPanel();
171
            buttonPane.setLayout(new GridBagLayout());
172
            buttonPane.add(getAcceptButton(), gridBagConstraints1);
173
            buttonPane.add(getCancelButton(), gridBagConstraints3);
174
            buttonPane.add(getApplyButton(), gridBagConstraints4);
175
        }
176

    
177
        return buttonPane;
178
    }
179

    
180
    /**
181
     * This method initializes Accept button
182
     *
183
     * @return javax.swing.JButton
184
     */
185
    public JButton getAcceptButton() {
186
        if (acceptButton == null) {
187
            acceptButton = new JButton("Aceptar");
188
            acceptButton.setText(Messages.getText("Aceptar"));
189
        }
190

    
191
        return acceptButton;
192
    }
193

    
194
    /**
195
     * This method initializes Cancel Button
196
     *
197
     * @return javax.swing.JButton
198
     */
199
    public JButton getCancelButton() {
200
        if (cancelButton == null) {
201
            cancelButton = new JButton("Cancelar");
202
            cancelButton.setText(Messages.getText("Cancelar"));
203
        }
204

    
205
        return cancelButton;
206
    }
207

    
208
    /**
209
     * This method initializes Apply Button
210
     *
211
     * @return javax.swing.JButton
212
     */
213
    public JButton getApplyButton() {
214
        if (applyButton == null) {
215
            applyButton = new JButton(Messages.getText("Aplicar"));
216
        }
217

    
218
        return applyButton;
219
    }
220

    
221
        public void componentHidden(ComponentEvent e) {
222
                // TODO Auto-generated method stub
223

    
224
        }
225

    
226
        public void componentMoved(ComponentEvent e) {
227
                // TODO Auto-generated method stub
228

    
229
        }
230

    
231
        public void componentResized(ComponentEvent e) {
232
                if(e.getSource() == this)
233
                        this.resizeWindow();
234
        }
235

    
236
        public void resizeWindow(){
237
                if (flag == 0){
238
                        cWidth = this.getSize().width;
239
                        cHeight = this.getSize().height;
240
                        flag++;
241
                }
242

    
243
                int nWidth = getWidth();
244
                int nHeight = getHeight();
245
                difWidth = nWidth - cWidth;
246
                difHeight = nHeight - cHeight;
247
                this.tabPane.setSize(this.tabPane.getSize().width + difWidth, this.tabPane.getSize().height + difHeight);
248
                this.tabPane.setLocation(this.tabPane.getLocation().x - difWidth/2, this.tabPane.getLocation().y - difHeight/2);
249

    
250
                this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight);
251
                //this.pButton.setSize(this.getPButton().getWidth() + difWidth/2, 25);
252
                //this.buttonPane.setLocation(this.buttonPane.getLocation().x + difWidth/2, this.buttonPane.getLocation().y + difHeight/2);
253
                this.pButton.setLocation(this.pButton.getLocation().x + difWidth/2, this.pButton.getLocation().y + difHeight/2);
254

    
255
        }
256

    
257
        public void componentShown(ComponentEvent e) {
258
                // TODO Auto-generated method stub
259

    
260
        }
261

    
262

    
263
}  //  @jve:decl-index=0:visual-constraint="12,13"