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:
parent
f923e4cd90
commit
69b192a0f0
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -37,8 +38,7 @@ public class JoinVRE implements EntryPoint {
|
|||
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;
|
||||
|
||||
|
@ -104,15 +104,15 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -122,35 +122,35 @@ public class JoinVRE implements EntryPoint {
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addCategoriesTab(final TabPanel mainTabPanel) {
|
||||
|
|
|
@ -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();
|
||||
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
Boolean isTabbedLayout = false;
|
||||
if (tabbedLayoutObj != null) {
|
||||
isTabbedLayout = (Boolean) tabbedLayoutObj;
|
||||
if (isTabbedLayout)
|
||||
return getTabNames();
|
||||
}
|
||||
return isTabbedLayout;
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue