fixed bug after folder sharing

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@100018 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-09-18 13:29:39 +00:00
parent c087e182e6
commit cf2a2443a3
6 changed files with 54 additions and 48 deletions

View File

@ -236,8 +236,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
public void handleEvent(MessageBoxEvent be) { public void handleEvent(MessageBoxEvent be) {
// eventBus.fireEvent(new DeleteItemEvent(sel));
//IF NOT CANCELLED //IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId(); String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){ if(clickedButton.equals(Dialog.YES)){
@ -373,7 +371,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
final DialogShareFolder finalDialog = dialogSharedFolder; final DialogShareFolder finalDialog = dialogSharedFolder;
final FileModel parentModel = parent; final FileModel parentModel = parent;
finalDialog.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() { finalDialog.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override @Override
@ -437,8 +434,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
else else
parentToRefresh = parentFileModel; parentToRefresh = parentFileModel;
GWT.log("share completed refresh folder : "+parentToRefresh.getName() +" get id: "+parentToRefresh.getIdentifier()); GWT.log("share completed throwing refresh folder : "+parentToRefresh.getName() +" get id: "+parentToRefresh.getIdentifier());
eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
// eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
//TODO UPDATED ID
RefreshFolderEvent refEvent = new RefreshFolderEvent(parentToRefresh, true, true, false);
refEvent.setForceReloadBreadCrumb(true);
eventBus.fireEvent(refEvent);
} }
explorerPanel.unmask(); explorerPanel.unmask();
} }
@ -545,18 +548,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(getLinkEvent.getSourceFile()!=null){ if(getLinkEvent.getSourceFile()!=null){
String currentUrl = portalURL(); String currentUrl = portalURL();
int lastChar = currentUrl.lastIndexOf("?"); int lastChar = currentUrl.lastIndexOf("?");
currentUrl = lastChar>-1?currentUrl.substring(0, lastChar):currentUrl; //IF EXISTS - REMOVE STRING AFTER ? (? INLCUSE) currentUrl = lastChar>-1?currentUrl.substring(0, lastChar):currentUrl; //IF EXISTS - REMOVE STRING AFTER ? (? INLCUSE)
// int last = currentUrl.lastIndexOf("/"); //int last = currentUrl.lastIndexOf("/");
// String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier(); //String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier(); String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
shareLinkUrl+="&"+ConstantsExplorer.GET_OPEARATION_PARAMETER+"="+WsPortletInitOperation.gotofolder; shareLinkUrl+="&"+ConstantsExplorer.GET_OPEARATION_PARAMETER+"="+WsPortletInitOperation.gotofolder;
DialogShareLink dialog = new DialogShareLink("Copy to clipboard Share Link: Ctrl+C", shareLinkUrl); DialogShareLink dialog = new DialogShareLink("Copy to clipboard Share Link: Ctrl+C", shareLinkUrl);
dialog.show(); dialog.show();
} }
@ -590,19 +589,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder()); explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
notifySubscriber(refreshItemEvent); notifySubscriber(refreshItemEvent);
} }
else{ //Valitaing folder existence - called portlet side else{ //Validating folder existence - called portlet side
FileModel target = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(refreshItemEvent.getFolderTarget().getIdentifier()); FileModel target = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(refreshItemEvent.getFolderTarget().getIdentifier());
if(target!=null) if(target!=null)
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder()); explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
} }
// notifySubscriber(refreshtemEvent);
} }
else else
GWT.log("warn: escape refresh because item is null"); GWT.log("warn: escape refresh because item is null");
} }
}); });
@ -683,7 +677,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(result){ if(result){
eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false, false, false)); eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false, false, false));
// explorerPanel.getAsycTreePanel().setExpandTreeLevel(event.getTargetParentFileModel(), true); //Expand level drop //explorerPanel.getAsycTreePanel().setExpandTreeLevel(event.getTargetParentFileModel(), true); //Expand level drop
} }
if(fileInTree!=null) if(fileInTree!=null)
@ -1741,14 +1735,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
String currentUrl = portalURL(); String currentUrl = portalURL();
int last = currentUrl.lastIndexOf("/"); int last = currentUrl.lastIndexOf("/");
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION; String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
// Log.trace("Url: "+reportUrl);
// System.out.println("currentUrl " +currentUrl);
// System.out.println("reportUrl " +reportUrl);
new WindowOpenUrl(reportUrl, "_self", ""); new WindowOpenUrl(reportUrl, "_self", "");
} }
else{ else{
String reportUrl = url; String reportUrl = url;
// System.out.println("reportUrl " +reportUrl);
new WindowOpenUrl(reportUrl, "_self", ""); new WindowOpenUrl(reportUrl, "_self", "");
} }
@ -1775,8 +1765,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
public void onSuccess(String url) { public void onSuccess(String url) {
if(url==null || url.isEmpty()){ if(url==null || url.isEmpty()){
String currentUrl = portalURL(); String currentUrl = portalURL();
int last = currentUrl.lastIndexOf("/"); int last = currentUrl.lastIndexOf("/");
String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION; String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
@ -1784,8 +1772,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
System.out.println("currentUrl " +currentUrl); System.out.println("currentUrl " +currentUrl);
System.out.println("reportUrl " +templateUrl); System.out.println("reportUrl " +templateUrl);
new WindowOpenUrl(templateUrl, "_self", ""); new WindowOpenUrl(templateUrl, "_self", "");
}else{ }else{
String templateUrl = url; String templateUrl = url;
@ -1904,7 +1890,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
RefreshFolderEvent refresh = (RefreshFolderEvent) event; RefreshFolderEvent refresh = (RefreshFolderEvent) event;
sub.refreshFolder(refresh.getFolderTarget(), refresh.isForceRefresh()); sub.refreshFolder(refresh.getFolderTarget(), refresh.isForceRefresh(), refresh.isForceReloadBreadCrumb());
}else if(event instanceof SendMessageEvent){ }else if(event instanceof SendMessageEvent){

View File

@ -17,6 +17,8 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
private boolean ifExists = false; private boolean ifExists = false;
private boolean forceReloadBreadCrumb = false;
/** /**
* *
* @param folderTarget * @param folderTarget
@ -77,6 +79,15 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
return ifExists; return ifExists;
} }
public boolean isForceReloadBreadCrumb() {
return forceReloadBreadCrumb;
}
public void setForceReloadBreadCrumb(boolean forceReloadBreadCrumb) {
this.forceReloadBreadCrumb = forceReloadBreadCrumb;
}
@Override @Override
public String toString() { public String toString() {
@ -89,7 +100,10 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
builder.append(forceRefresh); builder.append(forceRefresh);
builder.append(", ifExists="); builder.append(", ifExists=");
builder.append(ifExists); builder.append(ifExists);
builder.append(", forceReloadBreadCrumb=");
builder.append(forceReloadBreadCrumb);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -31,6 +31,6 @@ public enum EventsTypeEnum
PASTED_EVENT, PASTED_EVENT,
COPY_EVENT, COPY_EVENT,
TRASH_EVENT, TRASH_EVENT,
UPDATED_VRE_PERMISSION, UPDATED_VRE_PERMISSION,
ADD_ADMINISTRATOR_EVENT; ADD_ADMINISTRATOR_EVENT;
} }

View File

@ -31,7 +31,7 @@ public interface SubscriberInterface {
void smartFolderSelected(String folderId, String category); void smartFolderSelected(String folderId, String category);
void movedItems(String sourceParentIdentifier, FileModel targetParent); void movedItems(String sourceParentIdentifier, FileModel targetParent);
void switchView(ViewSwitchType type); void switchView(ViewSwitchType type);
void refreshFolder(FileModel fileModel, boolean forced); void refreshFolder(FileModel fileModel, boolean forceRefreshContent, boolean forceRefreshBreadcrumb);
// void updatePrevieMessage(String fromLogin, String subject, String date, String body, List<FileModel> attachs); // void updatePrevieMessage(String fromLogin, String subject, String date, String body, List<FileModel> attachs);
void createNewMessage(HashMap<String, String> hashAttachs); void createNewMessage(HashMap<String, String> hashAttachs);
@ -65,4 +65,11 @@ public interface SubscriberInterface {
*/ */
void updatedVREPermissions(String vreFolderId); void updatedVREPermissions(String vreFolderId);
/**
*
* @param oldId
* @param newId
*/
void changedFileModelId(String oldId, String newId);
} }

View File

@ -22,7 +22,7 @@ public class FileModel extends BaseModelData implements Serializable {
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected GXTFolderItemTypeEnum test; //TODO remove? protected GXTFolderItemTypeEnum folderItemType; //It's here to serialization don't remove
protected InfoContactModel infoContacts; protected InfoContactModel infoContacts;
protected boolean isRoot = false; protected boolean isRoot = false;
protected boolean isVreFolder; protected boolean isVreFolder;
@ -345,17 +345,29 @@ public class FileModel extends BaseModelData implements Serializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("FileModel [test="); builder.append("FileModel [isRoot=");
builder.append(test);
builder.append(", infoContacts=");
builder.append(infoContacts);
builder.append(", isRoot=");
builder.append(isRoot); builder.append(isRoot);
builder.append(", isVreFolder="); builder.append(", isVreFolder=");
builder.append(isVreFolder); builder.append(isVreFolder);
builder.append(", isSpecialFolder="); builder.append(", isSpecialFolder=");
builder.append(isSpecialFolder); builder.append(isSpecialFolder);
builder.append(", isShareable()=");
builder.append(isShareable());
builder.append(", getOwner()=");
builder.append(getOwner());
builder.append(", isShared()=");
builder.append(isShared());
builder.append(", getIdentifier()=");
builder.append(getIdentifier());
builder.append(", getName()=");
builder.append(getName());
// builder.append(", getParentFileModel()=");
// builder.append(getParentFileModel());
builder.append(", isDirectory()=");
builder.append(isDirectory());
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -742,10 +742,6 @@ public class AsyncTreePanel extends LayoutContainer {
private void reloadTreeLevelAndExpandFolder(final FolderModel folder, final boolean expandFolder){ private void reloadTreeLevelAndExpandFolder(final FolderModel folder, final boolean expandFolder){
treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION,ConstantsExplorer.LOADINGSTYLE); treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION,ConstantsExplorer.LOADINGSTYLE);
// System.out.println("ReloadTreeLevelAndExpandFolder");
// System.out.println("Start RPC - getFolderChildren");
AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){ AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){
@Override @Override
@ -756,8 +752,6 @@ public class AsyncTreePanel extends LayoutContainer {
eventBus.fireEvent(new SessionExpiredEvent()); eventBus.fireEvent(new SessionExpiredEvent());
return; return;
} }
// System.out.println("Error in reloadTreeLevelAndExpandFolder "+ caught.getMessage());
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items." +ConstantsExplorer.TRY_AGAIN, null); new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items." +ConstantsExplorer.TRY_AGAIN, null);
removeAllAndRecoveryRoot(); removeAllAndRecoveryRoot();
@ -767,16 +761,9 @@ public class AsyncTreePanel extends LayoutContainer {
public void onSuccess(List<FileModel> result) { public void onSuccess(List<FileModel> result) {
treePanel.unmask(); treePanel.unmask();
store.removeAll(folder); store.removeAll(folder);
addChildrenToFolder(folder.getIdentifier(), result); addChildrenToFolder(folder.getIdentifier(), result);
setExpandTreeLevel(folder, expandFolder); setExpandTreeLevel(folder, expandFolder);
// selectItem(folder);
// System.out.println("End RPC - getFolderChildren for uplaod/move");
} }
}); });