List of usage examples for com.google.gwt.view.client CellPreviewEvent getValue
public T getValue()
From source file:com.agnie.gwt.common.client.rpc.MultiSelectEventTranslator.java
License:Open Source License
@Override public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) { NativeEvent nativeEvent = event.getNativeEvent(); if ("click".equals(nativeEvent.getType())) { // Determine if we clicked on a checkbox. Element target = nativeEvent.getEventTarget().cast(); if ("input".equals(target.getTagName().toLowerCase())) { final InputElement input = target.cast(); if ("checkbox".equals(input.getType().toLowerCase())) { // Synchronize the checkbox with the current selection state. input.setChecked(event.getDisplay().getSelectionModel().isSelected(event.getValue())); return SelectAction.TOGGLE; }/*from w w w .j a v a2 s. co m*/ } else if (cmd != null) { cmd.setSelected(event.getValue()); Scheduler.get().scheduleDeferred(cmd); } } return SelectAction.IGNORE; }
From source file:com.google.gwt.sample.showcase.client.content.cell.CustomKeyboardHandler.java
@Override public void onCellPreview(CellPreviewEvent<ContactInfo> event) { if (Settings.get().getKeyHandling()) { NativeEvent nativeEvent = event.getNativeEvent(); if (nativeEvent.getType() == BrowserEvents.KEYDOWN) { // A key was pushed down if (nativeEvent.getShiftKey() || nativeEvent.getAltKey() || nativeEvent.getCtrlKey() || nativeEvent.getMetaKey()) { // Ignore if a modifier key is down return; }//from w w w.j a v a 2 s . c o m switch (nativeEvent.getKeyCode()) { case KeyCodes.KEY_DOWN: // The down arrow key case KeyCodes.KEY_J: setCurrentRow(cellList.getKeyboardSelectedRow() + 1); cancelEvent(event); break; case KeyCodes.KEY_UP: // The up arrow key case KeyCodes.KEY_K: if (cellList.getKeyboardSelectedRow() < 1) { goAboveList(event.getValue()); } else { setCurrentRow(cellList.getKeyboardSelectedRow() - 1); } cancelEvent(event); break; case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_SPACE: setCurrentRow(cellList.getKeyboardSelectedRow() + PAGE_INCREMENT); cancelEvent(event); break; case KeyCodes.KEY_PAGEUP: setCurrentRow(cellList.getKeyboardSelectedRow() - PAGE_INCREMENT); cancelEvent(event); break; case KeyCodes.KEY_HOME: setCurrentRow(cellList.getPageStart()); cancelEvent(event); break; case KeyCodes.KEY_END: goToVeryEnd(); cancelEvent(event); break; } // Bypass the default handler (super-class) for all keydown events. // For keys not handled here, let the browser handle them. return; } } // Should get here only if event was not handled above. Send the event to // the default handler. super.onCellPreview(event); }
From source file:com.jitlogic.zico.client.views.admin.TraceTemplatePanel.java
License:Open Source License
private void createTemplateListGrid() { templateGrid = new DataGrid<TraceTemplateInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selectionModel = new SingleSelectionModel<TraceTemplateInfo>(KEY_PROVIDER); templateGrid.setSelectionModel(selectionModel); Column<TraceTemplateInfo, TraceTemplateInfo> colOrder = new IdentityColumn<TraceTemplateInfo>(ORDER_CELL); templateGrid.addColumn(colOrder, new ResizableHeader<TraceTemplateInfo>("Order", templateGrid, colOrder)); templateGrid.setColumnWidth(colOrder, 80, Style.Unit.PX); Column<TraceTemplateInfo, TraceTemplateInfo> colCondition = new IdentityColumn<TraceTemplateInfo>( CONDITION_CELL);//from w ww. j a va 2 s. c o m templateGrid.addColumn(colCondition, new ResizableHeader<TraceTemplateInfo>("Condition", templateGrid, colCondition)); templateGrid.setColumnWidth(colCondition, 250, Style.Unit.PX); Column<TraceTemplateInfo, TraceTemplateInfo> colTemplate = new IdentityColumn<TraceTemplateInfo>( TEMPLATE_CELL); templateGrid.addColumn(colTemplate, "Description Template"); templateGrid.setColumnWidth(colTemplate, 100, Style.Unit.PCT); templateStore = new ListDataProvider<TraceTemplateInfo>(KEY_PROVIDER); templateStore.addDataDisplay(templateGrid); templateGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceTemplateInfo>() { @Override public void onCellPreview(CellPreviewEvent<TraceTemplateInfo> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selectionModel.setSelected(event.getValue(), true); editTemplate(null); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selectionModel.setSelected(event.getValue(), true); if (event.getValue() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); templateGrid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); templateGrid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
From source file:com.jitlogic.zico.client.views.admin.UserManagementPanel.java
License:Open Source License
private void createUserGrid() { userGrid = new DataGrid<UserInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selectionModel = new SingleSelectionModel<UserInfo>(KEY_PROVIDER); userGrid.setSelectionModel(selectionModel); Column<UserInfo, UserInfo> colUsername = new IdentityColumn<UserInfo>(USERNAME_CELL); userGrid.addColumn(colUsername, new ResizableHeader<UserInfo>("Username", userGrid, colUsername)); userGrid.setColumnWidth(colUsername, 128, Style.Unit.PX); Column<UserInfo, UserInfo> colUserRole = new IdentityColumn<UserInfo>(USERROLE_CELL); userGrid.addColumn(colUserRole, new ResizableHeader<UserInfo>("Role", userGrid, colUserRole)); userGrid.setColumnWidth(colUserRole, 64, Style.Unit.PX); Column<UserInfo, UserInfo> colRealName = new IdentityColumn<UserInfo>(REALNAME_CELL); userGrid.addColumn(colRealName, new ResizableHeader<UserInfo>("Real Name", userGrid, colRealName)); userGrid.setColumnWidth(colRealName, 256, Style.Unit.PX); Column<UserInfo, UserInfo> colUserHosts = new IdentityColumn<UserInfo>(USERHOSTS_CELL); userGrid.addColumn(colUserHosts, "Allowed hosts"); userGrid.setColumnWidth(colUserHosts, 100, Style.Unit.PCT); userStore = new ListDataProvider<UserInfo>(KEY_PROVIDER); userStore.addDataDisplay(userGrid);/*from www . j a v a 2s . c o m*/ userGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<UserInfo>() { @Override public void onCellPreview(CellPreviewEvent<UserInfo> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selectionModel.setSelected(event.getValue(), true); editUser(null); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selectionModel.setSelected(event.getValue(), true); if (event.getValue() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); userGrid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); userGrid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
From source file:com.jitlogic.zico.client.views.hosts.HostListPanel.java
License:Open Source License
private void createHostGrid() { hostGrid = new DataGrid<HostListObject>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selectionModel = new SingleSelectionModel<HostListObject>(KEY_PROVIDER); hostGrid.setSelectionModel(selectionModel); Column<HostListObject, HostListObject> colExpand = new IdentityColumn<HostListObject>(EXPAND_CELL); hostGrid.addColumn(colExpand, new ResizableHeader<HostListObject>("#", hostGrid, colExpand)); hostGrid.setColumnWidth(colExpand, 36, Style.Unit.PX); Column<HostListObject, HostListObject> colName = new IdentityColumn<HostListObject>(NAME_CELL); hostGrid.addColumn(colName, new ResizableHeader<HostListObject>("Name", hostGrid, colName)); hostGrid.setColumnWidth(colName, 140, Style.Unit.PX); Column<HostListObject, HostListObject> colAddr = new IdentityColumn<HostListObject>(ADDRESS_CELL); hostGrid.addColumn(colAddr, "Address"); hostGrid.setColumnWidth(colAddr, 60, Style.Unit.PCT); hostGrid.setSkipRowHoverStyleUpdate(true); hostGrid.setSkipRowHoverFloatElementCheck(true); hostGrid.setSkipRowHoverCheck(true); hostGrid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); hostGridStore = new ListDataProvider<HostListObject>(); hostGridStore.addDataDisplay(hostGrid); hostGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<HostListObject>() { @Override/*from w w w.j a va 2s . c o m*/ public void onCellPreview(CellPreviewEvent<HostListObject> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selectionModel.setSelected(event.getValue(), true); enableSelectionDependentControls(event.getValue()); if (event.getValue() instanceof HostInfo) { listTraces(null); } else { HostGroup hg = (HostGroup) event.getValue(); hg.toggleExpanded(); redrawHostList(); } } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selectionModel.setSelected(event.getValue(), true); if (event.getValue() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } // TODO update toolbar icons and context menu on element selection } }); hostGrid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); hostGrid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { enableSelectionDependentControls(selectionModel.getSelectedObject()); } }); }
From source file:com.jitlogic.zico.client.views.traces.TraceCallTreePanel.java
License:Open Source License
private void createCallTreeGrid() { grid = new DataGrid<TraceRecordInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selection = new SingleSelectionModel<TraceRecordInfo>(KEY_PROVIDER); grid.setSelectionModel(selection);//w w w . java2s . c o m Column<TraceRecordInfo, TraceRecordInfo> colExpander = new IdentityColumn<TraceRecordInfo>( DETAIL_EXPANDER_CELL); grid.addColumn(colExpander, "#"); grid.setColumnWidth(colExpander, 32, Style.Unit.PX); Column<TraceRecordInfo, TraceRecordInfo> colMethodName = new IdentityColumn<TraceRecordInfo>( METHOD_TREE_CELL); grid.addColumn(colMethodName, new ResizableHeader<TraceRecordInfo>("Method", grid, colMethodName)); grid.setColumnWidth(colMethodName, 100, Style.Unit.PCT); Column<TraceRecordInfo, TraceRecordInfo> colTime = new IdentityColumn<TraceRecordInfo>(METHOD_TIME_CELL); grid.addColumn(colTime, new ResizableHeader<TraceRecordInfo>("Time", grid, colTime)); grid.setColumnWidth(colTime, 60, Style.Unit.PX); colTime.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); Column<TraceRecordInfo, TraceRecordInfo> colCTime = new IdentityColumn<TraceRecordInfo>(METHOD_CTIME_CELL); grid.addColumn(colCTime, new ResizableHeader<TraceRecordInfo>("CTime", grid, colTime)); grid.setColumnWidth(colCTime, 60, Style.Unit.PX); colCTime.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); Column<TraceRecordInfo, TraceRecordInfo> colCalls = new IdentityColumn<TraceRecordInfo>(METHOD_CALLS_CELL); grid.addColumn(colCalls, new ResizableHeader<TraceRecordInfo>("Calls", grid, colCalls)); grid.setColumnWidth(colCalls, 60, Style.Unit.PX); Column<TraceRecordInfo, TraceRecordInfo> colErrors = new IdentityColumn<TraceRecordInfo>( METHOD_ERRORS_CELL); grid.addColumn(colErrors, new ResizableHeader<TraceRecordInfo>("Errors", grid, colErrors)); grid.setColumnWidth(colErrors, 60, Style.Unit.PX); Column<TraceRecordInfo, TraceRecordInfo> colPct = new IdentityColumn<TraceRecordInfo>(METHOD_PCT_CELL); grid.addColumn(colPct, new ResizableHeader<TraceRecordInfo>("Pct", grid, colPct)); grid.setColumnWidth(colPct, 60, Style.Unit.PX); rowBuilder = new TraceCallTableBuilder(grid, expandedDetails); grid.setTableBuilder(rowBuilder); // Disable hovering "features" overall to improve performance on big trees. grid.setSkipRowHoverStyleUpdate(true); grid.setSkipRowHoverFloatElementCheck(true); grid.setSkipRowHoverCheck(true); grid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceRecordInfo>() { @Override public void onCellPreview(CellPreviewEvent<TraceRecordInfo> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { TraceRecordInfo tr = event.getValue(); panelFactory.methodAttrsDialog(trace.getHostName(), trace.getDataOffs(), tr.getPath(), 0L) .asPopupWindow().show(); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selection.setSelected(event.getValue(), true); contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } }); grid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); grid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); data = new ListDataProvider<TraceRecordInfo>(); data.addDataDisplay(grid); }
From source file:com.jitlogic.zico.client.views.traces.TraceSearchPanel.java
License:Open Source License
private void createTraceGrid() { grid = new DataGrid<TraceInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selection = new SingleSelectionModel<TraceInfo>(KEY_PROVIDER); grid.setSelectionModel(selection);// w w w . j ava2 s . co m data = new ListDataProvider<TraceInfo>(); data.addDataDisplay(grid); sortHandler = new ColumnSortEvent.ListHandler<TraceInfo>(data.getList()); grid.addColumnSortHandler(sortHandler); Column<TraceInfo, TraceInfo> colExpander = new IdentityColumn<TraceInfo>(DETAIL_EXPANDER_CELL); grid.addColumn(colExpander, "#"); grid.setColumnWidth(colExpander, 32, Style.Unit.PX); Column<TraceInfo, TraceInfo> colTraceClock = new IdentityColumn<TraceInfo>(TRACE_CLOCK_CELL); grid.addColumn(colTraceClock, new ResizableHeader<TraceInfo>("Clock", grid, colTraceClock)); grid.setColumnWidth(colTraceClock, 140, Style.Unit.PX); colTraceClock.setSortable(true); sortHandler.setComparator(colTraceClock, new Comparator<TraceInfo>() { @Override public int compare(TraceInfo o1, TraceInfo o2) { return (int) (o1.getClock() - o2.getClock()); } }); Column<TraceInfo, TraceInfo> colTraceType = new IdentityColumn<TraceInfo>(TRACE_TYPE_CELL); grid.addColumn(colTraceType, new ResizableHeader<TraceInfo>("Type", grid, colTraceType)); grid.setColumnWidth(colTraceType, 60, Style.Unit.PX); Column<TraceInfo, TraceInfo> colTraceDuration = new IdentityColumn<TraceInfo>(TRACE_DURATION_CELL); grid.addColumn(colTraceDuration, new ResizableHeader<TraceInfo>("Time", grid, colTraceDuration)); grid.setColumnWidth(colTraceDuration, 64, Style.Unit.PX); colTraceDuration.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); colTraceDuration.setSortable(true); sortHandler.setComparator(colTraceDuration, new Comparator<TraceInfo>() { @Override public int compare(TraceInfo o1, TraceInfo o2) { return (int) ((o1.getExecutionTime() - o2.getExecutionTime()) / 1000000L); } }); Column<TraceInfo, TraceInfo> colTraceCalls = new IdentityColumn<TraceInfo>(TRACE_CALLS_CELL); grid.addColumn(colTraceCalls, new ResizableHeader<TraceInfo>("Calls", grid, colTraceCalls)); grid.setColumnWidth(colTraceCalls, 50, Style.Unit.PX); colTraceCalls.setSortable(true); sortHandler.setComparator(colTraceCalls, new Comparator<TraceInfo>() { @Override public int compare(TraceInfo o1, TraceInfo o2) { return (int) (o1.getCalls() - o2.getCalls()); } }); Column<TraceInfo, TraceInfo> colTraceErrors = new IdentityColumn<TraceInfo>(TRACE_ERRORS_CELL); grid.addColumn(colTraceErrors, new ResizableHeader<TraceInfo>("Errs", grid, colTraceErrors)); grid.setColumnWidth(colTraceErrors, 50, Style.Unit.PX); colTraceErrors.setSortable(true); sortHandler.setComparator(colTraceErrors, new Comparator<TraceInfo>() { @Override public int compare(TraceInfo o1, TraceInfo o2) { return (int) (o1.getErrors() - o2.getErrors()); } }); Column<TraceInfo, TraceInfo> colTraceRecords = new IdentityColumn<TraceInfo>(TRACE_RECORDS_CELL); grid.addColumn(colTraceRecords, new ResizableHeader<TraceInfo>("Recs", grid, colTraceRecords)); grid.setColumnWidth(colTraceRecords, 50, Style.Unit.PX); colTraceRecords.setSortable(true); sortHandler.setComparator(colTraceRecords, new Comparator<TraceInfo>() { @Override public int compare(TraceInfo o1, TraceInfo o2) { return (int) (o1.getRecords() - o2.getRecords()); } }); Column<TraceInfo, TraceInfo> colTraceDesc = new IdentityColumn<TraceInfo>(TRACE_NAME_CELL); grid.addColumn(colTraceDesc, "Description"); grid.setColumnWidth(colTraceDesc, 100, Style.Unit.PCT); rowBuilder = new TraceSearchTableBuilder(grid, expandedDetails); grid.setTableBuilder(rowBuilder); grid.setSkipRowHoverStyleUpdate(true); grid.setSkipRowHoverFloatElementCheck(true); grid.setSkipRowHoverCheck(true); grid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceInfo>() { @Override public void onCellPreview(CellPreviewEvent<TraceInfo> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selection.setSelected(event.getValue(), true); openDetailView(); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selection.setSelected(event.getValue(), true); if (selection.getSelectedObject() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); grid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); grid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
From source file:com.jitlogic.zico.client.views.traces.TraceStatsPanel.java
License:Open Source License
private void createTraceGrid() { grid = new DataGrid<TraceInfoStatsResult>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selection = new SingleSelectionModel<TraceInfoStatsResult>(KEY_PROVIDER); grid.setSelectionModel(selection);/*from w w w . ja va 2 s . c o m*/ data = new ListDataProvider<TraceInfoStatsResult>(); data.addDataDisplay(grid); sortHandler = new ColumnSortEvent.ListHandler<TraceInfoStatsResult>(data.getList()); grid.addColumnSortHandler(sortHandler); Column<TraceInfoStatsResult, TraceInfoStatsResult> colTraceCalls = new IdentityColumn<TraceInfoStatsResult>( TRACE_CALLS_CELL); grid.addColumn(colTraceCalls, new ResizableHeader<TraceInfoStatsResult>("Calls", grid, colTraceCalls)); grid.setColumnWidth(colTraceCalls, 50, Style.Unit.PX); colTraceCalls.setSortable(true); sortHandler.setComparator(colTraceCalls, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return o1.getCalls() - o2.getCalls(); } }); Column<TraceInfoStatsResult, TraceInfoStatsResult> colTraceErrors = new IdentityColumn<TraceInfoStatsResult>( TRACE_ERRORS_CELL); grid.addColumn(colTraceErrors, new ResizableHeader<TraceInfoStatsResult>("Errors", grid, colTraceErrors)); grid.setColumnWidth(colTraceErrors, 50, Style.Unit.PX); colTraceErrors.setSortable(true); sortHandler.setComparator(colTraceErrors, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return o1.getErrors() - o2.getErrors(); } }); Column<TraceInfoStatsResult, TraceInfoStatsResult> colSumTime = new IdentityColumn<TraceInfoStatsResult>( TIME_SUM_CELL); grid.addColumn(colSumTime, new ResizableHeader<TraceInfoStatsResult>("Sum Time", grid, colSumTime)); grid.setColumnWidth(colSumTime, 96, Style.Unit.PX); colSumTime.setSortable(true); sortHandler.setComparator(colSumTime, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return (int) ((o1.getSumTime() - o2.getSumTime()) / 1000000L); } }); // avgTime Column<TraceInfoStatsResult, TraceInfoStatsResult> colMinTime = new IdentityColumn<TraceInfoStatsResult>( TIME_MIN_CELL); grid.addColumn(colMinTime, new ResizableHeader<TraceInfoStatsResult>("Min Time", grid, colMinTime)); grid.setColumnWidth(colMinTime, 96, Style.Unit.PX); colMinTime.setSortable(true); sortHandler.setComparator(colMinTime, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return (int) ((o1.getMinTime() - o2.getMinTime()) / 1000000L); } }); Column<TraceInfoStatsResult, TraceInfoStatsResult> colMaxTime = new IdentityColumn<TraceInfoStatsResult>( TIME_MAX_CELL); grid.addColumn(colMaxTime, new ResizableHeader<TraceInfoStatsResult>("Max Time", grid, colMaxTime)); grid.setColumnWidth(colMaxTime, 96, Style.Unit.PX); colMaxTime.setSortable(true); sortHandler.setComparator(colMaxTime, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return (int) ((o1.getMaxTime() - o2.getMaxTime()) / 1000000L); } }); Column<TraceInfoStatsResult, TraceInfoStatsResult> colAttr = new IdentityColumn<TraceInfoStatsResult>( ATTR_CELL); colAttr.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.addColumn(colAttr, new ResizableHeader<TraceInfoStatsResult>("Attr", grid, colAttr)); grid.setColumnWidth(colAttr, 100, Style.Unit.PCT); colAttr.setSortable(true); sortHandler.setComparator(colAttr, new Comparator<TraceInfoStatsResult>() { @Override public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) { return o1.getAttr().compareTo(o2.getAttr()); } }); grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceInfoStatsResult>() { @Override public void onCellPreview(CellPreviewEvent<TraceInfoStatsResult> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selection.setSelected(event.getValue(), true); openSearchView(); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selection.setSelected(event.getValue(), true); if (selection.getSelectedObject() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); grid.addDomHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); grid.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
From source file:com.jitlogic.zico.widgets.demo.client.views.UserManagementPanel.java
License:Open Source License
private void createUserGrid() { userGrid = new DataGrid<UserInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selectionModel = new SingleSelectionModel<UserInfo>(KEY_PROVIDER); userGrid.setSelectionModel(selectionModel); Column<UserInfo, String> colUserId = new Column<UserInfo, String>(new TextCell()) { @Override/*from w w w. j av a 2 s . co m*/ public String getValue(UserInfo object) { return "" + object.getId(); } }; userGrid.addColumn(colUserId, new ResizableHeader<UserInfo>("#", userGrid, colUserId)); userGrid.setColumnWidth(colUserId, 35, Style.Unit.PX); final EditTextCell cellUsername = new EditTextCell(); Column<UserInfo, String> colUsername = new Column<UserInfo, String>(cellUsername) { @Override public String getValue(UserInfo user) { return user.getUsername(); } }; colUsername.setFieldUpdater(new FieldUpdater<UserInfo, String>() { public void update(int index, UserInfo user, String value) { markChange(user); user.setUsername(value); cellUsername.clearViewData(user.getId()); } }); userGrid.addColumn(colUsername, new ResizableHeader<UserInfo>("Username", userGrid, colUsername)); userGrid.setColumnWidth(colUsername, 128, Style.Unit.PX); Map<String, Integer> roles = ZicoWidgets.map("VIEWER", 1, "ADMIN", 2); final SelectCell<String, Integer> cellRoles = new SelectCell<String, Integer>(roles); Column<UserInfo, Integer> colUserRole = new Column<UserInfo, Integer>(cellRoles) { @Override public Integer getValue(UserInfo user) { return user.getRole(); } }; colUserRole.setFieldUpdater(new FieldUpdater<UserInfo, Integer>() { public void update(int index, UserInfo user, Integer value) { markChange(user); user.setRole(value); cellRoles.clearViewData(user.getId()); } }); userGrid.addColumn(colUserRole, new ResizableHeader<UserInfo>("Role", userGrid, colUserRole)); userGrid.setColumnWidth(colUserRole, 128, Style.Unit.PX); final EditTextCell cellFullname = new EditTextCell(); Column<UserInfo, String> colFullname = new Column<UserInfo, String>(cellFullname) { @Override public String getValue(UserInfo user) { return user.getFullname(); } }; colFullname.setFieldUpdater(new FieldUpdater<UserInfo, String>() { public void update(int index, UserInfo user, String value) { markChange(user); user.setFullname(value); cellFullname.clearViewData(user.getId()); } }); userGrid.addColumn(colFullname, new ResizableHeader<UserInfo>("Full Name", userGrid, colFullname)); userGrid.setColumnWidth(colFullname, 256, Style.Unit.PX); final EditTextCell cellComment = new EditTextCell(); Column<UserInfo, String> colComment = new Column<UserInfo, String>(cellComment) { @Override public String getValue(UserInfo user) { return user.getComment(); } }; colComment.setFieldUpdater(new FieldUpdater<UserInfo, String>() { public void update(int index, UserInfo user, String value) { markChange(user); user.setComment(value); cellComment.clearViewData(user.getId()); } }); userGrid.addColumn(colComment, "Comment"); userGrid.setColumnWidth(colComment, 100, Style.Unit.PC); userStore = new ListDataProvider<UserInfo>(KEY_PROVIDER); userStore.addDataDisplay(userGrid); userGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<UserInfo>() { public void onCellPreview(CellPreviewEvent<UserInfo> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER) || BrowserEvents.DBLCLICK.equals(nev.getType())) { selectionModel.setSelected(event.getValue(), true); editUser(null); } if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selectionModel.setSelected(event.getValue(), true); if (event.getValue() != null) { contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); userGrid.addDomHandler(new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); userGrid.addDomHandler(new ContextMenuHandler() { public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java
License:Apache License
private void initTable(AsyncDataProvider<ItemDto> dataProvider) { final ProvidesKey<ItemDto> keyProvider = new ProvidesKey<ItemDto>() { public Object getKey(ItemDto list) { return list == null ? null : list.getId(); }//from ww w .ja v a2 s .c o m }; cellTable = new CellTable<ItemDto>(keyProvider); dataProvider.addDataDisplay(cellTable); cellTable.setPageSize(5); cellTable.sinkEvents(Event.ONDBLCLICK); final MultiSelectionModel<ItemDto> selectionModel = new MultiSelectionModel<ItemDto>(keyProvider); cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<ItemDto>() { @Override public void onCellPreview(CellPreviewEvent<ItemDto> event) { int eventType = Event.getTypeInt(event.getNativeEvent().getType()); if (eventType == Event.ONDBLCLICK) { ItemDto list = event.getValue(); presenter.edit(list); } } }); // styles // bootstrap cellTable.addStyleName("table"); cellTable.addStyleName("table-bordered"); // makes selection invisible on every even row // cellTable.addStyleName("table-striped"); AsyncHandler columnSortHandler = new AsyncHandler(cellTable); // columns addShopColumn(columnSortHandler); addNameColumn(); addCheckedColumn(); addEditColumn(); addDeleteColumn(); }