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

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

Introduction

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

Prototype

public static int getClientHeight() 

Source Link

Usage

From source file:com.ponysdk.ui.terminal.UIBuilder.java

License:Apache License

private void showCommunicationErrorMessage(final Throwable caught) {

    final VerticalPanel content = new VerticalPanel();
    if (caught instanceof StatusCodeException) {
        final StatusCodeException exception = (StatusCodeException) caught;
        content.add(new HTML("Server connection failed <br/>Code : " + exception.getStatusCode() + "<br/>"
                + "cause : " + exception.getMessage()));
    } else if (caught instanceof InvocationException) {
        content.add(new HTML("Exception durring server invocation : " + caught.getMessage()));
    } else {//w  w w.java2  s. c  o m
        content.add(new HTML("Failure : " + caught == null ? "" : caught.getMessage()));
    }

    final HorizontalPanel actionPanel = new HorizontalPanel();
    actionPanel.setSize("100%", "100%");

    final Anchor reloadAnchor = new Anchor("reload");
    reloadAnchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            History.newItem("");
            reload();
        }
    });

    final Anchor closeAnchor = new Anchor("close");
    closeAnchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            communicationErrorMessagePanel.hide();
        }
    });

    actionPanel.add(reloadAnchor);
    actionPanel.add(closeAnchor);

    actionPanel.setCellHorizontalAlignment(reloadAnchor, HasHorizontalAlignment.ALIGN_CENTER);
    actionPanel.setCellHorizontalAlignment(closeAnchor, HasHorizontalAlignment.ALIGN_CENTER);
    actionPanel.setCellVerticalAlignment(reloadAnchor, HasVerticalAlignment.ALIGN_MIDDLE);
    actionPanel.setCellVerticalAlignment(closeAnchor, HasVerticalAlignment.ALIGN_MIDDLE);

    content.add(actionPanel);

    communicationErrorMessagePanel.setWidget(content);
    communicationErrorMessagePanel.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(final int offsetWidth, final int offsetHeight) {
            communicationErrorMessagePanel.setPopupPosition((Window.getClientWidth() - offsetWidth) / 2,
                    (Window.getClientHeight() - offsetHeight) / 2);
        }
    });
}

From source file:com.preferanser.client.application.mvp.BaseTableView.java

License:Open Source License

@Override
public void prepositionCards(Card... cards) {
    for (Card card : cards) {
        CardWidget cardWidget = getOrCreateCardWidget(card);
        Style cardStyle = cardWidget.getElement().getStyle();
        cardStyle.setTop(Window.getClientHeight() + 10, Style.Unit.PX);
        cardStyle.setLeft(Math.round((Window.getClientWidth() - cardWidget.getOffsetWidth()) / 2),
                Style.Unit.PX);// ww w  . j a v a  2s .  c o m
    }
}

From source file:com.pronoiahealth.olhie.client.widgets.chat.ChatDialog.java

License:Open Source License

/**
 * The window can be dragged off the screen or the window can be resized
 * hidding the dialog. This method in conjunction with the monitoring window
 * rezie events prevents that from happening.
 * /*w w w.jav a2  s  . c om*/
 * @see com.google.gwt.user.client.ui.DialogBox#endDragging(com.google.gwt.event.dom.client.MouseUpEvent)
 */
@Override
protected void endDragging(MouseUpEvent event) {
    int genericMargin = 60;
    int leftMargin = -(this.getOffsetWidth() - genericMargin);
    int lowerMargin = Window.getClientHeight() - genericMargin;
    int rightMargin = Window.getClientWidth() - genericMargin;
    int upperMargin = 0;

    if (this.getAbsoluteLeft() > rightMargin) {
        this.setPopupPosition(rightMargin, this.getPopupTop());
    }

    if (this.getAbsoluteLeft() < leftMargin) {
        this.setPopupPosition(leftMargin, this.getPopupTop());
    }

    if (this.getAbsoluteTop() > lowerMargin) {
        this.setPopupPosition(this.getPopupLeft(), lowerMargin);
    }

    if (this.getAbsoluteTop() < upperMargin) {
        this.setPopupPosition(this.getPopupLeft(), upperMargin);
    }

    super.endDragging(event);
}

From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTable.java

License:Apache License

