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.freemedsoftware.gwt.client.widget.Popup.java

License:Open Source License

public void setPosition() {

    setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            int left = ((Window.getClientWidth() - offsetWidth) / widthmodifier) + widthoffset;
            int top = ((Window.getClientHeight() - offsetHeight) / heightmodifier) + heightoffset;
            setPopupPosition(left, top);
            // setStylePrimaryName("freemed-MessageBox-Popup");
        }/*from  ww  w  .  java  2s .c o m*/
    });
    //center();
    this.getElement().getStyle().setPosition(Position.FIXED);
}

From source file:org.freemedsoftware.gwt.client.widget.SchedulerWidget.java

License:Open Source License

public SchedulerWidget() {
    super(moduleName);

    ////////////Applying stored configurations////////////////
    int startHour = 10;
    int endHour = 18;
    int intervalsPerHour = 4;
    show24HourClock = false;//from  w w w. j a  v a 2s . c  om
    int intervalHeight = 50;
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        startHour = CurrentState.getSystemConfig("calshr") != null
                ? Integer.parseInt(CurrentState.getSystemConfig("calshr"))
                : startHour;
        endHour = CurrentState.getSystemConfig("calehr") != null
                ? Integer.parseInt(CurrentState.getSystemConfig("calehr"))
                : endHour;
        intervalsPerHour = CurrentState.getSystemConfig("calinterval") != null
                ? (60 / Integer.parseInt(CurrentState.getSystemConfig("calinterval")))
                : intervalsPerHour;
        intervalHeight = CurrentState.getSystemConfig("calintervalheight") != null
                ? Integer.parseInt(CurrentState.getSystemConfig("calintervalheight"))
                : intervalHeight;
        show24HourClock = CurrentState.getSystemConfig("calshow24hourclock") != null
                ? (Integer.parseInt(CurrentState.getSystemConfig("calshow24hourclock")) == 1)
                : show24HourClock;
    }
    StringPanelRenderer panelRenderer = new StringPanelRenderer();
    panelRenderer.setStartHour(startHour);
    panelRenderer.setEndHour(endHour);
    panelRenderer.setIntervalsPerHour(intervalsPerHour);
    panelRenderer.setShow24HourClock(show24HourClock);
    panelRenderer.setIntervalHeight(intervalHeight);
    ////////////End configurations////////////////      

    filterModulesAndMethods.put("ProviderModule", "GetDailyAppointmentsRange");
    filterModulesAndMethods.put("ProviderGroups", "GetDailyAppointmentsRangeByProviderGroup");
    SELECTED_MODULE = "ProviderModule";

    eventCacheController = new EventCacheController();
    multiPanel = new MultiView(eventCacheController, panelRenderer);
    panel.setWidth("100%");
    final HorizontalPanel loadingContainer = new HorizontalPanel();
    loadingContainer.add(new Image("resources/images/loading.gif"));
    loadingContainer.add(new HTML("<h3>" + "Loading" + "</h3>"));
    loadingDialog.setStylePrimaryName(SchedulerCss.EVENT_DIALOG);
    loadingDialog.setWidget(loadingContainer);
    loadingDialog.hide();

    final VerticalPanel headerArea = new VerticalPanel();
    headerArea.setWidth("100%");

    final HorizontalPanel fields = new HorizontalPanel();
    fields.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    fields.setWidth("100%");
    headerArea.add(fields);
    panel.add(headerArea, DockPanel.NORTH);

    /*
     * fields.add(label); fields.setCellHeight(label, "50%");
     */

    final HorizontalPanel filterPanel = new HorizontalPanel();
    fields.add(filterPanel);
    // fields.setCellWidth(filterPanel, "50%");
    Label selectFilterLabel = new Label(_("Filter by") + " :");
    selectFilterLabel.setStyleName(AppConstants.STYLE_LABEL_LARGE_BOLD);
    filterPanel.add(selectFilterLabel);

    final CustomListBox selectFilter = new CustomListBox();
    selectFilter.addItem(_("Provider"), "ProviderModule");
    selectFilter.addItem(_("Provider Groups"), "ProviderGroups");
    selectFilter.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent arg0) {
            SELECTED_MODULE = selectFilter.getStoredValue();
            filterModule.setModuleName(SELECTED_MODULE);
            filterModule.setValue(0);
        }
    });
    filterPanel.add(selectFilter);

    filterModule.setModuleName("ProviderModule");
    filterModule.setWidth("300px");
    filterModule.addValueChangeHandler(new ValueChangeHandler<Integer>() {
        @Override
        public void onValueChange(ValueChangeEvent<Integer> event) {
            Integer val = ((SupportModuleWidget) event.getSource()).getValue();
            // Log.debug("Patient value = " + val.toString());
            try {
                if (val.compareTo(new Integer(0)) != 0) {
                    multiPanel.clearData();
                    eventCacheController.getEventsForRange(multiPanel.getCurrent().getFirstDateLogical(),
                            multiPanel.getCurrent().getLastDateLogical(), val,
                            filterModulesAndMethods.get(SELECTED_MODULE), multiPanel, true);
                }
            } catch (Exception e) {
                // Don't do anything if no patient is declared
                GWT.log("Caught exception", e);
            }
        }
    });
    filterPanel.add(filterModule);

    CustomButton clearButton = new CustomButton(_("Clear"), AppConstants.ICON_CLEAR);
    clearButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            filterModule.setValue(0);
            eventCacheController.getEventsForRange(multiPanel.getCurrent().getFirstDateLogical(),
                    multiPanel.getCurrent().getLastDateLogical(), multiPanel, true);
        }
    });
    filterPanel.add(clearButton);

    final HorizontalPanel fields2Panel = new HorizontalPanel();
    fields2Panel.setSpacing(5);
    CustomButton showPicker = new CustomButton(_("Jump"));
    fields2Panel.add(showPicker);

    if (CurrentState.isActionAllowed(blockSlotsModuleName, AppConstants.SHOW)) {
        CustomButton showBlockSlots = new CustomButton(_("Block Slots"));
        showBlockSlots.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent arg0) {
                BlockTimeSlotPopup blockTimeSlotPopup = new BlockTimeSlotPopup();
                blockTimeSlotPopup.show();
                blockTimeSlotPopup.center();
            }
        });
        fields2Panel.add(showBlockSlots);
    }

    headerArea.add(fields2Panel);

    final VerticalPanel posPanel = new VerticalPanel();
    posPanel.setVisible(false);
    posPanel.setWidth("100%");
    HorizontalPanel pickerHolder = new HorizontalPanel();
    pickerHolder.add(posPanel);
    pickerHolder.add(multiPanel);

    showPicker.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            posPanel.setVisible(!posPanel.isVisible());
            if (posPanel.isVisible())
                multiPanel.setPixelSize((Window.getClientWidth() * 78) / 100,
                        (Window.getClientHeight() * 70) / 100);
            else
                multiPanel.setPixelSize((Window.getClientWidth() * 87) / 100,
                        (Window.getClientHeight() * 70) / 100);
        }
    });

    HTML space = new HTML("");
    posPanel.add(space);
    space.setHeight("40px");
    posPanel.add(navigator);
    // navigator.setVisible(false);
    // pickerHolder.setCellWidth(posPanel, "200px");
    pickerHolder.setVerticalAlignment(VerticalPanel.ALIGN_TOP);

    pickerHolder.setCellWidth(multiPanel, "100%");
    multiPanel.setWidth("100%");
    multiPanel.setPixelSize((Window.getClientWidth() * 87) / 100, (Window.getClientHeight() * 300) / 100);

    // posPanel.setWidth("200px");

    panel.add(pickerHolder, DockPanel.CENTER);
    pickerHolder.setWidth("100%");
    onWindowResized(-1, Window.getClientHeight());
    panel.setStyleName("whiteForDemo");
    multiPanel.addDateListener(this);
    navigator.addDateListener(this);
    Window.addResizeHandler(this);
    multiPanel.scrollToHour(7);

    initWidget(panel);
}

