Example usage for com.vaadin.ui Window Window

List of usage examples for com.vaadin.ui Window Window

Introduction

In this page you can find the example usage for com.vaadin.ui Window Window.

Prototype

public Window(String caption) 

Source Link

Document

Creates a new, empty window with a given title.

Usage

From source file:facs.components.Settings.java

License:Open Source License

private void addNewDevice() {
    final Window subWindow = new Window("Add Device");
    FormLayout form = new FormLayout();
    form.setMargin(true);//from  w  w  w. j a v  a2s . com
    final TextField name = new TextField();
    name.setImmediate(true);
    name.addValidator(new StringLengthValidator("The name must be 1-85 letters long (Was {0}).", 1, 85, true));
    name.setCaption("Name of new device");
    form.addComponent(name);
    final TextArea description = new TextArea();
    description.setImmediate(true);
    description.addValidator(
            new StringLengthValidator("The name must be 1-255 letters long (Was {0}).", 1, 255, true));
    description.setCaption("Description");
    form.addComponent(description);
    final OptionGroup restricted = new OptionGroup("Is Device restricted by operators?");
    restricted.addItem("yes");
    restricted.setMultiSelect(true);
    form.addComponent(restricted);
    HorizontalLayout buttons = new HorizontalLayout();
    Button save = new Button("save");
    buttons.addComponent(save);
    Button discard = new Button("discard");
    discard.setDescription("discarding will abort the process of adding a new device into the databse.");
    buttons.addComponent(discard);
    buttons.setSpacing(true);
    form.addComponent(buttons);
    subWindow.setContent(form);

    form.setMargin(true);
    form.setSpacing(true);
    buttons.setMargin(true);
    buttons.setSpacing(true);

    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setWidth("50%");
    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    discard.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -5808910314649620731L;

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();
        }
    });
    save.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 3748395242651585005L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (name.isValid() && description.isValid()) {
                Set<String> restr = (Set<String>) restricted.getValue();
                int deviceId = DBManager.getDatabaseInstance().addDevice(name.getValue(),
                        description.getValue(), (restr.size() == 1));
                DeviceBean bean = new DeviceBean(deviceId, name.getValue(), description.getValue(),
                        (restr.size() == 1));
                devicesGrid.addRow(bean);
            } else {
                Notification.show("Failed to add device to database.");
            }
        }
    });

    // DeviceBean db = new DeviceBean(0, "Device 1","some description1", false);
    // TODO
    // add to database
    /*
     * boolean added = false;//DBManager.getDatabaseInstance().addDevice(db); //TODO test //add to
     * grid if(added){ devicesGrid.addRow(db); }else{ //TODO log failed operation
     * Notification.show("Failed to add device to database.", Type.ERROR_MESSAGE); }
     */
}

From source file:fi.hip.sicx.vaadin.FileguiApplication.java

License:Open Source License

@Override
public void init() {
    Window mainWindow = new Window("FileGUI Application");
    guicompo = new GUIComponent();
    mainWindow.setContent(guicompo);//from w w  w  .  j  a  v a2s .com
    guicompo.openLoginWindow(); // Open login GUI
    setMainWindow(mainWindow);
}

From source file:fi.hip.sicx.vaadin.GUIComponent.java

License:Open Source License

/**
 * Opens a window for user login./*from   ww w  .ja  v a 2  s  . c o  m*/
 * 
 * @return true if all ok, else false
 */
public boolean openLoginWindow() {
    // Login window
    subwindow = new Window("SICX login");
    subwindow.setContent(new LoginWindow(this, subwindow));
    subwindow.setResizable(false);
    subwindow.setClosable(false);
    subwindow.setDraggable(false);
    subwindow.setModal(true);
    subwindow.setReadOnly(true);
    getWindow().addWindow(subwindow);

    return true;
}

From source file:fi.hip.sicx.vaadin.GUIComponent.java

License:Open Source License

/**
 * Opens a window for user login.//  w  w w . j  av a 2 s . c  o  m
 * 
 * @return true if all ok, else false
 */
