added handler to special folder

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@92699 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-03-05 16:45:33 +00:00
parent 84c824d283
commit 59c0b2af0a
12 changed files with 238 additions and 31 deletions

View File

@ -211,5 +211,7 @@ public class ConstantsExplorer {
public static final String ID_FOLDER = "idFolder"; public static final String ID_FOLDER = "idFolder";
public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement"; public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement";
//PROPERTY
public static final String SPECIALFOLDERNAME = "SPECIALFOLDERNAME";
public static final String SPECIALFOLDERNAMEPROPERTIESFILE = "specialfoldername.properties";
} }

View File

@ -26,6 +26,7 @@ public class FileModel extends BaseModelData implements Serializable {
protected InfoContactModel infoContacts; protected InfoContactModel infoContacts;
protected boolean isRoot = false; protected boolean isRoot = false;
protected boolean isVreFolder; protected boolean isVreFolder;
protected boolean isSpecialFolder = false;
protected FileModel(){ protected FileModel(){
} }
@ -219,7 +220,11 @@ public class FileModel extends BaseModelData implements Serializable {
}else if(this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD){ //IS A FOLDER IN LOADING }else if(this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD){ //IS A FOLDER IN LOADING
absImgPr = Resources.getIconLoading2(); absImgPr = Resources.getIconLoading2();
}else{//SIMPLE FOLDER }else{
//SPECIAL FOLDER?
if(this.isSpecialFolder())
absImgPr = Resources.getIconSpecialFolder();
else //SIMPLE FOLDER
absImgPr = Resources.getIconFolder(); absImgPr = Resources.getIconFolder();
} }
@ -265,7 +270,7 @@ public class FileModel extends BaseModelData implements Serializable {
} }
private void setName(String name) { public void setName(String name) {
set(ConstantsExplorer.NAME, name); set(ConstantsExplorer.NAME, name);
} }
@ -325,21 +330,31 @@ public class FileModel extends BaseModelData implements Serializable {
this.isVreFolder = isVreFolder; this.isVreFolder = isVreFolder;
} }
/**
* @param b
*/
public void setSpecialFolder(boolean bool) {
this.isSpecialFolder = bool;
}
public boolean isSpecialFolder() {
return isSpecialFolder;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("FileModel [isShareable()="); builder.append("FileModel [test=");
builder.append(isShareable()); builder.append(test);
builder.append(", isShared()="); builder.append(", infoContacts=");
builder.append(isShared()); builder.append(infoContacts);
builder.append(", getIdentifier()="); builder.append(", isRoot=");
builder.append(getIdentifier()); builder.append(isRoot);
builder.append(", getName()="); builder.append(", isVreFolder=");
builder.append(getName()); builder.append(isVreFolder);
builder.append(", isDirectory()="); builder.append(", isSpecialFolder=");
builder.append(isDirectory()); builder.append(isSpecialFolder);
builder.append(", isRoot()=");
builder.append(isRoot());
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -299,10 +299,13 @@ public interface Icons extends ClientBundle {
@Source("icons/writeall.png") @Source("icons/writeall.png")
ImageResource writeall(); ImageResource writeall();
@Source("icons/vreShare.png") @Source("icons/specialfolder2.png")
ImageResource vreFolder(); ImageResource vreFolder();
@Source("icons/admin.png") @Source("icons/admin.png")
ImageResource administrator(); ImageResource administrator();
@Source("icons/specialfolder2.png")
ImageResource specialFolder();
} }

View File

@ -80,6 +80,11 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.users()); return AbstractImagePrototype.create(ICONS.users());
} }
public static AbstractImagePrototype getIconSpecialFolder(){
return AbstractImagePrototype.create(ICONS.specialFolder());
}
public static AbstractImagePrototype getIconAdministrator(){ public static AbstractImagePrototype getIconAdministrator(){
return AbstractImagePrototype.create(ICONS.administrator()); return AbstractImagePrototype.create(ICONS.administrator());

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

View File

@ -151,10 +151,12 @@ public class AsyncTreePanel extends LayoutContainer {
if(model.getStatus() == ConstantsExplorer.FOLDERNOTLOAD) if(model.getStatus() == ConstantsExplorer.FOLDERNOTLOAD)
return Resources.getIconLoading2(); return Resources.getIconLoading2();
if(model.isVreFolder()){ if(model.isVreFolder())
return Resources.getIconVREFolder(); return Resources.getIconVREFolder();
}
if(model.isSpecialFolder())
return Resources.getIconSpecialFolder();
//SHARE ICON //SHARE ICON
if(model.isShared()){ if(model.isShared()){
if(model.isShareable()) if(model.isShareable())
@ -318,7 +320,7 @@ public class AsyncTreePanel extends LayoutContainer {
return; return;
} }
if(sel.isVreFolder()){ if(sel.isVreFolder() || sel.isSpecialFolder()){
event.setCancelled(true); event.setCancelled(true);
event.getStatus().setStatus(false); event.getStatus().setStatus(false);
return; return;
@ -860,6 +862,11 @@ public class AsyncTreePanel extends LayoutContainer {
return 1; return 1;
} }
if(m1.isSpecialFolder() && !m2.isSpecialFolder())
return -1;
else if(!m1.isSpecialFolder() && m2.isSpecialFolder())
return 1;
return m1.getName().compareToIgnoreCase(m2.getName()); return m1.getName().compareToIgnoreCase(m2.getName());
} }
}); });

