256: Workspace explorer
Task-Url: https://support.d4science.org/issues/256 Added events Refactor git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@115616 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a7f22fde61
commit
140cf9ce2c
|
@ -17,6 +17,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.view.Breadcrumbs;
|
|||
import org.gcube.portlets.widgets.wsexplorer.client.view.Navigation;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.view.WorkspaceExplorer;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
@ -30,13 +31,14 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 25, 2015
|
||||
*/
|
||||
public class WorkspaceExplorerController implements EventHandler{
|
||||
public class WorkspaceExplorerController implements EventHandler {
|
||||
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
private WorkspaceExplorerPanel workspaceExplorerPanel;
|
||||
private WorkspaceExplorer wsExplorer = new WorkspaceExplorer();
|
||||
private WorkspaceExplorer wsExplorer;
|
||||
private Breadcrumbs breadcrumbs = new Breadcrumbs();
|
||||
private Navigation navigation = new Navigation();
|
||||
|
||||
public static final WorkspaceExplorerServiceAsync workspaceNavigatorService = GWT.create(WorkspaceExplorerService.class);
|
||||
|
||||
/**
|
||||
|
@ -44,6 +46,7 @@ public class WorkspaceExplorerController implements EventHandler{
|
|||
*/
|
||||
public WorkspaceExplorerController(){
|
||||
bindEvents();
|
||||
wsExplorer = new WorkspaceExplorer();
|
||||
workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation);
|
||||
}
|
||||
|
||||
|
@ -68,7 +71,7 @@ public class WorkspaceExplorerController implements EventHandler{
|
|||
|
||||
@Override
|
||||
public void onLoadRoot(LoadRootEvent loadRootEvent) {
|
||||
wsExplorer.loadTree();
|
||||
wsExplorer.loadRoot();
|
||||
breadcrumbs.init();
|
||||
}
|
||||
});
|
||||
|
@ -125,4 +128,32 @@ public class WorkspaceExplorerController implements EventHandler{
|
|||
public WorkspaceExplorer getWsExplorer() {
|
||||
return wsExplorer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selectableTypes
|
||||
*/
|
||||
public void setSelectableTypes(ItemType[] selectableTypes) {
|
||||
wsExplorer.setSelectableTypes(selectableTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the selectableTypes
|
||||
*/
|
||||
public List<ItemType> getSelectableTypes() {
|
||||
return wsExplorer.getSelectableTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<ItemType> getShowableTypes() {
|
||||
return wsExplorer.getShowableTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param showableTypes
|
||||
*/
|
||||
public void setShowableTypes(ItemType[] showableTypes) {
|
||||
wsExplorer.setShowableTypes(showableTypes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController;
|
|||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.HasWorskpaceExplorerNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.WorskpaceExplorerNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
|
@ -48,6 +49,7 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
|||
* Add {@link WorskpaceExplorerNotificationListener} to receive events
|
||||
*/
|
||||
public WorkspaceExplorerLoadDialog(String captionTxt) {
|
||||
|
||||
this.captionTxt = (captionTxt==null || captionTxt.isEmpty())?WorkspaceExplorerConstants.WORKSPACE_EXPLORER_CAPTION:captionTxt;
|
||||
// setText(this.captionTxt);
|
||||
setAnimation(false);
|
||||
|
@ -68,6 +70,7 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// DockPanel dock = new DockPanel();
|
||||
// dock.setSpacing(5);
|
||||
|
||||
|
@ -133,8 +136,6 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
|||
|
||||
/**
|
||||
* Notify aborted.
|
||||
*
|
||||
* @param selected the selected
|
||||
*/
|
||||
private void notifyAborted(){
|
||||
|
||||
|
@ -202,4 +203,38 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
|||
listeners.remove(handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which items are selectable.
|
||||
* @param selectableTypes the selectableTypes to set
|
||||
*/
|
||||
public void setSelectableTypes(ItemType ... selectableTypes) {
|
||||
controller.setSelectableTypes(selectableTypes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selectable types.
|
||||
*
|
||||
* @return the selectable types
|
||||
*/
|
||||
public List<ItemType> getSelectableTypes() {
|
||||
return controller.getSelectableTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the showable items.
|
||||
* @return the showableTypes
|
||||
*/
|
||||
public List<ItemType> getShowableTypes() {
|
||||
return controller.getShowableTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the showable items. The folders items are show as default.
|
||||
* @param showableTypes the showableTypes to set
|
||||
*/
|
||||
public void setShowableTypes(ItemType ... showableTypes) {
|
||||
controller.setShowableTypes(showableTypes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.notification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
/**
|
||||
* The Interface SelectableTypes.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 29, 2015
|
||||
*/
|
||||
public interface SelectableTypes {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the selectable types.
|
||||
*
|
||||
* @param selectableTypes the new selectable types
|
||||
*/
|
||||
public void setSelectableTypes(ItemType ... selectableTypes);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selectable types.
|
||||
*
|
||||
* @return the selectable types
|
||||
*/
|
||||
public List<ItemType> getSelectableTypes();
|
||||
|
||||
}
|
|
@ -1,15 +1,14 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.notification;
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.view;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class SelectionItemNotification.
|
||||
* The Interface SelectionItem.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 29, 2015
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ShowableTypes.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 29, 2015
|
||||
*/
|
||||
public interface ShowableTypes {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the showable types.
|
||||
*
|
||||
* @return the showable types
|
||||
*/
|
||||
public List<ItemType> getShowableTypes();
|
||||
|
||||
/**
|
||||
* Sets the showable types.
|
||||
*
|
||||
* @param showableTypes the new showable types
|
||||
*/
|
||||
public void setShowableTypes(ItemType ... showableTypes);
|
||||
}
|
|
@ -7,8 +7,8 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.Util;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.grid.ItemsTable;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.resources.WorkspaceExplorerResources;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
@ -23,8 +23,11 @@ import com.google.gwt.user.client.ui.ScrollPanel;
|
|||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 29, 2015
|
||||
*/
|
||||
public class WorkspaceExplorer {
|
||||
public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||
|
||||
|
||||
protected static final HorizontalPanel LOADING_PANEL = new HorizontalPanel();
|
||||
|
@ -51,18 +54,24 @@ public class WorkspaceExplorer {
|
|||
protected ScrollPanel explorerPanel;
|
||||
private ItemsTable itTables;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace explorer.
|
||||
*
|
||||
* As default all items are showable and selectable
|
||||
*/
|
||||
public WorkspaceExplorer() {
|
||||
// as default all items are showable and selectable
|
||||
|
||||
for (ItemType type : ItemType.values()) {
|
||||
showableTypes.add(type);
|
||||
selectableTypes.add(type);
|
||||
}
|
||||
explorerPanel = new ScrollPanel();
|
||||
|
||||
// sp.setWidth(width+"px");
|
||||
// sp.setHeight(height+"px");
|
||||
|
||||
loadTree();
|
||||
|
||||
}
|
||||
|
||||
public void loadItems(){
|
||||
loadRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,13 +85,12 @@ public class WorkspaceExplorer {
|
|||
/**
|
||||
* Load the Workspace Tree.
|
||||
*/
|
||||
public void loadTree() {
|
||||
public void loadRoot() {
|
||||
GWT.log("loading tree data");
|
||||
setLoading();
|
||||
|
||||
// we make a copy of showable types
|
||||
List<ItemType> showableTypesParam = new ArrayList<ItemType>(
|
||||
showableTypes);
|
||||
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
||||
|
||||
// we get sure that folders are displayed
|
||||
for (ItemType folder : Util.FOLDERS) {
|
||||
|
@ -92,16 +100,14 @@ public class WorkspaceExplorer {
|
|||
|
||||
boolean purgeEmpyFolders = !showEmptyFolders;
|
||||
|
||||
FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,
|
||||
requiredProperties);
|
||||
FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties);
|
||||
|
||||
GWT.log("loading workspace tree from server");
|
||||
|
||||
WorkspaceExplorerController.workspaceNavigatorService.getRoot(showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback<Item>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Error loading workspace tree from server",
|
||||
caught);
|
||||
GWT.log("Error loading workspace tree from server",caught);
|
||||
}
|
||||
|
||||
public void onSuccess(Item item) {
|
||||
|
@ -113,6 +119,8 @@ public class WorkspaceExplorer {
|
|||
|
||||
/**
|
||||
* Load the Workspace Tree.
|
||||
*
|
||||
* @param item the item
|
||||
*/
|
||||
public void loadFolder(Item item) {
|
||||
GWT.log("loading folder data");
|
||||
|
@ -184,6 +192,11 @@ public class WorkspaceExplorer {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update explorer.
|
||||
*
|
||||
* @param items the items
|
||||
*/
|
||||
private void updateExplorer(ArrayList<Item> items){
|
||||
GWT.log("workspace explorer updating..");
|
||||
explorerPanel.clear();
|
||||
|
@ -194,13 +207,60 @@ public class WorkspaceExplorer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the panel.
|
||||
*
|
||||
* @return the explorerPanel
|
||||
*/
|
||||
public ScrollPanel getPanel() {
|
||||
return explorerPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item selected.
|
||||
*
|
||||
* @return the item selected
|
||||
*/
|
||||
public Item getItemSelected(){
|
||||
return itTables.getSelectedItem();
|
||||
|
||||
Item item = itTables.getSelectedItem();
|
||||
if (item!=null){
|
||||
boolean selectable = selectableTypes.contains(item.getType());
|
||||
return (selectable)?item:null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the selectableTypes
|
||||
*/
|
||||
@Override
|
||||
public List<ItemType> getSelectableTypes() {
|
||||
return selectableTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selectableTypes the selectableTypes to set
|
||||
*/
|
||||
@Override
|
||||
public void setSelectableTypes(ItemType ... selectableTypes) {
|
||||
this.selectableTypes.clear();
|
||||
if (selectableTypes!=null) for (ItemType type:selectableTypes) this.selectableTypes.add(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the showableTypes
|
||||
*/
|
||||
@Override
|
||||
public List<ItemType> getShowableTypes() {
|
||||
return showableTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param showableTypes the showableTypes to set
|
||||
*/
|
||||
@Override
|
||||
public void setShowableTypes(ItemType ... showableTypes) {
|
||||
this.showableTypes.clear();
|
||||
if (showableTypes!=null) for (ItemType type:showableTypes) this.showableTypes.add(type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.gcube.portlets.widgets.wsexplorer.client.grid;
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.view.grid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.SelectionItem;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.resources.CellTableResources;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.view.SelectionItem;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.CellTable;
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.grid;
|
||||
package org.gcube.portlets.widgets.wsexplorer.client.view.grid;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
Loading…
Reference in New Issue