List of usage examples for com.google.gwt.user.client Window addResizeHandler
public static HandlerRegistration addResizeHandler(ResizeHandler handler)
From source file:com.appspot.codsallarts.client.Application.java
License:Apache License
/** * Constructor./* w ww.ja v a 2 s .c o m*/ */ public Application() { // Setup the main layout widget FlowPanel layout = new FlowPanel(); initWidget(layout); // Setup the top panel with the title and links createTopPanel(); layout.add(topPanel); // Add the main menu bottomPanel = new HorizontalPanel(); bottomPanel.setWidth("100%"); bottomPanel.setSpacing(0); bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); layout.add(bottomPanel); // Setup the content layout contentLayout = new Grid(2, 1); contentLayout.setStyleName("Application-content-grid"); contentLayout.setCellPadding(0); contentLayout.setCellSpacing(0); contentDecorator = new DecoratorPanel(); contentDecorator.setWidget(contentLayout); contentDecorator.addStyleName(DEFAULT_STYLE_NAME + "-content-decorator"); bottomPanel.add(contentDecorator); if (LocaleInfo.getCurrentLocale().isRTL()) { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_LEFT); contentDecorator.getElement().setAttribute("align", "LEFT"); } else { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_RIGHT); contentDecorator.getElement().setAttribute("align", "RIGHT"); } CellFormatter formatter = contentLayout.getCellFormatter(); // Add the content title setContentTitle(new HTML("Welcome")); formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-content-title"); // Add the content wrapper contentWrapper = new SimplePanel(); contentLayout.setWidget(1, 0, contentWrapper); formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-content-wrapper"); setContent(null); //createMainMenu(); //bottomPanel.add(mainMenu); navigationPanel = new SimplePanel(); navigationPanel.addStyleName(DEFAULT_STYLE_NAME + "-nav"); bottomPanel.add(navigationPanel); // Add a window resize handler Window.addResizeHandler(this); }
From source file:com.arcbees.gquery.appear.client.Appear.java
License:Apache License
private HandlerRegistration addWindowResizeHandler() { return Window.addResizeHandler(new ResizeHandler() { @Override// w w w . j a va2 s . c o m public void onResize(ResizeEvent event) { hasResized = true; } }); }
From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java
License:Apache License
private void bind() { resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() { @Override/*www . j a v a 2 s . c o m*/ public void onResize(ResizeEvent event) { if (options.isAutoResize()) { layout(); } } }); if (MutationObserver.isSupported()) { mutationObserver = new MutationObserver(new DomMutationCallback() { @Override public void onNodesRemoved(JsArray<Node> removedNodes) { onItemsRemoved(); } @Override public void onNodesInserted(JsArray<Node> addedNodes, Node nextSibling) { onItemsInserted(toElementList(addedNodes)); } @Override public void onNodesAppended(JsArray<Node> addedNodes) { onItemsAppended(toElementList(addedNodes)); } }); mutationObserver.observe(container); } else { // try old api with DomMutationEvent $(container).on("DOMNodeInserted", new Function() { @Override public boolean f(Event event) { Node node = event.getEventTarget().cast(); if (node.getNodeType() != Node.ELEMENT_NODE || node.getParentElement() != container) { return false; } final Element element = node.cast(); Element prevSibling = element.getPreviousSiblingElement(); Element nextSibling = element.getNextSiblingElement(); if (prevSibling != null && getStyleInfo(prevSibling) != null && (nextSibling == null || getStyleInfo(nextSibling) == null)) { onItemsAppended(new ArrayList<Element>() { { this.add(element); } }); } else { onItemsInserted(new ArrayList<Element>() { { this.add(element); } }); } return false; } }).on("DOMNodeRemoved", new Function() { @Override public boolean f(Event event) { Node node = event.getEventTarget().cast(); if (node.getNodeType() != Node.ELEMENT_NODE || node.getParentElement() != container) { return false; } onItemsRemoved(); return false; } }); } }
From source file:com.arcbees.website.client.application.error.NotFoundView.java
License:Apache License
@Override protected void onAttach() { resizeHandler = Window.addResizeHandler(this); updateHeight(); }
From source file:com.astrofizzbizz.raspberrypicamera.client.tablayout.MyTabLayoutScrollPanel.java
License:Open Source License
public MyTabLayoutScrollPanel(MyTabLayoutPanel myTabLayoutPanel) { super();/* w ww .ja va2s . c o m*/ this.myTabLayoutPanel = myTabLayoutPanel; setAlwaysShowScrollBars(true); reSize(); Window.addResizeHandler(new MyResizeHandler()); }
From source file:com.badlogic.gdx.backends.gwt.widgets.ResizableWidgetCollection.java
License:Apache License
/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer * will not check their dimensions periodically. * //from w ww . ja v a 2 s . co m * @param enabled true to enable the resize checking timer */ public void setResizeCheckingEnabled(boolean enabled) { if (enabled && !resizeCheckingEnabled) { resizeCheckingEnabled = true; if (windowHandler == null) { windowHandler = Window.addResizeHandler(this); } resizeCheckTimer.schedule(resizeCheckDelay); } else if (!enabled && resizeCheckingEnabled) { resizeCheckingEnabled = false; if (windowHandler != null) { windowHandler.removeHandler(); windowHandler = null; } resizeCheckTimer.cancel(); } }
From source file:com.beyobe.client.widgets.Carousel.java
License:Apache License
/** * Construct a carousel widget with a given css * /*from w w w . j ava 2 s .c o m*/ * @param css the css to use */ public Carousel(CarouselCss css) { this.css = css; this.css.ensureInjected(); // childToHolder = new HashMap<Widget, Widget>(); main = new FlowPanel(); initWidget(main); main.addStyleName(css.carousel()); scrollPanel = new ScrollPanel(); scrollPanel.addStyleName(css.carouselScroller()); main.add(scrollPanel); container = new HorizontalPanel(); container.addStyleName(css.carouselContainer()); scrollPanel.setWidget(container); scrollPanel.setSnap(true); scrollPanel.setMomentum(true); scrollPanel.setShowScrollBarX(true); scrollPanel.setShowScrollBarY(false); scrollPanel.setScrollingEnabledX(true); scrollPanel.setScrollingEnabledY(false); scrollPanel.setAutoHandleResize(true); currentPage = 0; scrollPanel.addScrollEndHandler(new ScrollEndEvent.Handler() { @Override public void onScrollEnd(ScrollEndEvent event) { int page; page = scrollPanel.getCurrentPageX(); if (page >= 0) { currentPage = page; // log.info("Carousel: scrolled to Day# " + currentPage + " = " + container.getWidget(currentPage)); SelectionEvent.fire(Carousel.this, currentPage); } } }); // MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { // // @Override // public void onOrientationChanged(OrientationChangeEvent event) { // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // // @Override // public void execute() { // refresh(); // // } // }); // // } // }); addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { int page = scrollPanel.getCurrentPageX(); } }); if (MGWT.getOsDetection().isDesktop()) { Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { refresh(); } }); } }); } }
From source file:com.centretown.planets.client.application.widget.SizeableView.java
License:Apache License
public SizeableView() { Window.addResizeHandler(this); sizeWidth = Window.getClientWidth(); sizeHeight = Window.getClientHeight(); sanityCheck = 0; }
From source file:com.chinarewards.gwt.license.client.ui.DialogBox.java
@Override public void show() { if (resizeHandlerRegistration == null) { resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { windowWidth = event.getWidth(); }//from w w w . j a va 2 s . co m }); } super.show(); }
From source file:com.cms.gwt.fs.client.view.calendar.ExtMonthPanel.java
License:Apache License
private void buildPanel() { if (renderer.enableDragAndDrop()) { for (int i = 0; i < dropControllers.size(); i++) { final MonthPanelDropController real = dropControllers.get(i); dragController.unregisterDropController(real); }//w w w . java 2 s. com dropControllers.clear(); } monthPanel.clear(); DOM.setStyleAttribute(monthPanel.getElement(), "width", "100%"); DOM.setStyleAttribute(monthPanel.getElement(), "height", "100%"); helperCal.setFirstDayOfWeek(firstDayOfWeek); xPos = 0; yPos = 0; final Calendar today = new GregorianCalendar(); final DateTimeFormat dayFormatter = DateTimeFormat.getFormat("EEEE"); for (int i = firstDayOfWeek; i < 7 + firstDayOfWeek; i++) { helperCal.set(Calendar.DAY_OF_WEEK, i); HTML heading = new HTML(dayFormatter.format(helperCal.getTime())); heading.setStyleName("Calendar-MonthHeading"); monthPanel.setWidget(yPos, xPos, heading); monthPanel.getCellFormatter().setHorizontalAlignment(yPos, xPos, HorizontalPanel.ALIGN_CENTER); monthPanel.getCellFormatter().setHeight(yPos, xPos, "9%"); monthPanel.getColumnFormatter().setWidth(xPos, "12%"); xPos++; } yPos++; // set logical first day of the month helperCal.setTime(current.getTime()); helperCal.set(Calendar.DAY_OF_MONTH, 1); helperCal.set(Calendar.HOUR_OF_DAY, 0); helperCal.set(Calendar.MINUTE, 0); helperCal.set(Calendar.SECOND, 0); helperCal.set(Calendar.MILLISECOND, 0); firstLogical = helperCal.getTime(); // set logical last day of the month helperCal.add(Calendar.MONTH, 1); helperCal.add(Calendar.MILLISECOND, -1); lastLogical = helperCal.getTime(); // now loop over full weeks for showing days helperCal.setTime(current.getTime()); helperCal.add(Calendar.DAY_OF_MONTH, -(helperCal.get(Calendar.DAY_OF_MONTH))); while (helperCal.get(Calendar.DAY_OF_WEEK) != helperCal.getFirstDayOfWeek()) { helperCal.add(Calendar.DAY_OF_MONTH, -1); } firstShow = helperCal.getTime(); for (int y = 1; y < 8; y++) { for (int x = 0; x < 7; x++) { monthPanel.getCellFormatter().setHeight(y, x, "13%"); monthPanel.getCellFormatter().addStyleName(y, x, "Calendar-Month-Height"); final ExtMonthPanelDayPanel result = makeDayPanel(helperCal); // apply styles here for last month's days, today and next // month's days if (DateUtils.isSameDay(today, helperCal)) { result.addStyleName("Calendar-Month-Today"); } else if (current.get(Calendar.MONTH) == helperCal.get(Calendar.MONTH)) { result.addStyleName("Calendar-Month-CurrentMonth"); } else { result.addStyleName("Calendar-Month-OtherMonth"); } monthPanel.setWidget(y, x, result); // we do NOT have dragging enabled // if (renderer.enableDragAndDrop() && dragController != null) { // final MonthPanelDropController dropController = new // MonthPanelDropController( // result); // dropControllers.add(dropController); // dragController.registerDropController(dropController); // } helperCal.add(Calendar.DAY_OF_MONTH, 1); } } lastShow = helperCal.getTime(); Window.addResizeHandler(this); }