List of usage examples for com.vaadin.ui Label setWidth
@Override public void setWidth(float width, Unit unit)
From source file:annis.visualizers.component.RawTextVisualizer.java
License:Apache License
@Override public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) { // get config for alignment boolean vertical = Boolean.parseBoolean(visInput.getMappings().getProperty("vertical", "true")); // get the texts RawTextWrapper texts = visInput.getRawText(); // create the main panel Panel p = new Panel(); p.setSizeFull();/*from w w w . j av a 2 s.com*/ // some layout configuration p.addStyleName(ChameleonTheme.PANEL_BORDERLESS); p.addStyleName(PANEL_CLASS); // enable webfonts p.addStyleName(Helper.CORPUS_FONT_FORCE); Layout l; // if no text available inform user and exit if (texts == null) { Label text = new Label(NO_TEXT); text.addStyleName(LABEL_CLASS); text.setSizeFull(); p.setContent(text); return p; } if (texts.hasMultipleTexts()) { // set the aligmnent if (vertical) { l = new VerticalLayout(); } else { l = new GridLayout(texts.getTexts().size(), 1); } // limit the size to the parent panel. l.setSizeFull(); // add the texts to the layout for (int i = 0; i < texts.getTexts().size(); i++) { String s = texts.getTexts().get(i); Label lblText; // check if the text is empty if (s == null || hasOnlyWhiteSpace(s)) { lblText = new Label(NO_TEXT); } else { lblText = new Label(s, ContentMode.TEXT); } lblText.setCaption("text " + (i + 1)); lblText.addStyleName(LABEL_CLASS); lblText.setWidth(98, Sizeable.Unit.PERCENTAGE); l.addComponent(lblText); } // apply the panel p.setContent(l); return p; } Label lblText; if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) { lblText = new Label(texts.getFirstText(), ContentMode.TEXT); } else { lblText = new Label(NO_TEXT); } lblText.setSizeFull(); lblText.addStyleName(LABEL_CLASS); p.setContent(lblText); return p; }
From source file:by.bigvova.MainUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { EventBus.register(this); getPage().setTitle("FoodNote"); UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU")); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override//from w w w . j av a 2 s. c om public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull(); // By adding a security item filter, only views that are accessible to the user will show up in the side bar. sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity)); sideBar.setHeader(new CssLayout() { { Label header = new Label("<span>Food</span>Note", ContentMode.HTML); header.setWidth(100, Unit.PERCENTAGE); header.setHeightUndefined(); addComponent(header); addComponent(buildUserMenu()); } }); sideBar.getHeader().setStyleName("branding"); layout.addComponent(sideBar); CssLayout viewContainer = new CssLayout(); viewContainer.setSizeFull(); layout.addComponent(viewContainer); layout.setExpandRatio(viewContainer, 1f); Navigator navigator = new Navigator(this, viewContainer); // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all. springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class); navigator.addProvider(springViewProvider); navigator.setErrorView(ErrorView.class); navigator.navigateTo(navigator.getState()); setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI. }
From source file:ch.wscr.management.ui.view.MemberView.java
/** * Header der View erstellen/*from w w w .j a v a2s .com*/ * * @return der Header */ private Component buidViewHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth(100f, Unit.PERCENTAGE); header.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); header.setSpacing(true); Label title = new Label("Mitgliederverwaltung"); title.setSizeUndefined(); title.addStyleName(ValoTheme.LABEL_H1); header.addComponent(title); Label gap = new Label(); gap.setWidth(10, Unit.PIXELS); header.addComponent(gap); header.setExpandRatio(title, 1); return header; }
From source file:com.expressui.core.view.results.Results.java
License:Open Source License
private HorizontalLayout createNavigationLine() { HorizontalLayout resultCountDisplay = new HorizontalLayout(); setDebugId(resultCountDisplay, "resultCountDisplay"); firstResultTextField = createFirstResultTextField(); firstResultTextField.addStyleName("small"); firstResultTextField.setSizeUndefined(); resultCountDisplay.addComponent(firstResultTextField); resultCountLabel = new Label("", Label.CONTENT_XHTML); resultCountLabel.setSizeUndefined(); resultCountLabel.addStyleName("small"); resultCountDisplay.addComponent(resultCountLabel); Label spaceLabel = new Label(" ", Label.CONTENT_XHTML); spaceLabel.setSizeUndefined();/*from w w w . java 2 s .c o m*/ resultCountDisplay.addComponent(spaceLabel); Button refreshButton = new Button(null, getResultsTable(), "refresh"); refreshButton.setDescription(uiMessageSource.getToolTip("results.refresh.toolTip")); refreshButton.setSizeUndefined(); refreshButton.addStyleName("borderless"); refreshButton.setIcon(new ThemeResource("../expressui/icons/16/refresh-blue.png")); resultCountDisplay.addComponent(refreshButton); HorizontalLayout navigationButtons = new HorizontalLayout(); setDebugId(navigationButtons, "navigationButtons"); navigationButtons.setMargin(false, true, false, false); navigationButtons.setSpacing(true); String perPageText = uiMessageSource.getMessage("results.pageSize"); pageSizeMenu = new Select(); pageSizeMenu.addStyleName("small"); List<Integer> pageSizeOptions = applicationProperties.getPageSizeOptions(); for (Integer pageSizeOption : pageSizeOptions) { pageSizeMenu.addItem(pageSizeOption); pageSizeMenu.setItemCaption(pageSizeOption, pageSizeOption + " " + perPageText); } pageSizeMenu.setFilteringMode(Select.FILTERINGMODE_OFF); pageSizeMenu.setNewItemsAllowed(false); pageSizeMenu.setNullSelectionAllowed(false); pageSizeMenu.setImmediate(true); pageSizeMenu.setWidth(8, UNITS_EM); navigationButtons.addComponent(pageSizeMenu); firstButton = new Button(null, getResultsTable(), "firstPage"); firstButton.setDescription(uiMessageSource.getToolTip("results.first.toolTip")); firstButton.setSizeUndefined(); firstButton.addStyleName("borderless"); firstButton.setIcon(new ThemeResource("../expressui/icons/16/first.png")); navigationButtons.addComponent(firstButton); previousButton = new Button(null, getResultsTable(), "previousPage"); previousButton.setDescription(uiMessageSource.getToolTip("results.previous.toolTip")); previousButton.setSizeUndefined(); previousButton.addStyleName("borderless"); previousButton.setIcon(new ThemeResource("../expressui/icons/16/previous.png")); navigationButtons.addComponent(previousButton); nextButton = new Button(null, getResultsTable(), "nextPage"); nextButton.setDescription(uiMessageSource.getToolTip("results.next.toolTip")); nextButton.setSizeUndefined(); nextButton.addStyleName("borderless"); nextButton.setIcon(new ThemeResource("../expressui/icons/16/next.png")); navigationButtons.addComponent(nextButton); lastButton = new Button(null, getResultsTable(), "lastPage"); lastButton.setDescription(uiMessageSource.getToolTip("results.last.toolTip")); lastButton.setSizeUndefined(); lastButton.addStyleName("borderless"); lastButton.setIcon(new ThemeResource("../expressui/icons/16/last.png")); navigationButtons.addComponent(lastButton); excelButton = new Button(null, this, "openExportForm"); excelButton.setDescription(uiMessageSource.getToolTip("results.excel.toolTip")); excelButton.setSizeUndefined(); excelButton.addStyleName("borderless"); excelButton.setIcon(new ThemeResource("../expressui/icons/16/excel.bmp")); navigationButtons.addComponent(excelButton); exportForm.setExportButtonListener(this, "exportToExcel"); HorizontalLayout navigationLine = new HorizontalLayout(); setDebugId(navigationLine, "navigationLine"); navigationLine.setSizeUndefined(); navigationLine.setMargin(true, false, true, false); navigationLine.addComponent(resultCountDisplay); navigationLine.setComponentAlignment(resultCountDisplay, Alignment.BOTTOM_LEFT); spaceLabel = new Label("", Label.CONTENT_XHTML); spaceLabel.setWidth(2, Sizeable.UNITS_EM); navigationLine.addComponent(spaceLabel); navigationLine.addComponent(navigationButtons); navigationLine.setComponentAlignment(navigationButtons, Alignment.BOTTOM_RIGHT); return navigationLine; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java
License:Apache License
protected final void createButtonLink(final GridLayout panelContent, final String linkText, final Resource icon, final ClickListener command, final String description) { final GridLayout grid = new GridLayout(2, 1); grid.setWidth(100, Unit.PERCENTAGE); grid.setHeight(100, Unit.PERCENTAGE); grid.setColumnExpandRatio(0, 1);/*ww w . j ava 2 s .c om*/ grid.setColumnExpandRatio(1, 2); final Button b = new Button(linkText); b.setStyleName("link"); b.addClickListener(command); b.setWidth(100, Unit.PERCENTAGE); b.setIcon(icon); b.setWidth(100, Unit.PERCENTAGE); grid.addComponent(b, 0, 0); grid.setComponentAlignment(b, Alignment.MIDDLE_LEFT); final Label descriptionLabel = new Label(description); descriptionLabel.setWidth(100, Unit.PERCENTAGE); grid.addComponent(descriptionLabel, 1, 0); grid.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_LEFT); panelContent.addComponent(grid); panelContent.setComponentAlignment(grid, Alignment.MIDDLE_LEFT); }
From source file:com.karus.EnglishCheckerUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VaadinServiceSession.getCurrent().setErrorHandler(this); setSizeFull();// www.j av a 2 s .c om try { DiscoveryNavigator navigator = new DiscoveryNavigator(this, getContent()); navigator.navigateTo(UI.getCurrent().getPage().getFragment()); } /** * Exception on page load */ catch (AccessDeniedException e) { Label label = new Label(e.getMessage()); label.setWidth(-1, Unit.PERCENTAGE); Link goToMain = new Link("Go to login page", new ExternalResource("/login/")); VerticalLayout layout = new VerticalLayout(); layout.addComponent(label); layout.addComponent(goToMain); layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.addComponent(layout); mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); setContent(mainLayout); Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE); } }
From source file:com.klwork.explorer.project.PublicProjectListPage.java
License:Apache License
protected void addLeft() { Label title = new Label(""); title.addStyleName(ExplorerLayout.STYLE_H3); title.setWidth(100, Unit.PERCENTAGE); //grid.addComponent(title, 0, 0); }
From source file:com.klwork.explorer.ui.mainlayout.MainLayout.java
License:Apache License
protected void initFooter() { footer = new CssLayout(); footer.setWidth(100, Unit.PERCENTAGE); footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER); addComponent(footer);/* w ww . j av a 2 s . c o m*/ Label footerLabel = new Label(); footerLabel.setContentMode(ContentMode.HTML); footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE)); footerLabel.setWidth(100, Unit.PERCENTAGE); footer.addComponent(footerLabel); }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initPeopleTitle() { Label title = new Label(i18nManager.getMessage(Messages.TASK_PEOPLE)); title.addStyleName(ExplorerLayout.STYLE_H3); title.setWidth(100, UNITS_PERCENTAGE); peopleLayout.addComponent(title);/*from w w w . j a v a 2s. c o m*/ }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initSubTaskTitle() { Label title = new Label(i18nManager.getMessage(Messages.TASK_SUBTASKS)); title.addStyleName(ExplorerLayout.STYLE_H3); title.setWidth(100, UNITS_PERCENTAGE); subTasksLayout.addComponent(title);/*w w w . ja v a 2 s .co m*/ }