Org. Eclipse. UI. Console Guide

Source: Internet
Author: User
From: http://blog.csdn.net/hansoft/archive/2005/07/05/415015.aspx

Org. Eclipse. UI. Console is an extensible console view plug-in that can be used to implement various consoles and display them. The plug-in itself implements a message console. For RCP applications that only require message output, its functions are sufficient:

  • Call leleplugin. getdefault (). getconsolemanager () to obtain an iconsolemanager reference.
  • Create the required messageconsole and add it to the console manager obtained in the previous step.
  • Call messageconsole. newmessagestream () to obtain the output stream connected to this console (messageconsolestream)
  • Connect
    The print and println methods of messageconsolestream are used to output messages. Of course, you need to open the console view to see
    Output, which can be opened using window/show view, or placed in the initial layout of the self-implemented perspective.

The following briefly lists the key points of its design and implementation:

  • As a general console and Its display framework, org. Eclipse. UI. Console defines the following interfaces:
    • Iconsole. It represents a console. The main method is createpage, which is used to create pages of the console in the console view.
    • Iconsole manager. It represents a console manager and manages the console.
    • Iconsolelistener. indicates a console listener, which is notified when the console is added to or deleted from the console manager.
    • Iconsoleview. It represents the console view, used to display various consoles
  • Org. Eclipse. UI. Console
    A console view is implemented by means of extension on org. Eclipse. UI. Views.
    This implementation is already quite general. Generally, you do not need to implement your own console view. Its implementation class is consoleview, which is
    Pagebookview: each console is displayed on a page. The result is the console tab we see in eclipse.
  • Console
    And pagebookview
    Page relationship. In short, it is the relationship between the model and view in MVC. The model is the console, and the page is responsible for displaying it. For textconsole
    And textconsolepage,
    This Model-View relationship is between textconsole and textconsoleviewer.
    Model-View relationships ,.
    Let's look at the implementation of the Model-View relationship between textconsole and textconsoleviewer: textconsole associates
    Consoledocument implements the idoucment interface, while
    Textconsoleviewer is a textviewer. In its constructor, set its document to
    Document (consoledocument ).
    It can be seen that the Model-View relationship between textconsole and textconsolepage is still caused by jface
    Model-View between idocument and textviewer of the text framework
    Link. The relationship between the console and its page is established through the createpage method of the iconsole, for example, textconsole
    Textconsolepage object created by createpage
    The reference of the corresponding textconsole object is saved. For messageconsole, because it does not overwrite the createpage method of ioconsole
    This creates an ioconsolepage object. Although the ioconsolepage object is saved as a textconsole reference,
    However, the actual type is messageconsole.
  • When you get the console from step 1
    When adding the console to the manager, if the eagleview has been instantiated at this time, it will be a console of the console Manager
    Listener, so it will be notified by the consolesadded event. consoleview handles this event by calling the corresponding
    The createpage method of the console creates an ipagebookviewpage and displays it. If eagleview is instantiated later, it is instantiated.
    The console manager obtains all the consoles currently in the console manager, and creates
    Ipagebookviewpage.
  • Messgaeconsole is an ioconsole, which is used to display the I/O Stream
    While ioconsole is a textconsole, textconsole is an abstract text console that supports regular expression matching and super chain
    It contains a document, which is called jface.
    The document concept in the text framework. Its implementation class is consoledocument. Messageconsole. createpage returns
    Ioconsolepage. The createcontrol method creates an ioconsoleviewer, Which is jface.
    Text Frame
    The textviewer, whose document is set as the document of the messageconsole.
    When the document changes, the textviewer on its page will reflect the change.
  • Ioconsole associates a doucment
    Partitioner (iconsoledocumentpartitioner), which is extended from
    Idocumentpartitioner. Its implementation class is ioconsolepartitioner.
    Messageconsole
    When a message is output, the message actually enters a list of messages saved in the ioconsolepartitioner. Ioconsolepartitioner implements
    One job
    Scheduling constantly checks the message list and adds the messages to the end of the document on the messageconsole.
    . If eagleview is instantiated, The messageconsole is associated with ioconsoleviewer on its page,
    Therefore, the message is displayed on the page of the console.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.