use of org.rstudio.core.client.command.ShortcutManager.Handle in project rstudio by rstudio.
the class ModifyKeyboardShortcutsWidget method addHandlers.
private void addHandlers() {
table_.addCellPreviewHandler(new CellPreviewEvent.Handler<KeyboardShortcutEntry>() {
@Override
public void onCellPreview(CellPreviewEvent<KeyboardShortcutEntry> preview) {
Handle shortcutsHandler = shortcuts_.disable();
int column = preview.getColumn();
if (column == 0)
onNameCellPreview(preview);
else if (column == 1)
onShortcutCellPreview(preview);
else if (column == 2)
onNameCellPreview(preview);
shortcutsHandler.close();
}
});
table_.addColumnSortHandler(new ColumnSortEvent.Handler() {
@Override
public void onColumnSort(ColumnSortEvent event) {
List<KeyboardShortcutEntry> data = dataProvider_.getList();
if (event.getColumn().equals(nameColumn_))
sort(data, 0, event.isSortAscending());
else if (event.getColumn().equals(shortcutColumn_))
sort(data, 1, event.isSortAscending());
else if (event.getColumn().equals(typeColumn_))
sort(data, 2, event.isSortAscending());
updateData(data);
}
});
// Fix a bug where clicking on a table header would also
// select the cell at position [0, 0]. It seems that GWT's
// DataGrid over-aggressively selects the first cell on the
// _first_ mouse down event seen; after the first click,
// cell selection occurs only after full mouse clicks.
table_.addDomHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
Element target = event.getNativeEvent().getEventTarget().cast();
if (target.hasAttribute("__gwt_header")) {
event.stopPropagation();
event.preventDefault();
}
}
}, MouseDownEvent.getType());
}
Aggregations