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:kg.cloud.tuscon.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    setTheme("contacts");

    this.getContext().addTransactionListener(this);
    this.window = new Window("PIM");
    this.setMainWindow(window);
    viewManager = new ViewManager(window);
    viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen(this));
}

From source file:kg.cloud.uims.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    setTheme("last_cham");
    final ResourceBundle i18n = ResourceBundle.getBundle(UimsMessages.class.getName(), getLocale());
    this.getContext().addTransactionListener(this);
    this.window = new Window(i18n.getString(UimsMessages.AppTitle));
    this.setMainWindow(window);
    viewManager = new ViewManager(window);
    viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen(this));
}

From source file:kn.uni.gis.ui.GameApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("Fox and Hunter - Der Kohl sei mit euch!");
    setMainWindow(window);//from   w ww  .  j  a va2 s. c o m
    VerticalLayout verticalLayout = new VerticalLayout();

    map = getMap();

    window.setContent(verticalLayout);

    verticalLayout.setSizeFull();
    verticalLayout.addComponent(map);
    verticalLayout.setExpandRatio(map, 1);

    window.addWindow(createGameWindow());
    window.addWindow(createDownloadWindow());

    pi.setIndeterminate(true);
    pi.setPollingInterval(1000 / FPS);
    pi.setVisible(false);

}

From source file:kn.uni.gis.ui.GameApplication.java

License:Apache License

