Home button added
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129306 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c6586b9a47
commit
568d54e0cd
|
@ -4,6 +4,8 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetada
|
|||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEventHandler;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEventHandler;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEventHandler;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowStatisticsEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowStatisticsEventHandler;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserDatasetsEvent;
|
||||
|
@ -37,6 +39,38 @@ public class CkanEventHandlerManager {
|
|||
|
||||
|
||||
private void bind() {
|
||||
|
||||
// bind on show home event
|
||||
eventBus.addHandler(ShowHomeEvent.TYPE, new ShowHomeEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onShowHome(ShowHomeEvent showHomeEvent) {
|
||||
|
||||
// get the current path
|
||||
String currentPath = Window.Location.getHref();
|
||||
|
||||
// check if the "path" parameter is already present
|
||||
String currentParameter = Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
|
||||
|
||||
String finalPath;
|
||||
|
||||
if(currentParameter == null){
|
||||
finalPath = currentPath;
|
||||
|
||||
}else{
|
||||
|
||||
// remove from the first "path" on
|
||||
int index = currentPath.lastIndexOf("?"+GCubeCkanDataCatalog.GET_PATH_PARAMETER);
|
||||
String firstPartOfThePath = currentPath.substring(0, index);
|
||||
finalPath = firstPartOfThePath;
|
||||
|
||||
}
|
||||
|
||||
// redirect
|
||||
Window.Location.assign(finalPath);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// bind on insert metadata
|
||||
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* Raised when the user wants to go to the catalogue home
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class ShowHomeEvent extends GwtEvent<ShowHomeEventHandler> {
|
||||
public static Type<ShowHomeEventHandler> TYPE = new Type<ShowHomeEventHandler>();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new insert metadata event.
|
||||
*/
|
||||
public ShowHomeEvent() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ShowHomeEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ShowHomeEventHandler handler) {
|
||||
handler.onShowHome(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The event handler interface for the show home event.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public interface ShowHomeEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param showHomeEvent
|
||||
*/
|
||||
void onShowHome(ShowHomeEvent showHomeEvent);
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
|
|||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.EditMetadataEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.InsertMetadataEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowHomeEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowStatisticsEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserDatasetsEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.ShowUserOrganizationsEvent;
|
||||
|
@ -31,6 +32,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
|
|||
public class CkanMetadataManagementPanel extends FlowPanel{
|
||||
|
||||
private AlertBlock nav = new AlertBlock();
|
||||
private Button home = new Button("Home");
|
||||
private Button insertMeta = new Button("Publish Product");
|
||||
private Button editMeta = new Button("Edit Product");
|
||||
private Button myDatasets = new Button("My Products");
|
||||
|
@ -48,6 +50,7 @@ public class CkanMetadataManagementPanel extends FlowPanel{
|
|||
// this.getElement().getStyle().setPaddingBottom(H_OFFSET, Unit.PX);
|
||||
|
||||
// set link style buttons
|
||||
home.setType(ButtonType.LINK);
|
||||
myDatasets.setType(ButtonType.LINK);
|
||||
myOrganizations.setType(ButtonType.LINK);
|
||||
insertMeta.setType(ButtonType.LINK);
|
||||
|
@ -55,6 +58,7 @@ public class CkanMetadataManagementPanel extends FlowPanel{
|
|||
statistics.setType(ButtonType.LINK);
|
||||
|
||||
// set icons
|
||||
home.setIcon(IconType.HOME);
|
||||
myDatasets.setIcon(IconType.SITEMAP);
|
||||
myOrganizations.setIcon(IconType.BUILDING);
|
||||
insertMeta.setIcon(IconType.FILE);
|
||||
|
@ -66,6 +70,7 @@ public class CkanMetadataManagementPanel extends FlowPanel{
|
|||
insertMeta.setVisible(false);
|
||||
|
||||
// add to navigation bar
|
||||
nav.add(home);
|
||||
nav.add(myDatasets);
|
||||
nav.add(myOrganizations);
|
||||
nav.add(statistics);
|
||||
|
@ -83,6 +88,16 @@ public class CkanMetadataManagementPanel extends FlowPanel{
|
|||
*
|
||||
*/
|
||||
private void addHandlers() {
|
||||
|
||||
home.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
eventBus.fireEvent(new ShowHomeEvent());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
insertMeta.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue