コード例 #1
0
 private void setColumnWidth() {
   grid.getColumn(STATUS).setWidth(60);
   grid.getColumn(PROGRESS).setWidth(150);
   grid.getColumn(FILE_NAME).setWidth(200);
   grid.getColumn(REASON).setWidth(290);
   grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidth(200);
 }
コード例 #2
0
  private void buildLayout() {

    VerticalLayout top = new VerticalLayout();
    Label l1 = new Label("Users");

    l1.setStyleName("h2");
    top.addComponent(l1);
    top.addComponent(fieldSearch);
    top.addComponent(filterCCNo);

    Label l2 = new Label("Rules");
    l2.setStyleName("h2");

    userGrid.setWidth("100%");
    userGrid.setHeight("250px");

    userRulesGrid.setWidth("100%");
    userRulesGrid.setHeight("250px");

    HorizontalLayout rulesButtons = new HorizontalLayout();
    rulesButtons.addComponent(addUserRuleButton);
    rulesButtons.addComponent(editUserRuleButton);
    rulesButtons.addComponent(deleteUserRuleButton);

    Panel userPanel = new Panel(userGrid);
    Panel userRulesPanel = new Panel(userRulesGrid);

    VerticalLayout main = new VerticalLayout(top, userPanel, l2, userRulesGrid, rulesButtons);
    main.setMargin(new MarginInfo(false, true, false, true));

    setContent(main);
  }
コード例 #3
0
 private void resetColumnWidth() {
   grid.getColumn(STATUS).setWidthUndefined();
   grid.getColumn(PROGRESS).setWidthUndefined();
   grid.getColumn(FILE_NAME).setWidthUndefined();
   grid.getColumn(REASON).setWidthUndefined();
   grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setWidthUndefined();
 }
コード例 #4
0
 private void setGridColumnProperties() {
   grid.getColumn(STATUS).setRenderer(new StatusRenderer());
   grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer());
   grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, SPUILabelDefinitions.NAME_VERSION, REASON);
   setColumnWidth();
   grid.getColumn(SPUILabelDefinitions.NAME_VERSION)
       .setHeaderCaption(i18n.get("upload.swModuleTable.header"));
   grid.setFrozenColumnCount(5);
 }
コード例 #5
0
  @Before
  public void setUp() {
    grid = new Grid<>();
    grid.setItems(PERSON_A, PERSON_B, PERSON_C);
    selectionModel = (SingleSelectionModelImpl<Person>) grid.getSelectionModel();

    selectionChanges = new ArrayList<>();
    selectionModel.addSingleSelectionListener(e -> selectionChanges.add(e.getValue()));
  }
コード例 #6
0
ファイル: ClickableRenderer.java プロジェクト: Legioth/vaadin
  /**
   * Creates a new clickable renderer with the given presentation type and null representation.
   *
   * @param presentationType the data type that this renderer displays, not <code>null</code>
   * @param nullRepresentation a string that will be sent to the client instead of a regular value
   *     in case the actual cell value is <code>null</code>. May be <code>null</code>.
   */
  protected ClickableRenderer(Class<V> presentationType, String nullRepresentation) {
    super(presentationType, nullRepresentation);
    registerRpc(
        (RendererClickRpc)
            (String rowKey, String columnId, MouseEventDetails mouseDetails) -> {
              Grid<T> grid = getParentGrid();
              T item = grid.getDataCommunicator().getKeyMapper().get(rowKey);
              Column column = grid.getColumn(columnId);

              fireEvent(new RendererClickEvent<>(grid, item, column, mouseDetails));
            });
  }
コード例 #7
0
ファイル: VaadinUI.java プロジェクト: pawigor/jrtt
  private void listTasks() {

    grid.setContainerDataSource(
        new BeanItemContainer<>(
            Task.class,
            (Collection<? extends Task>) repo.findAll(new PageRequest(1, 1)).getContent()));
  }
