Friday, November 27, 2009

Super Cool Drag n Drop Sidebar Widget (Eclipse RCP / Lotus Expeditor plug-in)

I've just ended our PoC (Proof of Concept) on a multi featured Eclipse / Expeditor based Drag n Drop Widget, and the product managers and sales guys are ecstatic. They are all really excited and explodes with new ideas to the component.

This is what it look like, right now.... (please remember it's the first PoC so it will have to undergo some UI corrections and better practices ;)





Just to mention some of the features, as it is currently....
  • It's split up into to concepts
    • A drop enabled viewer part with a filter functionality (configured to fetch and show documents from views)
    • A drop pad (here users can drop documents on the current selected target document in the current Notes context, from the inbox, calender....whatever...)
A little word on some of the features:
  • The widget is extremely configurable
  • The widget can listen to Notes document selections coming from any view, folder or alike. And if any of the selected document has a form name that matches one from the configuration....well then it's a potential drop target.
  • You can have sticky targets (targets that stays tight, even when you select other potential target documents)
  • When you drop a bunch of documents they can either get copied and "responsed" on the target / main document or you can configure it to create a DND (Drag n Drop) main document in the target database and make the drop get "responsed" on that DND document instead, enabling you to do some processing on the drop before the dropped documents gets "responsed" on the real target / main document
  • You can configure agents to run on the target document (via the NOTEID) after a drop, enabling you to do some post processing
  • The user can use the viewer to directly open the documents and databases
  • And much much more....


Here is a shot of a drop of mails in the viewer part

 

Here is a shot of a drop of mails onto the drop pad (relating to a current selected target document, which could have been selected in a random Notes view in a random application.



Here you can see some of the setup possibilities in the relating preference pages. Focus on the tabbed folder component to see the different configuration settings.

The Database Tab:



The Viewer Tab:



The Drag n Drop Tab:



The Target Tab:



Cool right? Feel free to supply with any comments and ideas.

So what's the plan now???....Well now the widget has to undergo some further investigation in a complete features set, testing, release plan and other stuff (and we are thinking of distributing it for free!!!!) but let's see what happens in the end.

Thursday, November 26, 2009

Looking for Eclipse icons

I'am out looking for icon sites that has nice Eclipse RCP icons and images.

I've found some sites and will keep updating this blog entry when I find more sites or tips.

Remember you can also search your "eclipse/plugins" folder for *.gif and *.png images.

Here is my "list" of Eclipse oriented icon sites:
If you have any knowledge on valuable Eclipse based icon sites please comment this blog entry.

Wednesday, March 11, 2009

Launching a url using a browser component

If you need to launch a url in Lotus Expeditor based clients, you have several options depending on how you want to present it.

Here's a few ways on how to do it:
  • Using a Browser Widget ( added to a Composite)
  • Using the EmbeddedBrowser View

Using a Browser Widget ( added to a Composite)
Eclipse and Lotus Expeditor offers each a simple browser widget that can be added to a composite. They a very much alike.

Here's a sample using the core Eclipse SWT browser widget:

Browser browser;
try {

browser = new Browser(composite, SWT.NONE);
browser.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true));
browser.setUrl("http://www.ibm.com");

} catch (SWTError e) {
// Handle any errors.
}

And here's a sample with the Lotus Expeditor equivalent:

WebBrowser browser;
try {

browser = new WebBrowser(composite, SWT.NONE);
browser.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true));
browser.setUrl("http://www.ibm.com");

} catch (SWTError e) {
// Handle any errors.
}


You can use the browser.setText("...") method to add custom HTML content into the browser, if needed.
You also have the ability to listen to events and traverse the DOM (Document Object Model).

Using the EmbeddedBrowser View
The Lotus Expeditor platform also gives you a viewpart based browser component.

// Every instance needs it's own unique id.
String id = "com.rcpcompany.lotus.notes.spy.browserview.sample";

// Create a map with all the needed properties.
Map configMap = new HashMap();
configMap.put(BrowserPreference.ID, id);
configMap.put(BrowserPreference.INITIAL_URL, url);

// Get the active page
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();

// Create the browser instance.
EmbeddedBrowser browser = BrowserFactory.launch(page, configMap, id);

