Unleashing your Eclipse components on Notes 8.5

One of the cool features in Notes 8.5 Composite Applications is the new Wireable Properties function in the Composite Application Editor. In case you are not familiar with this, check out this screen shot that shows how you can check off the wireable box on a specific property.

This features enables another concept that is starting to get frequently asked for; which is “How can I create an Eclipse component that will work in Expeditor, Notes, and stand alone Eclipse?“. This means no binary dependency on Expeditor or Notes API's – like the PropertyBroker.

To start, in Eclipse workbench part, there is an API to publish a part property. The API method is firePartPropertyChanged() on the WorkbenchPart class. We will promote this method use in our example – so if you want to publish properties to other components start using this!

What I have done is, using the new Wireable properties function in the CAE, I have created a bridge between the Workbench Part property change API's and the XPD Property Broker API's. This allows for views to publish their properties to the broker and have them be wired to other components. The link is using the CAE Advanced Properties dialog to add the properties by name and mark them wireable.

Here is a basic flow diagram of how the pieces connect:

Here is a screen shot of the test view where the property published is sent over to the browser component on the right. I used the same property name as I showed on the Advanced Properties dialog. In reality, this would be a “known” property that the component designer would document since it is not automatically discovered by CAE – again because there is no WSDL.

What is amazing is the entire source listing for that component on the left is below – notice there are no Expeditor API's used? This architecture is pretty simple. We use an Eclipse Window and Perspective listener to figure out if any views on the screen have wireable properties. If so, then the bridge registers itself as a part property listener:

viewRef.addPartPropertyListener(this);

Now, whenever the part calls the firePartPropertyChanged() method the bridge takes the event and publishes it to the property broker. Since we wired that property name using the CAE, the broker delivers the property to the target component.

Attached is the source code for the entire sample view and bridge.

Source Component Code:


package net.balfes.partprop.bridge.views;


import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.*;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.SWT;

public class PropertyBridgeTest extends ViewPart {

Text propertyName = null;
Text propertyValue = null;
String oldValue = new String();

public PropertyBridgeTest() {
}

public void createPartControl(Composite parent) {
RowLayout rl = new RowLayout(SWT.VERTICAL);

parent.setLayout(rl);

Label l = new Label(parent, SWT.NONE);
l.setText("Enter property name");

RowData rd = new RowData();
rd.width = 300;

propertyName = new Text(parent, SWT.NONE);
propertyName.setLayoutData(rd);

l = new Label(parent, SWT.NONE);
l.setText("Enter property value");

propertyValue = new Text(parent, SWT.NONE);
propertyValue.setLayoutData(rd);

Button b = new Button(parent, SWT.PUSH);
b.setText("Publish");

b.addSelectionListener(new SelectionListener(){

public void widgetDefaultSelected(SelectionEvent arg0) {

}

public void widgetSelected(SelectionEvent arg0) {
firePartPropertyChanged(propertyName.getText(), oldValue, propertyValue.getText());

oldValue = propertyValue.getText();
}

});
}

public void setFocus() {
}

}

You can also install the bridge and sample view from this update site. Since its just a regular view, you will need to add the view to the CAE palette using the "Add locally installed Components" option and select "Property Bridge Test" if you intend on using it in a composite application.

Lastly, if you think this is something that should be in the base product I am more than willing to take this forward. To me its a no brainer but I am interested in hearing others thoughts.

Tags: : : :

Advertisements

1 thought on “Unleashing your Eclipse components on Notes 8.5

  1. Pingback: Full circle implementation of the part property bridge idea » Balfes.net

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.