Advertisement
Guest User

GridView

a guest
Dec 26th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.92 KB | None | 0 0
  1. public class AfanemekGridView
  2.         extends
  3.         BaseGridViewWithPaging<AfanemekGridActivity, AfanemekDomainProxy, AfanemekDomainProxyProperties, AfanemekRequest> {
  4.  
  5.     public AfanemekGridView() {
  6.         super();
  7.         HashMap<String, Object> hashMap = new HashMap<String, Object>();
  8.         hashMap.put(AbstractGridView.WITHCHECKCOLUMN, true);
  9.         setOptions(hashMap);
  10.  
  11.     }
  12.  
  13.     @Override
  14.     protected List<ColumnConfig<AfanemekDomainProxy, ?>> createColumns() {
  15.         ColumnConfig<AfanemekDomainProxy, String> nevColumnConfig = new ColumnConfig<AfanemekDomainProxy, String>(
  16.                 properties.nev(), 50, "Név");
  17.         ColumnConfig<AfanemekDomainProxy, BigDecimal> szazalekColumnConfig = new ColumnConfig<AfanemekDomainProxy, BigDecimal>(
  18.                 properties.szazalek(), 50, "Százalék");
  19.  
  20.         List<ColumnConfig<AfanemekDomainProxy, ?>> arrayList = new ArrayList<ColumnConfig<AfanemekDomainProxy, ?>>();
  21.         arrayList.add(nevColumnConfig);
  22.         arrayList.add(szazalekColumnConfig);
  23.  
  24.         return arrayList;
  25.     }
  26.  
  27.     @Override
  28.     protected ListStore<AfanemekDomainProxy> createNewListStore() {
  29.         return new ListStore<AfanemekDomainProxy>(properties.id());
  30.     }
  31.  
  32.     @Override
  33.     protected boolean isChecked(AfanemekDomainProxy dp) {
  34.         // TODO Auto-generated method stub
  35.         return false;
  36.     }
  37.  
  38.     @Override
  39.     public void bind() {
  40.         // TODO Auto-generated method stub
  41.  
  42.     }
  43.  
  44.     @Override
  45.     protected void clickEditColumn(Object object) {
  46.         presenter.clickEditColumn(object);
  47.     }
  48.  
  49.     @Override
  50.     protected void clickDeleteColumn(Object object) {
  51.         presenter.clickDeleteColumn(object);
  52.     }
  53.  
  54.     @Override
  55.     protected VerticalLayoutContainer createGrid() {
  56.         checkBoxSelectionModel = null;
  57.         // create columns
  58.         List<ColumnConfig<AfanemekDomainProxy, ?>> columns = createColumns();
  59.  
  60.         // ha kell checkboxcolumn akkor letrehozzuk
  61.         if (options != null && options.containsKey(WITHCHECKCOLUMN)) {
  62.             IdentityValueProvider<AfanemekDomainProxy> identityValueProvider = new IdentityValueProvider<AfanemekDomainProxy>(
  63.                     "szamlazoban_active");
  64.             checkBoxSelectionModel = new CheckBoxSelectionModel<AfanemekDomainProxy>(identityValueProvider);
  65.             columns.add(0, checkBoxSelectionModel.getColumn());
  66.         }
  67.  
  68.         // extra columns
  69.         createDeleteColumn(columns);
  70.         createEditColumn(columns);
  71.  
  72.         ColumnModel<AfanemekDomainProxy> columnModel = new ColumnModel<AfanemekDomainProxy>(columns);
  73.  
  74.         final Grid<AfanemekDomainProxy> grid = new Grid<AfanemekDomainProxy>(listStore, columnModel) {
  75.             @Override
  76.             protected void onAfterFirstAttach() {
  77.                 super.onAfterFirstAttach();
  78.                 Scheduler.get().scheduleDeferred(new ScheduledCommand() {
  79.                     @Override
  80.                     public void execute() {
  81.                         handleAfterFirstAttachGrid();
  82.                     }
  83.                 });
  84.             }
  85.         };
  86.         grid.getView().setForceFit(true);
  87.         grid.getView().setAutoFill(true);
  88.         grid.setLoadMask(true);
  89.         grid.getView().setStripeRows(true);
  90.         grid.setColumnReordering(true);
  91.         grid.setColumnResize(true);
  92.         if (checkBoxSelectionModel != null) {
  93.             grid.setSelectionModel(checkBoxSelectionModel);
  94.  
  95.         }
  96.         grid.addAttachHandler(new Handler() {
  97.             @Override
  98.             public void onAttachOrDetach(AttachEvent event) {
  99.                 // erre azert van szukseg mert mert ha mar egyszer megjelenitettuk akkor masodszorra
  100.                 // amikor csatoljuk a felulethez akkor azt csak igy tudjuk erzekelni
  101.                 if (event.isAttached() == true) {
  102.                     if (firstAttach == true) {
  103.                         firstAttach = false;
  104.                     } else {
  105.                         handleAttachGrid();
  106.                     }
  107.                 }
  108.             }
  109.         });
  110.  
  111.         VerticalLayoutContainer verticalLayoutContainer = new VerticalLayoutContainer();
  112.         ToolBar createTopToolBar = createTopToolBar();
  113.         createTopToolBar.setEnableOverflow(true);
  114.         if (createTopToolBar != null) {
  115.             verticalLayoutContainer.add(createTopToolBar, new VerticalLayoutData(1, -1));
  116.         }
  117.         verticalLayoutContainer.add(grid, new VerticalLayoutData(1, -1));
  118.         verticalLayoutContainer.setScrollMode(ScrollMode.AUTO);
  119.         verticalLayoutContainer.add(pagingToolBar, new VerticalLayoutData(1, -1));
  120.  
  121.         return verticalLayoutContainer;
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement