0 comments Monday, October 27, 2008

I looked for this for a while. Eclipse 3.x has the swooshed tab headers that taper towards the end.

To get that in your RCP application where you may use IFolderLayout to group views, or have multiple editors you need to make your Eclipse application a product and do the following:


To get the swoosh on any tabfolder that you create in your code. You have to use CTabFolder as follows:


CTabFolder tabFolder = new CTabFolder(shell, SWT.CLOSE | SWT.BOTTOM);


The following line does the magic:

tabFolder.setSimple(false);

1 comments Wednesday, September 10, 2008

The following technique can be used to get the currently active page and any view within that page.



IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = page.findView(MyView.ID);


The MyView.ID specified the ID of the view as declared in the plugin.xml file.



0 comments

If you want to add a custom dialog to a JFace application the easiest way is to override the JFace Dialog class as follows:

public class MyDialog extends Dialog {
/**
* @param parentShell
*/
public MyDialog(Shell parentShell) {
super(parentShell);

//forces open method to block until window is closed.
setBlockOnOpen(true);

}

@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID,
IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);

}


@Override
protected Control createDialogArea(Composite parent) {

Composite container = (Composite) super.createDialogArea(parent);

Label nameLabel = new Label(container,SWT.NONE);
nameLabel.setText("Name:");
Text nameText = new Text(container, SWT.BORDER);

return container;

}
}
The way you call it within any Action is as follows:
MyDialog d = new MyDialog(Display.getCurrent().getActiveShell());
int status = d.open();
For this example the open method will return OK or CANCEL. It is user-definable by overriding the getReturnCode() method on Dialog.

Make the Dialog resizable
By default it isnt, You must call this in the Dialog constructor:
Dialog.setShellStyle(SWT.RESIZE)

Change the Dialog title
You need to override the Window.configureShell method as follows

protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("My Dialog Title");
}

0 comments

When I started working on a new project at work, I had to decide on the UI platform I wanted to develop in. We have considerable Java experience in-house and hence we were limited to something on the Java platform. I have considerable experience designing in Swing, but I was really smitten by the Eclipse IDE UI. After researching other options that were available, Eclipse RCP seemed to be the most robust, with a well developed code-base, community support and online resources. However as I have started to work with Eclipse RCP, I realized that versions changed quite often and the literature wasnt keeping up. Good online resources that really go in-depth and teach complex tasks were very scarce. The best way to learn how to do stuff was to look at the Eclipse IDE codebase.


I started this blog as a place to document RCP/JFace/SWT tips and tricks that I learnt the hard way.