Java Code Examples for org.eclipse.jface.text.source.SourceViewer#getTextWidget()

The following examples show how to use org.eclipse.jface.text.source.SourceViewer#getTextWidget() . 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 vote down vote up
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: ResponseView.java    From http4e with Apache License 2.0 5 votes vote down vote up
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 3
Source File: ResponseView.java    From http4e with Apache License 2.0 5 votes vote down vote up
private StyledText buildJsonEditorText( Composite parent){
   final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
   StyledText st = sourceViewer.getTextWidget();
   JSONLineStyler jsonStyler = new JSONLineStyler();
   st.addLineStyleListener(jsonStyler);
   return st;
}
 
Example 4
Source File: SWTHelloWorld.java    From http4e with Apache License 2.0 5 votes vote down vote up
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 5
Source File: RequestView.java    From http4e with Apache License 2.0 5 votes vote down vote up
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 6
Source File: RequestView.java    From http4e with Apache License 2.0 5 votes vote down vote up
private StyledText buildJsonEditorText( Composite parent){
   final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
   StyledText st = sourceViewer.getTextWidget();
   JSONLineStyler jsonStyler = new JSONLineStyler();
   st.addLineStyleListener(jsonStyler);
   return st;
}
 
Example 7
Source File: SWTStyledTextExample.java    From http4e with Apache License 2.0 5 votes vote down vote up
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 8
Source File: AbstractSourceView.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private StyledText getTextWidget() {
	SourceViewer viewer = getSourceViewer();
	if (viewer != null) {
		return viewer.getTextWidget();
	}
	return null;
}
 
Example 9
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * 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 10
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
public static SourceViewer createSourceViewer(Composite parent, int flags, SourceViewerConfiguration config)
{
    SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, flags);
    sourceViewer.configure(config);
    sourceViewer.setTabsToSpacesConverter(getTabToSpacesConverter());

    StyledText control = sourceViewer.getTextWidget();
    control.setWordWrap(true);
    control.setFont(TLCUIActivator.getDefault().getCourierFont());
    control.setEditable(true);
    return sourceViewer;
}
 
Example 11
Source File: SQLDataSetEditorPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param viewer
 */
private final void attachMenus( SourceViewer viewer )
{
	StyledText widget = viewer.getTextWidget( );
	TextMenuManager menuManager = new TextMenuManager( viewer );
	widget.setMenu( menuManager.getContextMenu( widget ) );
}
 
Example 12
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateIndentationSettings(SourceViewer sourceViewer, String property) {
	if(CodeFormatterConstants.FORMATTER_TAB_SIZE.key.equals(property)) {
		StyledText textWidget = sourceViewer.getTextWidget();
		int tabWidth = getTabWidth(sourceViewer);
		textWidget.setTabs(tabWidth);
	}
}
 
Example 13
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateIndentationSettings(SourceViewer sourceViewer, String property) {
	if(CodeFormatterConstants.FORMATTER_TAB_SIZE.key.equals(property)) {
		StyledText textWidget = sourceViewer.getTextWidget();
		int tabWidth = getTabWidth(sourceViewer);
		textWidget.setTabs(tabWidth);
	}
}