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.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.AccountingHistoryEventHandler;
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.GxtItemsPanel;
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.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());
updateStoreByRpc(folder);
wsPortlet.getGridGroupContainer().setCurrentFolderView(folder);
loadBreadcrumbById(fileModel, true);
loadBreadcrumbByFileModel(fileModel, true);
}
else
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
appContrExplorer.searching(true);
doSearchItemById(searchItemByIdEvent.getItemId());
doSearchItemById(searchItemByIdEvent.getItemId(), searchItemByIdEvent.getOperationParameter());
}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().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
public void onFailure(Throwable caught) {
// System.out.println("Failure search RPC");
new MessageBoxAlert("Error", caught.getMessage(), null);
wsPortlet.getGridGroupContainer().unmask();
}
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", caught.getMessage(), null);
wsPortlet.getGridGroupContainer().unmask();
}
@Override
public void onSuccess(FileGridModel result) {
@Override
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)
loadBreadcrumbById(result, false); //ADDED 13-06-2013
}
});
break;
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) {
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
if(parentChanged)
loadBreadcrumbById(target,false);
loadBreadcrumbByFileModel(target,false);
}
else
loadBreadcrumbById(target,false);
loadBreadcrumbByFileModel(target,false);
}
@ -674,7 +721,7 @@ public class AppController implements SubscriberInterface {
* @param item
* @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+"]");
@ -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){
@ -715,10 +788,12 @@ public class AppController implements SubscriberInterface {
public void go(final HasWidgets rootPanel) {
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: idParameter "+idParameter);
GWT.log("GET PARAMETER "+ConstantsPortlet.GET_SEARCH_PARAMETER+": "+searchParameter);
GWT.log("GET PARAMETER "+ConstantsPortlet.GET_ITEMID_PARAMETER+": "+itemIdParameter);
GWT.log("GET PARAMETER "+ConstantsPortlet.GET_OPEARATION_PARAMETER+": "+operationParameter);
final boolean instanceWithGrouping = readCookieWorkspaceGridViewSetting();
@ -735,7 +810,7 @@ public class AppController implements SubscriberInterface {
if(searchParameter!=null && !searchParameter.isEmpty())
isSearch = true;
if(idParameter!=null && !idParameter.isEmpty()){
if(itemIdParameter!=null && !itemIdParameter.isEmpty()){
isSearch = true;
isSearchForItemId = true;
}
@ -767,12 +842,12 @@ public class AppController implements SubscriberInterface {
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() {
@Override
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{
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) {
FileModel lastParent = wsPortlet.getToolBarPath().getLastParent(); //RELOAD BREADCRUMB
loadBreadcrumbById(lastParent, true);
loadBreadcrumbByFileModel(lastParent, true);
return wsPortlet.getGridGroupContainer().renameItem(itemIdentifier, newName, extension);
@ -1025,6 +1100,8 @@ public class AppController implements SubscriberInterface {
@Override
public void movedItems(String sourceParentIdentifier, FileModel targetParent) {
updateStoreByRpc(targetParent);
loadBreadcrumbByFileModel(targetParent, true); //ADDED 13-06-2013
}
@Override

View File

@ -18,6 +18,9 @@ public class ConstantsPortlet {
//USED IN HTTP GET AS PARAMETERS
public static final String GET_SEARCH_PARAMETER ="search";
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
public static final String WORKSPACEDIV = "workspaceDiv";

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.workspace.client.event;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet.WsPortletInitOperation;
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>();
private String itemId;
private WsPortletInitOperation operationParameter = null;
public SearchItemByIdEvent(String itemId) {
public SearchItemByIdEvent(String itemId, String op) {
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
@ -36,4 +55,12 @@ public class SearchItemByIdEvent extends GwtEvent<SearchItemByIdEventHandler> {
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 boolean groupingEnabled = false;
private NumberFormat number = ConstantsExplorer.numberFormatterKB;
private final Grid<FileGridModel> grid;
public GxtGridFilterGroupPanel(boolean group) {
setLayout(new FitLayout());
@ -86,7 +87,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
cp.setHeaderVisible(false);
cp.setLayout(new FitLayout());
final Grid<FileGridModel> grid = new Grid<FileGridModel>(store, columnModel);
grid = new Grid<FileGridModel>(store, columnModel);
grid.getView().setAutoFill(true);
grid.setBorders(true);
@ -432,6 +433,26 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
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(){
return store;
}