01: package org.drools.eclipse.dsl.editor;
02:
03: import org.drools.eclipse.editors.DRLRuleEditor;
04: import org.eclipse.core.runtime.CoreException;
05: import org.eclipse.core.runtime.IProgressMonitor;
06: import org.eclipse.jface.text.source.SourceViewerConfiguration;
07: import org.eclipse.ui.part.FileEditorInput;
08:
09: public class DSLRuleEditor extends DRLRuleEditor {
10:
11: protected DSLAdapter dslAdapter;
12:
13: public DSLAdapter getDSLAdapter() {
14: if (dslAdapter == null) {
15: try {
16: String content = getSourceViewer().getDocument().get();
17: dslAdapter = new DSLAdapter(content,
18: ((FileEditorInput) getEditorInput()).getFile());
19: if (!dslAdapter.isValid()) {
20: dslAdapter = null;
21: }
22: } catch (CoreException exc) {
23: dslAdapter = null;
24: }
25: }
26: return dslAdapter;
27: }
28:
29: protected SourceViewerConfiguration createSourceViewerConfiguration() {
30: return new DSLRuleSourceViewerConfig(this );
31: }
32:
33: public void doSave(IProgressMonitor monitor) {
34: super .doSave(monitor);
35: // remove cached content
36: dslAdapter = null;
37: }
38: }
|