-
Bug
-
Resolution: Won't Do
-
Major
-
4.1.0.Beta1
-
None
In BrowserSim we use the following code to view the source code of currently opened page.
This code opens a default html editor with given content.
Everything is working fine, unless JSPMultiPageEditor is the default html editor.
In the case with JSPMultiPageEditor, the method JSPMultiPageEditor.getDocumentProvider().getDocument(input) returns null and blanck editor is shown.
private void openInMemoryHtmlEditor(String content, String name, String toolTip) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page = window != null ? window.getActivePage() : null; if (page != null) { try { IEditorDescriptor editorDescriptor = PlatformUI.getWorkbench() .getEditorRegistry().getDefaultEditor("view-source.html"); // get default editor for .html //$NON-NLS-1$ String editorId; if (editorDescriptor != null && editorDescriptor.isInternal()) { editorId = editorDescriptor.getId(); } else { editorId = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } IStorage storage = new StringStorage("", // see the long comment below to know why an empty storage is created //$NON-NLS-1$ "view-source.html"); // .html extension is needed to enable code highlighting in the WTP HTML editor //$NON-NLS-1$ IStorageEditorInput input = new StringInput(storage, name, toolTip); IEditorPart editor = page.openEditor(input, editorId); /* We change content of the editor AFTER the editor is created * as a workaround for the following WTP bug. * The essence of the bug is that if given HTML page contains a link * to an external DTD, then WTP HTML editor tries to access this DTD before the editor * is created and freezes UI. * See http://www.eclipse.org/forums/index.php/m/639937/ */ IDocument doc = null; ITextEditor textEditor = null; if (editor instanceof ITextEditor) { textEditor = (ITextEditor) editor; } else { textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); } if (textEditor != null) { doc = textEditor.getDocumentProvider().getDocument(input);// <<<<----- THE PROBLEM APPEARS HERE } if (doc != null) { doc.set(content); editor.doSave(null); // reset resource-changed marker } } catch (PartInitException e) { Activator.logError(e.getMessage(), e); } } else { Activator.logError("Cannot obtain workbench page", null); } }
- blocks
-
JBIDE-14103 BrowserSim: View Source results in a blank page is JBoss Tools JST plugins are not installed
- Closed