View Javadoc

1   /*
2    * Created on 9 avr. 2005
3    * 
4    *   Magic-Project is a turn based strategy simulator
5    *   Copyright (C) 2003-2007 Fabrice Daugan
6    *
7    *   This program is free software; you can redistribute it and/or modify it 
8    * under the terms of the GNU General Public License as published by the Free 
9    * Software Foundation; either version 2 of the License, or (at your option) any
10   * later version.
11   *
12   *   This program is distributed in the hope that it will be useful, but WITHOUT 
13   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
15   * details.
16   *
17   *   You should have received a copy of the GNU General Public License along  
18   * with this program; if not, write to the Free Software Foundation, Inc., 
19   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   */
21  package net.sf.magicproject.deckbuilder;
22  
23  import java.io.BufferedReader;
24  import java.io.FileReader;
25  import java.io.IOException;
26  
27  import javax.swing.JFrame;
28  import javax.swing.JScrollPane;
29  import javax.swing.JTextArea;
30  
31  import net.sf.magicproject.tools.MToolKit;
32  import net.sf.magicproject.ui.i18n.LanguageManager;
33  import net.sf.magicproject.ui.wizard.Ok;
34  
35  import org.apache.commons.io.IOUtils;
36  
37  /***
38   * @author <a href="mailto:goldeneyemdk@users.sourceforge.net">Sebastien Genete
39   *         </a>
40   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
41   * @since 0.83
42   */
43  public class DeckRules extends Ok {
44  
45  	/***
46  	 * Create a new instance of DeckRules
47  	 * 
48  	 * @param parent
49  	 */
50  	public DeckRules(JFrame parent) {
51  		super(LanguageManager.getString("jdeckrules", MdbLoader.tbsFullName),
52  				LanguageManager.getString("jdeckrules.tooltip", MdbLoader.tbsFullName),
53  				"wiz_library_wiz.png", LanguageManager.getString("close"), 490, 300);
54  		// ... Set initial text, scrolling, and border.
55  		final JTextArea textRules = new JTextArea();
56  		textRules.setEditable(false);
57  		textRules.setLineWrap(true);
58  		textRules.setWrapStyleWord(true);
59  		textRules.setAutoscrolls(true);
60  		textRules.setTabSize(2);
61  		textRules.setText("No defined rules");
62  		BufferedReader inGPL = null;
63  		try {
64  			inGPL = new BufferedReader(new FileReader(MToolKit
65  					.getTbsFile("decks/DECK_CONSTRAINTS-"
66  							+ LanguageManager.getLanguage().getLocale() + "-lang.info")));
67  			textRules.read(inGPL, "Deck constraints");
68  		} catch (IOException e) {
69  			// Ignore this error
70  		} finally {
71  			IOUtils.closeQuietly(inGPL);
72  		}
73  
74  		final JScrollPane scrollingArea = new JScrollPane(textRules);
75  		gameParamPanel.add(scrollingArea);
76  		pack();
77  	}
78  }