svn-gvsig-desktop / tags / v1_0_2_Build_902 / libraries / libCorePlugin / src / com / iver / core / NotificationDialog.java @ 10681
History | View | Annotate | Download (8.75 KB)
1 | 2917 | caballero | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package com.iver.core; |
||
42 | |||
43 | import com.iver.andami.PluginServices; |
||
44 | import com.iver.andami.messages.MessageEvent; |
||
45 | import com.iver.andami.messages.NotificationListener; |
||
46 | 6880 | cesar | import com.iver.andami.ui.mdiManager.SingletonWindow; |
47 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
48 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
49 | 2917 | caballero | |
50 | import javax.swing.JButton; |
||
51 | import javax.swing.JPanel; |
||
52 | import javax.swing.JScrollPane; |
||
53 | import javax.swing.JTextArea; |
||
54 | import javax.swing.SwingUtilities; |
||
55 | |||
56 | |||
57 | /**
|
||
58 | * Graphic interface that appears to show an error.
|
||
59 | *
|
||
60 | * @author Vicente Caballero Navarro
|
||
61 | */
|
||
62 | 6880 | cesar | public class NotificationDialog extends JPanel implements IWindow, SingletonWindow, |
63 | 2917 | caballero | NotificationListener {
|
64 | private JButton bDetails = null; |
||
65 | private JPanel pDescription = null; |
||
66 | private JTextArea txtDescription = null; |
||
67 | private JButton bNoDetails = null; |
||
68 | private JButton bAcept = null; |
||
69 | private JScrollPane pScrollDescription = null; |
||
70 | |||
71 | /**
|
||
72 | * This is the default constructor
|
||
73 | */
|
||
74 | public NotificationDialog() {
|
||
75 | super();
|
||
76 | initialize(); |
||
77 | } |
||
78 | |||
79 | /**
|
||
80 | * This method initializes this
|
||
81 | */
|
||
82 | private void initialize() { |
||
83 | Consola.consolaFrame.setSize(new java.awt.Dimension(457, 150)); |
||
84 | Consola.consolaFrame.setLocation(new java.awt.Point(11, 140)); |
||
85 | Consola.consolaFrame.setVisible(false);
|
||
86 | this.setLayout(null); |
||
87 | this.setSize(470, 175); |
||
88 | this.add(getBDetails(), null); |
||
89 | this.add(getPDescription(), null); |
||
90 | this.add(Consola.consolaFrame, null); |
||
91 | this.add(getDNoDetails(), null); |
||
92 | this.add(getBAcept(), null); |
||
93 | } |
||
94 | |||
95 | /**
|
||
96 | * This method initializes bDetails
|
||
97 | *
|
||
98 | * @return javax.swing.JButton
|
||
99 | */
|
||
100 | private JButton getBDetails() { |
||
101 | if (bDetails == null) { |
||
102 | bDetails = new JButton(); |
||
103 | bDetails.setBounds(new java.awt.Rectangle(315, 110, 129, 24)); |
||
104 | bDetails.setText(PluginServices.getText(this,"detalles") + " >>>"); |
||
105 | bDetails.setVisible(true);
|
||
106 | bDetails.addActionListener(new java.awt.event.ActionListener() {
|
||
107 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
108 | Consola.consolaFrame.setVisible(true);
|
||
109 | bDetails.setVisible(false);
|
||
110 | getDNoDetails().setVisible(true);
|
||
111 | PluginServices.getMDIManager() |
||
112 | 6880 | cesar | .getWindowInfo(NotificationDialog.this) |
113 | 2917 | caballero | .setHeight(325);
|
114 | setSize(460, 325); |
||
115 | } |
||
116 | }); |
||
117 | } |
||
118 | |||
119 | return bDetails;
|
||
120 | } |
||
121 | |||
122 | /**
|
||
123 | * This method initializes pDescription
|
||
124 | *
|
||
125 | * @return javax.swing.JPanel
|
||
126 | */
|
||
127 | private JPanel getPDescription() { |
||
128 | if (pDescription == null) { |
||
129 | pDescription = new JPanel(); |
||
130 | pDescription.setBounds(new java.awt.Rectangle(7, 5, 437, 99)); |
||
131 | pDescription.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
132 | null, PluginServices.getText(this,"descripcion"), |
||
133 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
134 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
135 | pDescription.add(getPScrollDescription(), null);
|
||
136 | } |
||
137 | |||
138 | return pDescription;
|
||
139 | } |
||
140 | |||
141 | /**
|
||
142 | * This method initializes txtDescription
|
||
143 | *
|
||
144 | * @return javax.swing.JTextArea
|
||
145 | */
|
||
146 | private JTextArea getTxtDescription() { |
||
147 | if (txtDescription == null) { |
||
148 | txtDescription = new JTextArea(); |
||
149 | //txtDescription.setPreferredSize(new java.awt.Dimension(420, 65));
|
||
150 | txtDescription.setForeground(java.awt.Color.blue); |
||
151 | txtDescription.setBackground(java.awt.SystemColor.control); |
||
152 | txtDescription.setEditable(false);
|
||
153 | } |
||
154 | |||
155 | return txtDescription;
|
||
156 | } |
||
157 | |||
158 | /**
|
||
159 | 6877 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getModel()
|
160 | 2917 | caballero | */
|
161 | 6880 | cesar | public Object getWindowModel() { |
162 | 2917 | caballero | return "consola"; |
163 | } |
||
164 | |||
165 | /**
|
||
166 | 6880 | cesar | * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
167 | 2917 | caballero | */
|
168 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
169 | WindowInfo info = new WindowInfo(WindowInfo.MODELESSDIALOG |
|
||
170 | WindowInfo.ICONIFIABLE); |
||
171 | 2917 | caballero | info.setTitle(PluginServices.getText(this, "titulo_consola")); |
172 | |||
173 | return info;
|
||
174 | } |
||
175 | |||
176 | /**
|
||
177 | * @see com.iver.mdiApp.NotificationListener#errorEvent(java.lang.String)
|
||
178 | */
|
||
179 | public void errorEvent(MessageEvent e) { |
||
180 | if (e.getMessages() != null) { |
||
181 | for (int i = 0; i < e.getMessages().length; i++) { |
||
182 | txtDescription.setText(e.getMessages()[i]); |
||
183 | } |
||
184 | } |
||
185 | |||
186 | 3250 | fjp | PluginServices.getMDIManager().restoreCursor(); |
187 | 2917 | caballero | if (SwingUtilities.isEventDispatchThread()) { |
188 | 6880 | cesar | PluginServices.getMDIManager().addWindow(this);
|
189 | 2917 | caballero | } else {
|
190 | SwingUtilities.invokeLater(new Runnable() { |
||
191 | public void run() { |
||
192 | 6880 | cesar | PluginServices.getMDIManager().addWindow(NotificationDialog.this); |
193 | 2917 | caballero | } |
194 | }); |
||
195 | } |
||
196 | |||
197 | } |
||
198 | |||
199 | /**
|
||
200 | * @see com.iver.mdiApp.NotificationListener#warningEvent(java.lang.String)
|
||
201 | */
|
||
202 | public void warningEvent(MessageEvent e) { |
||
203 | } |
||
204 | |||
205 | /**
|
||
206 | * @see com.iver.mdiApp.NotificationListener#infoEvent(java.lang.String)
|
||
207 | */
|
||
208 | public void infoEvent(MessageEvent e) { |
||
209 | } |
||
210 | |||
211 | /**
|
||
212 | * This method initializes dNoDetails
|
||
213 | *
|
||
214 | * @return javax.swing.JButton
|
||
215 | */
|
||
216 | private JButton getDNoDetails() { |
||
217 | if (bNoDetails == null) { |
||
218 | bNoDetails = new JButton(); |
||
219 | bNoDetails.setVisible(false);
|
||
220 | bNoDetails.setBounds(new java.awt.Rectangle(315, 110, 128, 24)); |
||
221 | bNoDetails.setText("<<< " + PluginServices.getText(this,"detalles")); |
||
222 | bNoDetails.addActionListener(new java.awt.event.ActionListener() {
|
||
223 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
224 | bDetails.setVisible(true);
|
||
225 | bNoDetails.setVisible(false);
|
||
226 | Consola.consolaFrame.setVisible(false);
|
||
227 | PluginServices.getMDIManager() |
||
228 | 6880 | cesar | .getWindowInfo(NotificationDialog.this) |
229 | 2917 | caballero | .setHeight(175);
|
230 | setSize(460, 175); |
||
231 | } |
||
232 | }); |
||
233 | } |
||
234 | |||
235 | return bNoDetails;
|
||
236 | } |
||
237 | |||
238 | /**
|
||
239 | * This method initializes bAcept
|
||
240 | *
|
||
241 | * @return javax.swing.JButton
|
||
242 | */
|
||
243 | private JButton getBAcept() { |
||
244 | if (bAcept == null) { |
||
245 | bAcept = new JButton(); |
||
246 | bAcept.setBounds(new java.awt.Rectangle(10, 110, 296, 24)); |
||
247 | bAcept.setText(PluginServices.getText(this,"aceptar")); |
||
248 | bAcept.addActionListener(new java.awt.event.ActionListener() {
|
||
249 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
250 | 6880 | cesar | PluginServices.getMDIManager().closeWindow(NotificationDialog.this); |
251 | 2917 | caballero | } |
252 | }); |
||
253 | } |
||
254 | |||
255 | return bAcept;
|
||
256 | } |
||
257 | |||
258 | /**
|
||
259 | * This method initializes pScrollDescription
|
||
260 | *
|
||
261 | * @return javax.swing.JScrollPane
|
||
262 | */
|
||
263 | private JScrollPane getPScrollDescription() { |
||
264 | if (pScrollDescription == null) { |
||
265 | pScrollDescription = new JScrollPane(); |
||
266 | pScrollDescription.setPreferredSize(new java.awt.Dimension(420,67)); |
||
267 | pScrollDescription.setAutoscrolls(true);
|
||
268 | pScrollDescription.setViewportView(getTxtDescription()); |
||
269 | } |
||
270 | |||
271 | return pScrollDescription;
|
||
272 | } |
||
273 | } // @jve:decl-index=0:visual-constraint="10,10" |