Tuesday, July 30, 2013

Tree expand/collapse issue in NatTable(0.9->1.0)

I was facing tree expand/collapse issue in NatTable after migrating from 0.9 to 1.0 version.  I could not even expand or collapse a tree after migration, it was disabled completely so we can’t even see the children of a tree.

This can be resolved by configuring CellPainterMouseEventMatcher with GridRegion.BODY  instead of  TreeLayer.TREE_COLUMN_CELL

If you are facing the same issue, this would be useful tip.




ToolTip information on NatTable cells


Default implementation is provided by ‘DefaultToolTip’ class from Jface, so we can override getText() method to provide tool tip information based on the specific criteria.

Example below:



import java.util.Properties;

import org.eclipse.jface.window.DefaultToolTip;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;


public class MyXToolTip extends DefaultToolTip {

private NatTable natTable;
private XSpanningDataProvider bodyDataProvider;


public MyXToolTip (NatTable natTable, XSpanningDataProvider bodyDataProvider) {
super(natTable, ToolTip.NO_RECREATE, false);
this.natTable = natTable;
this.bodyDataProvider = bodyDataProvider;
}


protected Object getToolTipArea(Event event) {
int col = natTable.getColumnPositionByX(event.x);
int row = natTable.getRowPositionByY(event.y);

//if any specific implementation here ex: You want to display tooltip information only on first column. if(col != 0) return;

return new Point(col, row);
}

protected String getText(Event event) {
int col = natTable.getColumnPositionByX(event.x);
int row = natTable.getRowPositionByY(event.y);

ILayerCell cell = natTable.getCellByPosition(col, row);
INode rowObject = bodyDataProvider.getRowObject(cell.getRowIndex()); //my INode Object which has specific cell information
String channelName = rowObject.getName();

//If any specific implementation here, ex: mixing column and row information
return channelName;
}

protected Composite createToolTipContentArea(Event event, Composite parent) {
// This is where you could get really creative with your tooltips...
return super.createToolTipContentArea(event, parent);
}
}


Thursday, July 18, 2013

Eclipse NatTable: How do you render Checkbox, Image and Text in a single cell

Say, below is your requirement. I am showing only part of the complete dialog below.


I am talking here about first column,rending check box and windows 8 image and followed by display text.

Do the following:
Use a TextPainter, decorate it (CellPainterDecorator) with an ImagePainter, use the resulting painter as base painter of another decorator and decorate it with a CheckboxPainter


//Text painter to diplay text
TextPainter textPainter = new TextPainter() {
//Any specific implementation
};


//My image painter
 class MyImagePainter extends ImagePainter {

private MyData data = null
public MyImagePainter(MyData data) {
this.data = data; //this would be useful, what image has to displayed on call.
}

@Override
protected Image getImage(ILayerCell cell, IConfigRegistry configRegistry) {
//return specific image on data object and it's properties.
return null;
}
 }

//Cell painter decorator for image and text
CellPainterDecorator cellPainterDecorator = new CellPainterDecorator(
textPainter, //text painter
CellEdgeEnum.LEFT, //Image should left side of Text
new MyImagePainter(bodyDataProvider)); //Image Painter
 
//Wrapper for cellPainterDecorator  and checkbox
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
new CellPainterWrapper(new BackgroundPainter(
new CellPainterDecorator(
cellPainterDecorator, //decorator to render image and text
CellEdgeEnum.LEFT, // check box has to be displayed left hand side of the cell.
myCheckBoxPainter)), // check box painter
10),
DisplayMode.NORMAL,
TreeLayer.TREE_COLUMN_CELL);

registerEditing(configRegistry, TreeLayer.TREE_COLUMN_CELL);


























Maintaining clear git history tree

This is what I have learned from my colleague few days back.

My general workflow with git:
Git pull origin Dev-5.0
Then I would have worked for a day or two
Now, I want to push my changes for last 2 days. But, in mean time many people in my team also would have pushed the code.
Git commit  “last 2 days commits message”
Git pull origin Dev-5.0 -> get the latest code from server again
Git push origin Dev-5.0 -> push your committed changes to the server


But, this is creating a very bad hierarchy tree in git(gitk). Like below













The problem here is, while I am committing my code I don't have the latest code from central repository. This would create a different tree hierarchy in git from my last state, and only when I push my code it will merge your local branch with the central repository. Then it will connect your local branch tree node to the central tree node.

Below is the approach which has worked out for us.

Git pull origin Dev-5.0
Then you might be working for few days
Now you want to commit your changes.
Git stash   -> stash your current changes in local repository
Git pull origin Dev-5.0   -> Get the latest changes from the central repository
Now your local repository has latest changes
Apply your stashed changes on latest changes which we have pulled from central repository.
Git stash pop -> This will apply stashed changes to current changes.
If any merge conflicts, resolve them
Git commit  “my changes”
Git push origin Dev-5.0    => This would fail, if somebody else has pushed the code in mean time after your last pull, so we need to pull the code again and proceed with the push.

