Example usage for com.vaadin.ui Window Window

List of usage examples for com.vaadin.ui Window Window

Introduction

In this page you can find the example usage for com.vaadin.ui Window Window.

Prototype

public Window(String caption) 

Source Link

Document

Creates a new, empty window with a given title.

Usage

From source file:nl.svenvintges.demo.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("Data centric testcase");
    setMainWindow(window);// w w  w .  ja  v a 2 s. c  o m
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking"));
        }
    });
    window.addComponent(button);

    PopupDateField startDateField = new PopupDateField();
    startDateField.setCaption("Startdatum:");
    startDateField.setDateFormat("dd-MM-yyyy");
    window.addComponent(startDateField);

    Button searchButton = new Button();
    searchButton.setCaption("Zoeken");
    window.addComponent(searchButton);

    Table messageResultTable = new Table("Resultaten van gevonden berichten op het platform");
    MessageContainer messageContainer = new MessageContainer();
    messageContainer.populateContainer((new MessageDAOImpl()).getMessageByDateRange(new Date(), new Date()));
    messageResultTable.setContainerDataSource(messageContainer);
    window.addComponent(messageResultTable);

}

From source file:org.abstractform.sampleapp.SampleApplication.java

License:Apache License

@Override
public void init() {
    try {//w  w  w  . j av  a 2 s.co  m
        Window main = new Window("Test window");
        setMainWindow(main);
        BFormToolkit<Component> toolkit = BFormService.getInstance().getFormToolkit(Component.class);
        BForm<BusinessPartner> form = new SampleForm();
        final BFormInstance<BusinessPartner, Component> formInstance = toolkit.buildForm(form);
        main.addComponent(formInstance.getImplementation());

        final BusinessPartner bean1 = new BusinessPartner();
        bean1.setAbc("A");
        bean1.setOrganization(SampleForm.ORG4);
        bean1.setActive(true);
        bean1.setCifCode("B55425451");
        bean1.setClient(true);
        bean1.setName("Sample Name");
        bean1.setMail("mail@nomail.org");
        bean1.setCreated(new Date());
        bean1.setCreatedBy("User 1");
        bean1.setUpdated(new Date());
        bean1.setUpdatedBy("User 2");

        BusinessPartnerLocation loc = new BusinessPartnerLocation();
        loc.setAddress1("Adress One of Bean One");
        loc.setZipCode("78734");
        bean1.getBusinessPartnerLocationSet().add(loc);

        final BusinessPartner bean2 = new BusinessPartner();
        bean2.setAbc("B");
        bean2.setOrganization(null);
        bean2.setActive(false);
        bean2.setCifCode("OTRO");
        bean2.setClient(false);
        bean2.setName("Otro nombre");
        bean2.setMail(null);
        bean2.setCreated(new Date());
        bean2.setCreatedBy("Administrator 2");
        bean2.setUpdated(new Date());
        bean2.setUpdatedBy("Administrator 1");

        formInstance.setValue(bean1);

        Button but1 = new Button("Change bean", new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                if (formInstance.getValue() == bean1) {
                    formInstance.setValue(bean2);
                } else {
                    formInstance.setValue(bean1);
                }
            }
        });

        main.addComponent(but1);

        but1 = new Button("Update Model", new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                formInstance.updateModel();
            }
        });

        main.addComponent(but1);
    } catch (Exception ex) {
        throw new UndeclaredThrowableException(ex);
    }
}

From source file:org.accelerators.activiti.admin.AdminApp.java

License:Open Source License

@Override
public void init() {

    // Set theme/*from   ww  w.j  a va  2  s  .co  m*/
    setTheme(Consts.THEME);

    // Set default locale
    setLocale(new Locale("en"));

    // Init resource bundle
    final ResourceBundle i18n = ResourceBundle.getBundle(Messages.class.getName(), getLocale());

    // Add title
    mainWindow = new Window(i18n.getString(Messages.AppTitle));

    // Set window to full size
    mainWindow.setSizeFull();

    // Set as main window
    setMainWindow(mainWindow);

    // Add window to view manager
    viewManager = new ViewManager(mainWindow);

    // Create the login screen
    viewManager.switchScreen(LoginView.class.getName(), new LoginView(this));

}

