use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project liferay-ide by liferay.
the class UITestsUtils method getEditor.
public static StructuredTextEditor getEditor(IFile file) {
StructuredTextEditor editor = (StructuredTextEditor) fileToEditorMap.get(file);
if (editor == null) {
try {
final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
final IWorkbenchPage page = workbenchWindow.getActivePage();
final IEditorPart editorPart = IDE.openEditor(page, file, true, true);
assertNotNull(editorPart);
if (editorPart instanceof SapphireEditorForXml) {
editor = ((SapphireEditorForXml) editorPart).getXmlEditor();
} else if (editorPart instanceof StructuredTextEditor) {
editor = ((StructuredTextEditor) editorPart);
} else if (editorPart instanceof XMLMultiPageEditorPart) {
XMLMultiPageEditorPart xmlEditorPart = (XMLMultiPageEditorPart) editorPart;
editor = (StructuredTextEditor) xmlEditorPart.getAdapter(StructuredTextEditor.class);
}
assertNotNull(editor);
standardizeLineEndings(editor);
fileToEditorMap.put(file, editor);
} catch (Exception e) {
fail("Could not open editor for " + file + " exception: " + e.getMessage());
}
}
return editor;
}
use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart 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.xml.ui.internal.tabletree.XMLMultiPageEditorPart 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.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.
the class TestOpenEditorXML method testOpenOnLocalFileStore.
public void testOpenOnLocalFileStore() throws Exception {
// filebuffers for local files have a location
IPath stateLocation = XMLUITestsPlugin.getDefault().getStateLocation();
File file = stateLocation.append(FILE_NAME).toFile();
FileOutputStream fileOutputStream = new FileOutputStream(file);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
InputStream contents = fFile.getContents();
if (contents != null) {
int c;
byte[] bytes = new byte[2048];
try {
while ((c = contents.read(bytes)) >= 0) {
buffer.write(bytes, 0, c);
}
contents.close();
} catch (IOException ioe) {
// no cleanup can be done
}
}
fileOutputStream.write(buffer.toByteArray());
URI uri = URIUtil.toURI(new Path(file.getAbsolutePath()));
IFileStore store = EFS.getStore(uri);
FileStoreEditorInput input = new FileStoreEditorInput(store);
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorPart editor = IDE.openEditor(page, input, "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart");
page.closeEditor(editor, false);
assertTrue("Unable to open structured text editor " + fEditor, (fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor));
}
use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.
the class TestOpenEditorXML 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;
}
assertTrue("Input file not accessible: " + fFile.getFullPath(), fFile.isAccessible());
// 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);
assertTrue("Unable to open structured text editor " + fEditor, (fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor));
}
}
Aggregations