Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / InitialWarningExtension.java @ 44535

History | View | Annotate | Download (4.64 KB)

1 40558 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40558 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5 40435 jjdelcerro
 *
6 42589 jjdelcerro
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 40435 jjdelcerro
 *
11 42589 jjdelcerro
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 40435 jjdelcerro
 *
16 42589 jjdelcerro
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 40435 jjdelcerro
 *
20 42589 jjdelcerro
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22 40435 jjdelcerro
 */
23
package org.gvsig.app.extension;
24
25
import java.awt.Color;
26
import java.awt.Window;
27
28
import javax.swing.JButton;
29
import javax.swing.JCheckBox;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JWindow;
33
import javax.swing.border.TitledBorder;
34
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.plugins.Extension;
37
import org.gvsig.andami.ui.mdiManager.WindowInfo;
38
39
public class InitialWarningExtension extends Extension {
40
41 42589 jjdelcerro
    private DlgWaring dlgWarning;
42 40435 jjdelcerro
43 42589 jjdelcerro
    @Override
44
    public boolean isEnabled() {
45
        return false;
46
    }
47 40435 jjdelcerro
48 42589 jjdelcerro
    @Override
49
    public boolean isVisible() {
50
        return true;
51
    }
52 40435 jjdelcerro
53 42589 jjdelcerro
    @Override
54
    public void initialize() {
55 40435 jjdelcerro
56 42589 jjdelcerro
        if (isEnabled() && isVisible()) {
57
            dlgWarning = new DlgWaring();
58
            dlgWarning.setText(PluginServices.getText(this, "initial_warning"));
59
            dlgWarning.setVisible(true);
60
        }
61 40435 jjdelcerro
62 42589 jjdelcerro
    }
63 40435 jjdelcerro
64 42589 jjdelcerro
    @Override
65
    public void execute(String actionCommand) {
66 40435 jjdelcerro
67 42589 jjdelcerro
    }
68 40435 jjdelcerro
69 42589 jjdelcerro
    private class DlgWaring extends JWindow {
70 40435 jjdelcerro
71 42589 jjdelcerro
        private JButton btnOk = null;
72
        private final JCheckBox chkBoxShowAgain = null;
73
        private JLabel lblText = null;
74
        private JPanel panel = null;
75
        private JPanel panel2;
76 40435 jjdelcerro
77 42589 jjdelcerro
        /**
78
         * This is the default constructor
79
         */
80
        public DlgWaring() {
81
            super((Window) PluginServices.getMainFrame());
82
            Window window = (Window) PluginServices.getMainFrame();
83
            setLocation(window.getWidth() / 2 + window.getX() - 150, window.getHeight() / 2 + window.getY() - 150);
84
            initialize();
85
            this.setAlwaysOnTop(true);
86
        }
87 40435 jjdelcerro
88 42589 jjdelcerro
        public void setText(String string) {
89
            lblText.setText(string);
90
        }
91 40435 jjdelcerro
92 42589 jjdelcerro
        /**
93
         * This method initializes this
94
         *
95
         * @return void
96
         */
97
        private void initialize() {
98
            panel = new JPanel();
99
            panel.setBackground(Color.black);
100
            panel.setLayout(null);
101
            panel.setBounds(0, 0, 300, 300);
102
            panel2 = new JPanel();
103
            panel2.setLayout(null);
104
            panel2.setBounds(2, 2, 298, 298);
105
            lblText = new JLabel();
106
            lblText.setBounds(15, 15, 271, 200);
107
            lblText.setText("JLabel");
108
            lblText.setBorder(new TitledBorder(PluginServices.getText(this, "warning")));
109
            panel2.add(lblText);
110
            panel2.setSize((int) (panel.getSize().getWidth() - 4), (int) (panel.getSize().getHeight() - 4));
111
            panel.add(panel2);
112
            this.setLayout(null);
113
            this.setSize(300, 300);
114
            this.add(getBtnOk(), null);
115
            this.add(panel, null);
116
        }
117 40435 jjdelcerro
118 42589 jjdelcerro
        /**
119
         * This method initializes btnOk
120
         *
121
         * @return javax.swing.JButton
122
         */
123
        private JButton getBtnOk() {
124
            if (btnOk == null) {
125
                btnOk = new JButton();
126
                btnOk.setBounds(100, 250, 100, 20);
127
                btnOk.setText(PluginServices.getText(this, "aceptar"));
128
                btnOk.addActionListener(new java.awt.event.ActionListener() {
129
                    @Override
130
                    public void actionPerformed(java.awt.event.ActionEvent e) {
131
                        dlgWarning.setVisible(false);
132
                        dlgWarning.dispose();
133
                        //                                                PluginServices.getMDIManager().closeWindow(dlgWarning);
134
                    }
135
                });
136
            }
137
            return btnOk;
138
        }
139 40435 jjdelcerro
140 42589 jjdelcerro
        public WindowInfo getWindowInfo() {
141
            WindowInfo vi = new WindowInfo(WindowInfo.MODALDIALOG);
142
            vi.setWidth(300 + 8);
143
            vi.setHeight(250);
144
            vi.setTitle(PluginServices.getText(this, "warning"));
145
            return vi;
146
        }
147
148
    }
149
150 40435 jjdelcerro
}