コード例 #8
0
 private void restoreState() {
   final Indexed container = grid.getContainerDataSource();
   if (container.getItemIds().isEmpty()) {
     container.removeAllItems();
     for (final UploadStatusObject statusObject :
         artifactUploadState.getUploadedFileStatusList()) {
       final Item item =
           container.addItem(
               getItemid(statusObject.getFilename(), statusObject.getSelectedSoftwareModule()));
       item.getItemProperty(REASON)
           .setValue(statusObject.getReason() != null ? statusObject.getReason() : "");
       if (statusObject.getStatus() != null) {
         item.getItemProperty(STATUS).setValue(statusObject.getStatus());
       }
       if (statusObject.getProgress() != null) {
         item.getItemProperty(PROGRESS).setValue(statusObject.getProgress());
       }
       item.getItemProperty(FILE_NAME).setValue(statusObject.getFilename());
       final SoftwareModule sw = statusObject.getSelectedSoftwareModule();
       item.getItemProperty(SPUILabelDefinitions.NAME_VERSION)
           .setValue(HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()));
     }
     if (artifactUploadState.isUploadCompleted()) {
       minimizeButton.setEnabled(false);
     }
   }
 }
コード例 #9
0
 private void resizeWindow(final ClickEvent event) {
   if (FontAwesome.EXPAND.equals(event.getButton().getIcon())) {
     event.getButton().setIcon(FontAwesome.COMPRESS);
     setWindowMode(WindowMode.MAXIMIZED);
     resetColumnWidth();
     grid.getColumn(STATUS).setExpandRatio(0);
     grid.getColumn(PROGRESS).setExpandRatio(1);
     grid.getColumn(FILE_NAME).setExpandRatio(2);
     grid.getColumn(REASON).setExpandRatio(3);
     grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setExpandRatio(4);
     mainLayout.setSizeFull();
   } else {
     event.getButton().setIcon(FontAwesome.EXPAND);
     setWindowMode(WindowMode.NORMAL);
     setColumnWidth();
     setPopupSizeInMinMode();
   }
 }
コード例 #10
0
  @Test
  public void testGridWithSingleSelection() {
    Grid<String> gridWithStrings = new Grid<>();
    gridWithStrings.setItems("Foo", "Bar", "Baz");

    GridSelectionModel<String> model = gridWithStrings.getSelectionModel();
    Assert.assertFalse(model.isSelected("Foo"));

    model.select("Foo");
    Assert.assertTrue(model.isSelected("Foo"));
    Assert.assertEquals(Optional.of("Foo"), model.getFirstSelectedItem());

    model.select("Bar");
    Assert.assertFalse(model.isSelected("Foo"));
    Assert.assertTrue(model.isSelected("Bar"));

    model.deselect("Bar");
    Assert.assertFalse(model.isSelected("Bar"));
    Assert.assertFalse(model.getFirstSelectedItem().isPresent());
  }
コード例 #11
0
  private void configureComponents() {
    keyList.setContainerDataSource(new BeanItemContainer<>(Key.class));
    keyList.setColumnOrder("name", "type");
    keyList.removeColumn("value");
    keyList.setStyleName(ValoTheme.TABLE_SMALL);

    keyList.setSelectionMode(Grid.SelectionMode.SINGLE);
    keyList.addSelectionListener(
        e -> {
          Key key = (Key) keyList.getSelectedRow();
          editForm.edit(key);
        });
    keyList.setEditorEnabled(false);
  }
コード例 #12
0
  @SuppressWarnings({"serial"})
  @Test
  public void addValueChangeListener() {
    AtomicReference<SingleSelectionListener<String>> selectionListener = new AtomicReference<>();
    Registration registration = Mockito.mock(Registration.class);
    Grid<String> grid = new Grid<>();
    grid.setItems("foo", "bar");
    String value = "foo";
    SingleSelectionModelImpl<String> select =
        new SingleSelectionModelImpl<String>() {
          @Override
          public Registration addSingleSelectionListener(SingleSelectionListener<String> listener) {
            selectionListener.set(listener);
            return registration;
          }

          @Override
          public Optional<String> getSelectedItem() {
            return Optional.of(value);
          }
        };

    AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>();
    Registration actualRegistration =
        select.addSingleSelectionListener(
            evt -> {
              Assert.assertNull(event.get());
              event.set(evt);
            });
    Assert.assertSame(registration, actualRegistration);

    selectionListener
        .get()
        .selectionChange(new SingleSelectionEvent<>(grid, select.asSingleSelect(), true));

    Assert.assertEquals(grid, event.get().getComponent());
    Assert.assertEquals(value, event.get().getValue());
    Assert.assertTrue(event.get().isUserOriginated());
  }