This is how it looks, if we maintain the above procedure.









Tuesday, July 16, 2013

Companies which are working on Eclipse related development

Companies which are working on Eclipse Plug-in development related work.

Hyderabad:
IBM ISL -Many products they have on Eclipse- Rational rose, myEclipse, OpenStack development
Kony Labs - KonyOne IDE
Pramati - Pramati servers which are based on OSGI
Progress Software - Many products which are based on Eclipse
ModelN - Enterprise modeling tools
Xilinx Inc - Embeded/chip modeling tools/Programmable logic development
Rockwell Collins - Aircraft solutions
Oracle
..very few!!!

Bangalore:
IBM ISL
SAP Labs - BO IDT, HANA Studio, BRM/BPM Tool
Mercedes Benz Research Lab
Robert Bosch
..many more!!!

Design thinking


2 years back, I have attended the session from the founders of "Realizing Empathy" Org on "Design Thinking". It was really amazing!!, they gave a lot of insight on Design thinking.

It's a new way of thinking to build a great products with innovative ideas.
With Design Thinking you organize your creative thoughts with empathy, communication, optimism, experimentation and collaboration. You put the persons and all their needs in the centre when analysing a problem and looking for a solution. You have a challenge, and this challenge is based on 3 things: people, technology and business. You need to be careful and look for results that can be meaningful for the people, technically feasible and economically viable.


fig dt.jpg



Wednesday, July 10, 2013

Determine windows is 32 or 64 bit using Java Programatically

import com.sun.servicetag.SystemEnvironment;

"os.arch" environment may not give you the correct architecture.
Let's try out.

public class OSArchLies {
  
  public static void main(String[] args) {
    
    // Will say "x86" even on a 64-bit machine using a 32-bit Java runtime
    SystemEnvironment env =   SystemEnvironment.getSystemEnvironment();
    final String envArch = env.getOsArchitecture();
    
    // The os.arch property will also say "x86" on a 64-bit machine using a 32-bit runtime
    final String propArch = System.getProperty("os.arch");
    
    System.out.println( "getOsArchitecture() says => " + envArch );
    System.out.println( "getProperty() says => " + propArch );
    
  }

}

Environment: Windows 7, 64 bit os, 32 bit JVM

Output:
getOsArchitecture() says => x86
getProperty() says => x86


Try this approach,

public class Windows32Or64bitCheck {

public static void main(String[] args) {
        boolean is64bit = false;
       
        System.out.println(System.getProperty("sun.arch.data.model", "?"));
        System.out.println(System.getProperty("os.arch")); // Please note, the os.arch property will only give you the architecture of the JRE, not of the underlying os. 
        System.out.println(System.getenv("ProgramFiles(x86)"));
        
        if (System.getProperty("os.name").contains("Windows")) {
            is64bit = (System.getenv("ProgramFiles(x86)") != null);
        } else {
            is64bit = (System.getProperty("os.arch").indexOf("64") != -1);
        }
        System.out.println("is64bit: " + is64bit);
 }

}

Environment: Windows 7, 64 bit os, 32 bit JVM

Output:
32
x86
C:\Program Files (x86)
is64bit: true


This is the only way which i could find from Java( Using native C, there is a better and accurate way to achieve this) 

Using C, please follow below link

Other way I have learned recently, using Windows wmi service calls.
>  wmic OS get OSArchitecture


C:\Users\KH1205>wmic OS get OSArchitecture
OSArchitecture
64-bit

Try to run this command programatically using Java Runtime process.

JSLint integration for the Eclipse IDE

JSLint is a well-know JavaScript validation library developed by Douglas Crockford. The library allows developer to validate JavaScript against a set of best practices that have been developed over the years.

Here is the link for download:
http://marketplace.eclipse.org/content/jslint-eclipse-plugin#.Ud0-3vnYLdU

Friday, July 5, 2013

Multitenancy vs Multi-instance Architecture

Multitenancy Architecture:

Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants).


With a multitenant architecture, a software application is designed to virtually partition its data and configuration, and each client organization works with a customized virtual application instance.


Multitenancy is also regarded as one of the essential attributes of cloud computing.


Multi-instance architecture:

Multitenancy is contrasted with a Multi-instance architecture, where separate software instances  are set up to serve different client organizations


As we can see in the below architecture diagram, In case of multi-tentant design, a single hardware is configured with single operating system to server all the clients, but virtually it's partition the data in the database  to avoid the security issues.In certain cases, client might have configured individual databases based upon their requirement.


In multi-instance architecture, on a single hardware server we will be setting up the virtualization software is also called hardware virtualization, on top of it every client can setup their own operating system, application server and end user application. Here, every instance is completely independent of each other.



Architectures




Here are some of the pros and cons of each.

For a multi-instance architecture, the pros are:
  • Cost effective based on the use of common hardware and resources
  • Inherently more secure and isolated environment
  • Greater flexibility and control of configuration, updates and upgrades (timing, content controlled by customer), change management and SLAs
  • Less chance that a provider, user or malicious behavior will impact performance and reliability of multiple customers
  • Investment protection – ability to migrate to premise over time should business needs, preferences dictate
  • Simplicity in software architecture, especially as the number of customers grows
