use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class XMLCodeFoldingTest method testConfigTypeHierarchyExploration.
/**
* <p><b>TEST:</b> that even though .xsl documents do not have a specifically specified
* folding strategy that by the power of hierarchical content types the XML folding
* strategy is used for the XSLT document.
*/
public void testConfigTypeHierarchyExploration() throws Exception {
IFile file = getFile("XSLFoldingTest1.xsl");
StructuredTextEditor editor = getEditor(file);
List expectedPositions = new ArrayList();
expectedPositions.add(new Position(120, 88));
expectedPositions.add(new Position(147, 44));
expectedPositions.add(new Position(39, 187));
waitForReconcileThenVerify(editor.getTextViewer(), expectedPositions);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestPropertySheetConfiguration method setUp.
protected void setUp() throws Exception {
if (!fIsSetup) {
// create project
createProject(PROJECT_NAME);
fFile = getOrCreateFile(PROJECT_NAME + "/" + FILE_NAME);
fIsSetup = true;
}
// editor is opened each time
if (fIsSetup && fMainEditor == null) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
fMainEditor = IDE.openEditor(page, fFile, true, true);
if (fMainEditor instanceof StructuredTextEditor)
fEditor = (StructuredTextEditor) fMainEditor;
else if (fMainEditor != null) {
Object adapter = fMainEditor.getAdapter(ITextEditor.class);
if (adapter instanceof StructuredTextEditor)
fEditor = (StructuredTextEditor) adapter;
}
if (fEditor == null)
assertTrue("Unable to open structured text editor " + ((fMainEditor != null) ? fMainEditor.getClass().getName() : ""), false);
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestXMLContentAssistComputers method testXMLLinkedPositions.
public void testXMLLinkedPositions() throws Exception {
IFile file = getFile("test1.xml");
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
int offset = viewer.getDocument().getLineOffset(13);
ICompletionProposal[][] pages = getProposals(viewer, offset, 4);
assertNotNull("No proposals returned.", pages);
assertTrue("Not enough pages.", pages.length > 0);
assertTrue("Not enough proposals.", pages[0].length > 0);
ICompletionProposalExtension2 proposal = null;
// Check for the member proposal
for (int i = 0; i < pages[0].length; i++) {
if ("Member".equals(pages[0][i].getDisplayString())) {
assertTrue("Proposal not of the proper type", pages[0][i] instanceof ICompletionProposalExtension2);
proposal = (ICompletionProposalExtension2) pages[0][i];
break;
}
}
assertNotNull("No appropriate proposal found.", proposal);
proposal.apply(viewer, (char) 0, 0, offset);
String[] categories = viewer.getDocument().getPositionCategories();
String category = null;
for (int i = 0; i < categories.length; i++) {
if (categories[i].startsWith("org.eclipse.jface.text.link.LinkedModeModel")) {
category = categories[i];
}
}
assertNotNull("Could not find the linked model position category.", category);
assertTrue("No linked positions were generated.", viewer.getDocument().getPositions(category).length > 0);
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project webtools.sourceediting by eclipse.
the class TestXMLContentAssistComputers 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 static 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");
}
if (editor != null) {
standardizeLineEndings(editor);
fFileToEditorMap.put(file, editor);
} else {
fail("Could not open editor 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 TestXMLContentAssistComputers method runProposalTest.
/**
* <p>Run a proposal test by opening the given file and invoking content assist for
* each expected proposal count at the given line number and line character
* offset and then compare the number of proposals for each invocation (pages) to the
* expected number of proposals.</p>
*
* @param fileName
* @param lineNum
* @param lineRelativeCharOffset
* @param expectedProposalCounts
* @throws Exception
*/
private static void runProposalTest(String fileName, int lineNum, int lineRelativeCharOffset, int[] expectedProposalCounts) throws Exception {
IFile file = getFile(fileName);
StructuredTextEditor editor = getEditor(file);
StructuredTextViewer viewer = editor.getTextViewer();
int offset = viewer.getDocument().getLineOffset(lineNum) + lineRelativeCharOffset;
ICompletionProposal[][] pages = getProposals(viewer, offset, expectedProposalCounts.length);
verifyProposalCounts(pages, expectedProposalCounts);
}
Aggregations