use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class NoRegionContentAssistProcessorForHTML method initPartitionToProcessorMap.
protected void initPartitionToProcessorMap() {
super.initPartitionToProcessorMap();
IContentAssistProcessor htmlProcessor = new HTMLContentAssistProcessor();
addPartitionProcessor(IHTMLPartitions.HTML_DEFAULT, htmlProcessor);
addPartitionProcessor(IHTMLPartitions.HTML_COMMENT, htmlProcessor);
IContentAssistProcessor jsContentAssistProcessor = new StructuredTextViewerConfigurationHTML().getContentAssistant(null).getContentAssistProcessor(IHTMLPartitions.SCRIPT);
addPartitionProcessor(IHTMLPartitions.SCRIPT, jsContentAssistProcessor);
IContentAssistProcessor cssContentAssistProcessor = new CSSContentAssistProcessor();
addPartitionProcessor(ICSSPartitions.STYLE, cssContentAssistProcessor);
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class ViewerTestHTML method createPartControl.
/**
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
*/
public void createPartControl(Composite parent) {
IContributionManager mgr = getViewSite().getActionBars().getMenuManager();
addActions(mgr);
// create source viewer & its content type-specific viewer
// configuration
fSourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
fConfig = new StructuredTextViewerConfigurationHTML();
// set up the viewer with a document & viewer config
setupViewerForNew();
setupViewerPreferences();
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class TestHTMLContentAssistComputers method getProposals.
/**
* <p>Invoke content assist on the given viewer at the given offset, for the given number of pages
* and return the results of each page</p>
*
* @param viewer
* @param offset
* @param pageCount
* @return
* @throws Exception
*/
private static ICompletionProposal[][] getProposals(StructuredTextViewer viewer, int offset, int pageCount) throws Exception {
// setup the viewer
StructuredTextViewerConfigurationHTML configuration = new StructuredTextViewerConfigurationHTML();
ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer);
viewer.configure(configuration);
viewer.setSelectedRange(offset, 0);
// get the processor
String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
// fire content assist session about to start
Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionBeginEvent", new Class[] { boolean.class });
privateFireSessionBeginEventMethod.setAccessible(true);
privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] { Boolean.TRUE });
// get content assist suggestions
ICompletionProposal[][] pages = new ICompletionProposal[pageCount][];
for (int p = 0; p < pageCount; ++p) {
pages[p] = processor.computeCompletionProposals(viewer, offset);
}
// fire content assist session ending
Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
privateFireSessionEndEventMethod.setAccessible(true);
privateFireSessionEndEventMethod.invoke(contentAssistant, null);
return pages;
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class NewHTMLTemplatesWizardPage method createViewer.
/**
* Creates, configures and returns a source viewer to present the template
* pattern on the preference page. Clients may override to provide a
* custom source viewer featuring e.g. syntax coloring.
*
* @param parent
* the parent control
* @return a configured source viewer
*/
private SourceViewer createViewer(Composite parent) {
SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML();
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return baseConfiguration.getConfiguredContentTypes(sourceViewer);
}
public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
}
};
SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
// $NON-NLS-1$
viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForHTML.ContentTypeID_HTML);
IDocument document = scratchModel.getStructuredDocument();
viewer.configure(sourceViewerConfiguration);
viewer.setDocument(document);
return viewer;
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class TestViewerConfigurationHTML method setUpViewerConfiguration.
private void setUpViewerConfiguration() {
if (Display.getCurrent() != null) {
Shell shell = null;
Composite parent = null;
if (PlatformUI.isWorkbenchRunning()) {
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
} else {
shell = new Shell(Display.getCurrent());
}
parent = new Composite(shell, SWT.NONE);
// dummy viewer
fViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
fConfig = new StructuredTextViewerConfigurationHTML();
} else {
fDisplayExists = false;
Logger.log(Logger.INFO, "Remember, viewer configuration tests are not run because workbench is not open (normal on build machine)");
}
}
Aggregations