1657: StatMan AIgorithms Importer - Create a widget to sopport Project Explorer
Task-Url: https://support.d4science.org/issues/1657 Added new class WorkspaceFolderExplorerSelectPanel Updated pom version at 1.1.0 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@120573 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ac9a7a24df
commit
2348899ed8
11
.project
11
.project
|
@ -30,6 +30,16 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||||
|
@ -38,5 +48,6 @@
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||||
|
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
jarsExcludedFromWebInfLib=
|
||||||
|
lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/workspace-explorer/target
|
||||||
|
warSrcDir=src/main/webapp
|
||||||
|
warSrcDirIsOutput=false
|
|
@ -0,0 +1,2 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
entryPointModules=org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer
|
3
pom.xml
3
pom.xml
|
@ -10,8 +10,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>workspace-explorer</artifactId>
|
<artifactId>workspace-explorer</artifactId>
|
||||||
<packaging>jar</packaging>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<name>gCube Workspace Explorer</name>
|
<name>gCube Workspace Explorer</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Workspace Explorer widget allows to navigate (gcube) user workspace
|
gCube Workspace Explorer widget allows to navigate (gcube) user workspace
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.gcube.portlets.widgets.wsexplorer.client;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entry point classes define <code>onModuleLoad()</code>.
|
|
||||||
*/
|
|
||||||
public class WorkspaceExplorer implements EntryPoint {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the entry point method.
|
|
||||||
*/
|
|
||||||
public void onModuleLoad() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -97,9 +97,13 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
public void onLoadFolder(LoadFolderEvent loadFolderEvent) {
|
public void onLoadFolder(LoadFolderEvent loadFolderEvent) {
|
||||||
|
|
||||||
if(loadFolderEvent.getTargetItem()!=null && loadFolderEvent.getTargetItem().isFolder()){
|
if(loadFolderEvent.getTargetItem()!=null && loadFolderEvent.getTargetItem().isFolder()){
|
||||||
wsExplorer.loadFolder(loadFolderEvent.getTargetItem());
|
try {
|
||||||
loadParentBreadcrumbByItemId(loadFolderEvent.getTargetItem().getId(), true);
|
wsExplorer.loadFolder(loadFolderEvent.getTargetItem());
|
||||||
clearMoreInfo();
|
loadParentBreadcrumbByItemId(loadFolderEvent.getTargetItem().getId(), true);
|
||||||
|
clearMoreInfo();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.gcube.portlets.widgets.wsexplorer.client;
|
||||||
|
|
||||||
|
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.EntryPoint;
|
||||||
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*/
|
||||||
|
public class WorkspaceExplorerEntryPoint implements EntryPoint {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the entry point method.
|
||||||
|
*/
|
||||||
|
public void onModuleLoad() {
|
||||||
|
|
||||||
|
WorkspaceExplorer wsExplorer = new WorkspaceExplorer(ItemType.values(), ItemType.values());
|
||||||
|
|
||||||
|
Item item = new Item("9d031962-4678-4e6b-a687-2be532b8e974", "D&D", true);
|
||||||
|
|
||||||
|
RootPanel.get("workspace_explorer").add(wsExplorer.getPanel());
|
||||||
|
try {
|
||||||
|
wsExplorer.loadFolder(item);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ public class WorkspaceExplorerPanel extends DockPanel{
|
||||||
ensureDebugId("WorkspaceNavigatorPanel");
|
ensureDebugId("WorkspaceNavigatorPanel");
|
||||||
|
|
||||||
add(breadcrumbs, DockPanel.NORTH);
|
add(breadcrumbs, DockPanel.NORTH);
|
||||||
|
|
||||||
southPanel.ensureDebugId("SouthPanelWEP");
|
southPanel.ensureDebugId("SouthPanelWEP");
|
||||||
add(southPanel, DockPanel.SOUTH);
|
add(southPanel, DockPanel.SOUTH);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,301 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.wsexplorer.client.select;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.Util;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEvent;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.HasWorskpaceExplorerSelectNotificationListener;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.view.WorkspaceExplorer;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class WorkspaceExplorerSelectPanel.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Jul 28, 2015
|
||||||
|
*/
|
||||||
|
public class WorkspaceFolderExplorerSelectPanel extends ScrollPanel implements HasWorskpaceExplorerSelectNotificationListener{
|
||||||
|
|
||||||
|
private WorkspaceFolderExplorerSelectPanel INSTANCE = this;
|
||||||
|
private boolean isSelect = false;
|
||||||
|
private String captionTxt;
|
||||||
|
private Alert alertConfirm;
|
||||||
|
// private WorkspaceExplorerController controller;
|
||||||
|
private List<WorskpaceExplorerSelectNotificationListener> listeners = new ArrayList<WorskpaceExplorerSelectNotificationListener>();
|
||||||
|
private VerticalPanel mainVP = new VerticalPanel();
|
||||||
|
private HorizontalPanel footerHP = new HorizontalPanel();
|
||||||
|
private WorkspaceExplorer wsExplorer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new workspace folder explorer select panel.
|
||||||
|
*
|
||||||
|
* @param folderId the folder id
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public WorkspaceFolderExplorerSelectPanel(String folderId, String folderName) throws Exception {
|
||||||
|
initExplorer(folderId, folderName, ItemType.values(), ItemType.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initExplorer(String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes) throws Exception{
|
||||||
|
bindEvents();
|
||||||
|
wsExplorer = new WorkspaceExplorer(showableTypes, selectableTypes, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME});
|
||||||
|
Item item = new Item(folderId, folderName, true);
|
||||||
|
wsExplorer.loadFolder(item);
|
||||||
|
initPanel("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new workspace explorer select panel.
|
||||||
|
*
|
||||||
|
* @param captionTxt the caption txt
|
||||||
|
* @param showOnlyFolders the show only folders
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public WorkspaceFolderExplorerSelectPanel(String folderId, boolean showOnlyFolders) throws Exception {
|
||||||
|
|
||||||
|
if(showOnlyFolders){
|
||||||
|
ItemType[] itemsType = new ItemType[1];
|
||||||
|
itemsType[0] = ItemType.FOLDER;
|
||||||
|
initExplorer(folderId, "", itemsType, itemsType);
|
||||||
|
}else{
|
||||||
|
initExplorer(folderId, "", ItemType.values(), ItemType.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind events.
|
||||||
|
*/
|
||||||
|
private void bindEvents(){
|
||||||
|
WorkspaceExplorerController.eventBus.addHandler(ClickItemEvent.TYPE, new ClickItemEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(final ClickItemEvent clickItemEvent) {
|
||||||
|
isSelect = false;
|
||||||
|
Item item = wsExplorer.getItemSelected();
|
||||||
|
|
||||||
|
//Return if item is not selectable
|
||||||
|
if(!itemIsSelectable(item)){
|
||||||
|
notifyNotValidSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notifySelectedItem(wsExplorer.getItemSelected());
|
||||||
|
isSelect = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResize() {
|
||||||
|
super.onResize();
|
||||||
|
GWT.log("on Resize...");
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.user.client.ui.Widget#onLoad()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
GWT.log("on Load...");
|
||||||
|
// adjustSize();
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustSize(){
|
||||||
|
if(this.getParent()!=null && this.getParent().getElement()!=null)
|
||||||
|
Util.adjustSize(this.getParent().getElement(), wsExplorer.getPanel(), 85);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the panel.
|
||||||
|
*
|
||||||
|
* @param captionTxt the caption txt is the tool-tip
|
||||||
|
*/
|
||||||
|
private void initPanel(String captionTxt) {
|
||||||
|
this.captionTxt = captionTxt;
|
||||||
|
if(this.captionTxt!=null && !this.captionTxt.isEmpty())
|
||||||
|
setTitle(this.captionTxt);
|
||||||
|
|
||||||
|
setWidth(WorkspaceExplorerConstants.WIDHT_DIALOG+"px");
|
||||||
|
setAlertConfirm("", false, null);
|
||||||
|
mainVP.add(wsExplorer.getPanel());
|
||||||
|
mainVP.add(footerHP);
|
||||||
|
add(mainVP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alert confirm.
|
||||||
|
*
|
||||||
|
* @param html the html
|
||||||
|
* @param show the show
|
||||||
|
* @param item the item
|
||||||
|
*/
|
||||||
|
private void setAlertConfirm(String html, boolean show, final Item item){
|
||||||
|
try{
|
||||||
|
footerHP.remove(alertConfirm);
|
||||||
|
}catch(Exception e){
|
||||||
|
//silent
|
||||||
|
}
|
||||||
|
|
||||||
|
alertConfirm = new Alert();
|
||||||
|
alertConfirm.setText(html);
|
||||||
|
alertConfirm.setVisible(show);
|
||||||
|
alertConfirm.setClose(true);
|
||||||
|
alertConfirm.setType(AlertType.INFO);
|
||||||
|
|
||||||
|
Button yes = new Button("Yes");
|
||||||
|
yes.setType(ButtonType.LINK);
|
||||||
|
yes.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
if(item!=null){
|
||||||
|
isSelect = true;
|
||||||
|
notifySelectedItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button no = new Button("No");
|
||||||
|
no.setType(ButtonType.LINK);
|
||||||
|
no.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
alertConfirm.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alertConfirm.add(yes);
|
||||||
|
alertConfirm.add(no);
|
||||||
|
footerHP.insert(alertConfirm,0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Notify selected item.
|
||||||
|
*
|
||||||
|
* @param selected the selected
|
||||||
|
*/
|
||||||
|
private void notifySelectedItem(Item selected){
|
||||||
|
|
||||||
|
for (WorskpaceExplorerSelectNotificationListener worskpaceExplorerNotificationListener : listeners) {
|
||||||
|
worskpaceExplorerNotificationListener.onSelectedItem(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify aborted.
|
||||||
|
*/
|
||||||
|
private void notifyAborted(){
|
||||||
|
|
||||||
|
for (WorskpaceExplorerSelectNotificationListener worskpaceExplorerNotificationListener : listeners) {
|
||||||
|
worskpaceExplorerNotificationListener.onAborted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify not valid selection.
|
||||||
|
*/
|
||||||
|
private void notifyNotValidSelection(){
|
||||||
|
|
||||||
|
for (WorskpaceExplorerSelectNotificationListener worskpaceExplorerNotificationListener : listeners) {
|
||||||
|
worskpaceExplorerNotificationListener.onNotValidSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify failed.
|
||||||
|
*
|
||||||
|
* @param t the t
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void notifyFailed(Throwable t){
|
||||||
|
|
||||||
|
for (WorskpaceExplorerSelectNotificationListener worskpaceExplorerNotificationListener : listeners) {
|
||||||
|
worskpaceExplorerNotificationListener.onFailed(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the caption txt.
|
||||||
|
*
|
||||||
|
* @return the captionTxt
|
||||||
|
*/
|
||||||
|
public String getCaptionTxt() {
|
||||||
|
return captionTxt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid hide.
|
||||||
|
*
|
||||||
|
* @return the isValidHide
|
||||||
|
*/
|
||||||
|
public boolean isValidHide() {
|
||||||
|
return isSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.HasWorskpaceExplorerNotificationListener#addWorkspaceExplorerNotificationListener(org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.WorskpaceExplorerNotificationListener)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addWorkspaceExplorerSelectNotificationListener(WorskpaceExplorerSelectNotificationListener handler) {
|
||||||
|
if(handler!=null)
|
||||||
|
listeners.add(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.HasWorskpaceExplorerNotificationListener#removeWorkspaceExplorerNotificationListener(org.gcube.portlets.widgets.wsexplorer.client.notification.WorskpaceExplorerNotification.WorskpaceExplorerNotificationListener)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeWorkspaceExplorerSelectNotificationListener(WorskpaceExplorerSelectNotificationListener handler) {
|
||||||
|
if(handler!=null){
|
||||||
|
if(listeners.contains(handler))
|
||||||
|
listeners.remove(handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item is selectable.
|
||||||
|
*
|
||||||
|
* @param item the item
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public boolean itemIsSelectable(Item item){
|
||||||
|
GWT.log("Selectable type: "+wsExplorer.getSelectableTypes());
|
||||||
|
GWT.log("item: "+item);
|
||||||
|
if (item!=null){
|
||||||
|
boolean selectable = wsExplorer.getSelectableTypes().contains(item.getType());
|
||||||
|
return (selectable)?true:false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.event.RootLoadedEvent;
|
import org.gcube.portlets.widgets.wsexplorer.client.event.RootLoadedEvent;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.resources.WorkspaceExplorerResources;
|
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.client.view.grid.ItemsTable;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
@ -48,13 +49,11 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
protected Alert alert = new Alert();
|
protected Alert alert = new Alert();
|
||||||
protected List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
protected List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
||||||
protected List<ItemType> showableTypes = new ArrayList<ItemType>();
|
protected List<ItemType> showableTypes = new ArrayList<ItemType>();
|
||||||
// protected List<String> allowedMimeTypes = new ArrayList<String>();
|
|
||||||
// protected List<String> allowedFileExtensions = new ArrayList<String>();
|
|
||||||
// protected Map<String, String> requiredProperties = new HashMap<String, String>();
|
|
||||||
protected FilterCriteria filterCriteria = null;
|
protected FilterCriteria filterCriteria = null;
|
||||||
protected boolean showEmptyFolders = true;
|
protected boolean showEmptyFolders = true;
|
||||||
protected ScrollPanel explorerPanel;
|
protected ScrollPanel explorerPanel;
|
||||||
private ItemsTable itTables;
|
private ItemsTable itTables;
|
||||||
|
private DISPLAY_FIELD[] displayFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace explorer.
|
* Instantiates a new workspace explorer.
|
||||||
|
@ -62,11 +61,11 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
* @param showableTypes the showable types
|
* @param showableTypes the showable types
|
||||||
* @param selectableTypes the selectable types
|
* @param selectableTypes the selectable types
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorer(ItemType[] showableTypes, ItemType[] selectableTypes) {
|
public WorkspaceExplorer(ItemType[] showableTypes, ItemType[] selectableTypes, DISPLAY_FIELD...fields) {
|
||||||
setShowableTypes(showableTypes);
|
setShowableTypes(showableTypes);
|
||||||
setSelectableTypes(selectableTypes);
|
setSelectableTypes(selectableTypes);
|
||||||
|
itTables = new ItemsTable(true, fields);
|
||||||
explorerPanel = new ScrollPanel();
|
explorerPanel = new ScrollPanel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,8 +76,8 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
* @param showableTypes the showable types
|
* @param showableTypes the showable types
|
||||||
* @param selectableTypes the selectable types
|
* @param selectableTypes the selectable types
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorer(FilterCriteria filterCriteria, ItemType[] showableTypes, ItemType[] selectableTypes) {
|
public WorkspaceExplorer(FilterCriteria filterCriteria, ItemType[] showableTypes, ItemType[] selectableTypes, DISPLAY_FIELD...fields) {
|
||||||
this(showableTypes, selectableTypes);
|
this(showableTypes, selectableTypes, fields);
|
||||||
this.filterCriteria = filterCriteria;
|
this.filterCriteria = filterCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,43 +140,51 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Workspace Tree.
|
* Load folder.
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public void loadFolder(Item item) {
|
public void loadFolder(final Item item) throws Exception {
|
||||||
GWT.log("loading folder data");
|
GWT.log("loading folder data");
|
||||||
setLoading();
|
setLoading();
|
||||||
|
|
||||||
if(item.isFolder()){
|
if(!item.isFolder())
|
||||||
// we make a copy of showable types
|
throw new Exception("Item is not a folder");
|
||||||
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
|
||||||
|
if(item.getId()==null || item.getId().isEmpty())
|
||||||
|
throw new Exception("Item id is null or empty");
|
||||||
|
|
||||||
|
// we make a copy of showable types
|
||||||
|
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
||||||
|
|
||||||
// we get sure that folders are displayed
|
// we get sure that folders are displayed
|
||||||
for (ItemType folder : Util.FOLDERS) {
|
for (ItemType folder : Util.FOLDERS) {
|
||||||
if (!showableTypesParam.contains(folder))
|
if (!showableTypesParam.contains(folder))
|
||||||
showableTypesParam.add(folder);
|
showableTypesParam.add(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean purgeEmpyFolders = !showEmptyFolders;
|
boolean purgeEmpyFolders = !showEmptyFolders;
|
||||||
// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions);
|
// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions);
|
||||||
|
|
||||||
GWT.log("loading workspace tree from server");
|
GWT.log("loading workspace folder by item id from server: "+item.getId());
|
||||||
WorkspaceExplorerController.workspaceNavigatorService.getFolder(item.getId(), showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback<Item>() {
|
WorkspaceExplorerController.workspaceNavigatorService.getFolder(item.getId(), showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback<Item>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(caught.getMessage());
|
Window.alert(caught.getMessage());
|
||||||
setAlert(caught.getMessage(), AlertType.ERROR);
|
setAlert(caught.getMessage(), AlertType.ERROR);
|
||||||
GWT.log("Error loading workspace folder from server",caught);
|
GWT.log("Error loading workspace folder from server",caught);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Item result) {
|
public void onSuccess(Item result) {
|
||||||
updateExplorer(result.getChildren());
|
if(item.getName()==null || item.getName().isEmpty())
|
||||||
}
|
item.setName(result.getName());
|
||||||
});
|
|
||||||
}
|
updateExplorer(result.getChildren());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -225,7 +232,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
private void updateExplorer(ArrayList<Item> items){
|
private void updateExplorer(ArrayList<Item> items){
|
||||||
GWT.log("workspace explorer updating..");
|
GWT.log("workspace explorer updating..");
|
||||||
explorerPanel.clear();
|
explorerPanel.clear();
|
||||||
itTables = new ItemsTable(true);
|
// itTables = new ItemsTable(true, displayFields);
|
||||||
itTables.addItems(items);
|
itTables.addItems(items);
|
||||||
explorerPanel.add(itTables.getCellTable());
|
explorerPanel.add(itTables.getCellTable());
|
||||||
GWT.log("workspace explorer updated");
|
GWT.log("workspace explorer updated");
|
||||||
|
@ -240,6 +247,24 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
return explorerPanel;
|
return explorerPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the displayFields
|
||||||
|
*/
|
||||||
|
public DISPLAY_FIELD[] getDisplayFields() {
|
||||||
|
return displayFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayFields the displayFields to set
|
||||||
|
*/
|
||||||
|
public void setDisplayFields(DISPLAY_FIELD[] displayFields) {
|
||||||
|
this.displayFields = displayFields;
|
||||||
|
itTables.setDisplayFields(displayFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the it tables.
|
* Gets the it tables.
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,7 +67,7 @@ public abstract class AbstractItemsCellTable {
|
||||||
cellTable.setCondensed(true);
|
cellTable.setCondensed(true);
|
||||||
cellTable.setWidth("100%", true);
|
cellTable.setWidth("100%", true);
|
||||||
dataProvider.addDataDisplay(cellTable);
|
dataProvider.addDataDisplay(cellTable);
|
||||||
initTable(cellTable, null, null);
|
// initTable(cellTable, null, null);
|
||||||
cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
||||||
|
|
||||||
ssm = new SingleSelectionModel<Item>();
|
ssm = new SingleSelectionModel<Item>();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.wsexplorer.client.view.grid;
|
package org.gcube.portlets.widgets.wsexplorer.client.view.grid;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -40,12 +41,16 @@ public class ItemsTable extends AbstractItemsCellTable implements SelectionItem{
|
||||||
private TextColumn<Item> name;
|
private TextColumn<Item> name;
|
||||||
private TextColumn<Item> owner;
|
private TextColumn<Item> owner;
|
||||||
private Item selectedItem = null;
|
private Item selectedItem = null;
|
||||||
|
public static enum DISPLAY_FIELD{ICON, NAME, OWNER};
|
||||||
|
private List<DISPLAY_FIELD> displayFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new items table.
|
* Instantiates a new items table.
|
||||||
*/
|
*/
|
||||||
public ItemsTable(boolean showMoreInfo) {
|
public ItemsTable(boolean showMoreInfo, DISPLAY_FIELD[] fields) {
|
||||||
super(showMoreInfo);
|
super(showMoreInfo);
|
||||||
|
setDisplayFields(fields);
|
||||||
|
initTable(cellTable, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -88,65 +93,77 @@ public class ItemsTable extends AbstractItemsCellTable implements SelectionItem{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
icon = new Column<Item, ImageResource>(iconResourceCell) {
|
if(this.displayFields.contains(DISPLAY_FIELD.ICON)){
|
||||||
@Override
|
icon = new Column<Item, ImageResource>(iconResourceCell) {
|
||||||
public ImageResource getValue(Item dataObj) {
|
@Override
|
||||||
return Util.getImage(dataObj);
|
public ImageResource getValue(Item dataObj) {
|
||||||
}
|
return Util.getImage(dataObj);
|
||||||
/* (non-Javadoc)
|
}
|
||||||
* @see com.google.gwt.user.cellview.client.Column#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
|
/* (non-Javadoc)
|
||||||
*/
|
* @see com.google.gwt.user.cellview.client.Column#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
|
||||||
@Override
|
*/
|
||||||
public void render(Context context, Item object, SafeHtmlBuilder sb) {
|
@Override
|
||||||
super.render(context, object, sb);
|
public void render(Context context, Item object, SafeHtmlBuilder sb) {
|
||||||
|
super.render(context, object, sb);
|
||||||
}
|
|
||||||
};
|
}
|
||||||
// icon.setCellStyleNames("img-centered-clickable");
|
};
|
||||||
icon.setSortable(false);
|
icon.setSortable(false);
|
||||||
packageTable.addColumn(icon, "");
|
packageTable.addColumn(icon, "");
|
||||||
packageTable.setColumnWidth(icon, 10.0, Unit.PCT);
|
packageTable.setColumnWidth(icon, 10.0, Unit.PCT);
|
||||||
|
}
|
||||||
|
|
||||||
//ARTIFACT ID
|
if(this.displayFields.contains(DISPLAY_FIELD.NAME)){
|
||||||
name = new TextColumn<Item>() {
|
//ARTIFACT ID
|
||||||
@Override
|
name = new TextColumn<Item>() {
|
||||||
public String getValue(Item object) {
|
@Override
|
||||||
return object.getName();
|
public String getValue(Item object) {
|
||||||
}
|
return object.getName();
|
||||||
};
|
}
|
||||||
name.setSortable(true);
|
};
|
||||||
packageTable.addColumn(name, "Name");
|
name.setSortable(true);
|
||||||
packageTable.setColumnWidth(name, 50.0, Unit.PCT);
|
|
||||||
|
packageTable.addColumn(name, "Name");
|
||||||
|
|
||||||
|
double width = displayFields.size()>1?50:90;
|
||||||
|
packageTable.setColumnWidth(name, width, Unit.PCT);
|
||||||
|
|
||||||
|
ListHandler<Item> nameColumnHandler = new ListHandler<Item>(dataProvider.getList());
|
||||||
|
nameColumnHandler.setComparator(name, new Comparator<Item>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Item o1, Item o2) {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
packageTable.addColumnSortHandler(nameColumnHandler);
|
||||||
|
|
||||||
ListHandler<Item> nameColumnHandler = new ListHandler<Item>(dataProvider.getList());
|
}
|
||||||
nameColumnHandler.setComparator(name, new Comparator<Item>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Item o1, Item o2) {
|
|
||||||
return o1.getName().compareTo(o2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
packageTable.addColumnSortHandler(nameColumnHandler);
|
if(this.displayFields.contains(DISPLAY_FIELD.OWNER)){
|
||||||
|
|
||||||
|
owner = new TextColumn<Item>() {
|
||||||
|
@Override
|
||||||
|
public String getValue(Item object) {
|
||||||
|
return object.getOwner() != null ? object.getOwner() : "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
owner.setSortable(true);
|
||||||
|
packageTable.addColumn(owner, "Owner");
|
||||||
|
double width = (displayFields.size()==2) ?90:40;
|
||||||
|
packageTable.setColumnWidth(owner, width, Unit.PCT);
|
||||||
|
|
||||||
|
ListHandler<Item> ownerColumnHandler = new ListHandler<Item>(dataProvider.getList());
|
||||||
|
ownerColumnHandler.setComparator(owner, new Comparator<Item>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Item o1, Item o2) {
|
||||||
|
return o1.getOwner().compareTo(o2.getOwner());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
packageTable.addColumnSortHandler(ownerColumnHandler);
|
||||||
|
|
||||||
owner = new TextColumn<Item>() {
|
}
|
||||||
@Override
|
|
||||||
public String getValue(Item object) {
|
|
||||||
return object.getOwner() != null ? object.getOwner() : "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
owner.setSortable(true);
|
|
||||||
packageTable.addColumn(owner, "Owner");
|
|
||||||
packageTable.setColumnWidth(owner, 40.0, Unit.PCT);
|
|
||||||
|
|
||||||
ListHandler<Item> ownerColumnHandler = new ListHandler<Item>(dataProvider.getList());
|
|
||||||
nameColumnHandler.setComparator(owner, new Comparator<Item>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Item o1, Item o2) {
|
|
||||||
return o1.getOwner().compareTo(o2.getOwner());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
packageTable.addColumnSortHandler(ownerColumnHandler);
|
|
||||||
|
|
||||||
/*final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();
|
/*final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();
|
||||||
selectionModel.addSelectionChangeHandler(new Handler() {
|
selectionModel.addSelectionChangeHandler(new Handler() {
|
||||||
|
@ -156,6 +173,20 @@ public class ItemsTable extends AbstractItemsCellTable implements SelectionItem{
|
||||||
});*/
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayFields the dispalyFields to set
|
||||||
|
*/
|
||||||
|
public void setDisplayFields(DISPLAY_FIELD[] fields) {
|
||||||
|
this.displayFields = (fields!=null && fields.length>0)?Arrays.asList(fields):Arrays.asList(DISPLAY_FIELD.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the displayFields
|
||||||
|
*/
|
||||||
|
public List<DISPLAY_FIELD> getDisplayFields() {
|
||||||
|
return displayFields;
|
||||||
|
}
|
||||||
|
|
||||||
public class ButtonImageCell extends ButtonCell{
|
public class ButtonImageCell extends ButtonCell{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,15 +7,18 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class Item.
|
* The Class Item.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 25, 2015
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Dec 2, 2015
|
||||||
*/
|
*/
|
||||||
public class Item implements IsSerializable {
|
public class Item implements IsSerializable {
|
||||||
|
|
||||||
protected Item parent;
|
protected Item parent;
|
||||||
protected String id;
|
protected String id;
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected ItemType type;
|
protected ItemType type;
|
||||||
protected String path;
|
protected String path;
|
||||||
|
@ -31,6 +34,17 @@ public class Item implements IsSerializable {
|
||||||
*/
|
*/
|
||||||
public Item() {
|
public Item() {
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Instantiates a new item.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param name the name
|
||||||
|
* @param isFolder the is folder
|
||||||
|
*/
|
||||||
|
public Item(String id, String name, boolean isFolder) {
|
||||||
|
this.id = id;
|
||||||
|
this.isFolder = isFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,17 +60,24 @@ public class Item implements IsSerializable {
|
||||||
* @param isRoot the is root
|
* @param isRoot the is root
|
||||||
*/
|
*/
|
||||||
public Item(Item parent, String id, String name, ItemType type, String path, String owner, boolean isFolder, boolean isRoot) {
|
public Item(Item parent, String id, String name, ItemType type, String path, String owner, boolean isFolder, boolean isRoot) {
|
||||||
|
this(id, name, isFolder);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.children = new ArrayList<Item>();
|
this.children = new ArrayList<Item>();
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.isFolder = isFolder;
|
|
||||||
this.isRoot = isRoot;
|
this.isRoot = isRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the id.
|
||||||
|
*
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is root.
|
* Checks if is root.
|
||||||
|
@ -238,6 +259,8 @@ public class Item implements IsSerializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the path.
|
||||||
|
*
|
||||||
* @return the path
|
* @return the path
|
||||||
*/
|
*/
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
|
|
Loading…
Reference in New Issue