Search in sources :

Example 1 with InputFormDialogRecipient

use of au.com.vaadinutils.editors.InputFormDialogRecipient 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)

Aggregations

InputFormDialog (au.com.vaadinutils.editors.InputFormDialog)1 InputFormDialogRecipient (au.com.vaadinutils.editors.InputFormDialogRecipient)1 AbstractLayout (com.vaadin.ui.AbstractLayout)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 FormLayout (com.vaadin.ui.FormLayout)1 TextField (com.vaadin.ui.TextField)1