From source file:org.freemedsoftware.gwt.client.widget.Toaster.java

License:Open Source License

protected void refreshDisplay() {
    // If there are items...
    if (items.keySet().size() > 0) {
        // Set positioning at bottom left of screen
        try {//from ww  w .j av  a 2  s.com
            hide();
        } catch (Exception e) {
            GWT.log("Exception", e);
        }

        // Loop through and set CSS properly
        Iterator<String> ks = items.keySet().iterator();
        while (ks.hasNext()) {
            final String k = (String) ks.next();
            if (!ks.hasNext()) {
                // If this is the last one, set to special
                ((HTML) itemWidgets.get(k)).setStylePrimaryName("freemed-ToasterItem-Last");
            } else {
                // Otherwise regular style
                ((HTML) itemWidgets.get(k)).setStylePrimaryName("freemed-ToasterItem");
            }
        }

        try {
            setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int left = (Window.getClientWidth() - offsetWidth) - 5;
                    int top = (Window.getClientHeight() - offsetHeight) - 5;
                    setPopupPosition(left, top + Window.getScrollTop());
                }
            });

        } catch (Exception e) {
            GWT.log("Exception attempting to popup toaster", e);
        }
    } else {
        hide();
    }
}

From source file:org.gems.ajax.client.util.Util.java

