List of usage examples for com.google.gwt.user.client Window addResizeHandler
public static HandlerRegistration addResizeHandler(ResizeHandler handler)
From source file:com.ponysdk.ui.terminal.ui.PCScrollPanel.java
License:Apache License
public PCScrollPanel() { Window.addResizeHandler(this); addScrollHandler(this); }
From source file:com.pronoiahealth.olhie.client.features.impl.MainWindowResizeFeature.java
License:Open Source License
/** * Add resize handler and fire windowResizeEvent * // w w w .j av a2s.c om * @see com.pronoiahealth.olhie.client.features.ClientFeature#activate() */ @Override public boolean activate() { windowResizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { windowResizeEvent.fire(new WindowResizeEvent()); } }); return true; }
From source file:com.qualogy.qafe.gwt.client.component.ShowPanelComponent.java
License:Apache License
@Override public void center() { super.center(); if (resizeRegistration == null) { resizeRegistration = Window.addResizeHandler(this); }//from www . j a va 2 s . c o m }
From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java
License:Apache License
@Override public void onModuleLoad() { JSNIUtil.exportQafeFunctions();//from w w w . j av a 2 s . c o m rootPanelValue = JSNIUtil.getScriptParameter(GWT.getModuleName(), JSNIUtil.ROOT_PANEL_PARAM); // inject default qafe-gwt.css Resources.INSTANCE.css().ensureInjected(); // This is same as StyleInjector.inject(Resources.INSTANCE.css().getText()); // now inject the custom css. injectGeneratedCSS(); buildUI(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { moveWidgets(); } }); Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(Window.ClosingEvent closingEvent) { closingEvent.setMessage(WINDOW_CLOSING_MESSAGE); } }); // For reloading of the CSS Element styleElement = DOM.createElement("style"); ClientApplicationContext.getInstance().setStyleElement(styleElement); // workaround for GWT issue 1813 // http://code.google.com/p/google-web-toolkit/issues/detail?id=1813 RootPanel.get(rootPanelValue).getElement().getStyle().setProperty("position", "relative"); // set uncaught exception handler GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable throwable) { Throwable tempThrowable = throwable; StringBuffer text = new StringBuffer("Uncaught exception: " + throwable.getMessage()); while (tempThrowable != null) { StackTraceElement[] stackTraceElements = tempThrowable.getStackTrace(); text.append(tempThrowable.toString() + "\n"); for (StackTraceElement element : stackTraceElements) { text.append(" at " + element + "\n"); } tempThrowable = tempThrowable.getCause(); if (tempThrowable != null) { text.append("Caused by: " + tempThrowable.getCause()); } } ClientApplicationContext.getInstance().log("Uncaught exception: " + throwable.getMessage(), text.toString(), true, true, throwable); } }); }
From source file:com.risevision.ui.client.common.widgets.grid.ScrollingGridWidget.java
License:Open Source License
protected void onLoad() { searchTextBox.setFocus(true);/*from w w w. j av a 2 s. c o m*/ super.onLoad(); if (resizeHandler != null) { resize(); handlerRegistration = Window.addResizeHandler(resizeHandler); } }
From source file:com.risevision.ui.client.presentation.common.HtmlEditorWidget.java
License:Open Source License
protected void onLoad() { if (editor == null) { this.getElement().setAttribute("id", elementId); editor = initCodeMirrorNative(); }//from w w w . j a va2 s .c om if (!fixedSize) { resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { resize(); } }); resize(); } }
From source file:com.risevision.ui.client.presentation.PresentationLayoutWidget.java
License:Open Source License
protected void onLoad() { super.onLoad(); resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override//from w w w .ja v a2 s . com public void onResize(ResizeEvent event) { getElement().getParentElement().getStyle().setPropertyPx("width", (int) (Window.getClientWidth() - 31)); getElement().getParentElement().getStyle().setPropertyPx("height", CommonHeaderController.getContentHeight() - 50); resizeCanvas(); } }); }
From source file:com.risevision.ui.client.UiControlBinder.java
License:Open Source License
public UiControlBinder() { instance = this; // createAndBindUi initializes this.nameSpan initWidget(uiBinder.createAndBindUi(this)); mainMenu.add(menuWidget);/* w w w .ja v a 2 s . c o m*/ lastModifiedContainer.appendChild(lastModified.getElement()); statusContainer.appendChild(statusBox.getElement()); actionContainer.add(actionsWidget); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { styleControls(); } }); initHandlers(); styleControls(); }
From source file:com.risevision.viewer.client.controller.ViewerScheduleController.java
License:Open Source License
public ViewerScheduleController(Command scheduleReadyCommand) { this.scheduleReadyCommand = scheduleReadyCommand; thisCount = count;/*from w ww .ja v a 2 s.c om*/ count++; Command scheduleTimerCommand = new Command() { public void execute() { timerExecute(); } }; timerController = ViewerTimerController.createInstance(); timerController.addTimerCommand(scheduleTimerCommand); // itemTimer = new Timer() { // @Override // public void run() { // playNextItem(); // } // }; // scheduleTimer = new Timer() { // @Override // public void run() { // verifySchedule(); // } // }; resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { onWindowResize(); } }); }
From source file:com.roughindustries.commonwealthcocktails.client.application.ApplicationPresenter.java
License:Apache License
@Override protected void onBind() { step.setValue(25);// ww w . j ava2s . c o m current.setValue(25); next.setValue(current.intValue() + step.intValue()); prev.setValue(0); lastScrollPos.setValue(0); lastMaxScrollTop.setValue(0); list.addAll(Collections.nCopies(current.intValue(), new ccCocktail())); final HTML f = new HTML(""); Column<ccCocktail, SafeHtml> text = new Column<ccCocktail, SafeHtml>(new SafeHtmlCell()) { public SafeHtml getValue(ccCocktail cocktail) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (cocktail == null || cocktail.getCocktailName() == null) { sb.appendHtmlConstant("Loading ..."); return sb.toSafeHtml(); } else { sb.appendHtmlConstant( "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>"); sb.appendHtmlConstant("<tbody>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant( "<td><img alt='Cocktail' src='https://s3.amazonaws.com/commonwealthcocktailbucket/noun_320760_cc.png' style='border-width: 0px; border-style: solid; margin: 0px; width: 100px; height: 100px;' /></td>"); sb.appendHtmlConstant( "<td border='0' cellpadding='1' cellspacing='1' style='width: 100%;' table=''>"); sb.appendHtmlConstant( "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>"); sb.appendHtmlConstant("<tbody>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant("<td><b>" + cocktail.getCocktailName() + "</b></td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant( "<td><b>Origin: </b>" + ((cocktail.getCocktailOrigin() == null) || (cocktail.getCocktailOrigin().length() == 0) ? "" : (cocktail.getCocktailOrigin().substring(0, 150) + "...")) + "</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant("<td><b>Method: </b>" + ((cocktail.getCocktailMethod() == null) || (cocktail.getCocktailMethod() == null) ? "" : (cocktail.getCocktailMethod().substring(0, 150) + "...")) + "</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("</tbody>"); sb.appendHtmlConstant("</table>"); sb.appendHtmlConstant("</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("</tbody>"); sb.appendHtmlConstant("</table>"); return sb.toSafeHtml(); } } }; getView().getCocktailGrid().addColumn(text); data.addAll(list); getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px"); if (Window.getClientWidth() <= 768) { getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125); } else { getView().getBrand().setMarginLeft(0); } if (Window.getClientWidth() > (800) && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) { getView().getHeaderContainer() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid().setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else if (Window.getClientWidth() <= (800 - NativeVerticalScrollbar.getNativeScrollbarWidth())) { getView().getHeaderContainer().setWidth( Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid().setWidth( Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else { getView().getHeaderContainer().setWidth("800px"); getView().getCocktailGrid().setWidth("800px"); if (!getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(true); getView().getRightBuffer().setVisible(true); } getView().getLeftBuffer() .setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); getView().getRightBuffer() .setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); } getView().getScroll().addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent ev) { int oldScrollPos = lastScrollPos.intValue(); lastScrollPos.setValue(getView().getScroll().getVerticalScrollPosition()); // If scrolling up, ignore the event. if (oldScrollPos >= lastScrollPos.intValue()) { return; } // Height of grid contents (including outside the viewable area) // - height of the scroll panel int maxScrollTop = getView().getScroll().getWidget().getOffsetHeight() - getView().getScroll().getOffsetHeight(); if (lastScrollPos.intValue() == maxScrollTop) { if ((data.size() + step.intValue()) <= queryResultsCount.intValue()) { prev.setValue(current); current.setValue(next); next.setValue(next.intValue() + step.intValue()); data.addAll( new ArrayList<ccCocktail>(Collections.nCopies(step.intValue(), new ccCocktail()))); } else { int diff = queryResultsCount.intValue() - data.size(); if (diff > 0) { step.setValue(diff); prev.setValue(current); current.setValue(next); next.setValue(next.intValue() + step.intValue()); data.addAll(new ArrayList<ccCocktail>(Collections.nCopies(diff, new ccCocktail()))); } else { step.setValue(0); } } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); if (step.intValue() != 0) { cocktailService.cocktailServer("", prev.intValue(), step.intValue(), new AsyncCallback<ccCocktail[]>() { public void onFailure(Throwable caught) { } public void onSuccess(ccCocktail[] result) { if (result != null) { for (ccCocktail item : result) { data.set(item.getPageRefID(), item); } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid() .setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); } } }); } } } }); Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override public void onWindowScroll(com.google.gwt.user.client.Window.ScrollEvent event) { // Window.alert("Scrolling Window"); } }); cocktailService.getCount("", new AsyncCallback<Integer>() { public void onFailure(Throwable caught) { } public void onSuccess(Integer result) { queryResultsCount.setValue(result.intValue()); cocktailService.cocktailServer("", prev.intValue(), current.intValue(), new AsyncCallback<ccCocktail[]>() { public void onFailure(Throwable caught) { } public void onSuccess(ccCocktail[] result) { ArrayList<ccCocktail> removed = new ArrayList<ccCocktail>(); for (ccCocktail item : result) { if (item != null) { removed.add(item); } } result = removed.toArray(new ccCocktail[0]); if (result != null) { for (ccCocktail item : result) { data.set(item.getPageRefID(), item); } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); } } }); } }); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px"); if (Window.getClientWidth() <= 768) { getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125); } else { getView().getBrand().setMarginLeft(0); } if (Window.getClientWidth() > (800) && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) { getView().getHeaderContainer() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else if (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth())) { getView().getHeaderContainer() .setWidth(Integer.toString( Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid() .setWidth(Integer.toString( Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else { getView().getHeaderContainer().setWidth("800px"); getView().getCocktailGrid().setWidth("800px"); if (!getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(true); getView().getRightBuffer().setVisible(true); } getView().getLeftBuffer().setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); getView().getRightBuffer().setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); } } }); }