Changeset 1857


Ignore:
Timestamp:
03/17/14 00:13:56 (11 years ago)
Author:
masberg
Message:

Fix so that if there is only a single completion proposal, it is inserted automatically.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/editor/ModelicaSourceViewerConfig.java

    r1127 r1857  
    22 * @author Adrian Pop
    33 * Copyright (c) 2006 Adrian Pop, adrpo@ida.liu.se
    4  * All rights reserved. 
     4 * All rights reserved.
    55 * Permission to use, copy, modify, and distribute this software and
    6  * its documentation for NON-COMMERCIAL purposes and without fee is hereby 
    7  * granted, provided that this copyright notice appear in all copies and 
     6 * its documentation for NON-COMMERCIAL purposes and without fee is hereby
     7 * granted, provided that this copyright notice appear in all copies and
    88 * that both the copyright notice and this permission notice and warranty
    99 * disclaimer appear in supporting documentation, and that the name of
    1010 * The Author not be used in advertising or publicity pertaining to
    1111 * distribution of the software without specific, written prior permission.
    12  * 
    13  * COMMERCIAL use, copy, modification and distribution 
     12 *
     13 * COMMERCIAL use, copy, modification and distribution
    1414 * is NOT permitted without prior agreement with Adrian Pop.
    15  * 
     15 *
    1616 * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
    1717 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
     
    6666
    6767/**
    68  * 
     68 *
    6969 * @author Adrian Pop
    7070 *   - big changes, splited scanners for different partitions, etc
    7171 */
    72 public class ModelicaSourceViewerConfig extends TextSourceViewerConfiguration 
    73 {   
     72public class ModelicaSourceViewerConfig extends TextSourceViewerConfiguration
     73{
    7474    private ModelicaCodeScanner              fCodeScanner;              /* for code parts and strings */
    7575    private ModelicaMultilineCommentScanner  fMultilineCommentScanner;  /* for C comments */
    7676    private ModelicaSinglelineCommentScanner fSinglelineCommentScanner; /* for single line comments */
    7777    private ModelicaStringScanner            fStringScanner;            /* for strings and comment strings */
    78    
     78
    7979    private ITextEditor textEditor;
    80        
     80
    8181    private String fDocumentPartitioning;
    82    
    83     public ModelicaSourceViewerConfig(ITextEditor textEditor, String partitioning) 
     82
     83    public ModelicaSourceViewerConfig(ITextEditor textEditor, String partitioning)
    8484    {
    8585        this.textEditor = textEditor;
     
    8787    }
    8888
    89     protected ModelicaCodeScanner getCodeScanner() 
    90     {
    91         if (fCodeScanner == null) 
     89    protected ModelicaCodeScanner getCodeScanner()
     90    {
     91        if (fCodeScanner == null)
    9292        {
    9393            fCodeScanner = new ModelicaCodeScanner();
     
    9797        return fCodeScanner;
    9898    }
    99    
    100     protected ModelicaMultilineCommentScanner getMultilineCommentScanner() 
    101     {
    102         if (fMultilineCommentScanner == null) 
     99
     100    protected ModelicaMultilineCommentScanner getMultilineCommentScanner()
     101    {
     102        if (fMultilineCommentScanner == null)
    103103        {
    104104            fMultilineCommentScanner = new ModelicaMultilineCommentScanner();
     
    109109    }
    110110
    111     protected ModelicaSinglelineCommentScanner getSinglelineCommentScanner() 
    112     {
    113         if (fSinglelineCommentScanner == null) 
     111    protected ModelicaSinglelineCommentScanner getSinglelineCommentScanner()
     112    {
     113        if (fSinglelineCommentScanner == null)
    114114        {
    115115            fSinglelineCommentScanner = new ModelicaSinglelineCommentScanner();
     
    120120    }
    121121
    122     protected ModelicaStringScanner getStringScanner() 
    123     {
    124         if (fStringScanner == null) 
     122    protected ModelicaStringScanner getStringScanner()
     123    {
     124        if (fStringScanner == null)
    125125        {
    126126            fStringScanner = new ModelicaStringScanner();
     
    130130        return fStringScanner;
    131131    }
    132        
    133     public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) 
     132
     133    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
    134134    {
    135135        PresentationReconciler reconciler = new PresentationReconciler();
    136        
     136
    137137        reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    138        
     138
    139139        DefaultDamagerRepairer drCode = new DefaultDamagerRepairer(getCodeScanner());
    140140        reconciler.setDamager(drCode, IDocument.DEFAULT_CONTENT_TYPE);
    141141        reconciler.setRepairer(drCode, IDocument.DEFAULT_CONTENT_TYPE);
    142        
    143         DefaultDamagerRepairer drMultilineComments = new DefaultDamagerRepairer(getMultilineCommentScanner());     
     142
     143        DefaultDamagerRepairer drMultilineComments = new DefaultDamagerRepairer(getMultilineCommentScanner());
    144144        reconciler.setDamager(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT);
    145         reconciler.setRepairer(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT);       
    146        
    147         DefaultDamagerRepairer drSingleComments = new DefaultDamagerRepairer(getSinglelineCommentScanner());       
     145        reconciler.setRepairer(drMultilineComments, IModelicaPartitions.MODELICA_MULTI_LINE_COMMENT);
     146
     147        DefaultDamagerRepairer drSingleComments = new DefaultDamagerRepairer(getSinglelineCommentScanner());
    148148        reconciler.setDamager(drSingleComments, IModelicaPartitions.MODELICA_SINGLE_LINE_COMMENT);
    149149        reconciler.setRepairer(drSingleComments, IModelicaPartitions.MODELICA_SINGLE_LINE_COMMENT);
    150        
     150
    151151        DefaultDamagerRepairer drStrings = new DefaultDamagerRepairer(getStringScanner());
    152152        reconciler.setDamager(drStrings, IModelicaPartitions.MODELICA_STRING);
    153         reconciler.setRepairer(drStrings, IModelicaPartitions.MODELICA_STRING);     
    154                
     153        reconciler.setRepairer(drStrings, IModelicaPartitions.MODELICA_STRING);
     154
    155155        return reconciler;
    156156    }
    157    
     157
    158158    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
    159159    {
    160160        ContentAssistant assistant = new ContentAssistant();
    161        
     161
    162162        assistant.setContentAssistProcessor(new ModelicaCompletionProcessor(textEditor), IDocument.DEFAULT_CONTENT_TYPE);
    163163        DialogSettings s = new DialogSettings("completion_proposal_size");
    164164        s.put(ContentAssistant.STORE_SIZE_X, "550");
    165         s.put(ContentAssistant.STORE_SIZE_Y, "280");       
     165        s.put(ContentAssistant.STORE_SIZE_Y, "280");
    166166        assistant.setRestoreCompletionProposalSize(s);
    167167        assistant.enableAutoActivation(true);
     
    173173        assistant.setInformationControlCreator(getInformationPresenterControlCreator(sourceViewer));
    174174        assistant.setRepeatedInvocationMode(true);
    175        
     175        assistant.enableAutoInsert(true);
    176176
    177177        return assistant;
    178178    }
    179    
     179
    180180    //TODO Adrian Pop, please add the tab length to the Modelica Preferences page!
    181     public int getTabWidth(ISourceViewer sourceViewer) 
     181    public int getTabWidth(ISourceViewer sourceViewer)
    182182    {
    183183        /* return the peter fritzson constant */
     
    205205            return fDocumentPartitioning;
    206206        return super.getConfiguredDocumentPartitioning(sourceViewer);
    207     }   
     207    }
    208208
    209209    public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
     
    223223    }
    224224
    225    
    226     public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) 
    227     {
    228        
     225
     226    public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask)
     227    {
     228
    229229        if (contentType.equals(IDocument.DEFAULT_CONTENT_TYPE))
    230230        {
     
    235235        else return super.getTextHover(sourceViewer, contentType);
    236236    }
    237    
     237
    238238    public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
    239239        return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
    240240    }
    241    
    242    
     241
     242
    243243    /**
    244244     * Returns the information presenter control creator. The creator is a factory creating the
     
    259259        };
    260260    }
    261    
    262    
     261
     262
    263263    /*
    264264     * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
    265265     * @since 2.0
    266266     */
    267     public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) 
     267    public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer)
    268268    {
    269269        InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
     
    276276        return presenter;
    277277    }
    278    
     278
    279279    /*
    280280     * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
     
    282282    public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
    283283        return new ModelicaAnnotationHover() {
    284             protected boolean isIncluded(Annotation annotation) 
     284            protected boolean isIncluded(Annotation annotation)
    285285            {
    286286                return isShowInVerticalRuler(annotation);
    287             }           
     287            }
    288288        };
    289289    }
     
    295295    public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
    296296        return new ModelicaAnnotationHover() {
    297             protected boolean isIncluded(Annotation annotation) 
     297            protected boolean isIncluded(Annotation annotation)
    298298            {
    299299                return isShowInOverviewRuler(annotation);
     
    331331    {
    332332        return null;
    333     }   
    334    
     333    }
     334
    335335}
Note: See TracChangeset for help on using the changeset viewer.