/** * Get content for bookmark popup * * @return */ private HLayout getPopupContent() { HLayout hlayout = new HLayout(); hlayout.setWidth100(); hlayout.setHeight100(); DynamicForm form = new DynamicForm(); form.setHeight100(); form.setWidth(260); form.setTitleWidth(100); bookmarkTitle = new TextItem(); bookmarkTitle.setTitle("Title"); if (!view.getSettings().inSingleEndpointMode()) { includeEndpoint = new CheckboxItem(); includeEndpoint.setTitle("Include endpoint"); includeEndpoint.setLabelAsTitle(true); form.setItems(bookmarkTitle, includeEndpoint); } else { form.setItems(bookmarkTitle); } Button bookmarkButton = new Button("Bookmark"); bookmarkButton.setHeight100(); bookmarkButton.setWidth(60); bookmarkButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Bookmark bookmark = new Bookmark(); if (includeEndpoint != null && includeEndpoint.getValueAsBoolean()) { bookmark.setEndpoint(view.getSelectedTabSettings().getEndpoint()); } bookmark.setQuery(view.getSelectedTabSettings().getQueryString()); bookmark.setTitle(bookmarkTitle.getValueAsString()); window.clear(); setSrc(Imgs.get(Imgs.LOADING)); view.getRemoteService() .addBookmark( bookmark, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { setSrc(Imgs.get(Imgs.BOOKMARK_QUERY)); if (caught instanceof OpenIdException) { view.getElements().onError(caught.getMessage() + ". Logging out"); view.getOpenId().logOut(); } else { view.getElements().onError(caught); } } @Override public void onSuccess(Void result) { setSrc(Imgs.get(Imgs.BOOKMARK_QUERY)); } }); } }); hlayout.addMembers(form, Helper.getHSpacer(), bookmarkButton); return hlayout; }
/** * Show tooltips * * @param fromVersionId */ public void showToolTips(int fromVersionId) { if (fromVersionId <= TOOLTIP_VERSION_BOOKMARKS) { TooltipProperties tProp = new TooltipProperties(); tProp.setId(getDOM().getId()); tProp.setContent(TooltipText.ADD_TO_BOOKMARKS); tProp.setMy(TooltipProperties.POS_TOP_RIGHT); tProp.setAt(TooltipProperties.POS_BOTTOM_CENTER); tProp.setYOffset(2); Helper.drawTooltip(tProp); } }
public String getDisplayName() { if (getFullName() != null) { return getFullName(); } else if (getNickName() != null) { return getNickName(); } else if (getFirstName() != null && getLastName() != null) { return getFirstName() + " " + getLastName(); } else if (getFirstName() != null) { return getFirstName(); } else if (getLastName() != null) { return getLastName(); } else if (getEmail() != null) { return getEmail(); } else { String baseDomain = Helper.getBaseDomain(getOpenId()); return baseDomain.substring(0, baseDomain.lastIndexOf('.')); } }