multi-selection is enabled to remove items from grid

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@90133 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-01-15 11:50:21 +00:00
parent 8792cf74e3
commit 8d41cf0d5b
9 changed files with 172 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/workspace-6.5.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/workspace-6.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -30,5 +30,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/workspace-6.5.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/workspace-6.6.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco-mangiacrapa/wseclipse/workspace/target/workspace-6.5.1-SNAPSHOT
lastWarOutDir=/home/francesco-mangiacrapa/wseclipse/workspace/target/workspace-6.6.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -56,6 +56,7 @@ import org.gcube.portlets.user.workspace.client.event.PathElementSelectedEvent;
import org.gcube.portlets.user.workspace.client.event.PathElementSelectedEventHandler;
import org.gcube.portlets.user.workspace.client.event.PreviewMessageEvent;
import org.gcube.portlets.user.workspace.client.event.PreviewMessageEventHandler;
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
import org.gcube.portlets.user.workspace.client.event.RenameItemEventHandler;
import org.gcube.portlets.user.workspace.client.event.SaveAttachmentsEvent;
@ -88,9 +89,13 @@ import org.gcube.portlets.user.workspace.client.view.trash.WindowTrash;
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.MessageBoxConfirm;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@ -410,14 +415,21 @@ public class AppController implements SubscriberInterface {
@Override
public void onGridElementSelected(GridElementSelectedEvent event) {
doElementGridSelected(true, event.getSourceFile());
FileGridModel fileItem = getGridSelectedItem();
if(!event.isMultiSelection()){ //IS NOT MULTISELECTION
doElementGridSelected(true, event.getSourceFile());
if(fileItem!=null){
accountingSetItemAsRead(fileItem.isMarkAsRead());
FileGridModel fileItem = getGridSelectedItem();
if(fileItem!=null){
accountingSetItemAsRead(fileItem.isMarkAsRead());
}
}else{ //IS MULTISELECTION
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemFunctionalities().activeButtonForMultiSelection(true);
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemDetails().enableButtons(false);
}
//setFileDetailsInView(event.getSourceFile().getIdentifier());
}
@ -802,7 +814,83 @@ public class AppController implements SubscriberInterface {
private void doDeleteItem(final DeleteItemEvent event){
AppControllerExplorer.getEventBus().fireEvent(new DeleteItemEvent(event.getFileTarget()));
if(!event.isMultiSelection()){ //IS NOT MULTI
AppControllerExplorer.getEventBus().fireEvent(new DeleteItemEvent(event.getFileTarget()));
}else{ //IS MULTI
if(event.getListTarget()!=null){
FileModel parent = null;
if(!wsPortlet.getSearchAndFilterContainer().isSearchActive()){ // IS NOT A SEARCH
if(wsPortlet.getToolBarPath().getLastParent()!=null){
parent = wsPortlet.getToolBarPath().getLastParent();
GWT.log("Search is not active get parent item for uploading from breadcrumb: " +parent.getName());
}else if(wsPortlet.getGridGroupContainer().getCurrentFolderView()!=null){
parent = wsPortlet.getGridGroupContainer().getCurrentFolderView();
GWT.log("Search is not active get parent item for uploading from CurrentFolderView: " +parent.getName());
}
}
final FileModel target = parent;
int size = event.getListTarget().size();
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsExplorer.MESSAGE_DELETE, "Are you sure you want to delete "+size+" items?");
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
// eventBus.fireEvent(new DeleteItemEvent(sel));
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){
wsPortlet.getGridGroupContainer().mask("Deleting",ConstantsExplorer.LOADINGSTYLE);
appContrExplorer.getRpcWorkspaceService().deleteListItemsForIds(event.getListTarget(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable arg0) {
wsPortlet.getGridGroupContainer().unmask();
appContrExplorer.refreshRoot(true);
}
@Override
public void onSuccess(Void arg0) {
//Deleting item from grid
for (String id : event.getListTarget()) {
deleteItem(id);
}
wsPortlet.getGridGroupContainer().unmask();
System.out.println("target: "+target);
if(wsPortlet.getSearchAndFilterContainer().isSearchActive()){
appContrExplorer.refreshRoot(false);
}else
AppControllerExplorer.getEventBus().fireEvent(new RefreshFolderEvent(target, true, false, true));
// AppController.getEventBus().fireEvent(new PathElementSelectedEvent(target));
}
});
}
}
});
}
}
}

View File

