Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / ui / DefaultDialogPanel.java @ 8026

History | View | Annotate | Download (7.44 KB)

1 8026 nacho
/*
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.Dimension;
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 java.awt.FlowLayout;
35
36
37
/**
38
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
39
 */
40
public class DefaultDialogPanel extends JPanel implements ComponentListener{
41
    final private static long serialVersionUID = -3370601314380922368L;
42
    protected JPanel contentPane = null;
43
    private JPanel tabPane = null;
44
    private JPanel buttonPane = null;
45
    private JButton acceptButton = null;
46
    private JButton cancelButton = null;
47
    private JButton applyButton = null;
48
    private int flag = 0;
49
    protected int cWidth = 0, difWidth = 0;
50
    protected int cHeight = 0, difHeight = 0;
51
52
    /**
53
     * Constructor
54
     * @param init
55
     */
56
    public DefaultDialogPanel(boolean init){
57
            if(init)
58
                    initialize();
59
    }
60
61
    /**
62
     * Constructor
63
     */
64
    public DefaultDialogPanel() {
65
        super();
66
        this.initialize();
67
    }
68
69
    /**
70
     * This method initializes this
71
     *
72
     * @return void
73
     */
74
    public void initialize() {
75
        //setBounds(0,0,321,230);
76
        //javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
77
        //jContentPane.setLayout(new java.awt.GridLayout(2,1));
78
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
79
        gridBagConstraints1.insets = new java.awt.Insets(3,22,2,23);
80
        gridBagConstraints1.gridy = 1;
81
        gridBagConstraints1.gridx = 0;
82
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
83
        gridBagConstraints.insets = new java.awt.Insets(5,0,2,0);
84
        gridBagConstraints.gridy = 0;
85
        gridBagConstraints.gridx = 0;
86
        setLayout(new GridBagLayout());
87
        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
88
89
        //jContentPane.setSize(30, 24);
90
        this.setPreferredSize(new java.awt.Dimension(320, 165));
91
        this.add(getTabPanel(), gridBagConstraints);
92
        this.add(getButtonPanel(), gridBagConstraints1);
93
        this.addComponentListener(this);
94
95
    }
96
97
    /**
98
     * Obtiene el panel general
99
     * @return
100
     */
101
    protected JPanel getContentPanel() {
102
        if (contentPane == null) {
103
            contentPane = new JPanel();
104
            contentPane.setLayout(new GridBagLayout());
105
            contentPane.setBounds(6, 200, 310, 125);
106
            contentPane.setPreferredSize(new java.awt.Dimension(310, 100));
107
        }
108
109
        return contentPane;
110
    }
111
112
    public JPanel getTabPanel() {
113
        if (tabPane == null) {
114
            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
115
            gridBagConstraints2.insets = new java.awt.Insets(5,0,0,0);
116
            gridBagConstraints2.gridy = 0;
117
            gridBagConstraints2.gridx = 0;
118
            tabPane = new JPanel();
119
            tabPane.setLayout(new GridBagLayout());
120
121
122
            //tabPane.setBounds(6, 7, 309, 189);
123
            tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
124
            tabPane.add(getContentPanel(), gridBagConstraints2);
125
        }
126
127
        return tabPane;
128
    }
129
130
    /**
131
     * Obtiene el panel que contiene los botones de Aceptar, Cancelar y Aplicar
132
     * @return
133
     */
134
    protected JPanel getButtonPanel() {
135
        if (buttonPane == null) {
136
            GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
137
            gridBagConstraints5.insets = new java.awt.Insets(1,0,1,0);
138
            gridBagConstraints5.gridy = 0;
139
            gridBagConstraints5.gridx = 2;
140
            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
141
            gridBagConstraints4.insets = new java.awt.Insets(1,0,1,8);
142
            gridBagConstraints4.gridy = 0;
143
            gridBagConstraints4.gridx = 1;
144
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
145
            gridBagConstraints3.insets = new java.awt.Insets(1,0,1,8);
146
            gridBagConstraints3.gridy = 0;
147
            gridBagConstraints3.gridx = 0;
148
            buttonPane = new JPanel();
149
            buttonPane.setLayout(new GridBagLayout());
150
            buttonPane.setSize(309, 25);
151
            buttonPane.setBounds(6, 200, 309, 25);
152
            buttonPane.add(getAcceptButton(), gridBagConstraints3);
153
            buttonPane.add(getCancelButton(), gridBagConstraints4);
154
            buttonPane.add(getApplyButton(), gridBagConstraints5);
155
        }
156
157
        return buttonPane;
158
    }
159
160
    /**
161
     * This method initializes Accept button
162
     *
163
     * @return javax.swing.JButton
164
     */
165
    public JButton getAcceptButton() {
166
        if (acceptButton == null) {
167
            acceptButton = new JButton("Aceptar");
168
            acceptButton.setText("Aceptar");
169
        }
170
171
        return acceptButton;
172
    }
173
174
    /**
175
     * This method initializes Cancel Button
176
     *
177
     * @return javax.swing.JButton
178
     */
179
    public JButton getCancelButton() {
180
        if (cancelButton == null) {
181
            cancelButton = new JButton("Cancelar");
182
            cancelButton.setText("Cancelar");
183
        }
184
185
        return cancelButton;
186
    }
187
188
    /**
189
     * This method initializes Apply Button
190
     *
191
     * @return javax.swing.JButton
192
     */
193
    public JButton getApplyButton() {
194
        if (applyButton == null) {
195
            applyButton = new JButton("Aplicar");
196
        }
197
198
        return applyButton;
199
    }
200
201
        public void componentHidden(ComponentEvent e) {
202
                // TODO Auto-generated method stub
203
204
        }
205
206
        public void componentMoved(ComponentEvent e) {
207
                // TODO Auto-generated method stub
208
209
        }
210
211
        public void componentResized(ComponentEvent e) {
212
                if(e.getSource() == this)
213
                        this.resizeWindow();
214
        }
215
216
        public void resizeWindow(){
217
                if (flag == 0){
218
                        cWidth = this.getSize().width;
219
                        cHeight = this.getSize().height;
220
                        flag++;
221
                }
222
223
                int nWidth = getWidth();
224
                int nHeight = getHeight();
225
                difWidth = nWidth - cWidth;
226
                difHeight = nHeight - cHeight;
227
                this.tabPane.setSize(this.tabPane.getSize().width + difWidth, this.tabPane.getSize().height + difHeight);
228
                this.tabPane.setLocation(this.tabPane.getLocation().x - difWidth/2, this.tabPane.getLocation().y - difHeight/2);
229
                this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight);
230
                this.buttonPane.setLocation(this.buttonPane.getLocation().x + difWidth/2, this.buttonPane.getLocation().y + difHeight/2);
231
232
        }
233
234
        public void componentShown(ComponentEvent e) {
235
                // TODO Auto-generated method stub
236
237
        }
238
}  //  @jve:decl-index=0:visual-constraint="12,13"