Revision 41157

View differences:

tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
    <modelVersion>4.0.0</modelVersion>
5
    <artifactId>org.gvsig.desktop.framework</artifactId>
6
    <packaging>pom</packaging>
7
    <name>${project.artifactId}</name>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.desktop</artifactId>
11
        <version>2.0.25</version>
12
    </parent>
13

  
14
    <modules>
15
        <module>org.gvsig.andami</module>
16
        <module>org.gvsig.andami.updater</module>
17
    </modules>
18

  
19
    <description>Contains the launcher and plugin framework used in gvSIG.</description>
20
</project>
21

  
0 22

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/test/java/org/gvsig/andami/AllTests.java
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.andami;
25

  
26
import junit.framework.Test;
27
import junit.framework.TestSuite;
28

  
29
public class AllTests {
30

  
31
	public static Test suite() {
32
		TestSuite suite = new TestSuite("Test for com.iver.andami");
33
		//$JUnit-BEGIN$
34

  
35
		//$JUnit-END$
36
		return suite;
37
	}
38

  
39
}
0 40

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/assembly/gvsig-andami-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-andami-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>.</baseDirectory>
32
  <!-- 
33
  <includeBaseDirectory>true</includeBaseDirectory>
34
   -->
35
  <files>
36
    <file>
37
      <source>target/${project.artifactId}-${project.version}.jar</source>
38
      <outputDirectory>lib</outputDirectory>
39
    </file>
40
    <file>
41
      <source>src/main/resources/default-log4j/log4j.properties</source>
42
      <outputDirectory>.</outputDirectory>
43
    </file>  
44
  </files>
45
  <fileSets>
46
    <fileSet>
47
      <directory>src/main/resources-application</directory>
48
      <outputDirectory>.</outputDirectory>
49
    </fileSet>
50
  </fileSets>
51
  
52
  <dependencySets>
53
    <dependencySet>
54
      <useProjectArtifact>false</useProjectArtifact>
55
      <useTransitiveDependencies>true</useTransitiveDependencies>
56
      <outputDirectory>lib</outputDirectory>
57
    </dependencySet>
58
  </dependencySets>
59

  
60
</assembly>
61

  
0 62

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/GlassPane.java
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.andami.ui.mdiFrame;
25
import java.awt.Cursor;
26

  
27
import javax.swing.JPanel;
28
import javax.swing.event.MouseInputAdapter;
29

  
30
public class GlassPane extends JPanel {
31

  
32
	public GlassPane(){
33
		this.setOpaque(false);
34
		this.addMouseListener(new MouseInputAdapter(){});
35
		this.addMouseMotionListener(new MouseInputAdapter(){});
36
		this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
37
	}
38

  
39
	/**
40
	 * @see java.awt.Component#setCursor(java.awt.Cursor)
41
	 */
42
	public void setCursor(Cursor cursor) {
43
		super.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
44
	}
45

  
46
}
47

  
0 48

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JMenuItem.java
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.andami.ui.mdiFrame;
25

  
26
import javax.swing.Action;
27
import javax.swing.Icon;
28

  
29
public class JMenuItem extends javax.swing.JMenuItem implements EnableTextSupport{
30
	/**
31
	 * 
32
	 */
33
	public JMenuItem() {
34
		super();
35
		// TODO Auto-generated constructor stub
36
	}
37
	/**
38
	 * @param text
39
	 */
40
	public JMenuItem(String text) {
41
		super(text);
42
		// TODO Auto-generated constructor stub
43
	}
44
	/**
45
	 * @param text
46
	 * @param mnemonic
47
	 */
48
	public JMenuItem(String text, int mnemonic) {
49
		super(text, mnemonic);
50
		// TODO Auto-generated constructor stub
51
	}
52
	/**
53
	 * @param text
54
	 * @param icon
55
	 */
56
	public JMenuItem(String text, Icon icon) {
57
		super(text, icon);
58
		// TODO Auto-generated constructor stub
59
	}
60
	/**
61
	 * @param a
62
	 */
63
	public JMenuItem(Action a) {
64
		super(a);
65
		// TODO Auto-generated constructor stub
66
	}
67
	/**
68
	 * @param icon
69
	 */
70
	public JMenuItem(Icon icon) {
71
		super(icon);
72
		// TODO Auto-generated constructor stub
73
	}
74
	private String enableText;
75
	private String toolTip = super.getToolTipText();
76
	
77
	
78
	/**
79
	 * @return Returns the enableText.
80
	 */
81
	public String getEnableText() {
82
		return enableText;
83
	}
84
	/**
85
	 * @param enableText The enableText to set.
86
	 */
87
	public void setEnableText(String enableText) {
88
		this.enableText = enableText;
89
	}
90
	
91
	
92
	/**
93
	 * @see java.awt.Component#setVisible(boolean)
94
	 */
95
	public void setEnabled(boolean aFlag) {
96
		super.setEnabled(aFlag);
97
		if (aFlag){
98
			setToolTipText(toolTip);
99
		}else{
100
			setToolTipText(enableText);
101
		}
102
	}
103
	/**
104
	 * @see javax.swing.JComponent#setToolTipText(java.lang.String)
105
	 */
106
	public void setToolTip(String text) {
107
		toolTip = text;
108
	}
109
}
0 110

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/DefaultThreadSafeDialogs.java
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.andami.ui.mdiFrame;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Component;
28
import java.awt.Dimension;
29
import java.awt.GridBagConstraints;
30
import java.awt.event.ComponentEvent;
31
import java.awt.event.ComponentListener;
32
import java.io.File;
33
import java.lang.reflect.Constructor;
34

  
35
import javax.swing.JFileChooser;
36
import javax.swing.JOptionPane;
37
import javax.swing.JPanel;
38
import javax.swing.SwingUtilities;
39
import javax.swing.filechooser.FileFilter;
40

  
41
import org.gvsig.andami.PluginServices;
42
import org.gvsig.andami.ui.mdiManager.IWindow;
43
import org.gvsig.andami.ui.mdiManager.MDIManager;
44
import org.gvsig.andami.ui.mdiManager.WindowInfo;
45
import org.gvsig.tools.task.CancellableTask;
46
import org.gvsig.tools.task.RunnableWithParameters;
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
50
/**
51
 * Thread safe functions for showing dialogs
52
 * 
53
 * @author jjdelcerro
54
 * 
55
 */
