Example usage for com.vaadin.ui Embedded Embedded

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

Introduction

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

Prototype

public Embedded(String caption, Resource source) 

Source Link

Document

Creates a new Embedded object whose contents is loaded from given resource.

Usage

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.HorizontalNavigationViewlet.java

License:Apache License

public void refresh() {
    final CssLayout navigationLayout = new CssLayout();
    //navigationLayout.setSpacing(true);
    //navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }/*from   w w w .j  a  v  a  2 s.  c  o m*/
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        itemLayout.setStyleName("horizontal-navigation-" + pageName);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setStyleName("horizontal-navigation-logout");
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(20, UNITS_PIXELS);
            embedded.setHeight(20, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.ImageViewlet.java

License:Apache License

@Override
public void attach() {
    super.attach();
    final String logoImageThemeFileName = getViewletDescriptor().getConfiguration();
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);//from www  .ja v a2 s .  c  o  m
    final Embedded embedded = new Embedded(null, new ThemeResource(logoImageThemeFileName));
    embedded.setWidth(32, UNITS_PIXELS);
    embedded.setHeight(32, UNITS_PIXELS);
    layout.addComponent(embedded);
    layout.setComponentAlignment(embedded, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layout);
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.VerticalNavigationViewlet.java

License:Apache License

public void refresh() {
    final VerticalLayout navigationLayout = new VerticalLayout();
    navigationLayout.setSpacing(true);/*w  w  w.j a  va2  s.  c o  m*/
    navigationLayout.setMargin(true);

    final NavigationVersion navigationVersion = getSite().getCurrentNavigationVersion();

    //final ViewDescriptor page = getPageWindow().getViewDescriptor();
    final String[] elements = navigationVersion.getTree().split(";");
    for (final String element : elements) {
        final int indentLastIndex = element.lastIndexOf('+');
        final String pageName = indentLastIndex == -1 ? element : element.substring(indentLastIndex + 1);

        final ViewVersion pageVersion = getSite().getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (getSite().getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        final String localizedPageName = getSite().localize("page-link-" + pageName);
        final Resource iconResource = getSite().getIcon("page-icon-" + pageName);

        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = indentLastIndex + 1;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(32, UNITS_PIXELS);
            embedded.setHeight(32, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button link = new Button(localizedPageName);
        link.setStyleName(BaseTheme.BUTTON_LINK);
        link.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(pageName);
            }
        });
        /*if (page.getName().equals(pageName)) {
        link.setEnabled(false);
        }*/

        itemLayout.addComponent(link);
        itemLayout.setComponentAlignment(link, Alignment.MIDDLE_LEFT);
    }

    if (getSite().getSecurityProvider().getUser() != null) {
        final HorizontalLayout itemLayout = new HorizontalLayout();
        itemLayout.setSpacing(true);
        itemLayout.setMargin(false);
        navigationLayout.addComponent(itemLayout);

        final int indentCount = 0;
        final StringBuilder indentBuilder = new StringBuilder();
        for (int i = 0; i < indentCount; i++) {
            indentBuilder.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }

        final Resource iconResource = getSite().getIcon("page-icon-logout");
        final Label indent = new Label(indentBuilder.toString(), Label.CONTENT_XHTML);
        itemLayout.addComponent(indent);
        if (iconResource != null) {
            final Embedded embedded = new Embedded(null, iconResource);
            embedded.setWidth(32, UNITS_PIXELS);
            embedded.setHeight(32, UNITS_PIXELS);
            itemLayout.addComponent(embedded);
        }

        final Button logoutButton = new Button(getSite().localize("button-logout"));
        logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
        logoutButton.addClickListener(new ClickListener() {
            /** Serial version UID. */
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final Company company = getSite().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());

                // Close the VaadinSession
                getSession().close();

            }
        });

        itemLayout.addComponent(logoutButton);
        itemLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_LEFT);
    }

    setCompositionRoot(navigationLayout);
}

