Wednesday, February 27, 2013

Enhance your navigator by decorating resources

Is your project explorer stuffed with too many projects? Are you looking for a way to get more structure into this? I was suffering from this problem for a long time now, having workspaces with 50+ projects in it. I am using Working Sets and Mylyn, still I sometimes get lost within all my resources.

Resource Decorator Plugin

So I came up with a nice little plugin that allows to add custom decorations to your resources. Eg you could set a dedicated background color for all your projects that fit to a dedicated name pattern. You could also set the foreground color for all your src folders or highlight plugin.xml files.


The Resource Decoration is accessible through the Navigator context menu, which contains some quick decorations and a generic wizard that allows to fine tune your settings. There you can build generic filters by creating a tree structure. The Resource filter will match a resource path within your workspace. This will always be an exact match. The RegExp filter takes a regular expression to match it against the resource name. You have to use drag and drop to build your filters, DEL will remove a selected filter along with its children.


To alter decorations you can go to Preferences / General / Appearance / Resource Decorator. Take care that the Resource Decorator is enabled in Preferences / General / Appearance / Label Decorations (which should be the default setting).


The tool is at a very early stage as the interface is a little rough and filtering is a bit limited so far. Yet it is working, save and quite useful to me.

Installation

When you are interested in this little helper you can install it from

http://codeandme.googlecode.com/svn/trunk/at.pontesegger/at.pontesegger.resourcedecorator.releng.p2/target/repository

Please use the bugtracker at googlecode to report any issues or additional ideas.

The whole project is available under EPL, source code is located at Google code.

Tuesday, February 19, 2013

Using git flow in eclipse

Git flow is a great way to improve your development process. It helps in setting up dedicated branches for development, releases and fixes. If you are not familiar with git flow please read a successful git branching model before continuing. Git flow is extremely easy to use and really worth a try.

Git flow is currently not integrated in eclipse (see bug 348610), so we need to use a command line to use it. Basically I love the power of command lines but when using an IDE I prefer visual support, so lets find a way to make this a bit more user friendly.

For this tutorial I assume you are using windows (if you were on linux you would love your bash anyway).

Step 1: Installing msysgit

As we need to enter commands on the command line we need to install the necessary tools for that, no way to avoid that.

Download and install the latest version of Git. At the time of writing this is v1.8.1.2. Go with the default settings when asked for the components and select Run Git from the Windows Command Prompt when asked for Adjusting your PATH environment. Line endings can be configured as you prefer.

You need to log off so your PATH variable will be updated accordingly. Afterwards you should be able to use the git command in a console.

Step 2: Installing git flow

Now we need to install the git flow addon. Here is a short excerpt of the install wiki page:

We need 2 additional files to download and copy to our msysgit/bin folder:
Go to the util-linux-ng download site and download the Binaries zip. From there extract only getopt.exe. Then download Dependencies zip to extraxt libintl3.dll.

During the setup we need to create a temporary directory. Open a command shell and switch to your temp directory
cd temp
git clone --recursive git://github.com/nvie/gitflow.git
cd gitflow
contrib\msysgit-install.cmd
The install command should work if you are using the default install locatin for msysgit. If it still cannot find msysgit you have to provide the install location as a parameter.

Afterwards try to run gitflow by entering
git flow
in a shell. If it works you can safely remove your temporary install folder.

Step 3: Using git flow

We are ready to use git flow by now from our shell. So give it a try, best following the blog post by Jeff Kreeftmeijer: Why aren't you using git-flow?

Step 4: Adding a shell to eclipse

WickedShell is a nice plugin for eclipse that integrates a shell into the IDE. Install it and restart your IDE. Now you can open a new view Wicked Shell / Shell which basically gives you a command prompt on windows. While you can use the windows shell I would rather go with bash.

To activate it go to Preferences / Wicked Shell and select Cygwin - Bash as Default Static Shell. To make it work you need to provide your msysgit install directory under Shell root directory (do not provide the bin dir, but its parent).

You can change the Active Shell in the view menu of the Shell view.

You may see some strange characters on the prompt by now. These are control codes which cannot be displayed by the SWT widget (at least not the way wicked shell is implemented). So we need to change the prompt. Find your home directory (enter: cd ~;pwd) and create a .bashrc file with following content:
PS1='\w $ '
You should not exchange the $ sign at the end as it is used as command delimiter token by wicked shell. If you go with some other character, wicked shell will automatically insert a $ when you type your first character.

Considerations

WickedShell seems to have its limitations. So it is not possible to send a CTRL-C in a shell. I also experienced problems when trying to enter text a command prompts for (therefore the git flow init command does not work). Fortunately you need only single line commands once git flow is initialized correctly. If you need a full shell you could still Open an external Shell from the Shell view menu.

I tested WickedShell on Windows 7, according to the bugtracker there seems to be no support for Windows 8 yet.