Java Code Examples for com.google.gwt.user.client.ui.PopupPanel#hide()

The following examples show how to use com.google.gwt.user.client.ui.PopupPanel#hide() . 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 File: SuggestionsSelectList.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds suggestions to the suggestion menu bar.
 * 
 * @param suggestions
 *            the suggestions to be added
 * @param textFieldWidget
 *            the text field which the suggestion is attached to to bring
 *            back the focus after selection
 * @param popupPanel
 *            pop-up panel where the menu bar is shown to hide it after
 *            selection
 * @param suggestionServerRpc
 *            server RPC to ask for new suggestion after a selection
 */
public void addItems(final List<SuggestTokenDto> suggestions, final VTextField textFieldWidget,
        final PopupPanel popupPanel, final TextFieldSuggestionBoxServerRpc suggestionServerRpc) {
    for (int index = 0; index < suggestions.size(); index++) {
        final SuggestTokenDto suggestToken = suggestions.get(index);
        final MenuItem mi = new MenuItem(suggestToken.getSuggestion(), true, new ScheduledCommand() {
            @Override
            public void execute() {
                final String tmpSuggestion = suggestToken.getSuggestion();
                final TokenStartEnd tokenStartEnd = tokenMap.get(tmpSuggestion);
                final String text = textFieldWidget.getValue();
                final StringBuilder builder = new StringBuilder(text);
                builder.replace(tokenStartEnd.getStart(), tokenStartEnd.getEnd() + 1, tmpSuggestion);
                textFieldWidget.setValue(builder.toString(), true);
                popupPanel.hide();
                textFieldWidget.setFocus(true);
                suggestionServerRpc.suggest(builder.toString(), textFieldWidget.getCursorPos());
            }
        });
        tokenMap.put(suggestToken.getSuggestion(),
                new TokenStartEnd(suggestToken.getStart(), suggestToken.getEnd()));
        Roles.getListitemRole().set(mi.getElement());
        WidgetUtil.sinkOnloadForImages(mi.getElement());
        addItem(mi);
    }
}
 
Example 2
Source File: HorizontalPanelWithHint.java    From unitime with Apache License 2.0 6 votes vote down vote up
public HorizontalPanelWithHint(Widget hint) {
	super();
	iHint = new PopupPanel();
	iHint.setWidget(hint);
	iHint.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowHint = new Timer() {
		@Override
		public void run() {
			iHint.show();
		}
	};
	iHideHint = new Timer() {
		@Override
		public void run() {
			iHint.hide();
		}
	};
}
 
Example 3
Source File: MessageCenterView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void onMessage(final Message message) {
    if (!message.isTransient()) {

        // update the visible message count
        reflectMessageCount();

        final PopupPanel display = createDisplay(message);
        displayNotification(display, message);

        if (!message.isSticky()) {

            Timer hideTimer = new Timer() {
                @Override
                public void run() {
                    // hide message
                    messageDisplay.clear();
                    display.hide();
                }
            };

            hideTimer.schedule(4000);
        }

    }
}
 
Example 4
Source File: GalleryClient.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
* loadSourceFile opens the app as a new app inventor project
* @param gApp the app to open
* @return True if success, otherwise false
*/
public boolean loadSourceFile(GalleryApp gApp, String newProjectName, final PopupPanel popup) {
  final String projectName = newProjectName;
  final String sourceKey = getGallerySettings().getSourceKey(gApp.getGalleryAppId());
  final long galleryId = gApp.getGalleryAppId();

  // first check name to see if valid and unique...
  if (!TextValidators.checkNewProjectName(projectName))
    return false;  // the above function takes care of error messages
  // Callback for updating the project explorer after the project is created on the back-end
  final Ode ode = Ode.getInstance();

  final OdeAsyncCallback<UserProject> callback = new OdeAsyncCallback<UserProject>(
  // failure message
  MESSAGES.createProjectError()) {
    @Override
    public void onSuccess(UserProject projectInfo) {
      Project project = ode.getProjectManager().addProject(projectInfo);
      Ode.getInstance().openYoungAndroidProjectInDesigner(project);
      popup.hide();
    }
    @Override
    public void onFailure(Throwable caught) {
      popup.hide();
      super.onFailure(caught);
    }
  };
  // this is really what's happening here, we call server to load project
  ode.getProjectService().newProjectFromGallery(projectName, sourceKey, galleryId, callback);
  return true;
}
 