From source file:org.vaadin.addons.sitekit.viewlet.user.AccountFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
    filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(),
            101, "=", String.class, ""));
    filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=",
            String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
            new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }//from   ww w.  java 2 s  .  c o m

    final GridLayout gridLayout = new GridLayout(1, 6);
    gridLayout.setRowExpandRatio(0, 0.0f);
    gridLayout.setRowExpandRatio(1, 0.0f);
    gridLayout.setRowExpandRatio(2, 0.0f);
    gridLayout.setRowExpandRatio(3, 0.0f);
    gridLayout.setRowExpandRatio(4, 0.0f);
    gridLayout.setRowExpandRatio(5, 1.0f);

    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(4, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout userAccountTitle = new HorizontalLayout();
    userAccountTitle.setMargin(new MarginInfo(false, false, false, false));
    userAccountTitle.setSpacing(true);
    final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user"));
    userAccountTitleIcon.setWidth(32, UNITS_PIXELS);
    userAccountTitleIcon.setHeight(32, UNITS_PIXELS);
    userAccountTitle.addComponent(userAccountTitleIcon);
    final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", Label.CONTENT_XHTML);
    userAccountTitle.addComponent(userAccountTitleLabel);
    gridLayout.addComponent(userAccountTitle, 0, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, false, false));
    titleLayout.setSpacing(true);
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer"));
    titleIcon.setWidth(32, UNITS_PIXELS);
    titleIcon.setHeight(32, UNITS_PIXELS);
    titleLayout.addComponent(titleIcon);
    final Label titleLabel = new Label("<h2>Customer Accounts</h2>", Label.CONTENT_XHTML);
    titleLayout.addComponent(titleLabel);
    gridLayout.addComponent(titleLayout, 0, 3);

    final Table table = new Table();
    table.setPageLength(10);
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 5);

    final Button editUserButton = new Button("Edit User Account");
    editUserButton.setIcon(getSite().getIcon("button-icon-edit"));
    gridLayout.addComponent(editUserButton, 0, 2);
    editUserButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider())
                    .getUserFromSession();
            final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class);
            customerView.edit(entity, false);
            getFlow().forward(UserAccountFlowlet.class);
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final Panel openIdPanel = new Panel();
        openIdPanel.setStyleName(Reindeer.PANEL_LIGHT);
        openIdPanel.setCaption("Choose OpenID Provider:");
        gridLayout.addComponent(openIdPanel, 0, 1);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        openIdPanel.setContent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlink";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    final HorizontalLayout customerButtonsLayout = new HorizontalLayout();
    gridLayout.addComponent(customerButtonsLayout, 0, 4);
    customerButtonsLayout.setMargin(false);
    customerButtonsLayout.setSpacing(true);

    final Button editCustomerDetailsButton = new Button("Edit Customer Details");
    customerButtonsLayout.addComponent(editCustomerDetailsButton);
    editCustomerDetailsButton.setEnabled(false);
    editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerDetailsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(entity, false);
        }
    });

    final Button editCustomerMembersButton = new Button("Edit Customer Members");
    customerButtonsLayout.addComponent(editCustomerMembersButton);
    editCustomerMembersButton.setEnabled(false);
    editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerMembersButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getMemberGroup(), false);
        }
    });

    final Button editCustomerAdminsButton = new Button("Edit Customer Admins");
    customerButtonsLayout.addComponent(editCustomerAdminsButton);
    editCustomerAdminsButton.setEnabled(false);
    editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerAdminsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getAdminGroup(), false);
        }
    });

    table.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            editCustomerDetailsButton.setEnabled(table.getValue() != null);
            editCustomerMembersButton.setEnabled(table.getValue() != null);
            editCustomerAdminsButton.setEnabled(table.getValue() != null);
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.user.privilege.PrivilegesFlowlet.java

License:Apache License

