the tab names are now parameters

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@158309 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2017-11-08 17:53:58 +00:00
parent f923e4cd90
commit 69b192a0f0
4 changed files with 67 additions and 61 deletions

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.joinvre.shared.VRE;
@ -17,7 +18,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("JoinService")
public interface JoinService extends RemoteService {
Boolean isTabbedPanel();
List<String> isTabbedPanel();
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs();

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.joinvre.shared.VRE;
@ -32,7 +33,7 @@ public interface JoinServiceAsync {
void getTermsOfUse(long siteId, AsyncCallback<String> callback);
void isTabbedPanel(AsyncCallback<Boolean> callback);
void isTabbedPanel(AsyncCallback<List<String>> callback);
void getPortalSitesMappedToVRE(String tabName, AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -31,18 +32,17 @@ public class JoinVRE implements EntryPoint {
public static final String GET_OID_PARAMETER = "siteId";
public static final String ORGANISATIONS_LABEL = "Organisations";
public static final String CATEGORIES_LABEL = "Categories";
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
private VerticalPanel mainPanel = new VerticalPanel();
private TabPanel mainTabPanel = new TabPanel(Tabs.ABOVE);
private Tab productsPane = new Tab();
private Tab portfolioPane = new Tab();
private boolean portfolioLoaded = false;
public void onModuleLoad() {
checkIsReferral();
}
@ -104,55 +104,55 @@ public class JoinVRE implements EntryPoint {
final ResponsivePanel toReturn = new ResponsivePanel();
mainPanel.setWidth("100%");
mainPanel.add(toReturn);
joinService.isTabbedPanel(new AsyncCallback<Boolean>() {
joinService.isTabbedPanel(new AsyncCallback<List<String>>() {
@Override
public void onFailure(Throwable caught) {}
@Override
public void onSuccess(Boolean result) {
if (result) {
public void onSuccess(List<String> tabNames) {
if (tabNames != null) {
GWT.log("TabbedPanel");
showTabs(toReturn);
showTabs(toReturn, tabNames);
}
}
});
RootPanel.get("JoinVRE-Container").add(mainPanel);
return toReturn;
}
private void showTabs(ResponsivePanel rp) {
productsPane.setHeading("Products");
productsPane.add(rp);
productsPane.setActive(true);
portfolioPane.setHeading("Portfolio");
portfolioPane.add(new LoadingPanel());
mainTabPanel.add(productsPane);
mainTabPanel.add(portfolioPane);
private void showTabs(ResponsivePanel rp, List<String> tabNames) {
int i = 0;
for (final String theTabName : tabNames) {
final Tab tab2Add = new Tab();
tab2Add.setHeading(theTabName);
if (i == 0) {
tab2Add.add(rp); //we add the responsivepanel to the first tab only and we set it active
tab2Add.setActive(true);
}
else {
tab2Add.add(new LoadingPanel());
tab2Add.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ResponsivePanel rpPort = new ResponsivePanel(theTabName);
tab2Add.clear();
tab2Add.add(rpPort);
}
});
}
mainTabPanel.add(tab2Add);
i++;
}
mainTabPanel.selectTab(0);
mainPanel.clear();
mainPanel.add(mainTabPanel);
addCategoriesTab(mainTabPanel);
portfolioPane.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (!portfolioLoaded) {
final ResponsivePanel rpPort = new ResponsivePanel("Portfolio");
portfolioPane.clear();
portfolioPane.add(rpPort);
portfolioLoaded = true;
}
}
});
addCategoriesTab(mainTabPanel);
}
private void addCategoriesTab(final TabPanel mainTabPanel) {
joinService.getAllCategories(new AsyncCallback<ArrayList<String>>() {
@Override
@ -164,11 +164,11 @@ public class JoinVRE implements EntryPoint {
final DropdownTab dropdownCategoriesTab = new DropdownTab(CATEGORIES_LABEL);
for (String catName : result) {
final String categoryName = catName;
final Tab tab2Add = new Tab();
tab2Add.setHeading(categoryName);
dropdownCategoriesTab.add(tab2Add);
tab2Add.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.joinvre.server;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
@ -134,28 +135,31 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return null;
}
}
public Boolean isTabbedPanel() {
/**
* returns null if is not a tabbedpanel, the tab names as list of Strings otherwise
*/
public List<String> isTabbedPanel() {
if (isWithinPortal()) {
_log.info("check if isTabbedPanel ");
Object tabbedLayoutObj = null;
try {
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
tabbedLayoutObj = groupsManager.readCustomAttr(currentSiteGroupId, TABBED_LAYOUT_ATTRIBUTE);
getTabNames();
Boolean isTabbedLayout = false;
if (tabbedLayoutObj != null) {
isTabbedLayout = (Boolean) tabbedLayoutObj;
if (isTabbedLayout)
return getTabNames();
}
} catch (Exception e1) {
e1.printStackTrace();
return false;
}
Boolean isTabbedLayout = false;
if (tabbedLayoutObj != null) {
isTabbedLayout = (Boolean) tabbedLayoutObj;
}
return isTabbedLayout;
return null;
}
return null;
}
else {
return Arrays.asList(new String[]{"Products?", "Portfolio"});
}
else
return true;
}
/**
*
@ -179,7 +183,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
try {
if (isWithinPortal()) {
if (isTabbedPanel()) {
if (isTabbedPanel() != null) {
String firstTabName = getTabNames().get(0);
_log.debug("\n\n ****isTabbedLayout isTabbedLayout, first TabName= "+firstTabName);
return getPortalSitesMappedToVRE(firstTabName);
@ -438,9 +442,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, VreMembershipType.PRIVATE));
vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING));
toReturn.put(devsecCategory, vres);
setVREsInSession(toReturn);
return toReturn;
}