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:org.cruxframework.crux.core.client.screen.views.ViewHandlers.java

License:Apache License

/**
 * @param handler/*from  w  w  w .  j  a v  a2 s .co m*/
 * @return
 */
private static HandlerRegistration addWindowResizeHandler(final ResizeHandler handler,
        final boolean lazyCheck) {
    ResizeHandler resizeHandler = new ResizeHandler() {
        public void onResize(ResizeEvent event) {
            if (!lazyCheck) {
                handler.onResize(event);
                return;
            }

            final ResizeBeginEndExecutor executor = new ResizeBeginEndExecutor(100, event) {
                private int clientHeight = Window.getClientHeight();
                private int clientWidth = Window.getClientWidth();

                @Override
                protected void doEndAction() {
                    if (!Screen.getCurrentDevice().equals(Device.largeDisplayMouse)) {
                        int newClientHeight = Window.getClientHeight();
                        int newClientWidth = Window.getClientWidth();

                        if (this.clientHeight != newClientHeight || clientWidth != newClientWidth
                                || Screen.isIos()) {
                            handler.onResize(getResizeEvent());
                        }
                        clientHeight = newClientHeight;
                        clientWidth = newClientWidth;
                    } else {
                        handler.onResize(getResizeEvent());
                    }
                }

                @Override
                protected void doBeginAction() {
                    // nothing
                }
            };

            executor.execute();
        }
    };

    final HandlerRegistration resizeHandlerRegistration = Window.addResizeHandler(resizeHandler);

    return new HandlerRegistration() {
        public void removeHandler() {
            if (resizeHandlerRegistration != null) {
                resizeHandlerRegistration.removeHandler();
            }
        }
    };
}

From source file:org.cruxframework.crux.smartfaces.client.dialog.PopupPanel.java

License:Apache License

/**
 * Gets the popup's left position relative to the browser's center area.
 * // w ww . j a  va2s . c  o  m
 * @return the popup's left position
 */
private int getPopupLeftToCenter() {
    int windowLeft = Window.getScrollLeft();
    int windowWidth = Window.getClientWidth();
    int centerLeft = (windowWidth / 2) + windowLeft;

    int offsetWidth = getOffsetWidth();
    return centerLeft - (offsetWidth / 2);
}

From source file:org.cruxframework.crux.smartfaces.client.dialog.PopupPanel.java

License:Apache License

private int getLeftRelativeObject(final UIObject relativeObject) {
    int offsetWidth = getOffsetWidth();
    int relativeElemOffsetWidth = relativeObject.getOffsetWidth();
    int offsetWidthDiff = offsetWidth - relativeElemOffsetWidth;
    int left;/*from   w w w. j a v a  2  s  .c  o m*/

    if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case

        int relativeElemAbsoluteLeft = relativeObject.getAbsoluteLeft();
        left = relativeElemAbsoluteLeft - offsetWidthDiff;
        if (offsetWidthDiff > 0) {
            int windowRight = Window.getClientWidth() + Window.getScrollLeft();
            int windowLeft = Window.getScrollLeft();

            int relativeElemLeftValForRightEdge = relativeElemAbsoluteLeft + relativeElemOffsetWidth;
            int distanceToWindowRight = windowRight - relativeElemLeftValForRightEdge;
            int distanceFromWindowLeft = relativeElemLeftValForRightEdge - windowLeft;
            if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) {
                left = relativeElemAbsoluteLeft;
            }
        }
    } else { // LTR case

        left = relativeObject.getAbsoluteLeft();
        if (offsetWidthDiff > 0) {
            int windowRight = Window.getClientWidth() + Window.getScrollLeft();
            int windowLeft = Window.getScrollLeft();
            int distanceToWindowRight = windowRight - left;
            int distanceFromWindowLeft = left - windowLeft;
            if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
                left -= offsetWidthDiff;
            }
        }
    }
    return left;
}

From source file:org.cruxframework.crux.smartfaces.client.util.dragdrop.GenericDragEventHandler.java

License:Apache License

@Override
public void onMouseDown(MouseDownEvent event) {
    if (DOM.getCaptureElement() == null) {
        windowWidth = Window.getClientWidth();
        clientLeft = Document.get().getBodyOffsetLeft();
        clientTop = Document.get().getBodyOffsetTop();

        dragging = true;//from  w  w w .jav  a2  s  .c  o m

        DOM.setCapture(action.getDraggable().getHandle(action.getFeature()).asWidget().getElement());

        dragStartX = event.getClientX();
        dragStartY = event.getClientY();

        action.onStartDrag();
    }
}