@Override
protected void initialize() {
    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, true, false));
    titleLayout.setSpacing(true);/*  w  w w.java 2s .c o m*/
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-privileges"));
    titleIcon.setWidth(32, Unit.PIXELS);
    titleIcon.setHeight(32, Unit.PIXELS);
    titleLayout.addComponent(titleIcon);
    titleLabel = new Label("<h1>" + getSite().localize("view-privileges") + "</h1>", ContentMode.HTML);
    titleLayout.addComponent(titleLabel);

    matrixLayout = new VerticalLayout();
    matrixLayout.setSpacing(true);
    matrixLayout.setMargin(false);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new Button.ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            saveGroupMatrix();
            saveUserMatrix();
            PrivilegeCache.flush((Company) Site.getCurrent().getSiteContext().getObject(Company.class));
        }
    });
    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new Button.ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            refreshGroupMatrix();
            refreshUserMatrix();
        }
    });

    final VerticalLayout panel = new VerticalLayout();
    panel.addComponent(titleLayout);
    panel.addComponent(matrixLayout);
    panel.addComponent(buttonLayout);
    panel.setSpacing(true);
    panel.setMargin(true);

    final Panel mainLayout = new Panel();
    mainLayout.setStyleName(Reindeer.PANEL_LIGHT);
    mainLayout.setContent(panel);

    setCompositionRoot(mainLayout);
}

From source file:org.vaadin.johannesh.jfokus2012.touchkit.view.ShowContactView.java

License:Open Source License

private void buildLayout() {
    layout = new CssLayout();
    layout.addStyleName("show-contact-view");
    layout.setWidth("100%");

    VerticalComponentGroup infoGroup = new VerticalComponentGroup("");
    infoGroup.setWidth("100%");

    Component label;/*from   w  w  w .  j  ava2 s.  c  o m*/
    Property p;

    p = item.getItemProperty(ContactUtils.PROPERTY_COMPANY);
    label = new Label(new ContactUtils.CompanyPropertyFormatter(p));
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_COMPANY));
    infoGroup.addComponent(label);

    p = item.getItemProperty(ContactUtils.PROPERTY_MOBILE);
    label = new Label(p);
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_MOBILE));
    infoGroup.addComponent(label);

    p = item.getItemProperty(ContactUtils.PROPERTY_EMAIL);
    label = new Label(p);
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_EMAIL));
    infoGroup.addComponent(label);

    Embedded picture = new Embedded("", new ThemeResource("icon/picture.png"));
    picture.setWidth("57px");
    picture.setHeight("57px");

    Label firstName = new Label(item.getItemProperty(ContactUtils.PROPERTY_FIRST_NAME));
    firstName.addStyleName("strong-name");

    Label lastName = new Label(item.getItemProperty(ContactUtils.PROPERTY_LAST_NAME));
    lastName.addStyleName("strong-name");

    GridLayout nameLayout = new GridLayout(2, 2);
    nameLayout.setWidth("100%");
    nameLayout.setSpacing(true);
    nameLayout.setMargin(true, true, false, true);
    nameLayout.setColumnExpandRatio(1, 1.0f);
    nameLayout.addComponent(picture, 0, 0, 0, 1);
    nameLayout.addComponent(firstName, 1, 0);
    nameLayout.addComponent(lastName, 1, 1);
    nameLayout.setComponentAlignment(firstName, Alignment.MIDDLE_LEFT);
    nameLayout.setComponentAlignment(lastName, Alignment.MIDDLE_LEFT);

    final Favourite favourite = new Favourite();
    favourite.setImmediate(true);
    favourite.setReadOnly(true);
    favourite.setIcon(new ThemeResource("icon/favourite.png"));
    favourite.setPropertyDataSource(item.getItemProperty(ContactUtils.PROPERTY_FAVOURITE));

    layout.addComponent(nameLayout);
    layout.addComponent(favourite);
    layout.addComponent(infoGroup);

    Button editButton = new Button("Edit");
    editButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getNavigationManager().navigateTo(new EditContactView(item));
        }
    });
    setRightComponent(editButton);
    setContent(layout);
}

From source file:org.vaadin.notifique.Notifique.java

License:Apache License

