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
|
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 | 193 ------------------------------------
src/plm/core/ui/MainFrame.java | 13 --
2 files changed, 1 insertion(+), 205 deletions(-)
Index: b/src/plm/core/ui/MainFrame.java
===================================================================
--- a/src/plm/core/ui/MainFrame.java
+++ b/src/plm/core/ui/MainFrame.java
@@ -95,7 +95,7 @@ public class MainFrame extends JFrame im
private JMenu menuLanguage, menuLangHuman, menuLangProg;
private JMenu menuHelp;
- private JMenuItem miHelpFeedback, miHelpLesson,miHelpWorld,miHelpAbout;
+ private JMenuItem miHelpLesson,miHelpWorld,miHelpAbout;
private LoggerPanel outputArea;
private MissionEditorTabs met;
@@ -386,16 +386,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;
@@ -770,7 +760,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,193 +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.io.IOException;
-
-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 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.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(
- "Please write your suggestion here, with all necessary details\n"
- + "(if possible in English or French).\n\n"
- + "When you find a typo or a sentence that is hard to understand, \n"
- + "it really helps to suggest a new wording.\n\n"
- + "If you encounter a technical bug, please tell us what you did,\n"
- + "which outcome you were expecting and what happened instead.\n\n"
- + " but DO NEVER DISCLOSE A PASSWORD to a bug tracker. Never."
- + "\n\n--------------------[ Technical Information ]--------------------\n"
- + "(This can help us fixing your problem, please don't erase)\n"); /* The rest is not translated */
-
- FeedbackDialog.instance.feedback.setText(defaultText
- + "\nLesson: "+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");
-
-
- 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);
-
- 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()) {
- client.setOAuth2Token(Game.getProperty("plm.github.oauth"));
- Issue issue = new Issue();
- issue.setTitle(title.getText());
- issue.setBody(feedback.getText());
- IssueService issueService = new IssueService(client);
- try {
- Issue i = issueService.createIssue(Game.getProperty("plm.github.owner"), Game.getProperty("plm.github.repo"), 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;
- }
-}
|