Skip to content

Commit

Permalink
redmine #8868 final closing
Browse files Browse the repository at this point in the history
  • Loading branch information
svuillet committed Sep 1, 2017
1 parent 272b14f commit 1ed41c6
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 12 deletions.
Expand Up @@ -27,10 +27,12 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.silverpeas.mobile.client.apps.favorites.events.app.AbstractFavoritesAppEvent;
import com.silverpeas.mobile.client.apps.favorites.events.app.AddFavoriteEvent;
import com.silverpeas.mobile.client.apps.favorites.events.app.FavoritesAppEventHandler;
import com.silverpeas.mobile.client.apps.favorites.events.app.FavoritesLoadEvent;
import com.silverpeas.mobile.client.apps.favorites.events.app.GotoAppEvent;
import com.silverpeas.mobile.client.apps.favorites.events.pages.FavoritesLoadedEvent;
import com.silverpeas.mobile.client.apps.favorites.pages.FavoritesPage;
import com.silverpeas.mobile.client.apps.navigation.events.app.external.AbstractNavigationEvent;
Expand All @@ -44,6 +46,7 @@
import com.silverpeas.mobile.client.common.EventBus;
import com.silverpeas.mobile.client.common.ServicesLocator;
import com.silverpeas.mobile.client.common.app.App;
import com.silverpeas.mobile.client.common.event.ErrorEvent;
import com.silverpeas.mobile.client.common.network.AsyncCallbackOnlineOnly;
import com.silverpeas.mobile.client.common.network.AsyncCallbackOnlineOrOffline;
import com.silverpeas.mobile.client.common.storage.LocalStorageHelper;
Expand All @@ -52,6 +55,7 @@
import com.silverpeas.mobile.shared.dto.ContentsTypes;
import com.silverpeas.mobile.shared.dto.FavoriteDTO;
import com.silverpeas.mobile.shared.dto.StatusDTO;
import com.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO;

import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -123,6 +127,22 @@ public void onSuccess(String result) {
action.attempt();
}

@Override
public void gotoApp(final GotoAppEvent event) {
ServicesLocator.getServiceNavigation().getApp(event.getInstanceId(), null, null,
new AsyncCallback<ApplicationInstanceDTO>() {
@Override
public void onFailure(final Throwable caught) {
EventBus.getInstance().fireEvent(new ErrorEvent(caught));
}

@Override
public void onSuccess(final ApplicationInstanceDTO applicationInstanceDTO) {
EventBus.getInstance().fireEvent(new NavigationAppInstanceChangedEvent(applicationInstanceDTO));
}
});
}

@Override
public void appInstanceChanged(final NavigationAppInstanceChangedEvent event) { /* only one instance */ }

