Category Archives: Eclipse

Eclipse plug-in & RCP stuff

Confirming cancel in a ProgressMonitorDialog

I’m working on a routine that downloads content from a host to the users desktop.

As the content is being downloaded, a progress dialog is displayed (implemented as ProgressMonitorDialog).

In the progress monitor, the cancel button is enabled.

In the default implementation, if the cancel button is pressed on the ProgressMonitorDialog, the cancel button is disabled.

I wanted to be able to ask the user if they really want to cancel the operation. If they don’t, then continue on with the operation. If they do, then perform the cancellation as usual.

I couldn’t find a straight forward way to implement this with the default operation, so I came up with my own solution…

Continue reading

Dynamically populating a Combo based on shift key

In a recent project I had a combo box that I wanted to add additional entries to if they clicked on it with the shift key pressed.

This is to allow to select entries that would not normally be displayed (for example, out dated values that could actually be selected).

To do this, I added key-up & key-down listeners on the Display object and populated the Combo based on the shift key state.
Continue reading

Text On Splash Screen

You may have heard a variation of this at some point …

A lazy programmer is not necessarily a good programmer … but a good programmer is a lazy programmer.

I fully subscribe to that statement … good programmers are always looking for ways to make their jobs easier.  Either by automating some repetitive function or making some functionality easier to change in the future.

Recently I had to do some re-branding on one of my eclipse based applications.  One thing that I had to do was update the splash screen that was displayed in the Eclipse RCP to display different text.

We had the basic graphic and all we needed was to have our designer update the text that was displayed on the bottom.  I sent the graphic over and the new text and the designer sent it back to me.

The problem was, I got the text wrong.  I knew I was going to have to go back to the designer and ask her to redo the graphic.  Luckily she’s a very nice person and never had a problem with this.

Continue reading

Modifying the Environment

Here’s a problem I just encountered … and, unfortunately, haven’t figured out a solution.

A customer is trying to run my Eclipse RCP application … but it’s crashing because it can’t find ‘com.mercury.javashared.agentloader.AgentBootstrap’ class (which is apparently part of the HP QuickTest Professional product).

Turns out they had the ‘JAVA_TOOL_OPTIONS’ environment variable set to ‘-agentlib:jvmhook’ at the system level (set in the Windows control panel).

This was causing the boot loader to try and load the class that couldn’t be found.

A temporary work around is to set the JAVA_TOOL_OPTIONS environment variable to blank every time they launch the application … but that’s a major pain in the long term.

I’d like to fix this by finding a way to override the JAVA_TOOL_OPTIONS environment variable in the eclipse.ini file, or possibly providing a different ‘-agentlib’ parameter option that will supersede the existing value.

I guess I could provide a batch file that clears the environment variable before invoking the application … but that’s kind of kludgy (IMO).

Of course, any product that sets a global environment variable such as this is (at least in my opinion) seriously broken.  The only global environment variable that any application should set (or even be allowed to set) is maybe the path.

Adding Help to Dialogs

I’m in the process of updating the help text for my RCP and have found that some of the dialogs that I’m invoking don’t have the ability to directly add help context id’s.

After a bit of digging, I found it’s not that difficult to add help to an object that extends Dialog.

For this example, I’m going to add a help id to the InputDialog class.

Continue reading

Inheritance

One my gripes about the Eclipse framework is the general lack of standardized interfaces & inheritance.

For instance: a TreeColumn & TableColumn both have a lot of attributes in common … width, alignment, movability, sortability, resizeability, etc.

But since they don’t share an interface or a common ancestor, you can’t handle them with common code.

Similarly widgets like the ComboBox and a Text field share a lot of attributes … they can hold text, they can be changed, etc, but you can’t access those attributes with a common interface.

Sadly most Eclipse widgets explicitly forbid subclassing … so I can’t subclass the various types and add my own interfaces. The following is a direct quote from the TableColumn javadocs …

IMPORTANT: This class is not intended to be subclassed.

And, unfortunately, they enforce this in code.

Preventing Multiple Instances

One of the things I needed to support in my RCP is the ability to prevent multiple copies (instances) of the application from running at the same time.

The solution is surprisingly easy … although, as with many things, not especially well documented.

In your Application class (that implements IApplication) you need to create a lock file in the application’s instance location.
Continue reading

Help Icon on Dialog Pages

Another item I struggled with … adding the help icon to various dialogs (wizards, preferences, properties, about box, etc).

In almost all Eclipse dialogs … there is a question mark icon in the lower left hand corner. You click on this and it invokes the context sensitive help.

The problem was, I couldn’t figure out how to activate this.

I thought it would be controlled by some plug-in or product setting, but I couldn’t determine where.

After a fair bit of digging & debugging of base Eclipse, I determined that this feature is turned on globally for the entire application:

Continue reading