Thursday, September 12, 2013

Intellij Idea task repository plugin creation

Key notes
1) Reuse existing infrastructure
@Tag("Rally") // This is name of part in xml configuration file where your settings will be stored
public class RallyRepository extends BaseRepositoryImpl {

public class RallyRepositoryType extends BaseRepositoryType<RallyRepository> {
// UI things are located here (repository name, icon and stuff)

public class RallyTask extends Task {
// It's all about tasks. But nothing special here. Just implement all methods carefully

META-INF/plugin.xml
// In this file you may find some plugin configuration. But there is also nothing special

Making all the stuff works
All configuration goes through repository deitor which is responsible for reading changing and storing configuration. So extend existing one:

public class RallyRepositoryEditor extends BaseRepositoryEditor<RallyRepository> {

What is necesary to understand before implementation is that editor is tightly coupled with repository itself. Main items:
1) Editor check if something changed via equals method of repository (In our case RallyRepository)
2) Editor uses copying constructor of repository to create new changed instance of it
3) Editor serializes and deserializes repository according to bean conventions by default, so don't forget about appropriate getters and setters
4) Also don't use getXXX and setXXX methods for fields you don't whant to serialize. (There is @Transient annotation and you can use it)
5) Don't invoke logger in constructior of repository

You may refer my own plugin at github for additional implementation details (https://github.com/crc83/rallydev). I changed a lot from one that I forked (https://github.com/RallySoftware/intellij-plugin).

Download ready to use jar you can from here (http://dl.bintray.com/crc83/generic/rallydev.zip).

Monday, April 1, 2013

BuildHive + Github, Precommit builds for free

In previous post I wrote about integration your github repository with continious integration server buildhive from cloudbees.
Now I'd like to write about one incredible feature I discovered recently.
Here is it. BuildHive CI server tracs all pul requests to your repository. So what it do when it discover new pull request? It build your master with changes from pullrequest. Then CI server makes comment to your pull request in case build was succesfull or not (see screenshot above).

And last but not least. You CAN make pull requests to your own repo in case you need this feature and you owner of the repo.



Thursday, January 3, 2013

Opensource development ecosystem


 My aim was to have compleatly free development ecosystem for one project. Since this is java project I whanted to have java ecosystem. As a source control system was choosen git and that's why project was hosted at github (you know where it is so I don't put link here).
the JenktocatI start looking for free CI service. First I found Travis-CI but to maintain build there I have to make additional file in my repository (but at that time I was a bit lazy to do so). Fortunally I found another service. It's BuildHive from Cloudbees (and here is the link https://buildhive.cloudbees.com/). This service is based on Jenkins-CI and it was first plus. The second plus was the way to configure build. Actually you don't need to configure build, just type shell comands to build project ant that's it. 


Monday, December 17, 2012

How to change your jenkins theme

Why? 

Because I have two environments: development and production. They look very similar and I don't whant to broke production environment during testing

How?

1) Install theme plugin
 
 2) Add your css and js (and img) files under %JEKINNS_INSTALLATION_PATH%/userContent folder

 3) Add links to these files in configuration
 

4)* You may left blank field with JS file if you don't have one

 

What I've got?

With css below 
 #top-panel > * {
    background-color : #B80000 !important;
 }
I've got this result

Wednesday, October 10, 2012

EnvMan4J

Short story 

Recently I evaluated couple of code generation Java frameworks and I faced with one interesting issue. Every framework or application server wants to have XXX_HOME variable and %XXX_HOME%/bin element in a path variable.
I dreamed about tool that do such thing for a long time. And now I decided to write it. I choose Lazarus to write this tool because it must be native application (in case I need to set JAVA_HOME ;) ). Now this program works fine with Windows (I have only one open issue). Hope I will also make Linux version.

Where to get

You may get this application from my github https://github.com/crc83/EnvMan4J

Case study

I made short screen cast because it's better to see once than to hear many times. You may find it here

Monday, August 20, 2012

Eclipse plugins that I like and dislike

EclEmma - code coverage
Checkstyle - check style
Subverse - svn client (remove) TortoiseSVN plugin instead
LogViewer - for Log viewing
JInto -messages (deletes comments in message files)
Jautodoc - javadocs generator
InstaSearch - quick search in all files
GoToFile - fast go to file http://www.muermann.org/gotofile/update
Eclipse2ant - creates ant build script easily (ugly ant script)
Subclipse - svn client  http://subclipse.tigris.org/update_1.8.x
QuickImage - for picture viewer (useful in pair with bug tracing system)
AnyEdit - easily replace tabs by spaces and vice versa http://andrei.gmxhome.de/eclipse/
ContextMenu - invokes Explorer context menu http://timealias.bplaced.net/ContextMenuPlugin/update/
EasyShell - Opens system shell in eclipse
GrepConsole - Allows you colorify console output

Wednesday, July 25, 2012

Vim in four days

Vim is the one of the most powerful and widely used text editor. But how can you learn it staying at home with children. The answer is simple and straightforward. You can learn vim by rough memorizing. 
For inspiration you may use any youtube screencast
As a step by step guide I use this book. I read one chapter in 10-20 minutes. Then I try to recollect shortcuts while playing with children. At the evening or on the next morning I try to use them. And here is result of past three days.