From source file:org.activiti.administrator.AdminApp.java

License:Apache License

@Override
public void init() {

    // Set theme/*from   ww w .j a v  a2s.  com*/
    setTheme(Consts.THEME);

    // Set default locale
    setLocale(new Locale("en"));

    // Init resource bundle
    final ResourceBundle i18n = ResourceBundle.getBundle(Messages.class.getName(), getLocale());

    // Add title
    mainWindow = new Window(i18n.getString(Messages.AppTitle));

    // Set window to full size
    mainWindow.setSizeFull();

    // Set as main window
    setMainWindow(mainWindow);

    // Create main layout
    mainLayout = new CustomLayout(Consts.THEME);

    // Add styles
    mainLayout.addStyleName(Reindeer.LAYOUT_WHITE);
    mainLayout.setSizeFull();

    // Add layout to main window
    mainWindow.setContent(mainLayout);

    // Add window to view manager
    viewManager = new ViewManager(mainWindow);

    // Switch to the login screen
    switchView(LoginView.class.getName(), new LoginView(this));

}

From source file:org.activiti.kickstart.KickStartApplication.java

License:Apache License

protected void initMainWindow() {

    Window mainWindow = new Window(TITLE);
    setMainWindow(mainWindow);//from   www . j av a  2  s.  co  m
    Panel p = new Panel();
    p.setSizeFull();
    mainWindow.setContent(p);

    mainLayout = new CustomLayout(THEME_NAME); // uses layout defined in webapp/Vaadin/themes/yakalo
    mainLayout.setSizeFull();
    p.setContent(mainLayout);

    initSplitPanel();
    initViewManager();
    initActionsPanel();
}

From source file:org.aksw.autosparql.tbsl.gui.vaadin.TBSLApplication.java

License:Apache License

@Override
public void init() {
    // Create the application data instance
    UserSession sessionData = new UserSession(this);
    // Register it as a listener in the application context
    getContext().addTransactionListener(sessionData);

    setTheme("custom");

    ViewHandler.initialize(this);
    SessionHandler.initialize(this);
    Permissions.initialize(this, new JPAPermissionManager());

    Window mainWindow = new Window("AutoSPARQL TBSL");
    mainWindow.addParameterHandler(this);
    setMainWindow(mainWindow);/*from  w w  w.  j  a  v a  2 s.  co m*/

    mainView = new MainView();
    mainWindow.setContent(mainView);
    mainWindow.setSizeFull();

    setLogoutURL("http://aksw.org");

    mainWindow.addActionHandler(new Action.Handler() {

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            if (action == action_query) {
                onShowLearnedQuery();
            }

        }

        @Override
        public Action[] getActions(Object target, Object sender) {
            return new Action[] { action_query };
        }
    });

}

From source file:org.apache.ace.webui.vaadin.VaadinClient.java

License:Apache License

public void init() {
    setTheme("ace");

    if (!m_dependenciesResolved.get()) {
        final Window message = new Window("Apache ACE");
        message.getContent().setSizeFull();
        setMainWindow(message);/*from  w  w w  . j  av  a 2 s. c  o m*/

        Label richText = new Label("<h1>Apache ACE User Interface</h1>"
                + "<p>Due to missing component dependencies on the server, probably due to misconfiguration, "
                + "the user interface cannot be properly started. Please contact your server administrator. "
                + "You can retry accessing the user interface by <a href=\"?restartApplication\">following this link</a>.</p>");
        richText.setContentMode(Label.CONTENT_XHTML);

        // TODO we might want to add some more details here as to what's
        // missing on the other hand, the user probably can't fix that anyway
        message.addComponent(richText);
        return;
    }

    m_mainWindow = new Window("Apache ACE");
    m_mainWindow.getContent().setSizeFull();
    m_mainWindow.setBorder(Window.BORDER_NONE);

    setMainWindow(m_mainWindow);

    // Authenticate the user either by showing a login window; or by another means...
    authenticate();
}

