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 @ 44601
History | View | Annotate | Download (4.64 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 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 |
*
|
11 |
* 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 |
*
|
16 |
* 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 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
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 |
private DlgWaring dlgWarning;
|
42 |
|
43 |
@Override
|
44 |
public boolean isEnabled() { |
45 |
return false; |
46 |
} |
47 |
|
48 |
@Override
|
49 |
public boolean isVisible() { |
50 |
return true; |
51 |
} |
52 |
|
53 |
@Override
|
54 |
public void initialize() { |
55 |
|
56 |
if (isEnabled() && isVisible()) {
|
57 |
dlgWarning = new DlgWaring();
|
58 |
dlgWarning.setText(PluginServices.getText(this, "initial_warning")); |
59 |
dlgWarning.setVisible(true);
|
60 |
} |
61 |
|
62 |
} |
63 |
|
64 |
@Override
|
65 |
public void execute(String actionCommand) { |
66 |
|
67 |
} |
68 |
|
69 |
private class DlgWaring extends JWindow { |
70 |
|
71 |
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 |
|
77 |
/**
|
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 |
|
88 |
public void setText(String string) { |
89 |
lblText.setText(string); |
90 |
} |
91 |
|
92 |
/**
|
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 |
|
118 |
/**
|
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 |
|
140 |
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 |
} |