Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 106620

Summary: Webtools XML Editor ignores XML files with other extensions then .xml
Product: [WebTools] WTP Source Editing Reporter: Martin Burchard <webtools>
Component: wst.xmlAssignee: Nitin Dahyabhai <thatnitind>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: a.gurov, for.work.things, peter
Version: 0.7   
Target Milestone: 1.0 M8   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 99793    
Attachments:
Description Flags
org.eclipse.wst.xml.ui.patch
none
org.eclipse.wst.sse.ui.patch none

Description Martin Burchard CLA 2005-08-10 09:23:44 EDT
If you assign other file extension to the XML Editor like *.rdf or *.xul then
XML Editor can't work with the files.
The Design Page says "The document is empty" but that's not true. Renaming the
file to xml without change the content of the file and everything works fine...
But thats not a solution... I can't rename all my files again and again...
Comment 1 Nitin Dahyabhai CLA 2005-08-10 12:02:28 EDT
Please check the FAQ (http://www.eclipse.org/webtools/faq/main.html#xml_1) for
how to solve this problem.
Comment 2 David Williams CLA 2005-08-10 12:18:07 EDT
I am re-opening (on behalf of Martin :) as this has been reported enough we
could at least make some improvements. For example, the "The document is empty"
is probably a little frightening as a message ... and is not accurate .... and
at least source page shows the source, even if not handled as XML.

Perhaps the design page message should be "The document is empty or the content
type of the file is not recognized as a type of XML" ... perhaps with a link to
the contentType preference page? Or ... a status page dialog to directly update
the preference with the files extension (and/or give choice to open text editor)
if content type is not desired to be changed? Or .... something ... suggestions
welcome. 

The idea is we need to be "friendlier" for beginning users ... or, even very
experienced users! since this contentType stuff is new.
Comment 3 David Williams CLA 2005-08-10 12:19:20 EDT
Amy ... would you be interested in at least fixing the message? Bonus points for
creative ease-of-use solutions :) 
Comment 4 Amy Wu CLA 2005-08-16 12:26:52 EDT
Basic fix:
Rather than replacing "The document is empty.." message (since empty vs 
unsupported content type should be handled differently), I will add an 
additional message on XML design page so that if unknown content type is in 
editor, XML design page will display a message "Cannot display document 
contents."

Bonus points attempt:
If unsupported content type is in any structured text editor, an information 
dialog will pop up informing user of unsupported content type and dialog will 
provide a link to content types preference page.  There is also a checkbox 
for "do not show me this message again" and a preference in Structured Text 
Editor preference page "Inform when unsupported content type is in editor" (by 
default, users will be informed)
Comment 5 Amy Wu CLA 2005-08-16 12:35:38 EDT
Created attachment 26158 [details]
org.eclipse.wst.xml.ui.patch

Modified XML Design page to check for unsupported content type (actually checks
if able to get IStructuredModel)

One big change I made was in IDesignViewer
replaced setModel with setDocument

and changed implementors/references accordingly.  With this change, an
IDocument is passed to the design page instead of a model.  Then in the design
page, a model is retrieved from model manager (getexistingmodelforedit)
Comment 6 Amy Wu CLA 2005-08-16 12:41:59 EDT
Created attachment 26160 [details]
org.eclipse.wst.sse.ui.patch

Created new dialog UnknownContentTypeDialog that will pop up when unsupported
content type is in StructuredTextEditor.  Unsupported content type is detected
in StructuredTextEditor#doSetInput.  Dialog will open in UIJob so that it does
not stop editor from loading.  Added new preference:
  EditorPreferenceNames.SHOW_UNKNOWN_CONTENT_TYPE_MSG
to keep track of whether or not to display unsupported content type dialog.

Also added patch to fix bug 99793 (for fix details see that bug)
Comment 7 Amy Wu CLA 2005-08-16 12:44:23 EDT
Reassigning to David to apply patches.
Comment 8 Nitin Dahyabhai CLA 2005-08-24 13:17:32 EDT
Applying the patches with 2 changes:
1) Removed StructuredTextEditor.isSaveOnCloseNeeded
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=99793#c9)
2) Altered XMLMultiPageEditorPart to switch to the source page if there's no
model.  The design page is of no use in this scenario.

Thanks, Amy.
Comment 9 David Williams CLA 2005-09-24 17:36:16 EDT
*** Bug 108212 has been marked as a duplicate of this bug. ***
Comment 10 John Lanuti CLA 2006-11-28 15:59:28 EST
This is part of a mass update to close out all stale WTP resolved bugs from the 1.0.x and 1.5.0 timeframe.  If you feel this bug was closed inappropriately, please reopen.

Thanks, John Lanuti
Comment 11 Alexander Gurov CLA 2007-04-05 05:52:15 EDT
Dear developers, 

The Subversive users reported to us a bug in result of which Subversive cannot open XML files in his Repositories View (in WTP environment) with the "Unknown content type" message.
I investigated the problem and found that the reason of the problem is additional constraints in the org.eclipse.wst.sse.ui.StructuredTextEditor.setDocumentProvider() method:

...........
else if (input instanceof IStorageEditorInput && !(input instanceof IFileEditorInput) && !(input instanceof IPathEditorInput)) {
	setDocumentProvider(StorageModelProvider.getInstance());
}
...........

The Subversive editor input implements IPathEditorInput interface because it is required for opening files with external editors.

From my point of view these additional constraints is unreasonable and can be easily removed from the code. Could you please remove it or propose any another acceptable solution?
Comment 12 Nitin Dahyabhai CLA 2007-04-05 12:46:05 EDT
I'll need more concrete details on what kind of editor input is being used, after all the org.eclipse.team.internal.ccvs.ui.RemoteFileEditorInput works fine and IPathEditorInput is really meant for files on the local filesystem.  It also sounds like a completely different problem than the one for which this bug was originally opened.  Alexander, please open a separate report with more details.
Comment 13 Alexander Gurov CLA 2007-04-06 04:02:38 EDT
The problem description is moved into separate bug report with additional details:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=181384
Comment 14 Nitin Dahyabhai CLA 2007-05-01 19:20:30 EDT
Closing as the original problem is still fixed.