List of usage examples for com.vaadin.ui Embedded setHeight
@Override public void setHeight(float height, Unit unit)
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 w ww .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(); }/*from w ww .jav a2s. c om*/ }, 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); } }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor.//from w ww.j a v a2s .c om */ public BuildingControlPanel() { site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); siteContext = site.getSiteContext(); entityManager = siteContext.getObject(EntityManager.class); layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Control Panel"); title.setIcon(getSite().getIcon("inventory")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); elementLayout = new VerticalLayout(); elementLayout.setSpacing(true); elementLayout.setMargin(false); layout.addComponent(elementLayout); layout.setExpandRatio(elementLayout, 1); roomIcon = site.getIcon("room"); deviceIcon = site.getIcon("device"); temperatureIcon = site.getIcon("temperature"); brightnessIcon = site.getIcon("brightness"); humidityIcon = site.getIcon("humidity"); eventIcon = site.getIcon("event"); setCompositionRoot(layout); // the Refresher polls automatically final Refresher refresher = new Refresher(); refresher.setRefreshInterval(200); refresher.addListener(new Refresher.RefreshListener() { @Override public void refresh(final Refresher refresher) { while (!recordsQueue.isEmpty()) { final List<Record> records = recordsQueue.remove(); if (records.size() > 0) { final Record record = records.get(0); final RecordSet recordSet = record.getRecordSet(); final Element element = recordSet.getElement(); final GridLayout recordsLayout = recordsLayouts.get(element.getElementId()); if (recordsLayout == null) { continue; } final int columnIndex = recordSet.getType().ordinal(); final int rowIndex = 0; if (recordsLayout.getComponent(columnIndex, rowIndex) != null) { continue; } final VerticalLayout recordLayout = new VerticalLayout(); recordLayout.setSpacing(true); final Resource recordIcon; switch (recordSet.getType()) { case TEMPERATURE: recordIcon = temperatureIcon; break; case BRIGHTNESS: recordIcon = brightnessIcon; break; case HUMIDITY: recordIcon = humidityIcon; break; default: recordIcon = eventIcon; break; } final Embedded embedded = new Embedded(null, recordIcon); recordLayout.addComponent(embedded); recordLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); recordLayout.addComponent(label); recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); final String recordUnit = recordSet.getUnit(); final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(), recordUnit); final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(), recordUnit, displayUnit, record.getValue()); final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue); label.setValue(displayValueString + " " + displayUnit); label.setDescription(record.getCreated().toString()); recordsLayout.addComponent(recordLayout, columnIndex, rowIndex); } } } }); addExtension(refresher); }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Invoked when view is entered.//from w w w . j a va 2 s . c o m * @param parameters the parameters */ public final synchronized void enter(final String parameters) { if (recordReaderThread != null) { recordReaderExitRequested = true; recordReaderThread.interrupt(); try { recordReaderThread.join(); } catch (final InterruptedException e) { LOGGER.debug("Record reader thread death wait interrupted."); } } elementLayout.removeAllComponents(); recordsLayouts.clear(); recordsQueue.clear(); recordReaderExitRequested = false; final Company company = siteContext.getObject(Company.class); if (company == null || parameters == null || parameters.length() == 0) { return; } final String buildingId = parameters; final List<Element> elements = ElementDao.getElements(entityManager, company); boolean started = false; for (final Element element : elements) { if (element.getElementId().equals(buildingId)) { started = true; continue; } if (!started) { continue; } if (element.getTreeDepth() == 0) { break; } final HorizontalLayout elementLayout = new HorizontalLayout(); this.elementLayout.addComponent(elementLayout); elementLayout.setSpacing(true); final Resource elementIcon; switch (element.getType()) { case ROOM: elementIcon = roomIcon; break; case DEVICE: elementIcon = deviceIcon; break; default: elementIcon = deviceIcon; break; } final Embedded embedded = new Embedded(null, elementIcon); elementLayout.addComponent(embedded); elementLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); elementLayout.addComponent(label); elementLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); label.setValue(element.toString()); final GridLayout recordLayout = new GridLayout(); recordLayout.setSpacing(true); recordLayout.setColumns(4); recordLayout.setRows(1); this.elementLayout.addComponent(recordLayout); recordsLayouts.put(element.getElementId(), recordLayout); } recordReaderThread = new Thread(new Runnable() { @Override public void run() { try { final EntityManager threadEntityManager = ((EntityManagerFactory) getSite().getSiteContext() .getObject(EntityManagerFactory.class)).createEntityManager(); for (final Element element : elements) { final List<RecordSet> recordSets = RecordSetDao.getRecordSets(threadEntityManager, element); if (recordsLayouts.containsKey(element.getElementId())) { for (final RecordSet recordSet : recordSets) { recordsQueue.put(RecordDao.getRecords(threadEntityManager, recordSet, 1)); if (recordReaderExitRequested) { break; } } } } Thread.sleep(10); } catch (InterruptedException e) { } } }); recordReaderThread.start(); }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingSelectPanel.java
License:Apache License
/** * Default constructor.// www .j a v a2s . co m */ public BuildingSelectPanel() { site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); siteContext = site.getSiteContext(); entityManager = siteContext.getObject(EntityManager.class); buildingIcon = site.getIcon("building"); layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Select Building"); //title.setIcon(getSite().getIcon("inventory")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); final HorizontalLayout titleLayout = new HorizontalLayout(); layout.addComponent(titleLayout); titleLayout.setSpacing(true); titleLayout.setSizeFull(); final Embedded embedded = new Embedded(null, buildingIcon); titleLayout.addComponent(embedded); titleLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); buildingComboBox = new ComboBox(); titleLayout.addComponent(buildingComboBox); titleLayout.setComponentAlignment(buildingComboBox, Alignment.MIDDLE_LEFT); titleLayout.setExpandRatio(buildingComboBox, 0.9f); //buildingComboBox.setWidth(100, Unit.PERCENTAGE); buildingComboBox.setNullSelectionAllowed(false); buildingComboBox.setNewItemsAllowed(false); buildingComboBox.setTextInputAllowed(false); buildingComboBox.setImmediate(true); buildingComboBox.setBuffered(false); buildingComboBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { final Element building = (Element) buildingComboBox.getValue(); if (building != null && !building.getElementId().equals(selectedBuildingId)) { UI.getCurrent().getNavigator().navigateTo("default/" + building.getElementId()); } } }); setCompositionRoot(layout); }
From source file:org.bubblecloud.ilves.component.flow.AbstractFlowlet.java
License:Apache License
@Override public final void attach() { super.attach(); this.setSizeFull(); rootLayout = new GridLayout(1, 2); rootLayout.setMargin(false);// w w w.jav a 2s . co m rootLayout.setSpacing(true); rootLayout.setSizeFull(); rootLayout.setRowExpandRatio(0, 0f); rootLayout.setRowExpandRatio(1, 1f); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey())); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); rootLayout.addComponent(titleLayout, 0, 0); setCompositionRoot(rootLayout); initialize(); }
From source file:org.bubblecloud.ilves.ui.user.AccountFlowlet.java
License:Apache License
@Override public void initialize() { final GridLayout gridLayout = new GridLayout(1, 6); gridLayout.setRowExpandRatio(0, 0.0f); gridLayout.setRowExpandRatio(1, 0.0f); gridLayout.setRowExpandRatio(2, 0.0f); gridLayout.setRowExpandRatio(3, 0.0f); gridLayout.setRowExpandRatio(4, 0.0f); gridLayout.setRowExpandRatio(5, 1.0f); gridLayout.setSizeFull();/*from ww w . j ava 2 s.c om*/ gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(4, 1f); setViewContent(gridLayout); final HorizontalLayout userAccountTitle = new HorizontalLayout(); userAccountTitle.setMargin(new MarginInfo(false, false, false, false)); userAccountTitle.setSpacing(true); final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user")); userAccountTitleIcon.setWidth(32, Unit.PIXELS); userAccountTitleIcon.setHeight(32, Unit.PIXELS); userAccountTitle.addComponent(userAccountTitleIcon); final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", ContentMode.HTML); userAccountTitle.addComponent(userAccountTitleLabel); gridLayout.addComponent(userAccountTitle, 0, 0); final Button editUserButton = new Button("Edit User Account"); editUserButton.setIcon(getSite().getIcon("button-icon-edit")); gridLayout.addComponent(editUserButton, 0, 2); editUserButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider()) .getUserFromSession(); final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class); customerView.edit(entity, false); getFlow().forward(UserAccountFlowlet.class); } }); final Company company = getSite().getSiteContext().getObject(Company.class); if (company.isOpenIdLogin()) { final VerticalLayout mainPanel = new VerticalLayout(); mainPanel.setCaption("Choose OpenID Provider:"); gridLayout.addComponent(mainPanel, 0, 1); final HorizontalLayout openIdLayout = new HorizontalLayout(); mainPanel.addComponent(openIdLayout); openIdLayout.setMargin(new MarginInfo(false, false, true, false)); openIdLayout.setSpacing(true); final String returnViewName = "openidlink"; final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap(); for (final String url : urlIconMap.keySet()) { openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName)); } } if (SiteModuleManager.isModuleInitialized(CustomerModule.class)) { final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(), 101, "=", String.class, "")); filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000, new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId"); for (final FieldDescriptor fieldDefinition : fieldDefinitions) { entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(), fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable()); } final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, false, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h2>Customer Accounts</h2>", ContentMode.HTML); titleLayout.addComponent(titleLabel); gridLayout.addComponent(titleLayout, 0, 3); final Table table = new Table(); table.setPageLength(5); entityGrid = new Grid(table, entityContainer); entityGrid.setFields(fieldDefinitions); entityGrid.setFilters(filterDefinitions); //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId"); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); table.setColumnCollapsed("company", true); gridLayout.addComponent(entityGrid, 0, 5); final HorizontalLayout customerButtonsLayout = new HorizontalLayout(); gridLayout.addComponent(customerButtonsLayout, 0, 4); customerButtonsLayout.setMargin(false); customerButtonsLayout.setSpacing(true); final Button editCustomerDetailsButton = new Button("Edit Customer Details"); customerButtonsLayout.addComponent(editCustomerDetailsButton); editCustomerDetailsButton.setEnabled(false); editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerDetailsButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class); customerView.edit(entity, false); } }); final Button editCustomerMembersButton = new Button("Edit Customer Members"); customerButtonsLayout.addComponent(editCustomerMembersButton); editCustomerMembersButton.setEnabled(false); editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerMembersButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final GroupFlowlet view = getFlow().forward(GroupFlowlet.class); view.edit(entity.getMemberGroup(), false); } }); final Button editCustomerAdminsButton = new Button("Edit Customer Admins"); customerButtonsLayout.addComponent(editCustomerAdminsButton); editCustomerAdminsButton.setEnabled(false); editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit")); editCustomerAdminsButton.addClickListener(new ClickListener() { /** * Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (entityGrid.getSelectedItemId() == null) { return; } final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId()); final GroupFlowlet view = getFlow().forward(GroupFlowlet.class); view.edit(entity.getAdminGroup(), false); } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { editCustomerDetailsButton.setEnabled(table.getValue() != null); editCustomerMembersButton.setEnabled(table.getValue() != null); editCustomerAdminsButton.setEnabled(table.getValue() != null); } }); } }
From source file:org.bubblecloud.ilves.ui.user.privilege.PrivilegesFlowlet.java
License:Apache License
@Override protected void initialize() { final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true);// w w w .j a v a 2s . c o m final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-privileges")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); titleLabel = new Label("<h1>" + getSite().localize("view-privileges") + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); matrixLayout = new VerticalLayout(); matrixLayout.setSpacing(true); matrixLayout.setMargin(false); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); saveButton = getSite().getButton("save"); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new Button.ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { saveGroupMatrix(); saveUserMatrix(); PrivilegeCache.flush((Company) Site.getCurrent().getSiteContext().getObject(Company.class)); } }); discardButton = getSite().getButton("discard"); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new Button.ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { refreshGroupMatrix(); refreshUserMatrix(); } }); final CssLayout panel = new CssLayout(); panel.addComponent(titleLayout); panel.addComponent(matrixLayout); panel.addComponent(buttonLayout); setCompositionRoot(panel); }
From source file:org.vaadin.addons.sitekit.example.FeedbackViewlet.java
License:Apache License
/** * Default constructor.//from w w w . j a v a 2 s. c o m */ public FeedbackViewlet() { final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister.getFieldSetDescriptor("feedback") .getFieldDescriptors(); editor = new ValidatingEditor(fieldDescriptors); final Button submitButton = new Button(getSite().localize("button-submit")); submitButton.addClickListener(new ClickListener() { /** The default serial version ID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editor.commit(); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); final Company company = getSite().getSiteContext().getObject(Company.class); try { Notification.show(getSite().localize("message-feedback-submit-success"), Notification.Type.HUMANIZED_MESSAGE); } catch (final Exception e) { LOGGER.error("Error adding user.", e); Notification.show(getSite().localize("message-feedback-submit-error"), Notification.Type.WARNING_MESSAGE); } reset(); } }); editor.addListener(new ValidatingEditorStateListener() { @Override public void editorStateChanged(final ValidatingEditor source) { if (source.isValid()) { submitButton.setEnabled(true); } else { submitButton.setEnabled(false); } } }); reset(); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-feedback")); titleIcon.setWidth(32, Unit.PIXELS); titleIcon.setHeight(32, Unit.PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-feedback") + "</h1>", ContentMode.HTML); titleLayout.addComponent(titleLabel); final VerticalLayout panel = new VerticalLayout(); panel.addComponent(titleLayout); panel.addComponent(editor); panel.addComponent(submitButton); panel.setSpacing(true); panel.setMargin(true); final Panel mainLayout = new Panel(); mainLayout.setStyleName(Reindeer.PANEL_LIGHT); mainLayout.setContent(panel); setCompositionRoot(mainLayout); }
From source file:org.vaadin.addons.sitekit.flow.AbstractFlowlet.java
License:Apache License
@Override public final void attach() { super.attach(); this.setSizeFull(); rootLayout = new GridLayout(1, 2); rootLayout.setMargin(true);/*from w w w. j av a2 s . c o m*/ rootLayout.setSpacing(true); rootLayout.setSizeFull(); rootLayout.setRowExpandRatio(0, 0f); rootLayout.setRowExpandRatio(1, 1f); final HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setMargin(new MarginInfo(true, false, true, false)); titleLayout.setSpacing(true); final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-" + getFlowletKey())); titleIcon.setWidth(32, UNITS_PIXELS); titleIcon.setHeight(32, UNITS_PIXELS); titleLayout.addComponent(titleIcon); final Label titleLabel = new Label("<h1>" + getSite().localize("view-" + getFlowletKey()) + "</h1>", Label.CONTENT_XHTML); titleLayout.addComponent(titleLabel); rootLayout.addComponent(titleLayout, 0, 0); setCompositionRoot(rootLayout); initialize(); }