Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCorePlugin / src / com / iver / core / NotificationDialog.java @ 25005

History | View | Annotate | Download (8.95 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 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
import com.iver.andami.ui.mdiManager.SingletonWindow;
47
import com.iver.andami.ui.mdiManager.IWindow;
48
import com.iver.andami.ui.mdiManager.WindowInfo;
49

    
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
public class NotificationDialog extends JPanel implements IWindow, SingletonWindow,
63
    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
        private int width = 470;
71
        private int height = 175;
72

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

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

    
97
    /**
98
     * This method initializes bDetails
99
     *
100
     * @return javax.swing.JButton
101
     */
102
    private JButton getBDetails() {
103
        if (bDetails == null) {
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(NotificationDialog.this)
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 "consola";
165
    }
166

    
167
    /**
168
     * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
169
     */
170
    public WindowInfo getWindowInfo() {
171
        WindowInfo info = new WindowInfo(WindowInfo.MODELESSDIALOG |
172
                WindowInfo.ICONIFIABLE);
173
        info.setWidth(width);
174
        info.setHeight(height);
175
        info.setTitle(PluginServices.getText(this, "titulo_consola"));
176

    
177
        return info;
178
    }
179

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

    
190
        PluginServices.getMDIManager().restoreCursor();
191
        if (SwingUtilities.isEventDispatchThread()) {
192
            PluginServices.getMDIManager().addWindow(this);
193
        } else {
194
            SwingUtilities.invokeLater(new Runnable() {
195
                    public void run() {
196
                        PluginServices.getMDIManager().addWindow(NotificationDialog.this);
197
                    }
198
                });
199
        }
200
        
201
    }
202

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

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

    
215
    /**
216
     * This method initializes dNoDetails
217
     *
218
     * @return javax.swing.JButton
219
     */
220
    private JButton getDNoDetails() {
221
        if (bNoDetails == null) {
222
            bNoDetails = new JButton();
223
            bNoDetails.setVisible(false);
224
            bNoDetails.setBounds(new java.awt.Rectangle(315, 110, 128, 24));
225
            bNoDetails.setText("<<<   " + PluginServices.getText(this,"detalles"));
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(NotificationDialog.this)
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
            bAcept = new JButton();
250
            bAcept.setBounds(new java.awt.Rectangle(10, 110, 296, 24));
251
            bAcept.setText(PluginServices.getText(this,"aceptar"));
252
            bAcept.addActionListener(new java.awt.event.ActionListener() {
253
                    public void actionPerformed(java.awt.event.ActionEvent e) {
254
                        PluginServices.getMDIManager().closeWindow(NotificationDialog.this);
255
                    }
256
                });
257
        }
258

    
259
        return bAcept;
260
    }
261

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

    
275
        return pScrollDescription;
276
    }
277

    
278
        public Object getWindowProfile() {
279
                return WindowInfo.PROPERTIES_PROFILE;
280
        }
281
} //  @jve:decl-index=0:visual-constraint="10,10"