Friday, August 22, 2014

Converting Java io File to eclipse IFile resource

Below function will convert File to eclipse IFile resource.

public IFile convert(File file) {
   IWorkspace workspace= ResourcesPlugin.getWorkspace();  
   IPath location= Path.fromOSString(file.getAbsolutePath());
   IFile ifile= workspace.getRoot().getFileForLocation(location);
 return ifile;


This works only when resource exists with in the workspace.

Accessing the resources outside the workspace:

Debugging web applications - fiddler

Configuring Permgen parameter for Tomcat

Wednesday, August 13, 2014

git pull: Couldn't reserve space for cygwin's heap, Win32 error 0

When I tried to pull the code from git, it took so long and finally it said "Couldn't reserve space for cygwin's heap, Win32 error 0"

There are various discussions which I found over web. But the first thing which i tried was "restarting my windows system" and it worked for me!!


Tuesday, August 12, 2014

Opening eclipse editor or view in the dialog programatically

We can open eclipse editor or view in the dialog by using the Eclipse e4 model services. This is also called detaching the editors/views from the eclipse workbench.

For this, you need to have e4 workbench plugin and it provides org.eclipse.e4.ui.workbench.modeling API services.

IWorkbench workbench = ActivatorPlugin.getDefault().getWorkbench();

//get editorpart somehow which you wanted to open it.
EditorPart openEditor = /*IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), module, MyEditorID, false); */

//get editor site
IWorkbenchPartSite site = openEditor.getSite();

//get model service for editor site
EModelService modelService = (EModelService) site.getService(EModelService.class);
MPartSashContainerElement  mpartService = (MPart) site.getService(MPart.class);

//invoke detach on model service with coordinates.
modelService.detach(mpartService, 100, 100, 700, 700);

For view:

//Get view part
IViewPart view = workbench.getActiveWorkbenchWindow().getActivePage().findView(MyPerspective.ExplorerView_ID);
//get site for view
//invoke detach


Saturday, August 2, 2014

Hide toolbar in eclipse programatically

You might want to remove eclipse toolbar completely in your Eclipse RCP product to make use of that space or you might not have any useful toolbar actions which are specific to your product.

This how you can remove programatically.

private void hideCoolbar() {
try {
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
if (service != null)
service.executeCommand("org.eclipse.ui.ToggleCoolbarAction", null);
} catch (Exception e) {
KEditorPlugin.logError("Unable to hide the eclipse toolbar.",e);

Hide tool bar in eclipse

In eclipse 3.8 version and earlier, you can find "Hide Toolbar" option on the right click of eclipse toolbar itself. This will hide the complete toolbar.

In Eclipse e4 versions, you can find this option in on the Eclipse toolbar Window menu.
Window -> Hide Toolbar

To enable again,
Window -> Show Toolbar