[Jrisk-cvs] SF.net SVN: jrisk:[449] Domination/src_swing/net/yura/domination
Brought to you by:
yuranet
|
From: <yu...@us...> - 2010-09-22 15:27:03
|
Revision: 449
http://jrisk.svn.sourceforge.net/jrisk/?rev=449&view=rev
Author: yuranet
Date: 2010-09-22 15:26:56 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
grasshopper added
Modified Paths:
--------------
Domination/src_swing/net/yura/domination/engine/RiskUIUtil.java
Domination/src_swing/net/yura/domination/ui/flashgui/FlashRiskAdapter.java
Domination/src_swing/net/yura/domination/ui/swinggui/BugsPanel.java
Domination/src_swing/net/yura/domination/ui/swinggui/SwingGUIPanel.java
Removed Paths:
-------------
Domination/src_swing/net/yura/domination/engine/guishared/SimplePrintStream.java
Modified: Domination/src_swing/net/yura/domination/engine/RiskUIUtil.java
===================================================================
--- Domination/src_swing/net/yura/domination/engine/RiskUIUtil.java 2010-09-22 15:23:28 UTC (rev 448)
+++ Domination/src_swing/net/yura/domination/engine/RiskUIUtil.java 2010-09-22 15:26:56 UTC (rev 449)
@@ -636,80 +636,6 @@
}
- public static String sendText(String from, String text,String title) throws Exception {
-
- if (applet!=null) {
-
- throw new Exception("\n"+TranslationBundle.getBundle().getString("core.error.applet"));
-
- }
-
-/* this is doing a get, throws a 414 error on big messages
-
- //t = t.replaceAll("\n","%0A").replaceAll(" ","+").replaceAll("&","%26");
-
- text = java.net.URLEncoder.encode(text,"UTF-8");
- from = java.net.URLEncoder.encode(from,"UTF-8");
-
- URL url = new URL("http://yura.net/cgi-sys/FormMail.cgi?rec...@yu...&subject=bugs%20and%20suggestion&email="+from+"&text="+text );
-
- BufferedReader bufferin=new BufferedReader( new InputStreamReader(url.openStream()) );
-
- StringBuffer buffer = new StringBuffer();
-
- String input = bufferin.readLine();
-
- while(input != null) {
-
- buffer.append(input+"\n");
-
- input = bufferin.readLine(); // get next line
- }
-
- return buffer.toString();
-
-*/
-
-
-
- StringBuffer buffer = new StringBuffer();
-
- // Construct data
- String data = URLEncoder.encode("recipient", "UTF-8") + "=" + URLEncoder.encode("yu...@yu...", "UTF-8");
- data += "&" + URLEncoder.encode("subject", "UTF-8") + "=" + URLEncoder.encode(RiskUtil.GAME_NAME+" "+Risk.RISK_VERSION+" "+title, "UTF-8");
- data += "&" + URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode(from, "UTF-8");
- data += "&" + URLEncoder.encode("env_report", "UTF-8") + "=" + URLEncoder.encode("REMOTE_HOST,HTTP_USER_AGENT", "UTF-8");
- data += "&" + URLEncoder.encode("info", "UTF-8") + "=" + URLEncoder.encode(getSystemInfoText(), "UTF-8");
- data += "&" + URLEncoder.encode("text", "UTF-8") + "=" + URLEncoder.encode(text, "UTF-8");
-
-
- // Send data
- URL url = new URL(RiskUtil.RISK_POST_URL);
- URLConnection conn = url.openConnection();
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write(data);
- wr.flush();
-
- // Get the response
- BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String line;
- while ((line = rd.readLine()) != null) {
-
- buffer.append(line+"\n");
-
- }
- wr.close();
- rd.close();
-
-
- return buffer.toString();
-
-
-
- }
-
-
public static String getSystemInfoText() {
ResourceBundle resb = TranslationBundle.getBundle();
Deleted: Domination/src_swing/net/yura/domination/engine/guishared/SimplePrintStream.java
===================================================================
--- Domination/src_swing/net/yura/domination/engine/guishared/SimplePrintStream.java 2010-09-22 15:23:28 UTC (rev 448)
+++ Domination/src_swing/net/yura/domination/engine/guishared/SimplePrintStream.java 2010-09-22 15:26:56 UTC (rev 449)
@@ -1,36 +0,0 @@
-package net.yura.domination.engine.guishared;
-
-import java.io.*;
-
-public class SimplePrintStream extends OutputStream {
-
- private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256);
- private StringWriter sw = null;
-
- private SimplePrintStream(StringWriter a) {
-
- sw = a;
- }
-
- public void write(int b) {
-
- outputStream.write(b);
- }
-
- public void flush() throws IOException {
-
- super.flush();
-
- sw.write( outputStream.toString() );
-
- outputStream.reset();
-
- }
-
- public static PrintStream getSimplePrintStream(StringWriter a) {
-
- return new PrintStream(new SimplePrintStream(a), true);
-
- }
-
-}
Modified: Domination/src_swing/net/yura/domination/ui/flashgui/FlashRiskAdapter.java
===================================================================
--- Domination/src_swing/net/yura/domination/ui/flashgui/FlashRiskAdapter.java 2010-09-22 15:23:28 UTC (rev 448)
+++ Domination/src_swing/net/yura/domination/ui/flashgui/FlashRiskAdapter.java 2010-09-22 15:26:56 UTC (rev 449)
@@ -8,26 +8,16 @@
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import java.awt.Cursor;
-import javax.swing.JFrame;
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-import java.io.PrintStream;
-import java.io.StringWriter;
-import java.awt.BorderLayout;
-import javax.swing.JLabel;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
import java.io.IOException;
import javax.swing.JOptionPane;
import net.yura.domination.engine.Risk;
import net.yura.domination.engine.RiskListener;
import net.yura.domination.engine.RiskUIUtil;
+import net.yura.domination.engine.RiskUtil;
import net.yura.domination.engine.core.Country;
import net.yura.domination.engine.core.RiskGame;
import net.yura.domination.engine.guishared.PicturePanel;
-import net.yura.domination.engine.guishared.SimplePrintStream;
+import net.yura.domination.engine.translation.TranslationBundle;
/**
* <p> Risk Listener for FlashGUI </p>
@@ -48,12 +38,8 @@
private int nod;
private int nogames;
- private JFrame errFrame;
- private JTextArea debugText;
+ public FlashRiskAdapter(Risk r) {
-
- public FlashRiskAdapter(Risk r) {
-
myrisk = r;
myrisk.addRiskListener(this);
@@ -80,133 +66,21 @@
menu = m;
- errFrame=null;
- debugText = new JTextArea();
-
newgameframe = new NewGameFrame(myrisk);
- PrintStream ps = SimplePrintStream.getSimplePrintStream(
-
- new StringWriter() {
- public void write(String x) {
-
- // only create all this stuff if an error has happened
- if (errFrame==null) {
-
- errFrame = new JFrame("an error has occurred!!!");
-
- errFrame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
-
- debugText.setEditable(false);
-
- JScrollPane errScroll = new JScrollPane(debugText);
-
- Dimension size = new Dimension(400,400);
-
- errScroll.setMaximumSize(size);
- errScroll.setPreferredSize(size);
- errScroll.setMinimumSize(size);
-
- JLabel label = new JLabel("an error happened, please send it to yu...@yu...");
- label.setBorder( BorderFactory.createMatteBorder(10,10,10,10,Color.RED) );
-
- JButton saveErr = new JButton("click here to send");
-
- saveErr.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent a) {
-
- String email = JOptionPane.showInputDialog(errFrame,"tell me your e-mail please");
-
- if (email == null) { email ="none"; }
-
- try {
-
- RiskUIUtil.sendText(email , debugText.getText(), "FlashGUI Bug");
-
- JOptionPane.showMessageDialog(errFrame, "SENT!");
-
-
- }
- catch(Exception ex) {
-
- JOptionPane.showMessageDialog(errFrame, "ERROR: "+ex.getMessage() );
-
- }
-
-/*
-
- JFileChooser fc = new JFileChooser();
- RiskFileFilter filter = new RiskFileFilter(RiskFileFilter.RISK_LOG_FILES);
- fc.setFileFilter(filter);
-
- int returnVal = fc.showSaveDialog(errFrame);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- java.io.File file = fc.getSelectedFile();
- // Write your code here what to do with selected file
-
- String fileName = file.getAbsolutePath();
-
- if (!(fileName.endsWith( "." + RiskFileFilter.RISK_LOG_FILES ))) {
- fileName = fileName + "." + RiskFileFilter.RISK_LOG_FILES;
- }
-
- try {
-
- FileWriter fileout = new FileWriter(fileName);
- BufferedWriter buffer = new BufferedWriter(fileout);
- PrintWriter printer = new PrintWriter(buffer);
-
- printer.write(debugText.getText());
-
- printer.close();
-
- }
-
- catch(Exception error) {
- JOptionPane.showMessageDialog(errFrame, "unable to save file: " + error.getMessage(), "save error", JOptionPane.ERROR_MESSAGE);
- }
-
- } else {
- // Write your code here what to do if user has canceled Save dialog
- }
-
-
-*/
-
-
- }
- }
- );
-
- errFrame.getContentPane().add( label , BorderLayout.NORTH );
- errFrame.getContentPane().add( errScroll , BorderLayout.CENTER);
- errFrame.getContentPane().add( saveErr , BorderLayout.SOUTH);
-
- errFrame.pack();
-
- String n = System.getProperty("line.separator");
- debugText.append(n+n+"Date: "+new java.util.Date().toString()+n+n+n);
-
- errFrame.setVisible(true);
-
- }
-
- debugText.append(x);
-
- }
- }
-
- );
-
if (RiskUIUtil.checkForNoSandbox()) {
-
// catch everything in my PrintStream
- //System.setOut(ps);
- System.setErr(ps);
- }
+ try {
+ net.yura.grasshopper.PopupBug.initSimple(RiskUtil.GAME_NAME,
+ Risk.RISK_VERSION+" FlashGUI" // "(save: " + RiskGame.SAVE_VERSION + " network: "+RiskGame.NETWORK_VERSION+")"
+ , TranslationBundle.getBundle().getLocale().toString());
+ }
+ catch(Throwable th) {
+ System.out.println("Grasshopper not loaded");
+ }
+ }
}
/**
@@ -228,7 +102,13 @@
catch (NullPointerException e) { }
}
- public void sendDebug(String a) { debugText.append(a + System.getProperty("line.separator") ); }
+ public void sendDebug(String a) {
+ try {
+ net.yura.grasshopper.PopupBug.log( a + System.getProperty("line.separator") );
+ }
+ catch(Throwable th) {
+ }
+ }
public void showMessageDialog(String a) {
@@ -260,7 +140,6 @@
* @param state The game state
*/
public void setGameStatus(String state) {
-
try {
gameFrame.setGameStatus(state);
}
@@ -487,12 +366,13 @@
nogames++;
- if (errFrame==null) {
+ try {
+ net.yura.grasshopper.PopupBug.clearLog();
+ net.yura.grasshopper.PopupBug.log( "game "+nogames+" closed, log cleared"+System.getProperty("line.separator") );
+ }
+ catch(Throwable th) {
+ }
- debugText.setText("game "+nogames+" closed, log cleared"+System.getProperty("line.separator") );
-
- }
-
newgameframe.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
System.gc();
Modified: Domination/src_swing/net/yura/domination/ui/swinggui/BugsPanel.java
===================================================================
--- Domination/src_swing/net/yura/domination/ui/swinggui/BugsPanel.java 2010-09-22 15:23:28 UTC (rev 448)
+++ Domination/src_swing/net/yura/domination/ui/swinggui/BugsPanel.java 2010-09-22 15:26:56 UTC (rev 449)
@@ -16,7 +16,6 @@
import javax.swing.JTextField;
import javax.swing.JToolBar;
import net.yura.domination.engine.RiskUIUtil;
-import net.yura.domination.engine.RiskUtil;
/**
* @author Yura Mamyrin
@@ -66,19 +65,8 @@
if (a.getActionCommand().equals("send")) {
- try {
+ SwingGUIPanel.submitBug(this,text.getText(), from.getText(), "Suggestion");
- RiskUIUtil.sendText( from.getText(), text.getText(),"Suggestion" );
-
- JOptionPane.showMessageDialog(this, "SENT!");
-
-
- }
- catch(Exception ex) {
-
- JOptionPane.showMessageDialog(this, "ERROR: "+ex.getMessage() );
-
- }
}
}
Modified: Domination/src_swing/net/yura/domination/ui/swinggui/SwingGUIPanel.java
===================================================================
--- Domination/src_swing/net/yura/domination/ui/swinggui/SwingGUIPanel.java 2010-09-22 15:23:28 UTC (rev 448)
+++ Domination/src_swing/net/yura/domination/ui/swinggui/SwingGUIPanel.java 2010-09-22 15:26:56 UTC (rev 449)
@@ -26,9 +26,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.PrintStream;
import java.io.PrintWriter;
-import java.io.StringWriter;
+import java.io.Writer;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.AbstractButton;
@@ -73,7 +72,6 @@
import net.yura.domination.engine.guishared.MapMouseListener;
import net.yura.domination.engine.guishared.PicturePanel;
import net.yura.domination.engine.guishared.RiskFileFilter;
-import net.yura.domination.engine.guishared.SimplePrintStream;
import net.yura.domination.engine.guishared.StatsPanel;
import net.yura.domination.engine.translation.TranslationBundle;
import net.yura.domination.tools.mapeditor.MapEditor;
@@ -1388,6 +1386,24 @@
}
+ public static void submitBug(Component parent, String text,String from,String subject) {
+
+ try {
+ net.yura.grasshopper.BugSubmitter.submitBug(text, from, RiskUtil.GAME_NAME +" "+Risk.RISK_VERSION+" SwingGUI "+
+ TranslationBundle.getBundle().getLocale().toString()+" "+subject,
+ RiskUtil.GAME_NAME,
+ Risk.RISK_VERSION+" (save: " + RiskGame.SAVE_VERSION + " network: "+RiskGame.NETWORK_VERSION+")"
+ , TranslationBundle.getBundle().getLocale().toString()
+
+ );
+ JOptionPane.showMessageDialog(parent, "SENT!");
+ }
+ catch(Throwable ex) {
+ JOptionPane.showMessageDialog(parent, "ERROR: "+ex.toString() );
+ }
+
+ }
+
class DebugTab extends JSplitPane implements SwingGUITab,ActionListener {
private JTextArea debugText;
@@ -1559,34 +1575,30 @@
g.dispose();
final Icon icon = new ImageIcon(img);
- PrintStream ps = SimplePrintStream.getSimplePrintStream(
- new StringWriter() {
- public void write(String x) {
+ if (RiskUIUtil.checkForNoSandbox()) {
- int nom = tabbedpane.indexOfComponent(DebugTab.this);
+ net.yura.grasshopper.SimplePrintStream.interceptAndAlert(new Writer() {
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ errText.append(String.valueOf(cbuf, off, len));
+ }
+ public void flush() throws IOException {
+ }
+ public void close() throws IOException {
+ }
+ }, new net.yura.grasshopper.SimplePrintStream() {
+ public void action() {
+ int nom = tabbedpane.indexOfComponent(DebugTab.this);
- if (tabbedpane.getIconAt(nom)==null) {
- tabbedpane.setIconAt(nom,icon);
+ if (tabbedpane.getIconAt(nom)==null) {
+ tabbedpane.setIconAt(nom,icon);
- String n = System.getProperty("line.separator");
- errText.append(n+n+"Date: "+new java.util.Date().toString()+n+n+n);
- }
+ String n = System.getProperty("line.separator");
+ errText.append(n+n+"Date: "+new java.util.Date().toString()+n+n+n);
+ }
+ }
+ });
- errText.append(x);
-
- }
- }
-
- );
-
- if (RiskUIUtil.checkForNoSandbox()) {
-
- // catch everything in my PrintStream
- //System.setOut(ps);
- // only care about errors
- System.setErr(ps);
-
}
}
@@ -1632,25 +1644,12 @@
else if (a.getActionCommand().equals("send error")) {
- String email = JOptionPane.showInputDialog(this,"tell me your e-mail please");
+ String email = JOptionPane.showInputDialog(this,"tell me your e-mail please");
- if (email == null) { email ="none"; }
+ if (email == null) { email ="none"; }
- try {
+ submitBug( this, debugText.getText() + errText.getText(), email, "Bug" );
- RiskUIUtil.sendText(email , debugText.getText() + errText.getText(), "SwingGUI Bug" );
-
- JOptionPane.showMessageDialog(this, "SENT!");
-
-
- }
- catch(Exception ex) {
-
- showError("unable to send: "+ex.getMessage() );
-
- }
-
-
}
else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|