Example usage for com.google.gwt.user.client Window getClientWidth

List of usage examples for com.google.gwt.user.client Window getClientWidth

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getClientWidth.

Prototype

public static int getClientWidth() 

Source Link

Usage

From source file:com.risevision.viewer.client.data.DisplayRegistrationController.java

License:Open Source License

public static void registerDisplay(String claimId, String displayName) {
    // API: /v2/viewer/display/{claimId}/register?callback={callbackName}&name={displayName}
    //      callbackName is mandatory, displayName is optional.
    int viewerWidth = Window.getClientWidth();
    int viewerHeight = Window.getClientHeight();

    String url = Global.DATA_SERVER_URL.replace("{0}", "display");
    url = url.replace("{1}", claimId);
    url += "/register?width=" + viewerWidth + "&height=" + viewerHeight;
    if (displayName != null && !displayName.isEmpty()) {
        url += "&name=" + URL.encodeQueryString(displayName);
    }/*from   www  .  java  2s .co  m*/
    url += "&callback=?";
    callUrlNative(url, MODE_REGISTER);
}

From source file:com.risevision.viewer.client.data.ViewerDataProvider.java

License:Open Source License

public static void retrieveData(String reason) {
    if (state == IDLE_STATE) {
        // [AD] moved this function to after the data is retrieved - workaround for Core bug 
        // where the Viewer API and Channel Token calls can't be made at the same time 
        //         channelController.init(channelCommand);

        String url;//from w ww.  j a v  a 2s  . c om

        url = Global.DATA_SERVER_URL.replace("{0}", ViewerEntryPoint.getType());
        url = url.replace("{1}", ViewerEntryPoint.getId());

        int viewerWidth = Window.getClientWidth();
        int viewerHeight = Window.getClientHeight();

        String sysInfo = ViewerEntryPoint.getSysInfo();
        JsArrayString browserInfo = ViewerHtmlUtils.getBrowserVersion();

        String updateTicket = ChannelConnectionController.getUpdateTicket();
        updateTicket = updateTicket == null ? "" : "&ticket=" + updateTicket;

        String fullUrl = url + "?sig=" + ViewerDataController.getSig() + updateTicket + "&"
                + Global.VIEWER_URL_IDENTIFIER
                + (RiseUtils.strIsNullOrEmpty(sysInfo) ? "" : "&" + URL.decodeQueryString(sysInfo)) + "&cn="
                + browserInfo.get(0) + "&cv=" + browserInfo.get(1) + "&width=" + viewerWidth + "&height="
                + viewerHeight + "&callback=?";

        state = WAITING_STATE;

        // start 60 second timer for timeout of data retrieval
        apiTimer.schedule(ViewerDataController.MINUTE_UPDATE_INTERVAL);
        ViewerHtmlUtils.logExternalMessage("viewer data retrieval", reason);
        getDataNative(fullUrl);
    } else {
        state = CONTENT_STATE;
    }
}

From source file:com.risevision.viewer.client.widgets.oem.DisplayRegisterBaseWidget.java

License:Open Source License

public void show(boolean hasParent) {
    super.show();
    super.setPopupPosition((int) (Window.getClientWidth() / 2 - 200), 100);

    this.hasParent = hasParent;

    if (showCountdown) {
        startCountdownTimer();//from   w  w w  .j  a  va  2 s. c o m
        countdownLabel.setVisible(true);
    }
}

From source file:com.risevision.viewer.client.widgets.oem.HelpFrameWidget.java

License:Open Source License

private void prepareFrame() {
    w = Window.getClientWidth() - 40;
    h = Window.getClientHeight() - 40;

    styleControls();//  ww w.ja  va  2 s. c  o  m

    add(outerPanel);

    outerPanel.add(webPageFrame, 0, 7);
    outerPanel.add(closePanel, w - 10, -17);

    initActions();
}

From source file:com.risevision.viewer.client.widgets.ViewerPreviewShareWidget.java

License:Open Source License

public void show(String url) {
    super.show();
    super.setPopupPosition((int) (Window.getClientWidth() / 2 - 300), 100);

    urlTextBox.setText(url);//from  w  ww.ja va 2 s .  co m
    urlTextBox.setFocus(true);
    urlTextBox.selectAll();

    String embedCode = EMBED_HTML_CODE.replace("%1%", ViewerPreviewWidget.getPreviewUrl() + "&showui=false");
    embedCode = embedCode.replace("%2%", ViewerEntryPoint.getPresentationWidth() + "");
    embedCode = embedCode.replace("%3%", ViewerEntryPoint.getPresentationHeight() + "");

    embedTextBox.setText(embedCode);

    String linkCode = EMBED_LINK_CODE.replace("%1%", ViewerPreviewWidget.getPreviewUrl() + "&showui=false");
    linkCode = linkCode.replace("%2%", ViewerDataController.getItemName());

    embedLinkTextBox.setText(linkCode);
}

From source file:com.roughindustries.commonwealthcocktails.client.application.ApplicationPresenter.java

License:Apache License

@Override
protected void onBind() {

    step.setValue(25);//from   w  ww .ja v a2 s.co  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");
            }
        }

    });
}

From source file:com.sangnd.gwt.faceme.client.view.BoardViewMGwt.java

License:Open Source License

private void resizeScreen() {
    int w = Window.getClientWidth();
    int h = Window.getClientHeight() - 50;
    float rw = (float) w / Constant.SCREEN_WIDTH;
    float rh = (float) h / Constant.SCREEN_HEIGHT;
    if (rw < rh) {
        Constant.SCREEN_RATIO = rw;//from  w  w  w. jav  a  2  s  .  c o  m
    } else {
        Constant.SCREEN_RATIO = rh;
    }
    int width = ((int) ((float) Constant.SCREEN_WIDTH * Constant.SCREEN_RATIO) - 40);
    int height = ((int) ((float) Constant.SCREEN_HEIGHT * Constant.SCREEN_RATIO) - 40);

    this.setWidth(width + "px");
    this.setHeight(height + "px");
    boardPanel.getElement().getStyle().setProperty("backgroundSize", width + "px " + height + "px");
    notiShape.getElement().getStyle().setProperty("left", (width - 200) / 2 + "px");
    notiShape.getElement().getStyle().setProperty("top", (height - 40) / 2 + "px");
    this.reDrawChess();
}

From source file:com.sciencegadgets.client.Moderator.java

License:Open Source License

private void fitWindow() {
    SGAHeight = Window.getClientHeight();
    SGAWidth = Window.getClientWidth();

    // Fill up the window
    scienceGadgetArea.setSize(SGAWidth + "px", SGAHeight + "px");
}

From source file:com.sciencegadgets.client.ui.Prompt.java

License:Open Source License

@Override
public void resize() {
    flowPanel.setPixelSize((int) (Window.getClientWidth() * WIDTH_FRACTION),
            (int) (Window.getClientHeight() * HEIGHT_FRACTION));
}

From source file:com.seanchenxi.gwt.effect.core.Fly.java

License:Apache License

public void setTargetRelativeToCenter(int left, int top) {
    this.targetLeft = left + (Window.getClientWidth() - getWidget().getOffsetWidth()) >> 1;
    this.targetTop = top + (Window.getClientHeight() - getWidget().getOffsetHeight()) >> 1;
}