Source Code Cross Referenced for ConsoleDocumentModel.java in  » Byte-Code » PROSE » ch » ethz » prose » tools » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Byte Code » PROSE » ch.ethz.prose.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $Id: ConsoleDocumentModel.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
002:        // =====================================================================
003:        //
004:        // (history at end)
005:        //
006:
007:        package ch.ethz.prose.tools;
008:
009:        // used packages
010:        import java.io.*;
011:        import javax.swing.text.*;
012:
013:        /**
014:         * Class ConsoleDocumentModel XXX
015:         *
016:         * @version	$Revision: 1.1.1.1 $
017:         * @author	Andrei Popovici
018:         */
019:        public class ConsoleDocumentModel extends DefaultStyledDocument {
020:
021:            private static final long serialVersionUID = 3904682656649130801L;
022:            private Process currentProcess;
023:            private int maxColumn = 0;
024:            ReaderThread outputReader;
025:            ReaderThread errorReader;
026:            int rows;
027:            int columns = 80;
028:
029:            public int getRows() {
030:                return rows;
031:            }
032:
033:            public int getColumns() {
034:                return columns;
035:            }
036:
037:            protected void adjustToCurrentWidth(int crt) {
038:                if (crt > columns)
039:                    columns = crt;
040:            }
041:
042:            public void useProcessOutput(Process p) {
043:                if (outputReader != null) {
044:                    outputReader.stopReading();
045:                    // outputReader.stop();	// deprecated and not necessary
046:                }
047:                if (errorReader != null) {
048:                    errorReader.stopReading();
049:                    // errorReader.stop();	// deprecated and not necessary
050:                }
051:
052:                outputReader = new ReaderThread(this , p.getInputStream(), false);
053:                errorReader = new ReaderThread(this , p.getErrorStream(), true);
054:                outputReader.start();
055:                errorReader.start();
056:
057:            }
058:
059:            public void append(String s) {
060:                try {
061:                    insertString(getLength(), s, null);
062:                } catch (BadLocationException e1) {
063:                }
064:            }
065:
066:            static class ReaderThread extends Thread {
067:                BufferedReader toRead;
068:                //    InputStream toRead;
069:                Process proc;
070:                boolean isActive;
071:                ConsoleDocumentModel displayArea;
072:                SimpleAttributeSet attrSet;
073:
074:                ReaderThread(ConsoleDocumentModel owner, InputStream x,
075:                        boolean isErrorStream) {
076:                    this .displayArea = owner;
077:                    isActive = true;
078:                    toRead = new BufferedReader(new InputStreamReader(x));
079:                    attrSet = new SimpleAttributeSet();
080:                    if (isErrorStream)
081:                        StyleConstants.setForeground(attrSet,
082:                                java.awt.Color.red);
083:                    else
084:                        StyleConstants.setForeground(attrSet,
085:                                java.awt.Color.blue);
086:                    StyleConstants.setFontSize(attrSet, 10);
087:                }
088:
089:                public void stopReading() {
090:                    isActive = false;
091:                }
092:
093:                public void run() {
094:                    try {
095:                        try {
096:                            while (isActive) {
097:                                if (toRead.ready()) {
098:                                    String crtLine = toRead.readLine();
099:                                    displayArea.insertString(displayArea
100:                                            .getLength(), crtLine, attrSet);
101:                                    displayArea.insertString(displayArea
102:                                            .getLength(), "\n", attrSet);
103:                                    displayArea.rows++;
104:                                    displayArea.adjustToCurrentWidth(crtLine
105:                                            .length());
106:                                } else {
107:                                    try {
108:                                        sleep(5);
109:                                    } catch (InterruptedException e) {
110:                                    }
111:                                    ;
112:                                }
113:                            }
114:                        } catch (IOException e) {
115:                            e.printStackTrace();
116:                            displayArea.insertString(displayArea.getLength(),
117:                                    "\n\n", attrSet);
118:                        }
119:                    } catch (BadLocationException e1) {
120:                        e1.printStackTrace();
121:                    }
122:                }
123:
124:            };
125:
126:        }
127:
128:        //======================================================================
129:        //
130:        // $Log: ConsoleDocumentModel.java,v $
131:        // Revision 1.1.1.1  2003/07/02 15:30:52  apopovic
132:        // Imported from ETH Zurich
133:        //
134:        // Revision 1.1  2003/05/25 13:25:19  popovici
135:        // Refactoring
136:        // inf.iks.tools is now prose.tools
137:        // Stupid 'MyTableModel' renamed to 'WorksheetClientMode'
138:        // - other renamings from bad names to reasonable names
139:        //
140:        // Revision 1.1  2003/05/25 12:57:05  popovici
141:        // Initial revision
142:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.