Пример #1
0
  @Override
  public void init() {
    Window mainWindow = new Window("GridDemo");
    mainWindow.getContent().setSizeFull();
    ((VerticalLayout) mainWindow.getContent()).setSpacing(true);
    Indexed c = getTestContainer();
    final Table table = new Table();
    table.setImmediate(true);
    table.setSizeUndefined();
    table.setHeight("100%");
    table.setWidth("100%");
    table.setContainerDataSource(c);
    table.setCacheRate(0.5d);

    table.setNullSelectionAllowed(false);
    final Grid grid = new Grid(c);
    grid.setWidth("100%");
    grid.setHeight("100%");

    mainWindow.addComponent(grid);
    grid.getBody().setCelEditingEnabled(true);
    grid.setColumnWidth("p1", 200);
    grid.setImmediate(true);
    grid.setColumnAlignment("p1", Align.RIGHT);
    grid.setColumnAlignment("p2", Align.CENTER);
    grid.getHeader()
        .setHeaderFactory(
            new HeaderComponentFactory() {
              @Override
              public Component createComponent(final Grid grid, final Object propertyId) {
                final TextField l = new TextField("<b>" + propertyId + "<\b>");
                l.setImmediate(true);
                l.setWidth("100%");
                l.addListener(
                    new ValueChangeListener() {
                      @Override
                      public void valueChange(ValueChangeEvent event) {
                        ((Filterable) grid.getContainerDataSource())
                            .addContainerFilter(
                                new Filter() {

                                  @Override
                                  public boolean passesFilter(Object itemId, Item item)
                                      throws UnsupportedOperationException {
                                    return item.getItemProperty(propertyId)
                                        .getValue()
                                        .toString()
                                        .contains(l.getValue().toString());
                                  }

                                  @Override
                                  public boolean appliesToProperty(Object id) {
                                    return id.equals(propertyId);
                                  }
                                });
                      }
                    });
                return l;
              }
            });
    table.setEditable(true);
    // mainWindow.addComponent(table);
    setMainWindow(mainWindow);
    setTheme("griddemotheme");
  }
Пример #2
0
  @Override
  public void attach() {
    super.attach();
    init(
        getBundleString("streamingConfigPanel.caption"),
        getComponentFactory().createGridLayout(1, 5, true, true));
    myVlcEnabled = getComponentFactory().createCheckBox("streamingConfigPanel.vlcEnabled");
    myVlcBinary =
        getComponentFactory()
            .createTextField(
                "streamingConfigPanel.vlcBinary",
                new VlcExecutableFileValidator(
                    getBundleString("streamingConfigPanel.vlcBinary.invalidBinary")));
    myVlcBinary.setImmediate(false);
    myVlcBinarySelect =
        getComponentFactory().createButton("streamingConfigPanel.vlcBinary.select", this);
    myVlcHomepageButton =
        getComponentFactory().createButton("streamingConfigPanel.vlcHomepage", this);
    myVlcForm = getComponentFactory().createForm(null, true);
    myVlcForm.addField(myVlcEnabled, myVlcEnabled);
    myVlcForm.addField(myVlcBinary, myVlcBinary);
    myVlcForm.addField(myVlcBinarySelect, myVlcBinarySelect);
    myVlcForm.addField(myVlcHomepageButton, myVlcHomepageButton);
    Panel vlcPanel =
        getComponentFactory()
            .surroundWithPanel(
                myVlcForm,
                FORM_PANEL_MARGIN_INFO,
                getBundleString("streamingConfigPanel.caption.vlc"));
    addComponent(vlcPanel);
    Panel transcoderPanel = new Panel(getBundleString("streamingConfigPanel.caption.transcoder"));
    transcoderPanel.setContent(getComponentFactory().createVerticalLayout(true, true));
    Panel addTranscoderButtons = new Panel();
    addTranscoderButtons.addStyleName("light");
    addTranscoderButtons.setContent(
        getApplication().getComponentFactory().createHorizontalLayout(false, true));
    myAddTranscoder =
        getComponentFactory().createButton("streamingConfigPanel.transcoder.add", this);
    addTranscoderButtons.addComponent(myAddTranscoder);
    myTranscoderTable = new Table();
    myTranscoderTable.setCacheRate(50);
    myTranscoderTable.addContainerProperty(
        "name",
        String.class,
        null,
        getBundleString("streamingConfigPanel.transcoder.name"),
        null,
        null);
    myTranscoderTable.addContainerProperty("edit", Button.class, null, "", null, null);
    myTranscoderTable.addContainerProperty("delete", Button.class, null, "", null, null);
    myTranscoderTable.setSortContainerPropertyId("name");
    transcoderPanel.addComponent(myTranscoderTable);
    transcoderPanel.addComponent(addTranscoderButtons);
    addComponent(transcoderPanel);
    myCacheForm = getComponentFactory().createForm(null, true);
    myTranscodingCacheMaxGiB =
        getComponentFactory()
            .createTextField(
                "streamingConfigPanel.cache.transcodingCacheMaxGiB",
                getApplication().getValidatorFactory().createMinMaxValidator(1, 1024));
    myCacheForm.addField("limitTranscoding", myTranscodingCacheMaxGiB);
    myHttpLiveStreamCacheMaxGiB =
        getComponentFactory()
            .createTextField(
                "streamingConfigPanel.cache.httpLiveStreamCacheMaxGiB",
                getApplication().getValidatorFactory().createMinMaxValidator(1, 1024));
    myCacheForm.addField("limitHttpLiveStream", myHttpLiveStreamCacheMaxGiB);
    myClearAllCachesButton =
        getComponentFactory().createButton("streamingConfigPanel.clearAllCaches", this);
    myCacheForm.addField(myClearAllCachesButton, myClearAllCachesButton);
    addComponent(
        getComponentFactory()
            .surroundWithPanel(
                myCacheForm,
                FORM_PANEL_MARGIN_INFO,
                getBundleString("streamingConfigPanel.caption.cache")));

    addDefaultComponents(0, 4, 0, 4, false);

    initFromConfig();
  }