List of usage examples for com.vaadin.ui GridLayout getComponent
public Component getComponent(int x, int y)
From source file:edu.kit.dama.ui.admin.utils.UIComponentTools.java
License:Apache License
/** * */// ww w. j av a 2 s. co m private static void setLockedGridComponents(GridLayout layout, boolean locked) { for (int i = 0; i < layout.getColumns(); i++) { for (int j = 0; j < layout.getRows(); j++) { if (layout.getComponent(i, j) == null) { continue; } if (layout.getComponent(i, j).getClass().equals(Button.class)) { layout.getComponent(i, j).setEnabled(!locked); } else if (layout.getComponent(i, j).getClass().equals(ComboBox.class)) { layout.getComponent(i, j).setEnabled(!locked); layout.getComponent(i, j).setReadOnly(false); } else { layout.getComponent(i, j).setReadOnly(locked); } } } }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor./*from w ww . j a va 2 s . c o m*/ */ 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.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java
License:Open Source License
/** Constructor for view to display the completed ratings given. * * @param inRatings {@link QueryResult} the participants involved in the review and rating process * @param inQuestions {@link QueryResult} the reviewed questions * @param inCompletions {@link QueryResult} the reviewed completions * @param inTexts {@link QueryResult} the reviewed texts * @param inTask {@link IPluggableWithLookup} the controlling task * @throws VException//from w w w. j ava 2 s . c om * @throws SQLException */ public ShowCompletedRatingView(final QueryResult inRatings, final QueryResult inQuestions, final QueryResult inCompletions, final QueryResult inTexts, final IPluggableWithLookup inTask) throws VException, SQLException { final VerticalLayout lLayout = new VerticalLayout(); setCompositionRoot(lLayout); final IMessages lMessages = Activator.getMessages(); lLayout.setStyleName("vif-view"); //$NON-NLS-1$ lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", //$NON-NLS-1$ lMessages.getMessage("ratings.completed.title")), ContentMode.HTML)); //$NON-NLS-1$ lLayout.addComponent(new Label(lMessages.getMessage("ui.rated.subtitle"), ContentMode.HTML)); //$NON-NLS-1$ listContributions(inQuestions, inCompletions, inTexts, inTask, lLayout, lMessages); lLayout.addComponent(RiplaViewHelper.createSpacer()); final GridLayout lRatings = new GridLayout(5, 3); lRatings.setStyleName("vif-rating"); //$NON-NLS-1$ lRatings.setWidth("100%"); //$NON-NLS-1$ lRatings.setColumnExpandRatio(4, 1); lLayout.addComponent(lRatings); // headers lRatings.addComponent(new Label("")); //$NON-NLS-1$ addComponentSized(new Label(lMessages.getMessage("ui.rated.column.correctness"), ContentMode.HTML), //$NON-NLS-1$ lRatings); addComponentSized(new Label(lMessages.getMessage("ui.rated.column.efficiency"), ContentMode.HTML), //$NON-NLS-1$ lRatings); addComponentSized(new Label(lMessages.getMessage("ui.rated.column.etiquette"), ContentMode.HTML), lRatings); //$NON-NLS-1$ Label lRemark = new Label(lMessages.getMessage("ui.rated.column.remark"), ContentMode.HTML); //$NON-NLS-1$ lRemark.setStyleName("vif-colhead vif-padding-left"); //$NON-NLS-1$ lRatings.addComponent(lRemark); lRatings.getComponent(0, 0).setWidth(350, Unit.PIXELS); // ratings final Map<Long, String> lParticipants = new HashMap<Long, String>(); final List<Line> lLines = new Vector<ShowCompletedRatingView.Line>(); while (inRatings.hasMoreElements()) { final GeneralDomainObject lRating = inRatings.nextAsDomainObject(); setParticipant(lRating, lParticipants); lLines.add(new Line(lRating)); } for (final Line lLine : lLines) { lRatings.addComponent(new Label(lLine.getInvolved(lParticipants, lMessages), ContentMode.HTML)); addComponentAligened(lLine.getCorrectness(), lRatings); addComponentAligened(lLine.getEfficiency(), lRatings); addComponentAligened(lLine.getEtiquette(), lRatings); lRemark = new Label(lLine.getRemark(), ContentMode.HTML); lRemark.setStyleName("vif-padding-left"); //$NON-NLS-1$ lRatings.addComponent(lRemark); } }