List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:org.semanticsoft.vaaclipse.p2.install.ui.impl.LicenseView.java
License:Open Source License
@Override public void initUI() { // TODO Auto-generated method stub errorLayout.setHeight("30px"); mainLayout.addComponent(errorLayout); horizontalSplitPanel.setWidth("600px"); horizontalSplitPanel.setHeight("380px"); leftLayout.addComponent(treeRepo);//from ww w . jav a 2s.c om horizontalSplitPanel.setFirstComponent(leftLayout); horizontalSplitPanel.setSecondComponent(rightLayout); leftLayout.setSizeFull(); rightLayout.setSizeFull(); checkBox = new CheckBox("I agree"); checkBox.setValue(false); mainLayout.addComponent(horizontalSplitPanel); mainLayout.addComponent(checkBox); treeRepo.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { // TODO Auto-generated method stub Object itemId = event.getItemId(); rightLayout.removeAllComponents(); for (IInstallableUnit inst : listReos) { if (inst.getId().equals(itemId)) { Label c = new Label(); Collection<ILicense> licenses = inst.getLicenses(); c.setValue(""); for (ILicense iLicense : licenses) { c.setValue(c.getValue() + iLicense.getBody()); } rightLayout.addComponent(c); } } } }); }
From source file:org.semanticsoft.vaaclipse.p2.install.ui.impl.LicenseView.java
License:Open Source License
@Override public boolean validate() { errorLayout.removeAllComponents();// w w w. j a v a 2s .co m // TODO Auto-generated method stub Boolean value = checkBox.getValue(); if (!value) { Label c = new Label(); c.setValue("You must agree with license"); errorLayout.addComponent(c); } return value; }
From source file:org.semanticsoft.vaaclipse.p2.install.ui.impl.RepositoryLoader.java
License:Open Source License
public void initUI() { final Label errorLabel = new Label(); errorLabel.setImmediate(true);//from ww w. j a va2 s . c o m Label label = new Label("Enter URI here"); final TextField textField = new TextField(); textField.setValue("http://localhost/MyUpdateSite"); textField.setImmediate(true); textField.setSizeFull(); mainLayout.addComponent(errorLabel); mainLayout.addComponent(label); mainLayout.addComponent(textField); textField.addShortcutListener(new ShortcutListener("Enter URI", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { // TODO Auto-generated method stub errorLabel.setValue(""); validate = true; loadRepository.clear(); String value = textField.getValue(); if (value != null && !value.trim().isEmpty()) { try { loadRepository.addAll(getInstallService().loadRepository(value, getProvisioningAgent())); } catch (Exception e) { validate = false; e.printStackTrace(); errorLabel.setValue("URI is not valid"); errorMessage = e.getMessage(); } iRepositoryExplorer.addRepositories(loadRepository); } } }); }
From source file:org.sensorhub.ui.SWECommonForm.java
License:Mozilla Public License
protected Component buildWidget(DataComponent dataComponent, boolean showValues) { if (dataComponent instanceof DataRecord || dataComponent instanceof Vector) { VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, false)); l.setDescription(getTooltip(dataComponent)); layout.addComponent(l);/*from w w w. java 2 s. co m*/ VerticalLayout form = new VerticalLayout(); form.setMargin(new MarginInfo(false, false, false, true)); form.setSpacing(false); for (int i = 0; i < dataComponent.getComponentCount(); i++) { DataComponent c = dataComponent.getComponent(i); Component w = buildWidget(c, showValues); if (w != null) form.addComponent(w); } layout.addComponent(form); return layout; } else if (dataComponent instanceof DataArray) { DataArray dataArray = (DataArray) dataComponent; VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, false)); l.setDescription(getTooltip(dataComponent)); layout.addComponent(l); VerticalLayout form = new VerticalLayout(); form.setMargin(new MarginInfo(false, false, false, true)); form.setSpacing(false); form.addComponent(buildWidget(dataArray.getElementType(), false)); layout.addComponent(form); return layout; } else if (dataComponent instanceof DataChoice) { DataChoice dataChoice = (DataChoice) dataComponent; VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataChoice, false)); l.setDescription(getTooltip(dataChoice)); layout.addComponent(l); return layout; } else if (dataComponent instanceof SimpleComponent) { Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, showValues)); l.setDescription(getTooltip(dataComponent)); return l; } return null; }
From source file:org.vaadin.addons.javaee.table.ClassNameColumnGenerator.java
License:Apache License
@Override public Component generateCell(Table source, Object itemId, Object columnId) { EntityItem<?> item = (EntityItem<?>) source.getItem(itemId); String name = item.getEntity().getClass().getSimpleName(); Label field = new Label(); field.setValue(translationService.getText(name)); return field; }
From source file:org.vaadin.alump.fancylayouts.demo.CssLayoutDemo.java
License:Apache License
public CssLayoutDemo() { setMargin(true);/*from ww w . j a v a 2 s . co m*/ setSpacing(true); setSizeFull(); final FancyCssLayout cssLayout = new FancyCssLayout(); Label todo = new Label("FancyCssLayout adds transitions when you add or remove components from it."); addComponent(todo); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setWidth("100%"); addComponent(hLayout); Button addContent = new Button("Add new content item"); hLayout.addComponent(addContent); CheckBox middleCbox = new CheckBox("add middle"); middleCbox.setImmediate(true); middleCbox.setValue(addCssMiddle); hLayout.addComponent(middleCbox); CheckBox marginCbox = new CheckBox("slide"); marginCbox.setImmediate(true); marginCbox.setValue(cssLayout.isTransitionEnabled(FancyTransition.SLIDE)); hLayout.addComponent(marginCbox); CheckBox styleCbox = new CheckBox("cards"); styleCbox.setImmediate(true); styleCbox.setValue(boxMode); hLayout.addComponent(styleCbox); final Label counterLabel = new Label(getClickCounterCaption()); hLayout.addComponent(counterLabel); cssLayout.setSizeFull(); addComponent(cssLayout); setExpandRatio(cssLayout, 1.0f); for (int i = 0; i < 10; ++i) { addCssLayoutContent(cssLayout); } addContent.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { addCssLayoutContent(cssLayout); } }); middleCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { addCssMiddle = (Boolean) event.getProperty().getValue(); } }); marginCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { cssLayout.setSlideEnabled((Boolean) event.getProperty().getValue()); } }); styleCbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); Iterator<Component> iter = cssLayout.iterator(); while (iter.hasNext()) { Component component = iter.next(); if (value) { component.addStyleName("demo-removable-two"); } else { component.removeStyleName("demo-removable-two"); } } boxMode = value; } }); cssLayout.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { ++clickCounter; if (event.getChildComponent() == null) { ++layoutClickCounter; } counterLabel.setValue(getClickCounterCaption()); } }); }
From source file:org.vaadin.overlay.sample.OverlaySampleApplication.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); final Label label = new Label("Alignment.TOP_LEFT"); layout.addComponent(label);/*w w w. j a v a 2s . co m*/ for (int i = 0; i < 20; i++) { Button button = new Button("Sample Button"); layout.addComponent(button); final ImageOverlay io = new ImageOverlay(button); Resource res = new ClassResource(this.getClass(), "../icon-new.png"); io.setImage(res); io.setComponentAnchor(Alignment.TOP_LEFT); // Top left of the button io.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image io.setClickListener(new OverlayClickListener() { public void overlayClicked(CustomClickableOverlay overlay) { Notification.show("ImageOverlay Clicked!"); } }); layout.addComponent(io); io.setEnabled(true); final TextOverlay to = new TextOverlay(button, "New!"); to.setComponentAnchor(Alignment.MIDDLE_RIGHT); // Top right of the button to.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image to.setClickListener(new OverlayClickListener() { public void overlayClicked(CustomClickableOverlay overlay) { Notification.show("TextOverlay Clicked!"); } }); layout.addComponent(to); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Alignment a = io.getComponentAnchor(); String s = ""; if (Alignment.TOP_LEFT.equals(a)) { a = Alignment.TOP_CENTER; s = "TOP_CENTER"; } else if (Alignment.TOP_CENTER.equals(a)) { a = Alignment.TOP_RIGHT; s = "TOP_RIGHT"; } else if (Alignment.TOP_RIGHT.equals(a)) { a = Alignment.MIDDLE_RIGHT; s = "MIDDLE_RIGHT"; } else if (Alignment.MIDDLE_RIGHT.equals(a)) { a = Alignment.BOTTOM_RIGHT; s = "BOTTOM_RIGHT"; } else if (Alignment.BOTTOM_RIGHT.equals(a)) { a = Alignment.BOTTOM_CENTER; s = "BOTTOM_CENTER"; } else if (Alignment.BOTTOM_CENTER.equals(a)) { a = Alignment.BOTTOM_LEFT; s = "BOTTOM_LEFT"; } else if (Alignment.BOTTOM_LEFT.equals(a)) { a = Alignment.MIDDLE_LEFT; s = "MIDDLE_LEFT"; } else if (Alignment.MIDDLE_LEFT.equals(a)) { a = Alignment.TOP_LEFT; s = "TOP_LEFT"; } io.setComponentAnchor(a); label.setValue("Alignment." + s); } }); } setContent(layout); }
From source file:org.vaadin.spring.samples.mvp.ui.view.BannerView.java
License:Apache License
protected Layout buildUserArea(String username) { HorizontalLayout userArea = new HorizontalLayout(); String id = env.getProperty("app.security.scheme", Scheme.BASIC.id()); if (id.equals(Scheme.FORM.id())) { Button signOut = new Button("Sign Out"); signOut.addClickListener(logoutListener); userArea.addComponent(signOut);// w ww. jav a 2 s . c om } Label loggedInUser = new Label(); loggedInUser.setValue(username); loggedInUser.setSizeUndefined(); userArea.addComponent(loggedInUser); return userArea; }
From source file:org.vaadin.tori.component.AuthoringComponent.java
License:Apache License
private void updateAttachmentList() { attachmentsLayout.removeAllComponents(); attachmentsLayout.setVisible(!attachments.isEmpty()); for (final Entry<String, byte[]> entry : attachments.entrySet()) { final String fileName = entry.getKey(); final int fileSize = entry.getValue().length; final String caption = String.format("%s (%s KB)", fileName, fileSize / 1024); final Label nameComponent = new Label(); nameComponent.addStyleName("namelabel"); nameComponent.setValue(caption); nameComponent.setWidth(300.0f, Unit.PIXELS); try {//from w w w . j a v a2 s .c o m nameComponent.addStyleName(fileName.substring(fileName.lastIndexOf(".") + 1)); } catch (final IndexOutOfBoundsException e) { // NOP } final HorizontalLayout wrapperLayout = new HorizontalLayout(); wrapperLayout.addStyleName("filerow"); wrapperLayout.addComponent(nameComponent); final Label deleteLabel = new Label(); deleteLabel.addStyleName("deleteattachment"); wrapperLayout.addComponent(deleteLabel); wrapperLayout.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(final LayoutClickEvent event) { if (event.getChildComponent() == deleteLabel) { attachments.remove(entry.getKey()); updateAttachmentList(); } } }); attachmentsLayout.addComponent(wrapperLayout); } }
From source file:pl.exsio.plupload.examples.AdvancedUploaderExample.java
License:Open Source License
@Override protected void decorateActionPane(VerticalLayout pane) { final Plupload uploader = Util.createUploader(); uploader.setChunkSize("2mb"); uploader.setMaxRetries(5);/*from www. j av a 2s . c o m*/ uploader.setMultiSelection(true); uploader.setPreventDuplicates(true); uploader.addFilter(new PluploadFilter("image files", "jpg, png, jpeg")); uploader.setImageResize( new PluploadImageResize().setEnabled(true).setCrop(true).setHeight(100).setWidth(200)); uploader.addFileUploadedListener(new Plupload.FileUploadedListener() { @Override public void onFileUploaded(PluploadFile file) { Notification.show("I've just uploaded file: " + file.getName()); } }); final Label info = new Label(); uploader.addUploadProgressListener(new Plupload.UploadProgressListener() { @Override public void onUploadProgress(PluploadFile file) { info.setValue("I'm uploading " + file.getName() + " and I'm at " + file.getPercent() + "%"); } }); uploader.addFilesAddedListener(new Plupload.FilesAddedListener() { @Override public void onFilesAdded(PluploadFile[] files) { uploader.start(); } }); uploader.addUploadCompleteListener(new Plupload.UploadCompleteListener() { @Override public void onUploadComplete() { info.setValue("upload is completed!"); } }); uploader.addErrorListener(new Plupload.ErrorListener() { @Override public void onError(PluploadError error) { Notification.show("There was an error: " + error.getMessage() + " (" + error.getType() + ")", Notification.Type.ERROR_MESSAGE); } }); ComboBox chunkSizeChoice = new ComboBox("Choose chunk size"); for (double i = 0.5; i <= 3; i += 0.5) { chunkSizeChoice.addItem(i + "mb"); } chunkSizeChoice.setNullSelectionAllowed(false); chunkSizeChoice.setValue("2.0mb"); chunkSizeChoice.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String chunkSize = event.getProperty().getValue().toString(); uploader.setChunkSize(chunkSize); Notification.show("Chunk size was changed to " + chunkSize); } }); pane.setSpacing(true); pane.addComponent(chunkSizeChoice); pane.addComponent(uploader); pane.addComponent(info); }