use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class CommonMultiPageEditor method createSourcePage.
protected void createSourcePage() {
structuredTextEditor = new StructuredTextEditor();
try {
int index = addPage(structuredTextEditor, getEditorInput());
setPageText(index, Messages._UI_LABEL_SOURCE);
structuredTextEditor.update();
structuredTextEditor.setEditorPart(this);
structuredTextEditor.addPropertyListener(this);
firePropertyChange(PROP_TITLE);
} catch (PartInitException e) {
// $NON-NLS-1$
ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestReconcilerXML method setUp.
protected void setUp() throws Exception {
// only create project and file once
if (!fIsSetup) {
// create project
createProject(PROJECT_NAME);
fFile = getOrCreateFile(PROJECT_NAME + "/" + FILE_NAME);
fIsSetup = true;
}
// editor is opened each time
if (fIsSetup && fEditor == null) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
fEditor = IDE.openEditor(page, fFile, true, true);
if (!((fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor)))
assertTrue("Unable to open structured text editor", false);
}
// turn on reconciling
IPreferenceStore store = SSEUIPlugin.getDefault().getPreferenceStore();
fReconcilerPref = store.getBoolean(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS);
if (!fReconcilerPref)
store.setValue(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, true);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class XMLCodeFoldingTest method testComments.
/**
* <p><b>TEST:</b> test the folding of comments</p>
*/
public void testComments() throws Exception {
IFile file = getFile("XMLFoldingCommentTest.xml");
StructuredTextEditor editor = getEditor(file);
List expectedPositions = new ArrayList();
expectedPositions.add(new Position(275, 36));
expectedPositions.add(new Position(124, 49));
expectedPositions.add(new Position(179, 81));
expectedPositions.add(new Position(39, 281));
expectedPositions.add(new Position(191, 56));
expectedPositions.add(new Position(64, 31));
expectedPositions.add(new Position(99, 172));
expectedPositions.add(new Position(47, 13));
expectedPositions.add(new Position(108, 13));
waitForReconcileThenVerify(editor.getTextViewer(), expectedPositions);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class XMLCodeFoldingTest method getEditor.
/**
* <p>Given a <code>file</code> get an editor for it. If an editor has already
* been retrieved for the given <code>file</code> then return the same already
* open editor.</p>
*
* <p>When opening the editor it will also standardized the line
* endings to <code>\n</code></p>
*
* @param file open and return an editor for this
* @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
*/
private StructuredTextEditor getEditor(IFile file) {
StructuredTextEditor editor = (StructuredTextEditor) fFileToEditorMap.get(file);
if (editor == null) {
try {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorPart editorPart = IDE.openEditor(page, file, true, true);
if (editorPart instanceof XMLMultiPageEditorPart) {
XMLMultiPageEditorPart xmlEditorPart = (XMLMultiPageEditorPart) editorPart;
editor = (StructuredTextEditor) xmlEditorPart.getAdapter(StructuredTextEditor.class);
} else if (editorPart instanceof StructuredTextEditor) {
editor = ((StructuredTextEditor) editorPart);
} else {
fail("Unable to open structured text editor: " + editorPart.getClass().getName());
}
standardizeLineEndings(editor);
if (editor != null) {
fFileToEditorMap.put(file, editor);
} else {
fail("Could not open viewer for " + file);
}
} catch (Exception e) {
fail("Could not open editor for " + file + " exception: " + e.getMessage());
}
}
return editor;
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor 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());
}
}
Aggregations