コード例 #13
0
ファイル: VaadinUI.java プロジェクト: pawigor/jrtt
  @Override
  protected void init(VaadinRequest request) {
    // setContent(new But-ton("Click me", e -> Notification.show("Hello
    // Spring+Vaadin user!")));

    System.out.println(request);
    String page = request.getParameter("page");
    String size = request.getParameter("size");
    Map<String, String[]> m = request.getParameterMap();
    for (Map.Entry<String, String[]> e : m.entrySet()) {
      System.out.println(e.getKey());
      for (String s : e.getValue()) {
        System.out.println(s);
      }
    }

    VerticalLayout actions = new VerticalLayout(addNewBtn, grid);
    HorizontalLayout mainLayout = new HorizontalLayout(actions, editor);

    // actions.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    setContent(mainLayout);

    // setContent(grid);

    // Connect selected Customer to editor or hide if none is selected
    grid.addSelectionListener(
        e -> {
          if (e.getSelected().isEmpty()) {
            editor.setVisible(false);
          } else {
            editor.editTask((Task) e.getSelected().iterator().next());
          }
        });

    // Instantiate and edit new Customer the new button is clicked
    addNewBtn.addClickListener(e -> editor.editTask(new Task()));

    // Listen changes made by the editor, refresh data from backend
    editor.setChangeHandler(
        () -> {
          editor.setVisible(false);
          listTasks();
        });

    // Initialize listing
    listTasks();
  }
コード例 #14
0
 private Grid createGrid() {
   final Grid statusGrid = new Grid(uploads);
   statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
   statusGrid.setSelectionMode(SelectionMode.NONE);
   statusGrid.setHeaderVisible(true);
   statusGrid.setImmediate(true);
   statusGrid.setSizeFull();
   return statusGrid;
 }
コード例 #15
0
  private void buildLayout() {
    keyList.setSizeFull();

    HorizontalLayout showAndEdit = new HorizontalLayout(keyList, editForm);
    showAndEdit.setSizeFull();
    showAndEdit.setSpacing(true);
    showAndEdit.setMargin(false);
    showAndEdit.setExpandRatio(keyList, 0.5f);
    showAndEdit.setExpandRatio(editForm, 0.5f);

    addComponent(showAndEdit);

    setMargin(true);
    setSpacing(false);
    setSizeFull();
    setExpandRatio(showAndEdit, 1);
  }
コード例 #16
0
  public SubsEditViewImpl() {
    ButtonRenderer deleteButton = createDeleteButton();
    Slider percentSlider = createPercentSlider();
    MultiFileUpload uploader = createUploader();

    // need to update the grid a first time for initialization.
    updateGrid(null);
    grid.getColumn("delete").setRenderer(deleteButton);
    fileDownloader = new FileDownloader(generateResource());
    fileDownloader.extend(downloadButton);

    // create the main layout
    VerticalLayout content = new VerticalLayout();

    // layout which contains the uploader and the percentage - in other words : all the
    // configuration information
    HorizontalLayout configHorizontalLayout = new HorizontalLayout();
    configHorizontalLayout.addComponent(uploader);

    // Configure the layout which contains the percentage slider
    AbsoluteLayout sliderLayout = new AbsoluteLayout();
    sliderLayout.setWidth("100px");
    sliderLayout.setHeight("35px");
    sliderLayout.addComponent(percentSlider);

    // Configure the layout which contains the percentage slider layout and the labels linked to the
    // percentage
    HorizontalLayout percentageLayout = new HorizontalLayout();
    percentageLayout.addComponent(percentSliderTitle);
    percentageLayout.addComponent(sliderLayout);
    percentageLayout.addComponent(percentLabel);
    percentageLayout.setComponentAlignment(percentSliderTitle, Alignment.MIDDLE_LEFT);
    percentageLayout.setComponentAlignment(percentLabel, Alignment.MIDDLE_LEFT);

    // add the percentage Layout to the layout which contains the uploader
    configHorizontalLayout.addComponent(percentageLayout);
    configHorizontalLayout.setComponentAlignment(percentageLayout, Alignment.BOTTOM_LEFT);

    // add every layouts to the principal one
    content.addComponent(configHorizontalLayout);
    content.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    content.addComponents(grid);
    content.addComponent(downloadButton);
    setCompositionRoot(content);
  }