56
public class DefaultThreadSafeDialogs implements ThreadSafeDialogs {
57

  
58
	private static Logger logger = LoggerFactory
59
			.getLogger(DefaultThreadSafeDialogs.class);
60
	private Component rootComponent;
61
	private NewStatusBar statusbar;
62

  
63
	public DefaultThreadSafeDialogs() {
64
		this.rootComponent = null;
65
		this.statusbar = null;
66
	}
67

  
68
	public DefaultThreadSafeDialogs(Component rootComponent,
69
			NewStatusBar statusbar) {
70
		this.statusbar = statusbar;
71
		this.rootComponent = rootComponent;
72
	}
73

  
74
	private Component getRootComponent() {
75
		if (this.rootComponent == null) {
76
			try {
77
				this.rootComponent = (MDIFrame) PluginServices.getMainFrame();
78
			} catch (Throwable t) {
79
				// Ignore and return null
80
			}
81
		}
82
		return this.rootComponent;
83
	}
84

  
85
	private NewStatusBar getStatusbar() {
86
		if (this.statusbar == null) {
87
			this.statusbar = PluginServices.getMainFrame().getStatusBar();
88
		}
89
		return this.statusbar;
90
	}
91

  
92
	private void message(String message, int messageType) {
93
		this.getStatusbar().message(message, messageType);
94
	}
95

  
96
	private String translate(String message) {
97
		return translate(message, null);
98
	}
99

  
100
	private String translate(String message, String[] args) {
101
		String msg = message;
102
		if (msg == null) {
103
			msg = "";
104
		}
105
		if (msg.startsWith("_")) {
106
			msg = org.gvsig.i18n.Messages.getText(msg, args);
107
			if (msg == null) {
108
				msg = "_" + message.replace("_", " ");
109
			}
110
		}
111
		return msg;
112
	}
113

  
114
	public int confirmDialog(final String message, final String title, final int optionType,
115
			final int messageType) {
116
		RunnableWithParameters runnable = new RunnableWithParameters() {
117
			public void run() {
118
				this.returnValue = JOptionPane.showConfirmDialog(
119
						getRootComponent(), message,title, optionType, messageType);
120
			}
121
		};
122
		if (SwingUtilities.isEventDispatchThread()) {
123
			runnable.run();
124
		} else {
125
			try {
126
				SwingUtilities.invokeAndWait(runnable);
127
			} catch (Exception e) {
128
				logger.info("Can't show input dialog '" + message + "'.", e);
129
			}
130
		}
131
		return (Integer) runnable.getReturnValue();
132
	}
133

  
134
	public String inputDialog(final String message, final String title, final int messageType,
135
			final String initialValue) {
136
		// inputDialog dlg = new inputDialog();
137
		// return dlg.show(translate(message), translate(title), messageType,
138
		// initialValue);
139
		//
140
		RunnableWithParameters runnable = new RunnableWithParameters() {
141
			public void run() {
142
				this.returnValue = JOptionPane.showInputDialog(
143
						getRootComponent(), translate(message),
144
						translate(title),
145
						messageType, null, null,
146
						initialValue);
147
			}
148
		};
149
		if (SwingUtilities.isEventDispatchThread()) {
150
			runnable.run();
151
		} else {
152
			try {
153
				SwingUtilities.invokeAndWait(runnable);
154
			} catch (Exception e) {
155
				logger.info("Can't show input dialog '" + message + "'.", e);
156
			}
157
		}
158
		return (String) runnable.getReturnValue();
159
	}
160

  
161
	public String inputDialog(final String message, final String title) {
162
		RunnableWithParameters runnable = new RunnableWithParameters() {
163
			public void run() {
164
				this.returnValue = JOptionPane.showInputDialog(
165
						getRootComponent(), (String) translate(message),
166
						translate(title),
167
						JOptionPane.QUESTION_MESSAGE, null, null, null);
168
			}
169
		};
170
		if (SwingUtilities.isEventDispatchThread()) {
171
			runnable.run();
172
		} else {
173
			try {
174
				SwingUtilities.invokeAndWait(runnable);
175
			} catch (Exception e) {
176
				logger.info("Can't show input dialog '" + message + "'.", e);
177
			}
178
		}
179
		return (String) runnable.getReturnValue();
180
	}
181

  
182
	public void messageDialog(String message, String title, int messageType) {
183
		messageDialog(message, null, title, messageType);
184
	}
185

  
186
	public void messageDialog(final String message, final String messageArgs[],
187
			final String title, final int messageType) {
188
		if (!SwingUtilities.isEventDispatchThread()) {
189
			try {
190
				SwingUtilities.invokeAndWait(new Runnable() {
191
					public void run() {
192
						messageDialog(message, messageArgs, title, messageType);
193
					}
194
				});
195
			} catch (Exception e) {
196
				logger.info("Can't show message dialog '" + message
197
						+ "'. redirect to status bar", e);
198
				this.message(message, messageType);
199
			}
200
			return;
201
		}
202

  
203
		if (message == null) {
204
			logger.info("message if null, message dialog not show.");
205
			return;
206
		}
207
		JOptionPane.showMessageDialog(getRootComponent(),
208
				translate(message, messageArgs), translate(title), messageType);
209
	}
210

  
211
	public void showDialog(final Component contents, final String title) {
212
		if (SwingUtilities.isEventDispatchThread()) {
213
			final DialogWindow window = new DialogWindow();
214
			window.setDialogFlag();
215
			window.setContents(contents, title);
216
			MDIManager manager = PluginServices.getMDIManager();
217
			manager.addWindow(window, GridBagConstraints.CENTER);
218
		} else {
219
			final DialogWindow window = new DialogWindow();
220
			SwingUtilities.invokeLater(new Runnable() {
221
				public void run() {
222
					window.setContents(contents, title);
223
					MDIManager manager = PluginServices.getMDIManager();
224
					manager.addWindow(window, GridBagConstraints.CENTER);
225
				}
226
			});
227
			try {
228
				synchronized (window) {
229
					if (contents instanceof CancellableTask) {
230
						while( contents.isVisible()  ) {
231
							if( ((CancellableTask)contents).isCancellationRequested() ) {
232
								SwingUtilities.invokeLater(new Runnable() {
233
									public void run() {
234
										contents.setVisible(false);
235
									}
236
								});
237
							}
238
							window.wait(10000);
239
						}
240
					} else {
241
						while( contents.isVisible() ) {
242
							window.wait();
243
						}
244
					}
245
				}
246
			} catch (InterruptedException e) {
247
				logger.info("showDialog can wait to close dialog.", e);
248
			}
249
		}
250
	}
251

  
252
	class DialogWindow extends JPanel implements IWindow, ComponentListener {
253

  
254
		/**
255
		 * 
256
		 */
257
		private static final long serialVersionUID = 6283975319620714565L;
258
		protected WindowInfo windowInfo;
259
		protected Object profile;
260
		protected Component contents;
261
		private int code = 0;
262

  
263
		public DialogWindow() {
264
			code = WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE
265
					| WindowInfo.ICONIFIABLE;
266
			profile = WindowInfo.DIALOG_PROFILE;
267
		}
268

  
269
		public void setDialogFlag() {
270
			code |= WindowInfo.MODALDIALOG;
271
		}
272

  
273
		public void setContents(Component contents, String title) {
274
			this.windowInfo = new WindowInfo(code);
275
			this.windowInfo.setTitle(title);
276

  
277
			this.contents = contents;
278

  
279
			Dimension size = this.contents.getPreferredSize();
280
			this.windowInfo.setHeight(size.height);
281
			this.windowInfo.setWidth(size.width);
282

  
283
			this.setLayout(new BorderLayout());
284
			this.add(this.contents, BorderLayout.CENTER);
285

  
286
			this.contents.addComponentListener(this);
287
		}
288

  
289
		public WindowInfo getWindowInfo() {
290
			return this.windowInfo;
291
		}
292

  
293
		public Object getWindowProfile() {
294
			return this.profile;
295
		}
296

  
297
		public void componentHidden(ComponentEvent arg0) {
298
			// Close window when hide contents panel.
299
			MDIManager manager = PluginServices.getMDIManager();
300
			manager.closeWindow(this);
301
			if ((code & WindowInfo.MODALDIALOG) == 0) {
302
				synchronized (this) {
303
					this.notifyAll();
304
				}
305
			}
306
		}
307

  
308
		public void componentMoved(ComponentEvent arg0) {
309
			// Do nothing
310
		}
311

  
312
		public void componentResized(ComponentEvent arg0) {
313
			// Do nothing
314
		}
315

  
316
		public void componentShown(ComponentEvent arg0) {
317
			// Do nothing
318
		}
319

  
320
	}
321

  
322
	public Component createComponent(final Class<? extends Component> theClass,
323
			final Object... parameters) {
324
		return createComponentWithParams(theClass, parameters);
325
	}
326

  
327
	public Component createComponentWithParams(
328
			final Class<? extends Component> theClass, final Object[] parameters) {
329
		final Class<?>[] parameterTypes = new Class<?>[parameters.length];
330
		for (int i = 0; i < parameters.length; i++) {
331
			parameterTypes[i] = parameters[i].getClass();
332
		}
333
		final Component component;
334
		final Constructor<?> constructor;
335
		try {
336
			constructor = theClass.getConstructor(parameterTypes);
337
		} catch (Exception e) {
338
			throw new IllegalArgumentException(e);
339
		}
340
		if (SwingUtilities.isEventDispatchThread()) {
341
			try {
342
				component = (Component) constructor.newInstance(parameters);
343
			} catch (Exception e) {
344
				throw new IllegalArgumentException(e);
345
			}
346
		} else {
347
			try {
348
				RunnableWithParameters runnable = new RunnableWithParameters(parameters) {
349
					public void run() {
350
						Constructor<?> cons = constructor;
351
						try {
352
							this.returnValue = cons.newInstance(parameters.toArray());
353
						} catch (Exception e) {
354
							String msg ="Can't create instance of components, constructor="+cons.toString()+", parameters="+this.parameters.toString()+"."; 
355
							logger.info(msg,e);
356
							throw new IllegalArgumentException(e);
357
						}
358
					}
359
				};
360
				SwingUtilities.invokeAndWait(runnable);
361
				component = (Component) runnable.getReturnValue();
362
			} catch (Exception e) {
363
				throw new IllegalArgumentException(e);
364
			}
365
		}
366
		return component;
367
	}
368

  
369
	public File[] showChooserDialog(
370
			final String title,
371
			final int type, // SAVE_DIALOG / OPEN_DIALOG
372
			final int selectionMode, //    JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES
373
			final boolean multiselection, 
374
			final File initialPath,
375
			final FileFilter filter,
376
			final boolean fileHidingEnabled
377
			) {
378
		RunnableWithParameters runnable = new RunnableWithParameters() {
379
			public void run() {
380
				JFileChooser fc = new JFileChooser();
381
				fc.setDialogTitle(title);
382
				fc.setDialogType(type);
383
				fc.setFileSelectionMode(selectionMode);
384
				fc.setMultiSelectionEnabled(multiselection);
385
				fc.setCurrentDirectory(initialPath);
386
				fc.setFileFilter(filter);
387
				fc.setFileHidingEnabled(fileHidingEnabled);
388
				int r = JFileChooser.CANCEL_OPTION;
389
				switch(type) {
390
				case JFileChooser.SAVE_DIALOG:
391
					r = fc.showSaveDialog(getRootComponent());
392
					break;
393
				case JFileChooser.OPEN_DIALOG:
394
				default:
395
					r = fc.showOpenDialog(getRootComponent());
396
					break;
397
				}
398
				if( r != JFileChooser.APPROVE_OPTION ) {
399
					this.returnValue = null;
400
					return;
401
				}
402
				if( fc.isMultiSelectionEnabled() ) {
403
					this.returnValue = fc.getSelectedFiles();
404
				} else {
405
					this.returnValue = new File[] { fc.getSelectedFile() };
406
				}
407
			}
408
		};
409
		if (SwingUtilities.isEventDispatchThread()) {
410
			runnable.run();
411
		} else {
412
			try {
413
				SwingUtilities.invokeAndWait(runnable);
414
			} catch (Exception e) {
415
				logger.info("Can't show chooser dialog '" + title + "'.", e);
416
			}
417
		}
418
		return (File[]) runnable.getReturnValue();
419
	}
420
	
421
	public File[] showOpenDirectoryDialog(String title, File initialPath) {
422
		return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.DIRECTORIES_ONLY, false, initialPath, null, false);
423
	}
