Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 281145 - [CheatSheet] Simple mechanism to publish internal resources of cheatsheet plugin via http urls
Summary: [CheatSheet] Simple mechanism to publish internal resources of cheatsheet plu...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Jim Perry CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-22 16:36 EDT by Shakeel Mahate CLA
Modified: 2009-10-19 12:46 EDT (History)
5 users (show)

See Also:


Attachments
Patch for org.eclipse.ui.browser (5.73 KB, patch)
2009-10-05 16:57 EDT, Jim Perry CLA
cgold: iplog+
Details | Diff
Patch for org.eclipse.ua.tests (1.18 KB, patch)
2009-10-05 16:58 EDT, Jim Perry CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shakeel Mahate CLA 2009-06-22 16:36:35 EDT
Build ID: M20080221-1800

Steps To Reproduce:
1. Create a new cheatsheet plugin
2. Add a contribution to the org.eclipse.ui.cheatsheets.cheatSheetContent
extension
3. Add a category
4. Create a new cheatsheet file using the New Wizard
5. Register the new cheatsheet file
6. Add a jpg file or an html file to the plugin project
7. Add a command to a cheatsheet step or sub-step. In the browse dialog select
the Open Browser command
8. In the url option for the Open Browser command, specify the path to the jpg or html file created in step 6. I have tried all different combinations of paths with the plugin id, without the plugin id, with a jar url
9. Preview the cheatsheet file and click on the Open Browser action which should open a browser window with the jpg or html file displayed.

More information:
I have made sure that the html or jpg resource is exported in the plugin editor.
Comment 1 Chris Goldthorpe CLA 2009-07-21 16:16:49 EDT
Can you be more specific about what you want to do - are you looking to open the jpg or html file in an internal browser or in an external browser?
Comment 2 Jim Perry CLA 2009-10-05 16:57:46 EDT
Created attachment 148828 [details]
Patch for org.eclipse.ui.browser
Comment 3 Jim Perry CLA 2009-10-05 16:58:29 EDT
Created attachment 148829 [details]
Patch for org.eclipse.ua.tests

JUnit test for this work item.
Comment 4 Jim Perry CLA 2009-10-05 16:59:31 EDT
Uploaded patches for both the org.eclipse.ui.browser and org.eclipse.ua.tests plugins.  This includes the code fixes (org.eclipse.ui.browser) and a JUnit test (org.eclipse.ua.tests)
Comment 5 Chris Goldthorpe CLA 2009-10-05 18:28:55 EDT
The patch for org.eclipse.ui.browser is good apart from the copyright year needing to be 2009. I was unable to apply the second patch, I got unmatched segments. It does not look correct in that not every new line has a '+' in column 0. Can you recreate the patch for org.eclipse.ua.tests and make sure it can be applied?
Comment 6 Chris Goldthorpe CLA 2009-10-12 15:31:37 EDT
I have committed the patch for org.eclipse.ui.browser. Jim, can you create a new patch for org.eclipse.ua.tests so I can close this bug?
Comment 7 Markus Keller CLA 2009-10-13 07:07:17 EDT
In the current form, this looks like functionality that should be packaged with your cheat sheet plug-in, and not by UA.

Unless I missed something, the patch only makes the contents of the given URL available, but all links to other resources (embedded images, style sheet, relative links, etc.) will not work when the plug-in is shipped in JAR'd form.

If you decide to keep it, you should add a warning to the command description that tells that it will only work for self-contained files. Or expand the command to allow clients to specify required dependencies that also need to be made available. Or use the help server to support platform URL protocols.
Comment 8 Chris Goldthorpe CLA 2009-10-13 14:51:32 EDT
That is a good point. When I originally discussed this with Jim we had considered using the help server but felt that it was unnecessary because we could open documents using the FileLocator, but as you say that leaves the possibility of not being able to load CSS files or images.
Comment 9 Chris Goldthorpe CLA 2009-10-14 19:47:02 EDT
I tried this command on a document from a jarred help plugin and I saw the page but the images did not load. Having thought about this some more it seems that the command would be more useful if it could process html files and their included files correctly, which requires the help server to be started. This could be done with the line below in the command handler.

if(!workspaceFile.exists())
  {	
    url = BaseHelpSystem.resolve("/" + pluginId + '/' + pluginPath , true); //$NON-NLS-1$

The command would need to be moved out of org.eclipse.ui.browser (which does not depend on the help system) and to one of the help plugins, probably org.eclipse.help.ui.

Markus, does this seem like a reasonable solution?
Comment 10 Chris Goldthorpe CLA 2009-10-15 13:34:11 EDT
I have changed the handler to use the help system to open resources from bundles, this way included images etc. will display correctly. I have also moved the code to org.eclipse.help.ui. Fixed in HEAD.
Comment 11 Shakeel Mahate CLA 2009-10-15 17:08:15 EDT
(In reply to comment #10)
> I have changed the handler to use the help system to open resources from
> bundles, this way included images etc. will display correctly. I have also
> moved the code to org.eclipse.help.ui. Fixed in HEAD.

Thanks, I think this is the right solution for the bug. My hack for cheatsheets was to publish the cheatsheet content as a help plugin and then use the urls. So now we this should work right out of the box, without creating a duplicate help plugin.
Comment 12 Chris Goldthorpe CLA 2009-10-19 12:46:44 EDT
Shakeel, if you get a chance can you download N20091016-2000 or newer version and verify that this feature is working to your satisfaction. If so can you add a comment to that effect with the version number you tested with and  if you have permission to do so set the state to verified (I think the submitter can change the state).