go to folder completed

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@77066 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-06-14 13:04:21 +00:00
parent cfb1f5fba6
commit 078599f602
4 changed files with 163 additions and 35 deletions

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType; import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeInResult; import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeInResult;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet.WsPortletInitOperation;
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent; import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler; import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler;
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent; import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
@ -75,6 +76,7 @@ import org.gcube.portlets.user.workspace.client.view.WorskpacePortlet;
import org.gcube.portlets.user.workspace.client.view.panels.GxtBorderLayoutPanel; import org.gcube.portlets.user.workspace.client.view.panels.GxtBorderLayoutPanel;
import org.gcube.portlets.user.workspace.client.view.panels.GxtItemsPanel; import org.gcube.portlets.user.workspace.client.view.panels.GxtItemsPanel;
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo; import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert; import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
import org.gcube.portlets.user.wsmail.client.forms.MailForm; import org.gcube.portlets.user.wsmail.client.forms.MailForm;
@ -399,7 +401,7 @@ public class AppController implements SubscriberInterface {
FolderModel folder = new FolderModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), true, fileModel.isShared()); FolderModel folder = new FolderModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), true, fileModel.isShared());
updateStoreByRpc(folder); updateStoreByRpc(folder);
wsPortlet.getGridGroupContainer().setCurrentFolderView(folder); wsPortlet.getGridGroupContainer().setCurrentFolderView(folder);
loadBreadcrumbById(fileModel, true); loadBreadcrumbByFileModel(fileModel, true);
} }
else else
GWT.log("an error occurred in double click on grid, item select is null"); GWT.log("an error occurred in double click on grid, item select is null");
@ -466,7 +468,7 @@ public class AppController implements SubscriberInterface {
wsPortlet.getSearchAndFilterContainer().setSearchActive(true); //ADDED 06-04-12 wsPortlet.getSearchAndFilterContainer().setSearchActive(true); //ADDED 06-04-12
appContrExplorer.searching(true); appContrExplorer.searching(true);
doSearchItemById(searchItemByIdEvent.getItemId()); doSearchItemById(searchItemByIdEvent.getItemId(), searchItemByIdEvent.getOperationParameter());
}else{ }else{
@ -476,33 +478,78 @@ public class AppController implements SubscriberInterface {
} }
} }
private void doSearchItemById(String itemId) { private void doSearchItemById(final String itemId, WsPortletInitOperation wsPortletInitOperation) {
wsPortlet.getGridGroupContainer().setBorderAsOnSearch(true); wsPortlet.getGridGroupContainer().setBorderAsOnSearch(true);
wsPortlet.getGridGroupContainer().mask(ConstantsExplorer.LOADING,ConstantsExplorer.LOADINGSTYLE); wsPortlet.getGridGroupContainer().mask(ConstantsExplorer.LOADING,ConstantsExplorer.LOADINGSTYLE);
appContrExplorer.getRpcWorkspaceService().getItemForFileGrid(itemId, new AsyncCallback<FileGridModel>() {
switch (wsPortletInitOperation) {
case gotofolder:
appContrExplorer.getRpcWorkspaceService().getFolderChildrenForFileGridById(itemId, new AsyncCallback<List<FileGridModel>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// System.out.println("Failure search RPC"); new MessageBoxAlert("Error", caught.getMessage(), null);
new MessageBoxAlert("Error", caught.getMessage(), null); wsPortlet.getGridGroupContainer().unmask();
wsPortlet.getGridGroupContainer().unmask();
}
}
@Override @Override
public void onSuccess(FileGridModel result) { public void onSuccess(List<FileGridModel> result) {
wsPortlet.getGridGroupContainer().updateStore(result);
wsPortlet.getGridGroupContainer().unmask();
if(result!=null && result.size()>0){
String childId = result.get(0).getIdentifier(); //GET FIRST CHILD ID TO LOAD PARENTS BREADCRUMB
loadParentBreadcrumbByItemId(childId);
}
boolean selected =wsPortlet.getGridGroupContainer().selectItemByFileModelId(itemId);
if(selected)
new InfoDisplay("Info", "The searched element was selected");
}
});
List<FileGridModel> listResult = new ArrayList<FileGridModel>();
listResult.add(result);
wsPortlet.getGridGroupContainer().updateStore(listResult);
wsPortlet.getGridGroupContainer().unmask();
if(result!=null) break;
loadBreadcrumbById(result, false); //ADDED 13-06-2013
} case sharelink:
});
appContrExplorer.getRpcWorkspaceService().getItemForFileGrid(itemId, new AsyncCallback<FileGridModel>() {
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", caught.getMessage(), null);
wsPortlet.getGridGroupContainer().unmask();
}
@Override
public void onSuccess(FileGridModel result) {
List<FileGridModel> listResult = new ArrayList<FileGridModel>();
listResult.add(result);
wsPortlet.getGridGroupContainer().updateStore(listResult);
wsPortlet.getGridGroupContainer().unmask();
if(result!=null)
loadBreadcrumbByFileModel(result, false); //ADDED 13-06-2013
}
});
break;
}
} }
}); });
@ -633,7 +680,7 @@ public class AppController implements SubscriberInterface {
public void loadBreadcrumb(LoadBreadcrumbEvent loadBreadcrumbEvent) { public void loadBreadcrumb(LoadBreadcrumbEvent loadBreadcrumbEvent) {
if(loadBreadcrumbEvent.getFileModel()!=null) if(loadBreadcrumbEvent.getFileModel()!=null)
loadBreadcrumbById(loadBreadcrumbEvent.getFileModel(), true); loadBreadcrumbByFileModel(loadBreadcrumbEvent.getFileModel(), true);
} }
}); });
} }
@ -655,10 +702,10 @@ public class AppController implements SubscriberInterface {
//RELOAD breadcrumb only if last parent id is changed //RELOAD breadcrumb only if last parent id is changed
if(parentChanged) if(parentChanged)
loadBreadcrumbById(target,false); loadBreadcrumbByFileModel(target,false);
} }
else else
loadBreadcrumbById(target,false); loadBreadcrumbByFileModel(target,false);
} }
@ -674,7 +721,7 @@ public class AppController implements SubscriberInterface {
* @param item * @param item
* @param isLastParent - if is true, load the item passed in input as last item of the resulted list * @param isLastParent - if is true, load the item passed in input as last item of the resulted list
*/ */
private void loadBreadcrumbById(final FileModel item, final boolean isLastParent){ private void loadBreadcrumbByFileModel(final FileModel item, final boolean isLastParent){
GWT.log("Reload Breadcrumb: [FileModel name: "+item.getName()+ ", isLastParent: "+isLastParent+"]"); GWT.log("Reload Breadcrumb: [FileModel name: "+item.getName()+ ", isLastParent: "+isLastParent+"]");
@ -700,6 +747,32 @@ public class AppController implements SubscriberInterface {
}); });
} }
/**
*
* @param itemId
*/
protected void loadParentBreadcrumbByItemId(final String itemId){
GWT.log("Reload Parent Breadcrumb: [Item id: "+itemId+"]");
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemId, new AsyncCallback<List<FileModel>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("failure get list parents by item identifier "+caught);
}
@Override
public void onSuccess(List<FileModel> result) {
setPathInView(result); //Set file path in tab panel on current item selected
}
});
}
private void setPathInView(List<FileModel> parents){ private void setPathInView(List<FileModel> parents){
@ -715,10 +788,12 @@ public class AppController implements SubscriberInterface {
public void go(final HasWidgets rootPanel) { public void go(final HasWidgets rootPanel) {
final String searchParameter = Window.Location.getParameter(ConstantsPortlet.GET_SEARCH_PARAMETER); final String searchParameter = Window.Location.getParameter(ConstantsPortlet.GET_SEARCH_PARAMETER);
final String idParameter = Window.Location.getParameter(ConstantsPortlet.GET_ITEMID_PARAMETER); final String itemIdParameter = Window.Location.getParameter(ConstantsPortlet.GET_ITEMID_PARAMETER);
final String operationParameter = Window.Location.getParameter(ConstantsPortlet.GET_OPEARATION_PARAMETER);
GWT.log("GET PARAMETER: searchParameter "+searchParameter); GWT.log("GET PARAMETER "+ConstantsPortlet.GET_SEARCH_PARAMETER+": "+searchParameter);
GWT.log("GET PARAMETER: idParameter "+idParameter); GWT.log("GET PARAMETER "+ConstantsPortlet.GET_ITEMID_PARAMETER+": "+itemIdParameter);
GWT.log("GET PARAMETER "+ConstantsPortlet.GET_OPEARATION_PARAMETER+": "+operationParameter);
final boolean instanceWithGrouping = readCookieWorkspaceGridViewSetting(); final boolean instanceWithGrouping = readCookieWorkspaceGridViewSetting();
@ -735,7 +810,7 @@ public class AppController implements SubscriberInterface {
if(searchParameter!=null && !searchParameter.isEmpty()) if(searchParameter!=null && !searchParameter.isEmpty())
isSearch = true; isSearch = true;
if(idParameter!=null && !idParameter.isEmpty()){ if(itemIdParameter!=null && !itemIdParameter.isEmpty()){
isSearch = true; isSearch = true;
isSearchForItemId = true; isSearchForItemId = true;
} }
@ -767,12 +842,12 @@ public class AppController implements SubscriberInterface {
wsPortlet.getSearchAndFilterContainer().searchText(searchParameter); wsPortlet.getSearchAndFilterContainer().searchText(searchParameter);
} }
}); });
} else if(idParameter!=null && !idParameter.isEmpty()){ //SEARCH FOR ITEM ID } else if(itemIdParameter!=null && !itemIdParameter.isEmpty()){ //SEARCH FOR ITEM ID
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
AppController.getEventBus().fireEvent(new SearchItemByIdEvent(idParameter)); AppController.getEventBus().fireEvent(new SearchItemByIdEvent(itemIdParameter, operationParameter));
} }
}); });
@ -918,7 +993,7 @@ public class AppController implements SubscriberInterface {
} }
else{ else{
updatGridViewForSelectedItem(item); //No operation is running.. view only items of same level tree of selected item updatGridViewForSelectedItem(item); //No operation is running.. view only items of same level tree of selected item
loadBreadcrumbById(item, true); loadBreadcrumbByFileModel(item, true);
} }
} }
@ -946,7 +1021,7 @@ public class AppController implements SubscriberInterface {
public boolean renameItem(String itemIdentifier, String newName, String extension) { public boolean renameItem(String itemIdentifier, String newName, String extension) {
FileModel lastParent = wsPortlet.getToolBarPath().getLastParent(); //RELOAD BREADCRUMB FileModel lastParent = wsPortlet.getToolBarPath().getLastParent(); //RELOAD BREADCRUMB
loadBreadcrumbById(lastParent, true); loadBreadcrumbByFileModel(lastParent, true);
return wsPortlet.getGridGroupContainer().renameItem(itemIdentifier, newName, extension); return wsPortlet.getGridGroupContainer().renameItem(itemIdentifier, newName, extension);
@ -1025,6 +1100,8 @@ public class AppController implements SubscriberInterface {
@Override @Override
public void movedItems(String sourceParentIdentifier, FileModel targetParent) { public void movedItems(String sourceParentIdentifier, FileModel targetParent) {
updateStoreByRpc(targetParent); updateStoreByRpc(targetParent);
loadBreadcrumbByFileModel(targetParent, true); //ADDED 13-06-2013
} }
@Override @Override

View File

@ -18,6 +18,9 @@ public class ConstantsPortlet {
//USED IN HTTP GET AS PARAMETERS //USED IN HTTP GET AS PARAMETERS
public static final String GET_SEARCH_PARAMETER ="search"; public static final String GET_SEARCH_PARAMETER ="search";
public static final String GET_ITEMID_PARAMETER ="itemid"; public static final String GET_ITEMID_PARAMETER ="itemid";
public static final String GET_OPEARATION_PARAMETER ="operation";
public static enum WsPortletInitOperation {sharelink, gotofolder}; //DEFAULT OPERATION IS GOTOFOLDER
// Div Gwt // Div Gwt
public static final String WORKSPACEDIV = "workspaceDiv"; public static final String WORKSPACEDIV = "workspaceDiv";

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.workspace.client.event; package org.gcube.portlets.user.workspace.client.event;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet.WsPortletInitOperation;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
@ -12,9 +14,26 @@ public class SearchItemByIdEvent extends GwtEvent<SearchItemByIdEventHandler> {
public static Type<SearchItemByIdEventHandler> TYPE = new Type<SearchItemByIdEventHandler>(); public static Type<SearchItemByIdEventHandler> TYPE = new Type<SearchItemByIdEventHandler>();
private String itemId; private String itemId;
private WsPortletInitOperation operationParameter = null;
public SearchItemByIdEvent(String itemId) { public SearchItemByIdEvent(String itemId, String op) {
this.itemId = itemId; this.itemId = itemId;
if(op!=null){
if(op.compareToIgnoreCase(WsPortletInitOperation.sharelink.toString())==0)
operationParameter = WsPortletInitOperation.sharelink;
else if(op.compareToIgnoreCase(WsPortletInitOperation.gotofolder.toString())==0)
operationParameter = WsPortletInitOperation.gotofolder;
}else
if(operationParameter==null)
operationParameter = WsPortletInitOperation.gotofolder; //DEFAULT OPERATION
} }
@Override @Override
@ -36,4 +55,12 @@ public class SearchItemByIdEvent extends GwtEvent<SearchItemByIdEventHandler> {
this.itemId = itemId; this.itemId = itemId;
} }
public WsPortletInitOperation getOperationParameter() {
return operationParameter;
}
public void setOperationParameter(WsPortletInitOperation operationParameter) {
this.operationParameter = operationParameter;
}
} }

View File

@ -60,6 +60,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
private GroupingView view = new GroupingView(); private GroupingView view = new GroupingView();
private boolean groupingEnabled = false; private boolean groupingEnabled = false;
private NumberFormat number = ConstantsExplorer.numberFormatterKB; private NumberFormat number = ConstantsExplorer.numberFormatterKB;
private final Grid<FileGridModel> grid;
public GxtGridFilterGroupPanel(boolean group) { public GxtGridFilterGroupPanel(boolean group) {
setLayout(new FitLayout()); setLayout(new FitLayout());
@ -86,7 +87,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
cp.setHeaderVisible(false); cp.setHeaderVisible(false);
cp.setLayout(new FitLayout()); cp.setLayout(new FitLayout());
final Grid<FileGridModel> grid = new Grid<FileGridModel>(store, columnModel); grid = new Grid<FileGridModel>(store, columnModel);
grid.getView().setAutoFill(true); grid.getView().setAutoFill(true);
grid.setBorders(true); grid.setBorders(true);
@ -432,6 +433,26 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return (FileGridModel) store.findModel(ConstantsExplorer.IDENTIFIER, id); return (FileGridModel) store.findModel(ConstantsExplorer.IDENTIFIER, id);
} }
/**
*
* @param id
* @return
*/
public boolean selectItemByFileModelId(String id){
if(id!=null && !id.isEmpty()){
FileGridModel fileModel = getFileGridModelByIdentifier(id);
if(fileModel!=null){
grid.getSelectionModel().select(fileModel, true);
return true;
}
}
return false;
}
public GroupingStore<FileGridModel> getStore(){ public GroupingStore<FileGridModel> getStore(){
return store; return store;
} }