Wednesday, June 10, 2015

How to rebase your pull request

But, why ?

Your pull request(PR) might be pretty old and in mean time many people would have changed the same code. So you can't simply merge your PR into master branch because of the conflicts.

Step 1:
Fetch the latest code from remote master branch.
> git fetch upstream

here upstream is pointing to a remote repository.

Step 2:
If you have multiple commits, it's better to squash them. But it's an optional step.
>git merge-base <yourforkedbranch> <mainremotebranch>
Example: git merge-base TISTUD-9000 release

This will give the hash-id.
>git rebase --interactive <hash-id>

It will list down the commits, If you have more than one, you can replace 'pick' by 'squash' for commits expect first one.
Example:
pick 4455 
squash 5555
squash 85858

Step 3:
Run rebase command
>git rebase upstream/master

For sure, this will fail because of the conflicts. I mean, that's the main reason why we wanted to go for rebase here.

And once you resolve the conflicts continue with the rebase --continue.

Step 4: 
Update the pull request forcefully
>git push -f

or
> git push origin <yourbranch> -f

This is the crystal clear resource which will talk about this.


Thursday, May 28, 2015

How to specify to load a eclipse plugin only on 32 bit machine but not on 64 bit machine.

It’s simple, specify Eclipse-PlatformFilter flag in MANIFEST.MF file with the required criteria.

For example, I wanted to load my plugin only in 32 bit operating systems.
Eclipse-PlatformFilter: (osgi.os=win32)

for adding multiple conditions.
Eclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))

The Framework supports filtering on the following system properties:
* osgi.nl - the platform language setting.
* osgi.os - the platform operating system.
* osgi.arch - the platform architecture.
* osgi.ws - the platform windowing system


Above example specify that, this bundle can only be resolved if the platform properties are osgi.ws=win32 and osgi.os=win32 and osgi.arch=x86. In other words a platform running on an x86 architecture, using a win32 operating system and the win32 windowing system.

We can find this property directly in plugin.xml file "Overview" tab.

Wednesday, May 13, 2015

Eclipse toolbar and menu bar group action id's

ICommonMenuConstants
IWorkbenchActionConstants
IIDEActionConstants


Few examples:
"group.new"
"group.goto"
"group.open"
"group.openWith"
"group.show"
"group.edit"
"group.reorganize"
"group.port"
"group.generate"
"group.search"
"group.build"
"additions"
"group.properties"

These will be used as a insertion points if you are contributing a new action/menu action/toolbar action.


Tuesday, May 12, 2015

Hiding certain UI elements from Eclipse RCP

We can achieve this by using "org.eclipse.ui.activities" extension point.

http://blog.vogella.com/2009/07/13/eclipse-activities/


We also use "Perspective Extensions" extension.
Example:
<extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="com.kk.StudioPerspective">
         <hiddenToolBarItem
               id="new.group">
         </hiddenToolBarItem>
      </perspectiveExtension>
   </extension>

Tuesday, May 5, 2015

Running multiple commands from single batch file in Windows

If your batch file is having multiple commands and those commands are trying to execute or invoke other batch commands something like this.

Example:
SET PATH=%PATH%;%PROGRAMFILES%\nodejs;%PROGRAMFILES(x86)%\nodejs;%APPDATA%\npm
npm install -g mypackageinstaller
mypackageinstaller use latest


If you run above commands from a batch file, only first 2 commands 
will be get executed and the last one will be ignored.

Reason being, here npm is a batch file from Node, once windows command process invokes npm process,after npm get executed it will not return to the original command process. Hence,third command won't be executed from a batch file.

To avoid these issues, we can invoke these kind of commands using 
"call".

Modified batch script:

SET PATH=%PATH%;%PROGRAMFILES%\nodejs;%PROGRAMFILES(x86)%\nodejs;%APPDATA%\npm
call npm install -g mypackageinstaller
call mypackageinstaller use latest

All these commands will be executed sequentially.

To make them parallel, we can use "start" command.

Listening to project explorer changes

If you want to control some actions based on the selection of an element from the project explorer, we can register a post selection changes through service registry.

//Register listener
ISelectionService ss = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();

ProjectExplorerSelectionListener selectionListener = new ProjectExplorerSelectionListener();
ss.addPostSelectionListener(IPageLayout.ID_PROJECT_EXPLORER, selectionListener);



//Listener
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;

class ProjectExplorerSelectionListener implements ISelectionListener
{
public void selectionChanged(IWorkbenchPart part, ISelection newSelection)
{
if (newSelection instanceof IStructuredSelection)
{
Object element = ((IStructuredSelection) newSelection).getFirstElement();
if (element instanceof IAdaptable)
{
IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
final IProject project = resource.getProject();
//do your action here!!
}
}

}

}