1 11 package org.eclipse.jdt.internal.debug.ui.display; 12 13 14 import org.eclipse.jdt.internal.debug.ui.JDIContentAssistPreference; 15 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 16 import org.eclipse.jdt.internal.debug.ui.contentassist.CurrentFrameContext; 17 import org.eclipse.jdt.internal.debug.ui.contentassist.JavaDebugContentAssistProcessor; 18 import org.eclipse.jdt.ui.PreferenceConstants; 19 import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; 20 import org.eclipse.jface.preference.IPreferenceStore; 21 import org.eclipse.jface.text.BadLocationException; 22 import org.eclipse.jface.text.IDocument; 23 import org.eclipse.jface.text.ITextDoubleClickStrategy; 24 import org.eclipse.jface.text.ITextViewer; 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.source.ISourceViewer; 29 import org.eclipse.ui.editors.text.EditorsUI; 30 import org.eclipse.ui.texteditor.ChainedPreferenceStore; 31 32 35 public class DisplayViewerConfiguration extends JavaSourceViewerConfiguration { 36 37 public DisplayViewerConfiguration() { 38 super(JDIDebugUIPlugin.getDefault().getJavaTextTools().getColorManager(), 39 new ChainedPreferenceStore(new IPreferenceStore[] { 40 PreferenceConstants.getPreferenceStore(), 41 EditorsUI.getPreferenceStore()}), 42 null, null); 43 } 44 45 50 public IPreferenceStore getTextPreferenceStore() { 51 return fPreferenceStore; 52 } 53 54 public IContentAssistProcessor getContentAssistantProcessor() { 55 return new JavaDebugContentAssistProcessor(new CurrentFrameContext()); 56 } 57 58 61 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { 62 63 ContentAssistant assistant = new ContentAssistant(); 64 assistant.setContentAssistProcessor( 65 getContentAssistantProcessor(), 66 IDocument.DEFAULT_CONTENT_TYPE); 67 68 JDIContentAssistPreference.configure(assistant, getColorManager()); 69 70 assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); 71 assistant.setInformationControlCreator( 72 getInformationControlCreator(sourceViewer)); 73 74 return assistant; 75 } 76 77 80 public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { 81 ITextDoubleClickStrategy clickStrat = new ITextDoubleClickStrategy() { 82 public void doubleClicked(ITextViewer viewer) { 84 try { 85 IDocument doc = viewer.getDocument(); 86 int caretOffset = viewer.getSelectedRange().x; 87 int lineNum = doc.getLineOfOffset(caretOffset); 88 int start = doc.getLineOffset(lineNum); 89 int length = doc.getLineLength(lineNum); 90 viewer.setSelectedRange(start, length); 91 } catch (BadLocationException e) { 92 JDIDebugUIPlugin.log(e); 93 } 94 } 95 }; 96 return clickStrat; 97 } 98 } 99 | Popular Tags |