Sciology = Science + Technology

Commonsense in Technology

PShelf Widget in Eclipse

Posted by sureshkrishna on December 21, 2006

PShelf Widget is really cool, if you want to implement a kind of Accordion widget in Eclipse. The Accordion widget is been gaining popularity in the end user community, especially with the AJAX and SOA presence.

Currently for simple implementations it looks quite stable. I had no problems till now. I have no idea when this project nebula is going to get integrated, but i am looking forward to it.

One good thing about this widget is that we can increase or decrease the time delay in the shelf roll-out. It also gives a very smooth transition from shelf to shelf. Can be very easily embedded into a View.

I am just adding a small snippet for the PShelf usage in a View. Hope this helps. Also this widget library it self is very very small, so you can include it very easily.

public void createPartControl(Composite parent) {
/* Create a grid layout object so the text and treeviewer
* are layed out the way I want. */
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 2;
text = new Text(parent, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER);
// layout the text field above the treeviewer
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
PShelf shelf = new PShelf(parent, SWT.BORDER);
PShelfItem shelfGroup1 = new PShelfItem(shelf, SWT.NONE);
shelfGroup1.setText("Group 1");
shelfGroup1.getBody().setLayout(new FillLayout());
Table componentTable = new Table(shelfGroup1.getBody(), SWT.NONE);
createTableItem(componentTable, "Item11");
PShelfItem shelfGroup2 = new PShelfItem(shelf, SWT.NONE);
shelfGroup2.setText("Group 2");
shelfGroup2.getBody().setLayout(new FillLayout());
Table containerTable = new Table(shelfGroup2.getBody(), SWT.NONE);
createTableItem(containerTable, "Item21");
PShelfItem shelfGroup3 = new PShelfItem(shelf, SWT.NONE);
shelfGroup3.setText("Group 3");
shelfGroup3.getBody().setLayout(new FillLayout());
Table advancedWidgets = new Table(shelfGroup3.getBody(), SWT.NONE);
createTableItem(advancedWidgets, "Item31");
GridData shelfLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);


One Response to “PShelf Widget in Eclipse”

  1. Lukas said

    Thx for this snippet.
    Nevertheless it’d be nice if you added your code comületely, e.g. the method call createTableItem() cannot be executed since it’s not there.
    Regards, Lukas

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: