List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft
public int getAbsoluteLeft()
From source file:com.google.gwt.sample.showcase.client.content.popups.CwBasicPopup.java
License:Apache License
/** * Initialize this example.//w w w. j ava 2s. c om */ @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;/*from w w w . j av a 2 s. co m*/ 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.googlesource.gerrit.plugins.cookbook.client.PopDownButton.java
License:Apache License
private void show() { if (popup != null) { getElement().getStyle().clearFontWeight(); popup.hide();/*w ww .jav a 2 s .c o m*/ return; } final Widget relativeTo = getParent(); final PopupPanel p = new PopupPanel(true) { @Override public void setPopupPosition(int left, int top) { top -= Document.get().getBodyOffsetTop(); int w = Window.getScrollLeft() + Window.getClientWidth(); int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth(); int right = w - r; Style style = getElement().getStyle(); style.clearProperty("left"); style.setPropertyPx("right", right); style.setPropertyPx("top", top); } }; Style popupStyle = p.getElement().getStyle(); popupStyle.setBorderWidth(0, Unit.PX); popupStyle.setBackgroundColor("#EEEEEE"); p.addAutoHidePartner(getElement()); p.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (popup == p) { getElement().getStyle().clearFontWeight(); popup = null; } } }); p.add(widget); p.showRelativeTo(relativeTo); GlobalKey.dialog(p); getElement().getStyle().setFontWeight(FontWeight.BOLD); popup = p; }
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;/* ww w. j a va 2 s . c om*/ }
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 ww w . j a v a 2s .com*/ 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/* w w w .jav a 2s . co m*/ */ 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 . jav a 2s .c o m*/ */ 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 ww . j av a 2s .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)); }
From source file:com.kk_electronic.kkportal.core.ui.GroupDisplay.java
License:Open Source License
@Override public boolean Drop(MouseUpEvent event, final T element) { Widget widget = element.asWidget(); int height = widget.getOffsetHeight(); event.setRelativeElement(canvas.getElement()); final int x = event.getX(); final int y = event.getY(); /*// w ww . j a va 2 s .c o m * Note must be 100.0 and not 100 since the later would result in * integer division which most likely would be 0 */ double width = (100.0 * widget.getOffsetWidth()) / canvas.getOffsetWidth(); final int top = widget.getAbsoluteTop() - canvas.getAbsoluteTop(); final double left = (100.0 * (widget.getAbsoluteLeft() - canvas.getAbsoluteLeft())) / canvas.getOffsetWidth(); final double xpct = 100.0 * x / canvas.getOffsetWidth(); canvas.add(widget); canvas.getWidgetContainerElement(widget).getStyle().clearOverflow(); canvas.setWidgetTopHeight(widget, top, Unit.PX, height, Unit.PX); canvas.setWidgetLeftWidth(widget, left, Unit.PCT, width, Unit.PCT); if (handler != null) { Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { handler.onElementDrop(xpct, y, element); } }); return true; } return false; }
From source file:com.ksyzt.gwt.client.ui.richeditor.RichTextToolbar.java
License:Open Source License
/** * Show popup.// w w w . j a va 2 s . co m * * @param attacheElement the attache element * @param w the w */ private void showPopup(Widget attacheElement, Widget w) { back_widget = attacheElement; if (w == null) { w = new HTMLPanel(""); w.setSize("100px", "100px"); m_ap_content.clear(); m_ap_content.add(w); } else { m_ap_content.clear(); m_ap_content.add(w); } m_ap_content.setVisible(true); m_ap_shadow.setVisible(true); m_ap_line.setVisible(true); int aleft = attacheElement.getAbsoluteLeft(); int atop = attacheElement.getAbsoluteTop(); int aw = attacheElement.getOffsetWidth(); int ah = attacheElement.getOffsetHeight(); int width = m_ap_content.getOffsetWidth(); int height = m_ap_content.getOffsetHeight(); int lbx = aleft; int lby = atop + ah; int rbx = lbx + aw; int rby = lby; Style style = m_ap_content.getElement().getStyle(); style.setLeft(rbx - width, Unit.PX); style.setTop(lby - 1, Unit.PX); style = m_ap_shadow.getElement().getStyle(); style.setLeft(rbx - width + 3, Unit.PX); style.setTop(lby + 2, Unit.PX); style.setWidth(width, Unit.PX); style.setHeight(height, Unit.PX); style = m_ap_line.getElement().getStyle(); style.setLeft(lbx + 1, Unit.PX); style.setTop(lby - 1, Unit.PX); style.setWidth(aw - 2, Unit.PX); back_css = attacheElement.getStyleName(); attacheElement.setStyleName("toolbar_over"); m_ap_content.getElement().focus(); m_b_show_popup = true; }