|
From: <ev...@us...> - 2010-12-25 21:33:19
|
Revision: 1467
http://rails.svn.sourceforge.net/rails/?rev=1467&view=rev
Author: evos
Date: 2010-12-25 21:33:13 +0000 (Sat, 25 Dec 2010)
Log Message:
-----------
Fixed ReportWindow
Modified Paths:
--------------
trunk/18xx/rails/ui/swing/AbstractReportWindow.java
trunk/18xx/rails/ui/swing/ReportWindow.java
trunk/18xx/rails/ui/swing/ReportWindowDynamic.java
Modified: trunk/18xx/rails/ui/swing/AbstractReportWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466)
+++ trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-12-25 21:33:13 UTC (rev 1467)
@@ -1,7 +1,7 @@
package rails.ui.swing;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
+import java.awt.Rectangle;
+import java.awt.event.*;
import javax.swing.JFrame;
@@ -10,10 +10,16 @@
public abstract class AbstractReportWindow extends JFrame {
private static final long serialVersionUID = 1L;
-
+
+ protected GameUIManager gameUIManager;
+
// can be set to false, than it cannot be closed
protected boolean closeable = true;
+ public AbstractReportWindow (GameUIManager gameUIManager) {
+ this.gameUIManager = gameUIManager;
+ }
+
public void init() {
setSize(400, 400);
setLocation(600, 400);
@@ -29,12 +35,29 @@
frame.dispose();
}
});
-
+ final GameUIManager guiMgr = gameUIManager;
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ guiMgr.getWindowSettings().set(frame);
+ }
+ @Override
+ public void componentResized(ComponentEvent e) {
+ guiMgr.getWindowSettings().set(frame);
+ }
+ });
+
+ WindowSettings ws = gameUIManager.getWindowSettings();
+ Rectangle bounds = ws.getBounds(this);
+ if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation());
+ if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize());
+ ws.set(frame);
+
setVisible("yes".equalsIgnoreCase(Config.get("report.window.open")));
}
-
+
public abstract void updateLog();
-
+
public abstract void scrollDown();
}
\ No newline at end of file
Modified: trunk/18xx/rails/ui/swing/ReportWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:12:39 UTC (rev 1466)
+++ trunk/18xx/rails/ui/swing/ReportWindow.java 2010-12-25 21:33:13 UTC (rev 1467)
@@ -31,7 +31,6 @@
private JMenuItem saveItem, loadItem, printItem;
private JMenuItem findItem, findBackItem, findNextItem, findPrevItem;
- private GameUIManager gameUIManager;
private GameManagerI gameManager;
private String reportDirectory = Config.get("report.directory");
@@ -52,8 +51,8 @@
public ReportWindow(GameUIManager gameUIManager) {
+ super(gameUIManager);
messageWindow = this;
- this.gameUIManager = gameUIManager;
this.gameManager = gameUIManager.getGameManager();
reportText = new JTextArea();
@@ -156,24 +155,6 @@
// default report window settings
super.init();
- final JFrame frame = this;
- final GameUIManager guiMgr = gameUIManager;
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentMoved(ComponentEvent e) {
- guiMgr.getWindowSettings().set(frame);
- }
- @Override
- public void componentResized(ComponentEvent e) {
- guiMgr.getWindowSettings().set(frame);
- }
- });
-
- WindowSettings ws = gameUIManager.getWindowSettings();
- Rectangle bounds = ws.getBounds(this);
- if (bounds.x != -1 && bounds.y != -1) setLocation(bounds.getLocation());
- if (bounds.width != -1 && bounds.height != -1) setSize(bounds.getSize());
- ws.set(frame);
}
/* (non-Javadoc)
Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java
===================================================================
--- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-12-25 21:12:39 UTC (rev 1466)
+++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-12-25 21:33:13 UTC (rev 1467)
@@ -1,22 +1,13 @@
package rails.ui.swing;
import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.EventQueue;
import java.awt.Font;
-import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.List;
-import javax.swing.JButton;
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.UIManager;
+import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.BadLocationException;
@@ -38,36 +29,34 @@
public class ReportWindowDynamic extends AbstractReportWindow implements ActionListener, HyperlinkListener {
private static final long serialVersionUID = 1L;
- private GameUIManager gameUIManager;
-
private JLabel message;
-
+
private JScrollPane reportPane;
private JEditorPane editorPane;
-
+
private JPanel buttonPanel;
private ActionButton forwardButton;
private ActionButton backwardButton;
private JButton returnButton;
private JButton playFromHereButton;
private JButton commentButton;
-
+
private boolean timeWarpMode;
-
+
protected static Logger log =
Logger.getLogger(ReportWindowDynamic.class.getPackage().getName());
public ReportWindowDynamic(GameUIManager gameUIManager) {
- super();
- this.gameUIManager = gameUIManager;
+ super(gameUIManager);
init();
}
+ @Override
public void init() {
super.init();
setLayout(new BorderLayout());
-
+
JPanel messagePanel = new JPanel();
messagePanel.setLayout(new BorderLayout());
@@ -75,7 +64,7 @@
message.setText( LocalText.getText("REPORT_TIMEWARP_ACTIVE"));
message.setHorizontalAlignment(JLabel.CENTER);
messagePanel.add(message, "North");
-
+
JPanel timeWarpButtons = new JPanel();
returnButton = new JButton(LocalText.getText("REPORT_LEAVE_TIMEWARP"));
returnButton.addActionListener(
@@ -98,7 +87,7 @@
timeWarpButtons.add(playFromHereButton);
messagePanel.add(timeWarpButtons, "South");
add(messagePanel, "North");
-
+
editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setContentType("text/html");
@@ -115,10 +104,10 @@
reportPane = new JScrollPane(editorPane);
add(reportPane, "Center");
-
+
buttonPanel = new JPanel();
add(buttonPanel, "South");
-
+
backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD"));
backwardButton.addActionListener(this);
buttonPanel.add(backwardButton);
@@ -126,8 +115,8 @@
forwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_FORWARD"));
forwardButton.addActionListener(this);
buttonPanel.add(forwardButton);
-
-
+
+
commentButton = new JButton(LocalText.getText("REPORT_COMMENT"));
commentButton.addActionListener(
new ActionListener() {
@@ -150,15 +139,15 @@
}
);
buttonPanel.add(commentButton);
-
+
}
-
+
@Override
public void updateLog() {
- // set the content of the pane to the current
+ // set the content of the pane to the current
editorPane.setText(ReportBuffer.getReportItems());
scrollDown();
-
+
forwardButton.setEnabled(false);
backwardButton.setEnabled(false);
@@ -173,7 +162,7 @@
backwardButton.setEnabled(true);
break;
case GameAction.FORCED_UNDO:
- if (undoFlag) break; // only activate forced undo, if no other undo available
+ if (undoFlag) break; // only activate forced undo, if no other undo available
backwardButton.setPossibleAction(action);
backwardButton.setEnabled(true);
break;
@@ -191,7 +180,7 @@
public void scrollDown() {
// only set caret if visible
if (!this.isVisible()) return;
-
+
// find the active message in the parsed html code (not identical to the position in the html string)
// thus the message indicator is used
int caretPosition;
@@ -206,7 +195,7 @@
editorPane.setCaretPosition(caretPositionStore);
}
}
-
+
public void actionPerformed(ActionEvent e) {
ActionButton button = (ActionButton)e.getSource();
GameAction action = (GameAction)button.getPossibleActions().get(0);
@@ -215,8 +204,8 @@
activateTimeWarp();
}
}
-
-
+
+
gameUIManager.processOnServer(action);
}
@@ -235,7 +224,7 @@
private void gotoLastIndex() {
gotoIndex(gameUIManager.getGameManager().getMoveStack().size());
}
-
+
private void gotoIndex(int index) {
MoveStack stack = gameUIManager.getGameManager().getMoveStack();
int currentIndex = stack.getIndex();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|