use of com.google.gwt.user.cellview.client.ColumnSortEvent in project rstudio by rstudio.
the class FilesList method addColumnSortHandler.
private void addColumnSortHandler() {
filesDataGrid_.addColumnSortHandler(new Handler() {
@Override
public void onColumnSort(ColumnSortEvent event) {
ColumnSortList sortList = event.getColumnSortList();
// insert the default initial sort order for size and modified
if (!applyingProgrammaticSort_) {
if (event.getColumn().equals(sizeColumn_) && forceSizeSortDescending) {
forceSizeSortDescending = false;
forceModifiedSortDescending = true;
sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(event.getColumn(), false));
} else if (event.getColumn().equals(modifiedColumn_) && forceModifiedSortDescending) {
forceModifiedSortDescending = false;
forceSizeSortDescending = true;
sortList.insert(0, new com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo(event.getColumn(), false));
} else {
forceModifiedSortDescending = true;
forceSizeSortDescending = true;
}
}
// record sort order and fire event to observer
JsArray<ColumnSortInfo> sortOrder = newSortOrderArray();
for (int i = 0; i < sortList.size(); i++) {
// match the column index
com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo sortInfo = sortList.get(i);
Object column = sortInfo.getColumn();
for (int c = 0; c < filesDataGrid_.getColumnCount(); c++) {
if (filesDataGrid_.getColumn(c).equals(column)) {
boolean ascending = sortInfo.isAscending();
sortOrder.push(ColumnSortInfo.create(c, ascending));
break;
}
}
}
observer_.onColumnSortOrderChanaged(sortOrder);
// record active sort column ascending state
activeSortColumnAscending_ = event.isSortAscending();
// delegate the sort
sortHandler_.onColumnSort(event);
}
private final native JsArray<ColumnSortInfo> newSortOrderArray();
private boolean forceSizeSortDescending = true;
private boolean forceModifiedSortDescending = true;
});
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent in project rstudio by rstudio.
the class BrowseAddinsDialog method addColumns.
private void addColumns() {
// Package ----
pkgColumn_ = new TextColumn<RAddin>() {
@Override
public String getValue(RAddin addin) {
return addin.getPackage();
}
};
pkgColumn_.setSortable(true);
table_.addColumn(pkgColumn_, new TextHeader("Package"));
table_.setColumnWidth(pkgColumn_, "120px");
// Name ----
nameColumn_ = new TextColumn<RAddin>() {
@Override
public String getValue(RAddin addin) {
return StringUtil.truncate(addin.getName(), 120, "...");
}
};
nameColumn_.setSortable(true);
table_.addColumn(nameColumn_, new TextHeader("Name"));
table_.setColumnWidth(nameColumn_, "120px");
// Description ----
descColumn_ = new TextColumn<RAddin>() {
@Override
public String getValue(RAddin addin) {
return addin.getDescription();
}
};
descColumn_.setSortable(true);
table_.addColumn(descColumn_, new TextHeader("Description"));
table_.addColumnSortHandler(new ColumnSortEvent.Handler() {
@Override
public void onColumnSort(ColumnSortEvent event) {
int index = -1;
if (event.getColumn().equals(pkgColumn_))
index = 0;
else if (event.getColumn().equals(nameColumn_))
index = 1;
else if (event.getColumn().equals(descColumn_))
index = 2;
if (index == -1)
return;
sort(index, event.isSortAscending());
}
});
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent 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