コード例 #17
0
  @Test
  public void serverSideSelection_GridChangingSelectionModel_sendsUpdatedRowsToClient() {

    CustomSingleSelectionModel customModel = new CustomSingleSelectionModel();
    Grid<String> customGrid =
        new Grid<String>() {
          {
            setSelectionModel(customModel);
          }
        };
    customGrid.setItems("Foo", "Bar", "Baz");

    customGrid.getDataCommunicator().beforeClientResponse(true);

    Assert.assertFalse(
        "Item should have been updated as selected", customModel.generatedData.get("Foo"));
    Assert.assertFalse(
        "Item should have been updated as NOT selected", customModel.generatedData.get("Bar"));
    Assert.assertFalse(
        "Item should have been updated as NOT selected", customModel.generatedData.get("Baz"));

    customModel.generatedData.clear();

    customGrid.getSelectionModel().select("Foo");
    customGrid.getDataCommunicator().beforeClientResponse(false);

    Assert.assertTrue(
        "Item should have been updated as selected", customModel.generatedData.get("Foo"));
    Assert.assertFalse(
        "Item should have NOT been updated", customModel.generatedData.containsKey("Bar"));
    Assert.assertFalse(
        "Item should have NOT been updated", customModel.generatedData.containsKey("Baz"));

    // switch to another selection model to cause event
    customModel.generatedData.clear();
    customGrid.setSelectionMode(SelectionMode.MULTI);
    customGrid.getDataCommunicator().beforeClientResponse(false);

    // since the selection model has been removed, it is no longer a data
    // generator for the data communicator, would need to verify somehow
    // that row is not marked as selected anymore ? (done in UI tests)
    Assert.assertTrue(customModel.generatedData.isEmpty()); // at least
    // removed
    // selection
    // model is not
    // triggered
  }
コード例 #18
0
  @Override
  public void updateGrid(Set<Subtitle> subs) {
    BeanItemContainer<Subtitle> subsContainer = new BeanItemContainer<>(Subtitle.class, subs);
    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(subsContainer);
    gpc.addGeneratedProperty(
        "delete",
        new PropertyValueGenerator<String>() {
          @Override
          public String getValue(Item item, Object itemId, Object propertyId) {
            return "Delete";
          }

          @Override
          public Class<String> getType() {
            return String.class;
          }
        });
    grid.setContainerDataSource(gpc);
    downloadButton.setEnabled(subs != null && subs.size() > 0);
  }
コード例 #19
0
  @Test
  public void gridChangingSelectionModel_firesSelectionChangeEvent() {
    Grid<String> customGrid = new Grid<>();
    customGrid.setItems("Foo", "Bar", "Baz");

    List<String> selectionChanges = new ArrayList<>();
    ((SingleSelectionModelImpl<String>) customGrid.getSelectionModel())
        .addSingleSelectionListener(e -> selectionChanges.add(e.getValue()));

    customGrid.getSelectionModel().select("Foo");
    assertEquals("Foo", customGrid.getSelectionModel().getFirstSelectedItem().get());
    assertEquals(Arrays.asList("Foo"), selectionChanges);

    customGrid.setSelectionMode(SelectionMode.MULTI);
    assertEquals(Arrays.asList("Foo", null), selectionChanges);
  }
コード例 #20
0
  @SuppressWarnings("unchecked")
  private void populateUsers() {

    if (users == null) {
      return;
    }

    configureContainer();

    for (User u : users) {
      if (u == null) continue;

      Item newItem = container.getItem(container.addItem());
      newItem.getItemProperty("creditCardNo").setValue(u.getCreditCardNo());
      newItem.getItemProperty("userId").setValue(u.getUserId());
      newItem.getItemProperty("firstname").setValue(u.getFirstname());
      newItem.getItemProperty("lastname").setValue(u.getLastname());
      newItem.getItemProperty("cityName").setValue(u.getCityName());
      newItem.getItemProperty("stateName").setValue(u.getStateName());
      newItem.getItemProperty("gender").setValue(u.getGender());
    }

    userGrid.setContainerDataSource(container);
  }
