当前位置: 首页>>代码示例>>Java>>正文


Java SingleSelectionModel.setSelected方法代码示例

本文整理汇总了Java中com.google.gwt.view.client.SingleSelectionModel.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java SingleSelectionModel.setSelected方法的具体用法?Java SingleSelectionModel.setSelected怎么用?Java SingleSelectionModel.setSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.view.client.SingleSelectionModel的用法示例。


在下文中一共展示了SingleSelectionModel.setSelected方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
 
开发者ID:rkfg,项目名称:gwtutil,代码行数:18,代码来源:ClientUtils.java

示例2: makeTemplateSelector

import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
/**
 * Creates the scrollable list of cells each of which serves as a link to a template.
 *
 * @param list an ArrayList of TemplateInfo
 * @return A CellList widget
 */
public CellList<TemplateInfo> makeTemplateSelector(ArrayList<TemplateInfo> list) {
  TemplateCell templateCell = new TemplateCell(list.get(0), templateHostUrl);

  CellList<TemplateInfo> templateCellList = new CellList<TemplateInfo>(templateCell,TemplateInfo.KEY_PROVIDER);
  templateCellList.setPageSize(list.size() + 10);
  templateCellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
  templateCellList.setWidth("250px");
  templateCellList.setHeight("400px");
  templateCellList.setVisible(true);

  // Add a selection model to handle user selection.
  final SingleSelectionModel<TemplateInfo> selectionModel =
    new SingleSelectionModel<TemplateInfo>(TemplateInfo.KEY_PROVIDER);
  templateCellList.setSelectionModel(selectionModel);
  selectionModel.setSelected(list.get(0), true);
  final TemplateUploadWizard wizard = this;
  selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
      public void onSelectionChange(SelectionChangeEvent event) {
        TemplateInfo selected = selectionModel.getSelectedObject();
        if (selected != null) {
          selectedTemplateNAME = selected.name;
          TemplateWidget.setTemplate(selected, wizard.getTemplateUrlHost());
        }
      }
    });

  // Set the total row count. This isn't strictly necessary, but it affects
  // paging calculations, so its good habit to keep the row count up to date.
  templateCellList.setRowCount(list.size(), true);

  // Push the data into the widget.
  templateCellList.setRowData(0, list);
  return templateCellList;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:41,代码来源:TemplateUploadWizard.java

示例3: removeObjectFromDataProvider

import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
public static <T extends Hierarchic> void removeObjectFromDataProvider(T object, SingleSelectionModel<T> selectionModel) {
    selectionModel.setSelected(object, false);
    removeObjectFromDataProvider(object);
}
 
开发者ID:rkfg,项目名称:gwtutil,代码行数:5,代码来源:ClientUtils.java

示例4: setDataObject

import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
private void setDataObject(DataObjectTO dataObject) {
    this.dataObject = dataObject;
    objectName.setText(dataObject.getName() + "::" + dataObject.getPackageName());

    //We create a new selection model due to a bug found in GWT when we change e.g. from one data object with 9 rows
    // to one with 3 rows and the table was sorted.
    //Several tests has been done and the final workaround (not too bad) we found is to
    // 1) sort the table again
    // 2) create a new selection model
    // 3) populate the table with new items
    // 3) select the first row
    SingleSelectionModel selectionModel2 = new SingleSelectionModel<ObjectPropertyTO>();
    dataObjectPropertiesTable.setSelectionModel(selectionModel2);

    selectionModel2.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ObjectPropertyTO selectedPropertyTO = ((SingleSelectionModel<ObjectPropertyTO>)dataObjectPropertiesTable.getSelectionModel()).getSelectedObject();
            notifyFieldSelected(selectedPropertyTO);
        }
    });

    ArrayList<ObjectPropertyTO> sortBuffer = new ArrayList<ObjectPropertyTO>();
    sortBuffer.addAll(dataObject.getProperties());
    Collections.sort(sortBuffer, new ObjectPropertyComparator("name"));

    dataObjectProperties = dataObject.getProperties();
    dataObjectPropertiesProvider.getList().clear();
    dataObjectPropertiesProvider.getList().addAll(sortBuffer);
    dataObjectPropertiesProvider.flush();
    dataObjectPropertiesProvider.refresh();

    dataObjectPropertiesTable.getColumnSortList().push(new ColumnSortList.ColumnSortInfo(dataObjectPropertiesTable.getColumn(1), true));

    if (dataObjectProperties.size() > 0) {
        dataObjectPropertiesTable.setKeyboardSelectedRow(0);
        selectionModel2.setSelected(sortBuffer.get(0), true);
    }

    //set the first row selected again. Sounds crazy, but's part of the workaround, don't remove this line.
    if (dataObjectProperties.size() > 0) {
        dataObjectPropertiesTable.setKeyboardSelectedRow(0);
    }

    if (dataObjectProperties.size() == 0) {
        //there are no properties.
        //fire an empty property seleccion event in order to notify the
        notifyFieldSelected(null);
    }
}
 
开发者ID:kiegroup,项目名称:jbpm-data-modeler,代码行数:52,代码来源:DataObjectBrowser.java

示例5: setDataModel

import com.google.gwt.view.client.SingleSelectionModel; //导入方法依赖的package包/类
public void setDataModel(DataModelTO dataModel) {
    this.dataModel = dataModel;
    this.dataObjects = dataModel.getDataObjects();
    modelName.setText(dataModel.getName());

    // We create a new selection model due to a bug found in GWT when we change e.g. from one data object with 9 rows
    // to one with 3 rows and the table was sorted.
    // Several tests has been done and the final workaround (not too bad) we found is to
    //  1) sort the table again
    //  2) create a new selection model
    //  3) populate the table with new items
    //  3) select the first row

    SingleSelectionModel selectionModel2 = new SingleSelectionModel<DataObjectTO>();
    dataObjectsTable.setSelectionModel(selectionModel2);

    selectionModel2.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            if (!skipNextOnChange) {
                DataObjectTO selectedObjectTO = ((SingleSelectionModel<DataObjectTO>)dataObjectsTable.getSelectionModel()).getSelectedObject();
                notifyObjectSelected(selectedObjectTO);
            }
            skipNextOnChange = false;
        }
    });

    ArrayList<DataObjectTO> sortBuffer = new ArrayList<DataObjectTO>();
    sortBuffer.addAll(dataObjects);
    Collections.sort(sortBuffer, new DataObjectComparator());

    dataObjectsProvider.getList().clear();
    dataObjectsProvider.getList().addAll(sortBuffer);
    dataObjectsProvider.flush();
    dataObjectsProvider.refresh();

    dataObjectsTable.getColumnSortList().push(new ColumnSortList.ColumnSortInfo(dataObjectsTable.getColumn(1), true));

    if (dataObjects.size() > 0) {
        dataObjectsTable.setKeyboardSelectedRow(0);
        selectionModel2.setSelected(sortBuffer.get(0), true);
    }

    // Set the first row selected again. Sounds crazy, but it's part of the workaround, don't remove this line.
    if (dataObjects.size() > 0) {
        dataObjectsTable.setKeyboardSelectedRow(0);
    }
}
 
开发者ID:kiegroup,项目名称:jbpm-data-modeler,代码行数:50,代码来源:DataModelBrowser.java


注:本文中的com.google.gwt.view.client.SingleSelectionModel.setSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。