Updated GetInfo adding Public Folder

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@131411 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-09-15 15:16:59 +00:00
parent 51df7faa73
commit 9c1205118a
5 changed files with 98 additions and 86 deletions

View File

@ -292,7 +292,7 @@ public class FileModel extends BaseModelData implements Serializable {
}else if(this.isShared()){ //IS A SHARED FOLDER?
GWT.log("setting icon is shared: "+this.isShared() + ", this.isVreFolder() "+this.isVreFolder() +", this.isShareable() "+this.isShareable());
GWT.log("setting icon "+this.getName()+" is shared: "+this.isShared() + ", this.isVreFolder() "+this.isVreFolder() +", this.isShareable() "+this.isShareable());
if(this.isVreFolder())
absImgPr = Resources.getIconVREFolder();
@ -304,7 +304,7 @@ public class FileModel extends BaseModelData implements Serializable {
absImgPr = Resources.getIconSharedFolder();
}else{ //IS A DESCENDANT
if(this.isPublic()) //IS PLUBIC
Resources.getIconFolderPublic();
absImgPr = Resources.getIconFolderPublic();
else
absImgPr = Resources.getIconFolder(); //IS A PRIVATE FOLDER
}

View File

@ -1534,8 +1534,6 @@ public class Resources {
return Resources.getIconWorkflowReport();
}else if(itemType.equals(GXTFolderItemTypeEnum.WORKFLOW_TEMPLATE)){
return Resources.getIconWorkflowTemplate();
}else if(itemType.equals(GXTFolderItemTypeEnum.FOLDER)){
return Resources.getIconFolder();
}else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK)){
return Resources.getIconResourceLink();
}

View File

