JavaSourceViewer not working in SWT composites [message #1734134] |
Sat, 04 June 2016 17:20 |
Akash Srivastava 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();
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02801 seconds