List of usage examples for com.google.gwt.user.client Window addResizeHandler
public static HandlerRegistration addResizeHandler(ResizeHandler handler)
From source file:com.google.livingstories.client.ui.AnchoredPanel.java
License:Apache License
@Override public void setWidget(Widget widget) { super.setWidget(widget); Style style = widget.getElement().getStyle(); style.setProperty("position", "relative"); style.setPropertyPx("left", 0); style.setPropertyPx("top", 0); removeHandlers();/* w ww .j a v a 2s . c om*/ scrollHandler = Window.addWindowScrollHandler(new ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { reposition(); } }); resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { reposition(); } }); }
From source file:com.google.livingstories.client.ui.GlassPanel.java
License:Apache License
public GlassPanel() { glass = new SimplePanel(); glass.setStylePrimaryName("fixedGlass"); Element element = glass.getElement(); DOM.setStyleAttribute(element, "backgroundColor", "#000000"); DOM.setStyleAttribute(element, "opacity", "0.50"); DOM.setStyleAttribute(element, "MozOpacity", "0.50"); DOM.setStyleAttribute(element, "filter", "alpha(opacity=50)"); glass.setVisible(false);/* w w w . java2s . co m*/ initWidget(glass); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (isVisible()) { sizeToDocument(); if (timer != null) { timer.cancel(); } // We need to call sizeToDocument() a second time, asynchronously, to get inappropriate // scrollbars to disappear when making the window smaller. We do this with a small // timeout, though, so as not to repeatedly call extra sizeToDocument over // the course of a drag. timer = new Timer() { @Override public void run() { // the size actually has to change to get the layout to reflow... glass.setSize("1px", "1px"); sizeToDocument(); timer = null; } }; timer.schedule(100); } } }); }
From source file:com.google.mobile.trippy.web.client.view.MenuView.java
License:Apache License
public MenuView() { initWidget(uiBinder.createAndBindUi(this)); menuPopUp.setModal(true);/*from w w w.j ava 2s . com*/ menuPopUp.setGlassEnabled(true); menuPopUp.removeFromParent(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (menuPopUp.isShowing()) { menuPopUp.center(); } } }); }
From source file:com.google.mobile.trippy.web.client.view.SearchResultsMapView.java
License:Apache License
public SearchResultsMapView() { super();//from w w w. j a va2s . co m initWidget(uiBinder.createAndBindUi(this)); //TODO :Its just remove the tabindex from DOM. But need to find //the alternative approach. nextItem.getElement().getChild(nextItem.getTabIndex()).removeFromParent(); prevItem.getElement().getChild(prevItem.getTabIndex()).removeFromParent(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { mapView.setHeight((Window.getClientHeight() - 74) + "px"); } }); mapView.setHeight((Window.getClientHeight() - 74) + "px"); }
From source file:com.google.mobile.trippy.web.client.view.TripEditPopupView.java
License:Apache License
public TripEditPopupView() { initWidget(uiBinder.createAndBindUi(this)); tripEditPopup.setGlassEnabled(true); Window.addResizeHandler(new ResizeHandler() { @Override/*from w ww . j av a2 s . c om*/ public void onResize(ResizeEvent event) { if (tripEditPopup.isShowing()) { tripEditPopup.center(); } } }); KeyPressHandler keyPressHandler = new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { NativeEvent clickEvent = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false); btnSave.getElement().dispatchEvent(clickEvent); } } }; displayTripName.addKeyPressHandler(keyPressHandler); durationField.addKeyPressHandler(keyPressHandler); }
From source file:com.google.mobile.trippy.web.client.view.TripListFilterView.java
License:Apache License
public TripListFilterView() { initWidget(uiBinder.createAndBindUi(this)); searchPopUp.setGlassEnabled(true);/*from w w w .j av a2s . co m*/ final KeyboardListener onEnter = new KeyboardListener() { @Override public void onKeyUp(Widget sender, char keyCode, int modifiers) { //No-ops. } @Override public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ENTER) { NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false); searchButton.getElement().dispatchEvent(evt); } } @Override public void onKeyDown(Widget sender, char keyCode, int modifiers) { //No-ops. } }; searchBox.addKeyboardListener(onEnter); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { if (searchPopUp.isShowing()) { searchPopUp.center(); } } }); }
From source file:com.google.mobile.trippy.web.client.view.TripMapView.java
License:Apache License
public TripMapView() { super();/*from w w w . j a v a 2s . com*/ initWidget(uiBinder.createAndBindUi(this)); //TODO :Its just remove the tabindex from DOM. But need to find //the alternative approach. nextItem.getElement().getChild(nextItem.getTabIndex()).removeFromParent(); prevItem.getElement().getChild(prevItem.getTabIndex()).removeFromParent(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { mapView.setHeight((Window.getClientHeight() - 74) + "px"); } }); mapView.setHeight((Window.getClientHeight() - 74) + "px"); }
From source file:com.google.sampling.experiential.client.ChartPanel.java
License:Open Source License
private Widget renderEventsOnMap() { markers.clear();//from w w w . j a va 2 s. co m createMap(); final LatLngBounds bounds = LatLngBounds.newInstance(google, google); for (final EventDAO event : data) { String latLon = event.getWhatByKey(input.getName()); if (latLon == null || latLon.length() == 0) { continue; } String[] splits = latLon.split(","); if (splits == null || splits.length != 2) { continue; } try { double latitude = Double.parseDouble(splits[0]); double longitude = Double.parseDouble(splits[1]); MarkerOptions markerOptions = MarkerOptions.newInstance(); markerOptions.setMap(map); markerOptions.setTitle(event.getWhatString()); LatLng newInstance = LatLng.newInstance(latitude, longitude); final Marker marker = Marker.newInstance(markerOptions); marker.setPosition(newInstance); bounds.union(LatLngBounds.newInstance(marker.getPosition(), marker.getPosition())); marker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent mapEvent) { openInfoWindowForMarker(event, marker); } }); markers.put(event, marker); } catch (NumberFormatException nfe) { } } map.fitBounds(bounds); final LatLng oldCenter = map.getCenter(); final int oldZoom = map.getZoom(); map.addResizeHandler(new ResizeMapHandler() { @Override public void onEvent(ResizeMapEvent event) { map.setCenter(oldCenter); map.setZoom(oldZoom); map.fitBounds(bounds); } }); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { MapHandlerRegistration.trigger(map, MapEventType.RESIZE); GWT.log("Window has been resized!"); } }); return map; }
From source file:com.google.speedtracer.latencydashboard.client.MarkTimelineLatencyDashboard.java
License:Apache License
private void createDashboardUi() { refreshButton.getElement().getStyle().setMarginLeft(3, Unit.EM); refreshButton.setEnabled(false);//from w w w. j a v a 2 s . com refreshButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { populateDashboard(); } }); VisualizationUtils.loadVisualizationApi(new Runnable() { /** * Load data from the server. */ public void run() { refreshButton.setEnabled(true); createCharts(); populateDashboard(); RootPanel.get().add(refreshButton); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { populateDashboard(); } }); } }, AreaChart.PACKAGE, LineChart.PACKAGE, PieChart.PACKAGE, Gauge.PACKAGE); }
From source file:com.google.webcourse.picasaapp.client.PicasaApp.java
License:Apache License
/** * This is the entry point method./*from w w w . j a v a 2 s . c o m*/ */ public void onModuleLoad() { LoadAlbumsForm loadAlbumsForm = new LoadAlbumsForm(); CommentSubmitForm commentSubmitForm = new CommentSubmitForm(); thumbnailList = RootPanel.get("thumbnailList"); photoView = new PhotoView(); commentsPanel = new CommentsPanel(); RootPanel.get("loadAlbumsForm").add(loadAlbumsForm); RootPanel.get("photoWrapper").add(photoView); RootPanel.get("comments").add(commentsPanel); RootPanel.get("comments").add(commentSubmitForm); loadAlbumsForm.setLoadAlbumListener(new LoadAlbumsListener() { public void loadAlbums(String username) { loadAlbumsOfUser(username); } }); commentSubmitForm.setCommentSubmitHandler(new CommentSubmitHandler() { public void submitComment(String comment) { commentService.storeComment(currentPhotoUrl, comment, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { // TODO: Show an error message } public void onSuccess(Void result) { loadComments(currentPhotoUrl); } }); } }); // Make sure the thumbnail list has always the correct height, as // height=100% doesn't work properly. Window.addResizeHandler(this); Window.addWindowScrollHandler(new ScrollHandler() { public void onWindowScroll(ScrollEvent event) { onResize(null); } }); onResize(null); }