Example usage for com.vaadin.ui Embedded addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.cards.CardSummaryLine.java

License:Open Source License

@Override
public void initGui() {
    Card c = Card.getTL(cardId);//from w w w . j a v a 2  s  .  com
    String tooltip = c.getText();

    User auth = c.getAuthor();

    Label lab = new Label(dateForm.format(c.getCreationDate()));
    lab.setWidth(6.0f, Unit.EM);
    addComponent(lab);
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    addComponent(lab = new Label(c.getCardType().getTitle()));
    lab.setWidth(5.0f, Unit.EM);
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    Embedded emb = new Embedded(null, mLoc.getCardDot(c.getCardType()));
    emb.setWidth("19px");
    emb.setHeight("15px");
    addComponent(emb);
    setComponentAlignment(emb, Alignment.MIDDLE_LEFT);
    emb.addStyleName("m-cursor-pointer");
    emb.setDescription(tooltip);

    addComponent(lab = new Label(c.getText()));
    lab.setHeight(1.0f, Unit.EM);
    ;
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    setExpandRatio(lab, 1.0f); // all the extra
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    if (auth.getAvatar() != null) {
        avatar = new Embedded(null, mLoc.locate(auth.getAvatar().getMedia(), 32));
        avatar.setWidth("24px");
        avatar.setHeight("24px");
        addComponent(avatar);
        setComponentAlignment(avatar, Alignment.MIDDLE_LEFT);
        avatar.addStyleName("m-cursor-pointer");
        avatar.setDescription(tooltip);
    }
    IDButton uButt = new IDButton(c.getAuthorName(), SHOWUSERPROFILECLICK, c.getAuthor().getId());
    uButt.addStyleName(BaseTheme.BUTTON_LINK);
    uButt.setWidth(8.0f, Unit.EM);
    addComponent(uButt);
    setComponentAlignment(uButt, Alignment.MIDDLE_LEFT);
    uButt.setDescription(tooltip);
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.DefineAwardsDialog.java

License:Open Source License

private void fillPanelTL() {
    @SuppressWarnings("unchecked")
    List<AwardType> typs = (List<AwardType>) HSess.get().createCriteria(AwardType.class).list();
    gridList = new ArrayList<AwardType>(typs.size());
    gridList.addAll(typs);//  w  w w  .j av a  2  s . c  om
    gridLayout.removeAllComponents();
    gridLayout.setRows(typs.size() + 1);
    gridLayout.setColumns(3);
    gridLayout.setSpacing(true);
    gridLayout.setColumnExpandRatio(1, 0.5f);
    gridLayout.setColumnExpandRatio(2, 0.5f);

    gridLayout.addComponent(new HtmlLabel("<b>Icon</b>"));
    gridLayout.addComponent(new HtmlLabel("<b>Name</b>"));
    gridLayout.addComponent(new HtmlLabel("<b>Description</b>"));

    MediaLocator mediaLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    for (AwardType at : typs) {
        Embedded emb = new Embedded(null, mediaLoc.locate(at.getIcon55x55()));
        emb.addStyleName("m-greyborder3");
        gridLayout.addComponent(emb);
        TextArea tf;
        gridLayout.addComponent(tf = makeTa(at.getName()));
        gridLayout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
        gridLayout.addComponent(tf = makeTa(at.getDescription()));
        gridLayout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
    }
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.ManageAwardsDialog.java

License:Open Source License

@HibernateUserRead
private void fillPanelTL(User u) {
    @SuppressWarnings("unchecked")
    List<AwardType> typs = (List<AwardType>) HSess.get().createCriteria(AwardType.class).list();
    gridList = new ArrayList<AwardType>(typs.size());
    gridList.addAll(typs);//from  w ww  .j a  va 2  s . c o m
    gridLayout.removeAllComponents();
    gridLayout.setRows(typs.size());
    gridLayout.setColumns(4);
    gridLayout.setSpacing(true);
    gridLayout.setColumnExpandRatio(2, 0.5f);
    gridLayout.setColumnExpandRatio(3, 0.5f);

    Set<Award> uAwards = u.getAwards();
    MediaLocator mediaLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    for (AwardType at : typs) {
        CheckBox cb;
        boolean checked = hasBeenAwarded(uAwards, at);
        gridLayout.addComponent(cb = new CheckBox());
        cb.setValue(checked);
        gridLayout.setComponentAlignment(cb, Alignment.MIDDLE_CENTER);
        Embedded emb = new Embedded(null, mediaLoc.locate(at.getIcon55x55()));
        emb.addStyleName("m-greyborder3");
        gridLayout.addComponent(emb);
        Label lab;
        gridLayout.addComponent(lab = new Label(at.getName()));
        gridLayout.setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
        gridLayout.addComponent(lab = new Label(at.getDescription()));
        gridLayout.setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    }
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();/*from   ww  w. j  a  v a  2  s .c o  m*/
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();/*from www  . j  a v  a2s . co m*/
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-cube.jpg"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:org.accelerators.activiti.admin.ui.LoginView.java

License:Open Source License

@SuppressWarnings("serial")
public LoginView(AdminApp application) {

    // Set application reference
    this.app = application;

    // Init window caption
    app.getMainWindow().setCaption(app.getMessage(Messages.Title));

    // Set layout to full size
    setSizeFull();// w w w .  ja v  a 2 s  .  c o  m

    // Set style
    this.setStyleName("login-background");

    // Add header bar
    final HorizontalLayout header = new HorizontalLayout();
    header.setHeight("50px");
    header.setWidth("100%");
    addComponent(header);
    setComponentAlignment(header, Alignment.MIDDLE_CENTER);

    // Setup grid
    GridLayout loginGrid = new GridLayout(1, 2);
    loginGrid.setWidth("250px");
    addComponent(loginGrid);
    setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    loginGrid.addComponent(logoGrid, 0, 0);
    loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("login-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add field and button layout
    VerticalLayout buttonLayout = new VerticalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(false);
    buttonLayout.setStyleName("login-form");
    loginGrid.addComponent(buttonLayout, 0, 1);
    loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    // Add username field
    username = new TextField(app.getMessage(Messages.Username));
    username.setWidth("100%");
    buttonLayout.addComponent(username);

    // Add password field
    password = new PasswordField(app.getMessage(Messages.Password));
    password.setWidth("100%");
    buttonLayout.addComponent(password);

    // Add Login button
    buttonLayout.addComponent(login);
    buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT);

    // Set focus to this component
    username.focus();

    // Add shortcut to login button
    login.setClickShortcut(KeyCode.ENTER);

    login.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {

                // Athenticate the user
                authenticate((String) username.getValue(), (String) password.getValue());

                // Switch to the main view
                app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app));

            } catch (Exception e) {
                getWindow().showNotification(e.toString());
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    footer.setWidth("100%");
    addComponent(footer);

}

From source file:org.accelerators.activiti.admin.ui.MainView.java

License:Open Source License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);/*from  w  ww.  j a  v a 2 s . c  om*/
    setSpacing(false);
    setSizeFull();

    // Add header
    GridLayout header = new GridLayout(2, 1);
    header.setWidth("100%");
    header.setHeight("34px");
    addComponent(header);

    // Add header styles
    header.addStyleName(Consts.HEADER);
    header.addStyleName("header");
    header.setSpacing(true);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    header.addComponent(logoGrid, 0, 0);
    header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("header-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add logout button to header
    GridLayout logoutGrid = new GridLayout(2, 1);
    Label userLabel = new Label("Signed in as: " + app.getUser().toString());
    userLabel.addStyleName("user");
    logout.setStyleName(Reindeer.BUTTON_LINK);
    logout.addStyleName("logout");
    logoutGrid.addComponent(userLabel, 0, 0);
    logoutGrid.addComponent(logout, 1, 0);
    header.addComponent(logoutGrid, 1, 0);
    header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT);

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

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

License:Apache License

/**
 * Switch view/*from  w w  w  .  j a va2 s.c o m*/
 * 
 * @param name
 *          the name of the view class
 * @param view
 *          the view to switch to
 */
public void switchView(String name, Layout view) {

    // Add view to main layout
    mainLayout.addComponent(view, Consts.CONTENT);

    // Add logout button if user is authenticated
    if ((getUser() != null) && !getUser().toString().isEmpty()) {

        // Create logout grid with user icon, user id and logout button
        GridLayout logoutGrid = new GridLayout(3, 1);
        logoutGrid.setStyleName("logout");

        // Add user icon
        Embedded userIcon = new Embedded(null, new ThemeResource("img/user-icon.png"));
        userIcon.setType(Embedded.TYPE_IMAGE);
        userIcon.addStyleName("icon");

        // Add user id
        Label userLabel = new Label(getUser().toString());
        userLabel.addStyleName("user");

        // Add logout button
        logout.setStyleName(Reindeer.BUTTON_LINK);
        logout.addStyleName("logout");
        logout.setIcon(new ThemeResource("img/divider-white.png"));

        // Add to logout grid
        logoutGrid.addComponent(userIcon, 0, 0);
        logoutGrid.addComponent(userLabel, 1, 0);
        logoutGrid.addComponent(logout, 2, 0);

        // Add logout grid to header
        mainLayout.addComponent(logoutGrid, Consts.LOGOUT);

    } else {

        // Remove logout button
        mainLayout.removeComponent(Consts.LOGOUT);

    }

    // Switch to new view
    viewManager.switchScreen(name, mainLayout);

}

From source file:org.activiti.explorer.ui.custom.UserProfileLink.java

License:Apache License

protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) {
    if (renderPicture) {
        Picture picture = identityService.getUserPicture(userName);
        if (picture != null) {
            Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()),
                    userName + picture.getMimeType(), ExplorerApp.get());

            Embedded image = new Embedded(null, imageResource);
            image.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
            image.setType(Embedded.TYPE_IMAGE);
            image.setHeight(30, Embedded.UNITS_PIXELS);
            image.setWidth(30, Embedded.UNITS_PIXELS);
            image.addListener(new MouseEvents.ClickListener() {
                private static final long serialVersionUID = 7341560240277898495L;

                public void click(MouseEvents.ClickEvent event) {
                    viewManager.showProfilePopup(userName);
                }/*from   ww  w .  ja v a2 s.  co m*/
            });

            addComponent(image);
            setComponentAlignment(image, Alignment.MIDDLE_LEFT);
        } else {
            // TODO: what when no image is available?
        }
    }
}

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected void initPicture() {
    StreamResource imageresource = new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 1L;

        public InputStream getStream() {
            return picture.getInputStream();
        }/*  w w  w .  j a v a2 s.co  m*/
    }, user.getId(), ExplorerApp.get());
    imageresource.setCacheTime(0);

    Embedded picture = new Embedded(null, imageresource);
    picture.setType(Embedded.TYPE_IMAGE);
    picture.setHeight(200, UNITS_PIXELS);
    picture.setWidth(200, UNITS_PIXELS);
    picture.addStyleName(ExplorerLayout.STYLE_PROFILE_PICTURE);

    imageLayout.addComponent(picture);
    imageLayout.setWidth(picture.getWidth() + 5, picture.getWidthUnits());

    // Change picture button
    if (isCurrentLoggedInUser) {
        Upload changePictureButton = initChangePictureButton();
        imageLayout.addComponent(changePictureButton);
        imageLayout.setComponentAlignment(changePictureButton, Alignment.MIDDLE_CENTER);
    }
}