The Cons are:
  • Higher operational effort and cost for providers
  • Requires more hardware in the provider’s data center
  • More provider time and resources required to update/upgrade large numbers of customers
  • Less suited to support consumer scale applications (hundreds of thousands to millions of customers)
  • Requires more billing and contract management overhead
  • Provider has less insight into application usage and behavior across customer base
For a Multi-Tenant Architecture, the Pros include:
  • Cost effective via use of common hardware and resources
  • Requires less hardware in provider data center
  • Less time and resources required to update/upgrade large numbers of customers
  • Better suited to support consumer scale applications (hundreds of thousands to millions of customers)
  • Requires less billing and contract management overhead
  • Provider has greater insight into application usage and behavior across customer base
The Cons are:
  • Higher development/testing effort and cost for providers
  • Inherently less secure and isolated environment
  • More chance that a provider, user or malicious behavior will impact performance and reliability of multiple customers
  • Less flexibility and control of configuration, updates and upgrades (timing, content controlled by provider and applied to all customers simultaneously), change management and SLAs
  • Loss of investment if customer chooses to move to premise over time
  • Complex software architecture to support all users on same instance in a secure and reliable manner, especially as the number of customers grows

Monday, July 1, 2013

GIT Remote Branches

You might want to figure out, what are the branches exist in the git remote repository,then you want to choose the specific one which you are looking and check them out and merge them into a local repository.

The easiest way do it:
>git branch <-a/-r>

-a => List down all branches- remote and local
-r => List down only remote branches.

Example:

K1205@K1205 /d/Work/KIDE/jsdebugger (master)
$ git branch
  Dev-5.0
  jsdebugger_plugins-master.06
* master

K1205@K1205 /d/Work/KIDE/jsdebugger (master)
$ git branch -a
  Dev-5.0
  jsdebugger_plugins-master.06
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/JSD-BETA-5.0.05
  remotes/origin/JSD-BETA-5.0.06
  remotes/origin/JSD-GA-5.0.01
  remotes/origin/JSD-GA-5.0.02
  remotes/origin/JSD-GA-5.0.3
  remotes/origin/JSD-GM-5.0
  remotes/origin/JSD-QA-5.0.01
  remotes/origin/JSD-QA-5.0.02
  remotes/origin/JSD-QA-5.0.03
  remotes/origin/JSD-QA-5.0.04
  remotes/origin/JSD-QA-5.0.05
  remotes/origin/JSD-QA-5.0.06
  remotes/origin/JSD-QA-5.0.06.01
  remotes/origin/jsdebugger_plugin-master.01
  remotes/origin/jsdebugger_plugins-master.01
  remotes/origin/jsdebugger_plugins-master.02
  remotes/origin/jsdebugger_plugins-master.03
  remotes/origin/jsdebugger_plugins-master.04
  remotes/origin/jsdebugger_plugins-master.05
  remotes/origin/jsdebugger_plugins-master.06
  remotes/origin/master

K1205@K1205 /d/Work/KIDE/jsdebugger (master)
$ git branch -r
  origin/HEAD -> origin/master
  origin/JSD-BETA-5.0.05
  origin/JSD-BETA-5.0.06
  origin/JSD-GA-5.0.01
  origin/JSD-GA-5.0.02
  origin/JSD-GA-5.0.3
  origin/JSD-GM-5.0
  origin/JSD-QA-5.0.01
  origin/JSD-QA-5.0.02
  origin/JSD-QA-5.0.03
  origin/JSD-QA-5.0.04
  origin/JSD-QA-5.0.05
  origin/JSD-QA-5.0.06
  origin/JSD-QA-5.0.06.01
  origin/jsdebugger_plugin-master.01
  origin/jsdebugger_plugins-master.01
  origin/jsdebugger_plugins-master.02
  origin/jsdebugger_plugins-master.03
  origin/jsdebugger_plugins-master.04
  origin/jsdebugger_plugins-master.05
  origin/jsdebugger_plugins-master.06
  origin/master

Eclipse 4.3 new features

This release was more focused from the tools development and integration point of view, not much enhancements from the underlying platform architecture end.

Here you can find, top 10 Eclipse Kepler Features by Ian Bull 

Eclipse workbench internals

I have come across very good article on eclipse workbench internals. Please find the link below.
http://www.eclipse.org/articles/Article-UI-Workbench/workbench.html


Workbench Hierarchy:




Eclipse Workbench Representation:






Eclipse Nat Table - Advanced SWT Table widget

Nat Table is the implementation on top of SWT Table with a lot of additional features.

The list includes:
  • Multiple row spanning
  • Multiple column spanning
  • Better paining mechanism in table cells
  • Better way of hooking a model to the table.

 These are the features which I have used so far..but there are many more!!



Here is the link from Eclipse, where you can find everything about it.

Eclipse RCP Best Practices