enhancements on ACLs

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@91804 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-02-17 18:20:45 +00:00
parent f9e31d67b4
commit 543a3eb0d1
10 changed files with 656 additions and 38 deletions

View File

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

View File

@ -5,7 +5,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="workspace-tree-widget-6.6.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-tree-widget/workspace-tree-widget">
<dependent-module archiveName="workspace-tree-widget-6.6.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/WorkspaceTree/WorkspaceTree">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>

View File

@ -74,7 +74,6 @@ import org.gcube.portlets.user.workspace.client.event.SendMessageEventHandler;
import org.gcube.portlets.user.workspace.client.event.SettingPermissionEvent;
import org.gcube.portlets.user.workspace.client.event.SettingPermissionEventHandler;
import org.gcube.portlets.user.workspace.client.event.TrashEvent;
import org.gcube.portlets.user.workspace.client.event.TrashEvent.TRASHOPERATION;
import org.gcube.portlets.user.workspace.client.event.TrashEventHandler;
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEventHandler;
@ -88,12 +87,16 @@ import org.gcube.portlets.user.workspace.client.view.WorskpacePortlet;
import org.gcube.portlets.user.workspace.client.view.dialog.DialogPermission;
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.toolbars.GxtBreadcrumbPathPanel;
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.user.workspace.shared.TrashOperationResult;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
import com.extjs.gxt.ui.client.event.Listener;
@ -175,19 +178,28 @@ public class AppController implements SubscriberInterface {
switch (trashEvent.getTrashOperation()) {
case SHOW:
WindowTrash.getInstance().show();
break;
case MOVETO:
break;
case RESTOREFROM:
break;
default:
if(trashEvent.getTrashOperation()!=null){
WindowTrash.getInstance().mask("Submitting Operation");
AppControllerExplorer.rpcWorkspaceService.executeOperationOnTrash(trashEvent.getTargetFileModel().getIdentifier(), trashEvent.getTrashOperation(), new AsyncCallback<TrashOperationResult>() {
@Override
public void onFailure(Throwable arg0) {
WindowTrash.getInstance().unmask();
}
@Override
public void onSuccess(TrashOperationResult operationResult) {
WindowTrash.getInstance().unmask();
WindowTrash.getInstance().updateTrashContainer(operationResult.getTrashContent());
}
});
}
break;
}
@ -887,12 +899,7 @@ public class AppController implements SubscriberInterface {
});
}
}
});
});
}
}
@ -1015,7 +1022,7 @@ public class AppController implements SubscriberInterface {
result.add(item);
}
setPathInView(result); //Set file path in tab panel on current item selected
updateBreadcrumb(result); //Set file path in tab panel on current item selected
}
@ -1042,18 +1049,45 @@ public class AppController implements SubscriberInterface {
@Override
public void onSuccess(List<FileModel> result) {
setPathInView(result); //Set file path in tab panel on current item selected
updateBreadcrumb(result); //Set file path in tab panel on current item selected
}
});
}
private void setPathInView(List<FileModel> parents){
private void updateBreadcrumb(List<FileModel> parents){
//this.wsPortlet.getBasicTabContainer().setLabelPath(path); //Set path in tab view panel
//this.wsPortlet.getBasicTabContainer().setLabelPath(path); //Set path in breadcrumb
this.wsPortlet.getToolBarPath().setPath(parents); //Set path in tab view panel
GxtBreadcrumbPathPanel breadCrumb = this.wsPortlet.getToolBarPath();
breadCrumb.setPath(parents); //Set path in breadcrumb
FileModel parent = breadCrumb.getLastParent();
if(parent!=null && parent.isDirectory() && parent.isShared())
setACLInfo(parent.getIdentifier());
}
private void setACLInfo(String parentId){
AppControllerExplorer.rpcWorkspaceService.getACLForFolderId(parentId, new AsyncCallback<List<WorkspaceACL>>() {
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(List<WorkspaceACL> res) {
if(res!=null && res.size()>0)
wsPortlet.getToolBarItemDetails().updateACLInfo(res.get(0));
}
});
}
/**
@ -1302,7 +1336,7 @@ public class AppController implements SubscriberInterface {
if(item.isDirectory()) //ADDED 11-06-2013
parents.add(item);
setPathInView(parents); //set path
updateBreadcrumb(parents); //set path
//CASE IS A SEARCH
if(wsPortlet.getSearchAndFilterContainer().isSearchActive()){ //ADDED 12-04-12
@ -1377,7 +1411,7 @@ public class AppController implements SubscriberInterface {
@Override
public void setParentItemSelected(ArrayList<FileModel> listParents){
setPathInView(listParents);
updateBreadcrumb(listParents);
}
@Override
@ -1605,8 +1639,7 @@ public class AppController implements SubscriberInterface {
* @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#trashEvent(org.gcube.portlets.user.workspace.client.event.TrashEvent.TRASHOPERATION, org.gcube.portlets.user.workspace.client.model.FileModel)
*/
@Override
public void trashEvent(TRASHOPERATION trashOperation, FileModel targetFileModel) {
public void trashEvent(WorkspaceTrashOperation trashOperation, FileModel targetFileModel) {
}

View File

@ -6,7 +6,7 @@ import org.gcube.portlets.user.workspace.client.view.panels.GxtBorderLayoutPanel
import org.gcube.portlets.user.workspace.client.view.panels.GxtCardLayoutResultPanel;
import org.gcube.portlets.user.workspace.client.view.panels.GxtSeachAndFilterPanel;
import org.gcube.portlets.user.workspace.client.view.toolbars.GxtBottomToolBarItem;
import org.gcube.portlets.user.workspace.client.view.toolbars.GxtPathPanel;
import org.gcube.portlets.user.workspace.client.view.toolbars.GxtBreadcrumbPathPanel;
/**
@ -21,7 +21,7 @@ public class WorskpacePortlet {
private ExplorerPanel explorerPanel = null;
private GxtBottomToolBarItem toolBarItemDetails;
private GxtListView listViewContainer;
private GxtPathPanel toolBarPathPanel;
private GxtBreadcrumbPathPanel toolBarPathPanel;
private GxtGridFilterGroupPanel gridFilterGroupContainer;
private GxtSeachAndFilterPanel searchAndFilterContainer;
private GxtCardLayoutResultPanel gxtCardLayoutResultPanel;
@ -30,7 +30,7 @@ public class WorskpacePortlet {
// Log.trace("Initializing WorskpacePortlet");
this.basicTabContainer = new GxtBasicTabPanel();
this.toolBarPathPanel = new GxtPathPanel();
this.toolBarPathPanel = new GxtBreadcrumbPathPanel();
this.searchAndFilterContainer = new GxtSeachAndFilterPanel(this.toolBarPathPanel.getToolBarPathPanel());
this.gridFilterGroupContainer = new GxtGridFilterGroupPanel(activeGroup);
@ -67,7 +67,7 @@ public class WorskpacePortlet {
}
public GxtPathPanel getToolBarPath() {
public GxtBreadcrumbPathPanel getToolBarPath() {
return toolBarPathPanel;
}

View File

@ -90,6 +90,7 @@ public class DialogPermission extends Dialog {
getOwner(folder.getIdentifier(), callcack);
//TODO GET ACL FOR USER
AppControllerExplorer.rpcWorkspaceService.getACLs(new AsyncCallback<List<WorkspaceACL>>() {
@Override

View File

@ -0,0 +1,59 @@
package org.gcube.portlets.user.workspace.client.view.toolbars;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.HTML;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Feb 17, 2014
*
*/
public class ACLDivInfo extends LayoutContainer {
private HorizontalPanel hpPanel = new HorizontalPanel();
private HTML text = new HTML();
public ACLDivInfo(String caption, AbstractImagePrototype img) {
super();
super.setWidth(80);
text.setPixelSize(50, 30);
hpPanel.setWidth("100%");
updateInfo(caption,img);
}
public void updateInfo(String caption, AbstractImagePrototype img){
String html = "<div style=\"width: 100%; height: 28px; text-align:left;\">";
if(img!=null)
html+=addImage(img);
if(caption!=null)
html+=addCaption(caption);
html+="</div>";
text.setHTML(html);
hpPanel.layout();
}
private String addImage(AbstractImagePrototype img){
return "<span style=\"display:inline-block; vertical-align:middle;\" >" + img.getHTML() + "</span>";
}
private String addCaption(String caption){
return "<span style=\"padding-left: 5px; vertical-align:middle;\">"+ caption+"</span>";
}
}

View File

@ -5,16 +5,21 @@ import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
import org.gcube.portlets.user.workspace.client.event.TrashEvent;
import org.gcube.portlets.user.workspace.client.event.TrashEvent.TRASHOPERATION;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.util.GetPermissionIconByACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -43,6 +48,7 @@ public class GxtBottomToolBarItem extends ToolBar{
private Button bHistory;
private Button bRead;
private Button btnGetTrash;
private ACLDivInfo aclDivInfo;
public GxtBottomToolBarItem(){
super();
@ -98,6 +104,11 @@ public class GxtBottomToolBarItem extends ToolBar{
// add(bRead);
add(new FillToolItem());
aclDivInfo = new ACLDivInfo("", null);
add(aclDivInfo);
btnGetTrash = new Button("Trash");
btnGetTrash.setIcon(Resources.getTrash());
btnGetTrash.addSelectionListener(new SelectionListener<ButtonEvent>() {
@ -105,17 +116,19 @@ public class GxtBottomToolBarItem extends ToolBar{
@Override
public void componentSelected(ButtonEvent ce) {
AppController.getEventBus().fireEvent(new TrashEvent(TRASHOPERATION.SHOW, null));
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.SHOW, null));
}
});
// add(new FillToolItem());
// add(btnGetTrash);
enableButtons(false);
}
public void resetDetails(){
@ -154,4 +167,11 @@ public class GxtBottomToolBarItem extends ToolBar{
bRead.setEnabled(markAsRead);
}
public void updateACLInfo(WorkspaceACL acl){
AbstractImagePrototype img = GetPermissionIconByACL.getImage(acl);
aclDivInfo.updateInfo(acl.getLabel(), img);
}
}

View File

@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Image;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class GxtPathPanel {
public class GxtBreadcrumbPathPanel {
private static final String ROOT_NAME = "Workspace";
@ -34,7 +34,7 @@ public class GxtPathPanel {
private FileModel lastParent;
public GxtPathPanel() {
public GxtBreadcrumbPathPanel() {
toolBar = new HorizontalPanel();
toolBar.setHeight("25px");
initToolbar();

View File

@ -0,0 +1,386 @@
package org.gcube.portlets.user.workspace.client.view.trash;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
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.FileTrashedModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.DNDEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.GroupingStore;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Record;
import com.extjs.gxt.ui.client.store.TreeStoreModel;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters;
import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.i18n.client.NumberFormat;
public class TrashInfoContainer extends LayoutContainer {
/**
*
*/
private Grid<FileTrashedModel> grid;
private ContentPanel cp;
private GroupingStore<FileTrashedModel> store = new GroupingStore<FileTrashedModel>();
private boolean groupingEnabled;
private ListStore<FileTrashedModel> typeStoreOperation = new ListStore<FileTrashedModel>();
private NumberFormat number = ConstantsExplorer.numberFormatterKB;
private GridDropTarget gridDropTarget;
public TrashInfoContainer() {
initContentPanel();
initGrid();
createToolBar();
initDropTarget();
}
/**
*
*/
private void initDropTarget() {
this.gridDropTarget = new GridDropTarget(grid){
/* (non-Javadoc)
* @see com.extjs.gxt.ui.client.dnd.GridDropTarget#onDragDrop(com.extjs.gxt.ui.client.event.DNDEvent)
*/
@Override
protected void onDragDrop(DNDEvent e) {
// TODO Auto-generated method stub
List<FileModel> listFileModel = getDragSource(e);
List<String> ids = new ArrayList<String>();
for (FileModel fileModel : listFileModel) {
fileModel.setIcon();
ids.add(fileModel.getIdentifier());
}
System.out.println("** Trash Event move handleInsertDrop is completed");
super.onDragDrop(e);
}
private List<FileModel> getDragSource(DNDEvent event){
List<FileModel> listDraggedFile = new ArrayList<FileModel>();
if(event.getData() != null){
List<BaseModelData> listItemsSource = event.getData();
System.out.println("Trash - Number of move " + listItemsSource.size());
// FileModel sourceFileModel = null; //for print
for(int i=0; i<listItemsSource.size(); i++){
if(listItemsSource.get(i) instanceof TreeStoreModel){ //DRAG FROM TREE
// System.out.println("qui 1");
//
// TreeStoreModel itemSource = (TreeStoreModel) listItemsSource.get(i);
//
// listDraggedFile.add((FileModel) itemSource.getModel());
// sourceFileModel = (FileModel) itemSource.getModel();
//
// if(sourceFileModel.getParentFileModel()!=null)
//
// System.out.println("Trash Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag " + " Parent Name: " + sourceFileModel.getParentFileModel().getName() + "id " + sourceFileModel.getParentFileModel().getIdentifier());
// else
// System.out.println("Trash Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag ");
}else if(listItemsSource.get(i) instanceof FileGridModel){ //DRAG FROM GRID
listDraggedFile.add((FileModel) listItemsSource.get(i));
// FileGridModel fileGrid = listItemsSource.get(i);
// System.out.println("qui 2");
// System.out.println("class "+listItemsSource.get(i).getClass());
}
// System.out.println("Trash Child count: " + itemSource.getChildCount());
}
}
return listDraggedFile;
}
};
}
private void initContentPanel() {
setLayout(new FitLayout());
getAriaSupport().setPresentation(true);
cp = new ContentPanel();
cp.setHeaderVisible(false);
cp.setBodyBorder(true);
cp.setLayout(new FitLayout());
cp.setButtonAlign(HorizontalAlignment.CENTER);
add(cp);
}
private void createToolBar() {
ToolBar bar = new ToolBar();
final ToggleButton buttonGrouping = new ToggleButton("",Resources.getIconGridView());
buttonGrouping.setToolTip("Grouping by Type");
buttonGrouping.setScale(ButtonScale.SMALL);
buttonGrouping.toggle(true);
buttonGrouping.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if (buttonGrouping.isPressed())
enableGrouping();
else
disableGrouping();
}
});
// bar.add(buttonGrouping);
cp.setTopComponent(bar);
}
public void initGrid() {
// store.groupBy(ConstantsExplorer.SHORTCUTCATEGORY);
// groupingEnabled = true;
ColumnConfig icon = new ColumnConfig(ConstantsExplorer.ICON, "", 25);
ColumnConfig name = createSortableColumnConfig(ConstantsExplorer.NAME, ConstantsExplorer.NAME, 200);
ColumnConfig type = createSortableColumnConfig(ConstantsExplorer.TYPE, ConstantsExplorer.TYPE, 50);
ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(), "Original Path", 200);
ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(), "Delete Date", 50);
ColumnConfig deleteUser = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEUSER.toString(), "Delete User", 150);
// ColumnConfig category = createSortableColumnConfig(ConstantsExplorer.SHORTCUTCATEGORY, ConstantsExplorer.SHORTCUTCATEGORY, 100);
// ColumnConfig ownerFullName = createSortableColumnConfig(ConstantsExplorer.OWNERFULLNAME, ConstantsExplorer.OWNER, 100);
// ColumnConfig ownerFullName = createSortableColumnConfig(ConstantsExplorer.OWNERFULLNAME, ConstantsExplorer.OWNER, 100);
ColumnModel cm = new ColumnModel(Arrays.asList(icon, name, type, originalPath, deleteDate, deleteUser));
final ColumnModel columnModel = cm;
grid = new Grid<FileTrashedModel>(this.store, cm);
GroupingView view = new GroupingView();
view.setShowGroupedColumn(true);
this.grid.setView(view);
// view.setGroupRenderer(new GridGroupRenderer() {
// public String render(GroupColumnData data) {
// String f = columnModel.getColumnById(data.field).getHeader();
// String l = data.models.size() == 1 ? "Item" : "Items";
// return f + ": " + data.group + " (" + data.models.size() + " "
// + l + ")";
// }
// });
GridCellRenderer<FileModel> folderRender = new GridCellRenderer<FileModel>() {
@Override
public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<FileModel> store, Grid<FileModel> grid) {
String val = model.get(property);
String color = "black";
if(val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())){
// color = "#EEC900";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' style='font-weight: bold;color:" + color + "'>" + val + "</span>";
}else{
if(val==null)
val = "";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>";
}
}
};
type.setRenderer(folderRender);
GridFilters filters = new GridFilters();
filters.setLocal(true);
StringFilter nameFilter = new StringFilter(ConstantsExplorer.NAME);
StringFilter authorFilter = new StringFilter(ConstantsExplorer.TYPE);
filters.addFilter(nameFilter);
filters.addFilter(authorFilter);
grid.addPlugin(filters);
grid.setBorders(true);
grid.setStripeRows(true);
grid.getView().setAutoFill(true);
grid.setColumnLines(true);
grid.setColumnReordering(true);
grid.setStyleAttribute("borderTop", "none");
cp.add(grid);
}
public void setPanelSize(int width, int height) {
if (width > 0 && height > 0 && grid != null) {
cp.setSize(width, height);
// grid.setSize(width, height);
}
}
public TrashInfoContainer(List<FileTrashedModel> trashFiles) {
initContentPanel();
initGrid();
updateTrash(trashFiles);
}
public void disableGrouping() {
GroupingStore<FileTrashedModel> groupingStore = null;
if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<FileTrashedModel>) store;
if (groupingStore != null) {
groupingStore.clearGrouping();
}
this.groupingEnabled = false;
}
}
public void enableGrouping() {
GroupingStore<FileTrashedModel> groupingStore = null;
if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<FileTrashedModel>) store;
if (groupingStore != null) {
groupingStore.groupBy(ConstantsExplorer.SHORTCUTCATEGORY);
}
this.groupingEnabled = true;
}
}
public void updateTrash(List<FileTrashedModel> trashFiles) {
store.removeAll();
typeStoreOperation.removeAll();
store.add(trashFiles);
}
private void updateStore(ListStore<FileTrashedModel> store) {
resetStore();
this.grid.getStore().add(store.getModels());
}
public void resetStore() {
this.grid.getStore().removeAll();
}
public ColumnConfig createSortableColumnConfig(String id, String name,
int width) {
ColumnConfig columnConfig = new ColumnConfig(id, name, width);
columnConfig.setSortable(true);
return columnConfig;
}
public void setHeaderTitle(String title) {
cp.setHeading(title);
// cp.layout();
}
public boolean isGroupingEnabled() {
return groupingEnabled;
}
public void setGroupingEnabled(boolean groupingEnabled) {
this.groupingEnabled = groupingEnabled;
}
/**
*
* @param identifier
* @return
*/
public FileTrashedModel getFileModelByIdentifier(String identifier){
return store.findModel(ConstantsExplorer.IDENTIFIER, identifier);
}
/**
*
* @param identifier (MANDATORY)
* @return
*/
public boolean deleteItem(String identifier) {
FileTrashedModel fileTarget = getFileModelByIdentifier(identifier);
if(fileTarget!=null){
return deleteItem(fileTarget);
}
else
System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" );
return false;
}
/**
*
* @param fileTarget (MANDATORY)
* @return
*/
private boolean deleteItem(FileTrashedModel fileTarget) {
Record record = store.getRecord(fileTarget);
if (record != null) {
FileTrashedModel item = (FileTrashedModel) record.getModel();
store.remove(item);
return true;
} else
System.out.println("Record Error: file target with "
+ fileTarget.getIdentifier()
+ " identifier not exist in store");
return false;
}
}

