Exemplo n.º 1
0
  private ContentPanel createScreenPairList(GroupRef groupRef) {
    TouchPanelDefinition touchPanel = groupRef.getPanel().getTouchPanelDefinition();

    ContentPanel screenContainer = new ContentPanel();
    screenContainer.setHeaderVisible(false);
    screenContainer.setWidth(260);
    screenContainer.setHeight(150);
    screenContainer.setLayout(new FitLayout());
    // overflow-auto style is for IE hack.
    screenContainer.addStyleName("overflow-auto");

    screenPairListView = new CheckBoxListView<BeanModel>();
    ListStore<BeanModel> store = new ListStore<BeanModel>();

    List<BeanModel> otherModels = new ArrayList<BeanModel>();
    List<BeanModel> screenPairModels = BeanModelDataBase.screenTable.loadAll();
    List<BeanModel> selectedModels = new ArrayList<BeanModel>();
    for (ScreenPairRef screenRef : groupRef.getGroup().getScreenRefs()) {
      selectedModels.add(screenRef.getScreen().getBeanModel());
    }
    for (BeanModel screenPairModel : screenPairModels) {
      if (((ScreenPair) screenPairModel.getBean()).getTouchPanelDefinition().equals(touchPanel)) {
        store.add(screenPairModel);
        screenPairListView.getSelectionModel().select(screenPairModel, true);
      } else if (((ScreenPair) screenPairModel.getBean())
          .getTouchPanelDefinition()
          .getCanvas()
          .equals(touchPanel.getCanvas())) {
        otherModels.add(screenPairModel);
      }
    }

    store.add(otherModels);
    for (BeanModel selectedModel : selectedModels) {
      screenPairListView.setChecked(selectedModel, true);
    }
    screenPairListView.setStore(store);
    screenPairListView.setDisplayProperty("panelName");
    screenPairListView.setStyleAttribute("overflow", "auto");
    screenPairListView.setSelectStyle("screen-view-item-sel");
    screenContainer.add(screenPairListView);
    return screenContainer;
  }
Exemplo n.º 2
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    final ExampleServiceAsync service = (ExampleServiceAsync) Registry.get(Examples.SERVICE);

    RpcProxy<List<Photo>> proxy =
        new RpcProxy<List<Photo>>() {
          @Override
          protected void load(Object loadConfig, AsyncCallback<List<Photo>> callback) {
            service.getPhotos(callback);
          }
        };

    ListLoader<ListLoadResult<Photo>> loader =
        new BaseListLoader<ListLoadResult<Photo>>(proxy, new BeanModelReader());
    ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
    loader.load();

    final ContentPanel panel = new ContentPanel();
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setFrame(true);
    panel.setHeading("CheckBox ListView (0 items selected)");
    panel.setWidth(300);
    panel.setAutoHeight(true);
    panel.setBodyBorder(false);

    final CheckBoxListView<BeanModel> view =
        new CheckBoxListView<BeanModel>() {
          @Override
          protected BeanModel prepareData(BeanModel model) {
            String s = model.get("name");
            model.set("shortName", Format.ellipse(s, 15));
            return model;
          }
        };

    view.setStore(store);
    view.setDisplayProperty("name");
    view.getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<BeanModel>>() {

              public void handleEvent(SelectionChangedEvent<BeanModel> be) {
                panel.setHeading(
                    "CheckBox ListView (" + be.getSelection().size() + " items selected)");
              }
            });
    panel.add(view);

    panel.addButton(
        new Button(
            "get checked items",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                Info.display(
                    "Checked Items", "There are " + view.getChecked().size() + " items checked!");
              }
            }));
    add(panel);
  }