Drag’n’drop in SWT components

Those who went to my Lotusphere session already know this but doing drag’n’drop in SWT is actually quite easy. All you need to do is define a drag source and/or a drop target. The former is only required if a control in users should be able to drag data from a control in your code. The latter is required if you would like users to be able to drop stuff onto your component.

When setting up a drag source or a drop target you specify the control the source/target controls and the types of data you can provide/accept. These types are called Transfer types and are subclasses of the org.eclipse.ui.dnd.Transfer class.

Transfer types that might come handy – the class names should be pretty self-explanatory:

  • org.eclipse.swt.dnd.URLTransfer.getInstance()
  • org.eclipse.swt.dnd.FileTransfer.getInstance()
  • org.eclipse.swt.dnd.TextTransfer.getInstance()

Making a JFace viewer a drop target is simple passing in the underlying control:

DropTarget dropTarget = new DropTarget(viewer.getControl(),
   DND.DROP_DEFAULT | DND.DROP_MOVE);

Once the drop target has been created you set the transfer types:

final Transfer[] dropTransferTypes = new Transfer[] {
  type1,
  type2
};
dropTarget.setTransfer(dropTransferTypes);

The last thing you need is to add an instance of DropTargetListener or use a subclass of DropTargetAdapter as I do here:

dropTarget.addDropListener(new DropTargetAdapter() {
  ...
  ...
});

Creating a drag source is analogous.

The stuff you need to test plug-in deployment in Notes 8

While testing the plug-in deployment features of Lotus Notes 8.x I needed some plug-ins to actually install. They needed to be small, not to have any dependencies on the platform as such as well as having a manageable, and known, dependency graph. Also I needed multiple versions to test installing different versions, upgrading and uninstalling. For this specific purpose I wrote a couple of very, very, very simple sidebar plug-ins (very simple – they just display the version of the plug-in) to play around with.

I now have two plug-ins packaged into two features – Feature 1 and Feature 2. Feature 1 depends on (a specific version of) Feature 2 which in turn doesn’t depend on anything else than the platform (Eclipse core). This means that I can test installing different versions of Feature 1 and verify that Feature 2 is also updated accordingly.

I have made these features publicly available so if you need something similar read on.

Feature dependencies

The below table shows the dependencies between the two test features provided. The table should be read so that Feature 1 v. 1.0.1 depends on Feature 2 v. 2.0.0 and Feature 1 v. 1.1.1 depends on Feature 2 v. 2.0.2.

Feature 2 version
Feature 1 version 2.0.0 2.0.1 2.0.2
1.0.0 X    
1.0.1 X    
1.0.2   X  
1.1.0   X  
1.1.1     X

Installing the features

You can test installation of the features in one of two ways. Either use an update site I provide or use the widget descriptors to install using a widget catalog or the My Widgets sidebar plug-in.

To use the update site point your Update Manager at http://update.lekkimworld.com/testplugins/site.xml and make sure that, when you install, untick the “Only show the latest version of a feature per update site” when selecting features.

Failure to do so will result in your only being able to see Feature 1 v. 1.1.1 and Feature 2 v. 2.0.2. Unticking the box will allow you to select any combination of features you would want to test.

To use the widget descriptors right-click and save the below widget descriptors to your system and use them directly by dragging them onto the My Widgets sidebar plug-in or import them into a widget catalog.

SOA is dead – long live its offspring mashups, BPM, SaaS…

Was tuned in to this blog post (“SOA is Dead; Long Live Services” by Anne Thomas Manes) by a very interesting interview about the post on ITConversations. The podcast is definitely worth a listen and quite interesting. Quoting from the blog post:

“SOA met its demise on January 1, 2009, when it was wiped out by the catastrophic impact of the economic recession. SOA is survived by its offspring: mashups, BPM, SaaS, Cloud Computing, and all other architectural approaches that depend on “services”.”

Sounds like something you realized without knowing it? The interview is very interesting and addresses, among other things, why SOA and governance is a concept and not something you buy. The podcast runs about 44 minutes and may be streamed or downloaded as MP3.

LS2J rules!

