Search in sources :

Example 1 with AbstractLayout

use of com.vaadin.ui.AbstractLayout in project VaadinUtils by rlsutton1.

the class ComboBoxWithSearchFieldChooserWindow method getPopupContent2.

@SuppressWarnings("unchecked")
public Component getPopupContent2() {
    grid = new SearchableGrid<T, C>() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public GridHeadingPropertySetIfc<T> getHeadingPropertySet() {
            return headingProps;
        }

        @Override
        protected Filter getContainerFilter(String filterString, boolean advancedSearchActive) {
            List<Filter> filters = new ArrayList<>();
            if (baseFilters != null) {
                filters.add(baseFilters);
            }
            if (filterString.length() > 0) {
                filters.add(new SimpleStringFilter(sortColumns[0], filterString, true, false));
            }
            if (filters.size() == 0) {
                return null;
            }
            return new And(filters.toArray(new Filter[] {}));
        }

        @Override
        protected String getTitle() {
            return null;
        }

        @Override
        public C getContainer() {
            return localContainer;
        }

        @Override
        protected AbstractLayout getAdvancedSearchLayout() {
            if (advancedSearchProvider == null) {
                return null;
            }
            return advancedSearchProvider.getAdvancedSearchLayout();
        }

        @Override
        protected AdvancedSearchListener getAdvancedSearchListener() {
            return advancedSearchListener;
        }
    };
    grid.init(caption, (Class<T>) type);
    // grid.getGrid().removeHeaderRow(0);
    ItemClickListener itemClickListener = new ItemClickListener() {

        private static final long serialVersionUID = -4659382639878762429L;

        @Override
        public void itemClick(ItemClickEvent event) {
            listener.selected(event.getItemId());
        }
    };
    Sort sort = Sort.by(sortColumns[0]);
    for (int i = 1; i < sortColumns.length; i++) {
        sort.then(sortColumns[i]);
    }
    grid.sort(sort);
    grid.setSelectionMode(SelectionMode.SINGLE);
    grid.addItemClickListener(itemClickListener);
    grid.setSizeFull();
    holder = new VerticalLayout();
    holder.setWidth("100%");
    holder.setHeight("300");
    holder.addComponent(grid);
    return holder;
}
Also used : ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) ItemClickEvent(com.vaadin.event.ItemClickEvent) AdvancedSearchListener(au.com.vaadinutils.crud.AdvancedSearchListener) Filter(com.vaadin.data.Container.Filter) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) And(com.vaadin.data.util.filter.And) Sort(com.vaadin.data.sort.Sort) VerticalLayout(com.vaadin.ui.VerticalLayout) ArrayList(java.util.ArrayList) List(java.util.List) AbstractLayout(com.vaadin.ui.AbstractLayout) GridHeadingPropertySetIfc(au.com.vaadinutils.crud.GridHeadingPropertySetIfc) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter)

Example 2 with AbstractLayout

use of com.vaadin.ui.AbstractLayout in project VaadinUtils by rlsutton1.

the class SearchableGrid method buildSearchBar.

protected AbstractLayout buildSearchBar() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    searchField.setWidth(100, Unit.PERCENTAGE);
    searchBar = layout;
    basicSearchLayout = new HorizontalLayout();
    basicSearchLayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(basicSearchLayout);
    final AbstractLayout advancedSearch = buildAdvancedSearch();
    if (advancedSearch != null) {
        basicSearchLayout.addComponent(advancedSearchButton);
    }
    searchField.setInputPrompt("Search");
    searchField.setId("searchField");
    searchField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    searchField.setImmediate(true);
    searchField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(final TextChangeEvent event) {
            filterString = event.getText().trim();
            triggerFilter(filterString);
        }
    });
    // clear button
    final Button clear = createClearButton();
    basicSearchLayout.addComponent(clear);
    basicSearchLayout.setComponentAlignment(clear, Alignment.MIDDLE_LEFT);
    basicSearchLayout.addComponent(searchField);
    basicSearchLayout.setExpandRatio(searchField, 1.0f);
    return layout;
}
Also used : TextChangeEvent(com.vaadin.event.FieldEvents.TextChangeEvent) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) AbstractLayout(com.vaadin.ui.AbstractLayout) TextChangeListener(com.vaadin.event.FieldEvents.TextChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with AbstractLayout

use of com.vaadin.ui.AbstractLayout in project VaadinUtils by rlsutton1.

the class DashBoardView method createRenameButton.

private Button createRenameButton() {
    Button rename = new Button(FontAwesome.EDIT);
    rename.setDescription("Rename Dashboard");
    rename.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
    rename.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1058348590862935257L;

        @Override
        public void buttonClick(ClickEvent event) {
            Tblportallayout portalLayout = (Tblportallayout) dashBoardSelector.getValue();
            if (portalLayout == null) {
                Notification.show("You must select a dashboard first", Type.ERROR_MESSAGE);
                return;
            }
            final TextField primaryFocusField = new TextField("New Dashboard Name");
            AbstractLayout form = new FormLayout();
            form.setSizeFull();
            form.addComponent(primaryFocusField);
            InputFormDialogRecipient recipient = new InputFormDialogRecipient() {

                @Override
                public boolean onOK() {
                    Tblportallayout portalLayout = (Tblportallayout) dashBoardSelector.getValue();
                    container.removeItem(portalLayout);
                    portalLayout = JpaBaseDao.getGenericDao(Tblportallayout.class).findById(portalLayout.getId());
                    portalLayout.setName(primaryFocusField.getValue());
                    container.addBean(portalLayout);
                    dashBoardSelector.select(portalLayout);
                    dashboardsSlider.setCaption("Dashboards: " + portalLayout.getName());
                    return true;
                }

                @Override
                public boolean onCancel() {
                    return true;
                }
            };
            new InputFormDialog(UI.getCurrent(), "Rename " + portalLayout.getName() + " to:", primaryFocusField, form, recipient);
        }
    });
    return rename;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) TextField(com.vaadin.ui.TextField) InputFormDialog(au.com.vaadinutils.editors.InputFormDialog) InputFormDialogRecipient(au.com.vaadinutils.editors.InputFormDialogRecipient) AbstractLayout(com.vaadin.ui.AbstractLayout) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 4 with AbstractLayout