424

  
425
	
426
	public File[] showOpenFileDialog(String title, File initialPath) {
427
		return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false);
428
	}
429

  
430
	
431
	public File[] showSaveFileDialog(String title, File initialPath) {
432
		return showChooserDialog(title, JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false);
433
	}
434

  
435
}
0 436

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/ToggleButtonModel.java
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.andami.ui.mdiFrame;
25

  
26
import javax.swing.ButtonGroup;
27

  
28
/**
29
 * @author Cesar Martinez Izquierdo <cesar.martinez@iver.es>
30
 */
31
public class ToggleButtonModel extends javax.swing.JToggleButton.ToggleButtonModel {
32
	
33
	private String _groupName = null;
34

  
35
	public ButtonGroup getGroup() {
36
		return group;
37
	}
38
	
39
	public String getGroupName() {
40
		return _groupName;
41
	}
42
	
43
	public void setGroupName(String groupName) {
44
		_groupName = groupName; 
45
	}
46

  
47
}
0 48

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MainFrame.java
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.andami.ui.mdiFrame;
25

  
26
import java.awt.Frame;
27
import java.awt.event.ActionListener;
28

  
29
import javax.swing.JComponent;
30
import javax.swing.JToolBar;
31

  
32
import org.gvsig.andami.actioninfo.ActionInfo;
33
import org.gvsig.andami.plugins.PluginClassLoader;
34
import org.gvsig.andami.plugins.config.generate.Label;
35
import org.gvsig.andami.plugins.config.generate.Menu;
36
import org.gvsig.gui.beans.controls.IControl;
37

  
38

  
39

  
40
/**
41
 * This interface represents the main application's window. It allow to access
42
 * the menus, the tool bars and the status bar. 
43
 */
