Java Code Examples for com.google.gwt.user.client.Window#getClientWidth()

The following examples show how to use com.google.gwt.user.client.Window#getClientWidth() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: unitime   File: FilterBox.java    License: Apache License 2.0 6 votes vote down vote up
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) {
	int textBoxOffsetWidth = relativeObject.getOffsetWidth();
	int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;
	int 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;
		}
	}
	int top = relativeObject.getAbsoluteTop();
	int windowTop = Window.getScrollTop();
	int windowBottom = Window.getScrollTop() + Window.getClientHeight();
	int distanceFromWindowTop = top - windowTop;
	int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());
	if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
		top -= offsetHeight;
	} else {
		top += relativeObject.getOffsetHeight();
	}
	setPopupPosition(left, top);
}
 
Example 2
@Override
public void open() {
	StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN);
	Element menuElt = this.menuContainer.getElement();
	int topMenu = menuElt.getAbsoluteTop() - Window.getScrollTop();
	int menuHeight = menuElt.getOffsetHeight();
	int anchorHeight = this.anchor.getOffsetHeight();
	int clientHeight = Window.getClientHeight();
	if (topMenu + menuHeight > clientHeight && topMenu >= anchorHeight + menuHeight) {
		StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_UP);
	}
	int leftMenu = menuElt.getAbsoluteLeft() - Window.getScrollLeft();
	int menuWidth = menuElt.getOffsetWidth();
	int anchorWidth = this.anchor.getOffsetWidth();
	int clientWidth = Window.getClientWidth();
	if (leftMenu + menuWidth > clientWidth && leftMenu >= anchorWidth + menuWidth) {
		StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_LEFT);
	}
	this.open = true;
	this.updateHandlers();
}
 
Example 3
private Rectangle getVisiblePart() {
  if (DomUtil.hasScrollers(myContext.rootElement)) {
    return DomUtil.visiblePart(myContext.rootElement);
  } else {
    return new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
  }
}
 
Example 4
Source Project: unitime   File: UniTimeFrameDialog.java    License: Apache License 2.0 5 votes vote down vote up
public static void openDialog(String title, String source, String width, String height, boolean noCacheTS) {
	if (sDialog == null) {
		if (Window.getClientWidth() <= 800)
			sDialog = GWT.create(UniTimeFrameDialogDisplay.Mobile.class);
		else
			sDialog = GWT.create(UniTimeFrameDialogDisplay.class);
	}
	sDialog.openDialog(title, source, width, height, noCacheTS);
}
 
Example 5
private boolean cursorInsideBrowserContentArea(Event event) {
    if (event.getClientX() < 0 || event.getClientY() < 0) {
        // Outside to the left or above
        return false;
    }

    if (event.getClientX() > Window.getClientWidth()
            || event.getClientY() > Window.getClientHeight()) {
        // Outside to the right or below
        return false;
    }

    return true;
}
 
Example 6
/**
 * Shows the popup 
 */
public void show(int selectedFrom) {
	this.selectedFrom = selectedFrom;
	initButtons();
	int left = (Window.getClientWidth() - 400) / 2;
	int top = (Window.getClientHeight() - 325) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("thesaurus.directory.select.label"));

	// Resets to initial tree value
	thesaurusPanel.reset();

	center();
}
 
Example 7
/**
 * Shows de popup
 */
public void show() {
	setText(GeneralComunicator.i18n("confirm.label"));
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 125) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 8
/**
 * Shows de popup
 */
public void show() {
	setText(GeneralComunicator.i18nExtension("confirm.label"));
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 125) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 9
Source Project: unitime   File: PageLabel.java    License: Apache License 2.0 5 votes vote down vote up
public PageLabel() {
	if (Window.getClientWidth() <= 800)
		iDisplay = GWT.create(PageLabelDisplay.Mobile.class);
	else
		iDisplay = GWT.create(PageLabelDisplay.class);
	initWidget(iDisplay.asWidget());
}
 
Example 10
/**
 * Show the popup error
 *
 * @param msg Error message
 */
public void show(String msg) {
	//TODO: aqui pueden haber problemas de concurrencia al ser llamado simultaneamente este método
	// cabe la posibilidad de perder algun mensaje de error.
	if (!text.getHTML().equals("")) {
		text.setHTML(text.getHTML() + "<br><br>" + msg);
	} else {
		text.setHTML(msg);
	}
	setText(Main.i18n("error.label"));
	int left = (Window.getClientWidth() - 380) / 2;
	int top = (Window.getClientHeight() - 200) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 11
/**
 * Shows the popup 
 */
public void show() {
	initButtons();
	int left = (Window.getClientWidth() - 700) / 2;
	int top = (Window.getClientHeight() - 350) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("search.similar.document"));

	// Resets to initial tree value
	removeAllRows();
	evaluateEnableAction();
	super.show();
}
 
Example 12
/**
 * Show the popup error
 *
 * @param msg Error message
 */
public void show() {
	setText(Main.i18n("workflow.label"));
	findLatestProcessDefinitions(); // Gets all groups
	listBox.setVisible(true);
	addButton.setEnabled(false);
	workflowWidget = null;
	listBox.setVisible(true);
	sp.setVisible(false);
	sp.clear();
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 100) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 13
/**
 * Show the popup error
 *
 * @param msg Error message
 */
