svn-gvsig-desktop / tags / v1_1_Build_1003 / libraries / libCq_CMS_praster / src / org / cresques / ui / DefaultDialogPanel.java @ 12271
History | View | Annotate | Download (8.13 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 | 10645 | nacho | import java.awt.FlowLayout; |
27 | 8026 | nacho | 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 | 10645 | nacho | import javax.swing.event.ChangeEvent; |
35 | import javax.swing.event.ChangeListener; |
||
36 | 8026 | nacho | |
37 | 10645 | nacho | import org.cresques.i18n.Messages; |
38 | 8026 | nacho | |
39 | 10645 | nacho | |
40 | 8026 | nacho | /**
|
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 | 10645 | nacho | protected JPanel buttonPane = null; |
48 | 8026 | nacho | 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 | 10645 | nacho | protected JPanel pButton = null; |
55 | 8026 | nacho | |
56 | /**
|
||
57 | * Constructor
|
||
58 | * @param init
|
||
59 | */
|
||
60 | public DefaultDialogPanel(boolean init){ |
||
61 | if(init)
|
||
62 | initialize(); |
||
63 | } |
||
64 | 10645 | nacho | |
65 | 8026 | nacho | /**
|
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 | 10645 | nacho | GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
83 | gridBagConstraints11.gridx = 0;
|
||
84 | gridBagConstraints11.insets = new java.awt.Insets(4,0,0,0); |
||
85 | gridBagConstraints11.gridy = 1;
|
||
86 | 8026 | nacho | 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 | 10645 | nacho | this.add(getPButton(), gridBagConstraints11);
|
97 | 8026 | nacho | this.addComponentListener(this); |
98 | 10645 | nacho | |
99 | 8026 | nacho | } |
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 | 10645 | nacho | |
125 | |||
126 | 8026 | nacho | //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 | 10645 | nacho | * 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 | 8026 | nacho | * @return
|
157 | */
|
||
158 | protected JPanel getButtonPanel() { |
||
159 | if (buttonPane == null) { |
||
160 | GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
||
161 | 10645 | nacho | gridBagConstraints4.gridx = 2;
|
162 | gridBagConstraints4.insets = new java.awt.Insets(0,3,0,0); |
||
163 | 8026 | nacho | gridBagConstraints4.gridy = 0;
|
164 | GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
||
165 | 10645 | nacho | gridBagConstraints3.gridx = 1;
|
166 | gridBagConstraints3.insets = new java.awt.Insets(0,3,0,3); |
||
167 | 8026 | nacho | gridBagConstraints3.gridy = 0;
|
168 | 10645 | nacho | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
169 | gridBagConstraints1.insets = new java.awt.Insets(0,0,0,3); |
||
170 | gridBagConstraints1.gridy = 0;
|
||
171 | gridBagConstraints1.gridx = 0;
|
||
172 | 8026 | nacho | buttonPane = new JPanel(); |
173 | buttonPane.setLayout(new GridBagLayout()); |
||
174 | 10645 | nacho | buttonPane.add(getAcceptButton(), gridBagConstraints1); |
175 | buttonPane.add(getCancelButton(), gridBagConstraints3); |
||
176 | buttonPane.add(getApplyButton(), gridBagConstraints4); |
||
177 | 8026 | nacho | } |
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 | 10645 | nacho | acceptButton.setText(Messages.getText("Aceptar"));
|
191 | 8026 | nacho | } |
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 | 10645 | nacho | cancelButton.setText(Messages.getText("Cancelar"));
|
205 | 8026 | nacho | } |
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 | 10645 | nacho | applyButton = new JButton(Messages.getText("Aplicar")); |
218 | 8026 | nacho | } |
219 | |||
220 | return applyButton;
|
||
221 | } |
||
222 | |||
223 | public void componentHidden(ComponentEvent e) { |
||
224 | // TODO Auto-generated method stub
|
||
225 | 10645 | nacho | |
226 | 8026 | nacho | } |
227 | |||
228 | public void componentMoved(ComponentEvent e) { |
||
229 | // TODO Auto-generated method stub
|
||
230 | 10645 | nacho | |
231 | 8026 | nacho | } |
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 | 10645 | nacho | |
245 | 8026 | nacho | 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 | 10645 | nacho | |
252 | 8026 | nacho | this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight); |
253 | 10645 | nacho | //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 | 8026 | nacho | } |
258 | 10645 | nacho | |
259 | 8026 | nacho | public void componentShown(ComponentEvent e) { |
260 | // TODO Auto-generated method stub
|
||
261 | 10645 | nacho | |
262 | 8026 | nacho | } |
263 | 10645 | nacho | |
264 | |||
265 | 8026 | nacho | } // @jve:decl-index=0:visual-constraint="12,13" |