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.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.joinvre.shared.VRE;
|
import org.gcube.portlets.user.joinvre.shared.VRE;
|
||||||
|
@ -17,7 +18,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
@RemoteServiceRelativePath("JoinService")
|
@RemoteServiceRelativePath("JoinService")
|
||||||
public interface JoinService extends RemoteService {
|
public interface JoinService extends RemoteService {
|
||||||
|
|
||||||
Boolean isTabbedPanel();
|
List<String> isTabbedPanel();
|
||||||
|
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs();
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.joinvre.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.joinvre.shared.VRE;
|
import org.gcube.portlets.user.joinvre.shared.VRE;
|
||||||
|
@ -32,7 +33,7 @@ public interface JoinServiceAsync {
|
||||||
|
|
||||||
void getTermsOfUse(long siteId, AsyncCallback<String> callback);
|
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);
|
void getPortalSitesMappedToVRE(String tabName, AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.joinvre.client;
|
package org.gcube.portlets.user.joinvre.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -37,8 +38,7 @@ public class JoinVRE implements EntryPoint {
|
||||||
private VerticalPanel mainPanel = new VerticalPanel();
|
private VerticalPanel mainPanel = new VerticalPanel();
|
||||||
|
|
||||||
private TabPanel mainTabPanel = new TabPanel(Tabs.ABOVE);
|
private TabPanel mainTabPanel = new TabPanel(Tabs.ABOVE);
|
||||||
private Tab productsPane = new Tab();
|
|
||||||
private Tab portfolioPane = new Tab();
|
|
||||||
|
|
||||||
private boolean portfolioLoaded = false;
|
private boolean portfolioLoaded = false;
|
||||||
|
|
||||||
|
@ -104,15 +104,15 @@ public class JoinVRE implements EntryPoint {
|
||||||
final ResponsivePanel toReturn = new ResponsivePanel();
|
final ResponsivePanel toReturn = new ResponsivePanel();
|
||||||
mainPanel.setWidth("100%");
|
mainPanel.setWidth("100%");
|
||||||
mainPanel.add(toReturn);
|
mainPanel.add(toReturn);
|
||||||
joinService.isTabbedPanel(new AsyncCallback<Boolean>() {
|
joinService.isTabbedPanel(new AsyncCallback<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {}
|
public void onFailure(Throwable caught) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(List<String> tabNames) {
|
||||||
if (result) {
|
if (tabNames != null) {
|
||||||
GWT.log("TabbedPanel");
|
GWT.log("TabbedPanel");
|
||||||
showTabs(toReturn);
|
showTabs(toReturn, tabNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,35 +122,35 @@ public class JoinVRE implements EntryPoint {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTabs(ResponsivePanel rp) {
|
private void showTabs(ResponsivePanel rp, List<String> tabNames) {
|
||||||
|
int i = 0;
|
||||||
productsPane.setHeading("Products");
|
for (final String theTabName : tabNames) {
|
||||||
productsPane.add(rp);
|
final Tab tab2Add = new Tab();
|
||||||
productsPane.setActive(true);
|
tab2Add.setHeading(theTabName);
|
||||||
|
if (i == 0) {
|
||||||
portfolioPane.setHeading("Portfolio");
|
tab2Add.add(rp); //we add the responsivepanel to the first tab only and we set it active
|
||||||
portfolioPane.add(new LoadingPanel());
|
tab2Add.setActive(true);
|
||||||
|
}
|
||||||
mainTabPanel.add(productsPane);
|
else {
|
||||||
mainTabPanel.add(portfolioPane);
|
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);
|
mainTabPanel.selectTab(0);
|
||||||
mainPanel.clear();
|
mainPanel.clear();
|
||||||
mainPanel.add(mainTabPanel);
|
mainPanel.add(mainTabPanel);
|
||||||
|
|
||||||
addCategoriesTab(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) {
|
private void addCategoriesTab(final TabPanel mainTabPanel) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.joinvre.server;
|
package org.gcube.portlets.user.joinvre.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -134,28 +135,31 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
return null;
|
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()) {
|
if (isWithinPortal()) {
|
||||||
_log.info("check if isTabbedPanel ");
|
_log.info("check if isTabbedPanel ");
|
||||||
Object tabbedLayoutObj = null;
|
Object tabbedLayoutObj = null;
|
||||||
try {
|
try {
|
||||||
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
||||||
tabbedLayoutObj = groupsManager.readCustomAttr(currentSiteGroupId, TABBED_LAYOUT_ATTRIBUTE);
|
tabbedLayoutObj = groupsManager.readCustomAttr(currentSiteGroupId, TABBED_LAYOUT_ATTRIBUTE);
|
||||||
|
|
||||||
getTabNames();
|
|
||||||
|
|
||||||
} catch (Exception e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Boolean isTabbedLayout = false;
|
Boolean isTabbedLayout = false;
|
||||||
if (tabbedLayoutObj != null) {
|
if (tabbedLayoutObj != null) {
|
||||||
isTabbedLayout = (Boolean) tabbedLayoutObj;
|
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>>();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||||
try {
|
try {
|
||||||
if (isWithinPortal()) {
|
if (isWithinPortal()) {
|
||||||
if (isTabbedPanel()) {
|
if (isTabbedPanel() != null) {
|
||||||
String firstTabName = getTabNames().get(0);
|
String firstTabName = getTabNames().get(0);
|
||||||
_log.debug("\n\n ****isTabbedLayout isTabbedLayout, first TabName= "+firstTabName);
|
_log.debug("\n\n ****isTabbedLayout isTabbedLayout, first TabName= "+firstTabName);
|
||||||
return getPortalSitesMappedToVRE(firstTabName);
|
return getPortalSitesMappedToVRE(firstTabName);
|
||||||
|
|
Loading…
Reference in New Issue