private Window createGameWindow() {

    tabsheet = new TabSheet();
    tabsheet.setImmediate(true);//  w ww.  ja  va2s .co m
    tabsheet.setCloseHandler(new CloseHandler() {
        @Override
        public void onTabClose(TabSheet tabsheet, Component tabContent) {

            Game game = ((GameComposite) tabContent).getGame();

            GameComposite remove = gameMap.remove(game);

            // closes the game and the running thread!
            remove.getLayer().handleApplicationClosedEvent(new ApplicationClosedEvent());

            eventBus.unregister(remove);
            eventBus.unregister(remove.getLayer());

            map.removeLayer(remove.getLayer());

            tabsheet.removeComponent(tabContent);

            if (gameMap.isEmpty()) {
                pi.setVisible(false);
            }
        }
    });

    final Window mywindow = new Window("Games");
    mywindow.setPositionX(0);
    mywindow.setPositionY(0);
    mywindow.setHeight("50%");
    mywindow.setWidth("25%");
    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout lay = new HorizontalLayout();

    final Button button_1 = new Button();
    button_1.setCaption("Open Game");
    button_1.setWidth("-1px");
    button_1.setHeight("-1px");

    button_1.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            final String id = textField_1.getValue().toString();

            if (id.length() < 5) {
                window.showNotification("id must have at least 5 characters", Notification.TYPE_ERROR_MESSAGE);
            } else {
                String sql = String.format("select player_id,player_name,min(timestamp),max(timestamp) from %s"
                        + " where id LIKE ? group by player_id, player_name", GisResource.FOX_HUNTER);

                final Game game = new Game(id);
                final PreparedStatement statement = geoUtil.getConn()
                        .prepareStatement("select poly_geom,timestamp from " + GisResource.FOX_HUNTER
                                + " where id LIKE ? and player_id=? and timestamp > ? order by timestamp LIMIT "
                                + MAX_STATES_IN_MEM);

                try {
                    geoUtil.getConn().executeSafeQuery(sql, new DoWithin() {

                        @Override
                        public void doIt(ResultSet executeQuery) throws SQLException {

                            while (executeQuery.next()) {
                                if (statement == null) {

                                }
                                String playerId = executeQuery.getString(1);
                                Timestamp min = executeQuery.getTimestamp(3);
                                Timestamp max = executeQuery.getTimestamp(4);
                                game.addPlayer(playerId, executeQuery.getString(2), min, max,
                                        new TimingIterator(geoUtil, id, playerId, min.getTime(), statement));
                            }
                        }
                    }, id + "%");
                } catch (SQLException e) {
                    LOGGER.info("error on sql!", e);

                }

                game.finish(statement);

                if (!!!gameMap.containsKey(game)) {
                    if (game.getStates().size() == 0) {
                        window.showNotification("game not found!");
                    } else {
                        LOGGER.info("received game info: {},{} ", game.getId(), game.getStates().size());

                        GameVectorLayer gameVectorLayer = new GameVectorLayer(GameApplication.this, eventBus,
                                game, createColorMap(game));

                        final GameComposite gameComposite = new GameComposite(GameApplication.this, game,
                                gameVectorLayer, eventBus);

                        eventBus.register(gameComposite);
                        eventBus.register(gameVectorLayer);

                        map.addLayer(gameVectorLayer);
                        gameMap.put(game, gameComposite);

                        // Add the component to the tab sheet as a new tab.
                        Tab addTab = tabsheet.addTab(gameComposite);
                        addTab.setCaption(game.getId().substring(0, 5));
                        addTab.setClosable(true);

                        pi.setVisible(true);
                        // pl.get
                        PlayerState playerState = game.getStates().get(game.getFox()).peek();
                        map.zoomToExtent(new Bounds(CPOINT_TO_POINT.apply(playerState.getPoint())));
                    }
                }
            }
        }

        private Map<Player, Integer> createColorMap(Game game) {
            Function<Double, Double> scale = HardTasks.scale(0, game.getStates().size());

            ImmutableMap.Builder<Player, Integer> builder = ImmutableMap.builder();

            int i = 0;

            for (Player play : game.getStates().keySet()) {
                builder.put(play, getColor(scale.apply((double) i++)));
            }

            return builder.build();
        }

        private Integer getColor(double dob) {

            int toReturn = 0;
            toReturn = toReturn | 255 - (int) Math.round(255 * dob);
            toReturn = toReturn | (int) ((Math.round(255 * dob)) << 16);
            return toReturn;
            // return (int) (10000 + 35000 * dob + 5000 * dob + 1000 * dob +
            // 5 * dob);
        }

    });

    Button button_2 = new Button();
    button_2.setCaption("All seeing Hunter");
    button_2.setImmediate(false);
    button_2.setWidth("-1px");
    button_2.setHeight("-1px");
    button_2.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (adminWindow == null) {
                adminWindow = new AdminWindow(password, geoUtil, new ItemClickListener() {
                    @Override
                    public void itemClick(ItemClickEvent event) {

                        textField_1.setValue(event.getItemId().toString());
                        mywindow.bringToFront();
                        button_1.focus();
                    }
                });
                window.addWindow(adminWindow);
                adminWindow.setWidth("30%");
                adminWindow.setHeight("40%");
                adminWindow.addListener(new CloseListener() {
                    @Override
                    public void windowClose(CloseEvent e) {
                        adminWindow = null;
                    }
                });
            }
        }
    });

    lay.addComponent(button_1);
    textField_1 = new TextField();
    textField_1.setImmediate(false);
    textField_1.setWidth("-1px");
    textField_1.setHeight("-1px");
    lay.addComponent(textField_1);
    lay.addComponent(button_2);
    lay.addComponent(pi);

    lay.setComponentAlignment(pi, Alignment.TOP_RIGHT);

    layout.addComponent(lay);
    layout.addComponent(tabsheet);

    mywindow.addComponent(layout);
    mywindow.setClosable(false);

    /* Add the window inside the main window. */
    return mywindow;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);/*  w  w  w. j  a  v a 2  s.c om*/
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getWindowPreviews() {
    Layout grid = getPreviewLayout("Windows");

    Button win = new Button("Open normal sub-window", new Button.ClickListener() {
        @Override/* ww  w.ja v a 2 s  .  c o  m*/
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(new Window("Normal window"));
        }
    });
    grid.addComponent(win);
    win.setDescription("new Window()");

    win = new Button("Open opaque sub-window", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Window w = new Window("Window.addStyleName(\"opaque\")");
            w.addStyleName("opaque");
            getApplication().getMainWindow().addWindow(w);
        }
    });
    grid.addComponent(win);
    win.setDescription("Window.addStyleName(\"opaque\")");

    return grid;
}

