|
|
|
|
|
|
|
Re: Help system in pure e4 application [message #1827514 is a reply to message #1699736] |
Sat, 16 May 2020 11:36 |
Yves Prelot 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
|
|
|
Powered by
FUDForum. Page generated in 0.03041 seconds