use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.
the class ResultView method createViewer.
private SourceViewer createViewer(Composite parent) {
SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXSL();
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return baseConfiguration.getConfiguredContentTypes(sourceViewer);
}
@Override
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$
((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
viewer.configure(sourceViewerConfiguration);
viewer.setEditable(false);
return viewer;
}
use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.
the class XMLCodeFoldingTest method testRemoveNode.
/**
* <p><b>TEST:</b> that folding annotations are updated after node is removed</p>
*/
public void testRemoveNode() throws Exception {
IFile file = getFile("XMLFoldingTest1.xml");
StructuredTextEditor editor = getEditor(file);
try {
StructuredTextViewer viewer = editor.getTextViewer();
IDocument doc = viewer.getDocument();
doc.replace(87, 49, "");
editor.doSave(null);
final List expectedPositions = new ArrayList();
expectedPositions.add(new Position(93, 16));
expectedPositions.add(new Position(124, 36));
expectedPositions.add(new Position(39, 130));
expectedPositions.add(new Position(71, 13));
expectedPositions.add(new Position(62, 58));
expectedPositions.add(new Position(47, 13));
waitForReconcileThenVerify(viewer, expectedPositions);
} catch (BadLocationException e) {
fail("Test is broken, replace location has become invalid.\n" + e.getMessage());
}
}
use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.
the class TestXMLContentAssist method initializeSourceViewer.
protected void initializeSourceViewer() {
// some test environments might not have a "real" display
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
sourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
} else {
Assert.fail("Unable to run the test as a display must be available.");
}
configureSourceViewer();
}
use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.
the class DTDCodeFoldingTest method testAddNode.
/**
* <p><b>TEST:</b> that folding annotations are updated after node is removed</p>
* Removed because it keeps failing during builds but running locally and smoke testing
* presents no problems.
*/
/*public void testRemoveNode() throws Exception {
IFile file = getFile("DTDFoldingTest1.dtd");
StructuredTextEditor editor = getEditor(file);
try {
StructuredTextViewer viewer = editor.getTextViewer();
IDocument doc = viewer.getDocument();
doc.replace(337, 159, "");
editor.doSave(null);
final List expectedPositions = new ArrayList();
expectedPositions.add(new Position(1110, 28));
expectedPositions.add(new Position(39, 296));
expectedPositions.add(new Position(1140, 234));
expectedPositions.add(new Position(339, 751));
expectedPositions.add(new Position(1092, 17));
waitForReconcileThenVerify(viewer, expectedPositions);
} catch(BadLocationException e) {
fail("Test is broken, replace location has become invalid.\n" + e.getMessage());
}
}*/
/**
* <p><b>TEST:</b> that folding annotations are updated after node is added</p>
*/
public void testAddNode() throws Exception {
IFile file = getFile("DTDFoldingTest2.dtd");
StructuredTextEditor editor = getEditor(file);
try {
StructuredTextViewer viewer = editor.getTextViewer();
IDocument doc = viewer.getDocument();
String newNodeText = "<!ATTLIST BDO\n" + "%coreattrs;\t\t\t\t-- id, class, style, title --\n" + "lang\t%LanguageCode;\t#IMPLIED\t-- language code --\n" + "dir\t(ltr|rtl)\t#REQUIRED\t-- directionality --\n" + ">\n";
doc.replace(597, 0, newNodeText);
editor.doSave(null);
List expectedPositions = new ArrayList();
expectedPositions.add(new Position(1454, 234));
expectedPositions.add(new Position(498, 906));
expectedPositions.add(new Position(39, 296));
expectedPositions.add(new Position(1406, 17));
expectedPositions.add(new Position(337, 159));
expectedPositions.add(new Position(1424, 28));
waitForReconcileThenVerify(viewer, expectedPositions);
} catch (BadLocationException e) {
fail("Test is broken, add location has become invalid.\n" + e.getMessage());
}
}
use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.
the class ViewerTestDTD 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 StructuredTextViewerConfigurationDTD();
// set up the viewer with a document & viewer config
setupViewerForNew();
setupViewerPreferences();
}
Aggregations