KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > aciitemeditor > sourceeditor > ACISourceViewerConfiguration


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.aciitemeditor.sourceeditor;
21
22
23 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
24 import org.eclipse.jface.text.IDocument;
25 import org.eclipse.jface.text.contentassist.ContentAssistant;
26 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
27 import org.eclipse.jface.text.contentassist.IContentAssistant;
28 import org.eclipse.jface.text.formatter.ContentFormatter;
29 import org.eclipse.jface.text.formatter.IContentFormatter;
30 import org.eclipse.jface.text.formatter.IFormattingStrategy;
31 import org.eclipse.jface.text.presentation.IPresentationReconciler;
32 import org.eclipse.jface.text.presentation.PresentationReconciler;
33 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
34 import org.eclipse.jface.text.source.ISourceViewer;
35 import org.eclipse.jface.text.source.SourceViewerConfiguration;
36
37
38 /**
39  * This class enables the features of the editor (Syntax coloring, code completion, etc.)
40  *
41  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
42  * @version $Rev$, $Date$
43  */

44 public class ACISourceViewerConfiguration extends SourceViewerConfiguration
45 {
46     /* (non-Javadoc)
47      * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
48      */

49     public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer )
50     {
51         PresentationReconciler reconciler = new PresentationReconciler();
52         reconciler.setDocumentPartitioning( getConfiguredDocumentPartitioning( sourceViewer ) );
53
54         // Creating the damager/repairer for code
55
DefaultDamagerRepairer dr = new DefaultDamagerRepairer( Activator.getDefault().getAciCodeScanner() );
56         reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
57         reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
58
59         return reconciler;
60     }
61
62
63     /* (non-Javadoc)
64      * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer)
65      */

66     public IContentAssistant getContentAssistant( ISourceViewer sourceViewer )
67     {
68         // ContentAssistant assistant = new ContentAssistant();
69
ContentAssistant assistant = new DialogContentAssistant();
70         IContentAssistProcessor aciContentAssistProcessor = new ACIContentAssistProcessor();
71
72         assistant.setContentAssistProcessor( aciContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE );
73         assistant.setDocumentPartitioning( "org.apache.directory.ldapstudio.aci" ); //$NON-NLS-1$
74
assistant.enableAutoActivation( true );
75         assistant.setAutoActivationDelay( 500 );
76         assistant.setProposalPopupOrientation( IContentAssistant.PROPOSAL_STACKED );
77         assistant.setContextInformationPopupOrientation( IContentAssistant.CONTEXT_INFO_ABOVE );
78
79         return assistant;
80     }
81     
82     /* (non-Javadoc)
83      * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentFormatter(org.eclipse.jface.text.source.ISourceViewer)
84      */

85     public IContentFormatter getContentFormatter( ISourceViewer sourceViewer )
86     {
87         ContentFormatter formatter = new ContentFormatter();
88         IFormattingStrategy formattingStrategy = new ACIFormattingStrategy( sourceViewer );
89         formatter.enablePartitionAwareFormatting( false );
90         formatter.setFormattingStrategy( formattingStrategy, IDocument.DEFAULT_CONTENT_TYPE );
91         return formatter;
92     }
93     
94 }
95
Popular Tags