@ -37,7 +37,7 @@ import com.google.gwt.user.client.ui.Image;
public class DialogGetInfo extends Dialog {
/**
*
*
*/
public static final String EMPTY = "empty";
public static final String UNKNOWN = "unknown";
@ -52,6 +52,7 @@ public class DialogGetInfo extends Dialog {
private TextField<String> txtCreated = new TextField<String>();
private TextField<String> txtSize = new TextField<String>();
private TextField<String> txtLocation = new TextField<String>();
private TextField<String> txtIsPublic = new TextField<String>();
private TextField<String> txtShared = new TextField<String>();
// private TextArea textAreaSharedWith = new TextArea();
private Html htmlUsersWidget = new Html();
@ -60,14 +61,14 @@ public class DialogGetInfo extends Dialog {
// private TextField<String> txtGcubeItemProperties;
private HorizontalPanel hpGcubeProperties;
private DialogEditProperties editProperties = null;
public DialogGetInfo(final FileModel fileModel) {
FormLayout layout = new FormLayout();
layout.setLabelWidth(90);
layout.setDefaultWidth(300);
setLayout(layout);
setIcon(fileModel.getAbstractPrototypeIcon());
setHeading(fileModel.getName() + " Properties");
@ -78,17 +79,17 @@ public class DialogGetInfo extends Dialog {
setWidth(widthDialog);
setResizable(false);
setButtons(Dialog.OK);
txtName = new TextField<String>();
txtName.setFieldLabel("Name");
txtName.setReadOnly(true);
textFieldSetValue(txtName,fileModel.getName());
add(txtName);
txtLocation = new TextField<String>();
txtLocation.setFieldLabel("Location");
txtLocation.setReadOnly(true);
if(fileModel.isRoot())
txtLocation.setValue("/");
else
@ -96,11 +97,19 @@ public class DialogGetInfo extends Dialog {
add(txtLocation);
if(fileModel.isDirectory()){
txtIsPublic = new TextField<String>();
txtIsPublic.setFieldLabel("Public Folder");
txtIsPublic.setReadOnly(true);
txtIsPublic.setValue(fileModel.isPublic()+"");
add(txtIsPublic);
}
txtAreaDescription.setFieldLabel("Description");
txtAreaDescription.setHeight(30);
txtAreaDescription.setReadOnly(true);
add(txtAreaDescription);
//GCUBE PROPERTIES
hpGcubeProperties = new HorizontalPanel();
hpGcubeProperties.setStyleAttribute("padding-top", "6px");
@ -112,33 +121,33 @@ public class DialogGetInfo extends Dialog {
loadGcubeItemProperties(fileModel.getIdentifier());
htmlPropertiesWidget.setHeight(heightTextArea);
htmlPropertiesWidget.setWidth("275px");
LayoutContainer lc = new LayoutContainer();
lc.addStyleName("editPermissions");
Image imgProperties = Resources.getIconEdit().createImage(); //EDIT PROPERTIES
imgProperties.setTitle("Edit Properties");
lc.add(imgProperties);
hpGcubeProperties.add(lc);
final Command cmdReloadProperties = new Command() {
@Override
public void execute() {
loadGcubeItemProperties(fileModel.getIdentifier());
}
};
imgProperties.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(editProperties==null)
editProperties = new DialogEditProperties(fileModel, cmdReloadProperties);
editProperties.show();
}
});
htmlPropertiesWidget.setStyleAttribute("margin-left", "5px");
@ -146,19 +155,19 @@ public class DialogGetInfo extends Dialog {
hpGcubeProperties.setScrollMode(Scroll.AUTOY);
add(hpGcubeProperties);
setVisibleGcubeProperties(false);
if(fileModel.isDirectory()){
txtAreaDescription.setValue(fileModel.getDescription());
// add(txtAreaDescription);
}else
loadDescription(fileModel.getIdentifier());
txtType = new TextField<String>();
txtType.setFieldLabel("Type");
txtType.setReadOnly(true);
textFieldSetValue(txtType,fileModel.getType());
add(txtType);
txtCategory = new TextField<String>();
txtCategory.setFieldLabel("Category");
txtCategory.setReadOnly(true);
@ -176,9 +185,9 @@ public class DialogGetInfo extends Dialog {
txtCreated.setReadOnly(true);
loadCreationDate(fileModel.getIdentifier());
add(txtCreated);
txtLastMofication = new TextField<String>();
txtLastMofication.setFieldLabel("Last Mofication");
txtLastMofication.setReadOnly(true);
@ -186,30 +195,30 @@ public class DialogGetInfo extends Dialog {
textFieldSetValue(txtLastMofication, ((FileGridModel) fileModel).getLastModification().toString());
else
loadLastModificationDate(fileModel.getIdentifier());
add(txtLastMofication);
txtSize = new TextField<String>();
txtSize.setFieldLabel("Size");
txtSize.setReadOnly(true);
if(fileModel instanceof FileGridModel)
textFieldSetValue(txtSize,getFormattedSize(((FileGridModel) fileModel).getSize()));
else
loadSize(fileModel.getIdentifier());
add(txtSize);
//SHARED
txtShared = new TextField<String>();
txtShared.setFieldLabel("Shared");
txtShared.setReadOnly(true);
textFieldSetValue(txtShared,fileModel.isShared()+"");
add(txtShared);
//USERS SHARED
if(fileModel.isShared()){
HorizontalPanel hp = new HorizontalPanel();
hp.setStyleAttribute("padding-top", "6px");
Label label = new Label("Shared with");
@ -222,8 +231,8 @@ public class DialogGetInfo extends Dialog {
hp.setScrollMode(Scroll.AUTOY);
add(hp);
}
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
@ -233,23 +242,23 @@ public class DialogGetInfo extends Dialog {
});
this.show();
}
private void setVisibleGcubeProperties(boolean bool){
hpGcubeProperties.setVisible(bool);
}
/**
* @param identifier
*/
private void loadDescription(String identifier) {
txtAreaDescription.mask();
AppControllerExplorer.rpcWorkspaceService.getItemDescriptionById(identifier, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable arg0) {
txtAreaDescription.unmask();
}
@Override
@ -258,16 +267,16 @@ public class DialogGetInfo extends Dialog {
txtAreaDescription.setValue(result);
else
txtAreaDescription.setValue("");
txtAreaDescription.unmask();
}
});
}
private void loadLastModificationDate(final String itemId) {
txtLastMofication.mask();
AppControllerExplorer.rpcWorkspaceService.loadLastModificationDateById(itemId, new AsyncCallback<Date>() {
@ -275,33 +284,33 @@ public class DialogGetInfo extends Dialog {
public void onFailure(Throwable caught) {
GWT.log("an error occured in loadLastModificationDateById "+itemId + " "+caught.getMessage());
txtLastMofication.unmask();
}
@Override
public void onSuccess(Date result) {
if(result!=null)
txtLastMofication.setValue(result.toString());
else
txtLastMofication.setValue(UNKNOWN);
txtLastMofication.unmask();
}
});
}
private void textFieldSetValue(TextField<String> field, String value){
if(value==null || value.isEmpty())
field.setValue(UNKNOWN);
else
field.setValue(value);
}
private void loadOwner(final String itemId){
txtOwner.mask();
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(itemId, new AsyncCallback<InfoContactModel>() {
@ -319,9 +328,9 @@ public class DialogGetInfo extends Dialog {
}
});
}
private void loadGcubeItemProperties(final String itemId){
GWT.log("Load GcubeItemProperties");
htmlPropertiesWidget.mask();
@ -332,7 +341,7 @@ public class DialogGetInfo extends Dialog {
htmlPropertiesWidget.unmask();
GWT.log("an error occured in load properties by Id "+itemId + " "+caught.getMessage());
setVisibleGcubeProperties(true);
htmlPropertiesWidget.setHtml("Error on recovering properties");
htmlPropertiesWidget.setHtml("Error on recovering properties");
}
@Override
@ -350,8 +359,8 @@ public class DialogGetInfo extends Dialog {
}
});
}
private void loadSize(final String itemId){
GWT.log("Load size");
txtSize.mask();
@ -361,7 +370,7 @@ public class DialogGetInfo extends Dialog {
public void onFailure(Throwable caught) {
GWT.log("an error occured in load creation date by Id "+itemId + " "+caught.getMessage());
txtSize.unmask();
}
@Override
@ -372,10 +381,10 @@ public class DialogGetInfo extends Dialog {
}
});
}
private void loadCreationDate(final String itemId){
txtCreated.mask();
AppControllerExplorer.rpcWorkspaceService.getItemCreationDateById(itemId, new AsyncCallback<Date>() {
@ -389,23 +398,23 @@ public class DialogGetInfo extends Dialog {
public void onSuccess(Date result) {
if(result!=null)
textFieldSetValue(txtCreated,result.toString());
txtCreated.unmask();
}
});
}
private void loadACLsDescriptionForSharedFolder(String sharedId){
htmlUsersWidget.mask();
AppControllerExplorer.rpcWorkspaceService.getACLsDescriptionForWorkspaceItemById(sharedId, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
htmlUsersWidget.unmask();
htmlUsersWidget.setHtml("Error on recovering users");
}
@Override
@ -415,9 +424,9 @@ public class DialogGetInfo extends Dialog {
htmlUsersWidget.setHtml(result);
}
});
}
private String getFormattedSize(long value){
if(value>0){
@ -430,9 +439,9 @@ public class DialogGetInfo extends Dialog {
}else
return "";
}
private void loadLocation(String itemId){
txtLocation.mask();
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemId, false, new AsyncCallback<List<FileModel>>() {
@ -444,22 +453,22 @@ public class DialogGetInfo extends Dialog {
@Override
public void onSuccess(List<FileModel> result) {
String location="";
if(result!=null){
for (FileModel fileModel : result) {
location+="/"+fileModel.getName();
}
}
}
if(location.isEmpty())
location ="/";
txtLocation.setValue(location);
txtLocation.unmask();
}
});
}
}