44
public interface MainFrame extends ThreadSafeDialogs {
45
    
46
    public static final String MAIN_FRAME_POS = "MDIFramePos";
47
    public static final String MAIN_FRAME_SIZE = "MDIFrameSize";
48
    public static final String MAIN_FRAME_EXT_STATE = "MDIFrameState";
49
    
50
    public static final int[] MAIN_FRAME_POS_DEFAULT = { 0, 0 };
51
    public static final int[] MAIN_FRAME_SIZE_DEFAULT = { 1024, 768 };
52
    public static final int MAIN_FRAME_EXT_STATE_DEFAULT = Frame.MAXIMIZED_BOTH;
53

  
54
	/**
55
	 * Adds the provided menu to the menu bar.
56
	 *
57
	 * @param menu A Menu object containing the menu definition
58
	 * @param listener Object which receives the menu events
59
	 * @param loader ClassLoader of the plug-in that installs this menu
60
	 */
61
	public void addMenu(Menu menu, ActionListener listener,
62
		PluginClassLoader loader);
63

  
64
	public void addMenu(ActionInfo action, String text);
65

  
66
	public void addTool(final ActionInfo action, final String toolBarName);
67

  
68
	/**
69
	 * Changes the menu name, and thus also its location, as the name determines
70
	 * the location of the menu. 
71
	 *
72
	 * @param menu An array of Strings which represents the full menu path,
73
	 * for example, {"Vista", "export", "imagen"} is a reference to the menu
74
	 * "Vista/export/imagen" (that is, the menu Image within the submenu
75
	 * View-Export). Menu names are translation keys, "Vista", "export", etc will
76
	 * be translated to the suitable language when they are displayed.
77
	 * @param newName New menu's name, in the syntax "Vista/export/symbols". Each
78
	 * part of the name is a translation key.
79
	 * @param loader ClassLoader of the plug-in that added the menu
80
	 *
81
	 * @throws NoSuchMenuException If there is no menu matching the provided
82
	 * menu path
83
	 */
84
	public void changeMenuName(String[] menu, String newName,
85
		PluginClassLoader loader) throws NoSuchMenuException;
86

  
87
	/**
88
	 * Deletes the provided menu, if found.
89
	 *
90
	 * @param menu The menu to delete from the menu bar
91
	 */
92
	public void removeMenu(Menu menu);
93

  
94
	/**
95
	 * It checks whether each extension is enabled and visible, in order to
96
	 * enable/disable and show/hide their associated controls.
97
	 * 
98
	 * This method is thread safe.
99
	 * 
100
	 */
101
	public void enableControls();
102
	
103
	/**
104
	 * This method is thread safe.
105
	 * 
106
	 */
107
	public void refreshControls();
108

  
109
	/**
110
	 * Gets the status bar, the bar located in the bottom part of the main window.
111
	 * It can be used to show messages, show progress bars, or change the status.
112
	 *
113
	 * @return The main application's status bar.
114
	 */
115
	public NewStatusBar getStatusBar();
116

  
117
	/**
118
	 * Sets the main window title.
119
	 *
120
	 * This method is thread safe.
121
	 * 
122
	 * @param titulo The title to be set in the main window
123
	 */
124
	public void setTitle(String titulo);
125

  
126
    /**
127
     * Gets a previously added JComponent by name (including
128
     * tool bars, buttons from tool bars, status bar controls
129
     * and menus. For example
130
     * you can use it if you need to obtain an status bar
131
     * control or a JToolBar to
132
     * add some customized component
133
     * @param name
134
     * @return the JComponent or null if none has been found
135
     */
136
    public JComponent getComponentByName(String name);
137

  
138
    /**
139
     * Sets the tool associated to the provided actionComand
140
     * as the selected tool for the currently selected Andami window.
141
     */
142
    public void setSelectedTool(String actionCommand);
143
    
144
    /**
145
     * Gets an array containing all the toolbars.
146
     * 
147
     * @return An array containing all the toolbars.
148
     */
149
    public SelectableToolBar[] getToolbars();
150
    
151
    /**
152
     * Gets wheter or not this toolbar should be shown by Andami.
153
     * Note that this does not reflect the actual visibility
154
     * of the toolbar, because it also depends on other conditions
155
     * (the toolbar should contain at lest a currently visible button).
156
     * 
157
     * @param name The toolbar's name
158
     * @return
159
     */
160
    public boolean getToolbarVisibility(String name);
161
    
162
    /**
163
     * Sets wheter or not this toolbar should be shown by Andami.
164
     * This is useful if to hide some toolbars when they are not
165
     * going to be used.
166
     * If it's false, the toolbar will be
167
     * hidden even if its associated extensions are visible.
168
     * Note that setting visibility to true does not automatically
169
     * show the toolbar, because it also depends on other conditions
170
     * (the toolbar should contain at lest a currently visible button).
171
     * However, it allows the toolbar to be visible when necessary
172
     * conditions are fulfilled.
173
     * 
174
     * @param name The toolbar's name.
175
     * @param visibility
176
     * @return
177
     */
178
    public boolean setToolbarVisibility(String name, boolean visibility);
179

  
180
    /**
181
     * Gets the menu entry corresponding the provided menu path.
182
     * 
183
     * @param menuPath The menu path to the menu entry that we want to
184
     * retrieve. For example, if we want to retrieve the menu entry
185
     * corresponding to the XML menu "Layer/Export/Export_to_PDF" we
186
     * will provide an array containing ["Layer", "Export", "Export_to_PDF"].
187
     * 
188
     * @return The menu entry corresponding the provided menu path. Note that
189
     * the menu entry may be an instance of <code>javax.swing.JMenuItem</code>,
190
     * <code>javax.swing.JMenu</code> or
191
     * <code>com.iver.andami.ui.mdiFrame.JMenuItem</code>.
192
     */
193
    public javax.swing.JMenuItem getMenuEntry(String[] menuPath);
194
    
195
	/**
196
	 * Adds a control to the status bar and associate it with the
197
	 * provided extension. The control will be enabled and visible
198
	 * when the extension is enabled and visible.
199
	 * 
200
	 * @param extensionClass Extension which will determine whether the
201
	 * control is enabled and visible.
202
	 * @param control The control to add.
203
	 */
204
	public void addStatusBarControl(Class<?> extensionClass, IControl control);
205
	
206
	/**
207
	 * Removes the providedcontrol from the status bar.
208
	 * 
209
	 * @param name The name of the control to remove
210
	 */
211
	public void removeStatusBarControl(String name);
212
	
213
	/**
214
	 * Sets the provided label-set as the labels associated with the provided
215
	 * class. The labels will be visible in the status bar if the
216
	 * currently selected Andami window is an instance of the provided
217
	 * class.
218
	 * 
219
	 * @param clase The class which will be associated to the label-set. The
220
	 * labels will be visible if the currently selected Andami window is an
221
	 * instance of this class.
222
	 * 
223
	 * @param label An array of Labels. Each label has an ID which will be
224
	 * used to write text on them.
225
	 */
226
	public void setStatusBarLabels(Class<?> clase, Label[] label);
227

  
228
	/**
229
	 * Removes the labels associated with the provided class.
230
	 * 
231
	 * @param clase The class whose associated labels are to be removed.
232
	 */
233
	public void removeStatusBarLabels(Class<?> clase);
234
	
235
	public void addToolBarControl(Class<?> extensionClass, JToolBar control, String name);
236

  
237
	/**
238
	 * Show the message in the status bar of the application.
239
	 * 
240
	 * The types of messages are:
241
	 * 
242
	 * JOptionPane.INFORMATION_MESSAGE
243
	 * JOptionPane.WARNING_MESSAGE
244
	 * JOptionPane.ERROR_MESSAGE
245
	 * 
246
	 * This method is thread safe to use.
247
	 * 
248
	 * @param msg to show
249
	 * @param messageTyoe type of message.
250
	 */
251
	public void message(String msg, int messageTyoe);
252
	
253

  
254

  
255
}
0 256

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JPopUpMenu.java
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.andami.ui.mdiFrame;
25

  
26
import javax.swing.JPopupMenu;
27

  
28
public class JPopUpMenu extends JPopupMenu implements EnableTextSupport{
29
	private String enableText;
30
	private String toolTip = super.getToolTipText();
31
	
32
	
33
	/**
34
	 * @return Returns the enableText.
35
	 */
36
	public String getEnableText() {
37
		return enableText;
38
	}
39
	/**
40
	 * @param enableText The enableText to set.
41
	 */
42
	public void setEnableText(String enableText) {
43
		this.enableText = enableText;
44
	}
45
	
46
	
47
	/**
48
	 * @see java.awt.Component#setVisible(boolean)
49
	 */
50
	public void setEnabled(boolean aFlag) {
51
		super.setEnabled(aFlag);
52
		if (aFlag){
53
			setToolTipText(toolTip);
54
		}else{
55
			setToolTipText(enableText);
56
		}
57
	}
58
	/**
59
	 * @see javax.swing.JComponent#setToolTipText(java.lang.String)
60
	 */
61
	public void setToolTip(String text) {
62
		toolTip = text;
63
	}
64
	/**
65
	 * 
66
	 */
67
	public JPopUpMenu() {
68
		super();
69
		// TODO Auto-generated constructor stub
70
	}
71
	/**
72
	 * @param label
73
	 */
74
	public JPopUpMenu(String label) {
75
		super(label);
76
		// TODO Auto-generated constructor stub
77
	}
78
}
0 79

  
tags/org.gvsig.desktop-2.0.25/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/NewStatusBar.java
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.andami.ui.mdiFrame;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Component;
28
import java.awt.Dimension;
29
import java.awt.FlowLayout;
30
import java.awt.LayoutManager;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
33
import java.awt.event.MouseEvent;
34
import java.awt.event.MouseListener;
35
import java.util.HashMap;
36
import java.util.Map;
37

  
38
import javax.swing.BorderFactory;
39
import javax.swing.ImageIcon;
40
import javax.swing.JLabel;
41
import javax.swing.JOptionPane;
42
import javax.swing.JPanel;
43
import javax.swing.JPopupMenu;
44
import javax.swing.JProgressBar;
45
import javax.swing.SwingConstants;
46
import javax.swing.SwingUtilities;
47
import javax.swing.Timer;
48
import javax.swing.border.BevelBorder;
49

  
50
import org.gvsig.andami.IconThemeHelper;
51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.andami.messages.Messages;
53
import org.gvsig.andami.plugins.config.generate.Label;
54
import org.gvsig.gui.beans.controls.IControl;
55
import org.gvsig.tools.swing.api.ToolsSwingLocator;
56
import org.gvsig.tools.swing.api.task.JTasksStatus;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59

  
60
/**
61
 * <p>
62
 * This class contains the status bar. It contains the graphical component, and
63
 * the methods to manage it.
64
 * </p>
65
 * 
66
 * <p>
67
 * The status bar is divided in several areas. At the very left, there is an
68
 * icon and the main status text. There are three icons to show: Info, Warning
69
 * and Error icons. They can be set together with the main status text using the
70
 * methods <code>setInfoText()</code>, <code>setWarningText()</code> and
71
 * <code>setErrorText()</code> (and also with <code>setInfoTextTemporal()</code>
72
 * , etc). Then, there is a right area which contains labels and other controls.
73
 * Labels are set in the config.xml files and are visible or not depending on
74
 * the currently selected Andami window. Controls are associated to extensions,
75
 * and are enabled/disabled and visible/hidden depending on the associated
76
 * extension.
77
 * </p>
78
 * 
79
 */
