<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    子非魚

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      21 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

    參考:http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg01745.html
    在非Editor中實(shí)現(xiàn)syntax coloring


    Rainer wrote:
    I hope this is the right place to ask this question:

    It's fine; eclipse.platform would have been right as well.

    I am working on a simple XML editing rich client. One of the main components is a JFace TextViewer, embedded in an Eclipse view (I can't use an Eclipse editor in my special case, unfortunately). I want to add syntax coloring, but can't seem to get the presentation reconciler to work.

    Here's the sample code:

    [...]

    reconciler= new PresentationReconciler();
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new CodeRuleScanner());
    dr.setDocument(viewer.getDocument());
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.install(viewer);


    [..]

    The CodeRuleScanner (extends RuleBasedScanner) is configured with a set of rules and a default token. However, the PresentationReconciler seems to be totally inactive. Is there any further configuration necessary?

    No. If you look at the implementation of PresentationReconciler.install, you will see that it waits until the viewer's document is set (via an ITextInputListener). So, in order for the above to work, you have to set the document *after* installing the reconciler.


    You should also look at SourceViewer that adds more features and configures itself in the right order using a SourceViewerConfiguration.

    HTH, tom
     
    正確的做法:
     
    PresentationReconciler reconciler= new PresentationReconciler();
            DefaultDamagerRepairer dr 
    = new DefaultDamagerRepairer(new PolicyCodeScanner(new ColorProvider()));
            
            reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
            reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
            reconciler.install(sourceViewer);
    //PresentationReconciler.install必須在setDoucument之前,切記
            
            
    //設(shè)置字體
            sourceViewer.getTextWidget().setFont(new Font(sourceViewer.getControl().getDisplay(), 
                    
    new FontData("Courier"10, SWT.NORMAL)));
            
    //設(shè)置當(dāng)前編輯行的背景色
            CursorLinePainter painter= new CursorLinePainter(sourceViewer);
            painter.setHighlightColor(yellow);
            sourceViewer.addPainter(painter);
            
            
    //設(shè)置文檔幫助
            final ContentAssistant assistant = new ContentAssistant();
            assistant.setContentAssistProcessor(
    new PolicyContentAssistProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
            assistant.install(sourceViewer);
            
            
    //設(shè)置文本內(nèi)容
            sourceViewer.setDocument(new Document(this.content));
            
            dr.setDocument(sourceViewer.getDocument());
            
     
      
    另外:
    注入config:

    sourceViewer.configure(SourceViewerConfiguration configuration)


     

    posted on 2007-07-24 16:34 子非魚 閱讀(408) 評論(0)  編輯  收藏 所屬分類: eclipse
    主站蜘蛛池模板: 国产人成网在线播放VA免费| 亚洲AV成人精品日韩一区| 久久一区二区三区免费| 无码欧精品亚洲日韩一区夜夜嗨| 国产精品亚洲四区在线观看| 免费观看黄色的网站| 亚洲午夜一区二区电影院| 日韩不卡免费视频| 日本亚洲精品色婷婷在线影院| 免费无码AV电影在线观看| 亚洲sm另类一区二区三区| 日本免费人成视频播放| 污网站免费在线观看| 亚洲综合伊人久久综合| 99视频在线免费看| 亚洲成a人片在线观看播放| 国语成本人片免费av无码 | 色播在线永久免费视频| 色偷偷尼玛图亚洲综合| 亚洲熟妇少妇任你躁在线观看无码| 一本大道一卡二大卡三卡免费| 亚洲国产另类久久久精品小说| 亚洲免费精彩视频在线观看| 亚洲一区二区三区亚瑟| 国产hs免费高清在线观看| 波霸在线精品视频免费观看| 亚洲精品视频久久| 国产一级一片免费播放| a毛片免费全部播放完整成| 久久精品国产亚洲av麻豆小说 | 国产成人精品日本亚洲专区6| 成在线人永久免费视频播放| 亚洲精品黄色视频在线观看免费资源 | 四虎免费永久在线播放| a级特黄毛片免费观看| 亚洲fuli在线观看| 全亚洲最新黄色特级网站| 久久久久久一品道精品免费看 | 一个人看的hd免费视频| 亚洲精品国产第1页| 免费中文字幕在线观看|