public boolean openFileInfoWindow() {
    // Login window
    fileinfowindow = new Window("SICX file information");
    fileinfowindow.setContent(new FileInfoWindow(this, fileinfowindow));
    //fileinfowindow.setResizable(false);
    fileinfowindow.setClosable(true);
    fileinfowindow.setDraggable(true);
    //fileinfowindow.setModal(false);
    //fileinfowindow.setReadOnly(true);
    fileinfowindow.setWidth(500, UNITS_PIXELS);
    fileinfowindow.setHeight(400, UNITS_PIXELS);
    getWindow().addWindow(fileinfowindow);

    return true;
}

From source file:fi.vtt.RVaadin.RContainer.java

License:Apache License

/**
 * Get a Vaadin Window element that contains the corresponding R plot
 * generated by submitting and evaluating the RPlotCall String. The
 * imageName corresponds to the downloadable .png image name. The full name
 * of the images shown in the browser are of the format
 * {@code imageName_ISODate_runningId_[sessionId].png}, e.g.
 * 'Image_2012-08-29_001_[bmgolmfgvk].png' to keep them chronologically
 * ordered./*from  w ww.  ja va 2 s  .c  om*/
 * 
 * @param RPlotCall
 *            the String to be evaluated by R
 * @param width
 *            the width of the graphical image
 * @param height
 *            the height of the graphical image
 * @param imageName
 *            the image name attached to the right-click downloadable file
 * @param windowName
 *            the title name of the Vaadin window element
 * @return Vaadin Window object
 */
public Window getGraph(final String RPlotCall, final int width, final int height, final String imageName,
        String windowName) {

    /* Construct a Window to show the graphics */
    Window RGraphics = new Window(windowName);
    HorizontalLayout root = new HorizontalLayout();
    root.setMargin(true);

    RGraphics.setContent(root);
    RGraphics.setSizeUndefined();

    /* Control the image position */
    final int imageXoffset = 180;
    final int imageYoffset = 60;

    int imageYpos = rand.nextInt(50);
    int imageXpos = rand.nextInt(90);

    RGraphics.setPositionX(imageXoffset + imageXpos);
    RGraphics.setPositionY(imageYoffset + imageYpos);

    /* Call R for the graphics */
    Embedded rPlot = getEmbeddedGraph(RPlotCall, width, height, imageName);
    root.addComponent(rPlot);

    /*
     * Button bar to generate PDF (and for other options in the future)
     */
    if (showButtonsInGraph) {
        final HorizontalLayout buttonLayout = new HorizontalLayout();
        Button open = new Button("PDF");
        open.setStyleName(Reindeer.BUTTON_SMALL);
        buttonLayout.addComponent(open);

        Button.ClickListener openClicked = new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                StreamResource s = getImageResource(RPlotCall, width / screen_dpi, height / screen_dpi,
                        imageName, "pdf");

                Link pdfLink = new Link("Open pdf", s);
                pdfLink.setTargetName("_blank");

                buttonLayout.removeAllComponents();
                buttonLayout.addComponent(pdfLink);
            }
        };
        open.addClickListener(openClicked);
        root.addComponent(buttonLayout);
    }

    return RGraphics;
}

From source file:fi.vtt.RVaadin.RContainer.java

License:Apache License

/**
 * Generate a preview Window of R data.frame with Excel download option.
 * /*from   w w  w .j ava  2  s.  c  o  m*/
 * @param rs
 *            R string which evaluates into R data.frame
 * @param caption
 *            Window caption
 * @param maxRows
 *            Maximum number of rows shown in the window. Value null uses
 *            the internal default.
 * @param width
 *            Explicit width of the table, or null for automatic width.
 * @return Vaadin Window
 */
