Changeset 3380 for devel-tools/trunk


Ignore:
Timestamp:
Feb 6, 2008, 5:13:20 PM (13 years ago)
Author:
yura
Message:
Location:
devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpPresentationReconciler.java

    r3359 r3380  
    1111import org.refal.plus.rfpdt.editor.color.IColorPreferences;
    1212
    13 public final class RfpPresentationReconciler extends PresentationReconciler {
     13public final class RfpPresentationReconciler extends PresentationReconciler implements IPropertyChangeListener {
    1414    private final IPreferenceStore store;
    1515    private final ColorScanner defaultContentScanner;
     
    1818    private final NonRuleBasedDamagerRepairer word;
    1919    private final NonRuleBasedDamagerRepairer character;
    20     private final IPropertyChangeListener listener;
    2120
    2221    public RfpPresentationReconciler (String partitioning, IPreferenceStore prefStore) {
     
    4140        setDamager(character, IRfpPartitions.CHARACTER);
    4241        setRepairer(character, IRfpPartitions.CHARACTER);
    43         listener = new IPropertyChangeListener() {
    44             public void propertyChange (PropertyChangeEvent event) {
    45                 defaultContentScanner.setTokens();
    46                 multiLineComment.setDefaultTextAttribute(ColorScanner
    47                         .getTextAttribute(store, IColorPreferences.COMMENT));
    48                 singleLineComment.setDefaultTextAttribute(ColorScanner.getTextAttribute(store,
    49                         IColorPreferences.COMMENT));
    50                 word.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.SYMBOL));
    51                 character.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.SYMBOL));
    52             }
    53         };
    54 
    5542    }
    5643
     
    5845    public void install (ITextViewer viewer) {
    5946        super.install(viewer);
    60         store.addPropertyChangeListener(listener);
     47        store.addPropertyChangeListener(this);
    6148    }
    6249
     
    6451    public void uninstall () {
    6552        super.uninstall();
    66         store.removePropertyChangeListener(listener);
     53        store.removePropertyChangeListener(this);
     54    }
     55
     56    public void propertyChange (PropertyChangeEvent event) {
     57        defaultContentScanner.setTokens();
     58        multiLineComment.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.COMMENT));
     59        singleLineComment.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.COMMENT));
     60        word.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.SYMBOL));
     61        character.setDefaultTextAttribute(ColorScanner.getTextAttribute(store, IColorPreferences.SYMBOL));
    6762    }
    6863}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt.editor/src/org/refal/plus/rfpdt/editor/RfpReconcilingStrategy.java

    r3372 r3380  
    33import org.eclipse.core.resources.IFile;
    44import org.eclipse.jface.preference.IPreferenceStore;
     5import org.eclipse.jface.text.DocumentEvent;
    56import org.eclipse.jface.text.IDocument;
     7import org.eclipse.jface.text.IDocumentListener;
    68import org.eclipse.jface.text.IRegion;
    79import org.eclipse.jface.text.reconciler.DirtyRegion;
     
    1012import org.refal.plus.rfpdt.core.builder.RfpBuilder;
    1113
    12 public class RfpReconcilingStrategy implements IReconcilingStrategy {
     14public class RfpReconcilingStrategy implements IReconcilingStrategy, IDocumentListener {
    1315    private final RfpEditor editor;
    1416    private final IPreferenceStore store;
    15     private IDocument document;
     17    private IDocument document = null;
     18    private AstImplem astImplem = null;
     19    private boolean isRelevant = false;
     20
     21    private void updateAstImplem () {
     22        if (document == null || document.get().equals(""))
     23            astImplem = null;
     24        else {
     25            IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
     26            astImplem = RfpBuilder.checkAndCompileModuleImplem(file.getProject(), file, document.get());
     27        }
     28        isRelevant = true;
     29    }
    1630
    1731    public RfpReconcilingStrategy (RfpEditor editor, IPreferenceStore store) {
     
    2034        editor.rfpReconcilingStrategy = this;
    2135    }
    22    
     36
    2337    public AstImplem getAstImplem () {
    24         IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
    25         if (document == null || document.get().equals(""))
    26             return null;
    27         return RfpBuilder.checkAndCompileModuleImplem(file.getProject(), file, document.get());
     38        if (!isRelevant)
     39            updateAstImplem();
     40        return astImplem;
    2841    }
    2942
    3043    public void reconcile (IRegion partition) {
    31         AstImplem astImplem = getAstImplem();
     44        updateAstImplem();
    3245        if (astImplem != null)
    3346            editor.changeTextPresentation(document, PresentationVisitor.updateTextPresentation(astImplem, store));
     
    3952
    4053    public void setDocument (IDocument document) {
     54        if (this.document != null)
     55            this.document.removeDocumentListener(this);
    4156        this.document = document;
     57        isRelevant = false;
     58        if (this.document != null)
     59            this.document.addDocumentListener(this);
    4260        reconcile(null);
    4361    }
     62
     63    public void documentAboutToBeChanged (DocumentEvent event) {}
     64
     65    public void documentChanged (DocumentEvent event) {
     66        isRelevant = false;
     67    }
    4468}
Note: See TracChangeset for help on using the changeset viewer.