80
public class NewStatusBar extends JPanel {
81

  
82
    private static final long serialVersionUID = 5575549032728844632L;
83
    
84
    private static Logger logger = LoggerFactory.getLogger(NewStatusBar.class);
85
    
86
    private static final int INFO = 0;
87
    private static final int WARNING = 1;
88
    private static final int ERROR = 2;
89
    private JLabel lblIcon = null;
90
    private JLabel lblTexto = null;
91
    private boolean contenidoTemporal;
92
    private String textoAnterior;
93
    private int estadoAnterior;
94
    private int estado;
95
    private JProgressBar progressBar = null;
96
    private Map<String, JLabel> idLabel = new HashMap<String, JLabel>();
97
    private int[] widthlabels = null;
98
    private Map<String, Component> controls = new HashMap<String, Component>();
99
    private JPanel controlContainer;
100
    private JTasksStatus tasksStatus = null;
101
	private Timer messageTimer;
102

  
103
	private String textoCompleto;
104

  
105
	
106
    /**
107
     * This is the default constructor
108
     */
109
    public NewStatusBar() {
110
        super();
111
        initialize();
112
    }
113

  
114
	private ImageIcon getImageIcon(String iconName) {
115
//		return PluginServices.getIconTheme().get(iconName);
116
		return IconThemeHelper.getImageIcon(iconName);
117
	}
118
	
119

  
120
    /**
121
     * This method initializes the status bar. It creates the required
122
     * containers and sets the layout.
123
     */
124
    private void initialize() {
125
        LayoutManager mainLayout = new BorderLayout();
126
        this.setLayout(mainLayout);
127

  
128
        JPanel panelRight = new JPanel(new FlowLayout(FlowLayout.RIGHT, 1, 0));
129

  
130
        controlContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT, 1, 0));
