Java Code Examples for org.eclipse.jface.text.source.SourceViewer#configure()
The following examples show how to use
org.eclipse.jface.text.source.SourceViewer#configure() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterizeTextView.java From http4e with Apache License 2.0 | 6 votes |
private StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument1()); sourceViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed( KeyEvent e){ // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) { if (Utils.isAutoAssistInvoked(e)) { IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer); ca.showPossibleCompletions(); } } }); return sourceViewer.getTextWidget(); }
Example 2
Source File: JavaTemplatePreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
Example 3
Source File: DefaultMergeViewer.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void configureSourceViewer(SourceViewer sourceViewer) { IEditorInput editorInput = getEditorInput(sourceViewer); SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput); sourceViewer.unconfigure(); sourceViewer.configure(sourceViewerConfiguration); IXtextDocument xtextDocument = xtextDocumentUtil.getXtextDocument(sourceViewer); if (xtextDocument != null) { if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) { String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer); for (String contentType : configuredContentTypes) { sourceViewer.removeTextHovers(contentType); } sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer)); } } }
Example 4
Source File: SyntaxColoringPreferencePage.java From editorconfig-eclipse with Apache License 2.0 | 6 votes |
private Control createPreviewer(Composite parent) { IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() }); fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); fColorManager = new EditorConfigColorManager(false); EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager, store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING); fPreviewViewer.configure(configuration); Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new SourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document = new Document(content); EditorConfigDocumentSetupParticipant.setupDocument(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
Example 5
Source File: TypeScriptTemplatePreferencePage.java From typescript.java with MIT License | 6 votes |
protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING); IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new TypeScriptSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
Example 6
Source File: TypeScriptMergeViewer.java From typescript.java with MIT License | 6 votes |
@Override protected void configureTextViewer(TextViewer viewer) { if (viewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) viewer; if (fSourceViewer == null) fSourceViewer = new ArrayList<>(); if (!fSourceViewer.contains(sourceViewer)) fSourceViewer.add(sourceViewer); TypeScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools(); if (tools != null) { IEditorInput editorInput = getEditorInput(sourceViewer); sourceViewer.unconfigure(); if (editorInput == null) { sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null)); return; } getSourceViewerConfiguration(sourceViewer, editorInput); } } }
Example 7
Source File: JavaMergeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void configureTextViewer(TextViewer viewer) { if (viewer instanceof SourceViewer) { SourceViewer sourceViewer= (SourceViewer)viewer; if (fSourceViewer == null) fSourceViewer= new ArrayList<SourceViewer>(); if (!fSourceViewer.contains(sourceViewer)) fSourceViewer.add(sourceViewer); JavaTextTools tools= JavaCompareUtilities.getJavaTextTools(); if (tools != null) { IEditorInput editorInput= getEditorInput(sourceViewer); sourceViewer.unconfigure(); if (editorInput == null) { sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null)); return; } getSourceViewerConfiguration(sourceViewer, editorInput); } } }
Example 8
Source File: JavaStatusContextViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void createControl(Composite parent) { super.createControl(parent); final SourceViewer viewer= getSourceViewer(); viewer.unconfigure(); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); viewer.configure(new JavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null)); viewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); }
Example 9
Source File: ExpressionBuilder.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Creates the source viewer to be used by this editor. * * @param parent * the parent control * @return the source viewer */ protected SourceViewer createSourceViewer( Composite parent ) { IVerticalRuler ruler = createVerticalRuler( ); Composite composite = new Composite( parent, SWT.BORDER | SWT.LEFT_TO_RIGHT ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); composite.setLayout( UIUtil.createGridLayoutWithoutMargin( ) ); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; SourceViewer viewer = new SourceViewer( composite, ruler, styles ); viewer.configure( sourceViewerConfiguration ); updateStyledTextColors( viewer.getTextWidget( ) ); JSEditorInput editorInput = new JSEditorInput( expression, getEncoding( ) ); JSDocumentProvider documentProvider = new JSDocumentProvider( ); try { documentProvider.connect( editorInput ); } catch ( CoreException e ) { ExceptionHandler.handle( e ); } viewer.setDocument( documentProvider.getDocument( editorInput ), ruler == null ? null : ruler.getModel( ) ); return viewer; }
Example 10
Source File: AbstractLangEditor.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); if(input == null) { // Do nothing, editor will be closed. LangCore.logError("doSetInput = null"); return; } SourceViewer sourceViewer = getSourceViewer_(); if(sourceViewer == null) { changePreferenceStore(createCombinedPreferenceStore(input)); } else { getSourceViewerDecorationSupport(sourceViewer).uninstall(); sourceViewer.unconfigure(); changePreferenceStore(createCombinedPreferenceStore(input)); sourceViewer.configure(getSourceViewerConfiguration()); getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore()); } IDocument doc = getDocumentProvider().getDocument(input); // Setup up partitioning if not set. It can happen if opening non-language files in the language editor. LangUIPlugin_Actual.createDocumentSetupHelper().setupPartitioningIfNotSet(doc); internalDoSetInput(input); }
Example 11
Source File: CSSMergeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override protected void configureTextViewer(TextViewer textViewer) { super.configureTextViewer(textViewer); if (textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.unconfigure(); IPreferenceStore preferences = CSSSourceEditor.getChainedPreferenceStore(); CSSSourceViewerConfiguration config = new CSSSourceViewerConfiguration(preferences, null); sourceViewer.configure(config); } }
Example 12
Source File: DTDMergeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override protected void configureTextViewer(TextViewer textViewer) { super.configureTextViewer(textViewer); if (textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.unconfigure(); IPreferenceStore preferences = DTDEditor.getChainedPreferenceStore(); DTDSourceViewerConfiguration config = new DTDSourceViewerConfiguration(preferences, null); sourceViewer.configure(config); } }
Example 13
Source File: JSMergeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override protected void configureTextViewer(TextViewer textViewer) { super.configureTextViewer(textViewer); if (textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.unconfigure(); IPreferenceStore preferences = JSSourceEditor.getChainedPreferenceStore(); JSSourceViewerConfiguration config = new JSSourceViewerConfiguration(preferences, null); sourceViewer.configure(config); } }
Example 14
Source File: XMLMergeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override protected void configureTextViewer(TextViewer textViewer) { super.configureTextViewer(textViewer); if (textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.unconfigure(); IPreferenceStore preferences = XMLEditor.getChainedPreferenceStore(); XMLSourceViewerConfiguration config = new XMLSourceViewerConfiguration(preferences, null); sourceViewer.configure(config); } }
Example 15
Source File: LangTextMergeViewer.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected void configureTextViewer(TextViewer textViewer) { if(textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.configure(getSourceViewerConfiguration(sourceViewer)); } else { super.configureTextViewer(textViewer); } sourceViewerNumber = (sourceViewerNumber + 1) % 3; }
Example 16
Source File: FormHelper.java From tlaplus with MIT License | 5 votes |
/** * Creates the source viewer * @param parent * @param flags * @return */ public static SourceViewer createOutputViewer(Composite parent, int flags) { SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, flags); SourceViewerConfiguration configuration = new SourceViewerConfiguration(); sourceViewer.configure(configuration); sourceViewer.setTabsToSpacesConverter(getTabToSpacesConverter()); StyledText control = sourceViewer.getTextWidget(); control.setFont(TLCUIActivator.getDefault().getOutputFont()); control.setEditable(false); return sourceViewer; }
Example 17
Source File: LangTemplatePreferencePage.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected SourceViewer createViewer(Composite parent) { SourceViewer viewer = new LangSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); viewer.configure(createPreviewerSourceViewerConfiguration()); viewer.setEditable(false); viewer.setDocument(createViewerDocument()); return viewer; }
Example 18
Source File: SWTStyledTextExample.java From http4e with Apache License 2.0 | 5 votes |
private static StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache())); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument2()); return sourceViewer.getTextWidget(); }
Example 19
Source File: RequestView.java From http4e with Apache License 2.0 | 5 votes |
private StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache())); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument2()); return sourceViewer.getTextWidget(); }
Example 20
Source File: SWTHelloWorld.java From http4e with Apache License 2.0 | 5 votes |
private static StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache())); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument2()); return sourceViewer.getTextWidget(); }