use of com.vaadin.ui.AbstractLayout in project VaadinUtils by rlsutton1.

the class DashBoardView method createDashboard.

void createDashboard(Tblportallayout portalLayout) {
    if (portalLayout == null) {
        portalLayout = new Tblportallayout();
        portalLayout.setName("Dashboard " + (getNumberOfPortals() + 1));
        portalLayout.setAccount(getAccountId());
        EntityManagerProvider.persist(portalLayout);
        container.addBean(portalLayout);
    }
    if (loadJQuery) {
        dashBoard = new DashBoard();
    } else {
        dashBoard = new DashBoardNoJQuery();
    }
    // this wrapper is necessary so the portals in the dashboard resize
    // correctly
    VerticalLayout wrapper = new VerticalLayout();
    wrapper.setSizeFull();
    wrapper.addComponent(dashBoard);
    dashBoard.setSizeFull();
    dashBoardHolderPanel.setContent(wrapper);
    AbstractLayout dashboardToolBar = createToolBar(new DashBoardController(dashBoard), portalLayout.getGuid());
    toolbarHolder.removeAllComponents();
    toolbarHolder.addComponent(dashboardToolBar);
    loading = true;
    dashBoardSelector.setValue(portalLayout);
    loadDashboard(portalLayout, new DashBoardController(dashBoard));
    loading = false;
    dashboardsSlider.setCaption(portalLayout.getName());
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) AbstractLayout(com.vaadin.ui.AbstractLayout)

Example 5 with AbstractLayout

use of com.vaadin.ui.AbstractLayout in project VaadinUtils by rlsutton1.

the class BaseCrudView method buildSearchBar.

private void buildSearchBar() {
    AbstractLayout group = new HorizontalLayout();
    if (UI.getCurrent().getTheme().equals(ValoTheme.class.getSimpleName())) {
        group = new CssLayout();
        group.addStyleName("v-component-group");
    }
    group.setSizeFull();
    searchLayout.addComponent(group);
    AbstractLayout advancedSearch = buildAdvancedSearch();
    if (advancedSearch != null) {
        group.addComponent(advancedSearchButton);
    }
    Button clear = createClearButton();
    group.addComponent(clear);
    group.addComponent(createRefreshButton());
    // searchField.setWidth("80%");
    searchField.setId("CrudSearchField");
    group.addComponent(searchField);
    if (group instanceof HorizontalLayout) {
        ((HorizontalLayout) group).setExpandRatio(searchField, 1);
    }
    group.addComponent(searchButton);
    searchButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            triggerFilter();
        }
    });
    searchButton.setVisible(!dynamicSearch);
    final OnEnterKeyHandler onEnterKeyHandler = new OnEnterKeyHandler() {

        @Override
        public void enterKeyPressed() {
            if (!dynamicSearch) {
                searchButton.click();
            }
        }
    };
    onEnterKeyHandler.attachTo(searchField);
}
Also used : ValoTheme(com.vaadin.ui.themes.ValoTheme) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) AbstractLayout(com.vaadin.ui.AbstractLayout) ClickListener(com.vaadin.ui.Button.ClickListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

AbstractLayout (com.vaadin.ui.AbstractLayout)7 Button (com.vaadin.ui.Button)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 TextChangeEvent (com.vaadin.event.FieldEvents.TextChangeEvent)2 TextChangeListener (com.vaadin.event.FieldEvents.TextChangeListener)2 ClickEvent (com.vaadin.ui.Button.ClickEvent)2 ClickListener (com.vaadin.ui.Button.ClickListener)2 AdvancedSearchListener (au.com.vaadinutils.crud.AdvancedSearchListener)1 GridHeadingPropertySetIfc (au.com.vaadinutils.crud.GridHeadingPropertySetIfc)1 InputFormDialog (au.com.vaadinutils.editors.InputFormDialog)1 InputFormDialogRecipient (au.com.vaadinutils.editors.InputFormDialogRecipient)1 ClickableLabel (au.com.vaadinutils.fields.ClickableLabel)1 Filter (com.vaadin.data.Container.Filter)1 Item (com.vaadin.data.Item)1 Property (com.vaadin.data.Property)1 Sort (com.vaadin.data.sort.Sort)1 And (com.vaadin.data.util.filter.And)1 SimpleStringFilter (com.vaadin.data.util.filter.SimpleStringFilter)1 ItemClickEvent (com.vaadin.event.ItemClickEvent)1