Revision 33181
tags/v2_0_0_Build_2010/frameworks/_fwAndami/compile-classpath.xml | ||
---|---|---|
1 |
<project name="_fwAndami.compile-classpath" basedir="."> |
|
2 |
<!-- defines the classpath to be used for batch-compilation --> |
|
3 |
<property name="andami" location="../_fwAndami"/> |
|
4 |
<property name="andamiLibs" location="${andami}/lib"/> |
|
5 |
<path id="_fwAndami.compile-classpath"> |
|
6 |
<pathelement location="${andamiLibs}/beans.jar"/> |
|
7 |
<pathelement location="${andamiLibs}/castor-0.9.5.3-xml.jar"/> |
|
8 |
<pathelement location="${andamiLibs}/gvsig-i18n.jar"/> |
|
9 |
<pathelement location="${andamiLibs}/iver-utiles.jar"/> |
|
10 |
<pathelement location="${andamiLibs}/javaws.jar"/> |
|
11 |
<pathelement location="${andamiLibs}/JWizardComponent.jar"/> |
|
12 |
<pathelement location="${andamiLibs}/log4j-1.2.8.jar"/> |
|
13 |
<pathelement location="${andamiLibs}/tempFileManager.jar"/> |
|
14 |
<pathelement location="${andamiLibs}/xercesImpl.jar"/> |
|
15 |
<pathelement location="${andamiLibs}/xml-apis.jar"/> |
|
16 |
<pathelement location="${andamiLibs}/kxml2.jar"/> |
|
17 |
<pathelement location="${andamiLibs}/jcalendar.jar"/> |
|
18 |
</path> |
|
19 |
</project> |
|
0 | 20 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/theme/Theme.java | ||
---|---|---|
1 |
package org.gvsig.andami.ui.theme; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Point; |
|
5 |
import java.io.BufferedReader; |
|
6 |
import java.io.File; |
|
7 |
import java.io.FileInputStream; |
|
8 |
import java.io.FileNotFoundException; |
|
9 |
import java.io.FileReader; |
|
10 |
import java.io.IOException; |
|
11 |
import java.util.ArrayList; |
|
12 |
|
|
13 |
import javax.swing.ImageIcon; |
|
14 |
|
|
15 |
import org.gvsig.andami.Launcher; |
|
16 |
import org.gvsig.andami.PluginServices; |
|
17 |
import org.gvsig.andami.messages.NotificationManager; |
|
18 |
import org.kxml2.io.KXmlParser; |
|
19 |
import org.xmlpull.v1.XmlPullParser; |
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
/** |
|
24 |
* Personalization of the program according to the file xml with the necessary information. |
|
25 |
* |
|
26 |
* @author Vicente Caballero Navarro |
|
27 |
*/ |
|
28 |
public class Theme { |
|
29 |
public static final String CENTERED = "CENTERED"; |
|
30 |
public static final String EXPAND = "EXPAND"; |
|
31 |
public static final String MOSAIC = "MOSAIC"; |
|
32 |
|
|
33 |
private static String encoding = "UTF-8"; |
|
34 |
private static final String ANDAMI_PROPERTIES = "AndamiProperties"; |
|
35 |
private static final String APPLICATION_IMAGES = "ApplicationImages"; |
|
36 |
private static final String SPLASH_IMAGES = "SplashImages"; |
|
37 |
private static final String SPLASH = "Splash"; |
|
38 |
private static final String PATH = "path"; |
|
39 |
private static final String TIMER = "timer"; |
|
40 |
private static final String ICON = "Icon"; |
|
41 |
private static final String APPLICATION_NAME = "ApplicationName"; |
|
42 |
private static final String VALUE = "value"; |
|
43 |
private static final String BACKGROUND_IMAGE = "BackgroundImage"; |
|
44 |
private static final String WALLPAPER_TYPE = "WallpaperType"; |
|
45 |
|
|
46 |
private static final String VERSION="version"; |
|
47 |
private static final String FONTPOSITIONX="x"; |
|
48 |
private static final String FONTPOSITIONY="y"; |
|
49 |
|
|
50 |
private static final String FONTSIZE="fontsize"; |
|
51 |
private static final String FONTCOLOR="color"; |
|
52 |
|
|
53 |
private ArrayList<String> images = new ArrayList<String>(); |
|
54 |
private String icon; |
|
55 |
private ArrayList<String> timers = new ArrayList<String>(); |
|
56 |
private ArrayList<String> versions = new ArrayList<String>(); |
|
57 |
private ArrayList<String> fontColors = new ArrayList<String>(); |
|
58 |
private ArrayList<String> fontSizes = new ArrayList<String>(); |
|
59 |
private ArrayList<String> fontpositionsX=new ArrayList<String>(); |
|
60 |
private ArrayList<String> fontpositionsY=new ArrayList<String>(); |
|
61 |
|
|
62 |
private String name = null; |
|
63 |
private String backgroundimage; |
|
64 |
private String wallpaperType=CENTERED; |
|
65 |
|
|
66 |
public static void main(String[] args) { |
|
67 |
Theme theme = new Theme(); |
|
68 |
theme.readTheme(new File( |
|
69 |
"c:/workspace/_fwAndami/theme/andami-theme.xml")); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Read the file xml with the personalization. |
|
74 |
* |
|
75 |
* @param file xml |
|
76 |
*/ |
|
77 |
public void readTheme(File file) { |
|
78 |
try { |
|
79 |
FileReader fr; |
|
80 |
|
|
81 |
try { |
|
82 |
fr = new FileReader(file); |
|
83 |
|
|
84 |
BufferedReader br = new BufferedReader(fr); |
|
85 |
char[] buffer = new char[100]; |
|
86 |
br.read(buffer); |
|
87 |
|
|
88 |
StringBuffer st = new StringBuffer(new String(buffer)); |
|
89 |
String searchText = "encoding=\""; |
|
90 |
int index = st.indexOf(searchText); |
|
91 |
|
|
92 |
if (index > -1) { |
|
93 |
st.delete(0, index + searchText.length()); |
|
94 |
encoding = st.substring(0, st.indexOf("\"")); |
|
95 |
} |
|
96 |
} catch (FileNotFoundException ex) { |
|
97 |
ex.printStackTrace(); |
|
98 |
} catch (IOException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
} |
|
101 |
|
|
102 |
fr = new FileReader(file); |
|
103 |
|
|
104 |
KXmlParser parser = new KXmlParser(); |
|
105 |
parser.setInput(new FileInputStream(file), encoding); |
|
106 |
|
|
107 |
int tag = parser.nextTag(); |
|
108 |
|
|
109 |
if (parser.getEventType() != XmlPullParser.END_DOCUMENT) { |
|
110 |
parser.require(XmlPullParser.START_TAG, null, ANDAMI_PROPERTIES); |
|
111 |
|
|
112 |
while (tag != XmlPullParser.END_DOCUMENT) { |
|
113 |
//parser.next(); |
|
114 |
switch (tag) { |
|
115 |
case XmlPullParser.START_TAG: |
|
116 |
|
|
117 |
if (parser.getName().compareTo(ANDAMI_PROPERTIES) == 0) { |
|
118 |
parser.nextTag(); |
|
119 |
if (parser.getName().compareTo(APPLICATION_IMAGES) == 0) { |
|
120 |
int splashtag = parser.nextTag(); |
|
121 |
if (parser.getName().compareTo(SPLASH_IMAGES) == 0) { |
|
122 |
splashtag = parser.nextTag(); |
|
123 |
boolean endSplash = false; |
|
124 |
|
|
125 |
// parser.require(KXmlParser.START_TAG, |
|
126 |
// null, SPLASH); |
|
127 |
while ((splashtag != XmlPullParser.END_DOCUMENT) |
|
128 |
&& !endSplash) { |
|
129 |
if (splashtag == XmlPullParser.END_TAG) { |
|
130 |
splashtag = parser.nextTag(); |
|
131 |
|
|
132 |
continue; |
|
133 |
} |
|
134 |
|
|
135 |
if (parser.getName().compareTo(SPLASH) == 0) { |
|
136 |
images.add(fixPath(file, parser.getAttributeValue("", PATH))); |
|
137 |
timers.add(parser |
|
138 |
.getAttributeValue("", |
|
139 |
TIMER)); |
|
140 |
versions.add(parser |
|
141 |
.getAttributeValue("", |
|
142 |
VERSION)); |
|
143 |
fontpositionsX.add(parser |
|
144 |
.getAttributeValue("", |
|
145 |
FONTPOSITIONX)); |
|
146 |
fontpositionsY.add(parser |
|
147 |
.getAttributeValue("", |
|
148 |
FONTPOSITIONY)); |
|
149 |
fontSizes.add(parser |
|
150 |
.getAttributeValue("", |
|
151 |
FONTSIZE)); |
|
152 |
fontColors.add(parser |
|
153 |
.getAttributeValue("", |
|
154 |
FONTCOLOR)); |
|
155 |
|
|
156 |
splashtag = parser.nextTag(); |
|
157 |
} else { |
|
158 |
endSplash = true; |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
int tagOptions = XmlPullParser.START_TAG; |
|
163 |
while ((tagOptions != XmlPullParser.END_TAG)) { |
|
164 |
if (parser.getName().compareTo( |
|
165 |
BACKGROUND_IMAGE) == 0) { |
|
166 |
backgroundimage = fixPath(file, parser.getAttributeValue("", PATH)); |
|
167 |
tag = parser.next(); |
|
168 |
} else if (parser.getName().compareTo(ICON) == 0) { |
|
169 |
icon = fixPath(file, parser.getAttributeValue("",PATH)); |
|
170 |
tag = parser.next(); |
|
171 |
} else if (parser.getName().compareTo( |
|
172 |
WALLPAPER_TYPE) == 0) { |
|
173 |
wallpaperType = parser.getAttributeValue( |
|
174 |
"", VALUE); |
|
175 |
tag = parser.next(); |
|
176 |
} |
|
177 |
tagOptions = parser.nextTag(); |
|
178 |
|
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
if (parser.getName().compareTo(APPLICATION_NAME) == 0) { |
|
183 |
name = parser.getAttributeValue("", |
|
184 |
VALUE); |
|
185 |
tag = parser.next(); |
|
186 |
} |
|
187 |
break; |
|
188 |
|
|
189 |
case XmlPullParser.END_TAG: |
|
190 |
break; |
|
191 |
|
|
192 |
case XmlPullParser.TEXT: |
|
193 |
|
|
194 |
// System.out.println("[TEXT]["+kxmlParser.getText()+"]"); |
|
195 |
break; |
|
196 |
} |
|
197 |
|
|
198 |
tag = parser.next(); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
parser.require(XmlPullParser.END_DOCUMENT, null, null); |
|
203 |
|
|
204 |
// } |
|
205 |
} catch (Exception e) { |
|
206 |
NotificationManager.addError("Error reading theme: "+file.getAbsolutePath(), e); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
private String fixPath(File theme, String path) { |
|
211 |
path = path.replace("$GVSIG_INSTALL",Launcher.getApplicationDirectory()); |
|
212 |
path = path.replace("$GVSIG_HOME", Launcher.getAppHomeDir()); |
|
213 |
path = path.replace("$GVSIG_PLUGINS", Launcher.getAndamiConfig().getPluginsDirectory()); |
|
214 |
File parent = theme.getParentFile().getAbsoluteFile(); |
|
215 |
File fpath = new File(path); |
|
216 |
if( ! fpath.isAbsolute() ) { |
|
217 |
fpath = new File(parent,path); |
|
218 |
} |
|
219 |
return fpath.getAbsolutePath(); |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* Returns image to the splashwindow. |
|
224 |
* |
|
225 |
* @return ImageIcon[] |
|
226 |
*/ |
|
227 |
public ImageIcon[] getSplashImages() { |
|
228 |
ImageIcon[] imgs = new ImageIcon[images.size()]; |
|
229 |
|
|
230 |
for (int i = 0; i < images.size(); i++) { |
|
231 |
imgs[i] = new ImageIcon(images.get(i)); |
|
232 |
} |
|
233 |
|
|
234 |
return imgs; |
|
235 |
} |
|
236 |
|
|
237 |
public String getTypeDesktop() { |
|
238 |
return wallpaperType; |
|
239 |
} |
|
240 |
/** |
|
241 |
* Return the icon. |
|
242 |
* |
|
243 |
* @return ImageIcon |
|
244 |
*/ |
|
245 |
public ImageIcon getIcon() { |
|
246 |
if (icon == null) { |
|
247 |
return null; |
|
248 |
} |
|
249 |
|
|
250 |
try { |
|
251 |
return new ImageIcon(icon); |
|
252 |
} catch (Exception e) { |
|
253 |
return null; |
|
254 |
} |
|
255 |
} |
|
256 |
/** |
|
257 |
* Return the backgroundimage. |
|
258 |
* |
|
259 |
* @return ImageIcon |
|
260 |
*/ |
|
261 |
public ImageIcon getBackgroundImage() { |
|
262 |
if (backgroundimage == null) { |
|
263 |
return null; |
|
264 |
} |
|
265 |
|
|
266 |
try { |
|
267 |
return new ImageIcon(backgroundimage); |
|
268 |
} catch (Exception e) { |
|
269 |
return null; |
|
270 |
} |
|
271 |
} |
|
272 |
/** |
|
273 |
* Return the time of the splash images. |
|
274 |
* |
|
275 |
* @return long[] |
|
276 |
*/ |
|
277 |
public long[] getTimers() { |
|
278 |
long[] tms = new long[timers.size()]; |
|
279 |
|
|
280 |
for (int i = 0; i < tms.length; i++) { |
|
281 |
tms[i] = Long.parseLong(timers.get(i)); |
|
282 |
} |
|
283 |
|
|
284 |
return tms; |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* Return the name of program. |
|
289 |
* |
|
290 |
* @return String |
|
291 |
*/ |
|
292 |
public String getName() { |
|
293 |
return name; |
|
294 |
} |
|
295 |
/** |
|
296 |
* Return the text to overwrite the images. |
|
297 |
* |
|
298 |
* @return String[] |
|
299 |
*/ |
|
300 |
public String[] getVersions() { |
|
301 |
return versions.toArray(new String[0]); |
|
302 |
} |
|
303 |
/** |
|
304 |
* Return the position of text to overwrite the images. |
|
305 |
* |
|
306 |
* @return Point[] |
|
307 |
*/ |
|
308 |
public Point[] getPositions() { |
|
309 |
Point[] points=new Point[fontpositionsX.size()]; |
|
310 |
for (int i=0;i<points.length;i++) { |
|
311 |
try { |
|
312 |
points[i]=new Point(Integer.valueOf(fontpositionsX.get(i)),Integer.valueOf(fontpositionsY.get(i))); |
|
313 |
}catch (NumberFormatException e) { |
|
314 |
NotificationManager.addInfo(PluginServices.getText(this,"incorrect_position"),e); |
|
315 |
} |
|
316 |
} |
|
317 |
return points; |
|
318 |
} |
|
319 |
/** |
|
320 |
* Return the font size text to overwrite the images. |
|
321 |
* |
|
322 |
* @return int[] |
|
323 |
*/ |
|
324 |
public int[] getFontSizes() { |
|
325 |
int[] sizes=new int[fontSizes.size()]; |
|
326 |
for (int i=0;i<sizes.length;i++) { |
|
327 |
try { |
|
328 |
sizes[i]=Integer.valueOf(fontSizes.get(i)); |
|
329 |
}catch (NumberFormatException e) { |
|
330 |
NotificationManager.addInfo(PluginServices.getText(this,"incorrect_size"),e); |
|
331 |
} |
|
332 |
} |
|
333 |
return sizes; |
|
334 |
} |
|
335 |
/** |
|
336 |
* Return the font color of text to overwrite the images. |
|
337 |
* |
|
338 |
* @return Color[] |
|
339 |
*/ |
|
340 |
public Color[] getFontColors() { |
|
341 |
Color[] colors=new Color[fontColors.size()]; |
|
342 |
for (int i=0;i<colors.length;i++) { |
|
343 |
try { |
|
344 |
String s=fontColors.get(i); |
|
345 |
String[] rgb=s.split(","); |
|
346 |
colors[i]=new Color(Integer.valueOf(rgb[0]),Integer.valueOf(rgb[1]),Integer.valueOf(rgb[2])); |
|
347 |
}catch (Exception e) { |
|
348 |
NotificationManager.addInfo(PluginServices.getText(this,"incorrect_color"),e); |
|
349 |
} |
|
350 |
} |
|
351 |
return colors; |
|
352 |
} |
|
353 |
} |
|
0 | 354 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/MDIManagerLoadException.java | ||
---|---|---|
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.andami.ui; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
*/ |
|
46 |
public class MDIManagerLoadException extends Exception{ |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
*/ |
|
51 |
public MDIManagerLoadException() { |
|
52 |
super(); |
|
53 |
// TODO Auto-generated constructor stub |
|
54 |
} |
|
55 |
/** |
|
56 |
* @param message |
|
57 |
*/ |
|
58 |
public MDIManagerLoadException(String message) { |
|
59 |
super(message); |
|
60 |
// TODO Auto-generated constructor stub |
|
61 |
} |
|
62 |
/** |
|
63 |
* @param message |
|
64 |
* @param cause |
|
65 |
*/ |
|
66 |
public MDIManagerLoadException(String message, Throwable cause) { |
|
67 |
super(message, cause); |
|
68 |
// TODO Auto-generated constructor stub |
|
69 |
} |
|
70 |
/** |
|
71 |
* @param cause |
|
72 |
*/ |
|
73 |
public MDIManagerLoadException(Throwable cause) { |
|
74 |
super(cause); |
|
75 |
// TODO Auto-generated constructor stub |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/JPopUpMenu.java | ||
---|---|---|
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.andami.ui.mdiFrame; |
|
42 |
|
|
43 |
import javax.swing.JPopupMenu; |
|
44 |
|
|
45 |
public class JPopUpMenu extends JPopupMenu implements EnableTextSupport{ |
|
46 |
private String enableText; |
|
47 |
private String toolTip = super.getToolTipText(); |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* @return Returns the enableText. |
|
52 |
*/ |
|
53 |
public String getEnableText() { |
|
54 |
return enableText; |
|
55 |
} |
|
56 |
/** |
|
57 |
* @param enableText The enableText to set. |
|
58 |
*/ |
|
59 |
public void setEnableText(String enableText) { |
|
60 |
this.enableText = enableText; |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
/** |
|
65 |
* @see java.awt.Component#setVisible(boolean) |
|
66 |
*/ |
|
67 |
public void setEnabled(boolean aFlag) { |
|
68 |
super.setEnabled(aFlag); |
|
69 |
if (aFlag){ |
|
70 |
setToolTipText(toolTip); |
|
71 |
}else{ |
|
72 |
setToolTipText(enableText); |
|
73 |
} |
|
74 |
} |
|
75 |
/** |
|
76 |
* @see javax.swing.JComponent#setToolTipText(java.lang.String) |
|
77 |
*/ |
|
78 |
public void setToolTip(String text) { |
|
79 |
toolTip = text; |
|
80 |
} |
|
81 |
/** |
|
82 |
* |
|
83 |
*/ |
|
84 |
public JPopUpMenu() { |
|
85 |
super(); |
|
86 |
// TODO Auto-generated constructor stub |
|
87 |
} |
|
88 |
/** |
|
89 |
* @param label |
|
90 |
*/ |
|
91 |
public JPopUpMenu(String label) { |
|
92 |
super(label); |
|
93 |
// TODO Auto-generated constructor stub |
|
94 |
} |
|
95 |
} |
|
0 | 96 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/NewStatusBar.java | ||
---|---|---|
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.andami.ui.mdiFrame; |
|
42 |
|
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.Component; |
|
45 |
import java.awt.Dimension; |
|
46 |
import java.awt.FlowLayout; |
|
47 |
import java.util.HashMap; |
|
48 |
|
|
49 |
import javax.swing.BorderFactory; |
|
50 |
import javax.swing.ImageIcon; |
|
51 |
import javax.swing.JLabel; |
|
52 |
import javax.swing.JPanel; |
|
53 |
import javax.swing.JProgressBar; |
|
54 |
import javax.swing.SwingConstants; |
|
55 |
import javax.swing.border.BevelBorder; |
|
56 |
|
|
57 |
import org.apache.log4j.Logger; |
|
58 |
import org.gvsig.andami.PluginServices; |
|
59 |
import org.gvsig.andami.messages.Messages; |
|
60 |
import org.gvsig.andami.plugins.config.generate.Label; |
|
61 |
import org.gvsig.gui.beans.controls.IControl; |
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* <p>This class contains the status bar. It contains the graphical component, |
|
67 |
* and the methods to manage it. |
|
68 |
* </p> |
|
69 |
* |
|
70 |
* <p>The status bar is divided in several areas. At the very left, there is |
|
71 |
* an icon and the main status text. There are three icons to show: |
|
72 |
* Info, Warning and Error icons. They can be set together with the main |
|
73 |
* status text using the methods <code>setInfoText()</code>, |
|
74 |
* <code>setWarningText()</code> and <code>setErrorText()</code> (and also with |
|
75 |
* <code>setInfoTextTemporal()</code>, etc). Then, there is a right area which |
|
76 |
* contains labels and other controls. Labels are set in the config.xml files |
|
77 |
* and are visible or not depending on the currently selected Andami window. |
|
78 |
* Controls are associated to extensions, and are enabled/disabled and |
|
79 |
* visible/hidden depending on the associated extension. |
|
80 |
* </p> |
|
81 |
* |
|
82 |
*/ |
|
83 |
public class NewStatusBar extends JPanel { |
|
84 |
private static Logger logger = Logger.getLogger(NewStatusBar.class.getName()); |
|
85 |
private static final int INFO = 0; |
|
86 |
private static final int WARNING = 1; |
|
87 |
private static final int ERROR = 2; |
|
88 |
private JLabel lblIcon = null; |
|
89 |
private JLabel lblTexto = null; |
|
90 |
private boolean contenidoTemporal; |
|
91 |
private String textoAnterior; |
|
92 |
private int estadoAnterior; |
|
93 |
private ImageIcon infoIcon; |
|
94 |
private ImageIcon warningIcon; |
|
95 |
private ImageIcon errorIcon; |
|
96 |
private int estado; |
|
97 |
private JProgressBar progressBar = null; |
|
98 |
private HashMap idLabel = new HashMap(); |
|
99 |
private int[] widthlabels = null; |
|
100 |
private HashMap controls = new HashMap(); |
|
101 |
private JPanel controlContainer; |
|
102 |
/** |
|
103 |
* This is the default constructor |
|
104 |
*/ |
|
105 |
public NewStatusBar() { |
|
106 |
super(); |
|
107 |
initialize(); |
|
108 |
infoIcon = PluginServices.getIconTheme().get("info-icon"); |
|
109 |
warningIcon = PluginServices.getIconTheme().get("warning-icon"); |
|
110 |
errorIcon = PluginServices.getIconTheme().get("error-icon"); |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* This method initializes the status bar. It creates the required |
|
116 |
* containers and sets the layout. |
|
117 |
*/ |
|
118 |
private void initialize() { |
|
119 |
BorderLayout mainLayout = new BorderLayout(); |
|
120 |
this.setLayout(mainLayout); |
|
121 |
|
|
122 |
JPanel container1 = new JPanel(); |
|
123 |
this.add(container1, BorderLayout.CENTER); |
|
124 |
controlContainer = new JPanel(); |
|
125 |
this.add(controlContainer, BorderLayout.EAST); |
|
126 |
|
|
127 |
this.setPreferredSize(new java.awt.Dimension(183,20)); |
|
128 |
this.setSize(new java.awt.Dimension(183,20)); |
|
129 |
lblIcon = new JLabel(); |
|
130 |
lblTexto = new JLabel(); |
|
131 |
lblTexto.setAlignmentX(JLabel.LEFT_ALIGNMENT); |
|
132 |
lblTexto.setHorizontalAlignment(SwingConstants.LEFT); |
|
133 |
lblTexto.setHorizontalTextPosition(SwingConstants.LEFT); |
|
134 |
|
|
135 |
FlowLayout rightLayout = new FlowLayout(); |
|
136 |
controlContainer.setLayout(rightLayout); |
|
137 |
rightLayout.setHgap(1); |
|
138 |
rightLayout.setVgap(2); |
|
139 |
rightLayout.setAlignment(java.awt.FlowLayout.RIGHT); |
|
140 |
lblIcon.setText(""); |
|
141 |
lblTexto.setText(Messages.getString("StatusBar.Aplicacion_iniciada")); |
|
142 |
|
|
143 |
FlowLayout leftLayout = new FlowLayout(FlowLayout.LEFT); |
|
144 |
leftLayout.setHgap(1); |
|
145 |
leftLayout.setVgap(2); |
|
146 |
container1.setLayout(leftLayout); |
|
147 |
container1.add(lblIcon, null); |
|
148 |
container1.add(getProgressBar(), null); |
|
149 |
container1.add(lblTexto, null); |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Gets the status bar main text. |
|
154 |
* |
|
155 |
* @return The status bar main text. |
|
156 |
* @see #setInfoText(String) |
|
157 |
* @see #setWarningText(String) |
|
158 |
* @see #setErrorText(String) |
|
159 |
* @see #setInfoTextTemporal(String) |
|
160 |
* @see #setWarningTextTemporal(String) |
|
161 |
* @see #setErrorTextTemporal(String) |
|
162 |
*/ |
|
163 |
public String getStatusText() { |
|
164 |
return lblTexto.getText(); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Restores the previous contents in the status bar main text, |
|
169 |
* after the {@link #setInfoTextTemporal(String)}, {@link #setWarningTextTemporal(String)} |
|
170 |
* or {@link #setErrorTextTemporal(String)} have been called. |
|
171 |
* |
|
172 |
* @see #setInfoTextTemporal(String) |
|
173 |
* @see #setWarningTextTemporal(String) |
|
174 |
* @see #setErrorTextTemporal(String) |
|
175 |
*/ |
|
176 |
public void restaurarTexto() { |
|
177 |
contenidoTemporal = false; |
|
178 |
|
|
179 |
if (estadoAnterior == -1) { |
|
180 |
return; |
|
181 |
} |
|
182 |
|
|
183 |
switch (estadoAnterior) { |
|
184 |
case INFO: |
|
185 |
setInfoText(textoAnterior); |
|
186 |
|
|
187 |
break; |
|
188 |
|
|
189 |
case WARNING: |
|
190 |
setWarningText(textoAnterior); |
|
191 |
|
|
192 |
break; |
|
193 |
|
|
194 |
case ERROR: |
|
195 |
setErrorText(textoAnterior); |
|
196 |
|
|
197 |
break; |
|
198 |
} |
|
199 |
|
|
200 |
estadoAnterior = -1; |
|
201 |
textoAnterior = null; |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* Sets a temporary information message in the status bar, and changes the |
|
206 |
* icon to an Info icon. The previous text and icon can be restored using |
|
207 |
* the {@link #restaurarTexto()} method. |
|
208 |
* |
|
209 |
* @param texto The text to set |
|
210 |
* @see #restaurarTexto() |
|
211 |
*/ |
|
212 |
public void setInfoTextTemporal(String texto) { |
|
213 |
if (!contenidoTemporal) { |
|
214 |
textoAnterior = getStatusText(); |
|
215 |
estadoAnterior = this.estado; |
|
216 |
contenidoTemporal = true; |
|
217 |
} |
|
218 |
|
|
219 |
this.estado = INFO; |
|
220 |
lblIcon.setIcon(infoIcon); |
|
221 |
lblTexto.setText(texto); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* Sets a temporary warning message in the status bar, and changes the |
|
226 |
* icon to a Warning icon. The previous text and icon can be restored using |
|
227 |
* the {@link #restaurarTexto()} method. |
|
228 |
* |
|
229 |
* @param texto The text to set |
|
230 |
* @see #restaurarTexto() |
|
231 |
*/ |
|
232 |
public void setWarningTextTemporal(String texto) { |
|
233 |
if (!contenidoTemporal) { |
|
234 |
estadoAnterior = this.estado; |
|
235 |
textoAnterior = getStatusText(); |
|
236 |
contenidoTemporal = true; |
|
237 |
} |
|
238 |
this.estado = WARNING; |
|
239 |
lblIcon.setIcon(warningIcon); |
|
240 |
lblTexto.setText(texto); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* Sets a temporary error message in the status bar, and changes the |
|
245 |
* icon to an Error icon. The previous text and icon can be restored using |
|
246 |
* the {@link #restaurarTexto()} method. |
|
247 |
* |
|
248 |
* @param texto The text to set |
|
249 |
* @see #restaurarTexto() |
|
250 |
*/ |
|
251 |
public void setErrorTextTemporal(String texto) { |
|
252 |
if (!contenidoTemporal) { |
|
253 |
estadoAnterior = this.estado; |
|
254 |
textoAnterior = getStatusText(); |
|
255 |
contenidoTemporal = true; |
|
256 |
} |
|
257 |
|
|
258 |
this.estado = ERROR; |
|
259 |
lblIcon.setIcon(errorIcon); |
|
260 |
lblTexto.setText(texto); |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* Sets a permanent info message in the status bar, and changes the |
|
265 |
* permanent icon to an Info icon. If there is a temporary message showing |
|
266 |
* at the moment, the message set now is not shown until |
|
267 |
* the {@link #restaurarTexto()} method is called. |
|
268 |
* |
|
269 |
* @param texto The permanent info message to set |
|
270 |
* @see #restaurarTexto() |
|
271 |
*/ |
|
272 |
public void setInfoText(String texto) { |
|
273 |
if (contenidoTemporal) { |
|
274 |
textoAnterior = texto; |
|
275 |
estadoAnterior = INFO; |
|
276 |
} else { |
|
277 |
lblTexto.setText(texto); |
|
278 |
lblIcon.setIcon(infoIcon); |
|
279 |
estado = INFO; |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Sets a permanent warning message in the status bar, and changes the |
|
285 |
* permanent icon to a Warning icon. If there is a temporary message showing |
|
286 |
* at the moment, the message set now is not shown until |
|
287 |
* the {@link #restaurarTexto()} method is called. |
|
288 |
* |
|
289 |
* @param texto The permanent warning message to set |
|
290 |
* @see #restaurarTexto() |
|
291 |
*/ |
|
292 |
public void setWarningText(String texto) { |
|
293 |
if (contenidoTemporal) { |
|
294 |
textoAnterior = texto; |
|
295 |
estadoAnterior = WARNING; |
|
296 |
} else { |
|
297 |
lblTexto.setText(texto); |
|
298 |
lblIcon.setIcon(warningIcon); |
|
299 |
estado = WARNING; |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* Sets a permanent error message in the status bar, and changes the |
|
305 |
* permanent icon to an Error icon. If there is a temporary message showing |
|
306 |
* at the moment, the message set now is not shown until |
|
307 |
* the {@link #restaurarTexto()} method is called. |
|
308 |
* |
|
309 |
* @param texto The permanent info message to set |
|
310 |
* @see #restaurarTexto() |
|
311 |
*/ |
|
312 |
public void setErrorText(String texto) { |
|
313 |
if (contenidoTemporal) { |
|
314 |
textoAnterior = texto; |
|
315 |
estadoAnterior = ERROR; |
|
316 |
} else { |
|
317 |
lblTexto.setText(texto); |
|
318 |
lblIcon.setIcon(errorIcon); |
|
319 |
estado = ERROR; |
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* If <code>p</code> is a value between 0 and 99, it shows a progress bar |
|
325 |
* in the left area of the status bar, and sets the specified progress. |
|
326 |
* If <code>p</code> is bigger than 99, it hides the progress bar. |
|
327 |
* |
|
328 |
* @param p The progress to set in the progress bar. If it is bigger |
|
329 |
* than 99, the task will be considered to be finished, and the |
|
330 |
* progress bar will be hidden. |
|
331 |
*/ |
|
332 |
public void setProgress(int p) { |
|
333 |
if (p < 100) { |
|
334 |
getProgressBar().setValue(p); |
|
335 |
getProgressBar().setVisible(true); |
|
336 |
} else { |
|
337 |
getProgressBar().setVisible(false); |
|
338 |
} |
|
339 |
|
|
340 |
getProgressBar().repaint(); |
|
341 |
} |
|
342 |
|
|
343 |
/** |
|
344 |
* Sets a label-set to be shown in the status bar. This method it is not |
|
345 |
* intended to be used directly, because the set will be overwritten when the selected |
|
346 |
* window changes. Use {@link MainFrame#setStatusBarLabels(Class, Label[])} |
|
347 |
* to permanently associate a label set with a window. |
|
348 |
* |
|
349 |
* @param labels The labels to set. |
|
350 |
* @see MainFrame#setStatusBarLabels(Class, Label[]) |
|
351 |
*/ |
|
352 |
public void setLabelSet(Label[] labels) { |
|
353 |
removeAllLabels(); |
|
354 |
idLabel.clear(); |
|
355 |
|
|
356 |
for (int i = 0; i < labels.length; i++) { |
|
357 |
JLabel lbl = new JLabel(); |
|
358 |
lbl.setPreferredSize(new Dimension(labels[i].getSize(), |
|
359 |
this.getHeight() - 2)); |
|
360 |
lbl.setSize(new Dimension(labels[i].getSize(), this.getHeight() - 2)); |
|
361 |
lbl.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
|
362 |
lbl.setName(labels[i].getId()); |
|
363 |
controlContainer.add(lbl); |
|
364 |
|
|
365 |
/* if (i != labels.length - 1){ |
|
366 |
this.add(new JSeparator(JSeparator.VERTICAL)); |
|
367 |
} |
|
368 |
*/ |
|
369 |
idLabel.put(labels[i].getId(), lbl); |
|
370 |
} |
|
371 |
|
|
372 |
JLabel[] configlabels = (JLabel[]) idLabel.values().toArray(new JLabel[0]); |
|
373 |
widthlabels = new int[configlabels.length]; |
|
374 |
|
|
375 |
for (int i = 0; i < labels.length; i++) { |
|
376 |
widthlabels[i] = configlabels[i].getWidth(); |
|
377 |
} |
|
378 |
|
|
379 |
this.repaint(); |
|
380 |
} |
|
381 |
|
|
382 |
/** |
|
383 |
* Hides the empty labels and adjust the space in the bar. |
|
384 |
*/ |
|
385 |
public void ajustar() { |
|
386 |
if (widthlabels == null) { |
|
387 |
return; |
|
388 |
} |
|
389 |
|
|
390 |
int ws = this.getWidth(); |
|
391 |
|
|
392 |
JLabel[] labels = (JLabel[]) idLabel.values().toArray(new JLabel[0]); |
|
393 |
|
|
394 |
/* double total = 1; |
|
395 |
for (int i = 0; i < widthlabels.length; i++) { |
|
396 |
if (labels[i].getText().compareTo("") != 0) { |
|
397 |
total += widthlabels[i]; |
|
398 |
} |
|
399 |
} |
|
400 |
double p = (ws - lblTexto.getWidth() - 20) / total; |
|
401 |
*/ |
|
402 |
for (int i = 0; i < labels.length; i++) { |
|
403 |
//if (labels[i] instanceof JLabel){ |
|
404 |
JLabel label = (JLabel) labels[i]; |
|
405 |
|
|
406 |
if (label.getText().compareTo("") != 0) { |
|
407 |
label.setVisible(true); |
|
408 |
label.setPreferredSize(new Dimension((int) (widthlabels[i]), |
|
409 |
this.getHeight() - 2)); |
|
410 |
} else { |
|
411 |
label.setVisible(false); |
|
412 |
|
|
413 |
//label.setPreferredSize(new Dimension(0,this.getHeight())); |
|
414 |
} |
|
415 |
|
|
416 |
//} |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
/** |
|
421 |
* Removes all the labels from the status bar. It does not remove the |
|
422 |
* controls. |
|
423 |
*/ |
|
424 |
private void removeAllLabels() { |
|
425 |
Component[] controlArray = controlContainer.getComponents(); |
|
426 |
|
|
427 |
for (int i = 0; i < controlArray.length; i++) { |
|
428 |
if ((controlArray[i] != lblIcon) && (controlArray[i] != lblTexto) && !(controlArray[i] instanceof IControl) && (controlArray[i] instanceof JLabel)) { |
|
429 |
controlContainer.remove(controlArray[i]); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
|
|
435 |
/** |
|
436 |
* Removes all the controls (including labels) from the status bar. |
|
437 |
*/ |
|
438 |
private void removeAllControls() { |
|
439 |
Component[] controlArray = controlContainer.getComponents(); |
|
440 |
|
|
441 |
for (int i = 0; i < controlArray.length; i++) { |
|
442 |
if ((controlArray[i] != lblIcon) && (controlArray[i] != lblTexto)) { |
|
443 |
controlContainer.remove(controlArray[i]); |
|
444 |
} |
|
445 |
} |
|
446 |
} |
|
447 |
|
|
448 |
/** |
|
449 |
* Sets the text of the provided label. |
|
450 |
* |
|
451 |
* @param id The ID of the label to modify. It is defined in the |
|
452 |
* config.xml file |
|
453 |
* @param msg The message to show in the label |
|
454 |
*/ |
|
455 |
public void setMessage(String id, String msg) { |
|
456 |
JLabel lbl = (JLabel) idLabel.get(id); |
|
457 |
|
|
458 |
if (lbl!=null) { |
|
459 |
lbl.setText(msg); |
|
460 |
} |
|
461 |
else { |
|
462 |
// try with controls |
|
463 |
try { |
|
464 |
IControl control = (IControl) controls.get(id); |
|
465 |
if (control!=null) |
|
466 |
control.setValue(msg); |
|
467 |
} |
|
468 |
catch (ClassCastException ex) { |
|
469 |
logger.debug("no label called " + id); |
|
470 |
} |
|
471 |
} |
|
472 |
|
|
473 |
ajustar(); |
|
474 |
} |
|
475 |
|
|
476 |
/** |
|
477 |
* Sets the control identified by 'id' with the provided value. |
|
478 |
* |
|
479 |
* @param id The ID of the control to modify |
|
480 |
* @param value The value to set in the control |
|
481 |
*/ |
|
482 |
public void setControlValue(String id, String value) { |
|
483 |
IControl control = (IControl) controls.get(id); |
|
484 |
if (control!=null) { |
|
485 |
control.setValue(value); |
|
486 |
} |
|
487 |
else { |
|
488 |
logger.debug("NewStatusBar -- no control called " + id); |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
492 |
/** |
|
493 |
* This method initializes the progressBar and gets it. |
|
494 |
* |
|
495 |
* @return javax.swing.JProgressBar |
|
496 |
*/ |
|
497 |
private JProgressBar getProgressBar() { |
|
498 |
if (progressBar == null) { |
|
499 |
progressBar = new JProgressBar(); |
|
500 |
progressBar.setPreferredSize(new java.awt.Dimension(100, 14)); |
|
501 |
progressBar.setVisible(false); |
|
502 |
progressBar.setMinimum(0); |
|
503 |
progressBar.setMaximum(100); |
|
504 |
progressBar.setValue(50); |
|
505 |
} |
|
506 |
|
|
507 |
return progressBar; |
|
508 |
} |
|
509 |
|
|
510 |
/** |
|
511 |
* Sets the width of the main message label. |
|
512 |
* |
|
513 |
* @param d The width ob the main label |
|
514 |
* @deprecated |
|
515 |
*/ |
|
516 |
public void setFixedLabelWidth(double d) { |
|
517 |
lblTexto.setPreferredSize(new Dimension((int) d, lblTexto.getHeight())); |
|
518 |
} |
|
519 |
|
|
520 |
/** |
|
521 |
* Adds a control to the status bar |
|
522 |
* |
|
523 |
* @param id The ID of the control, useful to later retrive it or set its value |
|
524 |
* @param control The control to add |
|
525 |
*/ |
|
526 |
public void addControl(String id, Component control) { |
|
527 |
if (!controls.containsKey(control.getName())) { |
|
528 |
controls.put(control.getName(), control); |
|
529 |
controlContainer.add(control); |
|
530 |
} |
|
531 |
else { |
|
532 |
logger.debug("NewStatusBar.addControl -- control 'id' already exists"+ id); |
|
533 |
} |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* Remove a control from the status bar |
|
538 |
* |
|
539 |
* @param id The ID of the control to get |
|
540 |
*/ |
|
541 |
public Component removeControl(String id) { |
|
542 |
try { |
|
543 |
Component component = (Component) controls.get(id); |
|
544 |
controlContainer.remove(component); |
|
545 |
controls.remove(id); |
|
546 |
return component; |
|
547 |
} |
|
548 |
catch (ClassCastException ex) { |
|
549 |
logger.debug("NewStatusBar.removeControl -- control "+id+"doesn't exist"); |
|
550 |
} |
|
551 |
return null; |
|
552 |
} |
|
553 |
|
|
554 |
/** |
|
555 |
* Gets a control from the status bar |
|
556 |
* |
|
557 |
* @param id The ID of the control to get |
|
558 |
*/ |
|
559 |
public Component getControl(String id) { |
|
560 |
return (Component) controls.get(id); |
|
561 |
} |
|
562 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
0 | 563 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/NoSuchMenuException.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 07-feb-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
21 |
USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
|
33 |
* www.gvsig.gva.es |
|
34 |
* |
|
35 |
* or |
|
36 |
* |
|
37 |
* IVER T.I. S.A |
|
38 |
* Salamanca 50 |
|
39 |
* 46005 Valencia |
|
40 |
* Spain |
|
41 |
* |
|
42 |
* +34 963163400 |
|
43 |
* dac@iver.es |
|
44 |
*/ |
|
45 |
package org.gvsig.andami.ui.mdiFrame; |
|
46 |
|
|
47 |
|
|
48 |
public class NoSuchMenuException extends RuntimeException { |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
*/ |
|
53 |
public NoSuchMenuException() { |
|
54 |
super(); |
|
55 |
|
|
56 |
} |
|
57 |
/** |
|
58 |
* @param message |
|
59 |
*/ |
|
60 |
public NoSuchMenuException(String message) { |
|
61 |
super(message); |
|
62 |
|
|
63 |
} |
|
64 |
/** |
|
65 |
* @param message |
|
66 |
* @param cause |
|
67 |
*/ |
|
68 |
public NoSuchMenuException(String message, Throwable cause) { |
|
69 |
super(message, cause); |
|
70 |
|
|
71 |
} |
|
72 |
/** |
|
73 |
* @param cause |
|
74 |
*/ |
|
75 |
public NoSuchMenuException(Throwable cause) { |
|
76 |
super(cause); |
|
77 |
|
|
78 |
} |
|
79 |
} |
|
0 | 80 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/KeyMapping.java | ||
---|---|---|
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.andami.ui.mdiFrame; |
|
42 |
|
|
43 |
import java.awt.event.KeyEvent; |
|
44 |
import java.util.HashMap; |
|
45 |
|
|
46 |
import org.gvsig.andami.messages.Messages; |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* Clase que sirve para obtener los codigos de las teclas de la manera que las |
|
52 |
* requieren los JMenu a partir de un caracter que representa dicha tecla |
|
53 |
* |
|
54 |
* @author Fernando Gonz?lez Cort?s |
|
55 |
*/ |
|
56 |
public class KeyMapping { |
|
57 |
/** Asocia caracteres con KeyEvents */ |
|
58 |
private static HashMap key = new HashMap(); |
|
59 |
|
|
60 |
static { |
|
61 |
key.put(new Character('a'), new Integer(KeyEvent.VK_A)); |
|
62 |
key.put(new Character('b'), new Integer(KeyEvent.VK_B)); |
|
63 |
key.put(new Character('c'), new Integer(KeyEvent.VK_C)); |
|
64 |
key.put(new Character('d'), new Integer(KeyEvent.VK_D)); |
|
65 |
key.put(new Character('e'), new Integer(KeyEvent.VK_E)); |
|
66 |
key.put(new Character('f'), new Integer(KeyEvent.VK_F)); |
|
67 |
key.put(new Character('g'), new Integer(KeyEvent.VK_G)); |
|
68 |
key.put(new Character('h'), new Integer(KeyEvent.VK_H)); |
|
69 |
key.put(new Character('i'), new Integer(KeyEvent.VK_I)); |
|
70 |
key.put(new Character('j'), new Integer(KeyEvent.VK_J)); |
|
71 |
key.put(new Character('k'), new Integer(KeyEvent.VK_K)); |
|
72 |
key.put(new Character('l'), new Integer(KeyEvent.VK_L)); |
|
73 |
key.put(new Character('m'), new Integer(KeyEvent.VK_M)); |
|
74 |
key.put(new Character('n'), new Integer(KeyEvent.VK_N)); |
|
75 |
key.put(new Character('o'), new Integer(KeyEvent.VK_O)); |
|
76 |
key.put(new Character('p'), new Integer(KeyEvent.VK_P)); |
|
77 |
key.put(new Character('q'), new Integer(KeyEvent.VK_Q)); |
|
78 |
key.put(new Character('r'), new Integer(KeyEvent.VK_R)); |
|
79 |
key.put(new Character('s'), new Integer(KeyEvent.VK_S)); |
|
80 |
key.put(new Character('t'), new Integer(KeyEvent.VK_T)); |
|
81 |
key.put(new Character('u'), new Integer(KeyEvent.VK_U)); |
|
82 |
key.put(new Character('v'), new Integer(KeyEvent.VK_V)); |
|
83 |
key.put(new Character('w'), new Integer(KeyEvent.VK_W)); |
|
84 |
key.put(new Character('x'), new Integer(KeyEvent.VK_X)); |
|
85 |
key.put(new Character('y'), new Integer(KeyEvent.VK_Y)); |
|
86 |
key.put(new Character('z'), new Integer(KeyEvent.VK_Z)); |
|
87 |
key.put(new Character('0'), new Integer(KeyEvent.VK_0)); |
|
88 |
key.put(new Character('1'), new Integer(KeyEvent.VK_1)); |
|
89 |
key.put(new Character('2'), new Integer(KeyEvent.VK_2)); |
|
90 |
key.put(new Character('3'), new Integer(KeyEvent.VK_3)); |
|
91 |
key.put(new Character('4'), new Integer(KeyEvent.VK_4)); |
|
92 |
key.put(new Character('5'), new Integer(KeyEvent.VK_5)); |
|
93 |
key.put(new Character('6'), new Integer(KeyEvent.VK_6)); |
|
94 |
key.put(new Character('7'), new Integer(KeyEvent.VK_7)); |
|
95 |
key.put(new Character('8'), new Integer(KeyEvent.VK_8)); |
|
96 |
key.put(new Character('9'), new Integer(KeyEvent.VK_9)); |
|
97 |
key.put(new Character('+'), new Integer(KeyEvent.VK_PLUS)); |
|
98 |
key.put(new Character('-'), new Integer(KeyEvent.VK_MINUS)); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Obtiene dado un caracter el entero correspondiente al codigo que tiene |
|
103 |
* la tecla que produce dicho caracter |
|
104 |
* |
|
105 |
* @param a caracter |
|
106 |
* |
|
107 |
* @return Codigo de la tecla asociada |
|
108 |
* |
|
109 |
* @throws RuntimeException Si el caracter no tiene una tecla asociada |
|
110 |
*/ |
|
111 |
public static int getKey(char a) { |
|
112 |
Integer ret = (Integer) key.get(new Character(a)); |
|
113 |
|
|
114 |
if (ret == null) { |
|
115 |
throw new RuntimeException(Messages.getString( |
|
116 |
"KeyMapping.Caracter_no_valido") + a); //$NON-NLS-1$ |
|
117 |
} |
|
118 |
|
|
119 |
return ret.intValue(); |
|
120 |
} |
|
121 |
} |
|
0 | 122 |
tags/v2_0_0_Build_2010/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/MDIFrame.java | ||
---|---|---|
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.andami.ui.mdiFrame; |
|
42 |
|
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.Component; |
|
45 |
import java.awt.Dimension; |
|
46 |
import java.awt.FlowLayout; |
|
47 |
import java.awt.Insets; |
|
48 |
import java.awt.Toolkit; |
|
49 |
import java.awt.event.ActionEvent; |
|
50 |
import java.awt.event.ActionListener; |
|
51 |
import java.awt.event.ComponentEvent; |
|
52 |
import java.awt.event.ComponentListener; |
|
53 |
import java.awt.event.ContainerEvent; |
|
54 |
import java.awt.event.ContainerListener; |
|
55 |
import java.awt.event.MouseAdapter; |
|
56 |
import java.awt.event.MouseEvent; |
|
57 |
import java.awt.event.WindowAdapter; |
|
58 |
import java.awt.event.WindowEvent; |
|
59 |
import java.util.ArrayList; |
|
60 |
import java.util.Enumeration; |
|
61 |
import java.util.HashMap; |
|
62 |
import java.util.Iterator; |
|
63 |
import java.util.NoSuchElementException; |
|
64 |
import java.util.StringTokenizer; |
|
65 |
import java.util.Vector; |
|
66 |
|
|
67 |
import javax.swing.AbstractButton; |
|
68 |
import javax.swing.ButtonGroup; |
|
69 |
import javax.swing.ImageIcon; |
|
70 |
import javax.swing.JComponent; |
|
71 |
import javax.swing.JFrame; |
|
72 |
import javax.swing.JMenu; |
|
73 |
import javax.swing.JMenuBar; |
|
74 |
import javax.swing.JPanel; |
|
75 |
import javax.swing.JPopupMenu; |
|
76 |
import javax.swing.JSeparator; |
|
77 |
import javax.swing.KeyStroke; |
|
78 |
import javax.swing.MenuElement; |
|
79 |
import javax.swing.SwingUtilities; |
|
80 |
import javax.swing.Timer; |
|
81 |
|
|
82 |
import org.apache.log4j.Logger; |
|
83 |
import org.gvsig.andami.Launcher; |
|
84 |
import org.gvsig.andami.PluginServices; |
|
85 |
import org.gvsig.andami.messages.Messages; |
|
86 |
import org.gvsig.andami.messages.NotificationManager; |
|
87 |
import org.gvsig.andami.plugins.ExtensionDecorator; |
|
88 |
import org.gvsig.andami.plugins.PluginClassLoader; |
|
89 |
import org.gvsig.andami.plugins.config.generate.ActionTool; |
|
90 |
import org.gvsig.andami.plugins.config.generate.Label; |
|
91 |
import org.gvsig.andami.plugins.config.generate.Menu; |
|
92 |
import org.gvsig.andami.plugins.config.generate.PopupMenu; |
|
93 |
import org.gvsig.andami.plugins.config.generate.SelectableTool; |
|
94 |
import org.gvsig.andami.plugins.config.generate.SkinExtensionType; |
|
95 |
import org.gvsig.andami.plugins.config.generate.ToolBar; |
|
96 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
|
97 |
import org.gvsig.andami.ui.mdiManager.MDIManagerFactory; |
|
98 |
import org.gvsig.gui.beans.controls.IControl; |
|
99 |
|
|
100 |
|
Also available in: Unified diff