public void show() {
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 100) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("group.label"));
	validate = -1;
	groupListBox.clear();
	propertyListBox.clear();
	propertyListBox.setVisible(false);
	propertyLabel.setVisible(false);
	getAllGroups(); // Gets all groups
	addButton.setEnabled(false);
	super.show();
}
 
Example 14
/**
 * Shows the popup 
 */
public void show() {
	initButtons();
	status.setVisible(false);
	int left = (Window.getClientWidth() - 450) / 2;
	int top = (Window.getClientHeight() - 440) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("trash.directory.select.label"));

	// Resets to initial tree value
	folderSelectTree.reset();
	super.show();
}
 
Example 15
/**
 * Shows de popup
 */
public void show() {
	url.setText("http://");
	int left = (Window.getClientWidth() - 300) / 2;
	int top = (Window.getClientHeight() - 125) / 2;
	setPopupPosition(left, top);
	super.show();
}
 
Example 16
/**
 * Shows the popup 
 */
public void show() {
	initButtons();
	int left = (Window.getClientWidth() - 700) / 2;
	int top = (Window.getClientHeight() - 350) / 2;
	setPopupPosition(left, top);
	setText(Main.i18n("search.folder.filter"));

	// Resets to initial tree value
	removeAllRows();
	keyword.setText("");
	evaluateEnableAction();
	super.show();
	keyword.setFocus(true);
}
 
Example 17
Source Project: unitime   File: UniTimeMenuBar.java    License: Apache License 2.0 4 votes vote down vote up
private boolean needsMove() {
	return iLastClientWidth != Window.getClientWidth() ||
		iLastScrollLeft != Window.getScrollLeft() || iLastScrollTop != Window.getScrollTop();
}
 
Example 18
private int computeWidth() {
	return Window.getClientWidth() - (HORIZONTAL_MARGIN * 2);
}
 
Example 19
Source Project: cuba   File: Tools.java    License: Apache License 2.0 4 votes vote down vote up
public static void showPopup(VOverlay overlay, int left, int top) {
    overlay.setAutoHideEnabled(true);
    overlay.setVisible(false);
    overlay.show();

    Widget widget = overlay.getWidget();
    if (widget instanceof VVerticalLayout) {
        resetItemSelection(widget);

        VVerticalLayout verticalLayout = (VVerticalLayout) widget;
        if (verticalLayout.getStyleName().contains(CUBA_CONTEXT_MENU_CONTAINER)) {
            int widgetCount = verticalLayout.getWidgetCount();
            if (widgetCount > 1) {
                Widget verticalSlot = verticalLayout.getWidget(0);
                Widget buttonWidget = ((Slot) verticalSlot).getWidget();
                buttonWidget.addStyleName(SELECTED_ITEM_STYLE);
                if (buttonWidget instanceof FocusWidget) {
                    ((FocusWidget) buttonWidget).setFocus(true);
                }
            }
        }
    }

    // mac FF gets bad width due GWT popups overflow hacks,
    // re-determine width
    int offsetWidth = overlay.getOffsetWidth();
    int offsetHeight = overlay.getOffsetHeight();
    if (offsetWidth + left > Window.getClientWidth()) {
        left = left - offsetWidth;
        if (left < 0) {
            left = 0;
        }
    }
    if (offsetHeight + top > Window.getClientHeight()) {
        top = top - offsetHeight;
        if (top < 0) {
            top = 0;
        }
    }

    overlay.setPopupPosition(left, top);
    overlay.setVisible(true);
}
 
Example 20
public StartUpPopup() {
	// Establishes auto-close when click outside
	super(false, true);

	vPanel = new VerticalPanel();
	status = new VerticalPanel();
	table = new FlexTable();
	button = new Button(Main.i18n("button.close"), this);
	scrollPanel = new ScrollPanel(status);
	scrollPanel.setAlwaysShowScrollBars(false);
	scrollPanel.setSize("490px", "160px");
	scrollPanel.setStyleName("okm-Input");

	status.setWidth("" + (490 - IE_SIZE_RECTIFICATION) + "px");

	vPanel.add(new HTML("&nbsp;"));
	vPanel.add(scrollPanel);
	vPanel.add(new HTML("&nbsp;"));
	vPanel.add(table);
	vPanel.add(button);
	vPanel.add(new HTML("&nbsp;"));

	button.setVisible(false);
	button.setStyleName("okm-YesButton");

	vPanel.setCellHorizontalAlignment(scrollPanel, HasAlignment.ALIGN_CENTER);
	vPanel.setCellHorizontalAlignment(table, HasAlignment.ALIGN_CENTER);
	vPanel.setCellHorizontalAlignment(button, HasAlignment.ALIGN_CENTER);
	vPanel.setCellVerticalAlignment(scrollPanel, HasAlignment.ALIGN_MIDDLE);

	int left = (Window.getClientWidth() - 510) / 2;
	int top = (Window.getClientHeight() - 220) / 2;
	vPanel.setWidth("510px");
	vPanel.setHeight("220px");

	for (int i = 0; i < StartUp.STARTUP_LOADING_HISTORY_SEARCH; i++) {
		table.setWidget(0, i, new Image(OKMBundleResources.INSTANCE.loadedDisabledIcon()));
	}

	setText(Main.i18n("startup.openkm"));
	setPopupPosition(left, top);
	setWidget(vPanel);
}