Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package com.example.vaadintest;
  2.  
  3. import java.io.File;
  4.  
  5. import com.sun.org.apache.xerces.internal.impl.xs.identity.Selector;
  6. import com.vaadin.Application;
  7. import com.vaadin.data.Property;
  8. import com.vaadin.data.Property.ValueChangeEvent;
  9. import com.vaadin.data.util.FilesystemContainer;
  10. import com.vaadin.data.util.TextFileProperty;
  11. import com.vaadin.ui.*;
  12.  
  13. public class VaadintestApplication extends Application {
  14.    
  15.     FilesystemContainer docs = new FilesystemContainer(new File("/home/juw/docs"));
  16.     Select selector = new Select(null, docs);
  17.     Label viewer = new Label("Select a doc", Label.CONTENT_RAW);
  18.     @Override
  19.     public void init() {
  20.         Window mainWindow = new Window("Vaadintest Application");
  21.         mainWindow.addComponent(selector);
  22.         mainWindow.addComponent(viewer);
  23.         setMainWindow(mainWindow);
  24.        
  25.         selector.setImmediate(true);
  26.         selector.setSizeFull();
  27.         selector.addListener(new Property.ValueChangeListener() {
  28.            
  29.             @Override
  30.             public void valueChange(ValueChangeEvent event) {
  31.                 // TODO Auto-generated method stub
  32.                 System.out.println("stuff have changed");
  33.                
  34.                 viewer.setPropertyDataSource(new TextFileProperty((File)selector.getValue()));
  35.                
  36.             }
  37.         });
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement