Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libCorePlugin / src / org / gvsig / coreplugin / NotificationDialog.java @ 38564

History | View | Annotate | Download (8.9 KB)

1
/* 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 org.gvsig.coreplugin;
42

    
43
import javax.swing.JButton;
44
import javax.swing.JPanel;
45
import javax.swing.JScrollPane;
46
import javax.swing.JTextArea;
47
import javax.swing.SwingUtilities;
48

    
49
import org.gvsig.andami.PluginServices;
50
import org.gvsig.andami.messages.MessageEvent;
51
import org.gvsig.andami.messages.NotificationListener;
52
import org.gvsig.andami.ui.mdiManager.IWindow;
53
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
54
import org.gvsig.andami.ui.mdiManager.WindowInfo;
55

    
56

    
57

    
58
/**
59
 * Graphic interface that appears to show an error.
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class NotificationDialog extends JPanel implements IWindow, SingletonWindow,
64
    NotificationListener {
65
    private JButton bDetails = null;
66
    private JPanel pDescription = null;
67
    private JTextArea txtDescription = null;
68
    private JButton bNoDetails = null;
69
    private JButton bAcept = null;
70
    private JScrollPane pScrollDescription = null;
71

    
72
    /**
73
     * This is the default constructor
74
     */
75
    public NotificationDialog() {
76
        super();
77
        initialize();
78
    }
79

    
80
    /**
81
     * This method initializes this
82
     */
83
    private void initialize() {
84
        Consola.consolaFrame.setSize(new java.awt.Dimension(457, 150));
85
        Consola.consolaFrame.setLocation(new java.awt.Point(11, 140));
86
        Consola.consolaFrame.setVisible(false);
87
        this.setLayout(null);
88
        this.setSize(470, 175);
89
        this.add(getBDetails(), null);
90
        this.add(getPDescription(), null);
91
        this.add(Consola.consolaFrame, null);
92
        this.add(getDNoDetails(), null);
93
        this.add(getBAcept(), null);
94
    }
95

    
96
    /**
97
     * This method initializes bDetails
98
     *
99
     * @return javax.swing.JButton
100
     */
101
    private JButton getBDetails() {
102
        if (bDetails == null) {
103
                final IWindow win = this;
104
            bDetails = new JButton();
105
            bDetails.setBounds(new java.awt.Rectangle(315, 110, 129, 24));
106
            bDetails.setText(PluginServices.getText(this,"detalles") + "   >>>");
107
            bDetails.setVisible(true);
108
            bDetails.addActionListener(new java.awt.event.ActionListener() {
109
                    public void actionPerformed(java.awt.event.ActionEvent e) {
110
                        Consola.consolaFrame.setVisible(true);
111
                        bDetails.setVisible(false);
112
                        getDNoDetails().setVisible(true);
113
                        PluginServices.getMDIManager()
114
                                      .getWindowInfo(win)
115
                                      .setHeight(325);
116
                        setSize(460, 325);
117
                    }
118
                });
119
        }
120

    
121
        return bDetails;
122
    }
123

    
124
    /**
125
     * This method initializes pDescription
126
     *
127
     * @return javax.swing.JPanel
128
     */
