Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » JavaSourceViewer not working in SWT composites(Javasourceviewer configured with Javascriptsourceviewerconfiguration opens in SWT shell, but does not show features like syntax coloring etc)
JavaSourceViewer not working in SWT composites [message #1734134] Sat, 04 June 2016 17:20 Go to next message
Akash Srivastava is currently offline Akash SrivastavaFriend
Messages: 4
Registered: June 2016
Junior Member
Hi,
I want to have an editor in a SWT shell, in which I can edit Javascript files. (Just to be clear, I want to achieve this without using the Eclipse Workbench Editor)
For this, I am instantiating the JavaSourceViewer Class and configuring it with JavaScriptSourceViewerConfiguration.

The sourceviewer does opens up, but it doesn't show the basic features of the editor like syntax coloring etc. It is all plain text, no colors at all. I have also attached a standalone RCP application code, having the same code I am using.

Below is the code in file "FileOpen.java" that you will find in the attached zip.

Shell dialog = new Shell(Display.getCurrent().getActiveShell());
dialog.setText("Dialog");
dialog.setSize(400, 400);
dialog.setLayout(new FillLayout());
Composite comp = new Composite(dialog, SWT.BORDER);
comp.setLayout(new FillLayout());

JavaScriptTextTools tools= JavaScriptPlugin.getDefault().getJavaTextTools();
int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
IPreferenceStore store= JavaScriptPlugin.getDefault().getCombinedPreferenceStore();

@SuppressWarnings("restriction")
JavaSourceViewer jsv = new JavaSourceViewer(comp, null, null , false, styles, store);

@SuppressWarnings("restriction")
JavaScriptSourceViewerConfiguration jssvc = new JavaScriptSourceViewerConfiguration(tools.getColorManager(), store, null, IDocument.DEFAULT_CONTENT_TYPE);
jsv.configure(jssvc);
Document doc = new Document();
jsv.setDocument(doc);
dialog.open();
Re: JavaSourceViewer not working in SWT composites [message #1734212 is a reply to message #1734134] Mon, 06 June 2016 09:22 Go to previous messageGo to next message
Akash Srivastava is currently offline Akash SrivastavaFriend
Messages: 4
Registered: June 2016
Junior Member
Hi,
JavaScriptSourceViewerConfiguration jssvc = new JavaScriptSourceViewerConfiguration(tools.getColorManager(), store, null, null);
..setting the last argument to null made it to work for me. The syntax coloring now works finally.
Through further reading, I found out, that I must write some extra code, to get the content assist working.
I'll be back here with my query ,if i face a problem in it
Re: JavaSourceViewer not working in SWT composites [message #1734534 is a reply to message #1734212] Thu, 09 June 2016 08:55 Go to previous message
Akash Srivastava is currently offline Akash SrivastavaFriend
Messages: 4
Registered: June 2016
Junior Member
Hi,
I want to use, the Javascript content assist with the "naked" sourceviewer as shown in the attached code.
I tried using the ContentAssist and Processors, but the some how still breaks.
Please provide some guidance over this.
Previous Topic:How to publish Dynamic Web Project on Linux Server
Next Topic:How to create an IJavaScriptProject?
Goto Forum:
  


Current Time: Tue Apr 16 19:55:58 GMT 2024

Powered by FUDForum. Page generated in 0.23250 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top