/** Put the widget in single activity mode. */ private void setSingleActivityMode() { sortPanel.setVisible(false); titlePanel.setVisible(false); postContent.setVisible(false); stream.setVisible(false); searchStatusWidget.setVisible(false); searchBoxWidget.setVisible(false); feedLinkWidget.setVisible(false); sortSearchRow.setVisible(false); EventBus.getInstance().notifyObservers(new ChangeActivityModeEvent(true)); }
/** * Initialize with strategy. * * @param inPagerStrategy the strategy. */ public void init(final PagerStrategy inPagerStrategy) { pagerStrategy = inPagerStrategy; EventBus.getInstance() .addObserver( PagerResponseEvent.class, new Observer<PagerResponseEvent>() { public void update(final PagerResponseEvent event) { if (event.getKey().equals(pagerStrategy.getKey())) { boolean enablePaging = pagerStrategy.hasNext() || pagerStrategy.hasPrev(); buttonContainer.setVisible(enablePaging); if (enablePaging) { String resultsLabel = String.valueOf(pagerStrategy.getStartIndex() + 1) + " - " + String.valueOf(pagerStrategy.getEndIndex() + 1) + " of " + String.valueOf(pagerStrategy.getTotal()); resultsNum.setText(resultsLabel); if (!pagerStrategy.hasNext()) { nextButton.addStyleName(style.pagingDisabled()); } else { nextButton.removeStyleName(style.pagingDisabled()); } if (!pagerStrategy.hasPrev()) { prevButton.addStyleName(style.pagingDisabled()); } else { prevButton.removeStyleName(style.pagingDisabled()); } } if (pageResults.getWidgetCount() != 0) { slideAnimation.slide( direction, event.getWidget(), pageResults, PAGER_ANIMATION_TIME); } else { pageResults.add(event.getWidget()); } } } }); }
/** Add events. */ private void addEvents() { EventBus.getInstance() .addObserver( MessageStreamAppendEvent.class, new Observer<MessageStreamAppendEvent>() { public void update(final MessageStreamAppendEvent event) { attachment = null; addLinkComposite.close(); postBox.setText(""); postBox.reset(); postBox.getElement().getStyle().clearHeight(); postOptions.removeClassName(style.visiblePostBox()); checkPostBox(); } }); EventBus.getInstance() .addObserver( PostableStreamScopeChangeEvent.class, new Observer<PostableStreamScopeChangeEvent>() { public void update(final PostableStreamScopeChangeEvent stream) { currentStream = stream.getResponse(); if (currentStream != null && !"".equals(currentStream.getDisplayName())) { if (currentStream.getScopeType().equals(ScopeType.PERSON)) { if (currentStream.getDisplayName().endsWith("s")) { postBox.setLabel("Post to " + currentStream.getDisplayName() + "' stream..."); } else { postBox.setLabel( "Post to " + currentStream.getDisplayName() + "'s stream..."); } } else { postBox.setLabel( "Post to the " + currentStream.getDisplayName() + " stream..."); } } else { postBox.setLabel("Post to your stream..."); } postPanel.setVisible(stream.getResponse().getScopeType() != null); } }); EventBus.getInstance() .addObserver( MessageAttachmentChangedEvent.class, new Observer<MessageAttachmentChangedEvent>() { public void update(final MessageAttachmentChangedEvent evt) { attachment = evt.getAttachment(); } }); EventBus.getInstance() .addObserver( GotSystemSettingsResponseEvent.class, new Observer<GotSystemSettingsResponseEvent>() { public void update(final GotSystemSettingsResponseEvent event) { String warning = event.getResponse().getContentWarningText(); if (warning != null && !warning.isEmpty()) { contentWarning.setText(warning); } else { contentWarning.setVisible(false); contentWarningContainer.getStyle().setDisplay(Display.NONE); } } }); Session.getInstance() .getEventBus() .addObserver( GotAllPopularHashTagsResponseEvent.class, new Observer<GotAllPopularHashTagsResponseEvent>() { public void update(final GotAllPopularHashTagsResponseEvent event) { allHashTags = new ArrayList<String>(event.getResponse()); } }); }
/** * Constructor. * * @param accountId Unique ID of person to display. */ public UserProfileBadgeWidget(final String accountId) { final FlowPanel widget = new FlowPanel(); widget.addStyleName(StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeContainer()); initWidget(widget); widget.addStyleName(StaticResourceBundle.INSTANCE.coreCss().eurekaConnectLoading()); EventBus.getInstance() .addObserver( GotPersonalInformationResponseEvent.class, new Observer<GotPersonalInformationResponseEvent>() { public void update(final GotPersonalInformationResponseEvent event) { widget.removeStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectLoading()); PersonModelView entity = event.getResponse(); if (entity == null) { final AvatarWidget blankAvatar = new AvatarWidget(EntityType.PERSON, Size.Normal); blankAvatar.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeAvatar()); widget.add(blankAvatar); final Label blankName = new Label(accountId); blankName.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeName()); widget.add(blankName); } else { AvatarLinkPanel linkPanel = new AvatarLinkPanel( EntityType.PERSON, entity.getAccountId(), entity.getAvatarId(), Size.Normal, false); linkPanel.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeAvatar()); widget.add(linkPanel); String linkUrl = "/#" + Session.getInstance() .generateUrl( new CreateUrlRequest(Page.PEOPLE, entity.getAccountId())); Anchor name = new Anchor(entity.getDisplayName(), linkUrl, "_BLANK"); name.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeName()); Label title = new Label(entity.getTitle()); title.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeTitle()); Label company = new Label(entity.getCompanyName()); company.addStyleName( StaticResourceBundle.INSTANCE.coreCss().eurekaConnectBadgeCompany()); widget.add(name); widget.add(title); widget.add(company); } } }); PersonalInformationModel.getInstance().fetch(accountId, false); }
/** * Fires of the UpdateGadgetPrefsEvent when called from the gadget container. * * @param inId - id of the gadget being updated. * @param inPrefs - updated preferences for the gadget. */ public static void updateGadgetPrefs(final int inId, final String inPrefs) { UpdateGadgetPrefsEvent event = new UpdateGadgetPrefsEvent(new Long(inId), inPrefs); EventBus.getInstance().notifyObservers(event); }
/** * Fires off a gadget change state event. * * @param id the gadget id * @param view the view to set. * @param params the optional parameters. */ public static void changeGadgetState(final int id, final String view, final String params) { GadgetStateChangeEvent event = new GadgetStateChangeEvent(new Long(id), "gadgetId", view, params); EventBus.getInstance().notifyObservers(event); }
/** Method that gets called during load of the EntryPoint. */ public void onModuleLoad() { // The entry point will be invoked when just a Eureka Connect widget is desired, so do nothing // if the // appropriate full-app element is not found rootPanel = RootPanel.get(FULL_APP_ELEMENT_ID); if (rootPanel == null) { return; } ActionRPCServiceAsync service = (ActionRPCServiceAsync) GWT.create(ActionRPCService.class); processor = new ActionProcessorImpl(service); ((ServiceDefTarget) service).setServiceEntryPoint("/gwt_rpc"); StaticResourceBundle.INSTANCE.coreCss().ensureInjected(); StaticResourceBundle.INSTANCE.yuiCss().ensureInjected(); session.setActionProcessor(processor); session.setEventBus(EventBus.getInstance()); session.setPeriodicEventManager( new PeriodicEventManager(APP_IDLE_TIMEOUT, new TimerFactory(), processor)); master = new MasterComposite(); EventBus.getInstance() .addObserver( FormLoginCompleteEvent.class, new Observer<FormLoginCompleteEvent>() { public void update(final FormLoginCompleteEvent event) { Window.Location.reload(); } }); EventBus.getInstance() .addObserver( TermsOfServiceAcceptedEvent.class, new Observer<TermsOfServiceAcceptedEvent>() { public void update(final TermsOfServiceAcceptedEvent event) { displayTOS = false; loadPerson(); } }); setUpGwtFunctions(); processor.makeRequest( new ActionRequestImpl<PersonModelView>("noOperation", null), new AsyncCallback<Serializable>() { public void onFailure(final Throwable caught) { if (caught.getMessage().contains("NO_CREDENTIALS")) { showLogin(); } else if (caught.getMessage().contains("LOGIN_DISABLED")) { Window.Location.assign(ACCESS_DENIED_PAGE); } else { Dialog.showCentered( new MessageDialogContent("Unable to Establish Connection", "Please Refresh.")); } } public void onSuccess(final Serializable sessionId) { ActionProcessorImpl.setCurrentSessionId((String) sessionId); loadPerson(); } }); }