Thursday, March 22, 2007

Eclipse Code Snippets

In this post I am collecting some useful code snippets for programming eclipse. Currently they are not in any order.

Access Status Bar of Eclipse Workbench

final IActionBars actionBars = getViewSite().getActionBars();
IStatusLineManager status = actionBars.getStatusLineManager();
status.setMessage("Status Message");


Console Manipulation
runInUIThread(
new Runnable() {
public void run() {
try{
IViewPart consoleView = PlatformUI.getWorkbench().
getActiveWorkbenchWindow().getActivePage()
.showView("org.eclipse.ui.console.ConsoleView");
}catch(Exception e){
System.out.println("Console Not Highlighted "+e);
}
}
});


GEF Undo/Redo Contextual Text
To provide contextual text in GEF Undo/Redo menu actions (e.g. instead of plain Undo you want Undo XYZ), please provide a label to every command. For that please override the setLabel(String label) of Command Class.

More can be found here.

No comments:


(c) Jyotirmaya Nanda 2012