Thanks to the TeeStream, standard output and standard error are now
written to, in addition to writing to the .log file.
This commit is contained in:
parent
ef60ccb31b
commit
635b707067
3 changed files with 957 additions and 948 deletions
|
@ -27,15 +27,22 @@ import java.awt.event.*;
|
||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
import javax.swing.text.rtf.*;
|
import javax.swing.text.rtf.*;
|
||||||
|
|
||||||
|
import org.thdl.util.TeeStream;
|
||||||
|
|
||||||
public class QDShell extends JFrame {
|
public class QDShell extends JFrame {
|
||||||
ResourceBundle messages = null;
|
ResourceBundle messages = null;
|
||||||
QD qd = null;
|
QD qd = null;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
PrintStream ps = new PrintStream(new FileOutputStream("qd.log"));
|
PrintStream psOut
|
||||||
System.setErr(ps);
|
= new TeeStream(System.out,
|
||||||
System.setOut(ps);
|
new PrintStream(new FileOutputStream("qd.log")));
|
||||||
|
PrintStream psErr
|
||||||
|
= new TeeStream(System.err,
|
||||||
|
new PrintStream(new FileOutputStream("qd.log")));
|
||||||
|
System.setErr(psErr);
|
||||||
|
System.setOut(psOut);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.swing.text.rtf.*;
|
||||||
|
|
||||||
import org.thdl.savant.ucuchi.*;
|
import org.thdl.savant.ucuchi.*;
|
||||||
import org.thdl.savant.tib.*;
|
import org.thdl.savant.tib.*;
|
||||||
|
import org.thdl.util.TeeStream;
|
||||||
|
|
||||||
public class SavantShell extends JFrame
|
public class SavantShell extends JFrame
|
||||||
{
|
{
|
||||||
|
@ -43,9 +44,14 @@ public class SavantShell extends JFrame
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
java.io.PrintStream ps = new java.io.PrintStream(new java.io.FileOutputStream("savant.log"));
|
PrintStream psOut
|
||||||
System.setErr(ps);
|
= new TeeStream(System.out,
|
||||||
System.setOut(ps);
|
new PrintStream(new FileOutputStream("savant.log")));
|
||||||
|
PrintStream psErr
|
||||||
|
= new TeeStream(System.err,
|
||||||
|
new PrintStream(new FileOutputStream("savant.log")));
|
||||||
|
System.setErr(psErr);
|
||||||
|
System.setOut(psOut);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import javax.swing.text.*;
|
||||||
import javax.swing.text.rtf.*;
|
import javax.swing.text.rtf.*;
|
||||||
|
|
||||||
import org.thdl.tib.text.*;
|
import org.thdl.tib.text.*;
|
||||||
|
import org.thdl.util.TeeStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple Tibetan text editor. Jskad editors lack most of the
|
* A simple Tibetan text editor. Jskad editors lack most of the
|
||||||
|
@ -50,7 +51,6 @@ import org.thdl.tib.text.*;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class Jskad extends JPanel implements DocumentListener {
|
public class Jskad extends JPanel implements DocumentListener {
|
||||||
private RTFEditorKit rtfEditor;
|
|
||||||
private String fontName = "";
|
private String fontName = "";
|
||||||
private JComboBox fontFamilies, fontSizes;
|
private JComboBox fontFamilies, fontSizes;
|
||||||
private JFileChooser fileChooser;
|
private JFileChooser fileChooser;
|
||||||
|
@ -154,16 +154,6 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
});
|
});
|
||||||
fileMenu.add(saveAsItem);
|
fileMenu.add(saveAsItem);
|
||||||
|
|
||||||
JMenuItem printItem = new JMenuItem("Print");
|
|
||||||
printItem.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
PrintDuffPane printer = new PrintDuffPane(Jskad.this, dp);
|
|
||||||
printer.preview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fileMenu.addSeparator();
|
|
||||||
fileMenu.add(printItem);
|
|
||||||
|
|
||||||
menuBar.add(fileMenu);
|
menuBar.add(fileMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +333,7 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
toolBar.add(keyboards);
|
toolBar.add(keyboards);
|
||||||
toolBar.add(Box.createHorizontalGlue());
|
toolBar.add(Box.createHorizontalGlue());
|
||||||
|
|
||||||
rtfEditor = new RTFEditorKit();
|
dp = new DuffPane();
|
||||||
dp = new DuffPane(rtfEditor);
|
|
||||||
JScrollPane sp = new JScrollPane(dp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane sp = new JScrollPane(dp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
dp.getDocument().addDocumentListener(this);
|
dp.getDocument().addDocumentListener(this);
|
||||||
|
|
||||||
|
@ -491,11 +480,11 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
newFrame.setLocation(point.x+50, point.y+50);
|
newFrame.setLocation(point.x+50, point.y+50);
|
||||||
Jskad newRTF = new Jskad(newFrame);
|
Jskad newRTF = new Jskad(newFrame);
|
||||||
newFrame.getContentPane().add(newRTF);
|
newFrame.getContentPane().add(newRTF);
|
||||||
rtfEditor.read(in, newRTF.dp.getDocument(), 0);
|
newRTF.dp.rtfEd.read(in, newRTF.dp.getDocument(), 0);
|
||||||
newRTF.dp.getDocument().addDocumentListener(newRTF);
|
newRTF.dp.getDocument().addDocumentListener(newRTF);
|
||||||
in.close();
|
in.close();
|
||||||
newFrame.setTitle(f_name);
|
newFrame.setTitle(f_name);
|
||||||
newRTF.fileName = f_name;
|
newRTF.fileName = new String(f_name);
|
||||||
newRTF.hasChanged = false;
|
newRTF.hasChanged = false;
|
||||||
newRTF.dp.getCaret().setDot(0);
|
newRTF.dp.getCaret().setDot(0);
|
||||||
newFrame.setVisible(true);
|
newFrame.setVisible(true);
|
||||||
|
@ -521,12 +510,12 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
try {
|
try {
|
||||||
InputStream in = new FileInputStream(fileChosen);
|
InputStream in = new FileInputStream(fileChosen);
|
||||||
dp.newDocument();
|
dp.newDocument();
|
||||||
rtfEditor.read(in, dp.getDocument(), 0);
|
dp.rtfEd.read(in, dp.getDocument(), 0);
|
||||||
in.close();
|
in.close();
|
||||||
dp.getCaret().setDot(0);
|
dp.getCaret().setDot(0);
|
||||||
dp.getDocument().addDocumentListener(Jskad.this);
|
dp.getDocument().addDocumentListener(Jskad.this);
|
||||||
hasChanged = false;
|
hasChanged = false;
|
||||||
fileName = f_name;
|
fileName = new String(f_name);
|
||||||
|
|
||||||
if (parentObject instanceof JFrame) {
|
if (parentObject instanceof JFrame) {
|
||||||
JFrame parentFrame = (JFrame)parentObject;
|
JFrame parentFrame = (JFrame)parentObject;
|
||||||
|
@ -553,12 +542,12 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
if (parentObject instanceof JFrame) {
|
if (parentObject instanceof JFrame) {
|
||||||
JFrame parentFrame = (JFrame)parentObject;
|
JFrame parentFrame = (JFrame)parentObject;
|
||||||
parentFrame.setTitle(s);
|
parentFrame.setTitle(s);
|
||||||
fileName = s;
|
fileName = new String(s);
|
||||||
}
|
}
|
||||||
else if (parentObject instanceof JInternalFrame) {
|
else if (parentObject instanceof JInternalFrame) {
|
||||||
JInternalFrame parentFrame = (JInternalFrame)parentObject;
|
JInternalFrame parentFrame = (JInternalFrame)parentObject;
|
||||||
parentFrame.setTitle(s);
|
parentFrame.setTitle(s);
|
||||||
fileName = s;
|
fileName = new String(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,12 +558,12 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
if (parentObject instanceof JFrame) {
|
if (parentObject instanceof JFrame) {
|
||||||
JFrame parentFrame = (JFrame)parentObject;
|
JFrame parentFrame = (JFrame)parentObject;
|
||||||
parentFrame.setTitle(s);
|
parentFrame.setTitle(s);
|
||||||
fileName = s;
|
fileName = new String(s);
|
||||||
}
|
}
|
||||||
else if (parentObject instanceof JInternalFrame) {
|
else if (parentObject instanceof JInternalFrame) {
|
||||||
JInternalFrame parentFrame = (JInternalFrame)parentObject;
|
JInternalFrame parentFrame = (JInternalFrame)parentObject;
|
||||||
parentFrame.setTitle(s);
|
parentFrame.setTitle(s);
|
||||||
fileName = s;
|
fileName = new String(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,8 +576,9 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JOptionPane.YES_OPTION: //save and continue
|
case JOptionPane.YES_OPTION: //save and continue
|
||||||
if (fileName == null)
|
if (fileName == null) {
|
||||||
saveAsFile();
|
saveAsFile();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
saveFile();
|
saveFile();
|
||||||
return true;
|
return true;
|
||||||
|
@ -602,16 +592,17 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
File fileChosen = new File(f_name);
|
File fileChosen = new File(f_name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OutputStream out = new FileOutputStream(fileChosen);
|
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileChosen));
|
||||||
rtfEditor.write(out, dp.getDocument(), 0, dp.getDocument().getLength());
|
dp.rtfEd.write(out, dp.getDocument(), 0, dp.getDocument().getLength());
|
||||||
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
hasChanged = false;
|
hasChanged = false;
|
||||||
}
|
} catch (IOException exception) {
|
||||||
catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
} catch (BadLocationException ble) {
|
||||||
|
ble.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return f_name;
|
return f_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,15 +905,20 @@ public class Jskad extends JPanel implements DocumentListener {
|
||||||
* to include the jskad.log file as an attachment.
|
* to include the jskad.log file as an attachment.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
/*
|
|
||||||
try {
|
try {
|
||||||
PrintStream ps = new PrintStream(new FileOutputStream("jskad.log"));
|
PrintStream psOut
|
||||||
System.setErr(ps);
|
= new TeeStream(System.out,
|
||||||
System.setOut(ps);
|
new PrintStream(new FileOutputStream("jskad.log")));
|
||||||
|
PrintStream psErr
|
||||||
|
= new TeeStream(System.err,
|
||||||
|
new PrintStream(new FileOutputStream("jskad.log")));
|
||||||
|
System.setErr(psErr);
|
||||||
|
System.setOut(psOut);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
|
Loading…
Reference in a new issue