I know it has limitations and that it has issues but today it worked like a charm. I was asked to write a library in LotusScript to resolve groups and nested groups from Active Directory into an array of users. It had to be cross platform which ruled out COM and ActiveX controls even if I had been able to find any.

The solution was of cause to write the code in Java using JNDI (Java Naming and Directory Interface) and then write a thin wrapper class in LotusScript using LS2J (LotusScript to Java bridge supplied with Notes out-of-the-box). Now I have a cross-platform solution that has no external dependencies. Beautiful!

So learn Java already! 🙂

IBM software available in the Amazon Cloud

Today I received an e-mail from Amazon Web Services (AWS) stating that IBM and Amazon has partnered up to provide IBM (and Lotus) software in the Amazon EC2 (Elastic Compute Cloud). How cool is that!?

We are excited to announce that IBM and Amazon Web Services have teamed up to provide you with the ability to build and run a range of IBM applications using the Amazon Elastic Compute Cloud (Amazon EC2) service. This relationship will enable you to bring your own IBM licenses to Amazon EC2, utilize IBM’s “Development” AMIs, or leverage the “Production” Amazon EC2 running IBM service. The initial list of IBM environments that will be available includes: IBM DB2, IBM Informix, WebSphere sMash, IBM Lotus Web Content Management, and IBM WebSphere Portal Server.

More info on the AWS partner page.

Tip for improving Notes startup time from Eclipse

On Tuesday I was contacted by a fellow Yellow-head concerning my Lotusphere 2009 demos and the startup time of Notes from Eclipse. The demos had nothing to do with it – the issue was with his Eclipse setup and was easy to fix.

He was experiencing that it took minutes to launch Notes from Eclipse which made development very frustrating and time consuming. He was using Eclipse configured through Lotus Expeditor Toolkit which made me take special notice as this could be a general problem and something many may/will experience.

After discussing his setup for a while I thought a little about it to tried and think of what could slow down Notes startup. One of the first things I could think of was that he might (inadvertently) be clearing his Eclipse workspace very time he launched Notes. This operation is time consuming and it turned out to be the case. After correcting this he was down to launch times in order of seconds which is also what I experience.

The Eclipse workspace contains all your Eclipse settings as well as a persistent registry of the plug-ins installed on the platform as well as their dependencies. This dependency graph takes a while to put together as it requires reading through all the plug-in manifests and trying to resolve the dependencies specified there. So as you can imagine clearing the workspace before each launch of Notes will take unnecessarily long. If no plug-ins are added to the core platform it doesn’t make any sense to recalculate this dependency graph.

To make sure you don’t clear your workspace when launching Notes from Eclipse do as follows:

  1. Open the launch configuration settings (select “RunRun Configurations…” from the menus)
  2. Select your Notes launch configuration (probably named “Notes” or similar)
  3. On the “Main”-tab take a look at the “Workspace Data”-section at the top. Make sure there isn’t a checkmark in the “Clear” ckecbox. If there is, remove it and apply the changes.

That’s all there is to it.

Quick survey: What would it take to get you started with Java in Notes?

Update: Let’s focus on Java development for Notes – not necessarily plug-ins but simply what would it take to get started with Java – the programming language as that is the first obstacle.

I’m running across quite a lot of people who would like to do sidebar plug-ins and general plug-in development for the Notes 8 platform but who are lacking the Java skills required. Many times they haven’t actually taken the time to learn Java at all since the IDE support in Domino Designer is so poor. Based on this I started thinking about how to get Notes developers started developing in Java. So…

What would it take for you to get started with Java in Notes?

  1. Up-to-date editor in Domino Designer – I wont use anything else!
  2. If it is made easy to develop, test and debug in Eclipse I can live with manually having to move the code to Notes for production use.
  3. It’s not the tool support which is the problem – it’s the lack of time, documentation, API’s, management support or this other thing (please state reason)
  4. I’m not at all interested in Java – I want to develop plug-ins using a scripting language.
  5. Other (please state reason)

Please post your response as a comment and a little explanation if you chose “Other”. If you chose option 2 I might just have a solution for you… 🙂

Thanks.