updating on copy/paste

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@81289 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-09-12 10:07:23 +00:00
parent 443a59fe37
commit 91fc563f4c
5 changed files with 199 additions and 24 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/workspace-6.4.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/workspace-6.3.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.4.1-SNAPSHOT/WEB-INF/classes"/>
</classpath>
<classpathentry kind="output" path="target/workspace-6.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -50,10 +50,13 @@ import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
import org.gcube.portlets.user.workspace.client.event.OpenReportsEventHandler;
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
import org.gcube.portlets.user.workspace.client.event.PasteItemEventHandler;
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;
@ -112,7 +115,6 @@ public class AppController implements SubscriberInterface {
private HasWidgets rootPanel;
public AppController(AppControllerExplorer appControllerExplorer) {
this.appContrExplorer = appControllerExplorer;
this.appContrExplorer.subscribe(this, new EventsTypeEnum[] {
@ -135,7 +137,8 @@ public class AppController implements SubscriberInterface {
EventsTypeEnum.CREATE_NEW_MESSAGE,
EventsTypeEnum.REPLY_FORWARD_MESSAGE,
EventsTypeEnum.FILE_DOWNLAD_EVENT,
EventsTypeEnum.SESSION_EXPIRED
EventsTypeEnum.SESSION_EXPIRED,
EventsTypeEnum.PASTED_EVENT
});
bind();
}
@ -164,6 +167,16 @@ public class AppController implements SubscriberInterface {
}
}
});
//PASTE EVENT
eventBus.addHandler(PasteItemEvent.TYPE, new PasteItemEventHandler() {
@Override
public void onCopyAndPaste(PasteItemEvent pasteItemEvent) {
AppControllerExplorer.getEventBus().fireEvent(new PasteItemEvent(pasteItemEvent.getItemId(), pasteItemEvent.getFolderDestinationId()));
}
});
//********EVENTS TO NOTIFY SUBSCRIBERS
eventBus.addHandler(OpenReportsEvent.TYPE, new OpenReportsEventHandler() {
@ -373,7 +386,8 @@ public class AppController implements SubscriberInterface {
// System.out.println("#############Scopde id " + scope.getId() + " name " + scope.getName());
if(result!=null && result.size()>0){
wsPortlet.getSearchAndFilterContainer().setListScope(result);
wsPortlet.getSearchAndFilterContainer().selectScopeByIndex(0); //select first scope
}
else
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting all scope. No scope available. " +ConstantsExplorer.TRY_AGAIN, null);
@ -553,7 +567,10 @@ public class AppController implements SubscriberInterface {
if(result!=null && result.size()>0){
String childId = result.get(0).getIdentifier(); //GET FIRST CHILD ID TO LOAD PARENTS BREADCRUMB
loadParentBreadcrumbByItemId(childId);
loadParentBreadcrumbByItemId(childId, false);
}else{ //FOLDER IS EMPTY AND EXISTS, FOLDER IS LAST PARENT INTO BREADCRUMB
loadParentBreadcrumbByItemId(itemId, true); //RELOAD BREDCRUMB
}
@ -781,13 +798,13 @@ 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
* @param isLastParent - if is true, load the item passed in input as last item of the list resulted
*/
private void loadBreadcrumbByFileModel(final FileModel item, final boolean isLastParent){
GWT.log("Reload Breadcrumb: [FileModel name: "+item.getName()+ ", isLastParent: "+isLastParent+"]");
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(item.getIdentifier(), new AsyncCallback<List<FileModel>>() {
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(item.getIdentifier(), false, new AsyncCallback<List<FileModel>>() {
@Override
public void onFailure(Throwable caught) {
@ -812,13 +829,13 @@ public class AppController implements SubscriberInterface {
/**
*
* @param itemId
* @param childItemId
*/
protected void loadParentBreadcrumbByItemId(final String itemId){
protected void loadParentBreadcrumbByItemId(final String childItemId, boolean includeItemAsParent){
GWT.log("Reload Parent Breadcrumb: [Item id: "+itemId+"]");
GWT.log("Reload Parent Breadcrumb: [Item id: "+childItemId+"]");
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemId, new AsyncCallback<List<FileModel>>() {
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(childItemId, includeItemAsParent, new AsyncCallback<List<FileModel>>() {
@Override
public void onFailure(Throwable caught) {
@ -1239,7 +1256,12 @@ public class AppController implements SubscriberInterface {
@Override
public void refreshFolder(FileModel folderTarget) {
updateStoreByRpc(folderTarget);
//REFRESH FOLDER ONLY IF IS DISPLAYED YOUR CHILDREN
FileGridModel file = wsPortlet.getGridGroupContainer().getFileGridModelByIdentifier(folderTarget.getIdentifier());
if(file==null)
updateStoreByRpc(folderTarget);
}
@ -1315,4 +1337,14 @@ public class AppController implements SubscriberInterface {
return errorPanel;
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#pasteEventIsCompleted()
*/
@Override
public void pasteEventIsCompleted() {
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemFunctionalities().activePasteButton(false);
}
}

View File

@ -454,6 +454,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return false;
}
public GroupingStore<FileGridModel> getStore(){
return store;
}

View File

@ -1,17 +1,28 @@
package org.gcube.portlets.user.workspace.client.view.panels;
import java.util.List;
import org.gcube.portlets.user.workspace.client.AppController;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsPortlet;
import org.gcube.portlets.user.workspace.client.event.SaveSmartFolderEvent;
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEvent;
import org.gcube.portlets.user.workspace.client.event.SearchTextEvent;
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
import org.gcube.portlets.user.workspace.client.view.GxtComboBox;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.dom.client.Style.Unit;
@ -31,6 +42,8 @@ import com.google.gwt.user.client.ui.RootPanel;
*/
public class GxtSeachAndFilterPanel extends LayoutContainer {
private GxtComboBox comboBoxGxt = null;
private ComboBox<ScopeModel> cbViewScope = null;
// private HTML txtViewScope = new HTML("<nobr>"+ConstantsPortlet.VIEWSPACE+":</nobr>");
private final TextField<String> textSearch = new TextField<String>();
private Button bSearch = new Button(ConstantsPortlet.SEARCH);
@ -39,11 +52,13 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
private TextField<String> textFull = new TextField<String>();
private DateField fromDate = new DateField();
private DateField toDate = new DateField();
private SimpleComboBox<String> cbNameFilter = null;
private HorizontalPanel toolbarPathPanel = null;
private boolean isSearchActive = false;
private VerticalPanel cp = new VerticalPanel();
HorizontalPanel hp = new HorizontalPanel();
HorizontalPanel hp2 = new HorizontalPanel();
HorizontalPanel hpMain = new HorizontalPanel();
@ -56,6 +71,11 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
setBorders(true);
setId("SearchAndFilter");
this.comboBoxGxt = new GxtComboBox();
this.cbViewScope = this.comboBoxGxt.getComboViewScope();
this.cbNameFilter = this.comboBoxGxt.getComboStringFilter();
this.cbViewScope.setWidth(360);
// this.cbViewScope.setAutoWidth(true);
this.toolbarPathPanel = toolbarContainer;
@ -71,7 +91,6 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
textSearch.setAllowBlank(true);
textSearch.setEmptyText(ConstantsPortlet.SEARCHINWORSPACE);
textSearch.setWidth(325);
textSearch.setHeight(22);
textSearch.setRegex("^[a-zA-Z0-9]+[ a-zA-Z0-9_().-]*"); //alphanumeric
textSearch.getMessages().setRegexText(ConstantsExplorer.MESSAGE_SEARCH_FORCE_APHANUMERIC);
@ -92,11 +111,21 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
bSearch.setWidth("70px");
bSave.setWidth("70px");
hpMain.setWidth("100%");
hp.setWidth("100%");
hp2.setHorizontalAlign(HorizontalAlignment.RIGHT);
hp2.setVerticalAlign(VerticalAlignment.MIDDLE);
//hp2.add(txtViewScope);
hp2.add(cbViewScope);
cbViewScope.setStyleAttribute("margin-left", "132px");
cbViewScope.setStyleAttribute("margin-top", "2px");
hpMain.add(hp);
//SOLUTION FOR SCOPE INVISIBLE
cbViewScope.setVisible(false);
hpMain.add(hp2);
cp.add(hpMain);
this.addListeners();
@ -123,9 +152,8 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
int rootWidth = Window.getClientWidth() - 2* leftBorder; //- rightScrollBar;
//SOLUTION FOR SCOPE INVISIBLE
hp.setWidth(rootWidth);
hpMain.setWidth(rootWidth-10);
hp.setWidth("100%");
// ORIGINAL CODE
// hp.setWidth(rootWidth - 500);
}
@ -160,6 +188,16 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
};
textSearch.addKeyListener(keyListener);
//
// bCancel.addClickHandler(new ClickHandler() {
// @Override
// public void onClick(ClickEvent event) {
// if(textSearch.getValue()!=null && !textSearch.getValue().isEmpty() && textSearch.isValid()){
// searchCancel();
// AppController.getEventBus().fireEvent(new SearchTextEvent(null));
// }
// }
// });
bSave.addClickHandler(new ClickHandler() {
@Override
@ -172,7 +210,18 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
}
});
this.cbViewScope.addSelectionChangedListener(new SelectionChangedListener<ScopeModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<ScopeModel> se) {
ScopeModel scope = se.getSelectedItem();
AppController.getEventBus().fireEvent(new ScopeChangeEvent(scope.getId()));
}
});
}
public void resetFields(){
@ -180,6 +229,8 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
this.textFull.reset();
this.fromDate.reset();
this.toDate.reset();
this.cbNameFilter.reset();
}
public void seVisibleButtonsCancelSave(boolean flag){
@ -198,6 +249,16 @@ public class GxtSeachAndFilterPanel extends LayoutContainer {
return this.isSearchActive;
}
public void setListScope(List<ScopeModel> listScope){
this.comboBoxGxt.setListScope(listScope);
}
public void selectScopeByIndex(int index){
this.cbViewScope.setValue(cbViewScope.getStore().getAt(index));
}
public void setSearchActive(boolean isSearchActive) {
// System.out.println("#################SET SEARCH ACTIVE in GRID " + isSearchActive);
this.isSearchActive = isSearchActive;

View File

@ -16,6 +16,7 @@ import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
import org.gcube.portlets.user.workspace.client.event.GridRefreshEvent;
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
@ -23,6 +24,7 @@ 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.resources.Resources;
import org.gcube.portlets.user.workspace.client.view.grids.GxtGridFilterGroupPanel;
import org.gcube.portlets.user.workspace.client.view.tree.CopyAndPaste;
import com.extjs.gxt.ui.client.Style.ButtonArrowAlign;
import com.extjs.gxt.ui.client.Style.ButtonScale;
@ -60,6 +62,8 @@ public class GxtToolBarItemFunctionality {
// private Button btnGetInfo;
private Button btnGetSharedLink;
private Button btnPublicLink;
private Button btnCopyItem;
private Button btnPasteItem;
public GxtToolBarItemFunctionality() {
initToolBar();
@ -123,13 +127,36 @@ public class GxtToolBarItemFunctionality {
// toolBar.add(new SeparatorToolItem());
// toolBar.add(new SeparatorToolItem());
btnRenameItem = new Button(ConstantsPortlet.RENAMEITEM,
Resources.getIconRenameItem());
btnRenameItem = new Button(ConstantsPortlet.RENAMEITEM, Resources.getIconRenameItem());
btnRenameItem.setScale(ButtonScale.SMALL);
btnRenameItem.setIconAlign(IconAlign.TOP);
btnRenameItem.setArrowAlign(ButtonArrowAlign.BOTTOM);
toolBar.add(btnRenameItem);
//COPY
btnCopyItem = new Button("Copy", Resources.getIconRenameItem());
btnCopyItem.setScale(ButtonScale.SMALL);
btnCopyItem.setIconAlign(IconAlign.TOP);
btnCopyItem.setIcon(Resources.getIconCopy());
toolBar.add(btnCopyItem);
//PASTE
btnPasteItem = new Button("Paste", Resources.getIconRenameItem());
btnPasteItem.setScale(ButtonScale.SMALL);
btnPasteItem.setIconAlign(IconAlign.TOP);
btnPasteItem.setIcon(Resources.getIconPaste());
btnPasteItem.setEnabled(false); //BY DEFAULT IS DISABLED
toolBar.add(btnPasteItem);
btnDownloadFile = new Button(ConstantsPortlet.DOWNLOADITEM,Resources.getIconDownload());
btnDownloadFile.setScale(ButtonScale.SMALL);
btnDownloadFile.setIconAlign(IconAlign.TOP);
@ -264,6 +291,37 @@ public class GxtToolBarItemFunctionality {
});
btnCopyItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
if(fileGridModel.getIdentifier()!=null){
CopyAndPaste.copy(fileGridModel.getIdentifier());
btnPasteItem.setEnabled(true);
}
}
});
btnPasteItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
FileModel parentTarget = getDirectoryOrParent(fileGridModel);
if(parentTarget!=null){
AppController.getEventBus().fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
CopyAndPaste.setCopiedfileModelId(null);
btnPasteItem.setEnabled(false);
}
}
});
btnRefreshFolder.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
@ -298,7 +356,7 @@ public class GxtToolBarItemFunctionality {
//
// }
// });
btnRenameItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
@ -446,6 +504,23 @@ public class GxtToolBarItemFunctionality {
// }
}
/**
* The method return input file model if is directory otherwise parent of file model
* @param fileModel
* @return
*/
private FileModel getDirectoryOrParent(FileModel fileModel){
if(fileModel!=null){
if(fileModel.isDirectory())
return fileModel;
else
return fileModel.getParentFileModel();
}
return null;
}
public void activeButtonsOnSelectForOperation(FileModel target, boolean active) {
@ -522,6 +597,7 @@ public class GxtToolBarItemFunctionality {
this.btnRenameItem.disable();
this.btnDownloadFile.disable();
this.btnOpen.disable();
this.btnCopyItem.disable();
// this.btnGetInfo.disable();
// this.btnGetSharedLink.disable();
} else {
@ -529,6 +605,7 @@ public class GxtToolBarItemFunctionality {
this.btnRenameItem.enable();
this.btnDownloadFile.enable();
this.btnOpen.enable();
this.btnCopyItem.enable();
// this.btnGetInfo.enable();
}
@ -561,5 +638,9 @@ public class GxtToolBarItemFunctionality {
public void activeButtonsOnSearch(boolean b) {
btnRefreshFolder.setEnabled(!b);
}
public void activePasteButton(boolean b){
btnPasteItem.setEnabled(b);
}
}