Example 5
Source File: AriaSuggestBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public AriaSuggestBox(AriaTextBox box, SuggestOracle oracle) {
	iOracle = oracle;
	iText = box;
	iText.setStyleName("gwt-SuggestBox");
	initWidget(iText);
	
	addEventsToTextBox();
	
	iSuggestionMenu = new SuggestionMenu();
	
	iPopupScroll = new ScrollPanel(iSuggestionMenu);
	iPopupScroll.addStyleName("scroll");
	
	iSuggestionPopup = new PopupPanel(true, false);
	iSuggestionPopup.setPreviewingAllNativeEvents(true);
	iSuggestionPopup.setStyleName("unitime-SuggestBoxPopup");
	iSuggestionPopup.setWidget(iPopupScroll);
	iSuggestionPopup.addAutoHidePartner(getElement());
	
	iSuggestionCallback = new SuggestionCallback() {
		@Override
		public void onSuggestionSelected(Suggestion suggestion) {
			if (!suggestion.getReplacementString().isEmpty()) {
				setStatus(ARIA.suggestionSelected(status(suggestion)));
			}
			iCurrentText = suggestion.getReplacementString();
			setText(suggestion.getReplacementString());
			hideSuggestionList();
			fireSuggestionEvent(suggestion);
		}
	};
	
	iOracleCallback = new SuggestOracle.Callback() {
		@Override
		public void onSuggestionsReady(Request request, Response response) {
			if (response.getSuggestions() == null || response.getSuggestions().isEmpty()) {
				if (iSuggestionPopup.isShowing()) iSuggestionPopup.hide();
			} else {
				iSuggestionMenu.clearItems();
				SuggestOracle.Suggestion first = null;
				for (SuggestOracle.Suggestion suggestion: response.getSuggestions()) {
					iSuggestionMenu.addItem(new SuggestionMenuItem(suggestion));
					if (first == null) first = suggestion;
				}
				iSuggestionMenu.selectItem(0);
				ToolBox.setMinWidth(iSuggestionMenu.getElement().getStyle(), (iText.getElement().getClientWidth() - 4) + "px");
				iSuggestionPopup.showRelativeTo(iText);
				iSuggestionMenu.scrollToView();
				if (response.getSuggestions().size() == 1) {
					if (first.getReplacementString().isEmpty())
						setStatus(status(first));
					else
						setStatus(ARIA.showingOneSuggestion(status(first)));
				} else {
					setStatus(ARIA.showingMultipleSuggestions(response.getSuggestions().size(), request.getQuery(), status(first)));
				}
			}
		}
	};
	
	Roles.getTextboxRole().setAriaAutocompleteProperty(iText.getElement(), AutocompleteValue.NONE);
	
	iSuggestionPopup.getElement().setAttribute("id", DOM.createUniqueId());
	Roles.getTextboxRole().setAriaOwnsProperty(iText.getElement(), Id.of(iSuggestionPopup.getElement()));
}
 
Example 6
Source File: InfoPanelImpl.java    From unitime with Apache License 2.0 4 votes vote down vote up
public InfoPanelImpl() {
	super("cell");
	iText = new P("text");
	add(iText);
	
	iHint = new ClickableHint(""); iHint.setStyleName("hint");
	add(iHint);
	
	iUpdateInfo = new Callback() {
		@Override
		public void execute(Callback callback) {
			if (callback != null) callback.execute(null);
		}
	};
	
	iInfo = new FlexTable();
	iInfo.setStyleName("unitime-InfoTable");
	// iUpdateInfo = updateInfo;
	iInfoPanel = new PopupPanel();
	iInfoPanel.setWidget(iInfo);
	iInfoPanel.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowInfo = new Timer() {
		@Override
		public void run() {
			if (iInfo.getRowCount() == 0) return;
			iUpdateInfo.execute(new Callback() {
				public void execute(Callback callback) {
					iInfoPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
						@Override
						public void setPosition(int offsetWidth, int offsetHeight) {
							int maxX = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth - 10;
							iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
						}
					});
					if (callback != null) callback.execute(null);
				}
			});
		}
	};
	iHideInfo = new Timer() {
		@Override
		public void run() {
			iInfoPanel.hide();
		}
	};
	
	iDefaultClickHandler = new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			if (iUrl != null && !iUrl.isEmpty())
				ToolBox.open(GWT.getHostPageBaseURL() + iUrl);
		}
	};
	iTextClick = iHint.addClickHandler(iDefaultClickHandler);
	iHintClick = iText.addClickHandler(iDefaultClickHandler);
	iHint.setTabIndex(-1);
}
 
Example 7
Source File: FinderColumn.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void openTopContextMenu(Element anchor, final NativeEvent event) {

        Element el = Element.as(event.getEventTarget());
        //Element anchor = el.getParentElement().getParentElement();

        final PopupPanel popupPanel = new PopupPanel(true);
        final MenuBar popupMenuBar = new MenuBar(true);
        popupMenuBar.setStyleName("dropdown-menu");

        int i=0;
        for (final MenuDelegate menuitem : accessibleTopMenuItems) {

            if(i>0) {     // skip the "default" action
                MenuItem cmd = new MenuItem(menuitem.getTitle(), true, new Command() {

                    @Override
                    public void execute() {
                        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                            @Override
                            public void execute() {
                                menuitem.getCommand().executeOn(null);
                            }
                        });

                        popupPanel.hide();
                    }

                });

                popupMenuBar.addItem(cmd);
            }
            i++;
        }

        popupMenuBar.setVisible(true);


        popupPanel.setWidget(popupMenuBar);
        int left = anchor.getAbsoluteLeft();
        int top = anchor.getAbsoluteTop() + 30;

        popupPanel.setPopupPosition(left, top);
        popupPanel.setAutoHideEnabled(true);
        popupPanel.show();
    }