License:Open Source License

public static void showErrorMessage(String error) {
    DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    simplePopup.ensureDebugId("cwBasicPopup-simplePopup");
    simplePopup.setWidth("150px");
    simplePopup.setWidget(new HTML(error));
    simplePopup.setPopupPosition(Util.half(Window.getClientWidth()), Util.half(Window.getClientHeight()));
    simplePopup.show();/*from   w  ww.  jav a  2s.  c  om*/
}

From source file:org.geomajas.gwt2.example.base.client.ExampleBase.java

License:Open Source License

public static void showSample(ShowcaseSampleDefinition sample) {
    ShowcaseDialogBox dialogBox = new ShowcaseDialogBox();
    dialogBox.setAnimationEnabled(true);
    dialogBox.setAutoHideEnabled(false);
    dialogBox.setModal(true);//  w w w  .  jav  a 2  s. c  o  m
    dialogBox.setGlassEnabled(true);
    dialogBox.setText(sample.getTitle());
    SamplePage page = new SamplePage();
    int width = Window.getClientWidth() - 200;
    int height = Window.getClientHeight() - 160;
    page.setSize(width + "px", height + "px");
    page.setSamplePanelFactory(sample);
    dialogBox.setWidget(page);
    dialogBox.center();
    dialogBox.show();
}

From source file:org.geomajas.gwt2.plugin.corewidget.example.client.sample.dialog.CloseableDialogBoxWidgetViewImpl.java

License:Open Source License

@Override
public void show() {

    // Set the CloseableDialogBox to half the client size when nothing has been set.
    if (!isSizeSet) {
        widget.setWidth(Window.getClientWidth() / 2 + "px");
        contentScrollPanel.setHeight(Window.getClientHeight() / 2 + "px");
        widget.center();/*  w w  w.ja  va  2s  . c o  m*/
        isSizeSet = true;
    }

    widget.show();

}

From source file:org.geomajas.gwt2.plugin.corewidget.example.client.sample.map.MapLegendDropDown.java

License:Open Source License

private int calculateLeft(int offsetWidth) {
    // Calculate left position for the popup. The computation for
    // the left position is bidi-sensitive.
    int textBoxOffsetWidth = this.getOffsetWidth();

    // Compute the difference between the popup's width and the
    // textbox's width
    int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;

    int left = this.getAbsoluteLeft();
    // If the suggestion popup is not as wide as the text box, always align to
    // the left edge of the text box. Otherwise, figure out whether to
    // left-align or right-align the popup.
    if (offsetWidthDiff > 0) {
        // Make sure scrolling is taken into account, since
        // box.getAbsoluteLeft() takes scrolling into account.
        int windowRight = Window.getClientWidth() + Window.getScrollLeft();
        int windowLeft = Window.getScrollLeft();

        // Distance from the left edge of the text box to the right edge
        // of the window
        int distanceToWindowRight = windowRight - left;

        // Distance from the left edge of the text box to the left edge of the
        // window
        int distanceFromWindowLeft = left - windowLeft;

        // If there is not enough space for the overflow of the popup's
        // width to the right of hte text box, and there IS enough space for the
        // overflow to the left of the text box, then right-align the popup.
        // However, if there is not enough space on either side, then stick with
        // left-alignment.
        if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
            // Align with the right edge of the text box.
            left -= offsetWidthDiff;// ww  w.jav a  2s.  c  o m
        }
    }
    return left;
}

From source file:org.geowe.client.local.main.tool.info.LayerEditDialog.java

License:Open Source License

private int computeWidth() {
    return Window.getClientWidth() - (HORIZONTAL_MARGIN * 2);
}

From source file:org.gwm.client.impl.DefaultGFrame.java

License:Apache License

public void maximize() {

    if (maxWidth == 0) {
        this.width = Window.getClientWidth();
    } else {/*from w w  w . j  a v  a  2  s. c o m*/
        this.width = maxWidth;
    }
    if (maxHeight == 0) {
        this.height = Window.getClientHeight();
    } else {
        this.height = maxHeight;
    }
    this.previousTop = getAbsoluteTop();
    this.previousLeft = getAbsoluteLeft();
    this.previousWidth = getWidth();
    this.previousHeight = getHeight();

    setLocation(0, 0);
    setSize(width, height);
    this.maximized = true;
    fireFrameMaximized();
}