public Message add(Resource icon, Component component, String style, boolean showCloseButton) {

    HorizontalLayout lo = new HorizontalLayout();
    lo.setSpacing(true);/*from  w w w  .  ja  v  a2 s.c o m*/
    lo.setWidth("100%");

    final Message i = createMessage(lo, style);
    publish(i);

    // Add icon if given
    if (icon != null) {
        lo.addComponent(new Embedded(null, icon));
    }

    lo.addComponent(component);
    lo.setExpandRatio(component, 1f);
    lo.setComponentAlignment(component, Alignment.MIDDLE_LEFT);

    // Close button if requested
    if (showCloseButton) {
        Button close = createCloseButtonFor(i);
        if (close != null) {
            lo.addComponent(close);
        }
    }

    // Listen for clicks
    lo.addListener(new LayoutClickListener() {
        private static final long serialVersionUID = 7524442205441374595L;

        public void layoutClick(LayoutClickEvent event) {
            if (getClickListener() != null) {
                getClickListener().messageClicked(i);
            }
        }
    });

    return i;
}

From source file:pt.ist.vaadinframework.ui.ApplicationWindow.java

License:Open Source License

public ApplicationWindow(String theme, Property applicationTitle, Property applicationSubtitle,
        Property copyright) {//  w  w  w  .j  a va 2 s.c o m
    setTheme(theme);
    this.applicationTitle = applicationTitle;
    this.applicationSubtitle = applicationSubtitle;
    this.copyright = copyright;
    VerticalLayout main = new VerticalLayout();
    main.setWidth(90, UNITS_PERCENTAGE);
    main.setHeight(98, UNITS_PERCENTAGE);
    main.addStyleName("application-container");

    VerticalLayout header = new VerticalLayout();
    header.setMargin(true, true, false, true);
    header.setSpacing(true);
    main.addComponent(header);
    HorizontalLayout iconAndTitle = new HorizontalLayout();
    iconAndTitle.setSizeFull();
    iconAndTitle.setSpacing(true);
    header.addComponent(iconAndTitle);
    Embedded logo = new Embedded(null, new ThemeResource("../runo/icons/64/globe.png"));
    iconAndTitle.addComponent(logo);
    iconAndTitle.setComponentAlignment(logo, Alignment.MIDDLE_LEFT);

    VerticalLayout titles = new VerticalLayout();
    titles.setSpacing(true);
    iconAndTitle.addComponent(titles);
    iconAndTitle.setExpandRatio(titles, 0.8f);
    Label title = new Label(applicationTitle);
    title.addStyleName("application-title");
    titles.addComponent(title);
    Label subtitle = new Label(applicationSubtitle);
    subtitle.addStyleName("application-subtitle");
    titles.addComponent(subtitle);

    HorizontalLayout controls = new HorizontalLayout();
    controls.setSpacing(true);
    iconAndTitle.addComponent(controls);
    iconAndTitle.setComponentAlignment(controls, Alignment.TOP_RIGHT);
    Label user = new Label("ist148357");
    controls.addComponent(user);
    Link logout = new Link("logout", new ExternalResource("#"));
    controls.addComponent(logout);

    MenuBar menu = new MenuBar();
    menu.addStyleName("application-menu");
    header.addComponent(menu);
    MenuItem hello = menu.addItem("hello", null);
    hello.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });
    MenuItem hello1 = menu.addItem("hello", null);
    hello1.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });
    MenuItem hello2 = menu.addItem("hello", null);
    hello2.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });

    body = new VerticalLayout();
    body.setSizeFull();
    body.setMargin(true);
    body.addStyleName("application-body");
    main.addComponent(body);
    main.setExpandRatio(body, 1f);
    body.addComponent(createDefaultPageBody());

    VerticalLayout footer = new VerticalLayout();
    main.addComponent(footer);
    main.setComponentAlignment(footer, Alignment.MIDDLE_CENTER);
    Label copyrightLabel = new Label(copyright);
    copyrightLabel.setSizeUndefined();
    copyrightLabel.addStyleName("application-footer");
    footer.addComponent(copyrightLabel);
    footer.setComponentAlignment(copyrightLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout outer = (VerticalLayout) getContent();
    outer.setSizeFull();
    outer.addComponent(main);
    outer.setComponentAlignment(main, Alignment.MIDDLE_CENTER);
}

