Wednesday, April 29, 2015

Git:Checkout to newly added remote branch

For example, If new branch is added to the repository and now you wanted to setup that in your local system.

$ git fetch

This will look up the origin and update the local repository with the new data.

For example, newly added branch is 'master'. It will show something like this.

$ git branch -r

Above command tell you what are all the remote branches available.

$git checkout -b master origin/master

This will create a new branch 'master' and will have a synch with remote branch /origin/master'

KKOLIPAKA-MBP:$ git fetch
 * [new branch]      master -> origin/master

KKOLIPAKA-MBP:$ git branch -r
  origin/HEAD -> origin/development

KKOLIPAKA-MBP:$ git checkout -b master origin/master
Checking out files: 100% (453/453), done.
Branch master set up to track remote branch master from origin.

Switched to a new branch 'master'

Tuesday, April 14, 2015

Eclipse: Indirectly referenced from required .class files issue

This issue comes when your class is indirectly referring to an other class which is not accessible from your plugin.

For example:

In this scenario, if we get an error some thing like this in Plugin-C.
The type UserAgent cannot be resolved. It is indirectly referenced from required .class files.

The problem is, Plugin-C is unable to locate class from Plugin-A. Because Plugin-C is not added Plugin-A as a dependency.

2 ways we can solve this.
1. Re-export Plugin-A from Plug-in B using "Re-export this dependency" option from Properties in dependencies section.
2. Directly add Plugin-A in Plugin-C dependency list.

Monday, April 13, 2015

Eclipse Spy plugins

To make spy plugins available for your run-time eclipse, add below 2 plugins in dependencies.
1. org.eclipse.pde.runtime
2. org.eclipse.pde.ui

Showing notification or popup dialog in Eclispe

Will use PopupDialog Class from eclipse Jface framework.

I am taking about something like this.


import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class PopupDialogExample {

public static void main(String[] args) {
static void open(){
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
shell.setSize(400, 300);
Button button = new Button(shell,SWT.PUSH);
button.setText("Click here!");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
int shellStyle = PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE;
boolean takeFocusOnOpen = true;
boolean persistSize = true;
boolean persistLocation = true;
boolean showDialogMenu = true;
boolean showPersistActions = true;
String titleText = "Updates Available"
String infoText = "Eclipse updates are available!";
PopupDialog  dialog = new PopupDialog(shell, shellStyle, takeFocusOnOpen, persistSize, persistLocation, showDialogMenu, showPersistActions, titleText, infoText){

protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Label text = new Label(composite,SWT.SINGLE);
text.setText("There is a update for your plugin, please install them before proceed!");
return composite;
public void widgetDefaultSelected(SelectionEvent e) {
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();


Thursday, April 9, 2015

Eclipse Jobs framework best practice: Handling the long running background jobs while Eclipse shutdown

How to handle background jobs which are running silently for a long time during the Eclipse shutdown ?

Solution would be to cancel all the jobs before before plugin stops,so that jobs won't complain about the other resources availablity. If we don't do this, some times we can get some null pointer issues in the log.

In Plugin Activator class, just invoke Job.getJobManager().cancel(jobName);

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;

public abstract class AbstractJob extends Job

private String jobFamilyName;

public AbstractJob(String name, String jobFamilyName)
this.jobFamilyName = jobFamilyName;

public boolean belongsTo(Object family)
return this.jobFamilyName.equals(family);

Your Actual Job Implementation:

Job coreJob = new AbstractJob("Collecting assets", "ASSETS_FAMILY")

protected IStatus run(IProgressMonitor monitor)
//TODO: some long work job

return Status.OK_STATUS;


In Activate Class:

public void stop(BundleContext context) throws Exception {
plugin = null;

This will cancel all the jobs who's family name is ASSETS_FAMILY.

Wednesday, April 8, 2015

Adding resource filter for project in eclipse

project.createFilter(IResourceFilterDescription.EXCLUDE_ALL | IResourceFilterDescription.FOLDERS,
new FileInfoMatcherDescription("org.eclipse.core.resources.regexFilterMatcher", //$NON-NLS-N$
"node_modules"), IResource.BACKGROUND_REFRESH, new NullProgressMonitor());
catch (CoreException e)


This piece code will hide the "node_modules" folder from project.