diff --git a/pom.xml b/pom.xml index e6d5ed5..020b74f 100644 --- a/pom.xml +++ b/pom.xml @@ -89,19 +89,18 @@ - - org.gcube.common - home-library-model - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) - provided - - - org.gcube.common - home-library-jcr - - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) - provided - + + + + + + + + + + + + org.gcube.common home-library diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml b/src/main/java/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml index a0787ad..c2f587c 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml @@ -3,8 +3,8 @@ - - + + @@ -22,4 +22,14 @@ - + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorerController.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorerController.java index 9870ae2..0022c74 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorerController.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorerController.java @@ -19,6 +19,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService 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.FilterCriteria; import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; @@ -61,10 +62,18 @@ public class WorkspaceExplorerController implements EventHandler { workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation); } -// public void loadRoot(){ -// wsExplorer.loadRoot(); -// } + /** + * Instantiates a new workspace explorer controller. + * + * @param filterCriteria the filter criteria + */ + public WorkspaceExplorerController(FilterCriteria filterCriteria) { + bindEvents(); + wsExplorer = new WorkspaceExplorer(filterCriteria); + workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation); + } + /** * Bind events. */ @@ -172,10 +181,18 @@ public class WorkspaceExplorerController implements EventHandler { }); } + /** + * Clear more info. + */ private void clearMoreInfo(){ workspaceExplorerPanel.getSouthPanel().clear(); } + /** + * Update more info. + * + * @param item the item + */ private void updateMoreInfo(Item item){ if(item!=null){ @@ -247,6 +264,8 @@ public class WorkspaceExplorerController implements EventHandler { } /** + * Gets the breadcrumbs. + * * @return the breadcrumbs */ public Breadcrumbs getBreadcrumbs() { @@ -263,6 +282,8 @@ public class WorkspaceExplorerController implements EventHandler { } /** + * Gets the ws explorer. + * * @return the wsExplorer */ public WorkspaceExplorer getWsExplorer() { @@ -270,13 +291,17 @@ public class WorkspaceExplorerController implements EventHandler { } /** - * @param selectableTypes + * Sets the selectable types. + * + * @param selectableTypes the new selectable types */ public void setSelectableTypes(ItemType[] selectableTypes) { wsExplorer.setSelectableTypes(selectableTypes); } /** + * Gets the selectable types. + * * @return the selectableTypes */ public List getSelectableTypes() { @@ -284,14 +309,18 @@ public class WorkspaceExplorerController implements EventHandler { } /** - * @return + * Gets the showable types. + * + * @return the showable types */ public List getShowableTypes() { return wsExplorer.getShowableTypes(); } /** - * @param showableTypes + * Sets the showable types. + * + * @param showableTypes the new showable types */ public void setShowableTypes(ItemType[] showableTypes) { wsExplorer.setShowableTypes(showableTypes); diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSaveDialog.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSaveDialog.java index e45c6bd..74577e3 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSaveDialog.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSaveDialog.java @@ -10,6 +10,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEventHandler; import org.gcube.portlets.widgets.wsexplorer.client.event.LoadRootEvent; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.HasWorskpaceExplorerSaveNotificationListener; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.WorskpaceExplorerSaveNotificationListener; +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; @@ -42,7 +43,7 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx private boolean isSave = false; private String captionTxt; private ModalFooter footer = new ModalFooter(); - private WorkspaceExplorerController controller = new WorkspaceExplorerController(); + private WorkspaceExplorerController controller; private List listeners = new ArrayList(); private TextBox fileNameTextBox = new TextBox(); @@ -54,10 +55,21 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx * @param fileName the file name */ public WorkspaceExplorerSaveDialog(String captionTxt, String fileName) { - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(captionTxt, fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt, fileName); + } + + /** + * Instantiates a new workspace explorer save dialog. + * + * @param captionTxt the caption txt + * @param fileName the file name + * @param filterCriteria the filter criteria to filter for Mime Types, File Extensions, Properties + */ + public WorkspaceExplorerSaveDialog(String captionTxt, String fileName, FilterCriteria filterCriteria) { + controller = new WorkspaceExplorerController(filterCriteria); + loadExplorer(captionTxt, fileName); } - /** * Instantiates a new workspace explorer save dialog. @@ -74,11 +86,9 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx setSelectableTypes(itemsType); setShowableTypes(itemsType); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(captionTxt, fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt, fileName); } - /** * Instantiates a new workspace explorer save dialog. @@ -94,8 +104,8 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx setSelectableTypes(itemsType); setShowableTypes(itemsType); } - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(WorkspaceExplorerConstants.WORKSPACE_EXPLORER_SAVE_AS_CAPTION, fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(WorkspaceExplorerConstants.WORKSPACE_EXPLORER_SAVE_AS_CAPTION, fileName); } @@ -113,9 +123,8 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx itemsType = showableTypes.toArray(itemsType); setShowableTypes(showableTypes.toArray(itemsType)); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(captionTxt, fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt, fileName); } @@ -132,7 +141,18 @@ public class WorkspaceExplorerSaveDialog extends Modal implements HasWorskpaceEx itemsType = showableTypes.toArray(itemsType); setShowableTypes(showableTypes.toArray(itemsType)); } - + controller = new WorkspaceExplorerController(); + loadExplorer(WorkspaceExplorerConstants.WORKSPACE_EXPLORER_SAVE_AS_CAPTION, fileName); + } + + + /** + * Load explorer. + * + * @param captionTxt the caption txt + * @param fileName the file name + */ + private void loadExplorer(String captionTxt, String fileName){ WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); initDialog(captionTxt, fileName); } diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSavePanel.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSavePanel.java index f5c8d60..3c55ecf 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSavePanel.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/save/WorkspaceExplorerSavePanel.java @@ -13,6 +13,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEventHandler; import org.gcube.portlets.widgets.wsexplorer.client.event.LoadRootEvent; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.HasWorskpaceExplorerSaveNotificationListener; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSaveNotification.WorskpaceExplorerSaveNotificationListener; +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; @@ -42,7 +43,7 @@ public class WorkspaceExplorerSavePanel extends ScrollPanel implements HasWorskp private Button saveButton; @SuppressWarnings("unused") private boolean isSave = false; - private WorkspaceExplorerController controller = new WorkspaceExplorerController(); + private WorkspaceExplorerController controller; private List listeners = new ArrayList(); private TextBox fileNameTextBox = new TextBox(); private VerticalPanel mainVP = new VerticalPanel(); @@ -55,10 +56,20 @@ public class WorkspaceExplorerSavePanel extends ScrollPanel implements HasWorskp * @param fileName the file name */ public WorkspaceExplorerSavePanel(String fileName) { - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initPanel(fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(fileName); + } + + /** + * Instantiates a new workspace explorer save panel. + * + * @param fileName the file name + * @param filterCriteria the filter criteria + */ + public WorkspaceExplorerSavePanel(String fileName, FilterCriteria filterCriteria) { + controller = new WorkspaceExplorerController(filterCriteria); + loadExplorer(fileName); } - /** * Instantiates a new workspace explorer save panel. @@ -74,9 +85,8 @@ public class WorkspaceExplorerSavePanel extends ScrollPanel implements HasWorskp setSelectableTypes(itemsType); setShowableTypes(itemsType); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initPanel(fileName); + controller = new WorkspaceExplorerController(); + loadExplorer(fileName); } /** @@ -92,7 +102,16 @@ public class WorkspaceExplorerSavePanel extends ScrollPanel implements HasWorskp itemsType = showableTypes.toArray(itemsType); setShowableTypes(showableTypes.toArray(itemsType)); } + controller = new WorkspaceExplorerController(); + loadExplorer(fileName); + } + /** + * Load explorer. + * + * @param fileName the file name + */ + private void loadExplorer(String fileName){ WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); initPanel(fileName); } @@ -282,6 +301,8 @@ public class WorkspaceExplorerSavePanel extends ScrollPanel implements HasWorskp } /** + * Gets the save button. + * * @return the saveButton */ public Button getSaveButton() { diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectDialog.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectDialog.java index 403f5ea..39749d6 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectDialog.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectDialog.java @@ -11,6 +11,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController; import org.gcube.portlets.widgets.wsexplorer.client.event.LoadRootEvent; 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.shared.FilterCriteria; import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; @@ -40,20 +41,32 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace private String captionTxt; private ModalFooter footer = new ModalFooter(); private Alert alertConfirm; - private WorkspaceExplorerController controller = new WorkspaceExplorerController(); + private WorkspaceExplorerController controller; private List listeners = new ArrayList(); /** * Instantiates a new workspace explorer select dialog. - * - * @param captionTxt the caption txt * You can implement {@link WorskpaceExplorerSelectNotificationListener} to receive events + * @param captionTxt the caption txt + * */ public WorkspaceExplorerSelectDialog(String captionTxt) { - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(captionTxt); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); } + + /** + * Instantiates a new workspace explorer select dialog. + * You can implement {@link WorskpaceExplorerSelectNotificationListener} to receive events + * @param captionTxt the caption txt + * @param filterCriteria the filter criteria + */ + public WorkspaceExplorerSelectDialog(String captionTxt, FilterCriteria filterCriteria) { + controller = new WorkspaceExplorerController(filterCriteria); + loadExplorer(captionTxt); + } + /** * Instantiates a new workspace explorer select dialog. @@ -69,9 +82,9 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace setSelectableTypes(itemsType); setShowableTypes(itemsType); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initDialog(captionTxt); + + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); } /** @@ -95,7 +108,17 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace itemsType = showableTypes.toArray(itemsType); setShowableTypes(showableTypes.toArray(itemsType)); } - + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); + } + + + /** + * Load explorer. + * + * @param captionTxt the caption txt + */ + private void loadExplorer(String captionTxt){ WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); initDialog(captionTxt); } @@ -155,7 +178,8 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace * Sets the alert confirm. * * @param html the html - * @param bool the bool + * @param show the show + * @param item the item */ private void setAlertConfirm(String html, boolean show, final Item item){ try{ diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectPanel.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectPanel.java index e58296a..a77341b 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/select/WorkspaceExplorerSelectPanel.java @@ -11,6 +11,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController; import org.gcube.portlets.widgets.wsexplorer.client.event.LoadRootEvent; 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.shared.FilterCriteria; import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; @@ -40,7 +41,7 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors private String captionTxt; private ModalFooter footer = new ModalFooter(); private Alert alertConfirm; - private WorkspaceExplorerController controller = new WorkspaceExplorerController(); + private WorkspaceExplorerController controller; private List listeners = new ArrayList(); private VerticalPanel mainVP = new VerticalPanel(); @@ -50,9 +51,22 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors * @param captionTxt the tool-tip of the panel */ public WorkspaceExplorerSelectPanel(String captionTxt) { - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initPanel(captionTxt); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); } + + + /** + * Instantiates a new workspace explorer select panel. + * + * @param captionTxt the caption txt + * @param filterCriteria the filter criteria + */ + public WorkspaceExplorerSelectPanel(String captionTxt, FilterCriteria filterCriteria) { + controller = new WorkspaceExplorerController(filterCriteria); + loadExplorer(captionTxt); + } + /** @@ -69,9 +83,8 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors setSelectableTypes(itemsType); setShowableTypes(itemsType); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initPanel(captionTxt); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); } @@ -94,12 +107,20 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors itemsType = showableTypes.toArray(itemsType); setShowableTypes(showableTypes.toArray(itemsType)); } - - WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); - initPanel(captionTxt); + controller = new WorkspaceExplorerController(); + loadExplorer(captionTxt); } + /** + * Load explorer. + * + * @param captionTxt the caption txt + */ + private void loadExplorer(String captionTxt){ + WorkspaceExplorerController.eventBus.fireEvent(new LoadRootEvent()); + initPanel(captionTxt); + } /** diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceExplorer.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceExplorer.java index 645a3c6..a20e587 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceExplorer.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceExplorer.java @@ -1,9 +1,7 @@ package org.gcube.portlets.widgets.wsexplorer.client.view; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.gcube.portlets.widgets.wsexplorer.client.Util; import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerController; @@ -48,9 +46,11 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{ protected Alert alert = new Alert(); protected List selectableTypes = new ArrayList(); protected List showableTypes = new ArrayList(); - protected List allowedMimeTypes = new ArrayList(); +// protected List allowedMimeTypes = new ArrayList(); +// protected List allowedFileExtensions = new ArrayList(); +// protected Map requiredProperties = new HashMap(); + protected FilterCriteria filterCriteria = null; protected boolean showEmptyFolders = true; - protected Map requiredProperties = new HashMap(); protected ScrollPanel explorerPanel; private ItemsTable itTables; @@ -68,7 +68,17 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{ explorerPanel = new ScrollPanel(); } - + + /** + * Instantiates a new workspace explorer. + * + * @param filterCriteria the filter criteria + */ + public WorkspaceExplorer(FilterCriteria filterCriteria) { + this(); + this.filterCriteria = filterCriteria; + } + /** * Sets the alert. * @@ -109,7 +119,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{ boolean purgeEmpyFolders = !showEmptyFolders; - FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties); +// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions); GWT.log("loading workspace tree from server"); @@ -148,7 +158,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{ } boolean purgeEmpyFolders = !showEmptyFolders; - FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties); +// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions); GWT.log("loading workspace tree from server"); WorkspaceExplorerController.workspaceNavigatorService.getFolder(item.getId(), showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback() { @@ -186,7 +196,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{ } boolean purgeEmpyFolders = !showEmptyFolders; - FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties); +// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions); GWT.log("loading workspace tree from server"); WorkspaceExplorerController.workspaceNavigatorService.getMySpecialFolder(showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback() { diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapConfigurator.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapConfigurator.java new file mode 100644 index 0000000..20bffd0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapConfigurator.java @@ -0,0 +1,23 @@ +package org.gcube.portlets.widgets.wsexplorer.resources; + + +import com.github.gwtbootstrap.client.ui.config.Configurator; +import com.github.gwtbootstrap.client.ui.resources.Resources; +import com.google.gwt.core.client.GWT; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Jul 30, 2014 + * + */ +public class BootstrapConfigurator implements Configurator { + + public Resources getResources() { + return GWT.create(BootstrapOverrideResources.class); + } + + public boolean hasResponsiveDesign() { + return false; + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapOverrideResources.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapOverrideResources.java new file mode 100644 index 0000000..25009af --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/BootstrapOverrideResources.java @@ -0,0 +1,14 @@ +package org.gcube.portlets.widgets.wsexplorer.resources; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Jul 28, 2014 + * + */ +import com.github.gwtbootstrap.client.ui.resources.Resources; +import com.google.gwt.resources.client.TextResource; + +public interface BootstrapOverrideResources extends Resources { + @Source("css/bootstrap.min.css") + TextResource bootstrapCss(); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/css/bootstrap.min.css b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/css/bootstrap.min.css new file mode 100644 index 0000000..f62bec2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/resources/css/bootstrap.min.css @@ -0,0 +1,960 @@ +/*MODAL FOOTER*/ +.modal-footer { + background-color: #F5F5F5; + border-radius: 0 0 6px 6px; + border-top: 1px solid #DDDDDD; + box-shadow: 0 1px 0 #FFFFFF inset; + margin-bottom: 0; + padding: 14px 15px 15px; + text-align: right; +} + +.modal-footer:before, .modal-footer:after { + content: ""; + display: table; + line-height: 0; +} + +.modal-footer:after { + clear: both; +} + +.modal-footer .btn+.btn { + margin-bottom: 0; + margin-left: 5px; +} + +.modal-footer .btn-group .btn+.btn { + margin-left: -1px; +} + +.modal-footer .btn-block+.btn-block { + margin-left: 0; +} + +/*TOOLTIP*/ +.tooltip { + display: block; + font-size: 11px; + line-height: 1.4; + opacity: 0; + position: absolute; + visibility: visible; + z-index: 1030; +} + +.tooltip.in { + opacity: 0.8; +} + +.tooltip.top { + margin-top: -3px; + padding: 5px 0; +} + +.tooltip.right { + margin-left: 3px; + padding: 0 5px; +} + +.tooltip.bottom { + margin-top: 3px; + padding: 5px 0; +} + +.tooltip.left { + margin-left: -3px; + padding: 0 5px; +} + +.tooltip-inner { + background-color: #000000; + border-radius: 4px; + color: #FFFFFF; + max-width: 200px; + padding: 8px; + text-align: center; + text-decoration: none; +} + +.tooltip-arrow { + border-color: rgba(0, 0, 0, 0); + border-style: solid; + height: 0; + position: absolute; + width: 0; +} + +.tooltip.top .tooltip-arrow { + border-top-color: #000000; + border-width: 5px 5px 0; + bottom: 0; + left: 50%; + margin-left: -5px; +} + +.tooltip.right .tooltip-arrow { + border-right-color: #000000; + border-width: 5px 5px 5px 0; + left: 0; + margin-top: -5px; + top: 50%; +} + +.tooltip.left .tooltip-arrow { + border-left-color: #000000; + border-width: 5px 0 5px 5px; + margin-top: -5px; + right: 0; + top: 50%; +} + +.tooltip.bottom .tooltip-arrow { + border-bottom-color: #000000; + border-width: 0 5px 5px; + left: 50%; + margin-left: -5px; + top: 0; +} + +/*BREADCRUMB*/ +.breadcrumb { + background-color: #F5F5F5; + border-radius: 4px; + list-style: none outside none; + margin: 0 0 20px; + padding: 8px 15px; +} + +.breadcrumb>li { + display: inline-block; + text-shadow: 0 1px 0 #FFFFFF; +} + +.breadcrumb>li>.divider { + color: #CCCCCC; + padding: 0 5px; +} + +.breadcrumb>.active { + color: #999999; +} + +/*TABLE*/ +.table { + margin-bottom: 20px; + width: 100%; +} + +.table th, .table td { + border-top: 1px solid #DDDDDD; + line-height: 20px; + padding: 8px; + text-align: left; + vertical-align: top; +} + +.table th { + font-weight: bold; +} + +.table thead th { + vertical-align: bottom; +} + +.table caption+thead tr:first-child th, .table caption+thead tr:first-child td, + .table colgroup+thead tr:first-child th, .table colgroup+thead tr:first-child td, + .table thead:first-child tr:first-child th, .table thead:first-child tr:first-child td + { + border-top: 0 none; +} + +.table tbody+tbody { + border-top: 2px solid #DDDDDD; +} + +.table .table { + background-color: #FFFFFF; +} + +.table-condensed th, .table-condensed td { + padding: 4px 5px; +} + +.table-bordered { + -moz-border-bottom-colors: none; + -moz-border-left-colors: none; + -moz-border-right-colors: none; + -moz-border-top-colors: none; + border-collapse: separate; + border-color: #DDDDDD #DDDDDD #DDDDDD -moz-use-text-color; + border-image: none; + border-radius: 4px; + border-style: solid solid solid none; + border-width: 1px 1px 1px 0; +} + +.table-bordered th, .table-bordered td { + border-left: 1px solid #DDDDDD; +} + +.table-bordered caption+thead tr:first-child th, .table-bordered caption+tbody tr:first-child th, + .table-bordered caption+tbody tr:first-child td, .table-bordered colgroup+thead tr:first-child th, + .table-bordered colgroup+tbody tr:first-child th, .table-bordered colgroup+tbody tr:first-child td, + .table-bordered thead:first-child tr:first-child th, .table-bordered tbody:first-child tr:first-child th, + .table-bordered tbody:first-child tr:first-child td { + border-top: 0 none; +} + +.table-bordered thead:first-child tr:first-child>th:first-child, + .table-bordered tbody:first-child tr:first-child>td:first-child, + .table-bordered tbody:first-child tr:first-child>th:first-child { + border-top-left-radius: 4px; +} + +.table-bordered thead:first-child tr:first-child>th:last-child, + .table-bordered tbody:first-child tr:first-child>td:last-child, + .table-bordered tbody:first-child tr:first-child>th:last-child { + border-top-right-radius: 4px; +} + +.table-bordered thead:last-child tr:last-child>th:first-child, + .table-bordered tbody:last-child tr:last-child>td:first-child, + .table-bordered tbody:last-child tr:last-child>th:first-child, + .table-bordered tfoot:last-child tr:last-child>td:first-child, + .table-bordered tfoot:last-child tr:last-child>th:first-child { + border-bottom-left-radius: 4px; +} + +.table-bordered thead:last-child tr:last-child>th:last-child, + .table-bordered tbody:last-child tr:last-child>td:last-child, + .table-bordered tbody:last-child tr:last-child>th:last-child, + .table-bordered tfoot:last-child tr:last-child>td:last-child, + .table-bordered tfoot:last-child tr:last-child>th:last-child { + border-bottom-right-radius: 4px; +} + +.table-bordered tfoot+tbody:last-child tr:last-child td:first-child { + border-bottom-left-radius: 0; +} + +.table-bordered tfoot+tbody:last-child tr:last-child td:last-child { + border-bottom-right-radius: 0; +} + +.table-bordered caption+thead tr:first-child th:first-child, + .table-bordered caption+tbody tr:first-child td:first-child, + .table-bordered colgroup+thead tr:first-child th:first-child, + .table-bordered colgroup+tbody tr:first-child td:first-child { + border-top-left-radius: 4px; +} + +.table-bordered caption+thead tr:first-child th:last-child, + .table-bordered caption+tbody tr:first-child td:last-child, + .table-bordered colgroup+thead tr:first-child th:last-child, + .table-bordered colgroup+tbody tr:first-child td:last-child { + border-top-right-radius: 4px; +} + +.table-striped tbody>tr:nth-child(2n+1)>td, .table-striped tbody>tr:nth-child(2n+1)>th + { + background-color: #F9F9F9; +} + +.table-hover tbody tr:hover>td, .table-hover tbody tr:hover>th { + background-color: #F5F5F5; +} + +table td[class*="span"], table th[class*="span"], .row-fluid table td[class*="span"], + .row-fluid table th[class*="span"] { + display: table-cell; + float: none; + margin-left: 0; +} + +.table td.span1, .table th.span1 { + float: none; + margin-left: 0; + width: 44px; +} + +.table td.span2, .table th.span2 { + float: none; + margin-left: 0; + width: 124px; +} + +.table td.span3, .table th.span3 { + float: none; + margin-left: 0; + width: 204px; +} + +.table td.span4, .table th.span4 { + float: none; + margin-left: 0; + width: 284px; +} + +.table td.span5, .table th.span5 { + float: none; + margin-left: 0; + width: 364px; +} + +.table td.span6, .table th.span6 { + float: none; + margin-left: 0; + width: 444px; +} + +.table td.span7, .table th.span7 { + float: none; + margin-left: 0; + width: 524px; +} + +.table td.span8, .table th.span8 { + float: none; + margin-left: 0; + width: 604px; +} + +.table td.span9, .table th.span9 { + float: none; + margin-left: 0; + width: 684px; +} + +.table td.span10, .table th.span10 { + float: none; + margin-left: 0; + width: 764px; +} + +.table td.span11, .table th.span11 { + float: none; + margin-left: 0; + width: 844px; +} + +.table td.span12, .table th.span12 { + float: none; + margin-left: 0; + width: 924px; +} + +.table tbody tr.success>td { + background-color: #DFF0D8; +} + +.table tbody tr.error>td { + background-color: #F2DEDE; +} + +.table tbody tr.warning>td { + background-color: #FCF8E3; +} + +.table tbody tr.info>td { + background-color: #D9EDF7; +} + +.table-hover tbody tr.success:hover>td { + background-color: #D0E9C6; +} + +.table-hover tbody tr.error:hover>td { + background-color: #EBCCCC; +} + +.table-hover tbody tr.warning:hover>td { + background-color: #FAF2CC; +} + +.table-hover tbody tr.info:hover>td { + background-color: #C4E3F3; +} + +/*BUTTONS*/ +button.close { + background: none repeat scroll 0 0 rgba(0, 0, 0, 0); + border: 0 none; + cursor: pointer; + padding: 0; +} + +.btn { + -moz-border-bottom-colors: none; + -moz-border-left-colors: none; + -moz-border-right-colors: none; + -moz-border-top-colors: none; + background-color: #F5F5F5; + background-image: linear-gradient(to bottom, #FFFFFF, #E6E6E6); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) #B3B3B3; + border-image: none; + border-radius: 4px; + border-style: solid; + border-width: 1px; + box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px + rgba(0, 0, 0, 0.05); + color: #333333; + cursor: pointer; + display: inline-block; + font-size: 14px; + line-height: 20px; + margin-bottom: 0; + padding: 4px 12px; + text-align: center; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); + vertical-align: middle; +} + +.btn:hover, .btn:focus, .btn:active, .btn.active, .btn.disabled, .btn[disabled] + { + background-color: #E6E6E6; + color: #333333; +} + +.btn:active, .btn.active { + +} + +.btn:first-child { + +} + +.btn:hover, .btn:focus { + background-position: 0 -15px; + color: #333333; + text-decoration: none; + transition: background-position 0.1s linear 0s; +} + +.btn:focus { + outline: thin dotted #333333; + outline-offset: -2px; +} + +.btn.active, .btn:active { + background-image: none; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px + rgba(0, 0, 0, 0.05); + outline: 0 none; +} + +.btn.disabled, .btn[disabled] { + background-image: none; + box-shadow: none; + cursor: default; + opacity: 0.65; +} + +.btn-large { + border-radius: 6px; + font-size: 17.5px; + padding: 11px 19px; +} + +.btn-large [class^="icon-"], .btn-large [class*=" icon-"] { + margin-top: 4px; +} + +.btn-small { + border-radius: 3px; + font-size: 11.9px; + padding: 2px 10px; +} + +.btn-small [class^="icon-"], .btn-small [class*=" icon-"] { + margin-top: 0; +} + +.btn-mini [class^="icon-"], .btn-mini [class*=" icon-"] { + margin-top: -1px; +} + +.btn-mini { + border-radius: 3px; + font-size: 10.5px; + padding: 0 6px; +} + +.btn-block { + -moz-box-sizing: border-box; + display: block; + padding-left: 0; + padding-right: 0; + width: 100%; +} + +.btn-block+.btn-block { + margin-top: 5px; +} + +input.btn-block[type="submit"], input.btn-block[type="reset"], input.btn-block[type="button"] + { + width: 100%; +} + +.btn-primary.active, .btn-warning.active, .btn-danger.active, + .btn-success.active, .btn-info.active, .btn-inverse.active { + color: rgba(255, 255, 255, 0.75); +} + +.btn-primary { + background-color: #006DCC; + background-image: linear-gradient(to bottom, #0088CC, #0044CC); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-primary:hover, .btn-primary:focus, .btn-primary:active, + .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] { + background-color: #0044CC; + color: #FFFFFF; +} + +.btn-primary:active, .btn-primary.active { + +} + +.btn-warning { + background-color: #FAA732; + background-image: linear-gradient(to bottom, #FBB450, #F89406); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-warning:hover, .btn-warning:focus, .btn-warning:active, + .btn-warning.active, .btn-warning.disabled, .btn-warning[disabled] { + background-color: #F89406; + color: #FFFFFF; +} + +.btn-warning:active, .btn-warning.active { + +} + +.btn-danger { + background-color: #DA4F49; + background-image: linear-gradient(to bottom, #EE5F5B, #BD362F); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger.active, + .btn-danger.disabled, .btn-danger[disabled] { + background-color: #BD362F; + color: #FFFFFF; +} + +.btn-danger:active, .btn-danger.active { + +} + +.btn-success { + background-color: #5BB75B; + background-image: linear-gradient(to bottom, #62C462, #51A351); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-success:hover, .btn-success:focus, .btn-success:active, + .btn-success.active, .btn-success.disabled, .btn-success[disabled] { + background-color: #51A351; + color: #FFFFFF; +} + +.btn-success:active, .btn-success.active { + +} + +.btn-info { + background-color: #49AFCD; + background-image: linear-gradient(to bottom, #5BC0DE, #2F96B4); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-info:hover, .btn-info:focus, .btn-info:active, .btn-info.active, + .btn-info.disabled, .btn-info[disabled] { + background-color: #2F96B4; + color: #FFFFFF; +} + +.btn-info:active, .btn-info.active { + +} + +.btn-inverse { + background-color: #363636; + background-image: linear-gradient(to bottom, #444444, #222222); + background-repeat: repeat-x; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #FFFFFF; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); +} + +.btn-inverse:hover, .btn-inverse:focus, .btn-inverse:active, + .btn-inverse.active, .btn-inverse.disabled, .btn-inverse[disabled] { + background-color: #222222; + color: #FFFFFF; +} + +.btn-inverse:active, .btn-inverse.active { + +} + +button.btn, input.btn[type="submit"] { + +} + +button.btn::-moz-focus-inner, input.btn[type="submit"]::-moz-focus-inner + { + border: 0 none; + padding: 0; +} + +button.btn.btn-large, input.btn.btn-large[type="submit"] { + +} + +button.btn.btn-small, input.btn.btn-small[type="submit"] { + +} + +button.btn.btn-mini, input.btn.btn-mini[type="submit"] { + +} + +.btn-link, .btn-link:active, .btn-link[disabled] { + background-color: rgba(0, 0, 0, 0); + background-image: none; + box-shadow: none; +} + +.btn-link { + border-color: rgba(0, 0, 0, 0); + border-radius: 0; + color: #0088CC; + cursor: pointer; +} + +.btn-link:hover, .btn-link:focus { + background-color: rgba(0, 0, 0, 0); + color: #005580; + text-decoration: underline; +} + +.btn-link[disabled]:hover, .btn-link[disabled]:focus { + color: #333333; + text-decoration: none; +} + +.btn-group { + display: inline-block; + font-size: 0; + position: relative; + vertical-align: middle; + white-space: nowrap; +} + +.btn-group:first-child { + +} + +.btn-group+.btn-group { + margin-left: 5px; +} + +.btn-toolbar { + font-size: 0; + margin-bottom: 10px; + margin-top: 10px; +} + +.btn-toolbar>.btn+.btn, .btn-toolbar>.btn-group+.btn, .btn-toolbar>.btn+.btn-group + { + margin-left: 5px; +} + +.btn-group>.btn { + border-radius: 0; + position: relative; +} + +.btn-group>.btn+.btn { + margin-left: -1px; +} + +.btn-group>.btn, .btn-group>.dropdown-menu, .btn-group>.popover { + font-size: 14px; +} + +.btn-group>.btn-mini { + font-size: 10.5px; +} + +.btn-group>.btn-small { + font-size: 11.9px; +} + +.btn-group>.btn-large { + font-size: 17.5px; +} + +.btn-group>.btn:first-child { + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; + margin-left: 0; +} + +.btn-group>.btn:last-child, .btn-group>.dropdown-toggle { + border-bottom-right-radius: 4px; + border-top-right-radius: 4px; +} + +.btn-group>.btn.large:first-child { + border-bottom-left-radius: 6px; + border-top-left-radius: 6px; + margin-left: 0; +} + +.btn-group>.btn.large:last-child, .btn-group>.large.dropdown-toggle { + border-bottom-right-radius: 6px; + border-top-right-radius: 6px; +} + +.btn-group>.btn:hover, .btn-group>.btn:focus, .btn-group>.btn:active, + .btn-group>.btn.active { + z-index: 2; +} + +.btn-group .dropdown-toggle:active, .btn-group.open .dropdown-toggle { + outline: 0 none; +} + +.btn-group>.btn+.dropdown-toggle { + box-shadow: 1px 0 0 rgba(255, 255, 255, 0.125) inset, 0 1px 0 + rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05); + padding-left: 8px; + padding-right: 8px; +} + +.btn-group>.btn-mini+.dropdown-toggle { + padding-left: 5px; + padding-right: 5px; +} + +.btn-group>.btn-small+.dropdown-toggle { + +} + +.btn-group>.btn-large+.dropdown-toggle { + padding-left: 12px; + padding-right: 12px; +} + +.btn-group.open .dropdown-toggle { + background-image: none; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px + rgba(0, 0, 0, 0.05); +} + +.btn-group.open .btn.dropdown-toggle { + background-color: #E6E6E6; +} + +.btn-group.open .btn-primary.dropdown-toggle { + background-color: #0044CC; +} + +.btn-group.open .btn-warning.dropdown-toggle { + background-color: #F89406; +} + +.btn-group.open .btn-danger.dropdown-toggle { + background-color: #BD362F; +} + +.btn-group.open .btn-success.dropdown-toggle { + background-color: #51A351; +} + +.btn-group.open .btn-info.dropdown-toggle { + background-color: #2F96B4; +} + +.btn-group.open .btn-inverse.dropdown-toggle { + background-color: #222222; +} + +.btn .caret { + margin-left: 0; + margin-top: 8px; +} + +.btn-large .caret { + margin-top: 6px; +} + +.btn-large .caret { + border-left-width: 5px; + border-right-width: 5px; + border-top-width: 5px; +} + +.btn-mini .caret, .btn-small .caret { + margin-top: 8px; +} + +.dropup .btn-large .caret { + border-bottom-width: 5px; +} + +.btn-primary .caret, .btn-warning .caret, .btn-danger .caret, .btn-info .caret, + .btn-success .caret, .btn-inverse .caret { + border-bottom-color: #FFFFFF; + border-top-color: #FFFFFF; +} + +.btn-group-vertical { + display: inline-block; +} + +.btn-group-vertical>.btn { + border-radius: 0; + display: block; + float: none; + max-width: 100%; +} + +.btn-group-vertical>.btn+.btn { + margin-left: 0; + margin-top: -1px; +} + +.btn-group-vertical>.btn:first-child { + border-radius: 4px 4px 0 0; +} + +.btn-group-vertical>.btn:last-child { + border-radius: 0 0 4px 4px; +} + +.btn-group-vertical>.btn-large:first-child { + border-radius: 6px 6px 0 0; +} + +.btn-group-vertical>.btn-large:last-child { + border-radius: 0 0 6px 6px; +} + +/*CLOSE*/ +.close { + color: #000000; + float: right; + font-size: 20px; + font-weight: bold; + line-height: 20px; + opacity: 0.2; + text-shadow: 0 1px 0 #FFFFFF; +} + +.close:hover, .close:focus { + color: #000000; + cursor: pointer; + opacity: 0.4; + text-decoration: none; +} + +/*ALERTS*/ +.alert { + background-color: #FCF8E3; + border: 1px solid #FBEED5; + border-radius: 4px; + margin-bottom: 20px; + padding: 8px 35px 8px 14px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); +} + +.alert, .alert h4 { + color: #C09853; +} + +.alert h4 { + margin: 0; +} + +.alert .close { + line-height: 20px; + position: relative; + right: -21px; + top: -2px; +} + +.alert-success { + background-color: #DFF0D8; + border-color: #D6E9C6; + color: #468847; +} + +.alert-success h4 { + color: #468847; +} + +.alert-danger, .alert-error { + background-color: #F2DEDE; + border-color: #EED3D7; + color: #B94A48; +} + +.alert-danger h4, .alert-error h4 { + color: #B94A48; +} + +.alert-info { + background-color: #D9EDF7; + border-color: #BCE8F1; + color: #3A87AD; +} + +.alert-info h4 { + color: #3A87AD; +} + +.alert-block { + padding-bottom: 14px; + padding-top: 14px; +} + +.alert-block>p, .alert-block>ul { + margin-bottom: 0; +} + +.alert-block p+p { + margin-top: 5px; +} + +/*A LINK*/ +a { + color: #0088CC; + text-decoration: none; +} + +a:hover, a:focus { + color: #005580; + text-decoration: underline; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java index c5d8da3..f801752 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java @@ -65,7 +65,7 @@ public class ItemBuilder { } /** - * Gets the item + * Gets the item. * * @param parent the parent * @param workspaceItem the workspace item @@ -151,6 +151,7 @@ public class ItemBuilder { } } + /** * Filter item. * @@ -161,9 +162,14 @@ public class ItemBuilder { * @throws InternalErrorException the internal error exception */ protected static boolean filterItem(ItemType type, WorkspaceItem item, FilterCriteria filterCriteria) throws InternalErrorException { + if(filterCriteria==null) return true; + boolean mimeTypeCheck = checkAllowedMimeTypes(type, item, filterCriteria.getAllowedMimeTypes()); if (!mimeTypeCheck) return false; + boolean fileExtensionCheck = checkAllowedFileExtension(type, item, filterCriteria.getAllowedFileExtensions()); + if(!fileExtensionCheck) return false; + boolean propertiesCheck = checkProperties(item, filterCriteria.getRequiredProperties()); return propertiesCheck; } @@ -177,7 +183,7 @@ public class ItemBuilder { * @return true, if successful */ protected static boolean checkAllowedMimeTypes(ItemType type, WorkspaceItem item, List allowedMimeTypes){ - if (allowedMimeTypes.size()==0) return true; + if (allowedMimeTypes==null || allowedMimeTypes.size()==0) return true; if (type == ItemType.EXTERNAL_FILE || type == ItemType.EXTERNAL_IMAGE || type == ItemType.EXTERNAL_PDF_FILE) { ExternalFile externalFile = (ExternalFile)item; @@ -188,6 +194,60 @@ public class ItemBuilder { } + + + /** + * Check allowed file extension. + * + * @param type the type + * @param item the item + * @param allowedFileExtension the allowed mime types + * @return true, if successful + */ + protected static boolean checkAllowedFileExtension(ItemType type, WorkspaceItem item, List allowedFileExtension){ + if (allowedFileExtension==null || allowedFileExtension.size()==0) return true; + + try { + if (type != ItemType.FOLDER) { + String name = item.getName(); + return checkFileExtension(name, allowedFileExtension); + } + return true; + } catch (InternalErrorException e) { + _log.error("checkAllowedFileExtension, InternalErrorException: ",e); + return false; + } + } + + /** + * Check file extension. + * + * @param fileName the file name + * @param allowedFileExtension the allowed file extension + * @return true, if successful + */ + protected static boolean checkFileExtension(String fileName, List allowedFileExtension){ + + if(fileName==null || fileName.isEmpty()) return false; + + int dot = fileName.lastIndexOf("."); + if(dot>=0 && (dot+1)<=fileName.length()){ + + String ext = fileName.substring(dot+1, fileName.length()); + _log.trace("Extension found: "+ext +" for: "+fileName); +// if(ext.isEmpty()) +// return false; + for (String fe : allowedFileExtension) { + if(ext.compareTo(fe)==0) + return true; + } + return false; + } + _log.trace("Extension not found for: "+fileName); + return false; + } + + /** * Check properties. * @@ -198,7 +258,7 @@ public class ItemBuilder { */ protected static boolean checkProperties(WorkspaceItem item, Map requestedProperties) throws InternalErrorException { - if (requestedProperties.size()==0 || item.getType()!=WorkspaceItemType.FOLDER_ITEM) return true; + if (requestedProperties==null || requestedProperties.size()==0 || item.getType()!=WorkspaceItemType.FOLDER_ITEM) return true; Map itemProperties = item.getProperties().getProperties(); for (Entry requestProperty:requestedProperties.entrySet()) { @@ -247,6 +307,12 @@ public class ItemBuilder { return item; } + /** + * Checks if is special folder. + * + * @param wsFolder the ws folder + * @return true, if is special folder + */ public static boolean isSpecialFolder(WorkspaceFolder wsFolder){ try { @@ -256,4 +322,13 @@ public class ItemBuilder { return false; } } + /* + public static void main(String[] args) { + List allowedFileExtension = new ArrayList(); + allowedFileExtension.add("csv"); + allowedFileExtension.add(""); + + String fileName = "t"; + System.out.println(checkFileExtension(fileName, allowedFileExtension)); + }*/ } diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/FilterCriteria.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/FilterCriteria.java index af25a92..787ae40 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/FilterCriteria.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/FilterCriteria.java @@ -17,30 +17,68 @@ import java.util.Map; public class FilterCriteria implements Serializable { - /** - * - */ private static final long serialVersionUID = 1912760277441333686L; protected List allowedMimeTypes; protected Map requiredProperties; + protected List allowedFileExtensions; /** * Instantiates a new filter criteria. */ public FilterCriteria(){} + /** * Instantiates a new filter criteria. * * @param allowedMimeTypes the allowed mime types + * @param allowedFileExtensions the allowed file extensions * @param requiredProperties the required properties */ - public FilterCriteria(List allowedMimeTypes, - Map requiredProperties) { + public FilterCriteria(List allowedMimeTypes, List allowedFileExtensions, Map requiredProperties) { this.allowedMimeTypes = allowedMimeTypes; + this.allowedFileExtensions = allowedFileExtensions; this.requiredProperties = requiredProperties; } + /** + * Sets the allowed mime types. + * + * @param allowedMimeTypes the allowedMimeTypes to set + */ + public void setAllowedMimeTypes(List allowedMimeTypes) { + this.allowedMimeTypes = allowedMimeTypes; + } + + + /** + * Sets the required properties. + * + * @param requiredProperties the requiredProperties to set + */ + public void setRequiredProperties(Map requiredProperties) { + this.requiredProperties = requiredProperties; + } + + + /** + * Sets the allowed file extensions. + * + * @param allowedFileExtensions the allowedFileExtensions to set + */ + public void setAllowedFileExtensions(List allowedFileExtensions) { + this.allowedFileExtensions = allowedFileExtensions; + } + + /** + * Gets the allowed file extensions. + * + * @return the allowed file extensions + */ + public List getAllowedFileExtensions() { + return allowedFileExtensions; + } + /** * Gets the allowed mime types. * @@ -59,8 +97,9 @@ public class FilterCriteria implements Serializable { return requiredProperties; } - /** - * {@inheritDoc} + + /* (non-Javadoc) + * @see java.lang.Object#toString() */ @Override public String toString() { @@ -69,6 +108,8 @@ public class FilterCriteria implements Serializable { builder.append(allowedMimeTypes); builder.append(", requiredProperties="); builder.append(requiredProperties); + builder.append(", allowedFileExtensions="); + builder.append(allowedFileExtensions); builder.append("]"); return builder.toString(); } diff --git a/src/main/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml b/src/main/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml index e868b55..428fbab 100644 --- a/src/main/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml +++ b/src/main/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml @@ -2,22 +2,35 @@ - + + + + + + - - + - - + - - + - + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetChildren.java b/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetChildren.java index eba1a9e..c4f4ac7 100644 --- a/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetChildren.java +++ b/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetChildren.java @@ -39,12 +39,11 @@ public class TestGetChildren { boolean purgeEmpyFolders = false; List allowedMimeTypes = new ArrayList(); Map requiredProperties = new HashMap(); - FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties); + FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,null,null); getRoot(showableTypes, purgeEmpyFolders, filterCriteria); } - public static Item getRoot(List showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException { _log.trace("getRoot showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+ filterCriteria); @@ -92,5 +91,4 @@ public class TestGetChildren { } } - } diff --git a/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetSize.java b/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetSize.java index fcf96bd..17dcc3e 100644 --- a/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetSize.java +++ b/src/test/java/org/gcube/portlets/widgets/wsexplorer/client/TestGetSize.java @@ -54,7 +54,7 @@ public class TestGetSize { boolean purgeEmpyFolders = false; List allowedMimeTypes = new ArrayList(); Map requiredProperties = new HashMap(); - FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties); + FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,null,null); try {