View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package net.sf.magicproject.ui.wizard;
20  
21  import java.awt.Dimension;
22  import java.awt.event.ActionEvent;
23  
24  import javax.swing.BoxLayout;
25  import javax.swing.JLabel;
26  import javax.swing.JPanel;
27  import javax.swing.JScrollPane;
28  import javax.swing.JTextArea;
29  import javax.swing.JTextField;
30  import javax.swing.ScrollPaneConstants;
31  import javax.swing.WindowConstants;
32  
33  import net.sf.magicproject.mail.MailUtils;
34  import net.sf.magicproject.tools.Configuration;
35  import net.sf.magicproject.ui.UIHelper;
36  import net.sf.magicproject.ui.component.JLink;
37  import net.sf.magicproject.ui.i18n.LanguageManager;
38  
39  /***
40   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
41   * @since 0.82
42   */
43  public class Feature extends YesNo {
44  
45  	/***
46  	 * Creates a new instance of Bug <br>
47  	 */
48  	public Feature() {
49  		super(LanguageManager.getString("wiz_featurerequest.title"),
50  				LanguageManager.getString("wiz_featurerequest.description"),
51  				"wiz_featurerequest.png", LanguageManager.getString("send"),
52  				LanguageManager.getString("cancel"), 600, 400);
53  		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
54  		gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS));
55  
56  		JPanel userPanel = new JPanel();
57  		userPanel.setLayout(new BoxLayout(userPanel, BoxLayout.X_AXIS));
58  		userPanel.add(new JLabel(LanguageManager
59  				.getString("wiz_sf.sourceforgename")
60  				+ " : "));
61  		userNameTxt = new JTextField(Configuration.getString("sourceforgeName", ""));
62  		userPanel.add(userNameTxt);
63  		userPanel.setMaximumSize(new Dimension(2000, 22));
64  		JLink sfLabel = new JLink(
65  				"http://sourceforge.net/tracker/?func=add&group_id=92519&atid=601043",
66  				UIHelper.getIcon("sourceforge_logo.png"));
67  		userPanel.add(sfLabel);
68  		gameParamPanel.add(userPanel);
69  
70  		JPanel summaryPanel = new JPanel();
71  		summaryPanel.setLayout(new BoxLayout(summaryPanel, BoxLayout.X_AXIS));
72  		summaryPanel.add(new JLabel(LanguageManager.getString("wiz_sf.summary")
73  				+ " : "));
74  		subjectTxt = new JTextField();
75  		summaryPanel.add(subjectTxt);
76  		summaryPanel.setMaximumSize(new Dimension(2000, 22));
77  		gameParamPanel.add(summaryPanel);
78  
79  		messageTxt = new JTextArea();
80  		JScrollPane scroll = new JScrollPane(
81  				ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
82  				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
83  		scroll.setAutoscrolls(true);
84  		scroll.setViewportView(messageTxt);
85  		gameParamPanel.add(scroll);
86  
87  		getRootPane().setDefaultButton(null);
88  	}
89  
90  	@Override
91  	public void actionPerformed(ActionEvent event) {
92  		Object source = event.getSource();
93  		if (source == okBtn) {
94  			/*
95  			 * invoked when user wanna report a bug
96  			 */
97  			Configuration.setProperty("sourceforgeName", userNameTxt.getText());
98  			MailUtils.sendEmail("", "feature_request_form@magic-project.net",
99  					new String[] { "feature_request_jmagicproject@yahoo.fr" },
100 					"Username:" + userNameTxt.getText() + "\nSummary:"
101 							+ subjectTxt.getText() + "\n\n" + messageTxt.getText(), null,
102 					"[magic-project] " + subjectTxt.getText(), null, null,
103 					"feature_request", "mx4.mail.yahoo.com"); // "smtp.mail.yahoo.fr");
104 		}
105 		super.actionPerformed(event);
106 	}
107 
108 	/***
109 	 * Textfield containing sourceforge username
110 	 */
111 	private JTextField userNameTxt;
112 
113 	/***
114 	 * Textfield containing message
115 	 */
116 	private JTextArea messageTxt;
117 
118 	/***
119 	 * Textfield containing the summary of this report
120 	 */
121 	private JTextField subjectTxt;
122 }