View File

@ -56,7 +56,6 @@ public class DialogGetLink extends Dialog {
public DialogGetLink(String headingTxt, final FileModel item, Link_Type type) {
this.item = item;
setButtonAlign(HorizontalAlignment.CENTER);
setIcon(Resources.getIconPublicLink());
vp.setHorizontalAlign(HorizontalAlignment.CENTER);
vp.setVerticalAlign(VerticalAlignment.MIDDLE);
vp.getElement().getStyle().setPadding(1, Unit.PX);
@ -95,6 +94,7 @@ public class DialogGetLink extends Dialog {
case PUBLIC_LINK:
vp.mask("Getting Public Link...");
setIcon(Resources.getIconPublicLink());
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(item.getIdentifier(), true, new AsyncCallback<PublicLink>() {
@ -129,6 +129,11 @@ public class DialogGetLink extends Dialog {
case FOLDER_LINK:
vp.mask("Getting Folder Link... checking permissions");
if(item.isShared()){
setIcon(Resources.getIconFolderSharedPublic());
}else
setIcon(Resources.getIconFolderPublic());
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(item.getIdentifier(), new AsyncCallback<InfoContactModel>() {

View File

@ -574,7 +574,7 @@ public class GWTWorkspaceBuilder {
switch (item.getType()) {
case FOLDER: fileModel = new FolderModel(item.getId(), item.getName(), true, false);
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
break;
case FOLDER_ITEM:
@ -590,7 +590,7 @@ public class GWTWorkspaceBuilder {
fileModel = new FolderModel(item.getId(), name, true, shared.isVreFolder());
fileModel.setShared(true);
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel());
break;
default:
@ -681,11 +681,11 @@ public class GWTWorkspaceBuilder {
boolean isPublic = ((WorkspaceFolder) item).isPublic();
fileModel = new FolderModel(item.getId(), item.getName(), parentFolderModel, true, false, false, isPublic);
if(isPublic)
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.toString());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel());
else
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
fileModel.setShareable(true);
fileModel.setDescription(item.getDescription());
break;
@ -764,7 +764,7 @@ public class GWTWorkspaceBuilder {
case FOLDER:
fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false,false, false);
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_FOLDERS);
fileGridModel.setShareable(true);
break;
@ -778,7 +778,7 @@ public class GWTWorkspaceBuilder {
case SHARED_FOLDER:
//ATTENTION: SEARCH ITEM IS NOT CASTABLE AT WorkspaceSharedFolder
fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, true, item.isVreFolder(), false);
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_SHARED_FOLDERS);
fileGridModel.setShareable(true);
break;
@ -857,9 +857,9 @@ public class GWTWorkspaceBuilder {
boolean isPublic = ((WorkspaceFolder)item).isPublic();
fileGridModel = new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false,false, isPublic);
if(isPublic)
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel().toString());
else
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel().toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_FOLDERS);
fileGridModel.setShareable(true);
@ -879,9 +879,9 @@ public class GWTWorkspaceBuilder {
fileGridModel = new FolderGridModel(item.getId(), name, toDate(item.getLastModificationTime()), parentFileModel, -1, true, true, shared.isVreFolder(), isPublic);
if(isPublic)
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.getLabel().toString());
else
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel().toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_SHARED_FOLDERS);
fileGridModel.setShareable(true);