129
    private JPanel getPDescription() {
130
        if (pDescription == null) {
131
            pDescription = new JPanel();
132
            pDescription.setBounds(new java.awt.Rectangle(7, 5, 437, 99));
133
            pDescription.setBorder(javax.swing.BorderFactory.createTitledBorder(
134
                    null, PluginServices.getText(this,"descripcion"),
135
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
136
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
137
            pDescription.add(getPScrollDescription(), null);
138
        }
139

    
140
        return pDescription;
141
    }
142

    
143
    /**
144
     * This method initializes txtDescription
145
     *
146
     * @return javax.swing.JTextArea
147
     */
148
    private JTextArea getTxtDescription() {
149
        if (txtDescription == null) {
150
            txtDescription = new JTextArea();
151
            //txtDescription.setPreferredSize(new java.awt.Dimension(420, 65));
152
            txtDescription.setForeground(java.awt.Color.blue);
153
            txtDescription.setBackground(java.awt.SystemColor.control);
154
            txtDescription.setEditable(false);
155
        }
156

    
157
        return txtDescription;
158
    }
159

    
160
    /**
161
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getModel()
162
     */
163
    public Object getWindowModel() {
164
        return "consolaOld";
165
    }
166

    
167
    /**
168
     * @see org.gvsig.andami.ui.mdiManager.IWindow#getWindowInfo()
169
     */
170
    public WindowInfo getWindowInfo() {
171
        WindowInfo info = new WindowInfo(WindowInfo.MODELESSDIALOG |
172
                WindowInfo.ICONIFIABLE);
173
        info.setTitle(PluginServices.getText(this, "titulo_consola"));
174

    
175
        return info;
176
    }
177

    
178
    /**
179
     * @see com.iver.mdiApp.NotificationListener#errorEvent(java.lang.String)
180
     */
181
    public void errorEvent(MessageEvent e) {
182
        if (e.getMessages() != null) {
183
            for (int i = 0; i < e.getMessages().length; i++) {
184
                txtDescription.setText(e.getMessages()[i]);
185
            }
186
        }
187

    
188
        PluginServices.getMDIManager().restoreCursor();
189
        if (SwingUtilities.isEventDispatchThread()) {
190
            PluginServices.getMDIManager().addWindow(this);
191
        } else {
192
                final IWindow win = this;
193
            SwingUtilities.invokeLater(new Runnable() {
194
                    public void run() {
195
                        PluginServices.getMDIManager().addWindow(win);
196
                    }
197
                });
198
        }
199

    
200
    }
201

    
202
    /**
203
     * @see com.iver.mdiApp.NotificationListener#warningEvent(java.lang.String)
204
     */
205
    public void warningEvent(MessageEvent e) {
206
    }
207

    
208
    /**
209
     * @see com.iver.mdiApp.NotificationListener#infoEvent(java.lang.String)
210
     */
211
    public void infoEvent(MessageEvent e) {
212
    }
213

    
214
    /**
215
     * This method initializes dNoDetails
216
     *
217
     * @return javax.swing.JButton
218
     */
219
    private JButton getDNoDetails() {
220
        if (bNoDetails == null) {
221
            bNoDetails = new JButton();
222
            bNoDetails.setVisible(false);
223
            bNoDetails.setBounds(new java.awt.Rectangle(315, 110, 128, 24));
224
            bNoDetails.setText("<<<   " + PluginServices.getText(this,"detalles"));
225
            final IWindow win = this;
226
            bNoDetails.addActionListener(new java.awt.event.ActionListener() {
227
                    public void actionPerformed(java.awt.event.ActionEvent e) {
228
                        bDetails.setVisible(true);
229
                        bNoDetails.setVisible(false);
230
                        Consola.consolaFrame.setVisible(false);
231
                        PluginServices.getMDIManager()
232
                                      .getWindowInfo(win)
233
                                      .setHeight(175);
234
                        setSize(460, 175);
235
                    }
236
                });
237
        }
238

    
239
        return bNoDetails;
240
    }
241

    
242
    /**
243
     * This method initializes bAcept
244
     *
245
     * @return javax.swing.JButton
246
     */
247
    private JButton getBAcept() {
248
        if (bAcept == null) {
249
                final IWindow win = this;
250
            bAcept = new JButton();
251
            bAcept.setBounds(new java.awt.Rectangle(10, 110, 296, 24));
252
            bAcept.setText(PluginServices.getText(this,"aceptar"));
253
            bAcept.addActionListener(new java.awt.event.ActionListener() {
254
                    public void actionPerformed(java.awt.event.ActionEvent e) {
255
                        PluginServices.getMDIManager().closeWindow(win);
256
                    }
257
                });
258
        }
259

    
260
        return bAcept;
261
    }
262

    
263
    /**
264
     * This method initializes pScrollDescription
265
     *
266
     * @return javax.swing.JScrollPane
267
     */
268
    private JScrollPane getPScrollDescription() {
269
        if (pScrollDescription == null) {
270
            pScrollDescription = new JScrollPane();
271
            pScrollDescription.setPreferredSize(new java.awt.Dimension(420,67));
272
            pScrollDescription.setAutoscrolls(true);
273
            pScrollDescription.setViewportView(getTxtDescription());
274
        }
275

    
276
        return pScrollDescription;
277
    }
278
        public Object getWindowProfile() {
279
                return WindowInfo.PROPERTIES_PROFILE;
280
        }
281

    
282
} //  @jve:decl-index=0:visual-constraint="10,10"