コード例 #21
0
  @SuppressWarnings("unchecked")
  public void populateUserRules() {

    System.out.println("Populating user rules");

    this.userRules = service.getUserRules(userId);

    configureRulesContainer();

    for (UserRule u : userRules) {
      if (u == null) continue;

      Item newItem = rulesContainer.getItem(rulesContainer.addItem());
      newItem.getItemProperty("userId").setValue(u.getUserId());
      newItem.getItemProperty("ruleId").setValue(u.getRuleId());
      newItem.getItemProperty("ruleName").setValue(u.getRuleName());
      newItem.getItemProperty("merchant").setValue(u.getMerchant());
      newItem.getItemProperty("amount").setValue(u.getAmount());
      newItem.getItemProperty("noOfTransactions").setValue(u.getNoOfTransactions());
      newItem.getItemProperty("noOfDays").setValue(u.getNoOfDays());
    }

    userRulesGrid.setContainerDataSource(rulesContainer);
  }
コード例 #22
0
ファイル: MyUI.java プロジェクト: YMGGTP/ParcAuto
  private void configureComponents() {

    // Chargement des données.
    Init uniqueinstance = Init.getInit();
    uniqueinstance.chargementinitial();

    contactList.setContainerDataSource(Vehicule.getVehicules());
    contactList1.setContainerDataSource(Vehicule.getVehiculesPrixBas());
    contactList2.setContainerDataSource(Visiteur.getVisiteur());
    contactList3.setContainerDataSource(Affectation.getAffectation());

    // contactTable.setContainerDataSource(new BeanItemContainer<>( Vehicule.class));
    contactList.setColumnOrder("marque", "modele", "prix"); // choisir l'ordre des colonnes
    contactList.removeColumn("id");
    contactList1.setColumnOrder("marque", "modele", "prix"); // choisir l'ordre des colonnes
    contactList1.removeColumn("id"); // masquer la colonne
    // contactList.setSelectionMode(Grid.SelectionMode.SINGLE);

    contactList2.setColumnOrder("id", "prenom", "nom", "marque"); // choisir l'ordre des colonnes
    contactList3.setColumnOrder("id", "dateAffection", "nom", "marque");

    contactList.setSizeFull();
    contactList1.setSizeFull();
    contactList2.setSizeFull();
    contactList3.setSizeFull();
  }
コード例 #23
0
ファイル: MyUI.java プロジェクト: PavelMaletin/d-model
  private Grid showGrid() {
    Grid grid = new Grid("Справочник", jpaPost);
    grid.setSizeFull();

    return grid;
  }
コード例 #24
0
  public GestionNotificacion() {
    super();
    setMargin(true);
    setSpacing(true);
    setSizeFull();
    HorizontalL h1 = new HorizontalL();
    id = new CampoRuc();
    razonSocial = new CampoRazonSocial();
    razonSocial.setWidth("320px");
    direccion = new CampoDireccion();
    direccion.setWidth("450px");
    correoElectronico = new CampoCorreoElectronico();
    correoElectronico.setWidth("260px");

    tipoIdentificacion = new ComboBox();
    tipoIdentificacion.addItem("04");
    tipoIdentificacion.addItem("05");
    tipoIdentificacion.addItem("06");
    tipoIdentificacion.addItem("07");
    tipoIdentificacion.addItem("08");
    tipoIdentificacion.setItemCaption("04", "RUC");
    tipoIdentificacion.setItemCaption("05", "CEDULA");
    tipoIdentificacion.setItemCaption("06", "PASAPORTE");
    tipoIdentificacion.setItemCaption("07", "CONSUMIDOR FINAL");
    tipoIdentificacion.setItemCaption("08", "IDENTIFICADOR EXTERIOR");
    tipoIdentificacion.setNullSelectionAllowed(false);
    tipoIdentificacion.setValue("04");
    tipoIdentificacion.setWidth("140px");

    h1.addComponent(tipoIdentificacion, id);
    h1.addComponent("Razón Social", razonSocial);
    // h1.addComponent("Dirección",direccion);
    h1.addComponent("Email", correoElectronico);
    botonAnadir = new BotonAnadir();

    addComponent(h1);
    setComponentAlignment(h1, Alignment.TOP_CENTER);
    HorizontalL h2 = new HorizontalL();
    h2.addComponent("direccion", direccion);
    h2.addComponent(botonAnadir);
    addComponent(h2);

    grid = new Grid();
    beanItemC = new BeanItemContainer<DemografiaCliente>(DemografiaCliente.class);
    grid.setContainerDataSource(beanItemC);
    //		DemografiaCliente d=new DemografiaCliente();
    //		beanItemC.addBean(d);
    grid.removeColumn("entidadEmisora");
    grid.getColumn("id").setHeaderCaption("Identificacion");
    grid.setColumnOrder("razonSocial", "identificacion", "direccion", "correoElectronico");
    grid.setSizeFull();
    grid.removeColumn("tipoIdentificacion");
    grid.removeColumn("id");
    botonCancelar = new BotonCancelar();

    addComponent(grid);
    addComponent(botonCancelar);
    setComponentAlignment(botonCancelar, Alignment.BOTTOM_RIGHT);
    setComponentAlignment(h2, Alignment.TOP_CENTER);
    setExpandRatio(h1, 1);
    setExpandRatio(h2, 1);
    setExpandRatio(grid, 8);
    setExpandRatio(botonCancelar, 1);
    nuevoDato = new DemografiaCliente();
    beanItem = new BeanItem<DemografiaCliente>(nuevoDato);
    fg = new FieldGroup();
    fg.setItemDataSource(beanItem);
  }
