Example usage for com.vaadin.ui Label setSizeUndefined

List of usage examples for com.vaadin.ui Label setSizeUndefined

Introduction

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

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:com.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private void initHeader() {
    HeaderWithFontAwesome headerText = ComponentUtils.headerH2(ProjectTypeConstants.PAGE,
            UserUIContext.getMessage(PageI18nEnum.LIST));

    headerLayout.with(headerText).alignAll(Alignment.MIDDLE_LEFT).expand(headerText);

    Label sortLbl = new Label(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_LABEL));
    sortLbl.setSizeUndefined();
    headerLayout.with(sortLbl).withAlign(sortLbl, Alignment.MIDDLE_RIGHT);

    ToggleButtonGroup sortGroup = new ToggleButtonGroup();
    headerLayout.with(sortGroup).withAlign(sortGroup, Alignment.MIDDLE_RIGHT);

    SortButton sortDateBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_DATE),
            clickEvent -> {//from   w w  w . j  a v  a 2  s.  c o m
                dateSourceAscend = !dateSourceAscend;
                if (dateSourceAscend) {
                    Collections.sort(resources, Ordering.from(dateSort));
                } else {
                    Collections.sort(resources, Ordering.from(dateSort).reverse());
                }
                displayPages(resources);
            });
    sortGroup.addButton(sortDateBtn);

    SortButton sortNameBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_NAME),
            clickEvent -> {
                nameSortAscend = !nameSortAscend;
                if (nameSortAscend) {
                    Collections.sort(resources, Ordering.from(nameSort));
                } else {
                    Collections.sort(resources, Ordering.from(nameSort).reverse());
                }
                displayPages(resources);
            });
    sortGroup.addButton(sortNameBtn);

    SortButton sortKindBtn = new SortButton(UserUIContext.getMessage(PageI18nEnum.OPT_SORT_BY_KIND),
            clickEvent -> {
                kindSortAscend = !kindSortAscend;
                if (kindSortAscend) {
                    Collections.sort(resources, Ordering.from(kindSort));
                } else {
                    Collections.sort(resources, Ordering.from(kindSort).reverse());
                }
                displayPages(resources);
            });
    sortGroup.addButton(sortKindBtn);
    sortGroup.withDefaultButton(sortDateBtn);

    MButton newGroupBtn = new MButton(UserUIContext.getMessage(PageI18nEnum.NEW_GROUP),
            clickEvent -> UI.getCurrent().addWindow(new GroupPageAddWindow())).withIcon(FontAwesome.PLUS)
                    .withStyleName(WebThemes.BUTTON_ACTION);
    newGroupBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    headerLayout.with(newGroupBtn).withAlign(newGroupBtn, Alignment.MIDDLE_RIGHT);

    MButton newPageBtn = new MButton(UserUIContext.getMessage(PageI18nEnum.NEW),
            clickEvent -> EventBusFactory.getInstance().post(new PageEvent.GotoAdd(this, null)))
                    .withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION);
    newPageBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));

    headerLayout.with(newPageBtn).withAlign(newPageBtn, Alignment.MIDDLE_RIGHT);
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.layouteditor.LayoutEditorPresenter.java

License:Open Source License

