source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/feedback/MyTextArea.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

File size: 2.0 KB
Line 
1/** This class is not currently used and therefore will not be compiled by makegli. */
2
3package org.greenstone.gatherer.feedback;
4
5import javax.swing.*;
6import javax.swing.text.*;
7import java.util.Date;
8import java.awt.Color;
9
10/**
11 * This class will allow us to changed what should be inputted to the
12 * text area as the user inputted the text to the text area.
13 * @author Veronica Liesaputra
14 */
15public class MyTextArea extends JTextArea
16{
17 /**
18 * Creating an empty JTextArea.
19 */
20 public MyTextArea ()
21 {
22 super();
23 }
24
25 /**
26 * Creating a JTextArea already appended with cols.
27 * (Precondition: (cols != null))
28 * @param cols the text to be appended.
29 */
30 public MyTextArea(String cols)
31 {
32 super(cols);
33 }
34
35 /**
36 * It will give the default model this text area should use.
37 * @return the default model this text area used.
38 */
39 protected Document createDefaultModel()
40 {
41 return new UpperCaseDocument();
42 }
43
44 /**
45 * This class will be used as the default model of MyTextArea.
46 * Here we can control and modified the string that is going to be inserted to
47 * the document.
48 */
49 static class UpperCaseDocument extends PlainDocument
50 {
51 /**
52 * This method will caused the document to be appended with the date followed by newline
53 * everytime user trying to insert a new line to the document.
54 * (Precondition : (offs >= 0) && (str != null))
55 * @param offs is the offset placted to insert the string.
56 * @param str is the string to be inserted.
57 * @param a is the attribute set to be used.
58 */
59 public void insertString(int offs, String str, AttributeSet a)
60 throws BadLocationException
61 {
62 if (str == null)
63 {
64 return;
65 }
66
67 char[] upper;
68 upper = str.toCharArray();
69
70 if (str.endsWith("\n") == true)
71 {
72 String str2;
73 str2 = str + ((new Date()).toString()) + "\n\n>";
74 upper = str2.toCharArray();
75 }
76
77 super.insertString(offs, new String(upper), a);
78 }
79 }
80}
81
82
83
84
85
Note: See TracBrowser for help on using the repository browser.