List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop
public int getAbsoluteTop()
From source file:geogebra.web.gui.advanced.client.ui.widget.ListPopupPanel.java
License:Apache License
/** * Checks whether the specified item is visible in the scroll area.<p/> * The result is <code>true</code> if whole item is visible. * * @param index is an index of the item. * @return a result of check.//from w w w.java 2 s .c om */ public boolean isItemVisible(int index) { Widget item = getList().getWidget(index); int itemTop = item.getAbsoluteTop(); int top = getScrollPanel().getAbsoluteTop(); return itemTop >= top && itemTop + item.getOffsetHeight() <= top + getScrollPanel().getOffsetHeight(); }
From source file:geogebra.web.gui.advanced.client.ui.widget.ListPopupPanel.java
License:Apache License
/** * This method checks whether the limit of displayed items reached.<p/> * It takes into account different aspects including setting of the widget, geometrical size of the * drop down list and selected value that must be displayed.<p/> * This method optimally chooses a number of items to display. * * @param previouslyRenderedRows is a number of rows previously loaded in the list * (items count before filling the list). * @return a result of check.//w w w. jav a2s . c o m */ protected boolean isRenderingLimitReached(int previouslyRenderedRows) { ListDataModel model = getComboBox().getModel(); int previousHeight = 0; if (previouslyRenderedRows > 0) { Widget last = getItem(previouslyRenderedRows - 1); Widget first = getItem(0); previousHeight = last.getOffsetHeight() + last.getAbsoluteTop() - first.getAbsoluteTop(); } return model.getCount() <= 0 // no data // OR a selected value has already been displayed || getItemCount() > getComboBox().getSelectedIndex() // AND one of the following conditions is true: && (getItemCount() >= model.getCount() //no items any more // OR no limit but there are too many items || isLazyRenderingEnabled() && getVisibleRows() <= 0 && getList().getOffsetHeight() - previousHeight >= Window.getClientHeight() * 0.6 // OR visible rows number is limited and there was a new page rendered excepting the first page // since two pages may be displayed if the list is rendered first time || isLazyRenderingEnabled() && getVisibleRows() > 0 && getItemCount() - previouslyRenderedRows > 0 && (getItemCount() - previouslyRenderedRows) % getVisibleRows() == 0 && (getItemCount() - previouslyRenderedRows) / getVisibleRows() != 1); }
From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.results.ModeController.java
protected void hookupCopyToFilterListener(final ResultsPanelCanCopyToFilter resultsPanel) { resultsPanel.addCopyToFilterClickListener(new ClickListener() { public void onClick(Widget sender) { String list = resultsPanel.getResultsTable().makeListFromCheckedRows(); if (list != null && list.length() > 0) { if (resultsPanel.getListBy() == FilterSpecifier.ListBy.Genes) { filterPanel.addToGeneList(list); } else if (resultsPanel.getListBy() == FilterSpecifier.ListBy.Patients) { filterPanel.addToPatientList(list); }/*w ww . ja v a 2 s .com*/ addToFilterPopup.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop() - 15); addToFilterPopup.show(); Timer hideTimer = new Timer() { public void run() { addToFilterPopup.hide(); } }; hideTimer.schedule(2000); } } }); }
From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.results.ModeControllerPathway.java
private void createTabForPathway(SinglePathwayResults pathwayResult) { final PathwayDiagramPanel panel = new PathwayDiagramPanel(pathwayResult, this); panel.addCopyToFilterClickListener(new ClickListener() { public void onClick(Widget sender) { String list = panel.makeListFromCheckedRows(); addToElementList(list);// w w w. j a v a 2 s . co m addToFilterPopup.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop() - 15); addToFilterPopup.show(); Timer hideTimer = new Timer() { public void run() { addToFilterPopup.hide(); } }; hideTimer.schedule(2000); } }); tabPanel.addOrReplaceTab(panel, getModeColorSchemeClass()); }
From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.util.TooltipListener.java
License:Open Source License
public void onMouseEnter(final Widget sender) { //if instance already visible, do nothing if (tooltip != null && tooltip.isVisible()) { return;/*from w w w . j a v a 2 s . c o m*/ } mouseIsOnLink = true; int delay = (DELAYBEFORESHOW < 0 ? 0 : DELAYBEFORESHOW); Timer t = new Timer() { public void run() { if (mouseIsOnLink && (tooltip == null || !tooltip.isVisible())) { //in case onMouseEnter is called twice, will only create tooltip once tooltip = new Tooltip(sender.getAbsoluteLeft() + DEFAULT_OFFSET_X, sender.getAbsoluteTop() + DEFAULT_OFFSET_Y, text, styleName); tooltip.show(); } } }; t.schedule(delay); }
From source file:gwt.material.design.components.client.utils.helper.UiHelper.java
License:Apache License
public static int calculateSpaceToBottom(Widget widget) { return Window.getClientHeight() - widget.getAbsoluteTop() - widget.getOffsetHeight(); }
From source file:ilarkesto.gwt.client.TooltipPopup.java
License:Open Source License
/** * Creates a new Tool Tip with the default show delay and no auto hiding * // w w w. j a va 2 s . co m * @param sender The widget to create the tool tip for * @param relLeft The left offset from the <code>sender</code> * @param relTop The top offset from the <code>sender</code> * @param text The tool tip text to display * @param useRelTop If true, then use the relative top offset. If not, then just use the sender's offset * height. */ public TooltipPopup(Widget sender, int relLeft, int relTop, final Widget contents, boolean useRelTop) { super(true); this.showTimer = null; this.hideTimer = null; add(contents); int left = getPageScrollLeft() + sender.getAbsoluteLeft() + relLeft; int top = getPageScrollTop() + sender.getAbsoluteTop(); if (useRelTop) { top += relTop; } else { top += sender.getOffsetHeight() + 1; } setAutoHideEnabled(true); setPopupPosition(left, top); addStyleName("Tooltip"); }
From source file:io.apiman.manager.ui.client.local.pages.common.PolicyList.java
License:Apache License
/** * Called when the user drags a policy./*from w ww . java 2s. c o m*/ * @param event * @param row */ protected void onDragging(MouseEvent<?> event, PolicyRow row) { row.getElement().getStyle().setTop(event.getClientY() - 20, Unit.PX); Widget w = getHoverWidget(event, row); if (w == null) { Widget firstRow = getWidget(0); Widget lastRow = getWidget(getWidgetCount() - 1); int top = firstRow.getAbsoluteTop(); int y = event.getClientY(); if (y <= top) { w = firstRow; } else { w = lastRow; } } if (w != dropHolder) { int index = getWidgetIndex(w); remove(dropHolder); insert(dropHolder, index); } }
From source file:io.apiman.manager.ui.client.local.pages.common.PolicyList.java
License:Apache License
/** * Figures out which widget in the list is being hovered over (using * only the Y coordinate of the event./*from w w w .j a v a 2 s. co m*/ * @param event * @param dragRow */ private Widget getHoverWidget(MouseEvent<?> event, PolicyRow dragRow) { int y = event.getClientY(); for (int i = 0; i < getWidgetCount(); i++) { Widget widget = getWidget(i); if (widget == dragRow) { continue; } int widgetTop = widget.getAbsoluteTop(); int widgetBottom = widgetTop + widget.getOffsetHeight(); if (y >= widgetTop && y <= widgetBottom) { return widget; } } return null; }
From source file:net.s17fabu.vip.gwt.showcase.client.content.popups.CwBasicPopup.java
License:Apache License
/** * Initialize this example./*from w w w . j ava2 s .co m*/ */ @Override public Widget onInitialize() { // Create a basic popup widget final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true); simplePopup.ensureDebugId("cwBasicPopup-simplePopup"); simplePopup.setWidth("150px"); simplePopup.setWidget(new HTML(constants.cwBasicPopupClickOutsideInstructions())); // Create a button to show the popup Button openButton = new Button(constants.cwBasicPopupShowButton(), new ClickHandler() { public void onClick(ClickEvent event) { // Reposition the popup relative to the button Widget source = (Widget) event.getSource(); int left = source.getAbsoluteLeft() + 10; int top = source.getAbsoluteTop() + 10; simplePopup.setPopupPosition(left, top); // Show the popup simplePopup.show(); } }); // Create a popup to show the full size image Image jimmyFull = Showcase.images.jimmy().createImage(); final PopupPanel imagePopup = new PopupPanel(true); imagePopup.setAnimationEnabled(true); imagePopup.ensureDebugId("cwBasicPopup-imagePopup"); imagePopup.setWidget(jimmyFull); jimmyFull.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { imagePopup.hide(); } }); // Add an image thumbnail Image jimmyThumb = Showcase.images.jimmyThumb().createImage(); jimmyThumb.ensureDebugId("cwBasicPopup-thumb"); jimmyThumb.addStyleName("cw-BasicPopup-thumb"); jimmyThumb.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { imagePopup.center(); } }); // Add the widgets to a panel VerticalPanel vPanel = new VerticalPanel(); vPanel.setSpacing(5); vPanel.add(openButton); vPanel.add(new HTML("<br><br><br>" + constants.cwBasicPopupInstructions())); vPanel.add(jimmyThumb); // Return the panel return vPanel; }