| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
| <html xmlns:v="urn:schemas-microsoft-com:vml" | |
| xmlns:o="urn:schemas-microsoft-com:office:office" | |
| xmlns:w="urn:schemas-microsoft-com:office:word" | |
| xmlns="http://www.w3.org/TR/REC-html40"> | |
| <head> | |
| <meta name=Title content="Jabbering Consoles"> | |
| <meta name=Keywords content=""> | |
| <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> | |
| <meta name=ProgId content=Word.Document> | |
| <meta name=Generator content="Microsoft Word 11"> | |
| <meta name=Originator content="Microsoft Word 11"> | |
| <link rel=File-List href="article_files/filelist.xml"> | |
| <link rel=Edit-Time-Data href="article_files/editdata.mso"> | |
| <!--[if !mso]> | |
| <style> | |
| v\:* {behavior:url(#default#VML);} | |
| o\:* {behavior:url(#default#VML);} | |
| w\:* {behavior:url(#default#VML);} | |
| .shape {behavior:url(#default#VML);} | |
| </style> | |
| <![endif]--> | |
| <title>Jabbering Consoles</title> | |
| <!--[if gte mso 9]><xml> | |
| <o:DocumentProperties> | |
| <o:Author>Kevin Barnes</o:Author> | |
| <o:Template>Normal</o:Template> | |
| <o:LastAuthor>Kevin Barnes</o:LastAuthor> | |
| <o:Revision>2</o:Revision> | |
| <o:Created>2005-10-17T20:19:00Z</o:Created> | |
| <o:LastSaved>2005-10-18T14:34:00Z</o:LastSaved> | |
| <o:Pages>2</o:Pages> | |
| <o:Words>2204</o:Words> | |
| <o:Characters>12567</o:Characters> | |
| <o:Lines>104</o:Lines> | |
| <o:Paragraphs>25</o:Paragraphs> | |
| <o:CharactersWithSpaces>15433</o:CharactersWithSpaces> | |
| <o:Version>11.512</o:Version> | |
| </o:DocumentProperties> | |
| <o:OfficeDocumentSettings> | |
| <o:AllowPNG/> | |
| </o:OfficeDocumentSettings> | |
| </xml><![endif]--><!--[if gte mso 9]><xml> | |
| <w:WordDocument> | |
| <w:Zoom>150</w:Zoom> | |
| </w:WordDocument> | |
| </xml><![endif]--> | |
| <link rel=Stylesheet type="text/css" media=all | |
| href="file://localhost/Users/kevinbarnes/Eclipse/workspace/platform-debug-home/articles/ConsoleExample/default_style.css"> | |
| <link rel=Stylesheet type="text/css" media=all | |
| href="file://localhost/Users/kevinbarnes/Eclipse/workspace/platform-debug-home/articles/ConsoleExample/default_style.css"> | |
| <style> | |
| <!-- | |
| <link rel=Stylesheet type="text/css" media=all | |
| href="file://localhost/Users/kevinbarnes/Eclipse/workspace/platform-debug-home/articles/ConsoleExample/default_style.css"> | |
| <link rel=Stylesheet type="text/css" media=all | |
| href="file://localhost/Users/kevinbarnes/Eclipse/workspace/platform-debug-home/articles/ConsoleExample/default_style.css"> | |
| /* Font Definitions */ | |
| @font-face | |
| {font-family:"Times New Roman"; | |
| panose-1:0 2 2 6 3 5 4 5 2 3; | |
| mso-font-charset:0; | |
| mso-generic-font-family:auto; | |
| mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} | |
| @font-face | |
| {font-family:Arial; | |
| panose-1:0 2 11 6 4 2 2 2 2 2; | |
| mso-font-charset:0; | |
| mso-generic-font-family:auto; | |
| mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} | |
| @font-face | |
| {font-family:"Courier New"; | |
| panose-1:0 2 7 3 9 2 2 5 2 4; | |
| mso-font-charset:0; | |
| mso-generic-font-family:auto; | |
| mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} | |
| @font-face | |
| {font-family:Verdana; | |
| panose-1:0 2 11 6 4 3 5 4 4 2; | |
| mso-font-charset:0; | |
| mso-generic-font-family:auto; | |
| mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} | |
| /* Style Definitions */ | |
| p.MsoNormal, li.MsoNormal, div.MsoNormal | |
| {mso-style-parent:""; | |
| margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| font-size:10.0pt; | |
| font-family:Times;} | |
| h1 | |
| {margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| mso-outline-level:1; | |
| font-size:28.0pt; | |
| font-family:Arial; | |
| mso-font-kerning:18.0pt; | |
| font-weight:bold;} | |
| h2 | |
| {margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-line-height-alt:14.0pt; | |
| mso-pagination:widow-orphan; | |
| mso-outline-level:2; | |
| font-size:18.0pt; | |
| font-family:Arial; | |
| font-weight:bold;} | |
| h3 | |
| {margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| mso-outline-level:3; | |
| font-size:14.0pt; | |
| font-family:Arial; | |
| font-weight:bold;} | |
| a:link, span.MsoHyperlink | |
| {color:blue; | |
| text-decoration:underline; | |
| text-underline:single;} | |
| a:visited, span.MsoHyperlinkFollowed | |
| {color:purple; | |
| text-decoration:underline; | |
| text-underline:single;} | |
| p | |
| {margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| font-size:10.0pt; | |
| font-family:Arial;} | |
| code {} | |
| pre | |
| {margin:0in; | |
| margin-bottom:.0001pt; | |
| mso-pagination:widow-orphan; | |
| tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; | |
| font-size:10.0pt; | |
| font-family:"Courier New";} | |
| table.MsoNormalTable | |
| {mso-style-parent:""; | |
| font-size:10.0pt; | |
| font-family:"Times New Roman";} | |
| p.indextop, li.indextop, div.indextop | |
| {mso-style-name:indextop; | |
| margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| font-size:24.0pt; | |
| font-family:Verdana; | |
| font-weight:bold;} | |
| p.indexsub, li.indexsub, div.indexsub | |
| {mso-style-name:indexsub; | |
| margin-right:0in; | |
| mso-margin-top-alt:auto; | |
| mso-margin-bottom-alt:auto; | |
| margin-left:0in; | |
| mso-pagination:widow-orphan; | |
| font-size:7.5pt; | |
| font-family:Arial; | |
| color:#8080FF;} | |
| @page Section1 | |
| {size:8.5in 11.0in; | |
| margin:1.0in 1.25in 1.0in 1.25in; | |
| mso-header-margin:.5in; | |
| mso-footer-margin:.5in; | |
| mso-paper-source:0;} | |
| div.Section1 | |
| {page:Section1;} | |
| --> | |
| </style> | |
| <!--[if gte mso 9]><xml> | |
| <o:shapedefaults v:ext="edit" spidmax="1027"/> | |
| </xml><![endif]--><!--[if gte mso 9]><xml> | |
| <o:shapelayout v:ext="edit"> | |
| <o:idmap v:ext="edit" data="1"/> | |
| </o:shapelayout></xml><![endif]--> | |
| </head> | |
| <body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'> | |
| <div class=Section1> | |
| <p class=MsoNormal>/* Font Definitions */ @font-face {font-family:"Times | |
| New Roman"; panose-1:0 2 2 6 3 5 4 5 2 3; mso-font-charset:0; | |
| mso-generic-font-family:auto; mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} @font-face {font-family:Arial; panose-1:0 | |
| 2 11 6 4 2 2 2 2 2; mso-font-charset:0; mso-generic-font-family:auto; | |
| mso-font-pitch:variable; mso-font-signature:50331648 0 0 0 1 0;} @font-face | |
| {font-family:"Courier New"; panose-1:0 2 7 3 9 2 2 5 2 4; | |
| mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} @font-face {font-family:Verdana; | |
| panose-1:0 2 11 6 4 3 5 4 4 2; mso-font-charset:0; | |
| mso-generic-font-family:auto; mso-font-pitch:variable; | |
| mso-font-signature:50331648 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, | |
| li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin-right:0in; | |
| mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; | |
| mso-pagination:widow-orphan; font-size:10.0pt; font-family:Times;} a:link, | |
| span.MsoHyperlink {color:blue; text-decoration:underline; | |
| text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; | |
| text-decoration:underline; text-underline:single;} p {font-size:10.0pt; | |
| font-family:Times;} code {} pre {margin:0in; margin-bottom:.0001pt; font-size:10.0pt; | |
| font-family:Times;} table.MsoNormalTable {mso-style-parent:""; | |
| font-size:10.0pt; font-family:"Times New Roman";} p.indextop, | |
| li.indextop, div.indextop {mso-style-name:indextop; font-size:24.0pt; | |
| font-family:Times;} p.indexsub, li.indexsub, div.indexsub | |
| {mso-style-name:indexsub; font-size:7.5pt; font-family:Times;} @page Section1 | |
| {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; | |
| mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} | |
| --> </p> | |
| <p class=MsoNormal align=right style='margin-top:0in;margin-right:0in; | |
| margin-bottom:0in;margin-left:17.0pt;margin-bottom:.0001pt;text-align:right'><span | |
| style='font-family:Arial'> </span><span style='font-family:"Times New Roman"'>© | |
| Copyright International Business Machines Corporation, 2004. All rights | |
| reserved</span><span style='font-family:Arial'> <o:p></o:p></span></p> | |
| <div align=right> | |
| <table border=0 cellspacing=0 cellpadding=0 width="100%" style='width:100.0%; | |
| mso-cellspacing:0in;margin-left:17.0pt;mso-padding-alt:2.0pt 2.0pt 2.0pt 2.0pt'> | |
| <tr> | |
| <td valign=top style='background:#0080C0;padding:2.0pt 2.0pt 2.0pt 2.0pt'> | |
| <p class=MsoNormal style='margin:0in;margin-bottom:.0001pt'><span | |
| style='font-family:Arial;color:white'><b> Eclipse Corner Article</b></span><span | |
| style='font-family:Arial'><o:p></o:p></span></p> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| <h1 style='margin-left:17.0pt'><img width=120 height=86 id="_x0000_i1025" | |
| src="../../images/article_images/Idea.jpg" align=middle></h1> | |
| <h1 align=center style='margin-left:17.0pt;text-align:center'><br> | |
| Jabbering Consoles</h1> | |
| <p class=MsoNormal style='margin-right:.5in;margin-left:53.0pt'><span | |
| style='font-family:Arial'><b>Summary</b></span><span style='font-family:Arial'> | |
| <br> | |
| Traditionally, consoles are used to display output and provide input to | |
| programs. The console plug-in in the Eclipse SDK provides a flexible framework | |
| for building text based consoles complete with pattern matching and hyperlink | |
| support, and also clients to provide arbitrary implementations of consoles with | |
| custom presentations. This article showcases the console framework in Eclipse | |
| with an example implementation of a console that supports instant messaging. <o:p></o:p></span></p> | |
| <p style='margin-right:.5in;margin-left:53.0pt'><b>By Darin Wright, IBM | |
| Rational Software Group<br> | |
| Kevin Barnes, IBM Rational Software Group</b><span style='font-weight:normal'><br> | |
| </span><span style='font-size:7.5pt'>November 5, 2004</span> <o:p></o:p></p> | |
| <div class=MsoNormal align=center style='margin-top:0in;margin-right:0in; | |
| margin-bottom:0in;margin-left:17.0pt;margin-bottom:.0001pt;text-align:center'><span | |
| style='font-family:Arial'> | |
| <hr size=2 width="100%" align=center> | |
| </span></div> | |
| <h2 style='margin-left:17.0pt'>Introduction</h2> | |
| <p style='margin-left:17.0pt'>The org.eclipse.ui.console plug-in provides a | |
| framework for building and managing consoles. A console view displays all registered | |
| consoles. Each console is displayed by a page within the console view, and a | |
| console may be visible in any number of console views at any given time. A | |
| console manager maintains the currently registered set of consoles, and | |
| provides notification when consoles are added and removed. All consoles | |
| registered with the manager are displayed in the console view.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>An extensible implementation of text based | |
| consoles is provided by the console plug-in. A text console maintains a | |
| partitionable document supporting regular expression matching and hyperlinks. | |
| The most general text console is used for displaying and editing a document. | |
| For example, the Java Stack Trace Console contributed by the Java debugger is a | |
| text console that supports pasting and navigating stack traces. The more | |
| specialized I/O console is used to display read-only output streams and | |
| provides an input stream that accepts input from the keyboard. For example, | |
| when an application is launched from Eclipse, an I/O console is used to display | |
| its standard output and error streams and provide input to its standard input | |
| stream.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>[insert image: the console view]<o:p></o:p></p> | |
| <h3 style='margin-left:17.0pt'>Basic API</b></h2> | |
| <p style='margin-left:17.0pt'>The first thing that users think of when the | |
| console is mention is the Console View. This view is a <span style='font-family: | |
| "Courier New"'>PageBookView</span> that contains a page for every console | |
| registered with the console manager. The Console View is an implementation of <span | |
| style='font-family:"Courier New"'>IConsoleView</span> and clients may interact | |
| with the view to manage the features provided by the view such as displaying a | |
| specific console, pinning a console on top of other pages, and turn scroll lock | |
| on or off. Consoles are never added directly to a Console View, instead a | |
| Console View contains all consoles that have been added to the console manager.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>The console managerÂ’s API is defined by <span | |
| style='font-family:"Courier New"'>IConsoleManager</span>, a singleton manager | |
| class available from the <span style='font-family:"Courier New"'>ConsolePlugin</span> | |
| class via <span style='font-family:"Courier New"'>ConsolePlugin.getDefault().getConsoleManager()</span>. | |
| All consoleÂ’s added to a console manager will be displayed in all Console Views.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Every console implements <span style='font-family: | |
| "Courier New"'>IConsole</span>, providing a name, and an optional image and | |
| type. The console plug-in provides an abstract base class that all console | |
| implementations are intended to subclass - <span style='font-family:"Courier New"'>AbstractConsole</span>. | |
| The base class provides an implementation of function common to consoles: | |
| getters, setters, and change notification for name, image, and type attributes; | |
| infrastructure for adding and removing property change listeners and firing | |
| property change notification; and lifecycle methods for initialization and | |
| cleanup (<span style='font-family:"Courier New"'>init()</span> and <span | |
| style='font-family:"Courier New"'>dispose()</span>) that can be specialized in | |
| subclasses. Two subclasses of AbstractConsole are also provided by the console | |
| plugin. <span style='font-family:"Courier New"'>TextConsole</span> does | |
| hyperlinking and regular expression pattern matching, and <span | |
| style='font-family:"Courier New"'>IOConsole</span> which additionally provides | |
| a document partitioner and streams for interacting with the console.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>The streams provided by <span style='font-family: | |
| "Courier New"'>IOConsole</span> are regular java.io streams, but also allow you | |
| to set some stream specific attributes such as color and font style. The <span | |
| style='font-family:"Courier New"'>IOConsoleOutputStream</span> also allows | |
| clients to specify whether the console should be activated when the stream is | |
| written to.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Page participants (<span style='font-family:"Courier New"'>IConsolePageParticipant</span>) | |
| can be selectively contributed to text consoles via the <span style='font-family: | |
| "Courier New"'>consolePageParticipants</span> extension point. A page | |
| participant can add actions to the console tool bar and context menu, provide | |
| adapters for the page, and implement custom function for the page. For example, | |
| the Java Stack Trace Console previously mentioned, contributes a page | |
| participant that adds Format and Close actions to the console tool bar.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Pattern matchers can also be contributed to text | |
| consoles selectively via the <span style='font-family:"Courier New"'>consolePatternMatchListeners</span> | |
| extension point, or they can be programmatically added (<span style='font-family: | |
| "Courier New"'>TextConsole.addPatternMatchListener(IPatternMatchListener)</span>). | |
| The most common use of pattern matching is to add hyperlinks (<span | |
| style='font-family:"Courier New"'>IHyperlink</span>) to a text console.<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>Instant messaging</h2> | |
| <p style='margin-left:17.0pt'><Overview of the parts of our example: a | |
| console to send/receive messages and file transfer, a buddy list. Built using | |
| Jabber/Smack.><br> | |
| Instant messaging has become an integral part of every day communication for | |
| many of us. Many messaging protocols and applications exist, but all share the | |
| same basic functionality - creation of a buddy list that informs us of our | |
| contacts availability, and ability to communicate with our buddies in real-time | |
| when they are available. The purpose of this article is to demonstrate how a | |
| simple instant messaging plug-in can be written quickly for Eclipse using | |
| Eclipse consoles and the Jabber protocols. <o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Jabber is an open set of protocols and | |
| technologies that allow for the exchange of messages, presence, and other | |
| structured information in close to real time. The Internet Engineering Task | |
| Force (IETF) has formalized the core set of jabber's protocols as an approved | |
| instant messaging and presence technology called Extensible Messaging and | |
| Presence Protocol (XMPP). Jive Software has developed an open source XMPP | |
| client library called Smack that we will be using to build our application.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>When complete, our plug-in will consist of a new | |
| Buddy List view and will reuse existing consoles to send and receive messages.<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>The Supporting cast</h2> | |
| <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; | |
| margin-left:17.0pt;margin-bottom:.0001pt'><span style='font-family:Arial'><>Before | |
| jumping into the console itself it's necessary to spend some time discussing a | |
| few other classes that allow us to have a functioning chat client.<br> | |
| <br> | |
| As with any chat application it's necessary to have a connection to a server | |
| before any messages can be sent or received. In this plug-in it is the | |
| ChatManager that is responsible for managing that connection. The ChatManager | |
| is an f<br> | |
| The central character is of course the connection to the server. Overview of | |
| the chat manager, chat session, and buddy view<br> | |
| Chat Manager<br> | |
| - the brains of the operation.<br> | |
| - Manages the connection (does the login, listens for incoming messages, and | |
| creates chat sessions)<br style='mso-special-character:line-break'> | |
| <![if !supportLineBreakNewLine]><br style='mso-special-character:line-break'> | |
| <![endif]><o:p></o:p></span></p> | |
| </> | |
| <p style='margin-left:17.0pt'>Chat Session<br> | |
| - creates and manages a chat console (displays messages as they are received | |
| from other chat participants, reads from the console's input stream and sends | |
| messages to the other participant)<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>RosterView<br> | |
| - I should probably just call this Buddy View for clarity. <br> | |
| - Tree Viewer. Displays Buddy groups, buddies and their current precence.<br> | |
| - Does it allow you to add buddies/groups? It should.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Login Dialog<br> | |
| - allows login and register. Explain register... most users probably won't have | |
| a jabber screen name. <o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>The chat console</h2> | |
| <p style='margin-left:17.0pt'>Since the purpose of this article is really to demonstrate | |
| how the Eclipse Console Framework makes some task very simple, our chat | |
| application is going to be console based. The framework does a few things to | |
| make our lives easier. It provides a common view that will display all of our | |
| consoles for us, it provides generic and reusable base implemenations of | |
| consoles that cna be used as is, and it provides the necessary API to allow for | |
| the creation of custom consoles. Anyone wishing to implement a Text based | |
| console should consider using or extending the base implementions - Text | |
| Console and IOConsole (for stream based consoles) - provided by the framework.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>For each chat session we'll be using an IOConsole | |
| as is. The functionality provided by the base console is enough to do what we | |
| require for demonstration purposed. Creating a console is simple and done by | |
| the constructor of ChatSession:<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'><code> fConsole = new IOConsole("Chat: | |
| " + fChat.getParticipant(), "Chat", null); </code><o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Adding the console to the view is done later in | |
| the same constructor. It's as simple as adding the console to the | |
| IConsoleManager provided by the console plugin:<br> | |
| <code> <br> | |
| IConsoleManager consoleManager = | |
| ConsolePlugin.getDefault().getConsoleManager();<br> | |
| consoleManager.addConsoles(new | |
| IConsole[] { fConsole });<br> | |
| </code><o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Every IOConsole is stream based, we can write to | |
| the console by creating an IOConsoleOutputStream <br> | |
| <code>fConsole.newOutputStream();<code><br> | |
| and using its write() methods.<o:p></o:p></p> | |
| <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; | |
| margin-left:17.0pt;margin-bottom:.0001pt'><span style='font-family:Arial'><>IOConsole | |
| allows you to create as many IOConsoleOutputStreams as you need.It also allows | |
| for each stream to be presented uniquely in the console with methods such as | |
| setFontStyle(int newFontStyle), and setColor(Color color). It also allow you to | |
| decide whether or not the ConsoleView should be "activated" when the | |
| stream is used. Explain activation quickly now. For our demo we only need one | |
| output stream, but we will change it's color to differentiated messages we send | |
| from those that we receive. Remember that accessing you need to use the UI | |
| thread to access system colors. The code looks like this:<br> | |
| <code><br> | |
| final Display display = ChatPlugin.getStandardDisplay();<br> | |
| display.asyncExec(new Runnable() {<br> | |
| public void | |
| run() {<br> | |
| | |
| fIn.setColor(display.getSystemColor(SWT.COLOR_DARK_BLUE));<br> | |
| | |
| out.setColor(display.getSystemColor(SWT.COLOR_DARK_RED));<br> | |
| | |
| out.setActivateOnWrite(true);<br> | |
| }<br> | |
| });<br> | |
| fOut = new PrintStream(out); // for | |
| convenience<br> | |
| </code><br> | |
| <br> | |
| This output stream will be used to write messages that we receive to our | |
| console, but we also want to be able to send messages. For this we'll need to | |
| use the IOConsoleInputStream provided by the IOConsole. IOConsole only provides | |
| one input stream via the getInputStream() method. The IOConsoleInputStream is | |
| very similar to the related output stream. Anything that the user types into | |
| the console will be accessible via the streams read() methods once the user | |
| hits "enter". We'll start a thread to read from the input stream, and | |
| send each message as it's entered. Our thread will do the following.<br> | |
| <code><br> | |
| int read = | |
| 0;<br> | |
| byte[] bytes | |
| = new byte[1024];<br> | |
| try {<br> | |
| | |
| while (!fKilled && read >= 0) {<br> | |
| | |
| read = fIn.read(bytes);<br> | |
| | |
| if (read > 0)<br> | |
| | |
| fChat.sendMessage(new String(bytes, 0, read));<br> | |
| | |
| }<br> | |
| } catch | |
| (IOException e) {<br> | |
| | |
| e.printStackTrace();<br> | |
| } catch | |
| (XMPPException e) {<br> | |
| | |
| e.printStackTrace();<br> | |
| }<br> | |
| close();<br> | |
| </code><br> | |
| <br> | |
| With very little code we have been able to create and display a new console | |
| that is able to display messages from other users and respond to them.<o:p></o:p></span></p> | |
| <h2 style='margin-left:17.0pt'>Pattern matching and hyperlinks</h2> | |
| <p style='margin-left:17.0pt'>Use pattern matching to find URLs, add hyperlinks | |
| for URLs, also add hyperlinks to use name for "add user".<br> | |
| Explain the console pattern matching with URL example. <br> | |
| Walk through add user enough to show that pattern matchers can be added | |
| programmatically.<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>The page participant</h2> | |
| <p style='margin-left:17.0pt'>Adds action for file transfer, and pattern | |
| matching for painting a smily face<br> | |
| - Actually does none of the above. Only adds remove console to the tool bar.<br> | |
| - Avoid discussing command/context stuff here. Too messy. If anyone asks give | |
| them Doug's email address and home phone number.<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>The console factory</h2> | |
| <p style='margin-left:17.0pt'>a factory to open a chat session<br> | |
| Pretty simple stuff. screen shots and code. not too much explanation | |
| needed. Maybe talk about other console factories??<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>Other stuff?</h2> | |
| <p style='margin-left:17.0pt'>tip: to warn of content change in a console<br> | |
| </p> | |
| <h2 style='margin-left:17.0pt'>Summary and further information</h2> | |
| <p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in; | |
| margin-left:17.0pt;margin-bottom:.0001pt'><span style='font-family:Arial'>Stress | |
| resusable, extensible, simple... themes Built to last and Ease of Use. Show | |
| that we make people's lives easy.<br> | |
| The Eclipse platform provides a very powerful framework that enables.<br> | |
| jabber.org link for XMPP information<br> | |
| Jive Software (Smack) http://www.jivesoftware.org/smack/<o:p></o:p></span></p> | |
| <h2 style='margin-left:17.0pt'>Acknowledgements</h2> | |
| <p style='margin-left:17.0pt'>Thanks to people for their careful reviews and | |
| critiques that have improved this paper.<o:p></o:p></p> | |
| <h2 style='margin-left:17.0pt'>Source code</h2> | |
| <p style='margin-left:17.0pt'><img width=61 height=13 id="_x0000_i1027" | |
| src="../../images/article_images/tryit.gif">To examine the entire source code, or to run the | |
| example, download the <a href="pda-plugins.zip">zip file</a> and unzip it into | |
| your Eclipse directory. The plug-in comes with complete source code. This | |
| article describes, and the included code requires, features that are available | |
| in Eclipse 3.1 M3 or a later version.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'><b>Trademarks</b><span style='font-weight:normal'><o:p></o:p></span></p> | |
| <p style='margin-left:17.0pt'>IBM and Rational are registered trademarks of | |
| International Business Machines Corporation in the United States, other | |
| countries, or both.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Linux is a trademark of Linus Torvalds in the | |
| United States, other countries, or both.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Microsoft and Windows are trademarks of Microsoft | |
| Corporation in the United States, other countries, or both.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Java and all Java-based trademarks are trademarks | |
| of Sun Microsystems, Inc. in the United States, other countries, or both.<o:p></o:p></p> | |
| <p style='margin-left:17.0pt'>Other company, product, and service names may be | |
| trademarks or service marks of others.<o:p></o:p></p> | |
| </div> | |
| </body> | |
| </html> |