private void showPrompt(final String senderId, final String listenerType) {

    final org.gwt.mosaic.ui.client.MessageBox prompt = new org.gwt.mosaic.ui.client.MessageBox(
            MessageBoxType.PROMPT, "Confirm") {
        @Override//from   w ww. j av a  2 s.com
        public void onClose(final boolean result) {
        }
    };
    final Label message = new Label();
    message.setText("Click ok to reset the data to initial value.");
    final Button ok = new Button("Ok");
    ok.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            resetInitialData = false;
            //datagridRendered = false;
            getRowValues().clear();
            getDataTable().clear();
            final List<DataContainerGVO> cloneOfInitialData = makeClone(initialData);
            insertData(cloneOfInitialData, false, senderId, listenerType);
            prompt.removeFromParent();
            clearSelection();
        }
    });
    final Button cancel = new Button("Cancel");
    cancel.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            prompt.removeFromParent();
        }
    });
    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(ok);
    hp.add(cancel);
    final VerticalPanel vp = new VerticalPanel();
    vp.add(message);
    vp.add(hp);
    prompt.add(vp);

    final int width = Window.getClientWidth() - 10;
    final int height = Window.getClientHeight() - 10;
    prompt.setSize(width + "", height + "");
    prompt.showModal();
}

From source file:com.qualogy.qafe.gwt.client.context.ClientApplicationContext.java

License:Apache License

public void updatePosition() {
    if (getWindows().size() > 1) {
        if (Window.getClientWidth() > (getStartXPosition() + STEP_SIZE_X + MARGIN_X)) {
            startXPosition += STEP_SIZE_X;
        } else {/*from  w  w w.j av  a 2 s  . c om*/
            startXPosition = INIT_START_X_POSITION;
            startYPosition = INIT_START_Y_POSITION + STEP_SIZE_Y;
        }

        if (Window.getClientHeight() > (getStartYPosition() + STEP_SIZE_Y + MARGIN_Y)) {
            startYPosition += STEP_SIZE_Y;
        } else {
            startXPosition = INIT_START_X_POSITION + STEP_SIZE_X;
            startYPosition = INIT_START_Y_POSITION;
        }
    } else {
        startXPosition = INIT_START_X_POSITION;
        startYPosition = INIT_START_Y_POSITION;
    }

}

From source file:com.qualogy.qafe.gwt.client.context.ClientApplicationContext.java

License:Apache License

public void addDesktopIcon(DesktopIcon desktopIcon) {
    if (desktopIcon != null) {
        desktopIcons.add(desktopIcon);//  w w  w.jav  a 2  s.com
        int rowCount = desktopIcons.size();
        int columnCount = 0;
        int posX = 0;
        int posY = desktopIconVGap + (rowCount * desktopIconVGap) + (rowCount * DesktopIcon.HEIGHT);
        if (posY + DesktopIcon.HEIGHT > Window.getClientHeight()) {
            columnCount = columnCount + 1;
            rowCount = 0;
        }
        posX = desktopIconHGap + (columnCount * desktopIconHGap) + (columnCount * DesktopIcon.WIDTH);
        posY = desktopIconVGap + (rowCount * desktopIconVGap) + (rowCount * DesktopIcon.HEIGHT);
        RootPanel.get().add(desktopIcon, posX, posY);
    }
}

From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java

License:Apache License

public static void createWindow(UIGVO ui, String windowId) {
    Widget w = GWTUIGenerator.createView(ui, windowId);

    if (ClientApplicationContext.getInstance().isMDI()) {
        WindowGVO windowGVO = getWindow(ui, windowId);
        String windowTitle = getWindowTitle(ui, windowId);

        if (windowGVO != null) {
            windowTitle = windowGVO.getTitle();
        }//  w  ww.j a  v  a  2  s . com

        if (w != null) {

            WindowPanel window = new QWindowPanel(windowTitle);
            window.getHeader().setText(windowTitle);

            if (w instanceof QRootPanel) {
                ((QWindowPanel) window).setQRootPanel((QRootPanel) w);
            }

            window.setAnimationEnabled(true);
            ((QWindowPanel) window).setManaged(true);

            // Do not pack the windows if the "width" or "height" attributes
            // are on
            boolean bPack = true;

            // window.updateSize();
            if (windowGVO.getHeight() != null && windowGVO.getHeight().length() > 0) {
                try {
                    int height = Integer.parseInt(windowGVO.getHeight());
                    // Test if the height is not negative
                    if (height < 0)
                        throw new NumberFormatException();
                    bPack = false;
                    window.setHeight(height + "px");
                } catch (NumberFormatException e) {
                    ClientApplicationContext.getInstance()
                            .log("could not set height on Window (it's not a valid integer):"
                                    + windowGVO.getHeight());
                }
            }
            if (windowGVO.getWidth() != null && windowGVO.getWidth().length() > 0) {
                try {
                    int width = Integer.parseInt(windowGVO.getWidth());
                    // Test if the width is not negative
                    if (width < 0)
                        throw new NumberFormatException();
                    bPack = false;
                    window.setWidth(width + "px");
                } catch (NumberFormatException e) {
                    ClientApplicationContext.getInstance().log(
                            "could not set width on Window (it's not a valid integer):" + windowGVO.getWidth());
                }
            }

            if (currentWindowTitle == null)
                currentWindowTitle = windowGVO.getTitle();
            if (!windowTitle.equalsIgnoreCase(currentWindowTitle)) {
                ClientApplicationContext.getInstance().updatePosition();
            }
            currentWindowTitle = windowTitle;
            int left = ClientApplicationContext.getInstance().getStartXPosition();
            int top = ClientApplicationContext.getInstance().getStartYPosition();
            if (windowGVO.getLeft() != null) {
                left = windowGVO.getLeft();
            }
            if (windowGVO.getTop() != null) {
                top = windowGVO.getTop();
            }
            window.setPopupPosition(left, top);

            ClientApplicationContext.getInstance().addWindows(ui, window, windowId);
            if (Cookies.getCookie(ui.getUuid() + "-top-" + windowId) != null
                    && Cookies.getCookie(ui.getUuid() + "-left-" + windowId) != null) {
                // There is a known bug that causes the parsing of the position stored as string in the cookie to be
                // returned as a double. 
                double leftPos = Double.parseDouble(Cookies.getCookie(ui.getUuid() + "-left-" + windowId));
                double rightPos = Double.parseDouble(Cookies.getCookie(ui.getUuid() + "-top-" + windowId));
                int roundedLeftPos = (int) Math.round(leftPos);
                int roundedRightPos = (int) Math.round(rightPos);
                window.setPopupPosition(roundedLeftPos, roundedRightPos);

            }
            window.setWidget(w);
            // If the width or the height attributes were set then we don't
            // pack the window
            // Use the default width and height that you got in the ClientApplicationContext.
            if (ClientApplicationContext.getInstance().getGlobalConfigurations()
                    .get("window.default.height") != null && windowGVO.getHeight() == null) {
                window.setHeight(ClientApplicationContext.getInstance().getGlobalConfigurations()
                        .get("window.default.height"));
                bPack = false;
            }
            if (ClientApplicationContext.getInstance().getGlobalConfigurations()
                    .get("window.default.width") != null && windowGVO.getWidth() == null) {
                window.setWidth(ClientApplicationContext.getInstance().getGlobalConfigurations()
                        .get("window.default.width"));
                bPack = false;
            }

            if (bPack) {
                window.pack();
                if (window.getContentHeight() > (int) (Window.getClientHeight() * 0.8)) {
                    Dimension d = window.getContentSize();
                    Dimension newD = new Dimension(d.getWidth(), Window.getClientHeight() / 2);
                    window.setContentSize(newD);
                }
                if (window.getContentWidth() > (int) (Window.getClientWidth() * 0.8)) {
                    Dimension d = window.getContentSize();
                    Dimension newD = new Dimension(Window.getClientWidth() / 2, d.getHeight());
                    window.setContentSize(newD);
                }
            }

            window.show();
            modifyWindowSize(w, window);

            EventFactory.createWindowSizeEvent(ui.getUuid(), windowId, window);
            if (windowGVO != null) {
                RendererHelper.addStyle(windowGVO.getRootPanel(), ((QWindowPanel) window).getQRootPanel());
                if (windowGVO.getClosable() != null) {
                    ((QWindowPanel) window).setClosable(windowGVO.getClosable().booleanValue());
                }
                if (windowGVO.getMaximizable() != null && windowGVO.getMaximizable().booleanValue()) {
                    ((QWindowPanel) window).addMaximizeButton();// setMaximizable(windowGVO.getMaximizable().booleanValue());
                }
                if (windowGVO.getMinimizable() != null && windowGVO.getMinimizable().booleanValue()) {
                    ((QWindowPanel) window).addMinimizeButton();
                }
                if (windowGVO.getResizable() != null) {
                    window.setResizable(windowGVO.getResizable().booleanValue());
                }

                // The id of the ui-window is winId|winId|appId (<id>|<parent>|<context>),
                // while the id of ui-components within a window is componentId|winId|appId
                RendererHelper.addId(windowGVO, window, ui.getUuid(), windowGVO.getId(), windowGVO.getContext(),
                        true);
                RendererHelper.addUUID(windowGVO, window, ui.getUuid());
                // /// TODO Check the unload and window actions...
                EventFactory.createDefaultCloseEvent(windowGVO, window,
                        ClientApplicationContext.getInstance().getWindowSession(), ui.getUuid());
                EventFactory.createWindowStateChangeListener(window, windowTitle, ui.getUuid(), windowId);
            }
        } else {
            ClientApplicationContext.getInstance().log("Opening Window failed", "Window with id '" + windowId
                    + "' could not be opened.\n This Window might not exist in this application context", true);
        }
    } else {
        WindowGVO windowGVO = getWindow(ui, windowId);

        setWidgetToMainPanel(w, windowGVO);
    }
}

From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java

License:Apache License

public static void setWidgetToMainPanel(Widget w, WindowGVO windowGVO) {
    if (w != null) {
        clearWidgetFromMainPanel();/*from www. ja v a2  s . c om*/
        SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel();
        if (mainPanel == null) {
            mainPanel = new SimplePanel();
            mainPanel.setWidth(Window.getClientWidth() + "px");
            mainPanel.setHeight(Window.getClientHeight() + "px");

            ClientApplicationContext.getInstance().setMainPanel(mainPanel);
            MenuBar menuBar = ClientApplicationContext.getInstance().getApplicationsMenu();
            if (menuBar != null) {
                menuBar.addStyleName("SDIMenu");
                RootPanel.get().add((Widget) mainPanel, 0, 24);
            } else {
                RootPanel.get().add((Widget) mainPanel, 0, 0);
            }
        }

        w.setWidth(Window.getClientWidth() + "px");
        w.setHeight(Window.getClientHeight() + "px");
        mainPanel.addStyleName("SDIWrapper");
        mainPanel.setWidget(w);
        w.addStyleName("SDIPanel");
        if (windowGVO != null) {
            RendererHelper.addStyle(windowGVO.getRootPanel(), w);
        }
    }
}

From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java

License:Apache License

protected void moveWidgets() {
    try {/*ww w  . j  av a2s  .  c om*/
        DOM.setStyleAttribute(ClientApplicationContext.getInstance().getPi().getElement(), "left",
                "" + (Window.getClientWidth() - ClientApplicationContext.getInstance().getPi().getWidth()));
        if (ClientApplicationContext.getInstance().isMDI()) {
            if (ClientApplicationContext.getInstance().getDockMode().booleanValue()) {
                int dockWidth = ClientApplicationContext.getInstance().getDockPanel().getOffsetWidth();
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(),
                        "left", Window.getClientWidth() / 2 - (dockWidth / 2) + "");
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getDockPanel().getElement(), "top",
                        "" + (Window.getClientHeight() - 80));
            } else {
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getBottomMenuBar().getElement(),
                        "left", "" + 0);
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getBottomMenuBar().getElement(),
                        "top", "" + (Window.getClientHeight() - 25));
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getHorizontalPanel().getElement(),
                        "left", "" + 0);
                DOM.setStyleAttribute(ClientApplicationContext.getInstance().getHorizontalPanel().getElement(),
                        "top", "" + (Window.getClientHeight() - 23));
            }
        } else {
            SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel();
            mainPanel.setWidth(Window.getClientWidth() + "px");
            mainPanel.setHeight(Window.getClientHeight() + "px");
        }
    } catch (Exception e) {
    }
}

From source file:com.qualogy.qafe.gwt.client.QAFEGWTWeb.java

License:Apache License

protected static void setupMDI(Boolean dockMode) {
    Window.enableScrolling(false);
    ClientApplicationContext.getInstance().setMode(ClientApplicationContext.MDI);
    ClientApplicationContext.getInstance().setDockMode(dockMode);
    RootPanel.get(rootPanelValue).add(buildMenu(), 0, 0);

    MainFactoryActions.processUIFromApplicationContext();
    ClientApplicationContext.getInstance().setLogText("MDI Mode");
    if (dockMode.booleanValue()) {
        Panel dockPanel = new HorizontalPanel();
        ClientApplicationContext.getInstance().setDockPanel(dockPanel);
        RootPanel.get(rootPanelValue).add(dockPanel, Window.getClientWidth() / 2,
                Window.getClientHeight() - 80);
    } else {/*w ww .j  a  va 2s .  c  o m*/
        RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getHorizontalPanel(), 0,
                Window.getClientHeight() - 23);
        ClientApplicationContext.getInstance().getBottomMenuBar().setWidth("100%");
        ClientApplicationContext.getInstance().getBottomMenuBar().addItem(" ", new Command() {
            @Override
            public void execute() {
            }
        });
        RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getBottomMenuBar(), 0,
                Window.getClientHeight() - 25);
    }
    AbsolutePanel image = new AbsolutePanel();
    image.addStyleName("imglogo");
    RootPanel.get(rootPanelValue).add(image);
    RootPanel.get(rootPanelValue).add(ClientApplicationContext.getInstance().getPi(),
            Window.getClientWidth() - ClientApplicationContext.getInstance().getPi().getWidth(), 3);
}