Monday, July 27, 2009

Eclipse Summit India

The Eclipse Summit India 2009, held in Bangalore on July 17-18, has been a great success. I enjoyed performing two 3-hrs workshops: "Plugin Development - Tips and Tricks" and "Design Patterns Used in Eclipse". In the first workshop I showed how to make a simple RCP application flexible with OSGi Services, extensible with Extension-Points and achieve production quality leveraging from advanced concepts like usage of Adapters, JFace Data Binding, Presentation API and, finally, deploying the product with P2 provisioning mechanism. In the second workshop we've had a look at OOP design patterns from another perspective: how this or that pattern is used in Eclipse and what are the possible advantages or pitfalls.

Here you can find the presentation files:
* Plug-in development - Tips and Tricks
* Design Patterns in Eclipse

Thursday, July 05, 2007

Europa deciphered

For those who get confused with guessing which features belong to which distribution I tried to create a short overview of Europa downloadable IDE distros:


































































































-Classic
Java
J2EE
RCP/Plug-in
C/C++
RCP/Platform+++++++
CVS++++++
EMF
+ (some)++ (some)
GEF
+++
JDT+++++
Mylin
+++
WST
+ (some)++ (some)
PDE++
+++
Datatools

+

JST

+

CDT



+


So, my choice is definitely a J2EE edition (I got some concerns whether this distro contains everything necessary for plug-in development).

I find it a bit disappointing that Eclipse guys have not prepared similar overview. Nevertheless, nothing can be 100% perfect ;)
Great release, great features, long live Europa!

Monday, June 25, 2007

IAction and Runnable

Does anybody know why org.eclipse.jface.IAction does not explicitly implement java.lang.Runnable interface?
I have always interpreted the IAction interface as "decorated Runnable" and I think there may be certain use cases where you might want your actions implement java.lang.Runnable.
Why is it like that? It seems that I miss some point here...

Friday, June 22, 2007

JFace snippets

Tom Schindl has recently posted a blog entry on topic "Why do we Devs need Code-Snippets". In this post Tom introduces the collection of JFace code snippets which is definitely useful for all JFace newcomers.

Wednesday, May 23, 2007

Java Stack Trace Console

Recently I've discovered another nice feature of Eclipse: you may paste a stack trace into the Java Stack Trace Console and use that nice hyperlinks to navigate the trace. You can open a new console instance from the Open Console drop-down menu in the Console view or even use an existing Java console. With Java Stack Trace Console it is possible to format the stack trace with standard Format key binding. If you use a running Java console, the pasted trace is presented in green color.



Nice feature for rapid analyzing of plain-text logs, isn't it?

P.S. This feature was introduced in Eclipse 3.1. Well, one has to pay more attention to "New and Noteworthy" issues ;)

Monday, May 21, 2007

How to learn if the Workbench is going to be restarted upon closing

Sometimes you need to intercept the Workbench shutdown event and check whether the workbench is being shut down or just restarted. Depending on that you may want to do something with your backend.
Unfortunately there is no public API for that - everything what we have is the IWorkbench#isClosing() method, which does not tell us if it's gonna be a restart or shutdown. However, in the internal implementation of IWorkbench (org.eclipse.ui.internal.Workbench) there is a private int field named "returnCode", which is set to PlatformUI.RETURN_RESTART value if somebody calls the restart() method.
Using reflection you can get the value of this field:

/**
* The method uses the private field of the internal IWorkbench implementation,
* since there is no public API to check whether the Workbench is being restarted.
*
* @return true, if the workbench is restarting
*
* @author Ilya Shinkarenko
*/
private boolean isWorkbenchRestarting() {
int returnValue = 0;
IWorkbench workbench = PlatformUI.getWorkbench();
try {
Field field = workbench.getClass().getDeclaredField("returnCode");
field.setAccessible(true);
Object value = field.get(workbench);
//the value is always Integer
returnValue = ((Integer)value).intValue();
}
catch (Exception e) {
//report the exception

}
return returnValue == PlatformUI.RETURN_RESTART;
}

Wednesday, May 09, 2007

Eclipse shared images

In Eclipse RCP there are several shared images which are accessible in the following way:

PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);

Here is the list of all shared images with their corresponding ISharedImages.* keys:


IMG_DEF_VIEW

IMG_OBJS_BKMRK_TSK

IMG_OBJS_ERROR_TSK

IMG_OBJS_INFO_TSK

IMG_OBJS_TASK_TSK

IMG_OBJS_WARN_TSK

IMG_OBJ_FILE

IMG_OBJ_FOLDER

IMG_OBJ_PROJECT

IMG_OBJ_PROJECT_CLOSED

IMG_OPEN_MARKER

IMG_TOOL_BACK

IMG_TOOL_BACK_DISABLED

IMG_TOOL_BACK_HOVER

IMG_TOOL_COPY

IMG_TOOL_COPY_DISABLED

IMG_TOOL_COPY_HOVER

IMG_TOOL_CUT

IMG_TOOL_CUT_DISABLED

IMG_TOOL_CUT_HOVER

IMG_TOOL_DELETE

IMG_TOOL_DELETE_DISABLED

IMG_TOOL_DELETE_HOVER

IMG_TOOL_FORWARD

IMG_TOOL_FORWARD_DISABLED

IMG_TOOL_FORWARD_HOVER

IMG_TOOL_NEW_WIZARD

IMG_TOOL_NEW_WIZARD_DISABLED

IMG_TOOL_NEW_WIZARD_HOVER

IMG_TOOL_PASTE

IMG_TOOL_PASTE_DISABLED

IMG_TOOL_PASTE_HOVER

IMG_TOOL_REDO

IMG_TOOL_REDO_DISABLED

IMG_TOOL_REDO_HOVER

IMG_TOOL_UNDO

IMG_TOOL_UNDO_DISABLED

IMG_TOOL_UNDO_HOVER

IMG_TOOL_UP

IMG_TOOL_UP_DISABLED

IMG_TOOL_UP_HOVER