本文整理汇总了Java中com.google.gwt.view.client.SingleSelectionModel.getSelectedObject方法的典型用法代码示例。如果您正苦于以下问题:Java SingleSelectionModel.getSelectedObject方法的具体用法?Java SingleSelectionModel.getSelectedObject怎么用?Java SingleSelectionModel.getSelectedObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.view.client.SingleSelectionModel
的用法示例。
在下文中一共展示了SingleSelectionModel.getSelectedObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollToTheEnd
import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
public static <T extends Hierarchic> void scrollToTheEnd(T newItem, SingleSelectionModel<T> selectionModel,
ListDataProvider<? extends Hierarchic> listDataProvider, ResizableDataGrid<? extends Hierarchic> resizableDataGrid) {
if (selectionModel.getSelectedObject() != null) {
T selectedObject = selectionModel.getSelectedObject();
selectionModel.setSelected(selectedObject, false);
}
Long oldId = newItem.getId();
newItem.setId(-1L);
selectionModel.setSelected(newItem, true);
newItem.setId(oldId);
int provSize = listDataProvider.getList().size();
int pageSize = resizableDataGrid.getPageSize();
int start = provSize < pageSize ? 0 : provSize - pageSize + 1;
resizableDataGrid.setVisibleRange(start, pageSize);
listDataProvider.refresh();
resizableDataGrid.getScrollPanel().scrollToBottom();
}
示例2: trySelectionModelValue
import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
/**
* Returns the selected object by selection model
*
* @param selectionModel
* @param failText
* text to throw in case of cast exception
* @param selectedClass
* expected class
* @param allowSubclasses
* don't throw exception if the result is a subclass of the
* specified class
* @return selectionModel's selected object
* @throws SelectionModelInvalidClassException
* if the object has unexpected type.
*/
public static <S, T extends S> T trySelectionModelValue(SingleSelectionModel<S> selectionModel, String failText, Class<T> selectedClass,
boolean allowSubclasses) {
try {
@SuppressWarnings("unchecked")
T result = (T) selectionModel.getSelectedObject();
if (result == null) {
throw new SelectionModelNullException(failText);
}
if (!allowSubclasses && !result.getClass().getName().equals(selectedClass.getName())) {
throw new SelectionModelInvalidClassException(failText);
}
return result;
} catch (ClassCastException e) {
throw new SelectionModelInvalidClassException(failText);
}
}
示例3: setTextboxValueBySelectionModel
import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
public static void setTextboxValueBySelectionModel(ValueBoxBase<String> textBox,
SingleSelectionModel<? extends HasListboxValue> selectionModel) {
HasListboxValue selected = selectionModel.getSelectedObject();
if (selected == null) {
textBox.setValue("");
} else {
textBox.setValue(selected.getListboxValue());
}
}