List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft
public int getAbsoluteLeft()
From source file:com.dimdim.conference.ui.common.client.user.NewChatPanel.java
License:Open Source License
/** * Same chat panel is used for global as well as personal chats. Global * chat is simply identified by using 'other' argument as null. *//* w ww.j a v a 2 s . c om*/ public NewChatPanel(UIRosterEntry me, UIRosterEntry other) { this.me = me; this.other = other; if (other != null) { this.toId = other.getUserId(); } this.lastActivityTime = System.currentTimeMillis(); if (ConferenceGlobals.isBrowserIE()) { spaceSequence = "DIMDIM_LTwbr>"; } // Add the central scroll panel that will hold the messages. scrollPanel = new ScrollPanel(); scrollPanel.add(this.chatMessages); scrollPanel.setStyleName("dm-chat-message-area"); // A small and short instructions / message area. instructionPanel = new HorizontalPanel(); instructionPanel.setStyleName("chat-instruction-panel"); instructionPanel.setWidth("248px"); //in public chat add powered by dimdim logo else have the help text if (null == toId) { HorizontalPanel hp = new HorizontalPanel(); HorizontalPanel tempSpacer = new HorizontalPanel(); tempSpacer.setWidth("10px"); tempSpacer.add(new Label(" ")); hp.add(tempSpacer); hp.setCellHorizontalAlignment(tempSpacer, HorizontalPanel.ALIGN_LEFT); hp.setCellVerticalAlignment(tempSpacer, VerticalPanel.ALIGN_MIDDLE); PNGImage image = new PNGImage("images/logo_powered.png", 8, 14); hp.add(image); //instructionPanel.setCellWidth(image,"100%"); hp.setCellHorizontalAlignment(image, HorizontalPanel.ALIGN_LEFT); hp.setCellVerticalAlignment(image, VerticalPanel.ALIGN_MIDDLE); //hp.setBorderWidth(1); HTML instruction = new HTML("Powered By <a href='#'><u> Dimdim </u></a>"); instruction.addClickListener(new ClickListener() { public void onClick(Widget sender) { openDimdimWebSite(); } }); instruction.setStyleName("poweredby-text"); hp.add(instruction); //instructionPanel.setCellWidth(instruction,"100%"); hp.setCellHorizontalAlignment(instruction, HorizontalPanel.ALIGN_LEFT); hp.setCellVerticalAlignment(instruction, VerticalPanel.ALIGN_MIDDLE); instructionPanel.add(hp); //instructionPanel.setCellWidth(instruction,"100%"); instructionPanel.setCellHorizontalAlignment(hp, HorizontalPanel.ALIGN_LEFT); instructionPanel.setCellVerticalAlignment(hp, VerticalPanel.ALIGN_MIDDLE); } else { Label instruction = new Label(UIStrings.getChatPanelInstruction()); instruction.setStyleName("chat-instruction"); instructionPanel.add(instruction); //instructionPanel.setCellWidth(instruction,"100%"); instructionPanel.setCellHorizontalAlignment(instruction, HorizontalPanel.ALIGN_LEFT); instructionPanel.setCellVerticalAlignment(instruction, VerticalPanel.ALIGN_MIDDLE); } Label emoticon = new Label(UIStrings.getChatPanelEmoticonInstruction()); emoticon.setStyleName("chat-emoticon-lable"); instructionPanel.add(emoticon); //instructionPanel.setCellWidth(emoticon,"30%"); instructionPanel.setCellHorizontalAlignment(emoticon, HorizontalPanel.ALIGN_RIGHT); instructionPanel.setCellVerticalAlignment(emoticon, VerticalPanel.ALIGN_MIDDLE); // Add the text area that the users will type their messages in. sendText = new TextArea(); sendText.setText(""); if (null == toId) { sendText.setText(UIStrings.getChatPanelInstruction()); sendText.setStyleName("chat-instruction"); } //if (ConferenceGlobals.isBrowserIE()) //{ sendText.setVisibleLines(2); //} //else //{ // sendText.setVisibleLines(1); //} sendText.setStyleName("chat-text-area"); keyboardListener = new KeyboardListenerAdapter() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ENTER) { sendChatMessage(); } } }; sendText.addKeyboardListener(keyboardListener); sendText.addFocusListener(this); // Assemble the overall chat panel. initWidget(pane); pane.setWidth("100%"); pane.add(outer); outer.setWidth("100%"); outer.add(scrollPanel); scrollPanel.addStyleName("dm-chat-message-area-pane"); outer.add(this.instructionPanel); outer.setCellWidth(this.instructionPanel, "100%"); outer.setCellHorizontalAlignment(this.instructionPanel, HorizontalPanel.ALIGN_LEFT); outer.add(this.sendText); outer.setCellWidth(this.sendText, "100%"); outer.setCellHorizontalAlignment(this.sendText, HorizontalPanel.ALIGN_CENTER); this.sendText.setStyleName("dm-chat-text-area"); this.rosterModel = ClientModel.getClientModel().getRosterModel(); // Window.alert("created popup.."); //setting up emoticons popup panel ePopUP = new EmoticonsPopup(sendText); emoticon.addMouseListener(new MouseListenerAdapter() { public void onMouseEnter(Widget sender) { int left = sender.getAbsoluteLeft() - 5; int top = sender.getAbsoluteTop() - 75; ePopUP.setPopupPosition(left, top); ePopUP.showHoverPopup(); ePopUP.popupVisible(); } }); if (emoticonsMap == null) { emoticonsMap = new HashMap(); prepareEmoticonsList(); // this is to handle :) and :( also } }
From source file:com.dimdim.conference.ui.resources.client.ResourceTypeEntryDropDownClickListener.java
License:Open Source License
public void onClick(Widget sender) { Widget w = this.widget; if (w == null) { w = sender;//from ww w .j a v a2 s. co m } if (this.listEntry.getResources() != null) { if (this.listEntry.getResources().size() == 0) { if (this.listEntry.getTypeName().equals(UIResourceObject.RESOURCE_TYPE_PRESENTATION)) { this.rtpcp.getShareLinkClickListener().onClick(w); } else if (this.listEntry.getTypeName().equals(UIResourceObject.RESOURCE_TYPE_COBROWSE)) { this.rtpcp.getShareCobClickListener().onClick(w); } } else { if (this.listEntry.getTypeName().equals(UIResourceObject.RESOURCE_TYPE_PRESENTATION)) { int left = w.getAbsoluteLeft() + 8; int top = w.getAbsoluteTop(); ResourceTypeListEntryPopupPanel rtlepp = new ResourceTypeListEntryPopupPanel(resourceList, rtpcp); rtlepp.paintPanel(this.listEntry.getTypeName()); DmGlassPanel2 dgp = new DmGlassPanel2(rtlepp); dgp.show(left, top); rtlepp.popupVisible(); } else if (this.listEntry.getTypeName().equals(UIResourceObject.RESOURCE_TYPE_COBROWSE)) { int left = w.getAbsoluteLeft() + 8; int top = w.getAbsoluteTop(); ResourceTypeListEntryPopupPanel rtlepp = new ResourceTypeListEntryPopupPanel(resourceList, rtpcp); rtlepp.paintPanel(this.listEntry.getTypeName()); DmGlassPanel2 dgp = new DmGlassPanel2(rtlepp); dgp.show(left, top); rtlepp.popupVisible(); } } } }
From source file:com.facebook.tsdb.tsdash.client.presenter.MetricPresenter.java
License:Apache License
private void setupAllMetricsPopup() { allMetricsPopup.setWidget(allMetricsContainer); Widget w = (Widget) widget; int top = w.getAbsoluteTop() + 10; int left = w.getAbsoluteLeft() + 350; allMetricsPopup.setPopupPosition(left, top); allMetricsContainer.addStyleName("allMetricsPopup"); }
From source file:com.google.appinventor.client.explorer.project.ProjectNodeContextMenu.java
License:Open Source License
/** * Shows a context menu for a node.// w w w .j a v a 2 s . c om * * @param node node for which to show the context menu * @param host widget to anchor context menu to */ public static void show(final ProjectNode node, Widget host) { List<CommandRegistry.Entry> entries = Ode.getCommandRegistry().get(node); if (entries.isEmpty()) { return; } final ContextMenu menu = new ContextMenu(); // Position the context menu to the East of the host widget. menu.setPopupPosition(host.getAbsoluteLeft() + host.getOffsetWidth(), host.getAbsoluteTop()); for (final CommandRegistry.Entry entry : entries) { final ProjectNodeCommand cmd = entry.getCommand(); // Create the menu item. menu.addItem(cmd.getLabel(), new Command() { @Override public void execute() { menu.hide(); cmd.execute(node); } }); } menu.show(); }
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
/** * Returns whether the specified widget contains a position given * by the absolute coordinates./*w w w .j a v a 2s. c om*/ * * @param w widget to test * @param absX absolute x coordinate of position * @param absY absolute y coordinate of position * @return {@code true} if the position is within the widget, {@code false} * otherwise */ private static boolean isInside(Widget w, int absX, int absY) { int wx = w.getAbsoluteLeft(); int wy = w.getAbsoluteTop(); int ww = w.getOffsetWidth(); int wh = w.getOffsetHeight(); return (wx <= absX) && (absX < wx + ww) && (wy <= absY) && (absY < wy + wh); }
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
@Override public void onMouseEnter(Widget sender) { if (dragInProgress) { // Firefox 2 specific. IE6 does not need this. if (dom.getFromElementOfCurrentEvent() == getDragWidget().getElement() && isRootHtmlElement(dom.getToElementOfCurrentEvent())) { // The user moved the mouse outside the browser window. ///* ww w . j a v a2s .c o m*/ // Simulate a mouse-moved event to a position offscreen, // since this is not done automatically in Firefox 2. onMouseMove(sender, /*localX*/ (/*absX*/ -1) - sender.getAbsoluteLeft(), /*localY*/ (/*absY*/ -1) - sender.getAbsoluteTop()); return; } } }
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
private void onDragStart(Widget sender, int x, int y) { // Notify drag source of the drag starting dragSource.onDragStart();//from www . ja va2 s.c o m // Cache the set of permissible drop targets dropTargets = dragSource.getDropTargets(); // Show drag proxy widget dragWidgetPopup = new DragWidgetPopup(dragSource.createDragWidget(startX, startY)); dragWidgetPopup.setPopupPosition(/*absX*/ x + sender.getAbsoluteLeft(), /*absY*/ y + sender.getAbsoluteTop()); dragWidgetPopup.show(); // Initialize hover state hoverDropTarget = null; }
From source file:com.google.appinventor.client.widgets.dnd.DragSourceSupport.java
License:Open Source License
private void onDragContinue(Widget sender, int x, int y) { int absX = x + sender.getAbsoluteLeft(); int absY = y + sender.getAbsoluteTop(); // Move drag proxy to new position dragWidgetPopup.setPopupPosition(absX, absY); // Find drop target that the cursor is currently hovering over for (DropTarget target : dropTargets) { Widget targetWidget = target.getDropTargetWidget(); if (target == sender) { // can't drop onto self - only an issue if sender is a container continue; }/*from w w w. j a v a 2s. c o m*/ boolean isInsideTargetWidget = isInside(targetWidget, absX, absY); if (target == hoverDropTarget) { if (isInsideTargetWidget) { // The last identified drop-target "captures" the attention // of the drag and drop system while the user is still dragging // within its bounds and no other contained drop target accepts the drag break; } else { // Drag has left the bounds of the current hover-target hoverDropTarget.onDragLeave(dragSource); hoverDropTarget = null; // Continue searching for enclosing and non-intersecting // drop targets to accept the current drag continue; } } if (isInsideTargetWidget) { int localX = absX - targetWidget.getAbsoluteLeft(); int localY = absY - targetWidget.getAbsoluteTop(); if (target.onDragEnter(dragSource, localX, localY)) { if (hoverDropTarget != null) { // Drag exits the old hover-target because it has entered // the bounds of an accepting drop target that is within // the bounds of the old hover-target hoverDropTarget.onDragLeave(dragSource); } // Drag accepted; current target becomes the new hover-target hoverDropTarget = target; // The guaranteed onDragContinue() event that follows all invocations // of onDragEnter() that accept the drag is fired later in this method break; } } } // Inform the hover-target of the continuing drag if (hoverDropTarget != null) { Widget targetWidget = hoverDropTarget.getDropTargetWidget(); hoverDropTarget.onDragContinue(dragSource, /*localX*/ absX - targetWidget.getAbsoluteLeft(), /*localY*/ absY - targetWidget.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);// ww w . jav a 2 s . com // 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 a v a2 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(); } }