131
        panelRight.add(controlContainer);
132
        panelRight.add(getTasksStatus());
133

  
134
        lblIcon = new JLabel();
135
        lblTexto = new JLabel();
136
        lblTexto.setAlignmentX(JLabel.LEFT_ALIGNMENT);
137
        lblTexto.setHorizontalAlignment(SwingConstants.LEFT);
138
        lblTexto.setHorizontalTextPosition(SwingConstants.LEFT);
139
        lblTexto.setVerticalAlignment(SwingConstants.CENTER);
140
        lblTexto.setVerticalTextPosition(SwingConstants.CENTER);
141
        lblIcon.setText("");
142
        lblTexto.setText(Messages.getString("StatusBar.Aplicacion_iniciada"));
143

  
144
        JPanel panelLeft = new JPanel();
145
        panelLeft.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
146
        panelLeft.add(lblIcon);
147
        panelLeft.add(lblTexto);
148
        panelLeft.add(getProgressBar());
149

  
150
        this.add(panelLeft, BorderLayout.CENTER);
151
        this.add(panelRight, BorderLayout.EAST);
152

  
153
        buildMesagePopupMenu();
154
        
155
        messageTimer = new Timer(30000, new ActionListener() {
156
			public void actionPerformed(ActionEvent e) {
157
				try {
158
					clearMessage();
159
				} catch( Throwable ex) {
160
					logger.info("Can't clear message", ex);
161
				}
162
			}
163
		});