From source file:org.askil.eshift.ui.EShiftApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("EShift");
    setMainWindow(window);/*from w  ww  . j a  va  2s. c o  m*/

    MainPage view = controller.getView();
    window.setContent(view);

}

From source file:org.axonframework.examples.addressbook.vaadin.AddressbookApplication.java

License:Apache License

private void buildMainLayout() {
    setMainWindow(new Window("Address Book Demo application"));

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();//from w w  w  . j  av  a  2 s.c  o  m
    verticalLayout.addComponent(createToolbar());
    verticalLayout.addComponent(horizontalSplit);
    verticalLayout.setExpandRatio(horizontalSplit, 1);
    horizontalSplit.setSplitPosition(150, HorizontalSplitPanel.UNITS_PIXELS);
    horizontalSplit.setFirstComponent(tree);
    tree.addListener((ItemClickEvent.ItemClickListener) this);
    getMainWindow().setContent(verticalLayout);
    setMainComponent(getListView());

}

From source file:org.azrul.langkuik.framework.webgui.EditorTableView.java

public void enter(final ViewChangeListener.ViewChangeEvent vcevent) {
    setCurrentView(vcevent.getViewName());
    this.removeAllComponents();

    //get user roles
    UserDetails userDetails = null;/* w w w . ja va2s.  c o  m*/
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (!(auth instanceof AnonymousAuthenticationToken)) {
        userDetails = (UserDetails) auth.getPrincipal();
    } else {
        return;
    }
    Set<String> currentUserRoles = new HashSet<>();
    for (GrantedAuthority grantedAuth : userDetails.getAuthorities()) {
        currentUserRoles.add(grantedAuth.getAuthority());
    }

    //determine entity rights 
    EntityRight entityRight = null;

    EntityUserMap[] entityUserMaps = classOfBean.getAnnotation(WebEntity.class).userMap();
    for (EntityUserMap e : entityUserMaps) {
        if (currentUserRoles.contains(e.role()) || ("*").equals(e.role())) {
            entityRight = e.right();
            break;
        }
    }
    if (entityRight == null) { //if entityRight=EntityRight.NONE, still allow to go through because field level might be accessible
        //Not accessible
        return;
    }

    //create bean utils
    BeanUtils beanUtils = new BeanUtils();

    //creat bread crumb
    BreadCrumbBuilder.buildBreadCrumb(vcevent.getNavigator(), pageParameter.getBreadcrumb(),
            pageParameter.getHistory());

    //create form
    FormLayout form = new FormLayout();
    FindAnyEntityParameter<C> searchQuery = new FindAnyEntityParameter<>(classOfBean);
    FindEntityCollectionParameter<P, C> entityCollectionQuery = new FindEntityCollectionParameter<>(parentBean,
            parentToBeanField,
            pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean));

    final SearchDataTableLayout<C> allDataTableLayout = new SearchDataTableLayout<>(searchQuery, classOfBean,
            dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles,
            entityRight);
    final CollectionDataTableLayout<P, C> beanTableLayout = new CollectionDataTableLayout<>(
            entityCollectionQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(),
            pageParameter.getConfig(), currentUserRoles, entityRight);

    //handle associate existing data
    final Window window = new Window("Associate");
    window.setId(window.getCaption());
    window.setContent(allDataTableLayout);
    window.setModal(true);

    HorizontalLayout popupButtonLayout = new HorizontalLayout();

    Button associateToCurrentBtn = new Button("Associate to current", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Collection<C> allDataList = allDataTableLayout.getTableValues();
            beanTableLayout.associateEntities(allDataList, choiceType);
            window.close();
        }
    });
    associateToCurrentBtn.setId(associateToCurrentBtn.getCaption());
    popupButtonLayout.addComponent(associateToCurrentBtn);

    Button closeBtn = new Button("Close", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            window.close();
        }
    });
    popupButtonLayout.addComponent(closeBtn);
    closeBtn.setId(closeBtn.getCaption());

    popupButtonLayout.setSpacing(true);
    MarginInfo marginInfo = new MarginInfo(true);

    allDataTableLayout.setMargin(marginInfo);
    allDataTableLayout.addComponent(popupButtonLayout);
    if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) {
        Button associateExistingBtn = new Button("Associate existing", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {

                EditorTableView.this.getUI().addWindow(window);
            }
        });
        form.addComponent(associateExistingBtn);
        associateExistingBtn.setId(associateExistingBtn.getCaption());
    }
    form.addComponent(beanTableLayout);

    //Navigation and actions
    HorizontalLayout buttonLayout = new HorizontalLayout();
    if (beanUtils.isCreatable(classOfBean, currentUserRoles)
            && parentToBeanFieldState.equals(ComponentState.EDITABLE)) {
        Button addNewBtn = new Button("Add new", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                C currentBean = dao.createNew(true);//dao.createAndSave(parentBean, parentToBeanField, pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean));
                BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField,
                        pageParameter);
                String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString();
                WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class);
                History his = new History(targetView, "Add new " + myObject.name());
                pageParameter.getHistory().push(his);
                vcevent.getNavigator().addView(targetView, beanView);
                vcevent.getNavigator().navigateTo(targetView);

            }
        });
        buttonLayout.addComponent(addNewBtn);
        addNewBtn.setId(addNewBtn.getCaption());
    }

    if (beanUtils.isEditable(classOfBean, currentUserRoles)
            || beanUtils.isViewable(classOfBean, currentUserRoles)) {
        Button manageBtn = new Button("Manage", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                C currentBean = beanTableLayout.getTableValues().iterator().next();
                if (currentBean != null) {
                    BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField,
                            pageParameter);
                    String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString();
                    WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class);
                    History his = new History(targetView, "Manage " + myObject.name());
                    pageParameter.getHistory().push(his);
                    vcevent.getNavigator().addView(targetView, beanView);
                    vcevent.getNavigator().navigateTo(targetView);
                }
            }
        });
        buttonLayout.addComponent(manageBtn);
        manageBtn.setId(manageBtn.getCaption());
    }

    if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) {

        if (beanUtils.isCreatable(classOfBean, currentUserRoles)
                && parentToBeanFieldState.equals(ComponentState.EDITABLE)) {
            Button deleteBtn = new Button("Delete", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    final Collection<C> currentBeans = (Collection<C>) beanTableLayout.getTableValues();
                    if (!currentBeans.isEmpty()) {
                        ConfirmDialog.show(EditorTableView.this.getUI(), "Please Confirm:",
                                "Are you really sure you want to delete these entries?", "I am", "Not quite",
                                new ConfirmDialog.Listener() {
                                    @Override
                                    public void onClose(ConfirmDialog dialog) {
                                        if (dialog.isConfirmed()) {
                                            EditorTableView.this.parentBean = beanTableLayout
                                                    .deleteData(currentBeans);
                                        }
                                    }
                                });
                    }
                }
            });
            buttonLayout.addComponent(deleteBtn);
            deleteBtn.setId(deleteBtn.getCaption());
        }
    }

    Button saveAndBackBtn = new Button("Save and back", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            //parentDao.save(parentBean);
            if (!pageParameter.getHistory().isEmpty()) {
                String currentView = pageParameter.getHistory().pop().getViewHandle();
                String lastView = pageParameter.getHistory().peek().getViewHandle();
                vcevent.getNavigator().removeView(currentView);
                vcevent.getNavigator().navigateTo(lastView);
            }
        }
    });
    buttonLayout.addComponent(saveAndBackBtn);
    saveAndBackBtn.setId(saveAndBackBtn.getCaption());

    buttonLayout.setSpacing(true);
    form.addComponent(buttonLayout);
    this.addComponent(form);
}