Source Code Cross Referenced for IOConsolePartition.java in  » IDE-Eclipse » ui » org » eclipse » ui » internal » console » 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 » IDE Eclipse » ui » org.eclipse.ui.internal.console 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.console;
011:
012:        import org.eclipse.jface.text.ITypedRegion;
013:        import org.eclipse.swt.custom.StyleRange;
014:        import org.eclipse.swt.graphics.Color;
015:        import org.eclipse.ui.console.ConsolePlugin;
016:        import org.eclipse.ui.console.IOConsoleInputStream;
017:        import org.eclipse.ui.console.IOConsoleOutputStream;
018:
019:        /**
020:         * A region in an IOConsole's document.
021:         * @since 3.1
022:         *
023:         */
024:        public class IOConsolePartition implements  ITypedRegion {
025:            public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin
026:                    .getUniqueIdentifier()
027:                    + ".io_console_output_partition_type"; //$NON-NLS-1$
028:            public static final String INPUT_PARTITION_TYPE = ConsolePlugin
029:                    .getUniqueIdentifier()
030:                    + ".io_console_input_partition_type"; //$NON-NLS-1$
031:
032:            /**
033:             * The data contained by this partition.
034:             */
035:            private StringBuffer buffer;
036:            private String type;
037:            private int offset;
038:            /**
039:             * Output partitions are all read only.
040:             * Input partitions are read only once they have been appended to the console's input stream.
041:             */
042:            private boolean readOnly;
043:
044:            /**
045:             * Only one of inputStream or outputStream will be null depending on the partitions type.
046:             */
047:            private IOConsoleOutputStream outputStream;
048:            private IOConsoleInputStream inputStream;
049:            private int length;
050:
051:            /**
052:             * Creates a new partition to contain output to console.
053:             */
054:            public IOConsolePartition(IOConsoleOutputStream outputStream,
055:                    int length) {
056:                this .outputStream = outputStream;
057:                this .length = length;
058:                this .type = OUTPUT_PARTITION_TYPE;
059:                this .readOnly = true;
060:            }
061:
062:            /**
063:             * Creates a new partition to contain input from a console
064:             */
065:            public IOConsolePartition(IOConsoleInputStream inputStream,
066:                    String text) {
067:                this .inputStream = inputStream;
068:                buffer = new StringBuffer(text);
069:                length = text.length();
070:                this .type = INPUT_PARTITION_TYPE;
071:                this .readOnly = false;
072:            }
073:
074:            /**
075:             * Inserts a string into this partition
076:             * @param s The string to insert
077:             * @param offset the offset in the partition
078:             */
079:            public void insert(String s, int insertOffset) {
080:                buffer.insert(insertOffset, s);
081:                length += s.length();
082:            }
083:
084:            /**
085:             * Deletes data from this partition.
086:             * @param delOffset
087:             * @param delLength
088:             */
089:            public void delete(int delOffset, int delLength) {
090:                buffer.delete(delOffset, delOffset + delLength);
091:                length -= delLength;
092:            }
093:
094:            /*
095:             *  (non-Javadoc)
096:             * @see org.eclipse.jface.text.ITypedRegion#getType()
097:             */
098:            public String getType() {
099:                return type;
100:            }
101:
102:            /*
103:             *  (non-Javadoc)
104:             * @see org.eclipse.jface.text.IRegion#getLength()
105:             */
106:            public int getLength() {
107:                return length;
108:            }
109:
110:            /*
111:             *  (non-Javadoc)
112:             * @see org.eclipse.jface.text.IRegion#getOffset()
113:             */
114:            public int getOffset() {
115:                return offset;
116:            }
117:
118:            /**
119:             * Sets this partitions offset in the document.
120:             * @param offset This partitions offset in the document.
121:             */
122:            public void setOffset(int offset) {
123:                this .offset = offset;
124:            }
125:
126:            /**
127:             * Sets this partitions length
128:             * 
129:             * @param length
130:             */
131:            public void setLength(int length) {
132:                this .length = length;
133:            }
134:
135:            /**
136:             * Returns the data contained in this partition.
137:             * @return The data contained in this partition.
138:             */
139:            public String getString() {
140:                return buffer != null ? buffer.toString() : ""; //$NON-NLS-1$
141:            }
142:
143:            /**
144:             * Returns a StyleRange object which may be used for setting the style
145:             * of this partition in a viewer.
146:             */
147:            public StyleRange getStyleRange(int rangeOffset, int rangeLength) {
148:                return new StyleRange(rangeOffset, rangeLength, getColor(),
149:                        null, getFontStyle());
150:            }
151:
152:            private int getFontStyle() {
153:                if (type.equals(INPUT_PARTITION_TYPE)) {
154:                    return inputStream.getFontStyle();
155:                }
156:                return outputStream.getFontStyle();
157:            }
158:
159:            public Color getColor() {
160:                if (type.equals(INPUT_PARTITION_TYPE)) {
161:                    return inputStream.getColor();
162:                }
163:                return outputStream.getColor();
164:            }
165:
166:            public boolean isReadOnly() {
167:                return readOnly;
168:            }
169:
170:            public void setReadOnly() {
171:                readOnly = true;
172:            }
173:
174:            public void clearBuffer() {
175:                buffer = null;
176:            }
177:
178:            IOConsoleOutputStream getStream() {
179:                return outputStream;
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.