Reporting progress of a org.eclipse.core.runtime.jobs.Job using a org.eclipse.swt.widgets.ProgressBar - swt

I would like to know whether it is possible and good practice to report the progress of a org.eclipse.core.runtime.jobs.Job using a org.eclipse.swt.widgets.ProgressBar.
The javadoc says that the run method of org.eclipse.core.runtime.jobs.Job takes a org.eclipse.core.runtime.IProgressMonitor argument. However I don't want to use a jface ProgressMonitorDialog and I'd rather a non-dialog widget.
Can anyone please advise?

Have a look at org.eclipse.ui.internal.progress.ProgressManager, which extends org.eclipse.core.runtime.jobs.ProgressProvider to provide progress to Jobs. You can provide a ProgressProvider, and that can return your preferred IProgressMonitor for use with Jobs. You can base it on org.eclipse.jface.dialogs.ProgressIndicator or work with ProgressBar directly.
As mentioned by https://stackoverflow.com/users/9204/alexey-romanov in RCP you should use the IProgressSevice if possible, and you can display your progress in the ProgressView already provided in the workbench.

In an RCP application, the best practice is to use IProgressService.

Related

Migrating to E4 - equivalent of PlatformUI.isWorkbenchRunning

In our Eclipse RCP 3.7 application we have quite a few calls to PlatformUI.isWorkbenchRunning().
For example most of the calls are guards around Workbench API calls, along the lines of
`
if (PlatformUI.isWorkbenchRunning()) {
display = PlatformUI.getWorkbench().getDisplay();
} else {
display = Display.getDefault();
}
We're migrating now to Eclipse RCP 4.4 and I can't find the correct way to replace these calls with RCP 4 compliant code.
I'm guessing I should inject some service / component and use that, but which component? IWorkbench cannot tell me whether it's running or not.
I would expect it to be quite a common problem, but could not find a solution by googling. Anyone solved this already?
e4 does not currently run headless so there isn't really an equivalent.
For access to the Display you can use
Display.getDefault()
everywhere.
If you have a class derived from SWT Control available you can also use Control.getDisplay()
If you want to use the asyncExec or syncExec methods of Display you can use UISynchronize as an alternative:
#Inject
UISynchronize uiSynch;
uiSynch.asyncExec(runnable);

How do you implement help (using mallard) for a gtk3 app?

I am trying to create my own gtk3 application. I like to use mallard to display some help about how to use my application. However I do not know how to code such that when the help menu item is clicked the help (mallard) is shown. I have the .page files already ready.
Please note, I am not asking how to create help files using mallard. But rather how to integrate mallard into my gtk3 help.
Good question. In cases like this, I always look on git.gnome.org to see how Gedit does it. That's an excellent 'example' application.
First, look here at how they organize their help files:
help
\--C
| \--*.page
\--Makefile.am
\--ar
\--bg
\--ca
\--...other languages...
In help/Makefile.am, they use #YELP_HELP_RULES# to install the files (which is set up by YELP_HELP_INIT in configure.ac.)
Then, when the user clicks Help/Contents, they open the URI help:gedit or help:gedit/link_id with gtk_show_uri() (see here, in the functions gedit_app_show_help_impl() and gedit_app_help_link_id_impl()) The files are then, presumably, automatically fetched by the desktop help system, translated into the proper language, and displayed in Yelp.

Eclipse builder: How does it work?

Does anyone know any details on the underlying eclipse builder that sends jobs to the compiler and get its report? and how to tap to it? The level of abstraction that the builder extension offers is too high and the information insufficient. So I implemented an IResourceChangeListener and played with the ResourceDelta in order to get the messages from an IMarker. It works perfectly, however I realized the message is just returning a string. So my question is, how do I do in order to get the type/reference of the object where the error is, what type of error, what class it should belongs to and all available info.
Thanks.
Have you looked at the builder documentation?
And there is also This article by John.
I think between those two and looking at the code you will find everything you need to know.

Navigate between GWT modules

I've divided my GWT app into multiple modules, what's the best way to navigate between them?
Currently I'm using Window.Location.assign("foo.html#bar") but is there a better way?
History.newItem only works for history within the current module. To change to another page I think the best way is to use Window.Location.assign.
I don't fully remember the issue (and perhaps it has been fixed now), but in our application we stopped using relative URLs as they would sometimes break (we have a comment referencing http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f79e7d5e002b48f6).
To this end we had a method that did the following:
public void goToRelativePage(final String relativeURL) {
Window.Location.assign(GWT.getHostPageBaseURL() + relativeURL);
}

GWT Composite best practices

I'm learning GWT and have started to get the hang of it. I'm at the point where my code is getting to be a spaghetti mess so I'm going back and factoring reasonable bits of it out as Composites. The first problem I ran into was that my tool support failed to give the new Composite class an initWidget() method. It did include a default constructor.
For the time being, I've simply filled in my overridden initWidget() method with a call to super(initWidget(w)) My project compiles and runs as expected, though I feel as though I must be missing something.
What should I keep in mind when overriding init and what if anything do i need to place in the constructor. Is there anything else that I need to know or does it just boil down to regular old Java after this?
Clarification - It has occurred to me that there are probably different answers to this question depending on whether you intend to release said Composite classes as part of a library or simply part of your stand-alone app. I in particular have no intention at this time of developing externally useful components (mainly because I'm so green in this particular technology.)
Thanks!
I'm not sure if I understand what you are trying to do. But for all the Composite's I've written I've never overridden the initWidget method. Because Composite itself doesn't need to be initialized with a constructor, i.e. no need to call super() my constructors of widgets extending composite look something like:
public mywidget() {
SomePanel p = new SomePanel();
....
initWidget(p);
}
As a best practice, imo, only the widget extending Composite should call it's 'own' initWidget.
"GWT Conference: Best Practices for Building Libraries" gives a couple of tips. You should also look at the source of GWT and at the source of one of the libraries for GWT (like gwt-ext)
[EDIT] I just saw another option: suco. From the description:
A micro library that helps to maintain your GWT client code clean and modular.