List of usage examples for com.google.gwt.user.client.ui RootPanel get
public static RootPanel get(String id)
From source file:anagram.client.GwtCanvasDemo.java
License:Apache License
public void onModuleLoad() { canvas = Canvas.createIfSupported(); backBuffer = Canvas.createIfSupported(); if (canvas == null) { RootPanel.get(holderId).add(new Label(upgradeMessage)); return;// w ww. j a v a2 s. c o m } // init the canvases canvas.setWidth(width + "px"); canvas.setHeight(height + "px"); canvas.setCoordinateSpaceWidth(width); canvas.setCoordinateSpaceHeight(height); backBuffer.setCoordinateSpaceWidth(width); backBuffer.setCoordinateSpaceHeight(height); RootPanel.get(holderId).add(canvas); context = canvas.getContext2d(); backBufferContext = backBuffer.getContext2d(); // init the objects logoGroup = new LogoGroup(width, height, 18, 165); ballGroup = new BallGroup(width, height); lens = new Lens(35, 15, width, height, new Vector(320, 150), new Vector(1, 1)); // init handlers initHandlers(); // setup timer final Timer timer = new Timer() { @Override public void run() { doUpdate(); } }; timer.scheduleRepeating(refreshRate); }
From source file:asquare.gwt.tests.clientcoords.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel.get("outer").add(new Label("Event client position")); final TextArea output = new TextArea(); RootPanel.get("outer").add(output); Event.addNativePreviewHandler(new Event.NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONMOUSEDOWN) { NativeEvent nativeEvent = event.getNativeEvent(); output.setText("clientX=" + nativeEvent.getClientX() + ", clientY=" + nativeEvent.getClientY()); }/*from w w w. j av a 2s.c o m*/ } }); }
From source file:asquare.gwt.tests.focusevent.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel.get("gwt").add(createDemoPanel()); }
From source file:au.com.uptick.serendipity.client.MultiPageEntryPoint.java
License:Open Source License
private void onModuleLoad2() { try {/*from ww w . jav a 2s. co m*/ if (!Log.isLoggingEnabled()) { Window.alert("Logging is disabled."); } // Use a code guard e.g. "if (Log.isDebugEnabled() {...}" // to ensure unnecessary code is complied out when log_level=OFF // or any log_level higher than DEBUG if (Log.isDebugEnabled()) { startTimeMillis = System.currentTimeMillis(); } // No code guard necessary as the code will be // complied out when log_level=OFF Log.debug("onModuleLoad2()"); // inject global styles GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected(); // load constants constants = (SerendipityConstants) GWT.create(SerendipityConstants.class); // load messages messages = (SerendipityMessages) GWT.create(SerendipityMessages.class); // this is required by gwt-platform proxy's generator DelayedBindRegistry.bind(ginjector); // get Host Page name Dictionary dictionary = Dictionary.getDictionary("Pages"); revealCurrentPlace(dictionary.get("page")); // hide the animated 'loading.gif' RootPanel.get("loading").setVisible(false); // Use a code guard e.g. "if (Log.isDebugEnabled() {...}" // to ensure unnecessary code is complied out when log_level=OFF // or any log_level higher than DEBUG if (Log.isDebugEnabled()) { long endTimeMillis = System.currentTimeMillis(); float durationSeconds = (endTimeMillis - startTimeMillis) / 1000F; Log.debug("Duration: " + durationSeconds + " seconds"); } } catch (Exception e) { Log.error("e: " + e); e.printStackTrace(); Window.alert(e.getMessage()); } }
From source file:bingo.client.Bingo.java
License:Open Source License
/** * This is the entry point method.//from w w w . ja v a2s . com */ public void onModuleLoad() { Label titleLabel = new Label(); titleLabel.setText(strings.title()); RootPanel.get("title").add(titleLabel); // This is the general notification text box RootPanel.get("message").add(message); // Cheking if the user has already an user id final String cookie = Cookies.getCookie(COOKIE_ID); // Validating the cookie bingoService.statusUserId(cookie, new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); Cookies.removeCookie(COOKIE_ID); } @Override public void onSuccess(Integer status) { // TODO: Control the logged status (I should not get a user if s/he is already logged) if (status.intValue() == BingoService.NO_LOGGED || status.intValue() == BingoService.LOGGED) { bingoService.getUserId(new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { message.setText(strings.errorUserCreation()); } @Override public void onSuccess(String result) { userId = result; } }); message.setHTML(""); // Showing image to enter ImageResource imageResource = BingoResources.INSTANCE.entry(); Image entryImage = new Image(imageResource.getSafeUri()); RootPanel.get("buttons").add(entryImage); // Selecting behavior (admin / voter) HorizontalPanel entryPoint = new HorizontalPanel(); entryPoint.setStyleName("mainSelectorPanel"); entryPoint.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); entryPoint.setSpacing(50); // // CREATING A BINGO // VerticalPanel leftPanel = new VerticalPanel(); leftPanel.setStyleName("selectorPanel"); Label leftPanelTitle = new Label(); leftPanelTitle.setStyleName("selectorPanelTitle"); leftPanelTitle.setText(strings.leftPanelTitle()); leftPanel.add(leftPanelTitle); leftPanel.setCellHorizontalAlignment(leftPanelTitle, HasHorizontalAlignment.ALIGN_CENTER); Grid leftSubPanel = new Grid(2, 2); leftSubPanel.setWidget(0, 0, new Label(strings.createBingoName())); final TextBox bingoNameBox = new TextBox(); leftSubPanel.setWidget(0, 1, bingoNameBox); leftSubPanel.setWidget(1, 0, new Label(strings.createBingoPassword())); final PasswordTextBox bingoPasswordBox = new PasswordTextBox(); leftSubPanel.setWidget(1, 1, bingoPasswordBox); leftPanel.add(leftSubPanel); final Button createButton = new Button("Create"); createButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { bingoService.createBingo(userId, bingoNameBox.getText(), bingoPasswordBox.getText(), new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(final String gameId) { final BingoGrid bingoGrid = new BingoGrid(); initAdminGrid(userId, bingoGrid, false); RootPanel.get("bingoTable").clear(); RootPanel.get("bingoTable").add(bingoGrid); message.setText(strings.welcomeMessageCreation()); // Setting the cookie Date expirationDate = new Date(); expirationDate.setHours(expirationDate.getHours() + EXPIRATION_VALUE); Cookies.setCookie(COOKIE_ID, userId, expirationDate); } }); } }); leftPanel.add(createButton); leftPanel.setCellHorizontalAlignment(createButton, HasHorizontalAlignment.ALIGN_CENTER); entryPoint.add(leftPanel); // // JOINING // VerticalPanel rightPanel = new VerticalPanel(); rightPanel.setStyleName("selectorPanel"); Label rightPanelTitle = new Label(); rightPanelTitle.setStyleName("selectorPanelTitle"); rightPanelTitle.setText(strings.rightPanelTitle()); rightPanel.add(rightPanelTitle); rightPanel.setCellHorizontalAlignment(rightPanelTitle, HasHorizontalAlignment.ALIGN_CENTER); Grid rightSubPanel = new Grid(2, 2); rightSubPanel.setWidget(0, 0, new Label(strings.joinToBingoName())); final ListBox joinExistingBingoBox = new ListBox(); bingoService.getBingos(new AsyncCallback<String[][]>() { @Override public void onFailure(Throwable caught) { joinExistingBingoBox.addItem(strings.noBingos()); } @Override public void onSuccess(String[][] result) { if (result == null) { joinExistingBingoBox.addItem(strings.noBingos()); } else { for (int i = 0; i < result.length; i++) { String gameName = result[i][0]; String gameId = result[i][1]; joinExistingBingoBox.addItem(gameName, gameId); } } } }); rightSubPanel.setWidget(0, 1, joinExistingBingoBox); rightSubPanel.setWidget(1, 0, new Label(strings.joinToBingoPassword())); final PasswordTextBox joinBingoPasswordBox = new PasswordTextBox(); rightSubPanel.setWidget(1, 1, joinBingoPasswordBox); rightPanel.add(rightSubPanel); final Button joinButton = new Button("Join"); joinButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { int index = joinExistingBingoBox.getSelectedIndex(); if (index < 0) message.setText(strings.noSelectedItem()); else { final String gameId = joinExistingBingoBox.getValue(index); if (gameId == null) message.setText(strings.noSelectedItem()); else { bingoService.joinBingo(userId, gameId, joinBingoPasswordBox.getText(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(Void result) { final BingoGrid bingoGrid = new BingoGrid(); initUserGrid(bingoGrid); RootPanel.get("bingoTable").clear(); RootPanel.get("bingoTable").add(bingoGrid); message.setText(strings.welcomeMessageJoin()); // Setting the cookie Date expirationDate = new Date(); expirationDate .setHours(expirationDate.getHours() + EXPIRATION_VALUE); Cookies.setCookie(COOKIE_ID, userId, expirationDate); } }); } } } }); rightPanel.add(joinButton); rightPanel.setCellHorizontalAlignment(joinButton, HasHorizontalAlignment.ALIGN_CENTER); entryPoint.add(rightPanel); RootPanel.get("bingoTable").add(entryPoint); } else if (status.intValue() == BingoService.ADMIN) { message.setText("Detected cookie: " + cookie + " as admin"); userId = cookie; bingoService.statusBingo(userId, new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(Integer result) { int status = result.intValue(); final BingoGrid bingoGrid = new BingoGrid(); if (status == BingoService.RUNNING) { initAdminGrid(userId, bingoGrid, false); message.setText(strings.welcomeMessageCreation()); } else if (status == BingoService.FINISHED) { initAdminGrid(userId, bingoGrid, true); message.setText(strings.finishMessage()); } RootPanel.get("bingoTable").clear(); RootPanel.get("bingoTable").add(bingoGrid); } }); } else if (status.intValue() == BingoService.PARTICIPANT) { message.setText("Detected cookie: " + cookie + " as participant"); userId = cookie; final BingoGrid bingoGrid = new BingoGrid(); initUserGrid(bingoGrid); updateUserGrid(bingoGrid, null); RootPanel.get("bingoTable").clear(); RootPanel.get("bingoTable").add(bingoGrid); } } }); }
From source file:bingo.client.Bingo.java
License:Open Source License
private void initAdminGrid(final String userId, final BingoGrid bingoGrid, final boolean hasFinished) { final Timer timer = new Timer() { int totalParticipants = 0; @Override/*w ww. ja va 2 s.c o m*/ public void run() { bingoService.getTotalParticipants(userId, new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Integer result) { totalParticipants = result.intValue(); } }); bingoService.getVotes(userId, new AsyncCallback<int[][]>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(int[][] result) { if (result == null) { result = new int[BingoGrid.ROW][BingoGrid.COL]; for (int i = 0; i < BingoGrid.ROW; i++) for (int j = 0; j < BingoGrid.COL; j++) result[i][j] = 0; } for (int row = 0; row < BingoGrid.ROW; ++row) for (int col = 0; col < BingoGrid.COL; ++col) { bingoGrid.setVoteString(row, col, String.valueOf(result[row][col]), String.valueOf(totalParticipants)); } } }); } }; // If the game is not finished, repeat; if so, run once if (!hasFinished) timer.scheduleRepeating(ADMIN_TIMER); else timer.run(); HorizontalPanel panel = new HorizontalPanel(); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); final Button finishButton = new Button(); // If the game is not finished, allow finishing it; if so, allow download data if (!hasFinished) finishButton.setText(strings.finishBingo()); else finishButton.setText(strings.download()); finishButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!hasFinished) bingoService.finishBingo(userId, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(Void result) { message.setText(strings.finishedBingo()); finishButton.setText(strings.download()); timer.cancel(); } }); bingoService.getVotes(userId, new AsyncCallback<int[][]>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(int[][] result) { // Create a popup dialog box final DialogBox box = new DialogBox(); box.setText(strings.info()); box.setAnimationEnabled(true); final Button boxAcceptButton = new Button(strings.accept()); boxAcceptButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { box.hide(); } }); Label boxLabel = new Label(); boxLabel.setText(strings.finishMessage()); HTML voteData = new HTML(); if (result == null) { result = new int[BingoGrid.ROW][BingoGrid.COL]; for (int i = 0; i < BingoGrid.ROW; i++) for (int j = 0; j < BingoGrid.COL; j++) result[i][j] = 0; } String cellKey = ""; String cellString = ""; String voteDataString = ""; for (int row = 0; row < BingoGrid.ROW; ++row) for (int col = 0; col < BingoGrid.COL; ++col) { cellKey = "cell" + row + col; cellString = strings.map().get(cellKey); voteDataString += " " + cellString + " = " + result[row][col] + "<br>"; } voteData.setHTML(voteDataString); voteData.addStyleName("boxData"); VerticalPanel boxPanel = new VerticalPanel(); boxPanel.addStyleName("boxPanel"); boxPanel.add(boxLabel); boxPanel.add(voteData); HorizontalPanel buttonsPanel = new HorizontalPanel(); buttonsPanel.add(boxAcceptButton); boxPanel.add(buttonsPanel); boxPanel.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_CENTER); box.setWidget(boxPanel); box.center(); } }); } }); panel.add(finishButton); final Button terminateButton = new Button(strings.terminateButton()); terminateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Create a popup dialog box final DialogBox box = new DialogBox(); box.setText(strings.warning()); box.setAnimationEnabled(true); final Button boxCancelButton = new Button(strings.cancel()); boxCancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { box.hide(); } }); final Button boxAcceptButton = new Button(strings.accept()); boxAcceptButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { bingoService.terminateBingo(userId, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { message.setText(caught.getMessage()); } @Override public void onSuccess(Void result) { message.setText(strings.terminatedBingo()); timer.cancel(); } }); box.hide(); } }); final Label boxLabel = new Label(); boxLabel.setText(strings.terminateMessage()); VerticalPanel boxPanel = new VerticalPanel(); boxPanel.addStyleName("boxPanel"); boxPanel.add(boxLabel); HorizontalPanel buttonsPanel = new HorizontalPanel(); buttonsPanel.add(boxCancelButton); buttonsPanel.add(boxAcceptButton); boxPanel.add(buttonsPanel); box.setWidget(boxPanel); box.center(); } }); panel.add(terminateButton); RootPanel.get("buttons").clear(); RootPanel.get("buttons").add(panel); }
From source file:bingo.client.Bingo.java
License:Open Source License
private void initUserGrid(final BingoGrid bingoGrid) { bingoGrid.addClickHandler(new ClickHandler() { @Override/*from ww w.java 2 s .com*/ public void onClick(ClickEvent event) { Cell cell = bingoGrid.getCellForEvent(event); if (cell != null) { final int row = cell.getRowIndex(); final int col = cell.getCellIndex(); if (!bingoGrid.cellHasBeenVoted(row, col)) { bingoGrid.voteForCell(row, col); bingoService.voteCell(userId, row, col, new AsyncCallback<Long>() { @Override public void onFailure(Throwable caught) { message.setText(strings.errorUserVote()); bingoGrid.voteAgainstCell(row, col); } @Override public void onSuccess(Long result) { // For now, no control of lines completed // bingoGrid.colorLines(result); } }); } else { message.setText(strings.alreadyVoted()); } } } }); Timer timer = new Timer() { @Override public void run() { updateUserGrid(bingoGrid, this); } }; timer.scheduleRepeating(USER_TIMER); RootPanel.get("buttons").clear(); }
From source file:br.org.olimpiabarbacena.client.Principal.java
License:Apache License
@Override public void onModuleLoad() { this.pesquisar = new Pesquisar(this); // FIX: Caused by: java.lang.NullPointerException // at/*from w w w . j a v a2 s.c o m*/ // br.org.olimpiabarbacena.client.Menu.onLinkAcervoClick(Menu.java:50) // at br.org.olimpiabarbacena.client.Menu.(Menu.java:38) // at // br.org.olimpiabarbacena.client.Principal.onModuleLoad(Principal.java:14) // ... 9 more this.menu = new Menu(this); this.controle = new Controle(this); RootPanel.get("content").add(menu); RootPanel.get("content").add(pesquisar); RootPanel.get("content").add(controle); }
From source file:br.usp.icmc.gazetteer.client.view.impl.Mapa.java
License:Apache License
@SuppressWarnings("deprecation") public void buildPanel() { System.out.println("INICIO"); MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setNumZoomLevels(16); //Create a MapWidget and add 2 OSM layers MapWidget mapWidget = new MapWidget(this.getParent().getOffsetWidth() + "px", this.getParent().getOffsetHeight() + "px", defaultMapOptions); GoogleV3Options gSatelliteOptions = new GoogleV3Options(); gSatelliteOptions.setIsBaseLayer(true); gSatelliteOptions.setType(GoogleV3MapType.G_HYBRID_MAP); final GoogleV3 gSatellite = new GoogleV3("Google Satellite", gSatelliteOptions); //MAP SERVERS final OSM osm_1 = OSM.Mapnik("Mapnik"); final OSM osm_2 = OSM.CycleMap("CycleMap"); osm_1.setIsBaseLayer(true);/*w w w .j a v a2s .c o m*/ osm_2.setIsBaseLayer(true); gSatellite.setIsBaseLayer(true); map = mapWidget.getMap(); map.addLayer(gSatellite); map.addLayer(osm_2); map.addLayer(osm_1); //ADD POINTS LAYER vectorFeature = new Vector("popups"); map.addLayer(vectorFeature); //Lets add some default controls to the map map.addControl(new LayerSwitcher()); //+ sign in the upperright corner to display the layer switcher map.addControl(new OverviewMap()); //+ sign in the lowerright to display the overviewmap map.addControl(new ScaleLine()); //Display the scaleline /** * Mouse position in map */ MousePositionOutput mpOut = new MousePositionOutput() { @Override public String format(LonLat lonLat, Map map) { lonLat.transform(map.getProjection(), DEFAULT_PROJECTION.getProjectionCode()); //transform lonlat to OSM coordinate system String out = ""; if (map.getBaseLayer().getId().equals(gSatellite.getId()) || map.getBaseLayer().getId().equals(osm_2.getId())) { out += "<p id=\"mouseCoord\"> "; out += lonLat.lat(); out += " "; out += lonLat.lon() + "</p>"; } else { out += "<p id=\"normCoord\"> "; out += lonLat.lat(); out += " "; out += lonLat.lon() + "</p>"; } return out; } }; MousePositionOptions mpOptions = new MousePositionOptions(); mpOptions.setFormatOutput(mpOut); // rename to setFormatOutput map.addControl(new MousePosition(mpOptions)); //Center and zoom to a location LonLat lonLat = new LonLat(-58, -4);//6.95, 50.94); lonLat.transform(DEFAULT_PROJECTION.getProjectionCode(), map.getProjection()); //transform lonlat to OSM coordinate system map.setCenter(lonLat, 5); mapWidget.getElement().getFirstChildElement().getStyle().setZIndex(0); //force the map to fall behind popups if (points.size() > 0) BuildCluster(); addButtons(); panel_map.add(mapWidget); System.out.println("FIM"); panel_map.addStyleName("#mapa"); DOM.setInnerHTML(RootPanel.get("Loading-Message").getElement(), ""); }
From source file:bufferings.ktr.wjr.client.KtrWjr.java
License:Apache License
/** * {@inheritDoc}/*ww w . j a v a 2s. co m*/ */ public void onModuleLoad() { KtrWjrServiceAsync rpcService = new KtrWjrJsonServiceAsync(); WjrPresenter presenter = new WjrPresenter(rpcService, new WjrLoadingView(), new WjrView()); RootPanel initialPanel = RootPanel.get(INITIAL_PANEL_ID); if (initialPanel != null) { initialPanel.getElement().removeFromParent(); } presenter.go(RootLayoutPanel.get()); }