List of usage examples for com.vaadin.ui Window bringToFront
Integer bringToFront
To view the source code for com.vaadin.ui Window bringToFront.
Click Source Link
From source file:kn.uni.gis.ui.GameApplication.java
License:Apache License
private Window createGameWindow() { tabsheet = new TabSheet(); tabsheet.setImmediate(true);/*ww w . j a va 2s . 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:org.vaadin.addons.serverpush.samples.chat.ManualPushChatApplication.java
License:Apache License
private void fireLoginWindow() { final Window window = new Window("Login"); window.setModal(true);/*from ww w. ja v a 2 s .co m*/ window.setWidth("640px"); window.setHeight("480px"); LoginForm loginForm = new LoginForm(); loginForm.setSizeFull(); loginForm.addListener(new LoginForm.LoginListener() { public void onLogin(LoginForm.LoginEvent event) { doLogin(event); getMainWindow().removeWindow(window); } }); window.setContent(loginForm); getMainWindow().addWindow(window); window.bringToFront(); }