List of usage examples for com.vaadin.ui Label setContentMode
public void setContentMode(ContentMode contentMode)
From source file:org.lunifera.christmastree.control.DesktopControlComponent.java
License:Creative Commons License
protected AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false);/*from ww w . j a va 2s .c o m*/ mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); // top-level component properties setWidth("100.0%"); setHeight("100.0%"); // title area ThemeResource resource = new ThemeResource("images/Title.png"); Image title = new Image(" ", resource); title.setHeight("108px"); title.setWidth("827px"); mainLayout.addComponent(title, "top:22.0px;left:120.0px"); VerticalLayout vl = new VerticalLayout(); vl.setHeight("500px"); vl.setWidth("400px"); vl.setSpacing(true); mainLayout.addComponent(vl, "top:140.0px;left:100.0px;"); contentLayout = buildContent(); vl.addComponent(contentLayout); vl.setExpandRatio(contentLayout, 1.0f); // licenses PopupView licenseLink = new PopupView("Attributions", new Label("<div><i>Monitor/tablet/smartphone</i> and <i>tree</i> icons </br> made by " + "<a href=\"http://www.freepik.com\" title=\"Freepik\">Freepik</a> " + "from <a href=\"http://www.flaticon.com\" title=\"Flaticon\">www.flaticon.com</a> </br>" + "is licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" " + "title=\"Creative Commons BY 3.0\">CC BY 3.0</a></div>", ContentMode.HTML)); licenseLink.setPrimaryStyleName("attributions"); vl.addComponent(licenseLink); Label image = new Label(); image.setHeight("400px"); image.setWidth("100%"); // image.setValue("<div style=\"overflow:hidden; width: 400px; // margin-left: -60px;\">" // + "<img src=\"http://77.119.240.22:8081\"/>" + "</div>"); image.setValue("<div style=\"overflow:hidden; width: 370px; margin-left: -60px;\">" + "<img src=\"http://192.168.0.108:8081\"/>" + "</div>"); image.setContentMode(ContentMode.HTML); mainLayout.addComponent(image, "top:140.0px;left:600.0px;"); return mainLayout; }
From source file:org.lunifera.christmastree.control.MobileControlComponent.java
License:Creative Commons License
protected AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false);/* ww w. j a v a2 s.c o m*/ mainLayout.setWidth("1280px"); mainLayout.setHeight("720px"); // top-level component properties setWidth("100.0%"); setHeight("100.0%"); // title area ThemeResource resource = new ThemeResource("images/Title.png"); Image title = new Image(" ", resource); title.setHeight("54px"); title.setWidth("413px"); mainLayout.addComponent(title, "top:11.0px;left:60.0px"); Label image = new Label(); image.setHeight("340px"); image.setWidth("600px"); image.setValue("<div style=\"overflow:hidden; width: 320px; height: 600px; margin-left: -60px;\">" + "<img src=\"http://192.168.0.108:8081\"/>" + "</div>"); image.setContentMode(ContentMode.HTML); mainLayout.addComponent(image, "top:70.0px;left:125px;"); // Image image = new Image(); // image.setHeight("240px"); // image.setWidth("320px"); // image.setSource(new // ExternalResource("http://192.168.0.108:8081/stream", // "video/x-motion-jpeg")); // mainLayout.addComponent(image, "top:70.0px;left:50.0px;"); VerticalLayout vl = new VerticalLayout(); // vl.setHeight("250px"); vl.setWidth("200px"); vl.setSpacing(true); mainLayout.addComponent(vl, "top:180.0px;left:535.0px;"); contentLayout = buildContent(); vl.addComponent(contentLayout); vl.setExpandRatio(contentLayout, 1.0f); // licenses PopupView licenseLink = new PopupView("Attributions", new Label("<div><i>Monitor/tablet/smartphone</i> and <i>tree</i> icons </br> made by " + "<a href=\"http://www.freepik.com\" title=\"Freepik\">Freepik</a> " + "from <a href=\"http://www.flaticon.com\" title=\"Flaticon\">www.flaticon.com</a> </br>" + "is licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" " + "title=\"Creative Commons BY 3.0\">CC BY 3.0</a></div>", ContentMode.HTML)); licenseLink.setPrimaryStyleName("attributions"); vl.addComponent(licenseLink); return mainLayout; }
From source file:org.lunifera.example.vaadin.osgi.bootstrap.ds.SimpleDSUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { HorizontalLayout layout = new HorizontalLayout(); setContent(layout);/*from ww w . ja v a 2 s. c o m*/ layout.setStyleName(Reindeer.LAYOUT_BLUE); layout.setSizeFull(); Label label = new Label(); label.setValue("<h1>Vaadin wired to Servlet by OSGi-DS component</h1>"); label.setContentMode(ContentMode.HTML); layout.addComponent(label); layout.setComponentAlignment(label, Alignment.TOP_CENTER); }
From source file:org.lunifera.example.vaadin.osgi.bootstrap.simple.SimpleUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { HorizontalLayout layout = new HorizontalLayout(); setContent(layout);//from www . j av a 2s . c o m layout.setStyleName(Reindeer.LAYOUT_BLUE); layout.setSizeFull(); Label label = new Label(); label.setValue("<h1>Simple OSGi integration</h1>"); label.setContentMode(ContentMode.HTML); layout.addComponent(label); layout.setComponentAlignment(label, Alignment.TOP_CENTER); }
From source file:org.opencms.ui.apps.projects.CmsProjectHistoryTable.java
License:Open Source License
/** * Loads the projects table.<p>/* w ww . j a va2 s .c o m*/ */ public void loadProjects() { CmsObject cms = A_CmsUI.getCmsObject(); Locale locale = UI.getCurrent().getLocale(); m_container.removeAllItems(); boolean isMultiOU = false; // hide ou column if only one ou exists try { isMultiOU = !OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true).isEmpty(); } catch (CmsException e) { // noop } if (isMultiOU) { setVisibleColumns(CmsProjectsTable.PROP_NAME, CmsProjectsTable.PROP_DESCRIPTION, PROP_PUBLISH_DATE, PROP_PUBLISH_USER, CmsProjectsTable.PROP_ORG_UNIT, CmsProjectsTable.PROP_OWNER, CmsProjectsTable.PROP_MANAGER, CmsProjectsTable.PROP_USER, CmsProjectsTable.PROP_DATE_CREATED, CmsProjectsTable.PROP_RESOURCES); } else { setVisibleColumns(CmsProjectsTable.PROP_NAME, CmsProjectsTable.PROP_DESCRIPTION, PROP_PUBLISH_DATE, PROP_PUBLISH_USER, CmsProjectsTable.PROP_OWNER, CmsProjectsTable.PROP_MANAGER, CmsProjectsTable.PROP_USER, CmsProjectsTable.PROP_DATE_CREATED, CmsProjectsTable.PROP_RESOURCES); } // get content try { List<CmsHistoryProject> projects = cms.getAllHistoricalProjects(); for (CmsHistoryProject project : projects) { Item item = m_container.addItem(new Integer(project.getPublishTag())); if (item != null) { item.getItemProperty(CmsProjectsTable.PROP_ID).setValue(project.getUuid()); item.getItemProperty(CmsProjectsTable.PROP_NAME).setValue(project.getSimpleName()); item.getItemProperty(CmsProjectsTable.PROP_DESCRIPTION).setValue(project.getDescription()); item.getItemProperty(PROP_PUBLISH_DATE).setValue(new Date(project.getPublishingDate())); item.getItemProperty(PROP_PUBLISH_USER).setValue(project.getPublishedByName(cms)); try { item.getItemProperty(CmsProjectsTable.PROP_ORG_UNIT).setValue(OpenCms.getOrgUnitManager() .readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName(locale)); item.getItemProperty(CmsProjectsTable.PROP_OWNER) .setValue(cms.readUser(project.getOwnerId()).getName()); item.getItemProperty(CmsProjectsTable.PROP_MANAGER) .setValue(cms.readGroup(project.getManagerGroupId()).getSimpleName()); item.getItemProperty(CmsProjectsTable.PROP_USER) .setValue(cms.readGroup(project.getGroupId()).getSimpleName()); } catch (CmsException e) { // TODO Auto-generated catch block e.printStackTrace(); } item.getItemProperty(CmsProjectsTable.PROP_DATE_CREATED) .setValue(new Date(project.getDateCreated())); StringBuffer html = new StringBuffer(512); for (String resource : cms.readProjectResources(project)) { html.append(resource); html.append("<br />"); } Label resLabel = new Label(); resLabel.setContentMode(ContentMode.HTML); resLabel.setValue(html.toString()); item.getItemProperty(CmsProjectsTable.PROP_RESOURCES).setValue(resLabel); } } m_container.sort(new Object[] { PROP_PUBLISH_DATE }, new boolean[] { false }); } catch (CmsException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.opencms.ui.apps.projects.CmsProjectsTable.java
License:Open Source License
/** * Loads the projects table.<p>//from w w w . j av a 2s . co m */ public void loadProjects() { CmsObject cms = A_CmsUI.getCmsObject(); Locale locale = UI.getCurrent().getLocale(); m_container.removeAllItems(); boolean isMultiOU = false; // hide ou column if only one ou exists try { isMultiOU = !OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true).isEmpty(); } catch (CmsException e) { // noop } if (isMultiOU) { setVisibleColumns(PROP_NAME, PROP_DESCRIPTION, PROP_ORG_UNIT, PROP_OWNER, PROP_MANAGER, PROP_USER, PROP_DATE_CREATED, PROP_RESOURCES); } else { setVisibleColumns(PROP_NAME, PROP_DESCRIPTION, PROP_OWNER, PROP_MANAGER, PROP_USER, PROP_DATE_CREATED, PROP_RESOURCES); } // get content try { List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(cms, "", true); for (CmsProject project : projects) { Item item = m_container.addItem(project.getUuid()); item.getItemProperty(PROP_ID).setValue(project.getUuid()); item.getItemProperty(PROP_NAME).setValue(project.getSimpleName()); item.getItemProperty(PROP_DESCRIPTION).setValue(project.getDescription()); try { item.getItemProperty(PROP_ORG_UNIT).setValue(OpenCms.getOrgUnitManager() .readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName(locale)); item.getItemProperty(PROP_OWNER).setValue(cms.readUser(project.getOwnerId()).getName()); item.getItemProperty(PROP_MANAGER) .setValue(cms.readGroup(project.getManagerGroupId()).getSimpleName()); item.getItemProperty(PROP_USER).setValue(cms.readGroup(project.getGroupId()).getSimpleName()); } catch (CmsException e) { LOG.error("Error reading project properties for " + project.getSimpleName()); } item.getItemProperty(PROP_DATE_CREATED).setValue(new Date(project.getDateCreated())); StringBuffer html = new StringBuffer(512); try { for (String resource : cms.readProjectResources(project)) { html.append(resource); html.append("<br />"); } } catch (CmsException e) { LOG.error("Error reading project resources for " + project.getSimpleName()); } Label resLabel = new Label(); resLabel.setContentMode(ContentMode.HTML); resLabel.setValue(html.toString()); item.getItemProperty(PROP_RESOURCES).setValue(resLabel); } } catch (CmsException e) { LOG.error("Error reading manageable projects", e); CmsErrorDialog.showErrorDialog(e); } }
From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java
License:Open Source License
/** * Creates a new instance.<p>/*www. j ava 2s.com*/ * * @param checkinBean the bean to be used for the check-in operation. */ public CmsGitToolOptionsPanel(CmsGitCheckin checkinBean) { m_checkinBean = checkinBean; if (!checkinBean.hasValidConfiguration()) { setMargin(true); Label errorLabel = new Label(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_APP_UNCONFIGURED_0)); errorLabel.setContentMode(ContentMode.HTML); addComponent(errorLabel); return; } CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); configureConfigurationSelector(); updateForNewConfiguration(m_checkinBean.getCurrentConfiguration()); m_user = A_CmsUI.getCmsObject().getRequestContext().getCurrentUser(); restoreFieldsFromUserInfo(); setAdvancedVisible(false); m_toggleOptions.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { setAdvancedVisible(!m_advancedVisible); } }); m_okButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void buttonClick(ClickEvent event) { if (m_dialogTab == DialogTab.checkIn) { runAction(ActionType.checkIn); } else { runAction(ActionType.checkOut); } } }); m_cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { A_CmsUI.get().getPage().setLocation(CmsVaadinUtils.getWorkplaceLink()); } }); m_deselectAll.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { for (Map.Entry<String, CheckBox> entry : m_moduleCheckboxes.entrySet()) { CheckBox checkBox = entry.getValue(); checkBox.setValue(Boolean.FALSE); } } }); m_tabs.addStyleName(ValoTheme.TABSHEET_FRAMED); m_tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR); m_tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void selectedTabChange(SelectedTabChangeEvent event) { DialogTab tab; if (m_tabs.getSelectedTab() == m_checkoutTab) { tab = DialogTab.checkOut; } else { tab = DialogTab.checkIn; } CmsGitToolOptionsPanel.this.setTab(tab); } }); m_fetchAndReset.setValue(Boolean.TRUE); setTab(m_dialogTab); }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.LicenceDescriptorPanel.java
License:Apache License
/** * updates the metadata fields from the licence string * if unable to read the metadata then returns false * @param licenceStr/*from ww w. ja va 2s .c o m*/ * @return true if metadata read, false if not */ public boolean updateMetadata(String licenceStr) { boolean success = false; if (licenceStr != null) { LicenceMetadata licenceMetadata = null; try { licenceMetadata = Licence.getUnverifiedMetadata(licenceStr); } catch (Exception e) { // can't decode string licenceMetadata will be null } if (licenceMetadata == null) { //create empty licenceMetadata panel licenceMetadata = new LicenceMetadata(); licenceMetadata.setStartDate(null); licenceMetadata.setProductId("cannot decode licence string"); success = false; } else success = true; productIdTextField.setReadOnly(false); productIdTextField .setValue((licenceMetadata.getProductId() == null) ? "" : licenceMetadata.getProductId()); productIdTextField.setReadOnly(noUpdate); featureRepositoryTextField.setReadOnly(false); featureRepositoryTextField.setValue( (licenceMetadata.getFeatureRepository() == null) ? "" : licenceMetadata.getFeatureRepository()); featureRepositoryTextField.setReadOnly(noUpdate); Format formatter = new SimpleDateFormat("yyyy-MM-dd"); startDateTextField.setReadOnly(false); startDateTextField.setValue((licenceMetadata.getStartDate() == null) ? "" : formatter.format(licenceMetadata.getStartDate())); startDateTextField.setReadOnly(noUpdate); expiryDateTextField.setReadOnly(false); expiryDateTextField.setValue((licenceMetadata.getExpiryDate() == null) ? "" : formatter.format(licenceMetadata.getExpiryDate())); expiryDateTextField.setReadOnly(noUpdate); durationTextField.setReadOnly(false); durationTextField .setValue((licenceMetadata.getDuration() == null) ? "" : licenceMetadata.getDuration()); durationTextField.setReadOnly(noUpdate); licenseeTextField.setReadOnly(false); licenseeTextField .setValue((licenceMetadata.getLicensee() == null) ? "" : licenceMetadata.getLicensee()); licenseeTextField.setReadOnly(noUpdate); licensorTextField.setReadOnly(false); licensorTextField .setValue((licenceMetadata.getLicensor() == null) ? "" : licenceMetadata.getLicensor()); licensorTextField.setReadOnly(noUpdate); maxSizeSystemIdsTextField.setReadOnly(false); maxSizeSystemIdsTextField.setValue( (licenceMetadata.getMaxSizeSystemIds() == null) ? "" : licenceMetadata.getMaxSizeSystemIds()); maxSizeSystemIdsTextField.setReadOnly(noUpdate); // display systemIds if present systemIdsVerticalLayout.removeAllComponents(); // add error messages if system ids defined when not expected Label l1 = new Label(); l1.setContentMode(ContentMode.HTML); Integer licenceMetadataMaxSizeSystemIds = null; try { licenceMetadataMaxSizeSystemIds = Integer.parseInt(licenceMetadata.getMaxSizeSystemIds()); } catch (Exception e) { } if (licenceMetadataMaxSizeSystemIds == null || licenceMetadataMaxSizeSystemIds == 0) { // if maxSizeSystemIds=0 check if systemId's list has entries (an error) if (licenceMetadata.getSystemIds() == null || licenceMetadata.getSystemIds().isEmpty()) { l1.setValue("<div style=\"color: green;\">" + "All SystemId's Accepted" + "</div>"); } else { l1.setValue("<div style=\"color: red;\">" + "Licence Error: MaxSizeSystemIds=0 but " + licenceMetadata.getSystemIds().size() + " systemId's are defined" + "</div>"); } systemIdsVerticalLayout.addComponent(l1); } else if (licenceMetadata.getSystemIds() == null || licenceMetadata.getSystemIds().isEmpty()) { l1.setValue("<div style=\"color: green;\">" + "No SystemId's Defined" + "</div>"); systemIdsVerticalLayout.addComponent(l1); } else if (licenceMetadata.getSystemIds().size() > licenceMetadataMaxSizeSystemIds) { l1.setValue("<div style=\"color: red;\">Licence Error: more system id's defined in licence (" + licenceMetadata.getSystemIds().size() + ") than allowed in maxSizeSystemIds=" + licenceMetadata.getMaxSizeSystemIds() + "</div>"); systemIdsVerticalLayout.addComponent(l1); } // add system id strings if present if (licenceMetadata.getSystemIds() != null) { for (String systemId : licenceMetadata.getSystemIds()) { Label systemIdField = new Label(); systemIdField.setImmediate(true); systemIdField.setWidth("400px"); systemIdField.setHeight("-1px"); systemIdField.setValue(systemId); systemIdsVerticalLayout.addComponent(systemIdField); } } // display licence options if present licenceOptionsVerticalLayout.removeAllComponents(); if (licenceMetadata.getOptions() == null || licenceMetadata.getOptions().isEmpty()) { Label l = new Label("No Licence Options Defined"); licenceOptionsVerticalLayout.addComponent(l); } else { for (OptionMetadata option : licenceMetadata.getOptions()) { TextField optionField = new TextField(); optionField.setImmediate(true); optionField.setWidth("400px"); optionField.setHeight("-1px"); optionField.setCaption(option.getName()); optionField.setValue(option.getValue()); optionField.setDescription(option.getDescription()); optionField.setReadOnly(noUpdate); licenceOptionsVerticalLayout.addComponent(optionField); } } mainLayout.markAsDirty(); } return success; }
From source file:org.opennms.features.topology.plugins.topo.bsm.info.BusinessServiceVertexStatusInfoPanelItem.java
License:Open Source License
public static Label createStatusLabel(final String caption, final Status status, final String text) { final Label label = createLabel(caption, text); label.setContentMode(ContentMode.HTML); label.addStyleName("severity-" + status.toString().toLowerCase()); label.addStyleName("bright"); return label; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.AlarmDetailsDashlet.java
License:Open Source License
/** * Adds the alarms components to a {@link AbstractOrderedLayout} * * @param component the component to add alarms to * @param alarms the alarms list// w ww. ja v a 2 s.co m */ private void addComponents(AbstractOrderedLayout component, List<OnmsAlarm> alarms) { if (alarms.size() == 0) { Label label = new Label("No alarms found!"); label.addStyleName("alert-details-noalarms-font"); component.addComponent(label); } else { StringBuilder sb = new StringBuilder(); sb.append("<table class='alert-details-dashlet onms-table'>"); sb.append("<thead>"); sb.append( "<th class='alert-details-dashlet onms-header-cell'>ID</th><th class='alert-details-dashlet onms-header-cell'>Severity</th><th class='alert-details-dashlet onms-header-cell'>Node</th><th class='alert-details-dashlet onms-header-cell'>Count</th><th class='alert-details-dashlet onms-header-cell'>Last Event Time</th><th class='alert-details-dashlet onms-header-cell'>Log Msg</th>"); sb.append("</thead>"); for (OnmsAlarm onmsAlarm : alarms) { OnmsNode onmsNode = null; if (onmsAlarm.getNodeId() != null) { CriteriaBuilder nodeCb = new CriteriaBuilder(OnmsNode.class); nodeCb.eq("id", onmsAlarm.getNodeId()); List<OnmsNode> nodes = m_nodeDao.findMatching(nodeCb.toCriteria()); if (nodes.size() == 1) { onmsNode = nodes.get(0); } } sb.append("<tr class='alert-details-dashlet " + onmsAlarm.getSeverity().getLabel() + "'>"); sb.append( "<td class='alert-details-dashlet onms-cell divider bright onms' valign='middle' rowspan='1'><nobr> " + onmsAlarm.getId() + "</nobr></td>"); sb.append( "<td class='alert-details-dashlet onms-cell divider onms' valign='middle' rowspan='1'><nobr>" + onmsAlarm.getSeverity().getLabel() + "</nobr></td>"); sb.append( "<td class='alert-details-dashlet onms-cell divider onms' valign='middle' rowspan='1'><nobr>" + (onmsNode != null ? onmsNode.getLabel() : "-") + "</nobr></td>"); sb.append( "<td class='alert-details-dashlet onms-cell divider onms' valign='middle' rowspan='1'><nobr>" + onmsAlarm.getCounter() + "</nobr></td>"); sb.append( "<td class='alert-details-dashlet onms-cell divider onms' valign='middle' rowspan='1'><nobr>" + onmsAlarm.getLastEventTime().toString() + "</nobr></td>"); sb.append("<td class='alert-details-dashlet onms-cell divider onms' valign='middle' rowspan='1'>" + onmsAlarm.getLogMsg().replaceAll("\\<.*?>", "") + "</td>"); sb.append("</td></tr>"); } sb.append("</table>"); Label label = new Label(sb.toString()); label.setSizeFull(); label.setContentMode(ContentMode.HTML); component.addComponent(label); } }