1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
/* */ package NET.worlds.console;
/* */
/* */ import NET.worlds.core.IniFile;
/* */ import java.awt.AWTEvent;
/* */ import java.awt.Component;
/* */ import java.awt.event.FocusEvent;
/* */ import java.io.BufferedReader;
/* */ import java.io.File;
/* */ import java.io.FileNotFoundException;
/* */ import java.io.FileReader;
/* */ import java.io.FileWriter;
/* */ import java.io.IOException;
/* */ import java.io.PrintStream;
/* */ import java.io.PrintWriter;
/* */ import java.text.DateFormat;
/* */ import java.util.Date;
/* */ import java.util.Observer;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ class NewSharedTextArea
/* */ extends GammaTextArea
/* */ implements SharedTextArea
/* */ {
/* */ private static final long serialVersionUID = 6732411958099438561L;
/* */ private static String sharedText;
/* */ private boolean isShared;
/* */ private String unsharedText;
/* 138 */ private String unaddedText = null;
/* */
/* */
/* */ private PrintWriter logFile;
/* */
/* */ private String logFileName;
/* */
/* */ private static final long oneMeg = 1048576L;
/* */
/* */ private static final long logLengthLimit = 524288L;
/* */
/* */
/* */ public NewSharedTextArea(int rows, int cols, boolean isShared)
/* */ {
/* 152 */ super("", rows, cols, 2);
/* 153 */ this.isShared = isShared;
/* 154 */ setEditable(false);
/* */ }
/* */
/* */
/* */ public void finalize()
/* */ {
/* 160 */ disableLogging();
/* */ }
/* */
/* */ public Component getComponent()
/* */ {
/* 165 */ return this;
/* */ }
/* */
/* */ public synchronized void validate()
/* */ {
/* 170 */ super.validate();
/* 171 */ String text = this.isShared ? sharedText : this.unsharedText;
/* 172 */ if (text != null)
/* */ {
/* */
/* 175 */ setText(text);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public synchronized void enableLogging(String fileName, String title, boolean append)
/* */ {
/* 192 */ if (this.logFile != null)
/* */ {
/* 194 */ if (this.logFileName.equals(fileName)) {
/* 195 */ return;
/* */ }
/* 197 */ this.logFile.close();
/* */ }
/* */ try {
/* 200 */ if ((append) && (new File(fileName).exists())) {
/* 201 */ truncateIfExceeds(fileName, title, 524288L);
/* 202 */ this.logFile = new PrintWriter(new FileWriter(fileName, true));
/* */ } else {
/* 204 */ this.logFile = new PrintWriter(new FileWriter(fileName, false));
/* 205 */ obsLogFile.setChanged(true);
/* 206 */ this.logFile.println("<html>");
/* 207 */ this.logFile.println("<head>");
/* 208 */ this.logFile.println("<title>" + title + "</title>");
/* 209 */ this.logFile.println("</head>");
/* 210 */ this.logFile.println("<body>");
/* */ }
/* 212 */ this.logFileName = fileName;
/* 213 */ this.logFile.println("<hr>");
/* 214 */ this.logFile.println("<h3>Conversation of " +
/* 215 */ DateFormat.getDateTimeInstance().format(new Date()) +
/* 216 */ "</h3>");
/* 217 */ this.logFile.flush();
/* 218 */ obsLogFile.notifyObservers(this);
/* */ } catch (IOException ex) {
/* 220 */ System.out.println("Log file not opened: " + ex);
/* */ }
/* */ }
/* */
/* */
/* 225 */ private static PublicObservable obsLogFile = new PublicObservable();
/* */
/* */
/* */
/* */
/* */ public static void addLogObserver(Observer o)
/* */ {
/* 232 */ obsLogFile.addObserver(o);
/* */ }
/* */
/* */ public static void deleteLogObserver(Observer o)
/* */ {
/* 237 */ obsLogFile.deleteObserver(o);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void truncateIfExceeds(String fileName, String title, long lengthLimit)
/* */ {
/* 247 */ File f = new File(fileName);
/* 248 */ if (f.length() > lengthLimit) {
/* 249 */ File tf = new File(fileName + ".temp");
/* */
/* */ try
/* */ {
/* 253 */ BufferedReader in = new BufferedReader(new FileReader(f));
/* 254 */ PrintWriter out = new PrintWriter(new FileWriter(tf));
/* 255 */ out.println("<html>");
/* 256 */ out.println("<head>");
/* 257 */ out.println("<title>" + title + "</title>");
/* 258 */ out.println("</head>");
/* 259 */ out.println("<body>");
/* 260 */ in.skip(f.length() - lengthLimit / 2L);
/* 261 */ String line = in.readLine();
/* 262 */ line = in.readLine();
/* 263 */ while (line != null) {
/* 264 */ out.println(line);
/* 265 */ line = in.readLine();
/* */ }
/* 267 */ in.close();
/* 268 */ out.close();
/* */
/* */
/* 271 */ f.delete();
/* 272 */ f = new File(fileName);
/* 273 */ tf.renameTo(f);
/* */ } catch (FileNotFoundException ex) {
/* 275 */ System.out.println("DuplexPart fatal: " + ex);
/* */ } catch (IOException ex) {
/* 277 */ System.out.println("DuplexPart: Unable to write, " + ex);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */ public synchronized void disableLogging()
/* */ {
/* 285 */ if (this.logFile != null) {
/* 286 */ this.logFile.close();
/* 287 */ this.logFile = null;
/* */ }
/* */ }
/* */
/* 291 */ private static int autoScrollLimit = IniFile.gamma().getIniInt("AutoScrollLimit", 0);
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public boolean canAddText()
/* */ {
/* 302 */ if (getText().length() < 3) {
/* 303 */ return true;
/* */ }
/* */
/* */
/* 307 */ if ((autoScrollLimit > 0) && (autoScrollLimit < this.unaddedText.length())) {
/* 308 */ return true;
/* */ }
/* 310 */ return isLastLineVisible();
/* */ }
/* */
/* 313 */ public static int chatLengthLimit = IniFile.gamma().getIniInt("ChatLengthLimit", 20000);
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public synchronized void println(String msg)
/* */ {
/* 323 */ if ((this.logFile != null) && (msg != null)) {
/* 324 */ this.logFile.println(DuplexPart.toHtml(msg) + "<br>");
/* 325 */ this.logFile.flush();
/* */ }
/* */
/* */
/* */
/* */
/* 331 */ if (this.unaddedText == null) {
/* 332 */ this.unaddedText = msg;
/* 333 */ } else if (msg != null) {
/* 334 */ this.unaddedText = (this.unaddedText + "\n" + msg);
/* */ }
/* 336 */ if ((this.unaddedText == null) || (!canAddText())) {
/* 337 */ return;
/* */ }
/* 339 */ if (getText().length() == 0) {
/* 340 */ append(this.unaddedText);
/* */ } else
/* 342 */ append("\n" + this.unaddedText);
/* 343 */ this.unaddedText = null;
/* */
/* */
/* 346 */ String text = getText();
/* 347 */ if (text.length() > chatLengthLimit) {
/* 348 */ int linePos = text.indexOf('\n', chatLengthLimit / 2 - 80);
/* 349 */ if (linePos >= 0) {
/* 350 */ text = text.substring(linePos + 1);
/* */
/* */
/* 353 */ linePos = text.lastIndexOf('\n');
/* 354 */ if (linePos > 0) {
/* 355 */ setText(text.substring(0, linePos));
/* 356 */ append(text.substring(linePos));
/* */ }
/* */ }
/* */ }
/* 360 */ if (this.isShared) {
/* 361 */ sharedText = text;
/* */ } else {
/* 363 */ this.unsharedText = text;
/* */ }
/* 365 */ repaint();
/* */ }
/* */
/* */
/* */ public synchronized void scrollToBottom()
/* */ {
/* 371 */ String text = getText();
/* 372 */ setText("");
/* 373 */ append(text);
/* 374 */ repaint();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ protected void processFocusEvent(FocusEvent e)
/* */ {
/* 384 */ super.processFocusEvent(e);
/* */ }
/* */
/* */ protected void processEvent(AWTEvent e)
/* */ {
/* 389 */ poll();
/* */
/* 391 */ super.processEvent(e);
/* */ }
/* */
/* */
/* */ public synchronized void poll()
/* */ {
/* 397 */ if (this.unaddedText != null) {
/* 398 */ println(null);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */ public boolean isFocusTraversable()
/* */ {
/* 407 */ return false;
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\NewSharedTextArea.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|