164
    }
165
    
166
    public void clearMessage() {
167
    	this.textoCompleto = "";
168
    	lblTexto.setText("");
169
    	lblIcon.setIcon(null);
170
    	estado = INFO;
171
    }
172

  
173
    
174
    public void message(final String msg, final int messageTyoe) {
175
        if (!SwingUtilities.isEventDispatchThread()) {
176
            SwingUtilities.invokeLater(new Runnable() {
177
                public void run() {
178
                	message(msg,messageTyoe);
179
                }
180
            });
181
            return;
182
        }
183
        messageTimer.stop();
184
    	switch (messageTyoe) {
185
		case JOptionPane.ERROR_MESSAGE:
186
			setErrorText(msg);
187
			break;
188
		case JOptionPane.WARNING_MESSAGE:
189
			setWarningText(msg);
190
			break;
191
		default:
192
		case JOptionPane.INFORMATION_MESSAGE:
193
			setInfoText(msg);
194
			break;
195
		}
196
    	this.doLayout();
197
    	this.repaint();
198
    	messageTimer.start();
199
	}
200

  
201
    private void buildMesagePopupMenu() {
202
    	final JPopupMenu menu = new JPopupMenu();
203
    	
204
    	JMenuItem item = new JMenuItem("View details");
205
    	item.addActionListener(new ActionListener() {
206
			public void actionPerformed(ActionEvent arg0) {
207
				switch (estado) {
208
				default:
209
				case INFO:
210
					JOptionPane.showMessageDialog(lblTexto, getStatusText(), "", JOptionPane.INFORMATION_MESSAGE);
211
					break;
212
				case WARNING:
213
					JOptionPane.showMessageDialog(lblTexto, getStatusText(), "", JOptionPane.WARNING_MESSAGE);
214
					break;
215
				case ERROR:
216
					JOptionPane.showMessageDialog(lblTexto, getStatusText(), "", JOptionPane.ERROR_MESSAGE);
217
					break;
218
				}
219
			}
220
		});
221
    	menu.add(item);
222
    	item = new JMenuItem("Clear");
223
    	item.addActionListener(new ActionListener() {
224
			public void actionPerformed(ActionEvent e) {
225
				clearMessage();
226
			}
227
		});
228
    	menu.add(item);
229
    	menu.addSeparator();
230
    	item = new JMenuItem("Cancel");
231
    	menu.add(item);
232
    	
233
    	this.lblTexto.addMouseListener( new MouseListener() {
234
			public void mouseReleased(MouseEvent e) {
235
				if( e.isPopupTrigger() ) {
236
					if( getStatusText().length() > 0 || estado!=INFO ) {
237
						menu.show(lblTexto, e.getX(), e.getY());
238
					}
239
				}
240
			}
241
			public void mousePressed(MouseEvent e) {
242
				if( e.isPopupTrigger() ) {
243
					if( getStatusText().length() > 0 || estado!=INFO ) {
244
						menu.show(lblTexto, e.getX(), e.getY());
245
					}
246
				}
247
			}
248
			public void mouseExited(MouseEvent e) {
249
			}
250
			public void mouseEntered(MouseEvent e) {
251
			}
252
			public void mouseClicked(MouseEvent e) {
253
			}
254
		});
255
    }
