Statistics
| Revision:

gvsig-projects-pool / org.gvsig.winmgr / trunk / org.gvsig.winmgr.app / org.gvsig.winmgr.app.mainplugin / src / main / java / org / gvsig / coreplugin / NotificationDialog.java @ 682

History | View | Annotate | Download (8.65 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.coreplugin;
25

    
26
import javax.swing.JButton;
27
import javax.swing.JPanel;
28
import javax.swing.JScrollPane;
29
import javax.swing.JTextArea;
30
import javax.swing.SwingUtilities;
31

    
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.andami.messages.MessageEvent;
34
import org.gvsig.andami.messages.NotificationListener;
35
import org.gvsig.andami.ui.mdiManager.IWindow;
36
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
37
import org.gvsig.andami.ui.mdiManager.WindowInfo;
38

    
39

    
40

    
41
/**
42
 * Graphic interface that appears to show an error.
43
 *
44
 * @author Vicente Caballero Navarro
45
 */
46
public class NotificationDialog extends JPanel implements IWindow, SingletonWindow,
47
    NotificationListener {
48
    private JButton bDetails = null;
49
    private JPanel pDescription = null;
50
    private JTextArea txtDescription = null;
51
    private JButton bNoDetails = null;
52
    private JButton bAcept = null;
53
    private JScrollPane pScrollDescription = null;
54

    
55
    /**
56
     * This is the default constructor
57
     */
58
    public NotificationDialog() {
59
        super();
60
        initialize();
61
    }
62

    
63
    /**
64
     * This method initializes this
65
     */
66
    private void initialize() {
67
        Consola.consolaFrame.setSize(new java.awt.Dimension(457, 150));
68
        Consola.consolaFrame.setLocation(new java.awt.Point(11, 140));
69
        Consola.consolaFrame.setVisible(false);
70
        this.setLayout(null);
71
        this.setSize(470, 175);
72
        this.add(getBDetails(), null);
73
        this.add(getPDescription(), null);
74
        this.add(Consola.consolaFrame, null);
75
        this.add(getDNoDetails(), null);
76
        this.add(getBAcept(), null);
77
    }
78

    
79
    /**
80
     * This method initializes bDetails
81
     *
82
     * @return javax.swing.JButton
83
     */
84
    private JButton getBDetails() {
85
        if (bDetails == null) {
86
                final IWindow win = this;
87
            bDetails = new JButton();
88
            bDetails.setBounds(new java.awt.Rectangle(315, 110, 129, 24));
89
            bDetails.setText(PluginServices.getText(this,"detalles") + "   >>>");
90
            bDetails.setVisible(true);
91
            bDetails.addActionListener(new java.awt.event.ActionListener() {
92
                    public void actionPerformed(java.awt.event.ActionEvent e) {
93
                        Consola.consolaFrame.setVisible(true);
94
                        bDetails.setVisible(false);
95
                        getDNoDetails().setVisible(true);
96
                        PluginServices.getMDIManager()
97
                                      .getWindowInfo(win)
98
                                      .setHeight(325);
99
                        setSize(460, 325);
100
                    }
101
                });
102
        }
103

    
104
        return bDetails;
105
    }
106

    
107
    /**
108
     * This method initializes pDescription
109
     *
110
     * @return javax.swing.JPanel
111
     */
112
    private JPanel getPDescription() {
113
        if (pDescription == null) {
114
            pDescription = new JPanel();
115
            pDescription.setBounds(new java.awt.Rectangle(7, 5, 437, 99));
116
            pDescription.setBorder(javax.swing.BorderFactory.createTitledBorder(
117
                    null, PluginServices.getText(this,"descripcion"),
118
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
119
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
120
            pDescription.add(getPScrollDescription(), null);
121
        }
122

    
123
        return pDescription;
124
    }
125

    
126
    /**
127
     * This method initializes txtDescription
128
     *
129
     * @return javax.swing.JTextArea
130
     */
131
    private JTextArea getTxtDescription() {
132
        if (txtDescription == null) {
133
            txtDescription = new JTextArea();
134
            //txtDescription.setPreferredSize(new java.awt.Dimension(420, 65));
135
            txtDescription.setForeground(java.awt.Color.blue);
136
            txtDescription.setBackground(java.awt.SystemColor.control);
137
            txtDescription.setEditable(false);
138
        }
139

    
140
        return txtDescription;
141
    }
142

    
143
    /**
144
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getModel()
145
     */
146
    public Object getWindowModel() {
147
        return "consolaOld";
148
    }
149

    
150
    /**
151
     * @see org.gvsig.andami.ui.mdiManager.IWindow#getWindowInfo()
152
     */
153
    public WindowInfo getWindowInfo() {
154
        WindowInfo info = new WindowInfo(WindowInfo.MODELESSDIALOG |
155
                WindowInfo.ICONIFIABLE);
156
        info.setTitle(PluginServices.getText(this, "titulo_consola"));
157

    
158
        return info;
159
    }
160

    
161
    /**
162
     * @see com.iver.mdiApp.NotificationListener#errorEvent(java.lang.String)
163
     */
164
    public void errorEvent(MessageEvent e) {
165
        if (e.getMessages() != null) {
166
            for (int i = 0; i < e.getMessages().length; i++) {
167
                txtDescription.setText(e.getMessages()[i]);
168
            }
169
        }
170

    
171
        PluginServices.getMDIManager().restoreCursor();
172
        if (SwingUtilities.isEventDispatchThread()) {
173
            PluginServices.getMDIManager().addWindow(this);
174
        } else {
175
                final IWindow win = this;
176
            SwingUtilities.invokeLater(new Runnable() {
177
                    public void run() {
178
                        PluginServices.getMDIManager().addWindow(win);
179
                    }
180
                });
181
        }
182

    
183
    }
184

    
185
    /**
186
     * @see com.iver.mdiApp.NotificationListener#warningEvent(java.lang.String)
187
     */
188
    public void warningEvent(MessageEvent e) {
189
    }
190

    
191
    /**
192
     * @see com.iver.mdiApp.NotificationListener#infoEvent(java.lang.String)
193
     */
194
    public void infoEvent(MessageEvent e) {
195
    }
196

    
197
    /**
198
     * This method initializes dNoDetails
199
     *
200
     * @return javax.swing.JButton
201
     */
202
    private JButton getDNoDetails() {
203
        if (bNoDetails == null) {
204
            bNoDetails = new JButton();
205
            bNoDetails.setVisible(false);
206
            bNoDetails.setBounds(new java.awt.Rectangle(315, 110, 128, 24));
207
            bNoDetails.setText("<<<   " + PluginServices.getText(this,"detalles"));
208
            final IWindow win = this;
209
            bNoDetails.addActionListener(new java.awt.event.ActionListener() {
210
                    public void actionPerformed(java.awt.event.ActionEvent e) {
211
                        bDetails.setVisible(true);
212
                        bNoDetails.setVisible(false);
213
                        Consola.consolaFrame.setVisible(false);
214
                        PluginServices.getMDIManager()
215
                                      .getWindowInfo(win)
216
                                      .setHeight(175);
217
                        setSize(460, 175);
218
                    }
219
                });
220
        }
221

    
222
        return bNoDetails;
223
    }
224

    
225
    /**
226
     * This method initializes bAcept
227
     *
228
     * @return javax.swing.JButton
229
     */
230
    private JButton getBAcept() {
231
        if (bAcept == null) {
232
                final IWindow win = this;
233
            bAcept = new JButton();
234
            bAcept.setBounds(new java.awt.Rectangle(10, 110, 296, 24));
235
            bAcept.setText(PluginServices.getText(this,"aceptar"));
236
            bAcept.addActionListener(new java.awt.event.ActionListener() {
237
                    public void actionPerformed(java.awt.event.ActionEvent e) {
238
                        PluginServices.getMDIManager().closeWindow(win);
239
                    }
240
                });
241
        }
242

    
243
        return bAcept;
244
    }
245

    
246
    /**
247
     * This method initializes pScrollDescription
248
     *
249
     * @return javax.swing.JScrollPane
250
     */
251
    private JScrollPane getPScrollDescription() {
252
        if (pScrollDescription == null) {
253
            pScrollDescription = new JScrollPane();
254
            pScrollDescription.setPreferredSize(new java.awt.Dimension(420,67));
255
            pScrollDescription.setAutoscrolls(true);
256
            pScrollDescription.setViewportView(getTxtDescription());
257
        }
258

    
259
        return pScrollDescription;
260
    }
261
        public Object getWindowProfile() {
262
                return WindowInfo.PROPERTIES_PROFILE;
263
        }
264

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