View File

@ -710,8 +710,8 @@ public class ContextMenuTree {
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true); contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
} }
//IS VRE FOLDER? //IS VRE FOLDER or SPECIAL FOLDER?
if(selectedItem.isVreFolder()){ if(selectedItem.isVreFolder() || selectedItem.isSpecialFolder()){
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder

View File

@ -58,6 +58,7 @@ import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
import org.gcube.portlets.user.workspace.server.util.StringUtil; import org.gcube.portlets.user.workspace.server.util.StringUtil;
import org.gcube.portlets.user.workspace.server.util.UserUtil; import org.gcube.portlets.user.workspace.server.util.UserUtil;
import org.gcube.portlets.user.workspace.server.util.WsUtil; import org.gcube.portlets.user.workspace.server.util.WsUtil;
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter; import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException; import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.workspace.shared.TrashOperationResult; import org.gcube.portlets.user.workspace.shared.TrashOperationResult;
@ -128,6 +129,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return WsUtil.getUriResolver(this.getThreadLocalRequest().getSession()); return WsUtil.getUriResolver(this.getThreadLocalRequest().getSession());
} }
protected PropertySpecialFolderReader getPropertySpecialFolderReader() {
return WsUtil.getPropertySpecialFolderReader(this.getThreadLocalRequest().getSession());
}
@Override @Override
public FolderModel getRootForTree() throws Exception { public FolderModel getRootForTree() throws Exception {
@ -254,6 +261,29 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
listFileModels = builder.buildGXTListFileModelItem(wsItem, folder); listFileModels = builder.buildGXTListFileModelItem(wsItem, folder);
//ADDING SPECIAL FOLDER?
if(wsItem.isRoot()){
//TODO
//ADD SPECIAL FOLDER
try{
workspaceLogger.info("Folder is root, loading special folders..");
WorkspaceFolder specialFolder = workspace.getMySpecialFolders();
FileModel specialFolderModel = builder.buildGXTFileModelItem(specialFolder, folder);
specialFolderModel.setSpecialFolder(true);
String newName = getNameForSpecialFolder();
if(!newName.isEmpty()){
workspaceLogger.info("Special folder name updated as: "+newName);
specialFolderModel.setName(newName);
}else
workspaceLogger.info("Special folder name is empty, skipping");
listFileModels.add(specialFolderModel);
}catch (Exception e) {
workspaceLogger.warn("An error occurred on retrieving special folders for folder id: "+folder.getIdentifier(), e);
}
}
return listFileModels; return listFileModels;
} catch (Exception e) { } catch (Exception e) {
@ -265,6 +295,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
} }
private String getNameForSpecialFolder(){
PropertySpecialFolderReader sfReader = getPropertySpecialFolderReader();
if(sfReader==null){
workspaceLogger.warn("Reader is null, skypping set to special folder name");
return "";
}
workspaceLogger.info("Read special folder name: '"+sfReader.getSpecialFolderName()+"', from property file..");
return sfReader.getSpecialFolderName();
}
@Override @Override
public List<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException { public List<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException {
@ -286,18 +330,40 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
// Long startTime = System.currentTimeMillis();
Long startTime = System.currentTimeMillis();
List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren(); List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren();
Long endTime = System.currentTimeMillis() - startTime; // Long endTime = System.currentTimeMillis() - startTime;
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); // String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
workspaceLogger.debug("##HL FILLING: grid getChildren() returning "+listItems.size()+" elements in " + time); // workspaceLogger.debug("##HL FILLING: grid getChildren() returning "+listItems.size()+" elements in " + time);
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder); listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder);
//ADDING SPECIAL FOLDER?
if(wsFolder.isRoot()){
//TODO
//ADD SPECIAL FOLDER
try{
workspaceLogger.info("Folder is root, loading special folders..");
WorkspaceFolder specialFolder = workspace.getMySpecialFolders();
FileGridModel specialFolderModel = builder.buildGXTFileGridModelItem(specialFolder, folder);
specialFolderModel.setSpecialFolder(true);
String newName = getNameForSpecialFolder();
if(!newName.isEmpty()){
workspaceLogger.info("Special folder name updated as: "+newName);
specialFolderModel.setName(newName);
}else
workspaceLogger.info("Special folder name is empty, skipping");
listFileGridModels.add(specialFolderModel);
}catch (Exception e) {
workspaceLogger.warn("An error occurred on retrieving special folders for folder id: "+folder.getIdentifier(), e);
}
}
return listFileGridModels; return listFileGridModels;
} catch (Exception e) { } catch (Exception e) {
@ -1510,11 +1576,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public boolean sentToByMessageModel(MessageModel message) throws Exception { public boolean sentToByMessageModel(MessageModel message) throws Exception {
return false; return false;
} }
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public boolean saveAttachments(String messageIdentifier, String messageType) throws Exception { public boolean saveAttachments(String messageIdentifier, String messageType) throws Exception {
try { try {
@ -1538,6 +1613,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public boolean saveAttach(String attachId) throws Exception { public boolean saveAttach(String attachId) throws Exception {
// TODO NOT USED // TODO NOT USED
return false; return false;
@ -1594,6 +1673,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public boolean deleteMessage(String messageIdentifier, String messageType) throws Exception { public boolean deleteMessage(String messageIdentifier, String messageType) throws Exception {
try { try {
@ -1617,7 +1700,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
} }
@Override
@Deprecated
/**
* use WsMailWidget
*/
public List<MessageModel> getNewMessagesReceived() throws Exception { public List<MessageModel> getNewMessagesReceived() throws Exception {
try { try {
@ -1644,6 +1731,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public List<MessageModel> searchInSentMessagesByText(String text) throws Exception { public List<MessageModel> searchInSentMessagesByText(String text) throws Exception {
try { try {
@ -1666,6 +1757,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
@Override @Override
@Deprecated
/**
* use WsMailWidget
*/
public List<MessageModel> searchInReceivedMessagesByText(String text) throws Exception { public List<MessageModel> searchInReceivedMessagesByText(String text) throws Exception {
try { try {

View File

@ -0,0 +1,8 @@
package org.gcube.portlets.user.workspace.server.util.resource;
@SuppressWarnings("serial")
public class PropertyFileReadingErrorException extends Exception {
public PropertyFileReadingErrorException(String message) {
super(message);
}
}

View File

@ -0,0 +1,69 @@
/**
*
*/
package org.gcube.portlets.user.workspace.server.util.resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Mar 5, 2014
*
*/
public class PropertySpecialFolderReader {
protected static Logger logger = Logger.getLogger(PropertySpecialFolderReader.class);
protected String specialFolderName = "";
public PropertySpecialFolderReader() throws PropertyFileReadingErrorException {
try{
logger.info("Instancing new PropertySpecialFolderReader..");
// URL resource = PropertySpecialFolderReader.class.getResource(ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
// File file = new File(resource.toURI());
// FileInputStream input = new FileInputStream(file);
InputStream input = PropertySpecialFolderReader.class.getResourceAsStream(ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
Properties properties = new Properties();
properties.load(input);
specialFolderName = properties.getProperty(ConstantsExplorer.SPECIALFOLDERNAME);
logger.info("PropertySpecialFolderReader read for key: "+ConstantsExplorer.SPECIALFOLDERNAME + " value: "+specialFolderName);
}catch (Exception e) {
logger.error("Error on loading property to read special folder name: ",e);
throw new PropertyFileReadingErrorException("Error on reading property file: "+ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
}
}
public String getSpecialFolderName() {
return specialFolderName;
}
public void setSpecialFolderName(String specialFolderName) {
this.specialFolderName = specialFolderName;
}
public static void main(String[] args) {
try {
new PropertySpecialFolderReader();
} catch (PropertyFileReadingErrorException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,3 @@
#Property file - Special Folder Name
#2014-05-03
SPECIALFOLDERNAME=myspecialfolder