public LayoutEditorView start(JcrNodeAdapter articleItem) {
    final String title = "LAYOUT EDITOR";

    Label previewLabel = new Label(title, ContentMode.HTML);
    previewLabel.setSizeUndefined();
    previewLabel.addStyleName("navigation-label");
    previewLabel.addStyleName("ax-shape");

    eventBus.fireEvent(new PreviewChangedEvent(previewLabel, ViewType.LayoutEditor));

    try {//from w  ww.  jav  a2 s.co  m
        server = MgnlContext.getWebContext().getRequest().getRequestURL().toString();
        server = server.substring(0, server.indexOf("/.magnolia")) + "/article?contentPath=";
        view.setArticleUrl(server + articleItem.getJcrItem().getName());
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
    return view;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionPresenter.java

License:Open Source License

public ArticlePromotionView start(JcrNodeAdapter articleItem) {
    this.articleItem = articleItem;

    String title = "PROMOTE";

    Label previewLabel = new Label(title, ContentMode.HTML);
    previewLabel.setSizeUndefined();
    previewLabel.addStyleName("navigation-label");
    previewLabel.addStyleName("ax-shape");

    view.setListener(this);
    view.construct();//from  w  ww .j a v a 2 s. co  m
    eventBus.fireEvent(new PreviewChangedEvent(previewLabel, ViewType.Promote));

    return view;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createAlert() {
    VerticalLayout alertTextLayout = new VerticalLayout();
    alertTextLayout.setSpacing(true);/*from w ww  .  j a  va2 s. c o m*/
    alertTextLayout.setCaption("Alert Text");

    MagnoliaRichTextField textField = (MagnoliaRichTextField) listener.createRichTextField();
    textField.setSizeFull();

    HorizontalLayout periodLayout = new HorizontalLayout();
    periodLayout.setSpacing(true);
    // periodLayout.setWidth("100%");
    DateField startDate = new DateField();
    // startDate.setWidth("100%");
    DateField endDate = new DateField();
    // endDate.setWidth("100%");

    periodLayout.addComponent(new Label("START"));
    periodLayout.addComponent(startDate);
    periodLayout.addComponent(new Label("END"));
    periodLayout.addComponent(endDate);

    alertTextLayout.addComponent(textField);
    alertTextLayout.addComponent(periodLayout);

    HorizontalLayout alertLayout = new HorizontalLayout();
    alertLayout.setSpacing(true);
    alertLayout.setWidth("100%");
    alertLayout.addComponent(alertTextLayout);

    final Label alertPreview = new Label("", ContentMode.HTML);
    alertPreview.setCaption("Alert Preview");
    alertPreview.addStyleName("preview-label");
    textField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            alertPreview.setValue(String.valueOf(event.getProperty().getValue()));
        }
    });
    alertPreview.setSizeUndefined();
    alertLayout.addComponent(alertPreview);
    alert.setContent(alertLayout);

    textField.setValue(
            "<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</b>");
}

From source file:com.peergreen.webconsole.core.exception.ExceptionView.java

License:Open Source License

public ExceptionView(Exception ex) {

    setSizeFull();// w  w w .  j a  v  a 2  s. c om
    addStyleName("dashboard-view");

    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    addComponent(top);
    final Label title = new Label("Oops ! A problem occurred when drawing this view");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    HorizontalLayout row = new HorizontalLayout();
    row.setSizeFull();
    row.setMargin(new MarginInfo(true, true, false, true));
    row.setSpacing(true);
    addComponent(row);
    setExpandRatio(row, 1.5f);

    Table t = new Table();
    t.setCaption("Stack trace");
    t.addContainerProperty("<p style=\"display:none\">Stack</p>", String.class, null);
    t.setWidth("100%");
    t.setImmediate(true);
    t.addStyleName("plain");
    t.addStyleName("borderless");
    t.setSortEnabled(false);
    t.setImmediate(true);
    t.setSizeFull();

    int i = 1;
    t.addItem(new Object[] { ex.toString() }, i++);
    for (StackTraceElement element : ex.getStackTrace()) {
        t.addItem(new Object[] { element.toString() }, i++);
    }
    CssLayout panel = new CssLayout();
    panel.addStyleName("layout-panel");
    panel.setSizeFull();

    panel.addComponent(t);

    row.addComponent(panel);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Init UI//from www  .  j  a va  2 s  . co m
 *
 * @param request vaadin request
 */
@Override
protected void init(VaadinRequest request) {
    setLocale(Locale.US);
    getPage().setTitle("Welcome to " + consoleName);
    setContent(root);
    root.addStyleName("root");
    root.setSizeFull();

    Label bg = new Label();
    bg.setSizeUndefined();
    bg.addStyleName("login-bg");
    root.addComponent(bg);

    Boolean isLogged = (Boolean) getSession().getAttribute("is.logged");
    if (!enableSecurity || (isLogged != null && isLogged)) {
        securityManager = (ISecurityManager) getSession().getAttribute("security.manager");
        if (securityManager == null) {
            Subject defaultSubject = new Subject();
            defaultSubject.getPrincipals().add(new UserPrincipal(ANONYMOUS_USER));
            RoleGroup group = new RoleGroup();
            if (defaultRoles != null) {
                for (String role : defaultRoles) {
                    group.addMember(new RolePrincipal(role));
                }
            }
            defaultSubject.getPrincipals().add(group);
            defaultSubject.setReadOnly();
            securityManager = new SecurityManager(defaultSubject);
            getSession().setAttribute("security.manager", securityManager);
            getSession().getService().addSessionDestroyListener(new SessionDestroyListener() {
                @Override
                public void sessionDestroy(SessionDestroyEvent sessionDestroyEvent) {
                    sessionDestroyEvent.getSession().getSession().removeAttribute("security.manager");
                }
            });
        }
        buildMainView();
    } else {
        //            Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
        //            if (userCookie != null) {
        //                String token = userCookie.getValue();
        //                // get user by token and show main view
        //            }
        buildLoginView(false);
    }
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view// www. j  ava 2s.  c o m
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java

License:Open Source License

@PostConstruct
public void init() {
    deploymentViewManager = createDeploymentViewManager();

    OptionGroup option = new OptionGroup();
    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setWidth("100%");
    toolBar.setSpacing(true);//from  w ww  .jav  a  2  s .com
    toolBar.setMargin(true);

    VerticalLayout uploadLayout = new VerticalLayout();

    Upload uploader = new Upload("Upload a file here", null);
    uploader.setButtonCaption("Upload");
    final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder,
            option);
    uploader.setReceiver(fileUploader);
    uploader.addSucceededListener(fileUploader);
    uploader.addStartedListener(fileUploader);
    uploadLayout.addComponent(uploader);

    HorizontalLayout target = new HorizontalLayout();
    option.addContainerProperty("id", String.class, null);
    option.setItemCaptionPropertyId("id");
    option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id")
            .setValue("Add to deployables");
    option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy");
    option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id")
            .setValue("Create a deployment plan");
    option.addStyleName("horizontal");
    option.select(DeployableContainerType.DEPLOYABLE.attribute());

    target.addComponent(option);
    uploadLayout.addComponent(target);
    toolBar.addComponent(uploadLayout);

    Label infoLabel = new Label("Drop files here to create a deployment plan");
    infoLabel.setSizeUndefined();
    final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel);
    deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER);
    Button draft = new Button("A draft is under construction");
    draft.addStyleName("link");
    draft.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            deploymentViewManager.showDeploymentPlanView();
        }
    });
    draft.setVisible(false);
    deploymentViewManager.setDeploymentPlanDraftViewer(draft);
    deploymentPlanMaker.addComponent(draft);
    deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER);
    deploymentPlanMaker.setSizeFull();
    deploymentPlanMaker.addStyleName("drop-area");
    deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker);
    deploymentPlanMakerWrapper.setSizeFull();
    toolBar.addComponent(deploymentPlanMakerWrapper);
    addComponent(toolBar);

    addComponent(framesContainer);
    setExpandRatio(framesContainer, 1.5f);

    helpWindow = notifierService.createHelpOverlay("Deployment module",
            "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel "
                    + "to deployed panel and vice versa.</p>"
                    + "<p>You can also drag files from desktop and drop them where you want to add them.");
}

