File: no-github

package info (click to toggle)
plm 2.9.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,008 kB
  • sloc: java: 33,607; ansic: 4,069; python: 2,558; xml: 230; perl: 106; makefile: 63; sh: 17; javascript: 14
file content (300 lines) | stat: -rw-r--r-- 12,730 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
The Java interface to the GitHub API is not packaged yet, so disable
this set of features for now.

---
 src/plm/core/ui/FeedbackDialog.java |  249 ------------------------------------
 src/plm/core/ui/MainFrame.java      |   13 -
 2 files changed, 1 insertion(+), 261 deletions(-)

Index: b/src/plm/core/ui/MainFrame.java
===================================================================
--- a/src/plm/core/ui/MainFrame.java
+++ b/src/plm/core/ui/MainFrame.java
@@ -91,7 +91,7 @@ public class MainFrame extends JFrame im
 
     private JMenu menuLanguage, menuLangHuman, menuLangProg;
     private JMenu menuHelp;
-    private JMenuItem miHelpFeedback, miHelpLesson,miHelpWorld,miHelpMission,miHelpAbout;
+    private JMenuItem miHelpLesson,miHelpWorld,miHelpMission,miHelpAbout;
         
 	private LoggerPanel outputArea;
 	private MissionEditorTabs met;
@@ -339,16 +339,6 @@ public class MainFrame extends JFrame im
 		menuHelp = new JMenu(i18n.tr("Help"));
 		menuHelp.setMnemonic(KeyEvent.VK_H);
 		menuBar.add(menuHelp);
