01: /*
02: * LicenseDlg.java
03: *
04: * Created on 15 February 2006, 17:07
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package xui.samples.carousel.components;
11:
12: import java.io.File;
13: import java.io.Reader;
14: import java.util.prefs.Preferences;
15: import net.xoetrope.swing.XDialog;
16:
17: /**
18: * Show the license dialog. The class provides a location for the getExtraText
19: * method which dynamically loads the page's content
20: * <p>Copyright: Xoetrope Ltd. (c) 2001-2006</p>
21: * <p>License: see license.txt</p>
22: * <p>$Revision: 1.6 $</p>
23: */
24: public class LicenseDlg extends XDialog {
25:
26: /** Creates a new instance of LicenseDlg */
27: public LicenseDlg() {
28: }
29:
30: /**
31: * Get the text for a popup from an extra file
32: * This method is called from an evaluated attribute in the page xml.
33: */
34: public String getExtraText(String fileName) {
35: // Localize the content by uncommenting the next few lines
36: // Preferences rsPrefs = Preferences.userNodeForPackage( Welcome.class );
37: // String defLangCode = rsPrefs.get( "defaultLanguage", "en" );
38: String filePath = /*defLangCode + File.separator +*/fileName
39: + ".html";
40: try {
41: Reader r = project.getBufferedReader(filePath);
42:
43: StringBuffer text = new StringBuffer();
44: int BUF_LEN = 1024;
45: int len = -1;
46: char buffer[] = new char[BUF_LEN];
47: while ((len = r.read(buffer, 0, BUF_LEN)) >= 0)
48: text.append(buffer, 0, BUF_LEN);
49: return text.toString();
50: } catch (Exception e) {
51: e.printStackTrace();
52: }
53:
54: // If we get this far
55: return translate("Missing resource");
56: }
57: }
|