Revision 2105

View differences:

org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterSwingLibrary.java
21 21
 */
22 22
package org.gvsig.raster.swing;
23 23

  
24
import java.awt.Component;
25
import java.util.List;
26

  
27
import javax.swing.JOptionPane;
28

  
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.i18n.Messages;
24 31
import org.gvsig.tools.library.AbstractLibrary;
25 32
import org.gvsig.tools.library.LibraryException;
26 33
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
34
import org.slf4j.LoggerFactory;
27 35

  
28 36
/**
29 37
 * Library for Swing API initialization and configuration.
......
49 57
                RasterSwingLocator.getInstance());
50 58
        }
51 59
    }
60
    
61
    public static boolean messageBoxYesOrNot(String msg, Object parentWindow){
62
		String string1 = PluginServices.getText(parentWindow, "yes");
63
		String string2 = PluginServices.getText(parentWindow, "no");
64
		Object[] options = {string1, string2};
65
		int n = JOptionPane.showOptionDialog((Component)parentWindow,
66
					"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>",
67
					Messages.getText("confirmacion"),
68
					JOptionPane.YES_NO_OPTION,
69
					JOptionPane.QUESTION_MESSAGE,
70
					null,
71
					options,
72
					string1);
73
		if (n == JOptionPane.YES_OPTION)
74
			return true;
75
		else
76
			return false;
77
	}
52 78

  
79
	public static void messageBoxError(String msg, Object parentWindow){
80
		String string = Messages.getText("accept");
81
		Object[] options = {string};
82
		JOptionPane.showOptionDialog((Component)parentWindow,
83
					"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>",
84
					Messages.getText("confirmacion"),
85
					JOptionPane.OK_OPTION,
86
					JOptionPane.ERROR_MESSAGE,
87
					null,
88
					options,
89
					string);
90
	}
91

  
92
	public static void messageBoxInfo(String msg, Object parentWindow){
93
		String string = PluginServices.getText(parentWindow, "accept");
94
		Object[] options = {string};
95
		JOptionPane.showOptionDialog((Component)parentWindow,
96
					"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>",
97
					Messages.getText("confirmacion"),
98
					JOptionPane.OK_OPTION,
99
					JOptionPane.INFORMATION_MESSAGE,
100
					null,
101
					options,
102
					string);
103
	}
104

  
105
	private static void debug(String msg, Object parent, Exception exception) {
106
		if(parent != null)
107
		    LoggerFactory
108
            .getLogger(parent.getClass()).debug(Messages.getText(msg), exception);
109
	}
110

  
111
	public static void messageBoxError(String msg, Object parentWindow, Exception exception) {
112
		debug(msg, parentWindow, exception);
113
		messageBoxError(msg, parentWindow);
114
	}
115
	
116
	public static void messageBoxError(String msg, Object parentWindow, List<Exception> exception) {
117
		for (int i = 0; i < exception.size(); i++) 
118
			debug(msg, parentWindow, exception.get(i));
119
		messageBoxError(msg, parentWindow);
120
	}
121

  
122
	public static void messageBoxInfo(String msg, Object parentWindow, Exception exception) {
123
		debug(msg, parentWindow, exception);
124
		messageBoxInfo(msg, parentWindow);
125
	}
126

  
127
	public static boolean messageBoxYesOrNot(String msg, Object parentWindow, Exception exception) {
128
		debug(msg, parentWindow, exception);
129
		return messageBoxYesOrNot(msg, parentWindow);
130
	}
131

  
53 132
}

Also available in: Unified diff