From source file:org.cruxframework.crux.widgets.client.datebox.NativeDateBox.java

License:Apache License

public NativeDateBox() {
    super();/*from   w w w . ja v  a  2  s . co m*/
    CruxCalendarView view = (CruxCalendarView) impl.getDatePicker().getView();
    view.getGrid().setHeight(Window.getClientHeight() + "px");
    view.getGrid().setWidth(Window.getClientWidth() + "px");

    CruxMonthSelector monthSelector = (CruxMonthSelector) impl.getDatePicker().getMonthSelector();
    monthSelector.getGrid().setWidth(Window.getClientWidth() + "px");

    CellFormatter formatter = monthSelector.getGrid().getCellFormatter();
    formatter.setWidth(0, 0, "15%");
    formatter.setWidth(0, 1, "15%");
    formatter.setWidth(0, 2, "40%");
    formatter.setWidth(0, 3, "15%");
    formatter.setWidth(0, 4, "15%");
}

From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java

License:Open Source License

public MetadataEdit(Document doc, boolean fullMode) {
    // moving init widget earlier
    if (!fullMode) {
        ScrollPanel sPanel = new ScrollPanel(form);

        int width = ((Window.getClientWidth() - 20) < 600 ? Window.getClientWidth() - 20 : 600);
        int height = ((Window.getClientHeight() - 70) < 500 ? Window.getClientHeight() - 70 : 500);

        sPanel.setWidth(width + "px");
        sPanel.setHeight(height + "px");
        initWidget(sPanel);//from   www.j  av  a 2  s . co  m
    } else
        initWidget(form);

    panel = new VerticalPanel();
    panel.addStyleName("metadata-edit-panel");

    form.setWidget(panel);
    form.setMethod(FormPanel.METHOD_POST);
    form.setEncoding(FormPanel.ENCODING_URLENCODED);

    bttSend.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            MetadataEdit.this.submit();
        }
    });
    bttSend.addStyleName("metadata-save");

    String txt = Main.getTranslation("metadata.save_button_text");
    if (txt.length() > 0 && !txt.equals("metadata.save_button_text")) {
        txtSend.setHTML(txt);
        txtSend.addStyleName("metadata-save-text");
    }

    sendContainer.addStyleName("righttext");
    sendContainer.add(bttSend);
    sendContainer.add(txtSend);

    if (doc != null)
        init(doc, fullMode);
    addStyleName("metadata-edit");
}

From source file:org.dataconservancy.dcs.access.client.presenter.CuratorViewPresenter.java

License:Apache License

