Thursday, March 26, 2009

Academic Earth

Academic earth is an organization that has been started to provide world class education through video lectures of some of the great scholars from Harvard, Yale, Stanford, MIT. Well this is a for profit organization and has been started from a young entrepreneur from Yale.

Most of the videos I watched are in the area of entrepreneurship with about 10 min talks from some professors and entrepreneurs and I should mention that they are very good.

Good work guys keep it up..

Tuesday, March 24, 2009

setting cell height of a grid

Actually the cell height of the grid in gxt changes based on the text and the initial line height is set to 15px. I tried to set it through CSS, but i wasn’t able to. So i decided to change the CSS in the “ext-all.css” which is a very bad idea. But this is one of the easier approaches that i could think of, but it works since we have javascript developed for each module as such, so using the changed CSS for one module doesn’t effect much. Anyways, the following has been modified to change the height of the cell to 50px.

.x-grid3-cell-inner
{
    HEIGHT : 50px;
    PADDING-BOTTOM: 3px;
    PADDING-LEFT: 5px;
    TEXT-OVERFLOW: ellipsis;
    PADDING-RIGHT: 3px;
    WHITE-SPACE: nowrap;
    OVERFLOW: hidden;
    PADDING-TOP: 3px;
    border: 1px solid #ffff;
    -o-text-overflow: ellipsis
}
and also 
.x-grid3-row TD
{
    LINE-HEIGHT : 15px;
    PADDING-LEFT: 1px;
    PADDING-RIGHT: 1px;
    VERTICAL-ALIGN: top;
    -moz-user-select: none
}

I am adding the highlighted attributes to the CSS, which will set the cell height to 50px and the line height for the cell to be 15px. So, the cell is display a total of 3 lines correctly.

Friday, March 20, 2009

Multi cell selection in a row in a grid in gxt

I have been working on selecting multiple cells in a particular row of a grid. This is a requirement for the schedule calendar that i am trying to build at work. This functionality as far as i know is not provided by gxt and thus i wrote a class that extends the CellSelectionModel and   that uses the same technique to select multiple rows in the grid. The user has to press the shift key for multi cell selection and also it should be noted that the selection is for only one row in a grid.

After working it out, in my selection the first cell is always not selected. On looking into it, i figured out that it is the problem of the focus. The gxt’s onfocus event occurs after i set the selected cells, so the first cell looses focus. In-order to  figure out a solution, i am not sure if this is the right way to do this, but i decided to use the DeferredCommand class from GWT. The code written in DeferredCommand is used executed after all the events are handled. So in this case i am setting the style to “cell-selected” after all the events are done, so it works perfectly fine. And the multi selection works only with the shift key.

package com.peoplenet.weekView.client;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.widget.grid.CellSelectionModel;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
/**
 * This class is an extension of CellSelectionModel. 
 * The CellSelectionModel allows us to select only one cell at a particular time. 
 * This Class allows us to select multiple cells in a particular row in a grid.
 * Multi select is performed by pressing the shift key with the mouse click
 *  
 * @author Ravikanth Kolli
 * @version 1.0
 * 
 * @param <M>
 */
public class RowCellSelectionModel<M extends ModelData> extends CellSelectionModel<M> { 
	int lastSelectedRow;
	int lastSelectedCol;
	private CellSelection selected ;
	List<CellSelection> cellsSelected = new ArrayList<CellSelection>();
	/**
	 * Overriding the handleMouseDown event.
	 * MultiSelect is done by pressing the shiftkey 
	 */
	@Override
	protected void handleMouseDown(GridEvent e) {
		if(e.colIndex ==0 )
			return;
		if(lastSelectedRow == 0)
		{
			selected = new CellSelection(store.getAt(e.rowIndex),e.rowIndex,e.colIndex);
			cellsSelected.add(selected);
			lastSelectedRow = e.rowIndex;
			lastSelectedCol = e.colIndex;
		}else if (lastSelectedRow == e.rowIndex && e.isShiftKey())
		{
			cellsSelected.clear();
			for (int i = 1 ; i < 8; i++) {
				Element cell = grid.getView().getCell(lastSelectedRow, i);
				if (cell != null) {
					El.fly(cell).removeStyleName("x-grid3-cell-selected");
				}
			}
			
			if(lastSelectedCol > e.colIndex){
				for (int iter = e.colIndex; iter < lastSelectedCol ; iter++)
				{
					selected = new CellSelection(store.getAt(e.rowIndex),e.rowIndex,iter);
					cellsSelected.add(selected);
				}
				lastSelectedRow = e.rowIndex;
			}else
			{
				for (int iter = lastSelectedCol; iter < e.colIndex + 1 ; iter++)
				{
					selected = new CellSelection(store.getAt(e.rowIndex),e.rowIndex,iter);
					cellsSelected.add(selected);
				}
				lastSelectedRow  = e.rowIndex;
			}
		}else
		{
			cellsSelected.clear();
			for (int i = 1 ; i < 8; i++)
			{
				Element cell = grid.getView().getCell(lastSelectedRow, i);
				if (cell != null) {
					El.fly(cell).removeStyleName("x-grid3-cell-selected");
				}
			}
			selected = new CellSelection(store.getAt(e.rowIndex),e.rowIndex,e.colIndex);
			cellsSelected.add(selected);
			lastSelectedRow = e.rowIndex;
			lastSelectedCol = e.colIndex;
		}
		
		DeferredCommand.addCommand(new Command() {
	        public void execute() {
	        	for (int iter = 0 ; iter < cellsSelected.size() ; iter++) {	
	    			Element element = grid.getView().getCell(cellsSelected.get(iter).row,cellsSelected.get(iter).cell);
	    			
	    			if (element != null) {
	    				El.fly(element).addStyleName("x-grid3-cell-selected");
	    			}	
	    		}     
	        }
	      });
		
		super.handleMouseDown(e);
	}
	/**
	 * Method to get the list of all the selected cells at a particular time
	 * @return list of selected CellSelections.
	 */
	public List<CellSelection> getSelectedCells()
	{
		return cellsSelected;
	}
}

Thursday, March 19, 2009

Blogging from shozu app..

Well I just downloaded an app called shozu. Well the app looks pretty good to me but it would hve been a bit more effective if it is available in landscape view.. Well atleast it gives an option for users to blog on the go..

Posted by ShoZu

Tuesday, March 10, 2009

workstation service

If you are trying to access a network, or if you are meddling with your windows services, make sure that the workstation service in started as it relates to accessing files over a local network. You can get to this service through Control Panel - > Administrative tools -> services.

Wednesday, March 4, 2009

Learning C#, basics of .net

A friend of mine took up the initiative to teach .NET to a bunch of illiterate guys ( well that includes me to) . So far we are done with 2 sessions and just started delving into the basics of .NET. I hope atleast this attempt of my learning .NET gets successful.