List of usage examples for com.vaadin.ui Embedded setWidth
@Override public void setWidth(float width, Unit unit)
From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneField.java
License:Apache License
public DettaglioMissioneField(FormProperty formProperty, GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) { I18nManager i18nManager = get().getI18nManager(); String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE); setSpacing(true);/*from w ww . ja v a2 s. c o m*/ setCaption(caption); setHeight(Sizeable.SIZE_UNDEFINED, 0); Label missionIdLabel = new Label(); missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome()); missionIdLabel.setStyleName("missione_label"); Label missionDateLabel = new Label(); missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " " + giornata.format(missione.getDataInizio())); missionDateLabel.setStyleName("missione_label"); Label agencyCodeLabel = new Label(); agencyCodeLabel.setValue( i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale()); agencyCodeLabel.setStyleName("missione_label"); Label rankingLabel = new Label(); rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING)); Embedded rankingImage = null; if (missione.getRanking() != null) { if (missione.getRanking().equals(VERDE)) rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png")); else if (missione.getRanking().equals(GIALLO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png")); else if (missione.getRanking().equals(ROSSO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png")); rankingImage.setWidth(20, UNITS_PIXELS); rankingImage.setStyleName("missione_label"); } Label mobilityCreditLabel = new Label(); mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " " + missione.getCreditoMobilita()); mobilityCreditLabel.setStyleName("missione_label"); addComponent(missionIdLabel); addComponent(missionDateLabel); addComponent(agencyCodeLabel); addComponent(rankingLabel); if (rankingImage != null) addComponent(rankingImage); addComponent(mobilityCreditLabel); setStyleName("dettaglio-missione"); policyDetailsButton = new Button(); policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON)); final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer; policyDetailsButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton() .click(); } }); addComponent(policyDetailsButton); // Invisible textfield, only used as wrapped field wrappedField = new TextField(); wrappedField.setVisible(false); addComponent(wrappedField); }
From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneSTField.java
License:Apache License
public DettaglioMissioneSTField(FormProperty formProperty, GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) { I18nManager i18nManager = get().getI18nManager(); String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE); setSpacing(true);//from w w w . j a v a 2 s .c o m setCaption(caption); setHeight(Sizeable.SIZE_UNDEFINED, 0); Label opLabel = new Label(); opLabel.setValue( i18nManager.getMessage(DETTAGLIO_MISSIONE_OPERATORE_LOGISTICO) + " " + missione.getCompagnia()); opLabel.setStyleName("missione_label"); Label missionIdLabel = new Label(); missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome()); missionIdLabel.setStyleName("missione_label"); Label missionDateLabel = new Label(); missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " " + giornata.format(missione.getDataInizio())); missionDateLabel.setStyleName("missione_label"); Label agencyCodeLabel = new Label(); agencyCodeLabel.setValue( i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale()); agencyCodeLabel.setStyleName("missione_label"); Label rankingLabel = new Label(); rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING)); Embedded rankingImage = null; if (missione.getRanking() != null) { if (missione.getRanking().equals(VERDE)) rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png")); else if (missione.getRanking().equals(GIALLO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png")); else if (missione.getRanking().equals(ROSSO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png")); rankingImage.setWidth(20, UNITS_PIXELS); rankingImage.setStyleName("missione_label"); } Label mobilityCreditLabel = new Label(); mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " " + missione.getCreditoMobilita()); mobilityCreditLabel.setStyleName("missione_label"); addComponent(opLabel); addComponent(missionIdLabel); addComponent(missionDateLabel); addComponent(agencyCodeLabel); addComponent(rankingLabel); if (rankingImage != null) addComponent(rankingImage); addComponent(mobilityCreditLabel); setStyleName("dettaglio-missione"); policyDetailsButton = new Button(); policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON)); final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer; policyDetailsButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton() .click(); } }); addComponent(policyDetailsButton); // Invisible textfield, only used as wrapped field wrappedField = new TextField(); wrappedField.setVisible(false); addComponent(wrappedField); }
From source file:it.vige.greenarea.bpm.custom.ui.form.DettaglioMissioneTRField.java
License:Apache License
public DettaglioMissioneTRField(FormProperty formProperty, GreenareaAbstractFormPropertyRenderer<T> greenareaAbstractFormPropertyRenderer, Missione missione) { I18nManager i18nManager = get().getI18nManager(); String caption = i18nManager.getMessage(DETTAGLIO_MISSIONE_TITLE); setSpacing(true);/* w ww. j av a2s . c om*/ setCaption(caption); setHeight(Sizeable.SIZE_UNDEFINED, 0); Label opLabel = new Label(); opLabel.setValue( i18nManager.getMessage(DETTAGLIO_MISSIONE_OPERATORE_LOGISTICO) + " " + missione.getCompagnia()); opLabel.setStyleName("missione_label"); Label missionIdLabel = new Label(); missionIdLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_ID_MISSIONE) + " " + missione.getNome()); missionIdLabel.setStyleName("missione_label"); Label missionDateLabel = new Label(); missionDateLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_DATA_MISSIONE) + " " + giornata.format(missione.getDataInizio())); missionDateLabel.setStyleName("missione_label"); Label agencyCodeLabel = new Label(); agencyCodeLabel.setValue( i18nManager.getMessage(DETTAGLIO_MISSIONE_CODICE_FILIALE) + " " + missione.getCodiceFiliale()); agencyCodeLabel.setStyleName("missione_label"); Label rankingLabel = new Label(); rankingLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_RANKING)); Embedded rankingImage = null; if (missione.getRanking() != null) { if (missione.getRanking().equals(VERDE)) rankingImage = new Embedded(null, new ThemeResource("img/circle_green.png")); else if (missione.getRanking().equals(GIALLO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_orange.png")); else if (missione.getRanking().equals(ROSSO)) rankingImage = new Embedded(null, new ThemeResource("img/circle_red.png")); rankingImage.setWidth(20, UNITS_PIXELS); rankingImage.setStyleName("missione_label"); } Label mobilityCreditLabel = new Label(); mobilityCreditLabel.setValue(i18nManager.getMessage(DETTAGLIO_MISSIONE_CREDITO_DI_MOBILITA) + " " + missione.getCreditoMobilita()); mobilityCreditLabel.setStyleName("missione_label"); addComponent(opLabel); addComponent(missionIdLabel); addComponent(missionDateLabel); addComponent(agencyCodeLabel); addComponent(rankingLabel); if (rankingImage != null) addComponent(rankingImage); addComponent(mobilityCreditLabel); setStyleName("dettaglio-missione"); policyDetailsButton = new Button(); policyDetailsButton.setCaption(i18nManager.getMessage(DETTAGLIO_MISSIONE_BUTTON)); final GreenareaAbstractFormPropertyRenderer<?> fGreenareaAbstractFormPropertyRenderer = greenareaAbstractFormPropertyRenderer; policyDetailsButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { fGreenareaAbstractFormPropertyRenderer.getGreenareaFormPropertiesForm().getSubmitFormButton() .click(); } }); addComponent(policyDetailsButton); // Invisible textfield, only used as wrapped field wrappedField = new TextField(); wrappedField.setVisible(false); addComponent(wrappedField); }
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 w w.ja v a 2s .c o 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 ww w .j a va 2s .c o m*/ }, 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.activiti.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) { for (final HistoricTaskInstance subTask : subTasks) { // icon/*from w w w. jav a2 s.co m*/ Embedded icon = new Embedded(null, Images.TASK_22); icon.setWidth(22, UNITS_PIXELS); icon.setWidth(22, UNITS_PIXELS); subTaskGrid.addComponent(icon); // Link to subtask Button subTaskLink = new Button(subTask.getName()); subTaskLink.addStyleName(Reindeer.BUTTON_LINK); subTaskLink.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showTaskPage(subTask.getId()); } }); subTaskGrid.addComponent(subTaskLink); subTaskGrid.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT); } }
From source file:org.activiti.explorer.ui.task.SubTaskComponent.java
License:Apache License
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) { if (!subTasks.isEmpty()) { for (final HistoricTaskInstance subTask : subTasks) { // icon Embedded icon = null; if (subTask.getEndTime() != null) { icon = new Embedded(null, Images.TASK_FINISHED_22); } else { icon = new Embedded(null, Images.TASK_22); }/* w w w.j av a 2 s . c o m*/ icon.setWidth(22, UNITS_PIXELS); icon.setWidth(22, UNITS_PIXELS); subTaskLayout.addComponent(icon); // Link to subtask Button subTaskLink = new Button(subTask.getName()); subTaskLink.addStyleName(Reindeer.BUTTON_LINK); subTaskLink.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showTaskPage(subTask.getId()); } }); subTaskLayout.addComponent(subTaskLink); subTaskLayout.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT); if (subTask.getEndTime() == null) { // Delete icon only appears when task is not finished yet Embedded deleteIcon = new Embedded(null, Images.DELETE); deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE); deleteIcon.addListener(new DeleteSubTaskClickListener(subTask, this)); subTaskLayout.addComponent(deleteIcon); subTaskLayout.setComponentAlignment(deleteIcon, Alignment.MIDDLE_RIGHT); } else { // Next line of grid subTaskLayout.newLine(); } } } else { Label noSubTasksLabel = new Label(i18nManager.getMessage(Messages.TASK_NO_SUBTASKS)); noSubTasksLabel.setSizeUndefined(); noSubTasksLabel.addStyleName(Reindeer.LABEL_SMALL); subTaskLayout.addComponent(noSubTasksLabel); } }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor./*w w w. j ava 2s . com*/ */ 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 www . ja v a 2s . 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./*w w w .j a v a 2 s. 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); }