From abf283727cc8b81a46184db38ee001137a20cd2e Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Fri, 17 Nov 2017 09:28:40 +0000 Subject: [PATCH] updated to support Description of tab names and changed category to thematic area git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@158589 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 -- .../user/joinvre/client/JoinService.java | 3 +- .../user/joinvre/client/JoinServiceAsync.java | 3 +- .../portlets/user/joinvre/client/JoinVRE.java | 17 ++++--- .../joinvre/client/ui/TabPageDescription.java | 33 +++++++++++++ .../client/ui/TabPageDescription.ui.xml | 14 ++++++ .../user/joinvre/server/JoinServiceImpl.java | 47 ++++++++++++++----- .../user/joinvre/shared/TabbedPage.java | 39 +++++++++++++++ src/main/webapp/WEB-INF/portlet.xml | 2 +- 9 files changed, 138 insertions(+), 23 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.java create mode 100644 src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/joinvre/shared/TabbedPage.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 39a2d62..5f32ca8 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -7,9 +7,6 @@ uses - - uses - diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java index bcec9a5..803f9b9 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java @@ -5,6 +5,7 @@ import java.util.LinkedHashMap; import java.util.List; import org.gcube.portal.databook.shared.UserInfo; +import org.gcube.portlets.user.joinvre.shared.TabbedPage; import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRECategory; @@ -18,7 +19,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("JoinService") public interface JoinService extends RemoteService { - List isTabbedPanel(); + List isTabbedPanel(); LinkedHashMap> getVREs(); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java index cb1ab63..12dba1c 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java @@ -5,6 +5,7 @@ import java.util.LinkedHashMap; import java.util.List; import org.gcube.portal.databook.shared.UserInfo; +import org.gcube.portlets.user.joinvre.shared.TabbedPage; import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRECategory; @@ -33,7 +34,7 @@ public interface JoinServiceAsync { void getTermsOfUse(long siteId, AsyncCallback callback); - void isTabbedPanel(AsyncCallback> callback); + void isTabbedPanel(AsyncCallback> callback); void getPortalSitesMappedToVRE(String tabName, AsyncCallback>> callback); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java index aca785d..9546f49 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java @@ -7,10 +7,13 @@ import java.util.logging.Logger; import org.gcube.portlets.user.joinvre.client.responsive.ResponsivePanel; import org.gcube.portlets.user.joinvre.client.ui.LoadingPanel; +import org.gcube.portlets.user.joinvre.client.ui.TabPageDescription; +import org.gcube.portlets.user.joinvre.shared.TabbedPage; import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRECategory; import com.github.gwtbootstrap.client.ui.DropdownTab; +import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.Tab; import com.github.gwtbootstrap.client.ui.TabPanel; import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs; @@ -31,7 +34,7 @@ public class JoinVRE implements EntryPoint { Logger logger = Logger.getLogger(JoinVRE.class.getName()); public static final String GET_OID_PARAMETER = "siteId"; public static final String ORGANISATIONS_LABEL = "Organisations"; - public static final String CATEGORIES_LABEL = "Categories"; + public static final String CATEGORIES_LABEL = "Thematic areas"; private final JoinServiceAsync joinService = GWT.create(JoinService.class); @@ -100,12 +103,12 @@ public class JoinVRE implements EntryPoint { final ResponsivePanel toReturn = new ResponsivePanel(); mainPanel.setWidth("100%"); mainPanel.add(toReturn); - joinService.isTabbedPanel(new AsyncCallback>() { + joinService.isTabbedPanel(new AsyncCallback>() { @Override public void onFailure(Throwable caught) {} @Override - public void onSuccess(List tabNames) { + public void onSuccess(List tabNames) { if (tabNames != null) { GWT.log("TabbedPanel"); showTabs(toReturn, tabNames); @@ -122,12 +125,13 @@ public class JoinVRE implements EntryPoint { * @param rp * @param tabNames */ - private void showTabs(ResponsivePanel rp, List tabNames) { + private void showTabs(ResponsivePanel rp, List tabNames) { int i = 0; - for (final String theTabName : tabNames) { + for (final TabbedPage theTabPage : tabNames) { final Tab tab2Add = new Tab(); - tab2Add.setHeading(theTabName); + tab2Add.setHeading(theTabPage.getName()); if (i == 0) { + tab2Add.add(new TabPageDescription(theTabPage)); tab2Add.add(rp); //we add the responsivepanel to the first tab only and we set it active tab2Add.setActive(true); } @@ -138,6 +142,7 @@ public class JoinVRE implements EntryPoint { public void onClick(ClickEvent event) { final ResponsivePanel rpPort = new ResponsivePanel(tab2Add); tab2Add.clear(); + tab2Add.add(new TabPageDescription(theTabPage)); tab2Add.add(rpPort); } }); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.java new file mode 100644 index 0000000..8dc80c1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.java @@ -0,0 +1,33 @@ +package org.gcube.portlets.user.joinvre.client.ui; + +import org.gcube.portlets.user.joinvre.shared.TabbedPage; + +import com.github.gwtbootstrap.client.ui.Paragraph; +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +public class TabPageDescription extends Composite { + + private static TabPageDescriptionUiBinder uiBinder = GWT.create(TabPageDescriptionUiBinder.class); + + interface TabPageDescriptionUiBinder extends UiBinder { + } + + public TabPageDescription() { + initWidget(uiBinder.createAndBindUi(this)); + } + + @UiField + Paragraph desc; + + public TabPageDescription(TabbedPage theTab) { + initWidget(uiBinder.createAndBindUi(this)); + desc.setText(theTab.getDescription()); + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.ui.xml b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.ui.xml new file mode 100644 index 0000000..1acfbdb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/TabPageDescription.ui.xml @@ -0,0 +1,14 @@ + + + + .important { + font-size: 18px; + font-weight: 200; + padding: 0 2px; + + } + + Some Text for the + Hero Unit. + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java index fedd470..8cec9f1 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java @@ -21,6 +21,7 @@ import org.gcube.portal.tou.TermsOfUseImpl; import org.gcube.portal.tou.exceptions.ToUNotFoundException; import org.gcube.portal.tou.model.ToU; import org.gcube.portlets.user.joinvre.client.JoinService; +import org.gcube.portlets.user.joinvre.shared.TabbedPage; import org.gcube.portlets.user.joinvre.shared.UserBelonging; import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRECategory; @@ -139,7 +140,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService /** * returns null if is not a tabbedpanel, the tab names as list of Strings otherwise */ - public List isTabbedPanel() { + public List isTabbedPanel() { if (isWithinPortal()) { _log.info("check if isTabbedPanel "); Object tabbedLayoutObj = null; @@ -159,7 +160,10 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService return null; } else { - return Arrays.asList(new String[]{"Products?", "Portfolio"}); + return Arrays.asList( + new TabbedPage[]{new TabbedPage("Products", "designed to apply Data Mining techniques to biological data. "), + new TabbedPage("Portfolio", "Portfolio description The algorithms are executed in ..")} + ); } } /** @@ -167,12 +171,28 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService * @return the list containing the names of the Tabs to show in the correct order. * @throws Exception */ - private List getTabNames() throws Exception { - List toReturn = new ArrayList(); + private List getTabNames() throws Exception { + List toReturn = new ArrayList(); long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId(); String[] values = (String[]) groupsManager.readCustomAttr(currentSiteGroupId, TAB_NAMES_ATTRIBUTE); - for (int i = 0; i < values.length; i++) { - toReturn.add(values[i]); + TabbedPage toAdd = new TabbedPage(); + if (values != null && values.length > 0) { + for (int i = 0; i < values.length; i++) { + toAdd = new TabbedPage(); + String[] splits = values[i].split("\\|"); + if (splits.length > 1) { + toAdd.setName(splits[0]); + toAdd.setDescription(splits[1]); + } else { + _log.warn("I could not find the Tab Description in the Custom field, is it separated by the pipe? getting all the value ..."); + toAdd.setName(values[i]); + toAdd.setDescription(""); + } + toReturn.add(toAdd); + } + } else { + toAdd.setName("NoTabbedPageAssigned"); + toAdd.setDescription("NoTabbedPageDescription"); } return toReturn; } @@ -184,7 +204,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService try { if (isWithinPortal()) { if (isTabbedPanel() != null) { - String firstTabName = getTabNames().get(0); + String firstTabName = getTabNames().get(0).getName(); return getPortalSitesMappedToVRE(firstTabName); } else { toReturn = getPortalSitesMappedToVRE(); @@ -217,11 +237,16 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService ArrayList toAdd = new ArrayList(); tabVREs.put(cat, toAdd); for (VRE vre : allVREs.get(cat)) { + _log.debug("getting selected tab for " + vre.getName()); String[] vreTabNames = (String[]) groupsManager.readCustomAttr(vre.getId(), TAB_NAMES_ATTRIBUTE); - String vreTabName = vreTabNames[0]; - if (tabName.equals(vreTabName)) { - toAdd.add(vre); - _log.debug("Added " + vre.getName() + " as it belongs to " + vreTabName); + if (vreTabNames != null && vreTabNames.length > 0) { + String vreTabName = vreTabNames[0]; + if (tabName.equals(vreTabName)) { + toAdd.add(vre); + _log.debug("Added " + vre.getName() + " as it belongs to " + vreTabName); + } + }else { + _log.warn("Spotted vre without tab assigned: " + vre.getName() + " skipping it ..."); } } } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/TabbedPage.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/TabbedPage.java new file mode 100644 index 0000000..26393af --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/TabbedPage.java @@ -0,0 +1,39 @@ +package org.gcube.portlets.user.joinvre.shared; + +import com.google.gwt.user.client.rpc.IsSerializable; + +public class TabbedPage implements IsSerializable, Comparable { + + protected String name; + protected String description; + + public TabbedPage() { + super(); + // TODO Auto-generated constructor stub + } + public TabbedPage(String name, String description) { + super(); + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** {@inheritDoc} */ + @Override + public int compareTo(TabbedPage tabName) { + return name.compareTo(tabName.name); + } +} diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml index 304162f..8623491 100644 --- a/src/main/webapp/WEB-INF/portlet.xml +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -13,7 +13,7 @@ text/html - Explore Virtual Research Environments + Explore (New) Virtual Research Environments JoinVRE Portlet JoinVRE Portlet