-
-		miHelpFeedback = new JMenuItem(new AbstractGameAction(g, i18n.tr("Provide feedback")) {
-			private static final long serialVersionUID = 1L;
-
-			public void actionPerformed(ActionEvent arg0) {
-				FeedbackDialog.getInstance().setVisible(true);
-			}			
-		});
-		miHelpFeedback.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, ActionEvent.CTRL_MASK));
-		menuHelp.add(miHelpFeedback);
 		
 		miHelpLesson = new JMenuItem(new AbstractGameAction(g, i18n.tr("About this lesson")) {
 			private static final long serialVersionUID = 1L;
@@ -730,7 +720,6 @@ public class MainFrame extends JFrame im
 		menuLangProg.setText(i18n.tr("Computer"));
 		
 		menuHelp.setText(i18n.tr("Help"));
-		miHelpFeedback.setText(i18n.tr("Provide feedback"));
 		miHelpLesson.setText(i18n.tr("About this lesson"));
 		miHelpWorld.setText(i18n.tr("About this world"));
 		if (miHelpAbout != null)
Index: b/src/plm/core/ui/FeedbackDialog.java
===================================================================
--- a/src/plm/core/ui/FeedbackDialog.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package plm.core.ui;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Label;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.Desktop;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JEditorPane;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-
-import org.eclipse.egit.github.core.Issue;
-import org.eclipse.egit.github.core.client.GitHubClient;
-import org.eclipse.egit.github.core.service.IssueService;
-import org.xnap.commons.i18n.I18n;
-import org.xnap.commons.i18n.I18nFactory;
-
-import plm.core.model.Game;
-import plm.core.model.lesson.Exercise;
-import plm.core.model.lesson.Lecture;
-import plm.core.model.lesson.Exercise.WorldKind;
-import plm.core.model.tracking.GitUtils;
-import plm.universe.World;
-
-public class FeedbackDialog extends JDialog {
-
-	private static final long serialVersionUID = 0;
-	private static FeedbackDialog instance = null;
-	private static String defaultTitle = "";
-	private static String defaultText = "";	
-	
-	public I18n i18n = I18nFactory.getI18n(getClass(), "org.plm.i18n.Messages", getLocale(), I18nFactory.FALLBACK);
-	public String errorMsg;
-	final JEditorPane feedback = new JEditorPane();
-	final JTextField title = new JTextField();
-	
-	public static FeedbackDialog getInstance() {
-		if (FeedbackDialog.instance == null) {
-			FeedbackDialog.instance = new FeedbackDialog();
-		}
-		StringBuffer worldInfo = new StringBuffer();
-		for (World w:((Exercise)Game.getInstance().getCurrentLesson().getCurrentExercise()).getWorlds(WorldKind.ANSWER)) {
-			String s = w.getDebugInfo();
-			if (s != "") 
-				worldInfo.append("World: "+s+"\n");
-		}
-
-		defaultTitle = FeedbackDialog.instance.i18n.tr("Please describe the problem in a few words");
-		defaultText = FeedbackDialog.instance.i18n.tr(
-				  "Your suggestion comes here, with all necessary details.\n\n\n\n\n\n"
-				+ "(The following helps us fixing your problem, please don't erase)\n\n"
-	            + "--------------------[ Technical Information ]--------------------\n"); /* The rest is not translated */
-		
-		Lecture exo = Game.getInstance().getCurrentLesson().getCurrentExercise();
-		String proposedExo = "";
-		if (exo instanceof Exercise)
-			proposedExo = "\n"+FeedbackDialog.instance.i18n.tr("--------------------[ my code for this exercise ]--------------------\n")
-			    + ((Exercise)exo).getSourceFile(Game.getProgrammingLanguage(), 0).getBody();
-
-		FeedbackDialog.instance.feedback.setText(defaultText
-				+ "Lesson: "+Game.getInstance().getCurrentLesson().getId() + "\n"
-				+ "Exercise: "+Game.getInstance().getCurrentLesson().getCurrentExercise().getId() + "\n"
-				+ worldInfo.toString()
-				+ "Programming Language: "+Game.getProgrammingLanguage().getLang() + "\n"
-				+ "Locale: "+Game.getInstance().getLocale().getDisplayName() + "\n"
-				+ "Java version: " + System.getProperty("java.version") + " (VM: " + System.getProperty("java.vm.name") + "; version: " + System.getProperty("java.vm.version") + ")" + "\n"
-				+ "OS: " + System.getProperty("os.name") + " (version: " + System.getProperty("os.version") + "; arch: " + System.getProperty("os.arch") + ")" + "\n"
-				+ "PLM version: " + Game.getProperty("plm.major.version", "internal", false) + " (" + Game.getProperty("plm.minor.version", "internal", false) + ")" + "\n"
-				+ "Public user ID: PLM"+GitUtils.sha1(Game.getInstance().getUsers().getCurrentUser().getUserUUIDasString())+ "\n"
-				+ proposedExo);
-		
-		
-		FeedbackDialog.instance.title.setText(defaultTitle);
-		FeedbackDialog.instance.pack();
-		return FeedbackDialog.instance;
-	}
-
-	private FeedbackDialog() {
-		super(MainFrame.getInstance(), "Report your feedback", false);
-		this.setTitle(i18n.tr("Report your feedback"));
-		initComponent();
-	}
-
-	public void initComponent() {
-
-		setLayout(new BorderLayout());
-		JPanel headerToolbar = new JPanel();
-		headerToolbar.add(new Label(i18n.tr("Issue title:")));
-		headerToolbar.add(title);
-		add(headerToolbar, BorderLayout.NORTH);
-		
-		JEditorPane hints = new JEditorPane("text/html","");
-		hints.setEditorKit(new PlmHtmlEditorKit());
-		hints.setEditable(false);
-		hints.setText(i18n.tr("<h1>Reporting a bug in PLM</h1>"
-						+ "<p>If you have your own GitHub account, please head to the <a href='https://github.com/BuggleInc/PLM'>PLM Bug Tracker</a>. "
-						+ "If not, you can use this window to report an issue in the PLM (be it in one exercise or in the PLM itself). "
-	 				    + "Please write your report in English or French if possible.</p>"
-						+ "<p>You should include all relevant information that could help us fixing the issue. Don't remove the technical details unless you are certain that they are not relevant. "
-						+ "What you write here will be public: <b>Never disclose passwords or other sensible information on a bug tracker</b></p>"
-					  	+ "<p>When you find a typo or a sentence that is hard to understand, it really helps to suggest a new wording."
-					  	+ "If you encounter a technical bug, please tell us what you did, which outcome you were expecting and what happened instead.</p><br/>"));
-		hints.addHyperlinkListener(new HyperlinkListener() {
-			public void hyperlinkUpdate(HyperlinkEvent event) {
-				if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
-					String uri = event.getDescription();
-
-					try {
-						if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
-							System.out.print("Directly");
-						    Desktop.getDesktop().browse(new URI(uri));
-        				} else if (new File("/usr/bin/xdg-open").exists()) {
-							Runtime.getRuntime().exec("/usr/bin/xdg-open " + uri);
-						} else if (System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0) {
-							Runtime.getRuntime().exec("open " + uri);
-						} else {
-							System.err.println("Cannot find any browser");
-						}
-					} catch (IOException | URISyntaxException e) {
-						e.printStackTrace();
-					}
-				}
-			}
-		});
-				
-		add(hints, BorderLayout.NORTH);
-
-		feedback.setBackground(Color.white);
-		feedback.setOpaque(true);
-		feedback.setEditable(true);
-		JScrollPane jsp = new JScrollPane(feedback);
-		jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-		jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
-		add(jsp, BorderLayout.CENTER);
-
-		feedback.setContentType("text/plain");
-
-		final JButton cancelBtn = new JButton(i18n.tr("Cancel"));
-		cancelBtn.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				int dialogResult = JOptionPane.showConfirmDialog(cancelBtn,
-																 i18n.tr("Do you really want to cancel your feedback and lose any edit?"),
-																 i18n.tr("are you sure?"),
-																 JOptionPane.YES_NO_OPTION);
-				if (dialogResult == JOptionPane.YES_OPTION) {
-					dispose();
-				}
-			}
-		});
-
-		final JButton sendBtn = new JButton(i18n.tr("Send feedback"));
-		sendBtn.addActionListener(new ActionListener() {
-			GitHubClient client = new GitHubClient();
-
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				if(isCorrect()) {
-					String rot13 = "apa3a7aqana0a5ara6asana8a7aoa1ana9a2aqa1a5a9a2aoa2a5a2ara5aqaqa8apa8a1a4a4apaoa3";
-					StringBuffer token = new StringBuffer();
-					for (int i=1; i<rot13.length(); i+=2) {
-			            char c = rot13.charAt(i);
-			            if      (c >= 'a' && c <= 'm') c += 13;
-			            else if (c >= 'A' && c <= 'M') c += 13;
-			            else if (c >= 'n' && c <= 'z') c -= 13;
-			            else if (c >= 'N' && c <= 'Z') c -= 13;
-			            else if (c>= '0' && c <= '4') c +=5;
-			            else if (c>= '5' && c <= '9') c -=5;
-			            token.append(c);
-					}
-					client.setOAuth2Token(token.toString());
-					Issue issue = new Issue();
-					issue.setTitle(title.getText());
-					issue.setBody(feedback.getText());
-					IssueService issueService = new IssueService(client);
-					try {
-						Issue i = issueService.createIssue("BuggleInc", "PLM", issue);
-						JOptionPane.showMessageDialog(sendBtn, i18n.tr(
-								  "Thank you for your remark, we will do our best to integrate it.\n"
-								+ "Follow our progress at {0}.",i.getHtmlUrl()), i18n.tr("Thanks for your suggestion"), JOptionPane.INFORMATION_MESSAGE);
-						dispose();
-					} catch (IOException ex) {
-						StringBuffer ctn = new StringBuffer(ex.getLocalizedMessage() + "\n");
-						for (StackTraceElement elm : ex.getStackTrace()) {
-							ctn.append(elm.toString()).append("\n");
-						}
-						JOptionPane.showMessageDialog(cancelBtn,
-													  ctn.toString(),
-													  i18n.tr("Error while uploading your feedback"),
-													  JOptionPane.ERROR_MESSAGE);
-						ex.printStackTrace();
-					}
-				}
-				else {
-					JOptionPane.showMessageDialog(FeedbackDialog.this, 
-							i18n.tr("Your feedback needs some little changes before being send,\nplease fix the following issue(s):\n\n")+errorMsg, 
-							i18n.tr("Incorrect feedback"), 
-							JOptionPane.ERROR_MESSAGE);
-				}
-			}
-		});
-
-		JPanel toolbar = new JPanel();
-		toolbar.add(cancelBtn);
-		toolbar.add(sendBtn);
-		add(toolbar, BorderLayout.SOUTH);
-
-		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-		pack();
-		setMinimumSize(new Dimension(200, 600));
-		setPreferredSize(new Dimension(500, 800));
-		setResizable(true);
-
-		setLocationRelativeTo(getParent());
-	}
-
-	public boolean isCorrect() {
-		boolean correct = true;
-		StringBuffer msg = new StringBuffer();
-		if(title.getText().equals(defaultTitle)) {
-			correct = false;
-			msg.append(i18n.tr("The feedback's title is still the default one, please specify a relevant one.\n"));
-		}
-		else if(title.getText().equals("")) {
-			correct = false;
-			msg.append(i18n.tr("The current title is empty, please specify a relevant title.\n"));
-		}
-		if(feedback.getText().contains(defaultText)) {
-			correct = false;
-			msg.append(i18n.tr("The feedback still contains the explanatory text (above the line of ---------), please remove it.\n"));
-		}
-		errorMsg = msg.toString();
-		return correct;
-	}
-}