Friday 12 April 2013

Gwt context menu


Example for gwt context menu.
here explains how to create a context menu in gwt .Using Cell list for context menu items. the below code listens  the right click event of a panel and shows a pop-up-panel 

                private MenuCell contextMenuItem = new MenuCell();
                private CellListResource resource = GWT.create(CellListResource.class);
                  private CellList<String>  contextMenuItems = new CellList<String>(contextMenuItem, resource);
                  private PopupPanel contextMenu; //using popupPanel  as a context menu
                private SingleSelectionModel<String> contextMenuSelectionModel = new SingleSelectionModel<String>();

                 private Panel topContainer;    // the container to be right clicked

                 public void onModuleLoad(){
                                 
                                   topContainer=new Panel();

                                   List<String> menuItmes=new ArrayList<String>()
                                
                                   menuItmes.add("menu item 1");
                                   menuItmes.add("menu item  2");
                                    menuItmes.add("menu item 3");
                                    menuItmes.add("menu  item 4");
                               
                                   contextMenuItems.setSelectionModel(contextMenuSelectionModel);
                                contextMenuItems.setRowCount(menuItems.size(), true);
                                contextMenuItems.setRowData(0, menuItems);

                                Panel p = new VerticalPanel();
                                p.add(contextMenuItems);    

                                    contextMenu = new PopupPanel(true);
                                    contextMenu.setStyleName("contextMenu");
                                contextMenu.add(p);
                                contextMenu.hide();
               

                                  topContainer.addHandler(new ContextMenuHandler() {
                 
                                     @Override
                                     public void onContextMenu(ContextMenuEvent event) {

                                   event.getNativeEvent().stopPropagation();
               event.getNativeEvent().preventDefault();
                                   contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                                                                event.getNativeEvent().getClientY());
                                   contextMenu.show();
                               
                                     }
                                     }, ContextMenuEvent.getType());
               
                                         contextMenuSelectionModel
                                                                .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

                                                                                @Override
                                                                                public void onSelectionChange(SelectionChangeEvent event) {
                                                                                                 // changed the context menu selection 
                                                                      Window.alert("Selected item is" + contextMenuSelectionModel.getSelectedObject());
                                                           
                                                                                          
                                                                                            
                                                                                               }               
                                                                });
                                   RootPanel.get().add(topContainer);

                         
}

Representation of a single cell
                class MenuCell extends AbstractCell<String> {

              @Override
              public void render(com.google.gwt.cell.client.Cell.Context context,
                           String value, SafeHtmlBuilder sb) {

                     SafeHtml html = SafeHtmlUtils
                                  .fromSafeConstant("<div class='cell'> " + value
                                                + "</div>");

                     sb.append(html);

              }

       }


Customization of cell style
public interface CellListResource extends  CellList.Resources {
      
         @Source({"myCellList.css"})
         CellList.Style cellListStyle();
      
}


myCellList.css
.cellListWidget {

}

.cellListEvenItem {
  cursor: pointer;
  zoom: 1;
}

.cellListOddItem {
  cursor: pointer;
  zoom: 1;
}

.cellListKeyboardSelectedItem {
  background: white;
}

@sprite .cellListSelectedItem {
  gwt-image: 'cellListSelectedBackground';
  background-color: white;
  color: white;
  height: auto;
  overflow: visible;
}





Basic style sheet (in war folder)

.cell:hover {
    border-color: #afd2fd;
    border-style: solid;
    border-width: 1px;
    background-color: #e1eefd;
    color: black;
      
}
.cell{
      
          border-color: white;
    border-style: solid;
    border-width: 1px;
       /*padding: 3px 29px 3px 10px;*/
      
       font-size: 11px;
    padding: 3px 61px 3px 41px;

}
.contextMenu {
    background-color: white;
    border-color: #979797;
    border-style: solid;
    border-width: 1px;
    box-shadow: 2px 3px 5px -3px black;
    padding: 3px;

}

-->

Thursday 28 March 2013

8 Ball Pool

Here you can play 8 Ball Pool without any network issue. If your network irritate  while playing 8 ball pool in '.miniclip' site the you can play game here. Here is chance of network issue is very low.

Friday 22 March 2013

Facebook security vulnerability





Here is the steps for how to access   someone's facebook account :


  • go to http://www.facebook.com
  • click forgot password
  • Then facebook ask for Email Id of  user

  • Enter email-Id then click Search
  • Then it shows  page like below 





















  • Then click 'No longer have  access 'these'
  • Then they ask for a new Email-ID 




















  • Enter a new Email ID of your's
  • And Click continue
























  • Click continue....
  • Then They ask for select three friends of account owner like below


  • Select any 3 friends you know and can contact.and click continue
  • Then Facebook sends security codes to the three friends  




  • Contact Friends and Enter three codes in above window.then Facebook sends Password reset link to The new E-mail you have Entered