Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Help system in pure e4 application
Help system in pure e4 application [message #1699736] Fri, 26 June 2015 09:43 Go to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
The eclipse help system is still bound to the old workbench and cannot be used in a pure e4 application. For the purpose of an rcp app we just needed a way to display the help application in a separate browser. This is easy to accomplish in a pure e4 app. Here is how:

I startet with a pure e4 rcp app based on the features org.eclipse.e4.rcp, o.e.emf.common and o.e.emf.ecore.

In order to use the help app I had to add the following bundles:

         org.eclipse.help
         org.eclipse.help.webapp
         org.eclipse.help.base
         org.apache.lucene.analysis
         org.apache.lucene.core
         org.eclipse.core.net
         org.eclipse.equinox.security
         org.eclipse.equinox.security.macosx (for macosx only)
         javax.servlet
         javax.servlet.jsp
         javax.el
         org.eclipse.equinox.http.registry
         org.eclipse.equinox.jsp.jasper.registry
         org.eclipse.equinox.jsp.jasper
         org.apache.jasper.glassfish
         org.eclipse.equinox.http.jetty
         org.eclipse.equinox.http.servlet
         org.eclipse.jetty.continuation
         org.eclipse.jetty.http
         org.eclipse.jetty.io
         org.eclipse.jetty.security
         org.eclipse.jetty.server
         org.eclipse.jetty.servlet
         org.eclipse.jetty.util


None of these have dependencies to org.eclipse.ui or any other 3.x stuff.

The Help Contents menu item is handled by the following:


package ch.arenae.anm.handler;

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.server.WebappManager;

public class HelpContentsHandler {
    @Execute
    public void execute() throws Exception {
        BaseHelpSystem.ensureWebappRunning();
        String helpURL = "http://" //$NON-NLS-1$
                + WebappManager.getHost() + ":" //$NON-NLS-1$
                + WebappManager.getPort() + "/help/index.jsp"; //$NON-NLS-1$
        BaseHelpSystem.getHelpBrowser(true).displayURL(helpURL);
    }

}


For us, this is enough. But I think it could be easily enhanced to open a specific topic.

HTH
Peter
Re: Help system in pure e4 application [message #1700113 is a reply to message #1699736] Tue, 30 June 2015 08:39 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thank you for this very interesting post. Could you go one step further and clarify the nature of your so-called help system. In Eclipse 3 I have an help system made of xml and html files, whereas your example refers to 'index.jsp'.

Thanks for your help
MS
Re: Help system in pure e4 application [message #1700128 is a reply to message #1700113] Tue, 30 June 2015 10:37 Go to previous messageGo to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
It's the same system as in eclipse 3.x. It serves the help content contributed through the extension points org.eclipse.help.toc and org.eclipse.help.contexts. The help system is a web application with index.jsp as an entry point (this is unchanged from eclipse 3.x).
Re: Help system in pure e4 application [message #1700299 is a reply to message #1700128] Wed, 01 July 2015 14:37 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thank for the quick feed-back. I'll try it out !!!

MS
Re: Help system in pure e4 application [message #1700477 is a reply to message #1700299] Thu, 02 July 2015 19:29 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 225
Registered: July 2009
Senior Member
Am 01.07.2015 um 16:37 schrieb Michel Simeon:
> Thank for the quick feed-back. I'll try it out !!!
>
> MS

Hi all,
just for completeness: There are some bug reports regarding the new
EHelpService:

- https://bugs.eclipse.org/bugs/show_bug.cgi?id=458829
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=457391
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=445600

The bugs are closed, but I think these are only some workarounds.
Personally I prefer also a "plain" E4 solution. But this could be a very
time consuming process since you have to re-implement the whole help
system. IIRC there was a proposal for this which stated the use of
docbook as source for the help files (but I can't find it anywhere).
As I also need a clean solution for this problem I could imagine to take
part on the discussion for it.

Greets,
Ralf.
Re: Help system in pure e4 application [message #1748349 is a reply to message #1700477] Tue, 22 November 2016 11:55 Go to previous messageGo to next message
Joe Fernandez is currently offline Joe FernandezFriend
Messages: 27
Registered: November 2014
Junior Member
Peter

Your solution works for me and is very useful.

How did you find out the details? And is there a way to do Welcome/Intro?

Thank you.
Re: Help system in pure e4 application [message #1748397 is a reply to message #1748349] Tue, 22 November 2016 17:56 Go to previous messageGo to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
Sorry, I don't know about welcome or intro. I got this solution by looking at the source of the working e3 implementation, I think.
Re: Help system in pure e4 application [message #1827514 is a reply to message #1699736] Sat, 16 May 2020 11:36 Go to previous message
Yves Prelot is currently offline Yves PrelotFriend
Messages: 13
Registered: September 2016
Junior Member
For those who are looking for more details, I have done the following:

    @PostConstruct
    public void createControls(Composite parent, MApplication app) {
        this.app = app;
        parent.setLayout(new GridLayout(2, false));
        // start help webapp server (we don't stop it). Note that it runs in a thread of the application JVM.
        if (server == null) try {
            server = new JettyHelpServer();
            server.start("help");
            this.baseUrl = "http://" + server.getHost() + ":" + server.getPort() + "/help/";
        } catch (Exception e1) {
            server = null;
            return;
        }
        // ok ? create browser
        browser = new Browser(parent, SWT.NONE);
        browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        app.getContext().set(HelpPart.class, this);
        ....
    }


This starts the help server and opens up a browser in a part where my help will display. Of course, this is layed out in my e4xmi file (in a singleton partstack that gets hidden when the user closes the help).

Then later I do:

    public static void trackHelp(MApplication app) {
        app.getContext().runAndTrack(new RunAndTrack() {
            boolean init = true;

            @Override
            public boolean changed(IEclipseContext context) {
                String helpId = (String) context.get(helpIdKey);
                if (helpId == null && !init) return false;
                init = false;
                HelpPart helpPart = app.getContext().get(HelpPart.class);
                if (helpPart != null && helpId != null) { // the tracker doesn't start the help system up!
                    IContext ctx = HelpSystem.getContext(helpId);
                    if (ctx.getRelatedTopics()[0] != null)
                        helpPart.browser.setUrl(helpPart.baseUrl + "nftopic" + ctx.getRelatedTopics()[0].getHref());
                    // here you can use:
                    // - nftopic for a wide display with no navigation (in particular not the document index)
                    // - topic for a not so wide display because of the presence of a left navigation panel into the document index
                    // Usually, we should use nftopic here because you can call the static help for the whole document
                    // Note also that topic has display anomalies that do not make this a palatable choice
                }
                return true; // This RAT doesn't stop unless we send a null
            }
        });


which is a RunAndTrack attached to the application where I can post the topic I wish to display. I have also added a Display filter that can automatically scan controls that get focus and read a context help id that it posts to the RunAndTrack.

    private org.eclipse.swt.widgets.Listener listener = event -> {
        String helpId = getHelpId(event.widget);
        if (helpId != null) app.getContext().set(helpIdKey, helpId);
    };


This lets me mimic the e3 help system rather closely.

The only dependency I have here on "old" code is the JettyHelpServer dependency (and everything that it draws behind it such as lucene etc.) I have no attachments to the old PlatformUI.

[Updated on: Tue, 19 May 2020 15:50]

Report message to a moderator

Previous Topic:IDs for placeholders and parts
Next Topic:NLS Support for org.eclipse.e4.ui.workbench.renderers.swt
Goto Forum:
  


Current Time: Thu Apr 22 04:12:11 GMT 2021

Powered by FUDForum. Page generated in 0.02125 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top