From source file:myGroup.gwt.client.ui.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    HorizontalSplitPanel sample = new HorizontalSplitPanel();
    sample.setSizeFull();//from  www. ja va 2s .c o  m
    //        sample.setSplitPosition(150.0f, PIXELS);

    sample.setSecondComponent(new Label("korte"));

    setContent(sample);

    Table grid = new Table();

    grid.setSizeFull();
    for (Object i : getItemContiner().getItemIds()) {
        System.out.println(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);

    //            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:net.larbig.ScriptRunnerApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("Scriptrunner");
    setMainWindow(window);/*w  w w  .ja v a2  s.  c  om*/

    VerticalLayout layout = new VerticalLayout();
    final TextField tfDriver = new TextField("Driver");
    tfDriver.setWidth(300, Sizeable.UNITS_PIXELS);
    tfDriver.setValue("com.mysql.jdbc.Driver");
    final TextField tfURL = new TextField("URL");
    tfURL.setWidth(300, Sizeable.UNITS_PIXELS);
    tfURL.setValue("jdbc:mysql://mysql.host.net:3306/datenbank");
    final TextField tfUser = new TextField("User");
    tfUser.setWidth(300, Sizeable.UNITS_PIXELS);
    final TextField tfPasswort = new TextField("Password");
    tfPasswort.setWidth(300, Sizeable.UNITS_PIXELS);
    final TextArea taSQL = new TextArea("SQL");
    taSQL.setWidth(300, Sizeable.UNITS_PIXELS);
    taSQL.setHeight(150, Sizeable.UNITS_PIXELS);

    Button button = new Button("Execute");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {

            try {
                Class.forName((String) tfDriver.getValue()).newInstance();
                Connection con = DriverManager.getConnection(tfURL.getValue().toString(),
                        tfUser.getValue().toString(), tfPasswort.getValue().toString());
                ScriptRunner runner = new ScriptRunner(con, false, true);
                Reader r = new StringReader(taSQL.getValue().toString());
                runner.runScript(r);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });

    layout.addComponent(tfDriver);
    layout.addComponent(tfURL);
    layout.addComponent(tfUser);
    layout.addComponent(tfPasswort);
    layout.addComponent(taSQL);
    layout.addComponent(button);
    window.addComponent(layout);

}

From source file:nl.amc.biolab.nsg.display.VaadinTestApplication.java

License:Open Source License

@Override
public void init() {
    logger.setLevel(Level.DEBUG);

    setErrorHandler(new ErrorListener() {
        private static final long serialVersionUID = -7266040717402386801L;

        @Override/*w  ww . j  av  a2 s . com*/
        public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) {
            if (event.getThrowable().getCause() instanceof InvalidValueException) {
                return;
            }

            logger.error("Error occured");

            event.getThrowable().printStackTrace();
        }
    });

    app.setLogoutURL("/");
    app.setTheme("nsg_theme");

    setMainWindow(new Window("AMC nsg portlet"));
    getMainWindow().setWidth("100%");
    getMainWindow().setHeight("300px");

    // If no user is set do not load the application
    if (getUser() == null) {
        userDataService = null;

        return;
    }

    // If no userDataService is set yet, or the user is not logged in yet
    // Set the userDataService and check XNAT connectivity
    // Parses errors coming back and displays them in the application when necessary
    if (userDataService == null || userDataService.xnatLogin() == false) {
        try {
            setUserDataService(((User) getUser()).getScreenName(), ((User) getUser()).getUserId());

            if (getPage() == DATA && this.getUserDataService() != null
                    && this.getUserDataService().getUserId() == 0L
                    && getUserDataService().getProjectDbId() == null) {
                this.getUserDataService().xnatLogin();
            }
        } catch (RuntimeException e) {
            if (e == null || e.getMessage() == null
                    || (!(e.getMessage().equals("No Password.") && !e.getMessage().equals("Wrong Password.")
                            && !e.getMessage().equals("No User login.")))) {
                HorizontalLayout layout = new HorizontalLayout();

                Label label = new Label("Server error. Please contact the administrator");

                layout.setWidth("100%");
                layout.setHeight("300px");
                layout.removeAllComponents();
                layout.addComponent(label);

                getMainWindow().removeAllComponents();
                getMainWindow().addComponent(layout);

                return;
            } else if (e.getMessage().equals("No Password.") || e.getMessage().equals("Wrong Password.")) {
                getMainWindow().removeAllComponents();
                getMainWindow().showNotification("Please enter your XNAT password");
            } else if (e.getMessage().equals("No User login.")) {
                getMainWindow().showNotification("No User login.");

                HorizontalLayout layout = new HorizontalLayout();

                Label label = new Label("Loading page.");

                layout.setWidth("100%");
                layout.setHeight("300px");
                layout.addComponent(label);

                label = new Label("Please contact the administrator for XNAT user setup");

                layout.removeAllComponents();
                layout.addComponent(label);

                getMainWindow().removeAllComponents();
                getMainWindow().addComponent(layout);

                return;
            }
        }
    }

    processingService = new ProcessingService(userDataService);

    getMainWindow().removeAllComponents();

    this.mainControl = new MainControl(this);

    //        logger.debug("Finished creating the application and the components.");
}

From source file:nl.arnovanoort.vaadintest6.MyVaadinApplication.java

License:Apache License

private void buildMainLayout() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);/* ww w .j  a  v a 2 s  .c  o m*/

    window.setContent(viewStatistics.create());
    /*
     * Set the initial split position so we can have a 200 pixel menu to the
     * left
     */
    horizontalSplit.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
    horizontalSplit.setFirstComponent(tree);
    horizontalSplit.setSecondComponent(searchView.create());

}