git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@164633 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-03-01 11:48:54 +00:00
parent bc1e67e430
commit 6d14ec7745
8 changed files with 106 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.model;
import java.io.Serializable;
import java.util.List;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
@ -35,7 +36,6 @@ public class FileModel extends BaseModelData implements Serializable {
protected boolean isSpecialFolder = false;
protected boolean isPublic = false; // IS IT A PUBLIC FOLDER?
public static final String NAME = "Name";
public static final String TYPE = "Type";
public static final String ICON = "Icon";
@ -52,6 +52,9 @@ public class FileModel extends BaseModelData implements Serializable {
public static final String OWNERFULLNAME = "Owner Name";
public static final String HUMAN_REDABLE_CATEGORY = "HR Category";
//Thredds Synch status
private Sync_Status synchedThreddsStatus;
/**
* Instantiates a new file model.
*/
@ -328,8 +331,22 @@ public class FileModel extends BaseModelData implements Serializable {
else{ //SIMPLE FOLDER
if(this.isPublic()) //IS PLUBIC
absImgPr = Resources.getIconFolderPublic();
else
else {
if(this.getSynchedThreddsStatus()!=null) {
switch(this.getSynchedThreddsStatus()) {
case OUTDATED_REMOTE:
absImgPr = Resources.getIconSyncTo();
break;
case OUTDATED_WS:
absImgPr = Resources.getIconSyncFrom();
break;
case UP_TO_DATE:
absImgPr = Resources.getIconSynched();
break;
}
}
absImgPr = Resources.getIconFolder();
}
}
}
@ -552,6 +569,15 @@ public class FileModel extends BaseModelData implements Serializable {
public boolean isPublic(){
return isPublic;
}
public void setSyncThreddsStatus(Sync_Status status) {
this.synchedThreddsStatus = status;
}
public Sync_Status getSynchedThreddsStatus() {
return synchedThreddsStatus;
}
/* (non-Javadoc)
@ -587,4 +613,5 @@ public class FileModel extends BaseModelData implements Serializable {
return builder.toString();
}
}

View File

@ -457,5 +457,21 @@ public interface Icons extends ClientBundle {
*/
@Source("icons/thredds.gif")
ImageResource thredds();
/**
* Sync icon to.
*
* @return the image resource
*/
@Source("icons/sync-icon-to.png")
ImageResource syncIconTo();
@Source("icons/sync-icon-from.png")
ImageResource syncIconFrom();
@Source("icons/sync-icon-synched.png")
ImageResource syncIconSynched();
}

View File

@ -4,6 +4,7 @@ import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
@ -1372,7 +1373,20 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.thredds());
}
public static AbstractImagePrototype getIconSyncTo() {
return AbstractImagePrototype.create(ICONS.syncIconTo());
}
public static AbstractImagePrototype getIconSyncFrom() {
return AbstractImagePrototype.create(ICONS.syncIconFrom());
}
public static AbstractImagePrototype getIconSynched() {
return AbstractImagePrototype.create(ICONS.syncIconSynched());
}
//ImageResources
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

View File

@ -55,6 +55,10 @@ import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
@ -89,6 +93,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import com.thoughtworks.xstream.XStream;
// TODO: Auto-generated Javadoc
/**
* The Class GWTWorkspaceBuilder.
*
@ -100,6 +105,7 @@ public class GWTWorkspaceBuilder {
protected static final String IMAGE_SERVICE_URL = "ImageService";
protected static Logger logger = Logger.getLogger(GWTWorkspaceBuilder.class);
private InfoContactModel userLogged;
private String scope;
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
@ -741,6 +747,7 @@ public class GWTWorkspaceBuilder {
fileModel.setShareable(false);
}
setSynchedThreddsStateFor(fileModel, scope, userLogged.getLogin());
return fileModel;
}
@ -820,6 +827,7 @@ public class GWTWorkspaceBuilder {
fileGridModel.setOwnerFullName(userLogged.getName());
}
setSynchedThreddsStateFor(fileGridModel, scope, userLogged.getLogin());
return fileGridModel;
}catch (Exception e) {
@ -937,6 +945,7 @@ public class GWTWorkspaceBuilder {
fileGridModel.setOwnerFullName(userLogged.getName());
}
setSynchedThreddsStateFor(fileGridModel, scope, userLogged.getLogin());
return fileGridModel;
}
@ -1949,15 +1958,17 @@ public class GWTWorkspaceBuilder {
return listAccFields;
}
/**
* Sets the user logged.
* Sets the contex info.
*
* @param infoContactModel the new user logged
* @param infoContactModel the info contact model
* @param scope the scope
*/
public void setUserLogged(InfoContactModel infoContactModel) {
public void setContexInfo(InfoContactModel infoContactModel, String scope) {
this.userLogged = infoContactModel;
this.scope = scope;
}
@ -2299,5 +2310,34 @@ public class GWTWorkspaceBuilder {
}
return listVersions;
}
/**
* Sets the synched thredds state for.
*
* @param fileModel the file model
* @param scope the scope
* @param username the username
* @return the file model
*/
protected FileModel setSynchedThreddsStateFor(FileModel fileModel, String scope, String username) {
try {
if(fileModel.isDirectory()) {
ScopeProvider.instance.set(scope);
Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(fileModel.getIdentifier(), username);
fileModel.setSyncThreddsStatus(status);
}
} catch (ItemNotSynched e) {
//silent
logger.trace("Item: "+fileModel.getIdentifier() + " name: "+fileModel.getName() +" is not synched");
} catch (Exception e) {
logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier());
}
return fileModel;
}
}

View File

@ -218,7 +218,7 @@ public class WsUtil {
logger.info("Initializing the workspace area builder");
builder = new GWTWorkspaceBuilder();
//ADDED 03/09/2013
builder.setUserLogged(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false));
builder.setContexInfo(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false), info.getCurrentScope());
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
}