コード例 #25
0
  @Test(expected = IllegalStateException.class)
  public void selectionModelChanged_usingPreviousSelectionModel_throws() {
    grid.setSelectionMode(SelectionMode.MULTI);

    selectionModel.select(PERSON_A);
  }
コード例 #26
0
 void uploadStarted(final String filename, final SoftwareModule softwareModule) {
   grid.scrollTo(getItemid(filename, softwareModule));
 }
コード例 #27
0
  private void configureComponents() {
    configureContainer();
    configureRulesContainer();

    fieldSearch.setNullSelectionAllowed(false);
    fieldSearch.addItem("cc_no");
    fieldSearch.addItem("user_id");
    fieldSearch.addItem("first");
    fieldSearch.addItem("last");
    fieldSearch.addItem("city");
    fieldSearch.addItem("state");
    fieldSearch.setValue("first");

    userGrid.setContainerDataSource(container);
    userGrid.setColumnOrder(
        "creditCardNo", "userId", "firstname", "lastname", "cityName", "stateName", "gender");
    userGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    userGrid.addSelectionListener(
        new SelectionListener() {

          @Override
          public void select(SelectionEvent event) {
            Item item = userGrid.getContainerDataSource().getItem(userGrid.getSelectedRow());

            if (item != null) {
              userId = item.getItemProperty("userId").getValue().toString();
              populateUserRules();
            }
          }
        });
    userRulesGrid.setContainerDataSource(rulesContainer);
    userRulesGrid.setColumnOrder(
        "userId", "ruleName", "merchant", "amount", "noOfTransactions", "noOfDays");
    userRulesGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    userRulesGrid.addSelectionListener(
        new SelectionListener() {

          @Override
          public void select(SelectionEvent event) {}
        });
    filterCCNo.addTextChangeListener(
        new TextChangeListener() {

          @Override
          public void textChange(TextChangeEvent event) {
            String filterValue = event.getText();

            users = service.searchUser(fieldSearch.getValue().toString(), filterValue);
            populateUsers();
          }
        });

    addUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item = userGrid.getContainerDataSource().getItem(userGrid.getSelectedRow());

            if (item != null) {

              userId = item.getItemProperty("userId").getValue().toString();
              UserRuleWindow sub = new UserRuleWindow(userId);
              // Add it to the root component
              getUI().addWindow(sub);
              populateUserRules();
            }
          }
        });
    editUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item =
                userRulesGrid.getContainerDataSource().getItem(userRulesGrid.getSelectedRow());

            if (item != null) {

              UserRule userRule =
                  service.getUserRule(
                      item.getItemProperty("userId").getValue().toString(),
                      item.getItemProperty("ruleId").getValue().toString());

              UserRuleWindow sub = new UserRuleWindow(userRule);

              getUI().addWindow(sub);
              populateUserRules();
            }
          }
        });
    deleteUserRuleButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            Item item =
                userRulesGrid.getContainerDataSource().getItem(userRulesGrid.getSelectedRow());

            if (item != null) {
              userId = item.getItemProperty("userId").getValue().toString();
              service.deleteUserRule(userId, item.getItemProperty("ruleId").getValue().toString());
              populateUserRules();
            }
          }
        });

    populateUsers();
  }
コード例 #28
0
  @Override
  public void refresh() {
    keyList.setContainerDataSource(new BeanItemContainer<>(Key.class, service.findAll("")));

    editForm.setVisible(false);
  }
コード例 #29
0
 @Override
 public void clearSelection() {
   keyList.select(null);
 }