List of usage examples for com.vaadin.ui Label setContentMode
public void setContentMode(ContentMode contentMode)
From source file:eu.maxschuster.vaadin.buttonlink.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { final VerticalLayout wrapper = new VerticalLayout(); wrapper.setSizeFull();// www . ja va2 s .c o m setContent(wrapper); // Show it in the middle of the screen final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeUndefined(); wrapper.addComponent(layout); wrapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); final Label themeName = new Label(); themeName.setCaption("Current Theme:"); themeName.addStyleName("h1"); layout.addComponent(themeName); Label waring = new Label("<strong>Attention:</strong><br />\nChanging the theme may take a few seconds!"); waring.setContentMode(ContentMode.HTML); layout.addComponent(waring); getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { String fragment = event.getUriFragment().replace("!", ""); if (fragment.isEmpty()) { fragment = defaultTheme; } loadTheme(fragment); } }); themeSelect.setSizeFull(); themeSelect.setNullSelectionAllowed(false); themeSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String fragment = "!" + themeSelect.getValue(); getPage().setUriFragment(fragment); } }); layout.addComponent(themeSelect); layout.setComponentAlignment(themeSelect, Alignment.BOTTOM_CENTER); final CheckBox useIcon = new CheckBox("Use icons"); useIcon.setValue(false); layout.addComponent(useIcon); final HorizontalLayout comparsionLayout = new HorizontalLayout(); comparsionLayout.setSpacing(true); layout.addComponent(comparsionLayout); layout.setComponentAlignment(comparsionLayout, Alignment.TOP_CENTER); final Button button = new Button("This is a \"normal\" Button", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Notification.show("Hello World!"); } }); comparsionLayout.addComponent(button); comparsionLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); // Initialize our new UI component final ButtonLink buttonLink = new ButtonLink("This is a ButtonLink", new ExternalResource("https://vaadin.com")); buttonLink.setTargetName("_blank"); buttonLink.setDescription("Visit vaadin.com in a new tab or window."); buttonLink.addStyleName("test-stylename"); comparsionLayout.addComponent(buttonLink); comparsionLayout.setComponentAlignment(buttonLink, Alignment.MIDDLE_LEFT); themeName.setPropertyDataSource(themeSelect); useIcon.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean b = (Boolean) event.getProperty().getValue(); if (b) { button.setIcon(vaadinIcon, "Vaadin Logo"); buttonLink.setIcon(vaadinIcon, "Vaadin Logo"); } else { button.setIcon(null); buttonLink.setIcon(null); } } }); String fragment = getPage().getUriFragment(); loadTheme( fragment == null || fragment.replace("!", "").isEmpty() ? defaultTheme : fragment.replace("!", "")); }
From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragCaptionDemo.java
License:Apache License
@Override public Component getLayout() { // start-source HorizontalLayout layout = new HorizontalLayout(); layout.setSizeFull();// w w w . j a va 2s. c o m layout.setMargin(true); layout.setSpacing(true); DDPanel panel1 = new DDPanel("Source"); panel1.setWidth("200px"); panel1.setHeight("200px"); panel1.setDragMode(LayoutDragMode.CLONE); panel1.setDropHandler(new DefaultPanelDropHandler()); panel1.setDragCaptionProvider(component -> new DragCaption( "<u>Custom drag caption:</u><br/>" + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE, ContentMode.HTML)); layout.addComponent(panel1); Button content = new Button("Drag me!"); content.setSizeFull(); panel1.setContent(content); DDPanel panel2 = new DDPanel("Destination"); panel2.setWidth("200px"); panel2.setHeight("200px"); panel2.setDragMode(LayoutDragMode.CLONE); panel2.setDropHandler(new DefaultPanelDropHandler()); panel2.setDragCaptionProvider(component -> new DragCaption( "Drag caption goes back! " + component.getClass().getSimpleName(), VaadinIcons.AIRPLANE)); layout.addComponent(panel2); // end-source Label label = new Label("In this demo you can drag the button." + "\nYou will see custom drag caption(with icon) provided by DragCaptionProvider"); label.setContentMode(ContentMode.PREFORMATTED); return new VerticalLayout(label, layout); }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
private static void fillIndicatorTable(Main main, Base base, final Table table, List<IndicatorDescription> descs) { boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); Property aika = Property.find(database, Property.AIKAVALI); for (int i = 0; i < descs.size(); i++) { IndicatorDescription desc = descs.get(i); Indicator meter = desc.indicator; Label text = new Label(desc.caption); text.setContentMode(ContentMode.HTML); String year = aika.getPropertyValue(meter); if (showYears) table.addItem(new Object[] { text, year }, meter); else//from w w w .j a v a2 s. com table.addItem(new Object[] { text }, meter); } }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static Label makeHistory(Database database, Indicator indicator, boolean forecast) { Label ta2 = new Label("Historia"); ta2.setContentMode(ContentMode.HTML); ta2.setWidth("100%"); ta2.setHeight("100%"); StringBuilder sb = new StringBuilder(); sb.append("<b>Historia</b><br><br>"); for (Map.Entry<Date, TimeSeriesEntry> entry : indicator.values.list()) { TimeSeriesEntry tse = entry.getValue(); Account account = tse.getAccount(); Date date = entry.getKey(); String user = account != null ? account.getId(database) : "Jrjestelm"; sb.append("<b>"); sb.append(user);/*from w ww.j a v a2 s .c o m*/ sb.append("</b> pivitti "); sb.append(forecast ? " ennustetta" : " toteumaa"); sb.append(" <b>"); sb.append(Utils.describeDate(date)); sb.append("</b><br><hr>"); sb.append(" Uusi arvo on <b>"); sb.append(forecast ? tse.getForecast() : tse.getValue() + " " + indicator.getUnitAndComment()); sb.append("</b><br>"); String comment = tse.getComment(); if (comment != null) sb.append("<p>" + tse.getComment() + "</p>"); sb.append("<br>"); } ta2.setValue(sb.toString()); return ta2; }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static void updateIndicators(final Main main, final Base base, boolean canWrite) { final Database database = main.getDatabase(); List<IndicatorDescription> descs = new ArrayList<IndicatorDescription>(); fillIndicatorDescriptions(main, base, "", descs); boolean isMap = base instanceof Strategiakartta; if (isMap && (!descs.isEmpty() || canWrite)) { HorizontalLayout indiHeader = new HorizontalLayout(); indiHeader.setSpacing(true);/*from www . j a v a 2 s. c om*/ Label header = new Label("Indikaattorit (ennuste)"); main.propertyCells.add(Utils.excelRow(header.getValue())); header.setHeight("32px"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); indiHeader.addComponent(header); indiHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editIndicators = new Image(null, new ThemeResource("chart_line_edit.png")); editIndicators.setHeight("24px"); editIndicators.setWidth("24px"); editIndicators.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editIndicators); manageIndicators(main, main.getUIState().currentItem); } }); indiHeader.addComponent(editIndicators); indiHeader.setComponentAlignment(editIndicators, Alignment.BOTTOM_CENTER); } main.properties.addComponent(indiHeader); main.properties.setComponentAlignment(indiHeader, Alignment.MIDDLE_CENTER); VerticalLayout indicators = new VerticalLayout(); boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); Property time = Property.find(database, Property.AIKAVALI); int index = 0; for (final IndicatorDescription desc : descs) { ArrayList<String> excelRow = new ArrayList<String>(); Indicator indicator = desc.indicator; final HorizontalLayout hl = new HorizontalLayout(); hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty"); hl.setSpacing(true); Label l = new Label(desc.caption); excelRow.add(l.getValue().replace("%nbsp", "")); l.setContentMode(ContentMode.HTML); l.setWidth("450px"); l.addStyleName("propertyName"); l.setData(desc); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); String value = updateIndicatorValue(main, hl, base, indicator, canWrite); excelRow.add(value); Label unit = new Label(indicator.getUnit()); unit.setWidth("100px"); hl.addComponent(unit); hl.setComponentAlignment(unit, Alignment.MIDDLE_LEFT); excelRow.add(unit.getValue()); Label comment = new Label(indicator.getValueShortComment()); comment.setWidth("150px"); hl.addComponent(comment); hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT); excelRow.add(comment.getValue()); if (showYears) { HorizontalLayout hl2 = new HorizontalLayout(); hl2.setWidth("70px"); hl2.setHeight("100%"); hl.addComponent(hl2); hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT); String years = time.getPropertyValue(indicator); if (years == null) years = Property.AIKAVALI_KAIKKI; final Label region = new Label(years); region.setWidthUndefined(); excelRow.add(region.getValue()); hl2.addComponent(region); hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER); } final Image wiki = new Image(); wiki.setSource(new ThemeResource("table_edit.png")); wiki.setHeight("24px"); wiki.setWidth("24px"); wiki.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Wiki.openWiki(main, desc.indicator); } }); hl.addComponent(wiki); hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER); indicators.addComponent(hl); indicators.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); main.propertyCells.add(excelRow); } indicators.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 3295743025581923380L; private String extractData(Component c) { if (c instanceof AbstractComponent) { Object data = ((AbstractComponent) c).getData(); if (data instanceof IndicatorDescription) { IndicatorDescription desc = (IndicatorDescription) data; return desc.indicator.getDescription(database); } } return null; } @Override public void layoutClick(LayoutClickEvent event) { String desc = extractData(event.getClickedComponent()); if (desc == null) return; String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">"; content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">" + desc + "</div>"; content += "</div>"; Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE); n.setHtmlContentAllowed(true); n.show(Page.getCurrent()); } }); main.properties.addComponent(indicators); main.properties.setComponentAlignment(indicators, Alignment.MIDDLE_CENTER); } }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void updateMeters(final Main main, boolean canWrite) { if (main.getUIState().currentItem instanceof Strategiakartta) return;/* w ww . j av a2 s.c om*/ final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; List<MeterDescription> descs = makeMeterDescriptions(main, base, false); if (!descs.isEmpty() || canWrite) { HorizontalLayout meterHeader = new HorizontalLayout(); meterHeader.setSpacing(true); Label header = new Label("Mittarit"); main.propertyCells.add(Utils.excelRow(header.getValue())); header.setHeight("32px"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); meterHeader.addComponent(header); meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png")); editMeters.setHeight("24px"); editMeters.setWidth("24px"); editMeters.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editMeters); manageMeters(main, main.getUIState().currentItem); } }); meterHeader.addComponent(editMeters); meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER); } main.properties.addComponent(meterHeader); main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER); VerticalLayout meters = new VerticalLayout(); boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); Property time = Property.find(database, Property.AIKAVALI); int index = 0; for (final MeterDescription desc : descs) { ArrayList<String> excelRow = new ArrayList<String>(); final Meter meter = desc.meter; final HorizontalLayout hl = new HorizontalLayout(); hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty"); hl.setSpacing(true); Label l = new Label(desc.caption); excelRow.add(l.getValue().replace("%nbsp", "")); l.setContentMode(ContentMode.HTML); l.setWidth("450px"); l.addStyleName("propertyName"); l.setData(desc); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); String value = updateMeterValue(main, hl, base, meter, canWrite); excelRow.add(value); String shortComment = ""; Indicator indicator = meter.getPossibleIndicator(database); if (indicator != null) shortComment = indicator.getValueShortComment(); Label comment = new Label(shortComment); comment.setWidth("150px"); hl.addComponent(comment); hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT); excelRow.add(comment.getValue()); if (showYears) { HorizontalLayout hl2 = new HorizontalLayout(); hl2.setWidth("70px"); hl2.setHeight("100%"); hl.addComponent(hl2); hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT); String years = time.getPropertyValue(meter); if (years == null) years = Property.AIKAVALI_KAIKKI; final Label region = new Label(years); region.setWidthUndefined(); excelRow.add(region.getValue()); hl2.addComponent(region); hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER); } AbsoluteLayout image = new AbsoluteLayout(); image.setWidth("32px"); image.setHeight("32px"); image.addStyleName("meterColor" + index); String color = meter.getTrafficColor(database); Styles styles = Page.getCurrent().getStyles(); styles.add( ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }"); hl.addComponent(image); hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER); hl.setExpandRatio(image, 0.0f); meters.addComponent(hl); meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png") : new ThemeResource("zoom_out.png"); final Image show = new Image(); show.setSource(res); show.setHeight("24px"); show.setWidth("24px"); if (canWrite) { show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa"); show.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { desc.meter.setShowInMap(!desc.meter.showInMap); Updates.update(main, true); } }); } hl.addComponent(show); hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER); final Image wiki = new Image(); wiki.setSource(new ThemeResource("table_edit.png")); wiki.setHeight("24px"); wiki.setWidth("24px"); wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan"); wiki.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Wiki.openWiki(main, desc.meter); } }); hl.addComponent(wiki); hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER); if (canWrite) { final Button principalButton = new Button(); if (meter.isPrincipal) { principalButton.setCaption("Poista kokonaisarvio"); } else { principalButton.setCaption("Aseta kokonaisarvioksi"); } principalButton.setStyleName(ValoTheme.BUTTON_TINY); principalButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 8247560202892661226L; @Override public void buttonClick(ClickEvent event) { if (meter.isPrincipal) { meter.isPrincipal = false; } else { for (Meter m : base.getMeters(database)) m.isPrincipal = false; meter.isPrincipal = true; } Updates.update(main, true); } }); hl.addComponent(principalButton); hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER); } main.propertyCells.add(excelRow); } meters.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 3295743025581923380L; private String extractData(Component c) { if (c instanceof AbstractComponent) { Object data = ((AbstractComponent) c).getData(); if (data instanceof MeterDescription) { MeterDescription desc = (MeterDescription) data; return desc.meter.getDescription(database); } } return null; } @Override public void layoutClick(LayoutClickEvent event) { String desc = extractData(event.getClickedComponent()); if (desc == null) return; String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">"; content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">" + desc + "</div>"; content += "</div>"; Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE); n.setHtmlContentAllowed(true); n.show(Page.getCurrent()); } }); main.properties.addComponent(meters); main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER); } }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
private static void fillMeterTable(Main main, Base base, final Table table, List<MeterDescription> descs) { boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); Property aika = Property.find(database, Property.AIKAVALI); for (int i = 0; i < descs.size(); i++) { MeterDescription desc = descs.get(i); Meter meter = desc.meter;//from w w w. j a v a2 s . c o m Label text = new Label(desc.caption); text.setContentMode(ContentMode.HTML); String year = aika.getPropertyValue(meter); if (showYears) table.addItem(new Object[] { text, year }, meter); else table.addItem(new Object[] { text }, meter); } }
From source file:fr.univlorraine.mondossierweb.views.AdressesView.java
License:Apache License
private void formatLabel(Label label, String caption, String value) { if (StringUtils.hasText(caption)) { label.setCaption(caption);//www.j av a 2 s .c om } if (StringUtils.hasText(value)) { label.setValue("<b>" + value + "</b"); label.setContentMode(ContentMode.HTML); } label.setSizeFull(); }
From source file:fr.univlorraine.mondossierweb.views.CalendrierView.java
License:Apache License
/** * Initialise la vue//from w w w .j av a 2s . c o m */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant()) && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { /* Style */ setMargin(true); setSpacing(true); //Si on n'a pas dj essayer de rcuprer le calendrier if (!MainUI.getCurrent().getEtudiant().isCalendrierRecupere()) { etudiantController.recupererCalendrierExamens(); } /* Titre */ HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); titleLayout.addComponent(title); titleLayout.setComponentAlignment(title, Alignment.MIDDLE_LEFT); //Test si on a des diplomes ou des etapes if (MainUI.getCurrent().getEtudiant().getCalendrier() != null && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) { Button pdfButton = new Button(); pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); pdfButton.addStyleName("button-big-icon"); pdfButton.addStyleName("red-button-icon"); pdfButton.setIcon(FontAwesome.FILE_PDF_O); pdfButton.setDescription( applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale())); if (PropertyUtils.isPushEnabled()) { MyFileDownloader fd = new MyFileDownloader(calendrierController.exportPdf()); fd.extend(pdfButton); } else { FileDownloader fd = new FileDownloader(calendrierController.exportPdf()); fd.setOverrideContentType(false); fd.extend(pdfButton); } titleLayout.addComponent(pdfButton); titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT); } addComponent(titleLayout); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); /* Message d'info */ if (applicationContext.getMessage(NAME + ".message.info", null, getLocale()) != null) { Panel panelVue = new Panel(); HorizontalLayout vueLayout = new HorizontalLayout(); vueLayout.setMargin(true); vueLayout.setSpacing(true); vueLayout.setSizeFull(); Label vueLabel = new Label( applicationContext.getMessage(NAME + ".message.info", null, getLocale())); vueLabel.setContentMode(ContentMode.HTML); vueLabel.setStyleName(ValoTheme.LABEL_SMALL); vueLayout.addComponent(vueLabel); vueLayout.setExpandRatio(vueLabel, 1); panelVue.setContent(vueLayout); globalLayout.addComponent(panelVue); } /* Le Calendrier */ Panel panelCalendrier = new Panel( applicationContext.getMessage(NAME + ".calendrier.title", null, getLocale())); panelCalendrier.setSizeFull(); if (MainUI.getCurrent().getEtudiant() != null && MainUI.getCurrent().getEtudiant().getCalendrier() != null && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) { BeanItemContainer<Examen> bic = new BeanItemContainer<>(Examen.class, MainUI.getCurrent().getEtudiant().getCalendrier()); Table calendrierTable = new Table(null, bic); calendrierTable.setWidth("100%"); String[] colonnes_to_create = CAL_FIELDS; if (configController.isAffNumPlaceExamen()) { colonnes_to_create = CAL_FIELDS_AVEC_PLACE; } for (String fieldName : colonnes_to_create) { calendrierTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale())); } calendrierTable.addGeneratedColumn("batiment", new BatimentColumnGenerator()); calendrierTable.addGeneratedColumn("salle", new SalleColumnGenerator()); calendrierTable.setColumnHeader("batiment", applicationContext.getMessage(NAME + ".table.batiment", null, getLocale())); calendrierTable.setColumnHeader("salle", applicationContext.getMessage(NAME + ".table.salle", null, getLocale())); String[] colonnes_to_display = CAL_FIELDS_ORDER; if (configController.isAffNumPlaceExamen()) { colonnes_to_display = CAL_FIELDS_ORDER_AVEC_PLACE; } calendrierTable.setVisibleColumns((Object[]) colonnes_to_display); calendrierTable.setColumnCollapsingAllowed(true); calendrierTable.setColumnReorderingAllowed(true); calendrierTable.setSelectable(false); calendrierTable.setImmediate(true); calendrierTable.setStyleName("noscrollabletable"); calendrierTable.setPageLength(calendrierTable.getItemIds().size()); panelCalendrier.setContent(calendrierTable); } else { HorizontalLayout labelExamenLayout = new HorizontalLayout(); labelExamenLayout.setMargin(true); labelExamenLayout.setSizeFull(); Label aucunExamen = new Label( applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale())); aucunExamen.setStyleName(ValoTheme.LABEL_COLORED); aucunExamen.addStyleName(ValoTheme.LABEL_BOLD); labelExamenLayout.addComponent(aucunExamen); panelCalendrier.setContent(labelExamenLayout); } globalLayout.addComponent(panelCalendrier); addComponent(globalLayout); } }
From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java
License:Apache License
/** * Initialise la vue/*from w w w . j a va2s .c o m*/ */ @PostConstruct public void init() { LOG.debug(userController.getCurrentUserName() + " EtatCivilView"); //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant())) { if (MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { LOG.debug(userController.getCurrentUserName() + " init EtatCivilView"); /* Style */ setMargin(true); setSpacing(true); /* Titre */ Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); addComponent(title); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); //Layout avec les infos etatcivil et contact CssLayout idLayout = new CssLayout(); idLayout.setSizeFull(); idLayout.setStyleName("flexwrap"); globalLayout.addComponent(idLayout); // Enable Responsive CSS selectors for the layout Responsive.makeResponsive(idLayout); /* Generalites */ FormLayout formGeneralitesLayout = new FormLayout(); formGeneralitesLayout.setSpacing(true); formGeneralitesLayout.setMargin(true); Panel panelGeneralites = new Panel( applicationContext.getMessage(NAME + ".generalites.title", null, getLocale())); String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null, getLocale()); Label fieldNumDossier = new Label(); formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu()); formGeneralitesLayout.addComponent(fieldNumDossier); String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale()); Label fieldNNE = new Label(); formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne()); formGeneralitesLayout.addComponent(fieldNNE); String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale()); Label fieldNom = new Label(); formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom()); formGeneralitesLayout.addComponent(fieldNom); String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale()); Label mailLabel = new Label(); mailLabel.setCaption(captionMail); String mail = MainUI.getCurrent().getEtudiant().getEmail(); if (StringUtils.hasText(mail)) { mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>"; mailLabel.setValue(mail); mailLabel.setContentMode(ContentMode.HTML); } mailLabel.setSizeFull(); formGeneralitesLayout.addComponent(mailLabel); String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null, getLocale()); Label fieldNationalite = new Label(); formatLabel(fieldNationalite, captionNationalite, MainUI.getCurrent().getEtudiant().getNationalite()); formGeneralitesLayout.addComponent(fieldNationalite); String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null, getLocale()); Label fieldDateNaissance = new Label(); formatLabel(fieldDateNaissance, captionDateNaissance, MainUI.getCurrent().getEtudiant().getDatenaissance()); formGeneralitesLayout.addComponent(fieldDateNaissance); String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null, getLocale()); Label fieldLieuNaissance = new Label(); formatLabel(fieldLieuNaissance, captionLieuNaissance, MainUI.getCurrent().getEtudiant().getLieunaissance()); formGeneralitesLayout.addComponent(fieldLieuNaissance); String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null, getLocale()); Label fieldDepNaissance = new Label(); formatLabel(fieldDepNaissance, captionDepNaissance, MainUI.getCurrent().getEtudiant().getDepartementnaissance()); formGeneralitesLayout.addComponent(fieldDepNaissance); panelGeneralites.setContent(formGeneralitesLayout); HorizontalLayout generalitesGlobalLayout = new HorizontalLayout(); generalitesGlobalLayout.setSizeUndefined(); generalitesGlobalLayout.setStyleName("firstitembox"); generalitesGlobalLayout.addComponent(panelGeneralites); generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1); idLayout.addComponent(generalitesGlobalLayout); /* Bac */ Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale())); //Si plusieurs bac if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) { panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale())); TabSheet bacTabSheet = new TabSheet(); VerticalLayout vBacLayout = new VerticalLayout(); vBacLayout.setSizeFull(); bacTabSheet.setSizeFull(); bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED); for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) { FormLayout tabBacLayout = new FormLayout(); tabBacLayout.setSizeFull(); tabBacLayout.setMargin(false); ajouterBacToView(tabBacLayout, bec); bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP); } vBacLayout.addComponent(bacTabSheet); panelBac.setContent(vBacLayout); } else { //Si un seul bac FormLayout formBacLayout = new FormLayout(); formBacLayout.setSizeFull(); if (MainUI.getCurrent().getEtudiant().getListeBac() != null && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) { formBacLayout.setSpacing(true); formBacLayout.setMargin(true); ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0)); } panelBac.setContent(formBacLayout); } HorizontalLayout bacGlobalLayout = new HorizontalLayout(); bacGlobalLayout.setSizeUndefined(); bacGlobalLayout.setStyleName("itembox"); bacGlobalLayout.addComponent(panelBac); bacGlobalLayout.setExpandRatio(panelBac, 1); idLayout.addComponent(bacGlobalLayout); /* Info de contact */ panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale())); renseignerPanelContact(); globalLayout.addComponent(panelContact); addComponent(globalLayout); } else { /* Erreur */ addComponent(new BasicErreurMessageLayout(applicationContext)); } } }