Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15769/src/games/stendhal/client/gui
Modified Files:
KTextEdit.java
Log Message:
don't depend on default encoding
Index: KTextEdit.java
===================================================================
RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/KTextEdit.java,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** KTextEdit.java 2 Dec 2012 17:53:11 -0000 1.81
--- KTextEdit.java 10 Jan 2013 23:21:34 -0000 1.82
***************
*** 1,5 ****
- /* $Id$ */
/***************************************************************************
! * (C) Copyright 2003-2012 - Stendhal *
***************************************************************************
***************************************************************************
--- 1,4 ----
/***************************************************************************
! * (C) Copyright 2003-2013 - Stendhal *
***************************************************************************
***************************************************************************
***************
*** 25,30 ****
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseEvent;
! import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
--- 24,31 ----
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseEvent;
! import java.io.FileOutputStream;
import java.io.IOException;
+ import java.io.OutputStreamWriter;
+ import java.io.Writer;
import java.util.Date;
***************
*** 56,60 ****
private static final long serialVersionUID = -698232821850852452L;
private static final Logger logger = Logger.getLogger(KTextEdit.class);
!
/** The actual text component for showing the chat log. */
JTextPane textPane;
--- 57,61 ----
private static final long serialVersionUID = -698232821850852452L;
private static final Logger logger = Logger.getLogger(KTextEdit.class);
!
/** The actual text component for showing the chat log. */
JTextPane textPane;
***************
*** 65,69 ****
/** Background color when not highlighting unread messages. */
private Color defaultBackground = Color.white;
!
/** Listener for opening the popup menu when it's requested. */
private final class TextPaneMouseListener extends MousePopupAdapter {
--- 66,70 ----
/** Background color when not highlighting unread messages. */
private Color defaultBackground = Color.white;
!
/** Listener for opening the popup menu when it's requested. */
private final class TextPaneMouseListener extends MousePopupAdapter {
***************
*** 93,97 ****
}
}
!
@Override
public void setFont(Font font) {
--- 94,98 ----
}
}
!
@Override
public void setFont(Font font) {
***************
*** 111,115 ****
buildGUI();
}
!
/**
* This method builds the Gui.
--- 112,116 ----
buildGUI();
}
!
/**
* This method builds the Gui.
***************
*** 127,136 ****
logger.warn("Failed to turn off caret following");
}
!
textPane.addMouseListener(new TextPaneMouseListener());
!
initStylesForTextPane(textPane, textPane.getFont().getSize());
setLayout(new BorderLayout());
!
scrollPane = new JScrollPane(textPane) {
@Override
--- 128,137 ----
logger.warn("Failed to turn off caret following");
}
!
textPane.addMouseListener(new TextPaneMouseListener());
!
initStylesForTextPane(textPane, textPane.getFont().getSize());
setLayout(new BorderLayout());
!
scrollPane = new JScrollPane(textPane) {
@Override
***************
*** 141,145 ****
}
};
!
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
--- 142,146 ----
}
};
!
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
***************
*** 147,151 ****
JScrollBar bar = (JScrollBar) ev.getAdjustable();
// Try to avoid turning the new message indicator off
! // while the player keeps adjusting the scroll bar to
// avoid missleading results
if (!bar.getValueIsAdjusting() && isAtMaximum(bar)) {
--- 148,152 ----
JScrollBar bar = (JScrollBar) ev.getAdjustable();
// Try to avoid turning the new message indicator off
! // while the player keeps adjusting the scroll bar to
// avoid missleading results
if (!bar.getValueIsAdjusting() && isAtMaximum(bar)) {
***************
*** 160,167 ****
/**
* Initializes the basic styles.
! *
* @param textPane
* the active text component
! * @param mainTextSize size of regular text
*/
protected void initStylesForTextPane(final JTextPane textPane, int mainTextSize) {
--- 161,168 ----
/**
* Initializes the basic styles.
! *
* @param textPane
* the active text component
! * @param mainTextSize size of regular text
*/
protected void initStylesForTextPane(final JTextPane textPane, int mainTextSize) {
***************
*** 210,214 ****
/**
* Get the style corresponding to a description and color.
! *
* @param desiredColor
* the color with which the text must be colored
--- 211,215 ----
/**
* Get the style corresponding to a description and color.
! *
* @param desiredColor
* the color with which the text must be colored
***************
*** 225,230 ****
/**
* Insert a header.
! *
! * @param header
*/
protected void insertHeader(final String header) {
--- 226,231 ----
/**
* Insert a header.
! *
! * @param header
*/
protected void insertHeader(final String header) {
***************
*** 242,246 ****
/**
* Insert time stamp.
! *
* @param header time stamp
*/
--- 243,247 ----
/**
* Insert time stamp.
! *
* @param header time stamp
*/
***************
*** 259,268 ****
/**
* Add text using a style defined for a notification type.
! *
* @param text
* @param type
*/
protected void insertText(final String text, final NotificationType type) {
!
final Color color = type.getColor();
final String styleDescription = type.getStyleDescription();
--- 260,269 ----
/**
* Add text using a style defined for a notification type.
! *
* @param text
* @param type
*/
protected void insertText(final String text, final NotificationType type) {
!
final Color color = type.getColor();
final String styleDescription = type.getStyleDescription();
***************
*** 282,286 ****
};
parser.format(text);
! } catch (final Exception e) {
// BadLocationException
logger.error("Couldn't insert initial text.", e);
--- 283,287 ----
};
parser.format(text);
! } catch (final Exception e) {
// BadLocationException
logger.error("Couldn't insert initial text.", e);
***************
*** 313,317 ****
private void addLine(final String header, final String line,
final NotificationType type) {
! // do the whole thing in the event dispatch thread to ensure the generated
// events get handled in the correct order
try {
--- 314,318 ----
private void addLine(final String header, final String line,
final NotificationType type) {
! // do the whole thing in the event dispatch thread to ensure the generated
// events get handled in the correct order
try {
***************
*** 330,334 ****
}
}
!
/**
* Add a new line with a specified header and content. The style will be
--- 331,335 ----
}
}
!
/**
* Add a new line with a specified header and content. The style will be
***************
*** 353,360 ****
insertText(line, type);
}
!
/**
* Check if a scroll bar is at its maximum value.
! *
* @param bar scroll bar
* @return <code>true</code> if the scrollbar is at its maximum value
--- 354,361 ----
insertText(line, type);
}
!
/**
* Check if a scroll bar is at its maximum value.
! *
* @param bar scroll bar
* @return <code>true</code> if the scrollbar is at its maximum value
***************
*** 367,377 ****
/**
* Append an event line.
! *
! * @param line
*/
public void addLine(final EventLine line) {
this.addLine(line.getHeader(), line.getText(), line.getType());
}
!
/**
* Clear the context.
--- 368,378 ----
/**
* Append an event line.
! *
! * @param line
*/
public void addLine(final EventLine line) {
this.addLine(line.getHeader(), line.getText(), line.getType());
}
!
/**
* Clear the context.
***************
*** 380,388 ****
textPane.setText("");
}
!
/**
* Set the background color to be used normally, when not highlighting
* unread messages.
! *
* @param color background color
*/
--- 381,389 ----
textPane.setText("");
}
!
/**
* Set the background color to be used normally, when not highlighting
* unread messages.
! *
* @param color background color
*/
***************
*** 390,397 ****
defaultBackground = color;
}
!
/**
* Set the name of the logged channel.
! *
* @param name channel name
*/
--- 391,398 ----
defaultBackground = color;
}
!
/**
* Set the name of the logged channel.
! *
* @param name channel name
*/
***************
*** 399,403 ****
this.name = name;
}
!
/**
* Set a clear warning for the user that there are new, unread lines.
--- 400,404 ----
this.name = name;
}
!
/**
* Set a clear warning for the user that there are new, unread lines.
***************
*** 411,418 ****
}
}
!
/**
* Get name of the file where logs should be saved on request.
! *
* @return file name
*/
--- 412,419 ----
}
}
!
/**
* Get name of the file where logs should be saved on request.
! *
* @return file name
*/
***************
*** 424,428 ****
}
}
!
/**
* Save the contents into the log file and inform the user about it.
--- 425,429 ----
}
}
!
/**
* Save the contents into the log file and inform the user about it.
***************
*** 430,436 ****
public void save() {
String fname = getSaveFileName();
! FileWriter fo;
try {
! fo = new FileWriter(fname);
try {
textPane.write(fo);
--- 431,437 ----
public void save() {
String fname = getSaveFileName();
! Writer fo;
try {
! fo = new OutputStreamWriter(new FileOutputStream(fname), "UTF-8");
try {
textPane.write(fo);
***************
*** 444,448 ****
}
}
!
/**
* A custom range model that implements the automatically scrolling pane.
--- 445,449 ----
}
}
!
/**
* A custom range model that implements the automatically scrolling pane.
***************
*** 453,457 ****
public void setRangeProperties(int value, int extent, int min, int max,
boolean adjusting) {
! boolean atBottom = getValue() + getExtent() >= getMaximum();
if (atBottom && (value == getValue())) {
// We are at bottom, use adjusted values to ensure we stay
--- 454,458 ----
public void setRangeProperties(int value, int extent, int min, int max,
boolean adjusting) {
! boolean atBottom = getValue() + getExtent() >= getMaximum();
if (atBottom && (value == getValue())) {
// We are at bottom, use adjusted values to ensure we stay
|