@Override
public void bind() {
    userService.checkSession(null, new AsyncCallback<UserSession>() {

        @Override//from w w  w.ja va  2 s .c o m
        public void onSuccess(final UserSession session) {
            if (session.getVivoId() != null) {
                vivoService.getAgentAffiliation(session.getVivoId(), new AsyncCallback<String>() {

                    @Override
                    public void onSuccess(final String repository) {
                        registryService.getAllCOs(repository, null, SeadApp.roUrl,
                                new AsyncCallback<List<ROMetadata>>() {

                                    @Override
                                    public void onSuccess(final List<ROMetadata> allCOs) {

                                        final Grid curatorData = new Grid(allCOs.size() + 1, 6);
                                        curatorData.setStyleName("curatorTable");
                                        curatorData.setWidth(Window.getClientWidth() / 2 + "px");

                                        curatorData.setWidget(0, 0,
                                                Util.label("Research Object Name", "SubsectionHeader"));
                                        curatorData.setWidget(0, 1,
                                                Util.label("Date Last Modified", "SubsectionHeader"));
                                        curatorData.setWidget(0, 2,
                                                Util.label("Current Assignment", "SubsectionHeader"));
                                        curatorData.setWidget(0, 3,
                                                Util.label("Modify Assignment", "SubsectionHeader"));
                                        curatorData.setWidget(0, 4, Util.label("Edit", "SubsectionHeader"));
                                        curatorData.setWidget(0, 5, Util.label("Publish", "SubsectionHeader"));

                                        curatorData.getRowFormatter().addStyleName(0, "curatoreHead");

                                        int i = 1;
                                        for (final ROMetadata ro : allCOs) {
                                            if (ro.getIsObsolete() == 1)
                                                continue;
                                            Label lbName = new Label();
                                            lbName.setText(ro.getName());
                                            Label dateLbl = new Label();
                                            dateLbl.setText(ro.getUpdatedDate());
                                            curatorData.setWidget(i, 0, lbName);
                                            curatorData.setWidget(i, 1, dateLbl);
                                            final Button edit = new Button("Edit");
                                            edit.setEnabled(false);
                                            final Button publish = new Button("Publish");
                                            publish.setEnabled(false);
                                            final int index = i;

                                            final Button reAssign = new Button("Re-assign to me");
                                            final Button unAssign = new Button("Unassign");

                                            final ClickHandler publishHandler = new ClickHandler() {

                                                @Override
                                                public void onClick(ClickEvent event) {
                                                    registryService.isObsolete(ro.getIdentifier(),
                                                            SeadApp.registryUrl, new AsyncCallback<Boolean>() {

                                                                @Override
                                                                public void onSuccess(Boolean isObsolete) {
                                                                    if (isObsolete) {
                                                                        ErrorPopupPanel popupPanel = new ErrorPopupPanel(
                                                                                "Sorry, this RO was ingested by another curator. Please select another RO to work on.");
                                                                        popupPanel.show();
                                                                        popupPanel.addCloseHandler(
                                                                                new CloseHandler<PopupPanel>() {

                                                                                    @Override
                                                                                    public void onClose(
                                                                                            CloseEvent<PopupPanel> event) {
                                                                                        History.newItem(
                                                                                                SeadState.CURATOR
                                                                                                        .toToken(
                                                                                                                "refresh"));
                                                                                    }
                                                                                });
                                                                    } else {
                                                                        registryService.getRelation(
                                                                                ro.getIdentifier(),
                                                                                SeadApp.registryUrl,
                                                                                "curatedBy",
                                                                                new AsyncCallback<String>() {
                                                                                    @Override
                                                                                    public void onSuccess(
                                                                                            String agentId) {
                                                                                        if (agentId.equals(
                                                                                                session.getRegistryId()))
                                                                                            submitSip(ro
                                                                                                    .getIdentifier(),
                                                                                                    publish,
                                                                                                    edit, index,
                                                                                                    false,
                                                                                                    curatorData,
                                                                                                    unAssign);
                                                                                        else {
                                                                                            ErrorPopupPanel popupPanel = new ErrorPopupPanel(
                                                                                                    "Sorry, this RO was reassigned to someone else. Please select another RO to work on.");
                                                                                            popupPanel.show();
                                                                                            popupPanel
                                                                                                    .addCloseHandler(
                                                                                                            new CloseHandler<PopupPanel>() {

                                                                                                                @Override
                                                                                                                public void onClose(
                                                                                                                        CloseEvent<PopupPanel> event) {
                                                                                                                    History.newItem(
                                                                                                                            SeadState.CURATOR
                                                                                                                                    .toToken(
                                                                                                                                            "refresh"));
                                                                                                                }
                                                                                                            });

                                                                                        }
                                                                                    }

                                                                                    @Override
                                                                                    public void onFailure(
                                                                                            Throwable caught) {
                                                                                        new ErrorPopupPanel(
                                                                                                "Error:" + caught
                                                                                                        .getMessage())
                                                                                                                .show();
                                                                                    }
                                                                                });
                                                                    }
                                                                }

                                                                @Override
                                                                public void onFailure(Throwable caught) {
                                                                    new ErrorPopupPanel(
                                                                            "Error:" + caught.getMessage())
                                                                                    .show();
                                                                }
                                                            });

                                                }
                                            };

                                            final ClickHandler editClickHandler = new ClickHandler() {

                                                @Override
                                                public void onClick(ClickEvent event) {
                                                    registryService.isObsolete(ro.getIdentifier(),
                                                            SeadApp.registryUrl, new AsyncCallback<Boolean>() {

                                                                @Override
                                                                public void onSuccess(Boolean isObsolete) {
                                                                    if (isObsolete) {
                                                                        ErrorPopupPanel popupPanel = new ErrorPopupPanel(
                                                                                "Sorry, this RO was ingested by another curator. Please select another RO to work on.");
                                                                        popupPanel.show();
                                                                        popupPanel.addCloseHandler(
                                                                                new CloseHandler<PopupPanel>() {

                                                                                    @Override
                                                                                    public void onClose(
                                                                                            CloseEvent<PopupPanel> event) {
                                                                                        History.newItem(
                                                                                                SeadState.CURATOR
                                                                                                        .toToken(
                                                                                                                "refresh"));
                                                                                    }
                                                                                });
                                                                    } else {
                                                                        registryService.getRelation(
                                                                                ro.getIdentifier(),
                                                                                SeadApp.registryUrl,
                                                                                "curatedBy",
                                                                                new AsyncCallback<String>() {

                                                                                    @Override
                                                                                    public void onSuccess(
                                                                                            String agentId) {
                                                                                        if (agentId.equals(
                                                                                                session.getRegistryId()))
                                                                                            History.newItem(
                                                                                                    SeadState.EDIT
                                                                                                            .toToken(
                                                                                                                    ro.getIdentifier()));
                                                                                        else {
                                                                                            new ErrorPopupPanel(
                                                                                                    "Sorry, this RO was reassigned to someone else. Please select another RO to work on.")
                                                                                                            .show();
                                                                                            History.newItem(
                                                                                                    SeadState.CURATOR
                                                                                                            .toToken(
                                                                                                                    "refresh"));

                                                                                        }
                                                                                    }

                                                                                    @Override
                                                                                    public void onFailure(
                                                                                            Throwable caught) {
                                                                                        new ErrorPopupPanel(
                                                                                                "Error:" + caught
                                                                                                        .getMessage())
                                                                                                                .show();
                                                                                    }
                                                                                });
                                                                    }
                                                                }

                                                                @Override
                                                                public void onFailure(Throwable caught) {
                                                                    new ErrorPopupPanel(
                                                                            "Error:" + caught.getMessage())
                                                                                    .show();
                                                                }
                                                            });
                                                }
                                            };

                                            publish.addClickHandler(publishHandler);
                                            edit.addClickHandler(editClickHandler);

                                            final Button assign = new Button("Assign to me");
                                            ClickHandler unAssignHandler = new ClickHandler() {

                                                @Override
                                                public void onClick(ClickEvent event) {
                                                    registryService.unassignFromAgent(ro.getIdentifier(),
                                                            session.getRegistryId(), SeadApp.registryUrl,
                                                            new AsyncCallback<Boolean>() {

                                                                @Override
                                                                public void onSuccess(Boolean result) {
                                                                    edit.setEnabled(false);
                                                                    publish.setEnabled(false);
                                                                    publish.removeStyleName("grayButton");
                                                                    publish.setStyleName("gwt-Button");
                                                                    curatorData.setWidget(index, 2,
                                                                            new Label("No one"));
                                                                    curatorData.setWidget(index, 3, assign);
                                                                }

                                                                @Override
                                                                public void onFailure(Throwable caught) {
                                                                    unAssign.setText("Failed");
                                                                    unAssign.setEnabled(false);
                                                                }
                                                            });
                                                }
                                            };
                                            unAssign.addClickHandler(unAssignHandler);

                                            assign.addClickHandler(new ClickHandler() {
                                                @Override
                                                public void onClick(ClickEvent event) {
                                                    registryService.assignToAgent(ro.getIdentifier(),
                                                            session.getRegistryId(), SeadApp.registryUrl,
                                                            new AsyncCallback<Boolean>() {

                                                                @Override
                                                                public void onSuccess(Boolean result) {
                                                                    curatorData.setWidget(index, 2,
                                                                            Util.label("You", "greenFont"));
                                                                    curatorData.setWidget(index, 3, unAssign);
                                                                    assign.setEnabled(false);
                                                                    edit.setEnabled(true);
                                                                    publish.setEnabled(true);
                                                                    publish.setStyleName("grayButton");
                                                                }

                                                                @Override
                                                                public void onFailure(Throwable caught) {
                                                                    assign.setText("Failed");
                                                                    assign.setEnabled(false);
                                                                }
                                                            });
                                                }
                                            });

                                            reAssign.addClickHandler(new ClickHandler() {

                                                @Override
                                                public void onClick(ClickEvent event) {
                                                    registryService.assignToAgent(ro.getIdentifier(),
                                                            session.getRegistryId(), SeadApp.registryUrl,
                                                            new AsyncCallback<Boolean>() {

                                                                @Override
                                                                public void onSuccess(Boolean result) {
                                                                    curatorData.setWidget(index, 2,
                                                                            Util.label("You", "greenFont"));
                                                                    curatorData.setWidget(index, 3, unAssign);
                                                                    edit.setEnabled(true);
                                                                    publish.setEnabled(true);
                                                                    publish.setStyleName("grayButton");
                                                                }

                                                                @Override
                                                                public void onFailure(Throwable caught) {
                                                                    reAssign.setText("Failed");
                                                                    reAssign.setEnabled(false);
                                                                }
                                                            });
                                                }
                                            });

                                            if (ro.getAgentId() == null) {
                                                curatorData.setWidget(i, 2, new Label("No one"));
                                                curatorData.setWidget(i, 3, assign);
                                            } else if (ro.getAgentId().trim()
                                                    .equalsIgnoreCase(session.getRegistryId().trim())) {
                                                curatorData.setWidget(i, 2, Util.label("You", "greenFont"));
                                                curatorData.setWidget(i, 3, unAssign);
                                                edit.setEnabled(true);
                                                publish.setEnabled(true);
                                                publish.setStyleName("grayButton");
                                            } else if (!ro.getAgentId()
                                                    .equalsIgnoreCase(session.getRegistryId())) {

                                                userService.getUser(ro.getAgentId(),
                                                        new AsyncCallback<Person>() {

                                                            @Override
                                                            public void onSuccess(Person user) {
                                                                curatorData.setWidget(index, 2,
                                                                        Util.label(
                                                                                user.getFirstName() + " "
                                                                                        + user.getLastName(),
                                                                                "greenFont"));

                                                                curatorData.setWidget(index, 3, reAssign);

                                                            }

                                                            @Override
                                                            public void onFailure(Throwable caught) {
                                                                // TODO Auto-generated method stub

                                                            }
                                                        });

                                            }

                                            curatorData.setWidget(i, 4, edit);

                                            curatorData.getRowFormatter().setStyleName(i, "CuratorRow");
                                            curatorData.setWidget(i, 5, publish);

                                            i++;
                                        }
                                        String institution = repository;
                                        if (repository.contains("IU"))
                                            institution = "Indiana University";
                                        display.getPublishContainer().clear();
                                        display.getPublishContainer()
                                                .add(Util.label("Curation Objects Review for " + institution,
                                                        "CurationHeader"));
                                        display.getPublishContainer().add(curatorData);

                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        new ErrorPopupPanel("Error:" + caught.getMessage()).show();
                                    }
                                });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        new ErrorPopupPanel("Failed to retrieve from VIVO:" + caught.getMessage()).show();
                    }
                });
            } else {
                new ErrorPopupPanel(
                        "User does not have a VIVO ID, hence cannot find the Affiliation/Curator queue.")
                                .show();
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            new ErrorPopupPanel("Error:" + caught.getMessage());
        }
    });

}

From source file:org.dataconservancy.dcs.access.client.view.CuratorView.java

public CuratorView() {
    publishContainer = new VerticalPanel();
    publishContainer.addStyleName("curatorView");
    Image loadImage = new Image("images/loading.gif");
    final int height = Window.getClientHeight();
    final int width = Window.getClientWidth();
    loadImage.getElement().getStyle().setProperty("marginTop", String.valueOf((height / 4)) + "px");
    loadImage.getElement().getStyle().setProperty("marginLeft", String.valueOf((width / 4) - 20) + "px");

    publishContainer.add(loadImage);//w ww.  ja  v  a2 s  .c o m

}

From source file:org.dataconservancy.dcs.access.client.view.ProvenanceView.java

License:Apache License

public ProvenanceView() {
    provenancePanel = new FlowPanel();
    provenancePanel.setWidth("100%");
    Label lbl = new Label("Monitor Workflows");
    lbl.setStyleName("SectionHeader");
    final int width = Window.getClientWidth();
    lbl.getElement().getStyle().setProperty("marginLeft", String.valueOf((width / 2) - 70) + "px");

    provenancePanel.add(lbl);//from  ww  w . j a  va  2 s  .c o  m
    loadImage = new Image("images/loading.gif");
    loadImage.setHeight(String.valueOf(width / 80) + "px");
    loadImage.setWidth(String.valueOf(width / 80) + "px");
    loadImage.getElement().getStyle().setProperty("marginLeft", String.valueOf((width / 2) - 20) + "px");
    final int height = Window.getClientHeight();
    loadImage.getElement().getStyle().setProperty("marginTop", String.valueOf((height / 4)) + "px");
    provenancePanel.add(loadImage);

}

From source file:org.daxplore.presenter.client.ui.StagePanel.java

License:Open Source License

/**
 * Update stage panel width and content to fill up the window.
 *//*from w  w w  . java  2s.co m*/
public void updateWidth() {
    Scheduler.get().scheduleFinally(new ScheduledCommand() {
        @Override
        public void execute() {
            int desiredStagePanelWidth = Math.max(minWidth, Window.getClientWidth());
            int widthOfOtherStuff = StagePanel.this.getOffsetWidth() - chartPanel.getOffsetWidth();
            chartPanel.setMaxWidth(desiredStagePanelWidth - widthOfOtherStuff);
        }
    });
}