Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_910 / libraries / libCq CMS for java.old / src / org / cresques / ui / DefaultDialogPanel.java @ 11275

History | View | Annotate | Download (8.13 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.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
import javax.swing.event.ChangeEvent;
35
import javax.swing.event.ChangeListener;
36

    
37
import org.cresques.i18n.Messages;
38

    
39

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

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

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

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

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

    
99
    }
100

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

    
113
        return contentPane;
114
    }
115

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

    
125

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

    
131
        return tabPane;
132
    }
133

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

    
153

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

    
179
        return buttonPane;
180
    }
181

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

    
193
        return acceptButton;
194
    }
195

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

    
207
        return cancelButton;
208
    }
209

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

    
220
        return applyButton;
221
    }
222

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

    
226
        }
227

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

    
231
        }
232

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

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

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

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

    
257
        }
258

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

    
262
        }
263

    
264

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