View File

@ -0,0 +1,119 @@
package org.gcube.portlets.user.workspace.client.view.trash;
import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @May 23, 2013
*
* Singleton
*/
public class WindowTrash extends Window {
private List<FileTrashedModel> trashedFiles;
private TrashInfoContainer trashContainers;
private static WindowTrash INSTANCE = null;
private WindowTrash() {
initAccounting();
setIcon(Resources.getTrash()); //TODO
setHeading("Trash");
// addResizeListner();
}
/**
*
* @return
*/
public static synchronized WindowTrash getInstance(){
if(INSTANCE==null)
INSTANCE = new WindowTrash();
return INSTANCE;
}
// public void addResizeListner(){
//
// this.addListener(Events.Resize, new Listener<WindowEvent>() {
//
// @Override
// public void handleEvent(WindowEvent we )
// {
//
// if(trashContainers!=null){
//// System.out.println("Size in event: " + we.getWidth() + "x" + we.getHeight() );
//// accountingsContainers.setPanelSize(we.getWidth()-14, we.getHeight()-30);
// }
// }
//
// });
// }
// public WindowTrash(List<FileModel> trashFiles) {
// updateTrashContainer(trashFiles);
// }
private void initAccounting() {
// setModal(true);
setLayout(new FitLayout());
setSize(700, 350);
setResizable(true);
setMaximizable(true);
// setCollapsible(true);
this.trashContainers = new TrashInfoContainer();
add(trashContainers);
}
public void setWindowTitle(String title) {
this.setHeading(title);
}
/**
*
* @param fileModelId
* @return
*/
public boolean deleteFileFromTrash(String fileModelId){
return this.trashContainers.deleteItem(fileModelId);
}
public void updateTrashContainer(List<FileTrashedModel> trashFiles) {
this.trashContainers.resetStore();
this.trashedFiles = trashFiles;
this.trashContainers.updateTrash(trashFiles);
}
public List<FileTrashedModel> getTrashedFiles() {
return trashedFiles;
}
public void maskAccountingInfo(boolean bool){
// if(accountingsContainers!=null){
//
// if(bool)
// accountingsContainers.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
// else
// accountingsContainers.unmask();
// }
if(bool)
this.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
else
this.unmask();
}
}