1-st day

  • Navigation keys "hjkl".
  • Insert {"i"} and normal {Esc} mode. 
  • page up and page down {CTRL-U CTRL-D}
  • undo {"u"} and block undo {"U"}
  • Home {"^"} and end {"$"}

2-nd day

  • Word by word navigation {"b" "w"}
  • Delete word {"dw"}or couple of words {"d5w"}
  • Append characters to the end {"A"}
  • Delete line {"dd"}
  • append line {"o" "O"}

3-rd day

  • Join lines {"J"} or join five lines at once {"5J"}
  • Find character "s" in line {"fs"}
  • Repeat last modifcation {"."}
  • Record macro for key "n" {"qn" commands... then "q"}
  • Invoke recorded macro {"@n"}

4-th day

I skipped some parts since I don't need it in near future (and they are boring :) ). These parts are:
  • Filtering 
  • Working with windows
Then I stucked with visual block mode. I even can't turn it on (with CTRL-V hotkey). I googled a little bit and found the solution. Use CTRL-Q instead of CTRL-V on Windows.
Visual block mode I'm going to learn with tecnique read and try because I can't imagine behavior of VIM.
BTW: Vrapper fo Eclipse still doesn't support visual block mode.

Sunday, March 11, 2012

Using ZTL (Zkoss testing language) framework and Concordion for integration testing



To use ZTL for integration testing we have to inherit org.zkoss.ztl.ZKClientTestCase. We should initialize some variables for testcase (for example in constructor)
            target = "http://localhost:8080/ZK-demo";
            browsers = getBrowsers("iexplore");
            _timeout=100;
To use Concordion we also have to inherit org.concordion.integration.junit3.ConcordionTestCase. But Java doesn’t allow us to use multiple inheritances. So we should replace one of inheritances to usage. I did it for ZKClientTestCase. All of the fields listed above are protected. I made class ZKIntegrationTestCase that inherits ZKClientTestCase. In that class I made public setters and getters for those fields. So we don’t need to use inheritance for ZTL
public class SpecTest extends ConcordionTestCase{
      private ZKIntegrationTestCase ZKFunctionalTestCase zk;

      public SpecTest() {
            zk = new ZKIntegrationTestCaseZKFunctionalTestCase();
            zk.setTarget("http://localhost:8080/ZK-demo");
            zk.setBrowsers(zk.makeListOfBrowsers("iexplore"));
            zk._setTimeout(100);
You may find patched ZTL library (ztl), sample project(ZK-demo) and sample test project(ztl-demo) here: https://github.com/crc83/ztl
Hope it help you make quick rampup.

All about Concordion you may find here: http://www.concordion.org/
Original ZTL you may also find at github: https://github.com/zkoss/ztl
And forum about ZTL issues is here: http://www.zkoss.org/forum/listComment/17556/1/20

Tuesday, January 10, 2012

Fluent interface in java


Simple and robust.

Task

I need to have several sets of methods of class, that can be invoked in special order using fluent interface. For example I need to have always first init(int a) method in a chain. In a second chain I need to have add(int a) and reset() methods. For the third chain I’d like to have dec(int a) and getValue() methods. getValue() method will return a result.

Solution

It’s good idea to use inner classes.
package org.sbelei;

public class FluentInterfaceSample {
     
      private SecondChain chain2;
      private ThirdChain chain3;
     
      private int value;

      {
            chain2 = new SecondChain();
            chain3 = new ThirdChain();
      }
     
      public static FluentInterfaceSample create(){
            return new FluentInterfaceSample();
      }
     
      public SecondChain init(int start){
            value = start;
            return chain2;
      }
     
      class SecondChain {
            public ThirdChain add(int a){
                  value += a;
                  return chain3;
            }
           
            public ThirdChain reset(){
                  value = 0;
                  return chain3;
            }
      }
     
      class ThirdChain {
            public ThirdChain dec(int b){
                  value -=b;
                  return chain3;
            }
           
            public int getValue(){
                  return value;
            }
      }
     
      public static void main(String[] args){
            int b = create().init(31).add(12).dec(10).getValue();
            System.out.println(b);
      }
}

Sunday, December 18, 2011

Bar-code readers


There is huge zoo of these devices. They are divided to different groups from marketing and user point of view. In this post I'd like to introduce you a third point of view. Point of view of software engineer.

1. Quick start

Bar-code reader is always read only device for PC.
Bar-code reader could be configured via scanning special bar-codes from it's user manual
You can configure many parameters in that way. The most interesting for us are prefix and suffix of code sequence (I'll back to this later in details)

2. Two kinds of bar-code readers

I divided our bar-code readers zoo in two parts: 1. Bar-code readers that interact with PC like HID devices (these includes PS/2 and USB bar-code readers); 2. Bar-code readers that connects via RS-232 port.
Both of these kinds of devices have their advantages and disadvantages.

2.1. HID devices

Pros:
+ Easy to prepare your program to work with them.
+ You have no need to handle reconnection issues and the like.
Cons:
- There is sometimes hard to determine if we have input from bar-code reader or from keyboard (but this can be solved by using a prefixes and suffixes).

2.2. RS- 232 devices

Pros:
+ You always know that input that you receive is from bar-code reader.
Cons:
- You should handle reading from RS-232 port in your program.
- You should handle connection issues in your program.

3.N.B.

If you make some mistakes in configuration of bar-code readers, there is a page with “reset to factory defaults” sequence in user manual (Check if you have this page before making any changes in configuration).