[jbosstools-issues] [JBoss JIRA] (JBIDE-14320) JSPMultiPageEditor.getDocumentProvider().getDocument(input) returns null
Vlado Pakan (JIRA)
jira-events at lists.jboss.org
Mon May 20 10:39:06 EDT 2013
[ https://issues.jboss.org/browse/JBIDE-14320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vlado Pakan closed JBIDE-14320.
-------------------------------
> JSPMultiPageEditor.getDocumentProvider().getDocument(input) returns null
> ------------------------------------------------------------------------
>
> Key: JBIDE-14320
> URL: https://issues.jboss.org/browse/JBIDE-14320
> Project: Tools (JBoss Tools)
> Issue Type: Bug
> Components: browsersim, jsp/jsf/xml/html source editing
> Affects Versions: 4.1.0.Beta1
> Reporter: Yahor Radtsevich
> Assignee: Victor Rubezhny
> Fix For: 4.1.0.Beta1
>
>
> In BrowserSim we [use|https://github.com/jbosstools/jbosstools-vpe/blob/master/plugins/org.jboss.tools.vpe.browsersim.eclipse/src/org/jboss/tools/vpe/browsersim/eclipse/callbacks/ViewSourceCallback.java#L108] 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.
> {code}
> 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);
> }
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jbosstools-issues
mailing list