Monday, July 8, 2013

Swt Tables setting the check box in cetre of the cell

tbleViewer.getTable().addListener(SWT.PaintItem, new Listener() {
 ......
.......

 int tmpWidth1 = 0;
                int tmpHeight1 = 0;
                int tmpX1 = 0;
                int tmpY1 = 0;
                tmpWidth1 = tbleViewer.getTable().getColumn(event.index).getWidth();
                tmpHeight1 = ((TableItem)event.item).getBounds().height;
       
                tmpX1 = tmpImage1.getBounds().width;
                tmpX1 = (tmpWidth1 / 2 - tmpX / 2);
                tmpY1 = tmpImage1.getBounds().height;
                tmpY1 = (tmpHeight1 / 2 - tmpY / 2);
                if(tmpX1 <= 0) tmpX1 = event.x;
                else tmpX1 += event1.x;
                if(tmpY1 <= 0) tmpY1 = event.y;
                else tmpY1 += event.y;
                event1.gc.drawImage(tmpImage1, tmpX1, tmpY1);

Courtsey : Read it somewhere on the internet and this stuff works .Full credit to the unknown author of this code ...

Friday, June 14, 2013

Endings


Endings are very important part for any story probably the only part that matters .
A story with solid ending is always a superhit .
Here is a flop story , a story which should have never happened ,because it brought only sorrow guilt and nothing else .
Sammer loved a girl name shweta . They were quite close to each other . Their love story almost went for over 6 years . Even though it was a long distance love story ,they always felt each other's company .
Cracks had started coming through after end college and start of professional life . Gestures made more sense that feelings . Giving time to each other was very difficult for them ,even though they had plenty for time  .There were tensions in the family as well . One day family agreed but she refused , Shweta had shown how unpredictable a girl can be . Fate played its part in dividing them . Its been almost three years since the breakup
still sameer remembers her .Still is not able to understand whose fault is it . He always asks himself some questions . Some questions which he never gets the answers to .
How ever good the story is if ending is not good then all work done is gone .
How ever truly you love somebody , how much but if you are not together with each other then its of no use.
Why is it that only Sameer had an unsuccessful love story and not others . People around him all have successful love story . Sameer ponders sometimes whether  he did something wrong to deserve this , or did he love the wrong person . Whom to blame ? Or is it that he should have never loved anybody .Generally he blame himself for this .
He feels that he was weak , his love was not strong enough to hold her near him .He let her go .Why did he  do so .
Fate never wanted them together , in the end he played in the fate's hand He read some where that if true love is there it will surely find a way back in . he also tried that but it never returned back . It went and went far and far away from him never to return back ,. here he is sitting alone in the theater , in the park , his bike's pillow seat is always empty . No one to hold hand and console him  . There is something left in his heart , some memories , some faint pictures of his love ,some moments they shared . A beer will do tonight not to forget her but just to go near those memories deep inside his heart be there for sometime no one to disturb .
He have learnt somethings , If you gonna love some day some body be sure to be with him/her till the end ,don't leave him in between .
Sameer probably won't love anybody as he used to love her . He always feels that he is weak , guilty .
I never think that sameer was wrong in what he did ,but you can't make sameer understand .The fault was the with the one who was not able to stand up with him . How can sameer expect her to stand with him through out his life .
Make sure that there is proper ending to your story . Don't leave the story unfinished .

Friday, April 19, 2013

Creating SWT table


                    SWT TableViewer

Below I will try to explain you as to how to create a SWT table .
1.Set the layout on the composite over which you wanna create the Table specifying width and height etc .

2. Create a table
         TableViewer tableViewer = new TableViewer(parentComposite,SWT.BORDER );

3.Set the content provider
          tableViewer.setContentProvider(new TableContentProvider())
here TableContentProvider is implemeting IStructuredContentProvider
its method : public Object[] getElements(Object inputElement)
 Returns the elements in the input, which must be either an array or a Collection
So what ever you set as Input in the table we must convert it into array of objects here .

4. Set the LabelProvider  :tableViewer.setLabelProvider(new tableLabelprovider())
         tableLabelprovider    implements ITableLabelProvider
Here we can override two methods
  public String getColumnText(Object element, int columnIndex) : Returns the label text for the given column of the given element.
 Get the model which you setting in the table as input from element and using switch case we can return the value for each column according to the column Index
this is to set the label for each field in your table

5.Add columns according to your requirement

6. If you want any kind of cellEditor eg:TextCellEditor ,CheckboxCellEditor,Dialog cellEditor ,then you have  to add CellEditors for each column . If you want your column to be editable then we can use TextCellEditor .
7. set a cellModifier to your table viewer .
here in the method canModify we have to return true if for a particular column you want it to be editable .
in the method getValue() return value from your model according to the column (property name )
in the method modify() get the value from the table that has been modified and set it to your model and save the model accordingly .
Remember to refresh your table viewer .




Monday, April 8, 2013

Creating quick fix extension for Eclipse Below i am listing the steps needed for creating quick fix extensions in eclipse . I am assuming that the problem has already been registered with eclipse 1.Create a marker type with extension point org.eclipse.core.resources.markers 2.Extend the org.eclipse.ui.ide.markerResolution extension point and create a markerresolutiongenerator . 3.add the marker type while creating the validation error in the code . 4.Create a class resolution generator implements IMarkerResolutionGenerator and register it to plugin while extending the extension point markerResolution . 5.In the function getResolutions(IMarker marker) return a new object which implements IMarkerResolution2 . 6.In the run function do the necessary work . 7.Use other methods such as getDescription() etc to make ur quick fix more informative

Wednesday, March 20, 2013

Happy Bday Dear !!

Last week was my friends birthday , one of the closest , who shares almost everything . As usual people wished him , he got gifts ,cake cutting , friends ko party bhi di .
Phir bhi kuch kami si mehsus ho rahi thi was his exact words that evening .There was something missing . Why was this different if you ask me then nothing much only that a person used to call him sharp at 12 'o clk , would fight if somebody else wished him before her .A gift not very costly but would make him very happy .Par aaj wo nahi hain uske pas . She is not there to pamper him , fight with him , tease him ...
He often ask this question to himself , why he need some one in his life .Now he have freedom ,no restrictions ,just   like khula sandh .. no one going to get angry if he sleep before 12 o clk or if  he go out with his friend(most of the times with me :) ) and stay late without calling her . No fights with his  parents over the issue of marriage . No one in the society is going to point a finger at him . If there are so many  (+)ves out of being single then why he still feel the emptiness . Why he cry when he watches  a romantic movie .Why he still wakes up in the night and check for missed calls . Why he  crave for her so much .He  doesn't have the patience to deal with a new relation but still some where in his heart he wants it . He wants it badly . May be its just the hormones playing its part . May be seeing others getting settled .He feels that he has missed something big in his life .

This word LOVE  confuses me a lot . It gives a lot of pain , a bit of happiness but still every body wants it. May be our mind is designed insanely to crave for it .
ps: I feel pity on my friend . Its his feeling and and my words .  So all people who still have their loved  ones beside you holding ur hands at every moment of ur life cherish it because it feels much more worse than what i have written .Hope i never have to through what my dearest friend went through .

Tuesday, March 5, 2013

Who's Right ?

People tend to evaluate themselves .
Every time they tend to judge themselves even though you might not be noticing .
We have this inherent habit of judging our past decisions ,what we did was right or wrong .
We want somebody to judge us . That's why most of us believe in God .
The very meaning of God is someone who's watching us from above and being impartial he/she will tell us
about the things we did were right or wrong .
We want to be judged .That's why majority of us are aesthetic  .
Confident people are 80% sure about their decisions but still 20% thinks the other way .
Now coming back to the original topic who's right ?
I have been bugged by this questions ever since i don't since when .
If everybody wants themselves to be judged so whom should i believe .
If someone tells me that my decision is wrong then on what basis should i it think as wrong or right
just that he /she gives some valid points to dismiss my points . No way .
If we take the above point then everybody who thinks that their decisions are right might be wrong
and those whom we think are wrong may be right .
Then again another thing comes to my mind as to who's Good and who's Evil .
Just that some section of society thinks that a person is evil should not be a valid basis for declaring him/her
as Evil .No way .
My blog confuses me more as i am still confused as to whats right and whats wrong .
I wrote this to clarify myself as to who's right and who's wrong .
I have concluded to myself that if others tell me that your decisions are wrong  i would say ,Better mind your own business ,I am free to make my own decisions . I will do whats seems right to me . You are no God to tell me that i am wrong or right .
I am free and i make my own decisions .
Cheers to freedom .
:-)
Sunny Shekhar