256
    
257
    /**
258
     * Gets the status bar main text.
259
     * 
260
     * @return The status bar main text.
261
     * @see #setInfoText(String)
262
     * @see #setWarningText(String)
263
     * @see #setErrorText(String)
264
     * @see #setInfoTextTemporal(String)
265
     * @see #setWarningTextTemporal(String)
266
     * @see #setErrorTextTemporal(String)
267
     */
268
    public String getStatusText() {
269
        return textoCompleto; //lblTexto.getText();
270
    }
271

  
272
    /**
273
     * Restores the previous contents in the status bar main text,
274
     * after the {@link #setInfoTextTemporal(String)},
275
     * {@link #setWarningTextTemporal(String)} or
276
     * {@link #setErrorTextTemporal(String)} have been called.
277
     * 
278
     * @see #setInfoTextTemporal(String)
279
     * @see #setWarningTextTemporal(String)
280
     * @see #setErrorTextTemporal(String)
281
     */
282
    public void restaurarTexto() {
283
        contenidoTemporal = false;
284

  
285
        if (estadoAnterior == -1) {
286
            return;
287
        }
288

  
289
        switch (estadoAnterior) {
290
        case INFO:
291
            setInfoText(textoAnterior);
292

  
293
            break;
294

  
295
        case WARNING:
296
            setWarningText(textoAnterior);
297

  
298
            break;
299

  
300
        case ERROR:
301
            setErrorText(textoAnterior);
302

  
303
            break;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff