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.ponysdk.core.terminal.ui.PTPopupPanel.java

License:Apache License

@Override
public void onMouseMove(final MouseMoveEvent event) {
    if (dragging) {
        final int absX = event.getX() + uiObject.getAbsoluteLeft();
        final int absY = event.getY() + uiObject.getAbsoluteTop();

        if (absX < Document.get().getBodyOffsetLeft() || absX >= Window.getClientWidth()
                || absY < Document.get().getBodyOffsetTop()) {
            return;
        }/*from w  ww .j av  a2s  . co  m*/

        uiObject.setPopupPosition(absX - dragStartX, absY - dragStartY);
    }
}

From source file:com.ponysdk.core.terminal.ui.PTPopupPanel.java

License:Apache License

@Override
public void addHandler(final ReaderBuffer buffer, final HandlerModel handlerModel) {
    if (HandlerModel.HANDLER_POPUP_POSITION == handlerModel) {
        uiObject.setVisible(true);//from   w w w.  jav  a 2  s  . c om
        uiObject.show();
        Scheduler.get().scheduleDeferred(() -> {
            final PTInstruction eventInstruction = new PTInstruction(getObjectID());

            final JSONArray widgetInfo = new JSONArray();
            int i = 0;
            widgetInfo.set(i++, new JSONNumber(uiObject.getOffsetWidth()));
            widgetInfo.set(i++, new JSONNumber(uiObject.getOffsetHeight()));
            widgetInfo.set(i++, new JSONNumber(Window.getClientWidth()));
            widgetInfo.set(i++, new JSONNumber(Window.getClientHeight()));

            eventInstruction.put(ClientToServerModel.POPUP_POSITION, widgetInfo);

            uiBuilder.sendDataToServer(uiObject, eventInstruction);
        });
    } else {
        super.addHandler(buffer, handlerModel);
    }
}

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

License:Apache License

@Override
public void create(final PTInstruction create, final UIService uiService) {
    final boolean autoHide = create.getBoolean(PROPERTY.POPUP_AUTO_HIDE);

    init(create, uiService, createPopupPanel(autoHide));

    addCloseHandler(create, uiService);//from   w  ww . j  a  v a2s .  c om

    windowWidth = Window.getClientWidth();
    clientLeft = Document.get().getBodyOffsetLeft();
    clientTop = Document.get().getBodyOffsetTop();
}

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

License:Apache License

@Override
public void addHandler(final PTInstruction addHandler, final UIService uiService) {
    final String handler = addHandler.getString(HANDLER.KEY);

    if (HANDLER.KEY_.POPUP_POSITION_CALLBACK.equals(handler)) {
        final PopupPanel popupPanel = cast();

        popupPanel.setVisible(false);/*from   ww  w.j  a  v  a2s.c o m*/
        popupPanel.show();

        final PTInstruction eventInstruction = new PTInstruction();
        eventInstruction.setObjectID(addHandler.getObjectID());
        eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
        eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.POPUP_POSITION_CALLBACK);
        eventInstruction.put(PROPERTY.OFFSETWIDTH, popupPanel.getOffsetWidth());
        eventInstruction.put(PROPERTY.OFFSETHEIGHT, popupPanel.getOffsetHeight());
        eventInstruction.put(PROPERTY.CLIENT_WIDTH, Window.getClientWidth());
        eventInstruction.put(PROPERTY.CLIENT_HEIGHT, Window.getClientHeight());
        uiService.triggerEvent(eventInstruction);
        return;
    }

    super.addHandler(addHandler, uiService);
}

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.  j a  v  a 2 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);// w  w  w  .j a va  2s . co  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.
 * /*from   ww  w .j  a v  a2  s . co  m*/
 * @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//  www.  j av a2s  .  c om
        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.component.QRootPanel.java

License:Apache License

public void showMessage(String message, Integer delay, String styleClass, String[][] styleProperties) {
    showMessage(message, delay, styleClass, styleProperties, Window.getClientWidth());
}

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 {/* ww w.  j  a  va  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;
    }

}