public Window getRTableWindow(String rs, String caption, Integer maxRows, String width) {

    final Integer DEFAULT_MAX_ROWS = 15;

    /* Initiate a new SpreadSheetFacotry, if it does not exist already */
    if (ssf == null) {
        ssf = new SpreadSheetFactory();
    }

    /* Initiate the Table showing the data.frame */
    RTable table = getRTable(rs);

    /* Show only part of large tables */
    if (maxRows == null) {
        maxRows = DEFAULT_MAX_ROWS;
    }
    if (table.getDataFrame().nrow() >= maxRows) {
        table.setPageLength(maxRows);
        table.setCacheRate(2.0);
    }

    if (width != null) {
        table.setWidth(width);
    }

    DataFrame df = table.getDataFrame();
    String[] columnNames = table.getColumnNames();

    /* The element with XLSX download button */
    final SpreadSheetDownload ssd = new SpreadSheetDownload(df, columnNames, null, null, ssf);

    HorizontalLayout ssdBox = new HorizontalLayout();
    ssdBox.setHeight("23px");
    ssdBox.addComponent(ssd);

    Window window = new Window(caption);
    VerticalLayout root = new VerticalLayout();
    root.setSpacing(true);
    root.setMargin(true);
    window.setContent(root);

    root.addComponent(ssdBox);
    root.addComponent(table);

    @SuppressWarnings("serial")
    Window.CloseListener windowListener = new Window.CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {

            /* Delete the XLSX file, if it was generated */
            ssd.clear();
        }
    };
    window.addCloseListener(windowListener);

    return window;
}

From source file:hr.openshift.tomcat.db_test.DbTesterApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("Vaadin DB Tester");
    window.setSizeFull();//from   w  w  w .jav  a  2  s.  co m
    setMainWindow(window);
    setTheme("runo");

    Panel panel = new MainPanel();
    window.addComponent(panel);

}

From source file:hu.fnf.devel.wishbox.ui.MainPage.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    PropertysetItem item = new PropertysetItem();
    item.addItemProperty("name", new ObjectProperty<String>("Zaphod"));
    item.addItemProperty("age", new ObjectProperty<Integer>(42));

    // Have some layout
    FormLayout form = new FormLayout();
    HorizontalLayout footer = new HorizontalLayout();
    footer.addComponent(new Button("cica"));
    footer.addComponent(new Button("kutya"));

    // Now create a binder that can also create the fields
    // using the default field factory
    FieldGroup binder = new FieldGroup(item);

    form.addComponent(binder.buildAndBind("Name", "name"));
    form.addComponent(binder.buildAndBind("Age", "age"));

    HorizontalSplitPanel sample = new HorizontalSplitPanel();
    sample.setSizeFull();/*from w  w w.j  a  v a2 s.com*/

    VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel();
    verticalSplitPanel.setFirstComponent(form);
    verticalSplitPanel.setSecondComponent(new Label("masodik"));

    sample.setSecondComponent(verticalSplitPanel);

    Table grid = new Table();

    grid.setSizeFull();
    for (Object i : getItemContiner().getItemIds()) {
        System.out.println("item ids: " + i.toString());
    }
    grid.setContainerDataSource(getItemContiner());
    grid.setSelectable(true);
    grid.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            final String valueString = String.valueOf(valueChangeEvent.getProperty().getValue());
            Notification.show("Value changed:", valueString, Notification.Type.TRAY_NOTIFICATION);
        }
    });
    sample.setFirstComponent(grid);

    setContent(sample);

    //            Main window is the primary browser window
    final Window main = new Window("Hello window");
    addWindow(main);
    // "Hello world" text is added to window as a Label component
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user != null) {
        String email = user.getEmail();
    } else {
        // no user logged in
    }
    assert user != null;

    main.setContent(new Label(user.getUserId()));
}

From source file:info.joseluismartin.gtc.admin.AdminApplication.java

License:Apache License

/**
 * {@inheritDoc}/*www  .j  a  va 2s  . c om*/
 */
@Override
public void init() {
    ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(
            ((WebApplicationContext) getContext()).getHttpSession().getServletContext());
    TilaGuiFactory guiFactory = (TilaGuiFactory) ctx.getBean("guiFactory");
    setTheme("tila");
    Window mainWindow = new Window("Tila Administration");
    CustomLayout cl = new CustomLayout("main");
    Component main = guiFactory.getComponent("main");
    cl.addComponent(main, "main");
    cl.setSizeFull();
    mainWindow.setContent(cl);
    setMainWindow(mainWindow);
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

public void showInWindow(String caption, Component vaadinComponent, Window.CloseListener closeListener) {

    // Create a sub-window and set the content
    Window subWindow = new Window(caption);

    subWindow.setContent(vaadinComponent);

    if (closeListener != null)
        subWindow.addCloseListener(closeListener);

    // Center it in the browser window
    subWindow.center();/*from  w w  w. ja va  2s  . co  m*/

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

}