From source file:pt.ist.vaadinframework.ui.fields.MultiLanguageStringField.java

License:Open Source License

public MultiLanguageStringField(String bundlename, Language... languages) {
    this.languages = languages;
    GridLayout languagesLayout = new GridLayout(3, languages.length);
    languagesLayout.setSpacing(true);//from   w  w w  . j ava 2  s .  c o m
    for (int i = 0; i < languages.length; ++i) {
        fields.put(languages[i], new TextField());
        languagesLayout.addComponent(fields.get(languages[i]), 0, i);

        Embedded languageIcon = new Embedded(null,
                new ThemeResource("../icons/flags/" + languages[i].toString() + ".gif"));
        languagesLayout.addComponent(languageIcon, 1, i);
        languagesLayout.setComponentAlignment(languageIcon, Alignment.MIDDLE_RIGHT);

        Label languageLabel = new Label(languages[i].toString());
        languagesLayout.addComponent(languageLabel, 2, i);
        languagesLayout.setComponentAlignment(languageLabel, Alignment.MIDDLE_LEFT);
    }
    setCompositionRoot(languagesLayout);
}

From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java

License:Apache License

private ComponentContainer getSearchFilter(final Entity entity, final UserAction ua,
        final OpenGroupsApplication app, final ActionContext ac) {
    final ComboBox select = new ComboBox();
    select.setImmediate(true);//from  w  ww . j  a v a2 s  . com
    select.setNullSelectionAllowed(true);
    select.setNewItemsAllowed(true);
    String stringToBigError = OpenGroupsResources.getMessage("search.string.to.big.error");
    select.addValidator(new StringLengthValidator(stringToBigError, 0, 1000, true));
    select.setWidth("350px");

    final String paramName = "searchString";
    String searchValue = (String) entity.getFilterValue(paramName);
    if (searchValue != null) {
        select.addItem(searchValue);
        select.setValue(searchValue);
    }

    // HorizontalLayout layout = new HorizontalLayout();
    // layout.setSpacing(true);
    // layout.setSizeUndefined();

    // final String searchCaption = OpenGroupsResources.getMessage("search");
    // Button searchButton = new Button(searchCaption);
    // searchButton.addListener(new ClickListener() {
    //
    // @Override
    // public void buttonClick(ClickEvent event) {
    // select.validate();
    // String value = (String) select.getValue();
    // if (value != null && "".equals(value.trim())) {
    // value = null;
    // }
    // FilterOption fo = new FilterOption(searchCaption, paramName, value);
    // entity.setFilter(fo);
    // refreshList(entity, ua, app, entity.getState().getLastUsedContainer());
    // }
    // });

    select.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            select.validate();
            String value = (String) select.getValue();
            if (value != null && "".equals(value.trim())) {
                value = null;
            }
            FilterOption fo = new FilterOption(null, paramName, value);
            entity.setFilter(fo);
            /* set current page to 1 */
            entity.getState().resetPageInfoForCurrentAction();
            refreshList(entity, ua, app, entity.getState().getLastUsedContainer(), ac);
        }
    });

    CssLayout container = new CssLayout();
    container.setSizeUndefined();
    Embedded eicon = new Embedded(null,
            OpenGroupsResources.getIcon(OpenGroupsIconsSet.SEARCH, OpenGroupsIconsSet.MEDIUM));
    eicon.setDescription(getMessage("search"));
    eicon.addStyleName("middle-left right-margin-10");
    select.addStyleName("middle-left");
    //   Label label = new Label(getMessage("search"));
    //   container.addComponent(label);
    container.addComponent(eicon);
    container.addComponent(select);
    return container;
}