List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop
public int getAbsoluteTop()
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
private void onDragEnd(Widget sender, int x, int y) { // Make sure the current hover-target is still valid, // and send the guaranteed onDragContinue() prior to onDrop() onDragContinue(sender, x, y);/*from www . ja v a 2s. c o m*/ // Hide drag widget popup dragWidgetPopup.hide(); // Inform the hover-target of the drop if (hoverDropTarget != null) { Widget targetWidget = hoverDropTarget.getDropTargetWidget(); Widget dragWidget = getDragWidget(); hoverDropTarget.onDrop(dragSource, /*localX*/ (/*absX*/ x + sender.getAbsoluteLeft()) - targetWidget.getAbsoluteLeft(), /*localY*/ (/*absY*/ y + sender.getAbsoluteTop()) - targetWidget.getAbsoluteTop(), getDragWidgetOffsetX(dragWidget), getDragWidgetOffsetY(dragWidget)); } // Notify drag source of the drag end dragSource.onDragEnd(); // Clean up dropTargets = null; dragWidgetPopup = null; hoverDropTarget = null; }
From source file:com.google.gwt.sample.kitchensink.client.Popups.java
License:Apache License
public void onClick(Widget sender) { if (sender == fPopupButton) { MyPopup p = new MyPopup(); int left = sender.getAbsoluteLeft() + 10; int top = sender.getAbsoluteTop() + 10; p.setPopupPosition(left, top);/*from w w w . j ava2 s . c om*/ p.show(); } else if (sender == fDialogButton) { DialogBox dlg = new MyDialog(); int left = fDialogButton.getAbsoluteLeft() + 10; int top = fDialogButton.getAbsoluteTop() + 10; dlg.setPopupPosition(left, top); dlg.show(); } }
From source file:com.google.gwt.sample.showcase.client.content.popups.CwBasicPopup.java
License:Apache License
/** * Initialize this example./*from ww w .j a v a 2 s. c o m*/ */ @ShowcaseSource @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 = new Image(Showcase.images.jimmy()); 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 = new Image(Showcase.images.jimmyThumb()); 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; }
From source file:com.google.gwt.search.sample.hellosearch.client.HelloSearch.java
License:Apache License
public void onKeep(KeepEvent event) { final Result result = event.getResult(); String title;// w w w .j a va 2 s.com if (result instanceof WebResult) { WebResult web = (WebResult) result; title = web.getTitle(); } else if (result instanceof NewsResult) { NewsResult web = (NewsResult) result; title = web.getTitle(); } else if (result instanceof VideoResult) { VideoResult video = (VideoResult) result; title = video.getTitle(); // Metadata is also available System.out.println( video.getTbHeight() + "x" + video.getTbWidth() + " " + video.getDuration() + "seconds"); } else { // Ads don't have an official interface title = "Advertisement"; } HTML h = new HTML(title); h.addStyleName("clipLink"); h.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { PopupPanel p = new PopupPanel(true); p.addStyleName("keepPopup"); p.setWidget(result.getHtml()); Widget w = (Widget) event.getSource(); p.setPopupPosition(w.getAbsoluteLeft() + 5, w.getAbsoluteTop() + w.getOffsetHeight() + 5); p.show(); } }); clips.add(h); }
From source file:com.google.livingstories.client.lsp.views.contentitems.ContainerStreamViewFooter.java
License:Apache License
public void addNavLinks(Map<String, Widget> typeStringToNavLinkTarget, final ToggleDisclosurePanel disclosurePanel) { for (Map.Entry<String, Widget> e : typeStringToNavLinkTarget.entrySet()) { InlineLabel link = new InlineLabel(e.getKey()); link.setStylePrimaryName(Resources.INSTANCE.css().clickable()); if (navLinks.getWidgetCount() > 1) { navLinks.add(new InlineHTML(" | ")); // separator }//from w w w . ja va 2 s .c o m navLinks.add(link); final Widget linkTarget = e.getValue(); link.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Consume this event, so that it doesn't cause the disclosurePanel to register the // click event.stopPropagation(); EventBus.INSTANCE .fireEvent(new BlockToggledEvent(true, contentItemId).setOnFinish(new Command() { @Override public void execute() { WindowScroll.scrollTo(linkTarget.getAbsoluteTop(), new Command() { @Override public void execute() { LivingStoryControls.repositionAnchoredPanel(); } }); } })); } }); } if (!typeStringToNavLinkTarget.isEmpty()) { navLinks.removeStyleName(Resources.INSTANCE.css().hidden()); } }
From source file:com.gwtmodel.table.WSize.java
License:Apache License
public WSize(Widget w) { this.top = w.getAbsoluteTop(); this.left = w.getAbsoluteLeft(); this.height = w.getOffsetHeight(); this.width = w.getOffsetWidth(); this.w = w;//from w ww . j a v a2s . co m }
From source file:com.gwtplatform.carstore.client.application.widget.header.HeaderMobileView.java
License:Apache License
@UiHandler("menu") void onMenuClicked(ClickEvent event) { final Widget widget = (Widget) event.getSource(); userInfoPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override/*from w w w.j ava 2 s. c o m*/ public void setPosition(int offsetWidth, int offsetHeight) { int left = widget.getAbsoluteLeft() - (userInfoPopup.getOffsetWidth() - widget.getOffsetWidth()); int top = widget.getAbsoluteTop() + widget.getOffsetHeight() + 10; userInfoPopup.setPopupPosition(left, top); } }); }
From source file:com.ikon.extension.frontend.client.widget.dropbox.Status.java
License:Open Source License
/** * Refreshing the panel/*from w w w. ja v a 2 s. c om*/ */ public void refresh() { if (flag_exporting || flag_importing || flag_search || flag_getChilds) { Widget widgetBaseToCenter = Main.get().mainPanel; if (flag_getChilds && widget != null) { widgetBaseToCenter = widget; } int left = widgetBaseToCenter.getAbsoluteLeft() + (widgetBaseToCenter.getOffsetWidth() - 200) / 2; int top = widgetBaseToCenter.getAbsoluteTop() + (widgetBaseToCenter.getOffsetHeight() - 40) / 2; if (left > 0 && top > 0) { setPopupPosition(left, top); super.show(); } } else { super.hide(); } }
From source file:com.ikon.extension.frontend.client.widget.macros.Status.java
License:Open Source License
/** * Refreshing the panel/*from w w w.j a va 2 s.c om*/ */ public void refresh() { if (flag_executeAction) { Widget tab = Main.get().mainPanel; int left = tab.getAbsoluteLeft() + (tab.getOffsetWidth() - 200) / 2; int top = tab.getAbsoluteTop() + (tab.getOffsetHeight() - 40) / 2; if (left > 0 && top > 0) { setPopupPosition(left, top); super.show(); } } else { super.hide(); } }
From source file:com.kk_electronic.kkportal.core.ui.Canvas.java
License:Open Source License
@Override public void onElementDrop(double x, int y, ModuleWindow element) { Widget p = element.getParent(); x = 100.0 * (double) ((element.getAbsoluteLeft() - p.getAbsoluteLeft() + element.getOffsetWidth() / 2)) / p.getOffsetWidth();/*from w w w.j a v a 2 s .co m*/ y = (element.getAbsoluteTop() - p.getAbsoluteTop() + element.getOffsetHeight() / 2); GWT.log("Before move" + groupedModuleWindows.toString()); for (List<ModuleWindow> moduleWindows : groupedModuleWindows) { if (moduleWindows.remove(element)) break; } List<ModuleWindow> column = findColumn(x); int index = findIndex(column, y); column.add(index, element); List<List<ModuleWindow>> newgroupedModuleWindows = new ArrayList<List<ModuleWindow>>(); for (List<ModuleWindow> moduleWindows : groupedModuleWindows) { if (!moduleWindows.isEmpty()) newgroupedModuleWindows.add(moduleWindows); } groupedModuleWindows = newgroupedModuleWindows; element.setFirstColumn(column == groupedModuleWindows.get(0)); GWT.log("After move" + groupedModuleWindows.toString()); tabsModel.setModuleIds(tabInfo, getIds(groupedModuleWindows)); }