public void draw(DoneDrawingCallback callback) { removeAll(); final List<ColumnConfig> cols = getColumns(); final Map<String, RowData> group = getGroupsForRows(); final Map<String, String> groupIDToName = new HashMap<String, String>(); final GroupingStore<BaseModelData> store = new GroupingStore<BaseModelData>(); for (RowData row : getRows()) { final BaseModelData model = new BaseModelData(); model.set("id", row.getField("id")); model.set("lockid", row.getField("lockid")); for (ColumnConfig col : cols) model.set(col.getId(), row.getField(col.getId())); RowData gID = group.get(row.getField("id")); if (gID == null) { model.set("groupid", "none"); model.set("groupidentifier", null); groupIDToName.put("none", "No Group Defined"); } else { model.set("groupid", gID.get("groupid")); model.set("groupidentifier", gID.get("id")); groupIDToName.put(gID.get("groupid"), "Working Set: " + gID.get("groupname")); } store.add(model); } store.groupBy("groupid"); final GroupingView view = new GroupingView(); view.setShowGroupedColumn(false); view.setGroupRenderer( new GridGroupRenderer() { public String render(GroupColumnData data) { return groupIDToName.get(data.group); } }); final GridSelectionModel<BaseModelData> sel = new GridSelectionModel<BaseModelData>(); sel.setSelectionMode(SelectionMode.SINGLE); grid = new Grid<BaseModelData>(store, new ColumnModel(cols)); grid.setSelectionModel(sel); grid.setView(view); grid.addListener( Events.RowClick, new Listener<GridEvent>() { public void handleEvent(GridEvent be) { if (groupButton != null && be != null && be.getModel() != null) groupButton.setEnabled(be.getModel().get("groupidentifier") != null); } }); // grid.setWidth(680); int size = 25; final LayoutContainer wrapper = new LayoutContainer(); wrapper.setLayout(new FillLayout()); // wrapper.setScrollMode(Scroll.ALWAYS); wrapper.add(grid); final LayoutContainer container = new LayoutContainer(new BorderLayout()); container.setBorders(false); container.add(getToolBar(), new BorderLayoutData(LayoutRegion.SOUTH, size, size, size)); container.add(wrapper, new BorderLayoutData(LayoutRegion.CENTER)); add(container); callback.isDrawn(); }
public Map<String, RowData> getGroupsForRows() { final Map<String, RowData> map = new LinkedHashMap<String, RowData>(); for (RowData row : LockLoader.impl.getPersistentLockGroups()) map.put(row.getField("persistentlockid"), row); return map; }