@ -14,14 +14,16 @@ public class GridElementSelectedEvent extends GwtEvent<GridElementSelectedEventH
public static Type<GridElementSelectedEventHandler> TYPE = new Type<GridElementSelectedEventHandler>();
private FileGridModel targetFile = null;
private boolean isMultiSelection;
public GridElementSelectedEvent(ModelData target) {
this.targetFile = (FileGridModel) target;
public GridElementSelectedEvent(ModelData target, boolean isMultiSelection) {
this.targetFile = (FileGridModel) target;
this.isMultiSelection = isMultiSelection;
}
@Override
public Type<GridElementSelectedEventHandler> getAssociatedType() {
// TODO Auto-generated method stub
return TYPE;
}
@ -34,4 +36,8 @@ public class GridElementSelectedEvent extends GwtEvent<GridElementSelectedEventH
public FileGridModel getSourceFile() {
return targetFile;
}
public boolean isMultiSelection() {
return isMultiSelection;
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.workspace.client.view.grids;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -17,6 +18,7 @@ import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.GroupingStoreModel;
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelData;
@ -188,7 +190,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
// grid.setSize(500, 500);
grid.addPlugin(filters);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().setSelectionMode(SelectionMode.MULTI);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<FileGridModel>() {
@ -200,12 +202,19 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
if(target!=null){
currenItemSelected = (FileGridModel) target;
AppController.getEventBus().fireEvent(new GridElementSelectedEvent(target));
boolean isMultiselection = false;
if(se.getSelection()!=null && se.getSelection().size()>1)
isMultiselection = true;
AppController.getEventBus().fireEvent(new GridElementSelectedEvent(target, isMultiselection));
}
else{
currenItemSelected = null;
AppController.getEventBus().fireEvent(new GridElementUnSelectedEvent());
}
}
});
@ -237,6 +246,11 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
{
if(grid.getSelectionModel().getSelectedItem()!=null){
if(grid.getSelectionModel().getSelection().size()>1){
new InfoDisplay("Info", "The context menu is not available if multi-select is active");
return;
}
FileGridModel fileGridModel = grid.getSelectionModel().getSelectedItem();
AppController.getEventBus().fireEvent(new OpenContextMenuTreeEvent(fileGridModel, be.getClientX(), be.getClientY()));
}
@ -359,6 +373,21 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
public List<String> getIdsSelectedItems(){
if(grid.getSelectionModel().getSelection()!=null){
List<String> ids = new ArrayList<String>();
for (FileModel file : grid.getSelectionModel().getSelection()) {
ids.add(file.getIdentifier());
}
return ids;
}
return null;
}
/**
*
* @param identifier (MANDATORY)

View File

@ -89,10 +89,15 @@ public class GxtGridFilterPanel extends LayoutContainer {
System.out.println("selection grid change");
ModelData target = se.getSelectedItem();
if(target!=null){
currenItemSelected = (FileGridModel) target;
AppController.getEventBus().fireEvent(new GridElementSelectedEvent(target));
boolean isMultiselection = false;
if(se.getSelection()!=null && se.getSelection().size()>1)
isMultiselection = true;
AppController.getEventBus().fireEvent(new GridElementSelectedEvent(target, isMultiselection));
}
else{
currenItemSelected = null;

View File

@ -89,7 +89,7 @@ public class GxtCardLayoutResultPanel extends LayoutContainer{
public GxtToolBarItemFunctionality getToolBarItemFunctionalities() {
return toolBarItemFunct;
}
public ContentPanel getActivePanel(){
return activePanel;
}

View File

@ -111,8 +111,8 @@ public class GxtBottomToolBarItem extends ToolBar{
}
});
add(new FillToolItem());
add(btnGetTrash);
// add(new FillToolItem());
// add(btnGetTrash);
enableButtons(false);

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.workspace.client.view.toolbars;
import java.util.List;
import org.gcube.portlets.user.workspace.client.AppController;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeInResult;
@ -271,10 +273,21 @@ public class GxtToolBarItemFunctionality {
@Override
public void componentSelected(ButtonEvent ce) {
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
AppController.getEventBus().fireEvent(
new DeleteItemEvent(fileGridModel));
List<String> listTarget = gridGroupViewContainer.getIdsSelectedItems();
if(listTarget!=null){
if(listTarget.size()>1){ //IS MULTI
AppController.getEventBus().fireEvent(new DeleteItemEvent(listTarget));
}else{
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
AppController.getEventBus().fireEvent(new DeleteItemEvent(fileGridModel));
}
}
}
});
@ -631,6 +644,15 @@ public class GxtToolBarItemFunctionality {
btnOpen.setEnabled(active);
btnPublicLink.setEnabled(active);
}
public void activeButtonForMultiSelection(boolean active){
this.btnRemoveItem.setEnabled(active);
this.btnRenameItem.setEnabled(!active);
this.btnDownloadFile.setEnabled(!active);
this.btnOpen.setEnabled(!active);
this.btnCopyItem.setEnabled(!active);
this.btnGetSharedLink.setEnabled(!active);
}
public ToolBar getToolBar() {
return this.toolBar;