Expand Down
Expand Up @@ -29,4 +29,5 @@
public interface FavoritesAppEventHandler extends EventHandler{
void loadFavorites(FavoritesLoadEvent event);
void addFavorite(AddFavoriteEvent event);
void gotoApp(GotoAppEvent event);
}
Expand Up @@ -40,7 +40,7 @@ public FavoritesLoadedEvent(List<FavoriteDTO> favorites){

@Override
protected void dispatch(FavoritesPagesEventHandler handler) {
handler.onContactsLoaded(this);
handler.onFavoritesLoaded(this);
}

public List<FavoriteDTO> getFavorites(){
Expand Down
Expand Up @@ -27,5 +27,5 @@
import com.google.gwt.event.shared.EventHandler;

public interface FavoritesPagesEventHandler extends EventHandler{
void onContactsLoaded(FavoritesLoadedEvent event);
void onFavoritesLoaded(FavoritesLoadedEvent event);
}
Expand Up @@ -68,7 +68,7 @@ public void stop() {
}

@Override
public void onContactsLoaded(final FavoritesLoadedEvent event) {
public void onFavoritesLoaded(final FavoritesLoadedEvent event) {

List<FavoriteDTO> favoritesList = event.getFavorites();
for (FavoriteDTO favoriteDTO : favoritesList) {
Expand Down
Expand Up @@ -40,6 +40,7 @@
import com.silverpeas.mobile.shared.dto.BaseDTO;
import com.silverpeas.mobile.shared.dto.ContentDTO;
import com.silverpeas.mobile.shared.dto.ContentsTypes;
import com.silverpeas.mobile.shared.dto.RightDTO;
import com.silverpeas.mobile.shared.dto.media.MediaDTO;
import com.silverpeas.mobile.shared.dto.media.PhotoDTO;
import com.silverpeas.mobile.shared.dto.media.SoundDTO;
Expand Down Expand Up @@ -197,6 +198,21 @@ public void showContent(final NavigationShowContentEvent event) {
event.getContent().getType().equals(ContentsTypes.Video.name()) ||
event.getContent().getType().equals(ContentsTypes.Streaming.name())) {
startWithContent(event.getContent());
} else if (event.getContent().getType().equals(ContentsTypes.Album.name())) {
ServicesLocator.getServiceNavigation().getApp(event.getContent().getInstanceId(), null, null,
new AsyncCallback<ApplicationInstanceDTO>() {
@Override
public void onFailure(final Throwable caught) {
EventBus.getInstance().fireEvent(new ErrorEvent(caught));
}

@Override
public void onSuccess(final ApplicationInstanceDTO applicationInstanceDTO) {
MediaNavigationPage page = new MediaNavigationPage();
page.init(event.getContent().getInstanceId(), event.getContent().getId(), applicationInstanceDTO.getRights());
page.show();
}
});
}
}

Expand Down
Expand Up @@ -97,14 +97,18 @@ public void onLoadedAlbums(final MediaItemsLoadedEvent event) {
public void onMediaItemClicked(final MediaItemClickEvent event) {
if (isVisible()) {
if (event.getMediaItem() instanceof AlbumDTO) {
MediaNavigationPage page = new MediaNavigationPage();
page.init(instanceId, ((AlbumDTO) event.getMediaItem()).getId(), rights);
page.show();
showAlbum((AlbumDTO) event.getMediaItem());
}
else {
EventBus.getInstance().fireEvent(new MediaViewShowEvent((MediaDTO)event.getMediaItem()));
}
}
}

private void showAlbum(final AlbumDTO album) {
MediaNavigationPage page = new MediaNavigationPage();
page.init(instanceId, album.getId(), rights);
page.show();
}

}
Expand Up @@ -2,6 +2,7 @@

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.silverpeas.mobile.client.apps.navigation.events.app.AbstractNavigationAppEvent;
import com.silverpeas.mobile.client.apps.navigation.events.app.LoadSpacesAndAppsEvent;
import com.silverpeas.mobile.client.apps.navigation.events.app.NavigationAppEventHandler;
Expand Down Expand Up @@ -55,8 +56,8 @@ public void setTitle(String title) {

@Override
public void loadSpacesAndApps(final LoadSpacesAndAppsEvent event) {
//TODO : replace call getSpaceAndApps by getHomePage
final String key = "spaceapp_" + event.getRootSpaceId();
//TODO : replace call getSpaceAndApps by getHomePage
final String key = "spaceapp_" + event.getRootSpaceId();

AsyncCallbackOnlineOrOffline action = new AsyncCallbackOnlineOrOffline<HomePageDTO>(getOfflineAction(key)) {

Expand Down Expand Up @@ -97,9 +98,9 @@ public void appInstanceChanged(final NavigationAppInstanceChangedEvent event) {
@Override
public void showContent(final NavigationShowContentEvent event) {
if (event.getContent().getType().equals(ContentsTypes.Space.name())) {
String spaceId = event.getContent().getId().replace("WA", "");
LoadSpacesAndAppsEvent ev = new LoadSpacesAndAppsEvent(spaceId);
loadSpacesAndApps(ev);
NavigationPage page = new NavigationPage();
page.setRootSpaceId(event.getContent().getId());
page.show();
}
}
}
Expand Up @@ -57,9 +57,9 @@ public NavigationPage() {
public void homePageLoaded(HomePageLoadedEvent event) {
if (isVisible() && dataLoaded == false) {
content.setData(event.getData());
setPageTitle(event.getData().getSpaceName());
dataLoaded = true;


actionsMenu.addAction(favorite);
favorite.init(null, event.getData().getId(), ContentsTypes.Space.name(), getPageTitle());
}
Expand Down
Expand Up @@ -29,14 +29,23 @@
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.silverpeas.mobile.client.SpMobil;
import com.silverpeas.mobile.client.apps.favorites.events.app.GotoAppEvent;
import com.silverpeas.mobile.client.apps.navigation.events.app.external
.NavigationAppInstanceChangedEvent;
import com.silverpeas.mobile.client.common.EventBus;
import com.silverpeas.mobile.client.common.ServicesLocator;
import com.silverpeas.mobile.client.common.ShortCutRouter;
import com.silverpeas.mobile.client.common.event.ErrorEvent;
import com.silverpeas.mobile.client.resources.ApplicationMessages;
import com.silverpeas.mobile.shared.dto.ContentsTypes;
import com.silverpeas.mobile.shared.dto.FavoriteDTO;
import com.silverpeas.mobile.shared.dto.navigation.ApplicationInstanceDTO;

public class FavoriteItem extends Composite {

Expand Down Expand Up @@ -82,8 +91,17 @@ protected void onClick(ClickEvent event) {
shortcutContentType = ContentsTypes.Folder.name();
shortcutAppId = shortcutContentId.substring(shortcutContentId.lastIndexOf("=") + 1);
shortcutContentId = shortcutContentId.substring(0, shortcutContentId.indexOf("?"));
} else if (data.getUrl().contains("/Rgallery/")){
shortcutContentType = ContentsTypes.Album.name();
shortcutContentId = data.getUrl().substring(data.getUrl().lastIndexOf("=") + 1);
shortcutAppId = data.getUrl().substring("/Rgallery/".length(), data.getUrl().lastIndexOf("/"));
} else if (data.getUrl().contains("/Space/")) {
shortcutContentType = ContentsTypes.Space.name();
} else if (data.getUrl().contains("/Component/")) {
GotoAppEvent eventGoApp = new GotoAppEvent();
eventGoApp.setInstanceId(shortcutContentId);
EventBus.getInstance().fireEvent(eventGoApp);
return;
}
ShortCutRouter.route(SpMobil.user, shortcutAppId, shortcutContentType, shortcutContentId);
}
Expand Down
Expand Up @@ -59,6 +59,14 @@ public HomePageDTO getHomePageData(String spaceId) throws NavigationException, A
checkUserInSession();
HomePageDTO data = new HomePageDTO();
data.setId(spaceId);
try {
if (spaceId != null) {
SpaceInstLight space = Administration.get().getSpaceInstLightById(spaceId);
data.setSpaceName(space.getName(getUserInSession().getUserPreferences().getLanguage()));
}
} catch (Exception e) {
throw new NavigationException(e);
}

List<PublicationDetail> lastNews = NewsHelper.getInstance().getLastNews(getUserInSession().getId(), spaceId);
data.setNews(NewsHelper.getInstance().populate(lastNews, false));
Expand Down
Expand Up @@ -36,6 +36,8 @@ public class HomePageDTO extends BaseDTO implements Serializable{

private static final long serialVersionUID = 5388415881024885835L;

private String spaceName;

private List<SilverpeasObjectDTO> spacesAndApps;
private List<NewsDTO> news = new ArrayList<NewsDTO>();
private List<FavoriteDTO> favorites = new ArrayList<FavoriteDTO>();
Expand Down Expand Up @@ -72,4 +74,12 @@ public List<SilverpeasObjectDTO> getSpacesAndApps() {
public void setSpacesAndApps(final List<SilverpeasObjectDTO> spacesAndApps) {
this.spacesAndApps = spacesAndApps;
}

public String getSpaceName() {
return spaceName;
}

public void setSpaceName(final String spaceName) {
this.spaceName = spaceName;
}
}

0 comments on commit 1ed41c6

Please sign in to comment.