From source file:com.peergreen.webconsole.scope.home.extensions.PeergreenNewsFeedFrame.java

License:Open Source License

/**
 * News popup/*from   w w w  .j  a v  a 2 s.c om*/
 *
 * @param feedMessage
 * @return
 */
private Window getNewsDescription(FeedMessage feedMessage) {
    FormLayout fields = new FormLayout();
    fields.setWidth("35em");
    fields.setSpacing(true);
    fields.setMargin(true);

    Label label = new Label("<a href=\"" + feedMessage.getLink() + "\">"
            + feedMessage.getLink().substring(0, 50) + "..." + "</a>");
    label.setContentMode(ContentMode.HTML);
    label.setSizeUndefined();
    label.setCaption("URL");
    fields.addComponent(label);

    String description = feedMessage.getDescription();
    if (description.length() > 1000) {
        description = description.substring(0, 999) + "...";
    }

    Label desc = new Label(description);
    desc.setContentMode(ContentMode.HTML);
    desc.setCaption("Description");
    fields.addComponent(desc);

    Button ok = new Button("Close");
    ok.addStyleName("wide");
    ok.addStyleName("default");

    final Window w = new DefaultWindow(feedMessage.getTitle(), fields, ok);
    w.center();
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            w.close();
        }
    });
    return w;
}

From source file:com.peergreen.webconsole.scope.system.internal.service.ServiceViewer.java

License:Open Source License

private void initHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setSpacing(true);/*from  w  ww  .  j  a v  a2 s.  c o m*/
    header.setMargin(true);

    Label title = new Label("OSGi Services");
    title.addStyleName("h1");
    title.setSizeUndefined();
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    final TextField filter = new TextField();
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            data.removeAllContainerFilters();
            String trimmed = event.getText().trim();
            Container.Filter or = new Or(new SimpleStringFilter(SERVICE_ID_COLUMN, trimmed, true, false),
                    new InterfacesFilter(trimmed), new BundleFilter(trimmed),
                    new ServicePropertiesFilter(trimmed));

            data.addContainerFilter(or);
        }
    });

    filter.setInputPrompt("Filter");
    filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            filter.setValue("");
            data.removeAllContainerFilters();
        }
    });
    header.addComponent(filter);
    header.setExpandRatio(filter, 1);
    header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);

    // Store the header in the vertical layout (this)
    addComponent(header);
}