// Maximize the new browser view if needed.
page.setPartState(page.getActivePartReference(), IWorkbenchPage.STATE_MAXIMIZED);

Tuesday, March 3, 2009

Getting access to files in Eclipse plug-ins

There are several ways to access files in Eclipse. Here are some samples
  • Getting an ImageDescriptor from a plug-in
  • Getting a resolved URL to a resource in another plug-in
  • Opening a resource in an editor

Getting an ImageDescriptor from a plug-in

You can get an image descriptor to an image resource via the
  • UIPlugin.imageDescriptorFromPlugin("pluginId", "icons/image.png")

Getting a URL to a resource inside a plug-in
First you have to have a plug-in (Bundle). Your can get it via
  • Activator.getDefault().getBundle() or
  • Platform.getBundle("plug-in id")

//If you want to access your own plug-in use Activator.getDefault().getBundle()

Bundle bundle = Platform.getBundle("org.eclipse.ui");

// This line return a url looking like this, bundleentry://921/plugin.xml
URL url = bundle.getEntry("/plugin.xml");

try {
// This line resolves the bundle resource url to an explicit file url into the bundle
// The url will get to look like below,
// jar:file:C:\...\org.eclipse.ui_3.4.0.I20080610-1200.jar!/plugin.xml
URL realUrl = FileLocator.resolve(url);

} catch (IOException e) {
e.printStackTrace();
}


Opening a resource in an editor
Here is a sample on how to open the org.eclipse.ui plugin.xml in an editor.

// Start by getting an IPath to a bundle resource.
IPath path = null;
URL url = null;
try {
url = FileLocator.toFileURL( Platform.getBundle("org.eclipse.ui").getEntry("/plugin.xml"));
path = new Path(url.getPath());
} catch (IOException e) {

e.printStackTrace();
}

// Next, use the Eclipse file store to validate and pass to an editor
IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);

if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {

IWorkbenchPage page = getSite().getPage();
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
e.printStackTrace();
}
}

Listening for selected Lotus Notes documents

If you want to react when documents are selected in the Notes client, you will use the Eclipse Selection Service.

When listening you can reference the some of the document summary classes
  • DocumentSummary (base class for selections)
  • NotesDocumentSummary (document selection in view or when opened)
  • NotesOpenDocumentSummary (only when opened)
  • NotesFieldSelection (field activation in open document)
  • NotesLiveNameSelection (live name field activation in open document)
  • And many others
The classes are located in the following plug-ins
  • com.ibm.csi
  • com.ibm.notes.client

Creating the listener


// Prepare the selection listening. Start by getting the selection service.
ISelectionService ss = getSite().getWorkbenchWindow().getSelectionService();

// Create a selection listener
listener = new ISelectionListener() {

public void selectionChanged(IWorkbenchPart part, ISelection selection) {

// Is the selection a structured selection
if (selection instanceof IStructuredSelection) {

// Get the selection (could contain multiple selected objects)
IStructuredSelection ss = (IStructuredSelection) selection;

// Are the any objects in the selection?
if (ss.isEmpty()) return;

// Let's test the first selected object
Object e = ss.getFirstElement();

// Is the object a NotesOpenDocumentSummary?
if (e instanceof NotesOpenDocumentSummary) {
NotesOpenDocumentSummary ds = (NotesOpenDocumentSummary)e;
String title = ds.getTitle();
String url = ds.getUrl();

//...

}
}
}
};

// Add a post selection listener, so we don't have to listen to
// insignificant UP and DOWN keystroke selection triggering,

// we just need the final selection.

ss.addPostSelectionListener( listener);

Removing the listener
Remember to remove you listener when done.

// Do the following in the dispose() method of the view part or alike.

public void dispose() {
if (listener != null) {
ISelectionService ss = getSite().getWorkbenchWindow().getSelectionService();
ss.removePostSelectionListener(listener);
}
super.dispose();
}

Search This Blog

Eclipse Live: Equinox Ganymede

The creator of an Eclipse Bible, introduces Equinox and its building blocks for creating applications. We overview the architecture and technology, and demonstrate many of the building blocks.
by Jeff McAffer (Code 9)