diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..980d7f8 --- /dev/null +++ b/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..7c03797 --- /dev/null +++ b/.project @@ -0,0 +1,42 @@ + + + workspace-explorer + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..b72a6a4 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..443e085 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..73675e3 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..735eb31 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..278279b --- /dev/null +++ b/pom.xml @@ -0,0 +1,245 @@ + + + + maven-parent + org.gcube.tools + 1.0.0 + + + 4.0.0 + org.gcube.portlets.widgets + workspace-explorer + jar + 0.0.1-SNAPSHOT + gCube Workspace Explorer + + gCube Workspace Explorer + + + + scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId} + http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId} + + + + 2.7.0 + distro + + 1.7 + 1.7 + + UTF-8 + UTF-8 + + + + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + + + + + + + com.google.gwt + gwt-user + ${gwtVersion} + compile + + + + com.github.gwtbootstrap + gwt-bootstrap + 2.3.2.0 + + + + + org.gcube.resources.discovery + ic-client + provided + + + org.gcube.core + common-scope-maps + compile + + + + + org.gcube.applicationsupportlayer + aslcore + provided + + + + + 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 + + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + asm-all + asm + + + + + + + log4j + log4j + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + slf4j-api + + + + junit + junit + 4.11 + test + + + + + + + src/main/java + + **/*.* + + + + + + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + test-jar + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + true + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + fully.qualified.MainClass + + + + + + servicearchive + install + + single + + + + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwtVersion} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Messages.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Messages.java new file mode 100644 index 0000000..f110334 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Messages.java @@ -0,0 +1,10 @@ +package org.gcube.portlets.widgets.wsexplorer.client; + +public interface Messages extends com.google.gwt.i18n.client.Messages { + + @DefaultMessage("Enter your name") + String nameField(); + + @DefaultMessage("Send") + String sendButton(); +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Util.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Util.java new file mode 100644 index 0000000..aa93db0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/Util.java @@ -0,0 +1,55 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client; + +import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; + +/** + * The Class Util. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 18, 2015 + */ +public class Util { + + public static final ItemType[] FOLDERS = new ItemType[] { ItemType.ROOT, + ItemType.FOLDER }; + + /** + * Checks if is folder. + * + * @param type + * the type + * @return true, if is folder + */ + public static boolean isFolder(ItemType type) { + for (ItemType folder : FOLDERS) + if (type == folder) + return true; + return false; + } + + /** + * Ellipsis. + * + * @param value + * the value + * @param lenght + * the lenght + * @param left + * the left + * @return the string + */ + public static String ellipsis(String value, int lenght, boolean left) { + if (lenght < 3) + throw new IllegalArgumentException( + "The lenght have to be more than 3"); + if (value.length() > lenght) { + if (left) + return "..." + value.substring(value.length() - lenght + 3); + else + return value.substring(0, lenght - 3) + "..."; + } + return value; + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorer.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorer.java new file mode 100644 index 0000000..6663f5e --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceExplorer.java @@ -0,0 +1,16 @@ +package org.gcube.portlets.widgets.wsexplorer.client; + + +import com.google.gwt.core.client.EntryPoint; + +/** + * Entry point classes define onModuleLoad(). + */ +public class WorkspaceExplorer implements EntryPoint { + + /** + * This is the entry point method. + */ + public void onModuleLoad() { + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorConstants.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorConstants.java new file mode 100644 index 0000000..ccdeb4a --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorConstants.java @@ -0,0 +1,11 @@ +package org.gcube.portlets.widgets.wsexplorer.client; + +public class WorkspaceNavigatorConstants { + public static final String SPECIAL_FOLDERS_LABEL = "MySpecialFolders"; + + public static final String VRE_FOLDERS_LABEL = "My VRE Folders"; + + public static final String WORKSPACE_EXPLORER_CAPTION = "Workspace Explorer"; + + public static final String HOME_LABEL = "Home"; +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorDialog.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorDialog.java new file mode 100644 index 0000000..742c471 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorDialog.java @@ -0,0 +1,119 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; + + +/** + * The Class WorspaceNavigatorDialog. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 24, 2015 + */ +public class WorkspaceNavigatorDialog extends DialogBox implements ClickHandler { + + /** + * + */ + + private Button cancel; + private WorkspaceNavigatorDialog INSTANCE = this; + private boolean isValidHide; + private String captionTxt; + private WorkspaceNavigatorPanel wsp = new WorkspaceNavigatorPanel(5); + + /** + * Instantiates a new worspace navigator dialog. + * + * @param captionTxt sets the text inside the caption, if null sets "Workspace Explorer" + */ + public WorkspaceNavigatorDialog(String captionTxt) { + this.captionTxt = (captionTxt==null || captionTxt.isEmpty())?WorkspaceNavigatorConstants.WORKSPACE_EXPLORER_CAPTION:captionTxt; + setText(this.captionTxt); + isValidHide = false; + cancel = new Button("Close"); + + DockPanel dock = new DockPanel(); + dock.setSpacing(5); + + // dock.add(okButton, DockPanel.SOUTH); + // dock.add(cancel, DockPanel.SOUTH); + + HorizontalPanel hp = new HorizontalPanel(); + hp.setStyleName("margin-auto"); +//// hp.add(okButton); +// hp.setWidth("50%"); +// hp.setStyleAttribute("margin", "0 auto"); + hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + cancel.getElement().getStyle().setMarginTop(5.0, Unit.PX); +// cancel.getElement().getStyle().setMarginBottom(5.0, Unit.PX); +// hp.getElement().getStyle().setMarginLeft("0 auto", Unit.PCT); + hp.add(cancel); + dock.add(hp, DockPanel.SOUTH); + + dock.add(wsp, DockPanel.CENTER); + + dock.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + dock.setWidth("100%"); + setWidget(dock); + +// okButton.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// +// } +// }); + cancel.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + isValidHide = false; + INSTANCE.hide(); + } + }); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event + * .dom.client.ClickEvent) + */ + @Override + public void onClick(ClickEvent event) { + hide(); + } + + + /** + * @return the captionTxt + */ + public String getCaptionTxt() { + return captionTxt; + } + + /** + * Checks if is valid hide. + * + * @return the isValidHide + */ + public boolean isValidHide() { + return isValidHide; + } + + @Override + public void show() { + super.show(); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorPanel.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorPanel.java new file mode 100644 index 0000000..7fbba9a --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/WorkspaceNavigatorPanel.java @@ -0,0 +1,67 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client; + +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.WorkspaceNavigator; + +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.ScrollPanel; + + +/** + * The Class SplitPanel. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 23, 2015 + */ +public class WorkspaceNavigatorPanel extends DockPanel{ + + public int width = 550; + public int height = 400; + public int west_width = 130; + + private ScrollPanel westPanel = new ScrollPanel(); + private ScrollPanel centerScrollable = new ScrollPanel(); + private Breadcrumbs breadcrumbs = new Breadcrumbs(); + private Navigation navigation = new Navigation(); + private WorkspaceNavigator wsExplorer = new WorkspaceNavigator(); + /** + * Instantiates a new split panel. + */ + public WorkspaceNavigatorPanel(int splitterSize) { +// setStyleName("cw-DockPanel"); + ensureDebugId("WorkspaceNavigatorPanel"); + setSpacing(4); +// setHorizontalAlignment(DockPanel.ALIGN_CENTER); + + add(breadcrumbs, DockPanel.NORTH); +// northPanel.add(breadcrumbs); + westPanel.setWidth(west_width+"px"); + westPanel.add(navigation); + add(westPanel, DockPanel.WEST); + + centerScrollable.setSize(width+"px", height+"px"); + centerScrollable.add(wsExplorer.getExplorerPanel()); + add(centerScrollable, DockPanel.CENTER); + } + + /** + * @return the westPanel + */ + public ScrollPanel getWestPanel() { + return westPanel; + } + + /** + * @return the centerScrollable + */ + public ScrollPanel getCenterScrollable() { + return centerScrollable; + } +} + + + diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/AbstractItemsCellTable.java new file mode 100644 index 0000000..5449598 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/AbstractItemsCellTable.java @@ -0,0 +1,180 @@ +package org.gcube.portlets.widgets.wsexplorer.client.grid; + +import java.util.List; + +import org.gcube.portlets.widgets.wsexplorer.client.resources.CellTableResources; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; + +import com.github.gwtbootstrap.client.ui.CellTable; +import com.github.gwtbootstrap.client.ui.Pagination; +import com.google.gwt.core.shared.GWT; +import com.google.gwt.event.dom.client.DoubleClickEvent; +import com.google.gwt.event.dom.client.DoubleClickHandler; +import com.google.gwt.user.cellview.client.AbstractCellTable; +import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.view.client.ListDataProvider; +import com.google.gwt.view.client.SelectionChangeEvent; +import com.google.gwt.view.client.SelectionChangeEvent.Handler; +import com.google.gwt.view.client.SingleSelectionModel; + +/** + * The Class AbstractItemTable. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 19, 2015 + */ +public abstract class AbstractItemsCellTable { + + protected CellTable cellTable; + protected ListDataProvider dataProvider = new ListDataProvider(); + protected boolean showGroupId; + + /** + * Inits the table. + * + * @param ItemTable + * the Item table + * @param pager + * the pager + * @param pagination + * the pagination + */ + public abstract void initTable(AbstractCellTable ItemTable, + final SimplePager pager, final Pagination pagination); + + /** + * Instantiates a new abstract Item table. + * + * @param showGroupId + * the show group id + */ + public AbstractItemsCellTable(boolean showGroupId) { + this.showGroupId = showGroupId; + cellTable = new CellTable(1, CellTableResources.INSTANCE); + cellTable.addStyleName("table-overflow"); + cellTable.setStriped(true); + cellTable.setBordered(true); +// cellTable.setCondensed(true); + cellTable.setWidth("98%", true); + dataProvider.addDataDisplay(cellTable); + initTable(cellTable, null, null); + cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); + + final SingleSelectionModel ssm = new SingleSelectionModel(); + cellTable.setSelectionModel(ssm); + ssm.addSelectionChangeHandler(new Handler() { + @Override + public void onSelectionChange(final SelectionChangeEvent event) + { + final Item selectedObject = ssm.getSelectedObject(); + GWT.log("Clicked: "+selectedObject); + } + }); + + cellTable.addDomHandler(new DoubleClickHandler() { + + @Override + public void onDoubleClick(final DoubleClickEvent event) { + Item selected = ssm.getSelectedObject(); + if (selected != null) { + GWT.log("Double Click: "+selected); + } + } + }, + DoubleClickEvent.getType()); + /* + cellTable.addCellPreviewHandler(new CellPreviewEvent.Handler () { + long lastClick=-1000; + + @Override + public void onCellPreview(CellPreviewEvent event) { + long clictAt = System.currentTimeMillis(); + GWT.log("clickAt: "+(clictAt)); + GWT.log("lastClick: "+(lastClick)); + if(event.getNativeEvent().getType().contains("click")){ + GWT.log(""+(clictAt-lastClick)); + if(clictAt-lastClick < 300) { // dblclick on 2 clicks detected within 300 ms + Window.alert("I am a double click crafted event!"); + } + lastClick = System.currentTimeMillis(); + } + + } + }); */ + } + + /** + * Adds the Items. + * + * @param Items + * the Items + */ + public void addItems(List Items) { + dataProvider.getList().clear(); + + for (Item pckg : Items) + addItem(pckg); + + cellTable.setPageSize(Items.size() + 1); + cellTable.redraw(); + } + + /** + * Adds the Item. + * + * @param pckg + * the pckg + */ + private void addItem(Item pckg) { + dataProvider.getList().add(pckg); + dataProvider.flush(); + dataProvider.refresh(); + } + + /** + * Gets the cell tables. + * + * @return the cell tables + */ + public CellTable getCellTable() { + return cellTable; + } + + /** + * Gets the data provider. + * + * @return the data provider + */ + public ListDataProvider getDataProvider() { + return dataProvider; + } + + /** + * Checks if is show group id. + * + * @return true, if is show group id + */ + public boolean isShowGroupId() { + return showGroupId; + } + + /** + * Sets the data provider. + * + * @param dataProvider + * the new data provider + */ + public void setDataProvider(ListDataProvider dataProvider) { + this.dataProvider = dataProvider; + } + + /** + * Sets the show group id. + * + * @param showGroupId + * the new show group id + */ + public void setShowGroupId(boolean showGroupId) { + this.showGroupId = showGroupId; + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/ItemsTable.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/ItemsTable.java new file mode 100644 index 0000000..e988c50 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/grid/ItemsTable.java @@ -0,0 +1,208 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client.grid; + +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.gcube.portlets.widgets.wsexplorer.shared.Item; + +import com.github.gwtbootstrap.client.ui.Pagination; +import com.google.gwt.cell.client.Cell.Context; +import com.google.gwt.cell.client.ImageResourceCell; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.cellview.client.AbstractCellTable; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.user.cellview.client.TextColumn; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.view.client.SelectionChangeEvent; +import com.google.gwt.view.client.SelectionChangeEvent.Handler; +import com.google.gwt.view.client.SingleSelectionModel; +/** + * The Class PackagesTable. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 19, 2015 + */ +public class ItemsTable extends AbstractItemsCellTable{ + + private Column icon; + private TextColumn name; + private TextColumn owner; + private TextColumn lastModified; + /** + * Instantiates a new packages table. + * + * @param showGroupId the show group id + */ + public ItemsTable(boolean showGroupId) { + super(showGroupId); + + } + + /* (non-Javadoc) + * @see org.gcube.portlets.admin.gcubereleases.client.view.AbstractPackageTable#addPackages(java.util.List) + */ + public void addItems(List packages) { + dataProvider.getList().clear(); + + for (Item pckg : packages) + addItem(pckg); + + cellTable.setPageSize(packages.size()+1); + cellTable.redraw(); + } + + /** + * Adds the package. + * + * @param pckg the pckg + */ + private void addItem(Item pckg) { + dataProvider.getList().add(pckg); + dataProvider.flush(); + dataProvider.refresh(); + } + + /* (non-Javadoc) + * @see org.gcube.portlets.admin.gcubereleases.client.view.AbstractPackageTable#initTable(com.google.gwt.user.cellview.client.AbstractCellTable, com.google.gwt.user.cellview.client.SimplePager, com.github.gwtbootstrap.client.ui.Pagination) + */ + @Override + public void initTable(AbstractCellTable packageTable, final SimplePager pager, final Pagination pagination) { + packageTable.setEmptyTableWidget(new Label("No data.")); + + double artifactIDWidht = 40.0; + + //ICONS + ImageResourceCell iconResourceCell = new ImageResourceCell() { + public Set getConsumedEvents() { + HashSet events = new HashSet(); + events.add("click"); + return events; + } + + }; + + icon = new Column(iconResourceCell) { + @Override + public ImageResource getValue(Item dataObj) { + +// if(dataObj.getURL()!=null && !dataObj.getURL().isEmpty()) +// return Icons.ICONS.download(); + + return null; + } + + @Override + public void onBrowserEvent(Context context, Element elem, Item object, NativeEvent event) { + super.onBrowserEvent(context, elem, object, event); + if ("click".equals(event.getType())) { +// Window.open(object.getURL(), "_blank", ""); +// GcubeReleasesAppController.eventBus.fireEvent(new PackageClickEvent(object, AccoutingReference.DOWNLOAD)); + } + } + + /* (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) { + super.render(context, object, sb); + + } + }; + + //ARTIFACT ID + name = new TextColumn() { + @Override + public String getValue(Item object) { + return object.getName(); + } + }; + name.setSortable(true); + packageTable.addColumn(name, "Name"); + packageTable.setColumnWidth(name, artifactIDWidht, Unit.PCT); + + ListHandler nameColumnHandler = new ListHandler(dataProvider.getList()); + nameColumnHandler.setComparator(name, new Comparator() { + @Override + public int compare(Item o1, Item o2) { + return o1.getName().compareTo(o2.getName()); + } + }); + + packageTable.addColumnSortHandler(nameColumnHandler); + /* + owner = new TextColumn() { + @Override + public String getValue(Item object) { + return object.getVersion() != null ? object.getVersion() : ""; + } + }; + + owner.setCellStyleNames("img-centered-clickable"); + owner.setSortable(true); + packageTable.addColumn(owner, "Version"); + + packageTable.setColumnWidth(owner, 10.0, Unit.PCT); + */ + + icon.setCellStyleNames("img-centered-clickable"); + icon.setSortable(false); + packageTable.addColumn(icon, "Download"); + packageTable.setColumnWidth(icon, 10.0, Unit.PCT); + + //MAVEN COORDS + ImageResourceCell myImgMavenCell = new ImageResourceCell() { + public Set getConsumedEvents() { + HashSet events = new HashSet(); + events.add("click"); + return events; + } + }; + + /* + //AS LINK + final SafeHtmlRenderer mvnCoordinatesRenderer = new AbstractSafeHtmlRenderer() { + @Override + public SafeHtml render(String object) { + SafeHtmlBuilder sb = new SafeHtmlBuilder(); + sb.appendHtmlConstant("").appendEscaped("Maven Repo").appendHtmlConstant(""); + return sb.toSafeHtml(); + } + }; + + mvnCoordinates = new Column(new ClickableTextCell(mvnCoordinatesRenderer)) { + @Override + public String getValue(Package object) { + return "http://maven.research-infrastructures.eu/nexus/index.html#nexus-search;quick~"+object.getArtifactID(); + } + }; + */ +// mvn.setSortable(false); + + final SingleSelectionModel selectionModel = new SingleSelectionModel(); + selectionModel.addSelectionChangeHandler(new Handler() { + @Override + public void onSelectionChange(SelectionChangeEvent event) { +// Package p = selectionModel.getSelectedObject(); + // CellTables.this.driver.edit(person); + } + }); + +// exampleTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); +// packageTable.setSelectionModel(selectionModel); + // pager.setDisplay(exampleTable); + // pagination.clear(); + + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTable.css b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTable.css new file mode 100644 index 0000000..987d0c8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTable.css @@ -0,0 +1,251 @@ +/* * Copyright 2010 Google Inc . */ +/* * */ +/* * Licensed under the Apache License, Version 2.0 (the "License "); you may not */ +/* * use this file except in compliance with the License . You may obtain a copy of */ +/* * the License at */ +/* * */ +/* * http: //www.apache.org /licenses/LICENSE-2.0 */ +/* * */ +/* * Unless required by applicable law or agreed to in writing, software */ +/* * distributed under the License is distributed on an "AS IS " BASIS, */ +/* WITHOUT */ +/* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied . See the */ +/* * License for the specific language governing permissions and limitations under */ +/* * the License . */ +/* * / */ +/* @def selectionBorderWidth 2px ; */ +/* .cellTableWidget { */ + +/* } */ + +/* .cellTableFirstColumn { */ + +/* } */ + +/* .cellTableLastColumn { */ + +/* } */ + +/* .cellTableFooter { */ +/* border-top: 2px solid #6f7277; */ +/* padding: 3px 15px; */ +/* text-align: left; */ +/* color: #4b4a4a; */ +/* text-shadow: #ddf 1px 1px 0; */ +/* overflow: hidden; */ +/* } */ + +/* .cellTableHeader { */ +/* border-bottom: 2px solid #6f7277; */ +/* padding: 3px 15px; */ +/* text-align: left; */ +/* color: #4b4a4a; */ +/* text-shadow: #ddf 1px 1px 0; */ +/* overflow: hidden; */ +/* } */ + +/* .cellTableCell { */ +/* padding: 2px 15px; */ +/* overflow: hidden; */ +/* } */ + +/* .cellTableFirstColumnFooter { */ + +/* } */ + +/* .cellTableFirstColumnHeader { */ + +/* } */ + +/* .cellTableLastColumnFooter { */ + +/* } */ + +/* .cellTableLastColumnHeader { */ + +/* } */ + +/* .cellTableSortableHeader { */ +/* cursor: pointer; */ +/* cursor: hand; */ +/* } */ + +/* .cellTableSortableHeader:hover { */ +/* color: #6c6b6b; */ +/* } */ + +/* .cellTableSortedHeaderAscending { */ + +/* } */ + +/* .cellTableSortedHeaderDescending { */ + +/* } */ + +/* .cellTableEvenRow { */ +/* background: #ffffff; */ +/* } */ + +/* .cellTableEvenRowCell { */ +/* border: selectionBorderWidth solid #ffffff; */ +/* } */ + +/* .cellTableOddRow { */ +/* background: #f3f7fb; */ +/* } */ + +/* .cellTableOddRowCell { */ +/* border: selectionBorderWidth solid #f3f7fb; */ +/* } */ + +/* .cellTableHoveredRow { */ +/* background: #eee; */ +/* } */ + +/* .cellTableHoveredRowCell { */ +/* border: selectionBorderWidth solid #eee; */ +/* } */ + +/* .cellTableKeyboardSelectedRow { */ +/* background: #ffc; */ +/* } */ + +/* .cellTableKeyboardSelectedRowCell { */ +/* border: selectionBorderWidth solid #ffc; */ +/* } */ + +/* .cellTableSelectedRow { */ +/* background: #628cd5; */ +/* color: white; */ +/* height: auto; */ +/* overflow: auto; */ +/* } */ + +/* .cellTableSelectedRowCell { */ +/* border: selectionBorderWidth solid #628cd5; */ +/* } */ +/* /** */ +/* * The keyboard selected cell is visible over selection. */ +/* */ +* / + /* .cellTableKeyboardSelectedCell { */ + /* border: selectionBorderWidth solid #d7dde8; */ + /* } */ + /* .cellTableLoading { */ + /* margin: 30px; */ + /* } */ + + @def selectionBorderWidth 1px ; .cellTableWidget { + +} + +.cellTableFirstColumn { + +} + +.cellTableLastColumn { + +} + +.cellTableFooter { + +} + +.cellTableHeader { +} + +.cellTableCell { + +} + +.cellTableFirstColumnFooter { + +} + +.cellTableFirstColumnHeader { + +} + +.cellTableLastColumnFooter { + +} + +.cellTableLastColumnHeader { + +} + +.cellTableSortableHeader { + +} + +.cellTableSortableHeader:hover { + +} + +.cellTableSortedHeaderAscending { + +} + +.cellTableSortedHeaderDescending { + +} + +.cellTableEvenRow { + +} + +.cellTableEvenRowCell { + +} + +.cellTableOddRow { + +} + +.cellTableOddRowCell { + +} + +.cellTableHoveredRow { + background: #D9EDF7 !important; + cursor: pointer; +} + +.cellTableHoveredRowCell { + background: #D9EDF7 !important; + cursor: pointer; +} + +.cellTableKeyboardSelectedRow, .cellTableKeyboardSelectedRow td, + .cellTableKeyboardSelectedRow th { + background: #3A87AD !important; +} + +.cellTableSelectedRow, .cellTableSelectedRow td, .cellTableSelectedRow th + { + /* background: #D9EDF7 !important; */ + /* color: white !important; */ + /* height: auto; */ + /* overflow: auto; */ + +} + +.cellTableSelectedRowCell, .cellTableSelectedRow td.cellTableSelectedRowCell + { + background: #3A87AD !important; +} + +.cellTableKeyboardSelectedRowCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedRowCell + { + background: #3A87AD !important; +} + +.cellTableKeyboardSelectedCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedCell + { + background: #3A87AD !important; + color: white !important; +} + +.cellTableLoading { + margin: 30px; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTableResources.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTableResources.java new file mode 100644 index 0000000..442c771 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/CellTableResources.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client.resources; + +import com.github.gwtbootstrap.client.ui.CellTable; +import com.github.gwtbootstrap.client.ui.CellTable.Resources; +import com.google.gwt.core.shared.GWT; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 23, 2015 + */ +public interface CellTableResources extends Resources { + + public CellTableResources INSTANCE = GWT.create(CellTableResources.class); + + // The styles used in this widget. + @Override + @Source("CellTable.css") + CellTable.Style cellTableStyle(); +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Icons.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Icons.java new file mode 100644 index 0000000..652eadd --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Icons.java @@ -0,0 +1,11 @@ +package org.gcube.portlets.widgets.wsexplorer.client.resources; + +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; + +public interface Icons extends ClientBundle { + + @Source("cancel.png") + ImageResource cancel(); +} + diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Resources.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Resources.java new file mode 100644 index 0000000..7cf05f5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/Resources.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.widgets.wsexplorer.client.resources; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.ui.AbstractImagePrototype; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * + */ +public class Resources { + + public static final Icons ICONS = GWT.create(Icons.class); + + + public static AbstractImagePrototype getIconCancel(){ + + return AbstractImagePrototype.create(ICONS.cancel()); + } + public static ImageResource getImageCancel() { + return ICONS.cancel(); + } + + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/cancel.png b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/cancel.png new file mode 100644 index 0000000..9aa895b Binary files /dev/null and b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/resources/cancel.png differ diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerService.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerService.java new file mode 100644 index 0000000..541b781 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerService.java @@ -0,0 +1,57 @@ +package org.gcube.portlets.widgets.wsexplorer.client.rpc; + +import java.util.List; + +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; +import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; +import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +/** + * The client side stub for the RPC service. + */ +@RemoteServiceRelativePath("greet") +public interface WorkspaceExplorerService extends RemoteService { + + /** + * @param itemIdentifier + * @param includeItemAsParent + * @return + * @throws Exception + */ + List getListParentsByItemIdentifier(String itemIdentifier, + boolean includeItemAsParent) throws Exception; + + /** + * @param name + * @return + * @throws WorkspaceNavigatorServiceException + */ + boolean checkName(String name) throws WorkspaceNavigatorServiceException; + + /** + * @param folderId + * @param showableTypes + * @param purgeEmpyFolders + * @param filterCriteria + * @return + * @throws WorkspaceNavigatorServiceException + */ + Item getFolder(String folderId, List showableTypes, + boolean purgeEmpyFolders, FilterCriteria filterCriteria) + throws WorkspaceNavigatorServiceException; + + /** + * @param showableTypes + * @param purgeEmpyFolders + * @param filterCriteria + * @return + * @throws WorkspaceNavigatorServiceException + */ + Item getRoot(List showableTypes, boolean purgeEmpyFolders, + FilterCriteria filterCriteria) + throws WorkspaceNavigatorServiceException; +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerServiceAsync.java new file mode 100644 index 0000000..2cb31d9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/rpc/WorkspaceExplorerServiceAsync.java @@ -0,0 +1,78 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client.rpc; + +import java.util.List; + +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; +import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; + +import com.google.gwt.user.client.rpc.AsyncCallback; + + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 24, 2015 + */ +public interface WorkspaceExplorerServiceAsync { + + /** + * Gets the root. + * + * @param showableTypes + * the showable types + * @param purgeEmpyFolders + * the purge empy folders + * @param filterCriteria + * the filter criteria + * @param callback + * the callback + * @return the root + */ + public void getRoot(List showableTypes, boolean purgeEmpyFolders, + FilterCriteria filterCriteria, AsyncCallback callback); + + /** + * Check name. + * + * @param name + * the name + * @param callback + * the callback + */ + public void checkName(String name, AsyncCallback callback); + + /** + * Gets the folder. + * + * @param folderId + * the folder id + * @param showableTypes + * the showable types + * @param purgeEmpyFolders + * the purge empy folders + * @param filterCriteria + * the filter criteria + * @param callback + * the callback + * @return the folder + */ + public void getFolder(String folderId, List showableTypes, + boolean purgeEmpyFolders, FilterCriteria filterCriteria, + AsyncCallback callback); + + /** + * Gets the list parents by item identifier. + * + * @param itemIdentifier the item identifier + * @param includeItemAsParent the include item as parent + * @param callback the callback + * @return the list parents by item identifier + */ + public void getListParentsByItemIdentifier(String itemIdentifier, + boolean includeItemAsParent, AsyncCallback> callback); + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.java new file mode 100644 index 0000000..87042ad --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.java @@ -0,0 +1,137 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client.view; + +import java.util.LinkedHashMap; +import java.util.List; + +import org.gcube.portlets.widgets.wsexplorer.shared.Item; + +import com.github.gwtbootstrap.client.ui.NavLink; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class Breadcrumbs. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 23, 2015 + */ +public class Breadcrumbs extends Composite { + + public static final String DIVIDER = ">"; + private LinkedHashMap hashFileModel = new LinkedHashMap();// Ordered-HashMap + private Item lastParent; + private static BreadcrumbsUiBinder uiBinder = GWT.create(BreadcrumbsUiBinder.class); + private NavLink homeLink = new NavLink("Home"); + + @UiField + com.github.gwtbootstrap.client.ui.Breadcrumbs breadcrumbs; + + /** + * The Interface BreadcrumbsUiBinder. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 23, + * 2015 + */ + interface BreadcrumbsUiBinder extends UiBinder { + } + + /** + * Instantiates a new breadcrumbs. + * + * @param rootName + * the root name + */ + public Breadcrumbs() { + initWidget(uiBinder.createAndBindUi(this)); + breadcrumbs.setDivider(DIVIDER); + initBreadcrumbs(); + // initBreadcrumb(true); + this.addStyleName("breadcrumbs-navigator"); + } + + /** + * Sets the path. + * + * @param parents + * the new path + */ + public void setPath(List parents) { + initBreadcrumbs(); + if (parents != null && parents.size() > 0) { + hashFileModel = new LinkedHashMap(); + for (Item parent : parents) { + addNavigationLink(parent); + hashFileModel.put(parent.getId(), parent); + } + lastParent = parents.get(parents.size() - 1); + } + } + + /** + * Reset breadcrumbs. + */ + private void initBreadcrumbs() { + breadcrumbs.clear(); + breadcrumbs.add(new NavLink(""));// INIT + breadcrumbs.add(homeLink);// INIT + breadcrumbs.add(new NavLink("2"));// INIT + } + + // @UiHandler("add") + /** + * Adds the navigation link. + * + * @param parent + * the parent + */ + public void addNavigationLink(Item parent) { + if (parent != null && parent.getParent() != null) { + final NavLink navLink = new NavLink(parent.getName()); + navLink.setName(parent.getId()); + breadcrumbs.add(navLink); + + navLink.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + Item target = hashFileModel.get(navLink.getName()); + } + }); + } else { // is Root + // final NavLink navLink = new NavLink(""); + NavLink navLink = new NavLink(""); + breadcrumbs.add(navLink);// INIT + } + } + + /** + * Breadcrumb is empty. + * + * @return true, if successful + */ + public boolean breadcrumbIsEmpty() { + + if (hashFileModel.size() == 0) + return true; + + return false; + } + + /** + * Gets the last parent. + * + * @return the last parent + */ + public Item getLastParent() { + return lastParent; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.ui.xml b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.ui.xml new file mode 100644 index 0000000..60a48c2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Breadcrumbs.ui.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.java new file mode 100644 index 0000000..eb87bd2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.java @@ -0,0 +1,55 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.client.view; + +import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceNavigatorConstants; + +import com.github.gwtbootstrap.client.ui.NavWidget; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 24, 2015 + */ +public class Navigation extends Composite{ + + private static NavigationUiBinder uiBinder = GWT.create(NavigationUiBinder.class); + + @UiField + NavWidget home; + + @UiField + NavWidget vre_folder; + + /** + * The Interface BreadcrumbsUiBinder. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 23, 2015 + */ + interface NavigationUiBinder extends UiBinder { + } + + /** + * + */ + public Navigation() { + initWidget(uiBinder.createAndBindUi(this)); + getElement().getStyle().setMarginLeft(5.0, Unit.PX); + home.setActive(true); + home.setText(WorkspaceNavigatorConstants.HOME_LABEL); + home.setIcon(IconType.HOME); + + vre_folder.setActive(true); + vre_folder.setText(WorkspaceNavigatorConstants.VRE_FOLDERS_LABEL); + vre_folder.setIcon(IconType.FOLDER_OPEN_ALT); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.ui.xml b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.ui.xml new file mode 100644 index 0000000..978e0af --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/Navigation.ui.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceNavigator.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceNavigator.java new file mode 100644 index 0000000..c85969c --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/view/WorkspaceNavigator.java @@ -0,0 +1,133 @@ +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.grid.ItemsTable; +import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService; +import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerServiceAsync; +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; +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.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.ScrollPanel; + +/** + * Entry point classes define onModuleLoad(). + */ +public class WorkspaceNavigator { + + private final WorkspaceExplorerServiceAsync workspaceNavigatorService = GWT.create(WorkspaceExplorerService.class); + protected static final HorizontalPanel LOADING_PANEL = new HorizontalPanel(); + + static { + LOADING_PANEL.setSpacing(3); + // LOADING_PANEL.add(LOADING_IMAGE); + LOADING_PANEL.add(new HTML("Loading...")); + } + protected List selectableTypes = new ArrayList(); + protected List showableTypes = new ArrayList(); + protected List allowedMimeTypes = new ArrayList(); + protected boolean showEmptyFolders = true; + protected Map requiredProperties = new HashMap(); + /** + * Create a remote service proxy to talk to the server-side Greeting + * service. + */ + + protected ScrollPanel explorerPanel; + + public WorkspaceNavigator() { + // 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(); + } + + /** + * Set the panel in loading mode. + */ + protected void setLoading() { + explorerPanel.clear(); + explorerPanel.add(LOADING_PANEL); + } + + /** + * Load the Workspace Tree. + */ + public void loadTree() { + GWT.log("loading tree data"); + setLoading(); + + // we make a copy of showable types + List showableTypesParam = new ArrayList( + showableTypes); + + // we get sure that folders are displayed + for (ItemType folder : Util.FOLDERS) { + if (!showableTypesParam.contains(folder)) + showableTypesParam.add(folder); + } + + boolean purgeEmpyFolders = !showEmptyFolders; + + FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes, + requiredProperties); + + GWT.log("loading workspace tree from server"); + + workspaceNavigatorService.getRoot(showableTypesParam, purgeEmpyFolders, + filterCriteria, new AsyncCallback() { + + + public void onFailure(Throwable caught) { + GWT.log("Error loading workspace tree from server", + caught); + // showErrorPanel(caught); + // DataLoadEvent.fireLoadDataFailed(WorkspaceLightTreePanel.this, + // caught); + } + + public void onSuccess(Item root) { + GWT.log("workspace tree retrieved."); + // tree.setRootItem(root); + + // we select the root + // tree.selectItem(root.getId()); + + // then we remove the loading icon + explorerPanel.clear(); + ItemsTable itTables = new ItemsTable(false); + itTables.addItems(root.getChildren()); + explorerPanel.add(itTables.getCellTable()); + + GWT.log("workspace tree loaded"); + // DataLoadEvent.fireLoadDataSuccess(WorkspaceLightTreePanel.this); + } + + }); + } + + /** + * @return the explorerPanel + */ + public ScrollPanel getExplorerPanel() { + return explorerPanel; + } + + +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/public/workspace-explorer.css b/src/main/java/org/gcube/portlets/widgets/wsexplorer/public/workspace-explorer.css new file mode 100644 index 0000000..b40ed47 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/public/workspace-explorer.css @@ -0,0 +1,16 @@ +.margin-auto { + margin: 0 auto; +/* width: 50%; */ +} + +.table-overflow td, th { + overflow: hidden !important; +} + +.table-overflow th{ + text-align: center !important; +} + +.breadcrumbs-navigator .breadcrumb { + margin-bottom: 3px !important; +} \ 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 new file mode 100644 index 0000000..bd58171 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemBuilder.java @@ -0,0 +1,159 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.server; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import org.gcube.common.homelibary.model.items.type.WorkspaceItemType; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; +import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; +import org.gcube.portlets.widgets.wsexplorer.client.Util; +import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceNavigatorConstants; +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; +import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; + +/** + * @author Federico De Faveri defaveri@isti.cnr.it + * Modified by Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + */ +public class ItemBuilder { + + public static Item purgeEmptyFolders(Item item) + { + for (Item child:item.getChildren()) purgeEmptyFolders(child); + + List toRemoveList = new LinkedList(); + for (Item child:item.getChildren()) { + boolean toRemove = isAnEmptyFolder(child); + if (toRemove) toRemoveList.add(child); + } + for (Item child:toRemoveList) item.removeChild(child); + + return item; + } + + protected static boolean isAnEmptyFolder(Item item) + { + return Util.isFolder(item.getType()) && item.getChildren().size() == 0; + } + + /** + * + * @param parent + * @param workspaceItem + * @param showableTypes + * @param depth + * @return + * @throws InternalErrorException + */ + public static Item getItem(Item parent, WorkspaceItem workspaceItem, List showableTypes, FilterCriteria filterCriteria, int depth) throws InternalErrorException + { +// System.out.println("\n\n workspaceItem: " + workspaceItem.getName() + ", depth : "+depth); + + if (depth == 0) return null; + + ItemType type = getItemType(workspaceItem); + + if (!showableTypes.contains(type)) return null; + if (!filterItem(type, workspaceItem, filterCriteria)) return null; + +// Added in date 26/06/2012 by Francesco Mangiacrapa +// Item item = new Item(parent, workspaceItem.getId(), workspaceItem.getName(), type, workspaceItem.getPath()); + + String itemName = workspaceItem.getName(); + if ( workspaceItem.getName().equals(WorkspaceNavigatorConstants.SPECIAL_FOLDERS_LABEL)) { + itemName = "My VRE Folders"; + } + + Item item = new Item(parent, workspaceItem.getId(), itemName, type, ""); + item.setShared(workspaceItem.getType()==WorkspaceItemType.SHARED_FOLDER); + + Item empty = null; + + // Add temporary item + if(Util.isFolder(item.getType())){ + empty = new Item(parent, UUID.randomUUID().toString(), "empty", ItemType.UNKNOWN_TYPE, ""); + item.addChild(empty); + } + + if(depth==1) return item; + + for (WorkspaceItem child: workspaceItem.getChildren()){ + Item itemChild = getItem(item, child, showableTypes, filterCriteria, depth-1); + if (itemChild!=null){ +// item.removeChild(empty); + item.addChild(itemChild); + } + } + + // Remove the temporary item when we finish loading + if(Util.isFolder(item.getType())&& item.getChildren().size()>1) + item.removeChild(empty); + + return item; + } + + protected static ItemType getItemType(WorkspaceItem item) throws InternalErrorException + { + switch(item.getType()) + { + case SHARED_FOLDER: + case FOLDER:{ + if (item.isRoot()) return ItemType.ROOT; + return ItemType.FOLDER; + } + case FOLDER_ITEM: return getFolderItemType((FolderItem) item); + } + return null; + } + + protected static ItemType getFolderItemType(FolderItem item) + { + //System.out.println("getFolderItemType "+item.getFolderItemType().toString()); + return ItemType.valueOf(item.getFolderItemType().toString()); + } + + protected static boolean filterItem(ItemType type, WorkspaceItem item, FilterCriteria filterCriteria) throws InternalErrorException + { + boolean mimeTypeCheck = checkAllowedMimeTypes(type, item, filterCriteria.getAllowedMimeTypes()); + if (!mimeTypeCheck) return false; + + boolean propertiesCheck = checkProperties(item, filterCriteria.getRequiredProperties()); + return propertiesCheck; + } + + protected static boolean checkAllowedMimeTypes(ItemType type, WorkspaceItem item, List allowedMimeTypes) + { + if (allowedMimeTypes.size()==0) return true; + + if (type == ItemType.EXTERNAL_FILE || type == ItemType.EXTERNAL_IMAGE || type == ItemType.EXTERNAL_PDF_FILE) { + ExternalFile externalFile = (ExternalFile)item; + String mimeType = externalFile.getMimeType(); + return allowedMimeTypes.contains(mimeType); + } + return true; + } + + + protected static boolean checkProperties(WorkspaceItem item, Map requestedProperties) throws InternalErrorException + { + if (requestedProperties.size()==0 || item.getType()!=WorkspaceItemType.FOLDER_ITEM) return true; + + Map itemProperties = item.getProperties().getProperties(); + for (Entry requestProperty:requestedProperties.entrySet()) { + String propertyValue = itemProperties.get(requestProperty.getKey()); + if (propertyValue == null) return false; + if (!propertyValue.equals(requestProperty.getValue())) return false; + } + + return true; + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemComparator.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemComparator.java new file mode 100644 index 0000000..729571e --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/ItemComparator.java @@ -0,0 +1,40 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.server; + +import java.util.Comparator; + +import org.gcube.portlets.widgets.wsexplorer.client.Util; +import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceNavigatorConstants; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; + + +/** + * A comparator that sorts the items first by type, folder up others down, the each group alphabetically on the item name. + * @author "Federico De Faveri defaveri@isti.cnr.it" + */ +public class ItemComparator implements Comparator { + + /** + * {@inheritDoc} + */ + @Override + public int compare(Item item1, Item item2) { + + //if one of the item is folder and the other one not, we move up the folder + boolean isItem1Folder = Util.isFolder(item1.getType()); + boolean isItem2Folder = Util.isFolder(item2.getType()); + + if (isSpecialFolder(item1) ^ isSpecialFolder(item2)) return isSpecialFolder(item1) ? -1 : 1; + + if (isItem1Folder ^ isItem2Folder) return isItem1Folder ? -1 : 1; + + //otherwise we compare the names + return String.CASE_INSENSITIVE_ORDER.compare(item1.getName(), item2.getName()); + } + + private boolean isSpecialFolder(Item item) { + return item.getName().equals(WorkspaceNavigatorConstants.VRE_FOLDERS_LABEL); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java new file mode 100644 index 0000000..2bae0df --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/WorkspaceExplorerServiceImpl.java @@ -0,0 +1,248 @@ +package org.gcube.portlets.widgets.wsexplorer.server; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import javax.servlet.http.HttpSession; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; +import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; +import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService; +import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria; +import org.gcube.portlets.widgets.wsexplorer.shared.Item; +import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; +import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +/** + * The server side implementation of the RPC service. + */ +@SuppressWarnings("serial") +public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implements WorkspaceExplorerService { + + public static final Logger _log = LoggerFactory.getLogger(WorkspaceExplorerServiceImpl.class); + public static final String USERNAME_ATTRIBUTE = "username"; + + + private ASLSession getASLSession(HttpSession httpSession) { + String sessionID = httpSession.getId(); + String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE); + + _log.error("WORKSPACE PORTLET SessionID= " + sessionID); + + //TODO we check for the older attribute name + if (user == null) user = (String) httpSession.getAttribute("user"); + + if (user == null) { + + _log.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND"); + + //for test only +// user = "test.user"; + user = "francesco.mangiacrapa"; + httpSession.setAttribute(USERNAME_ATTRIBUTE, user); + ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user); + session.setScope("/gcube/devsec/devVRE"); + + return session; + } else _log.trace("user found in session "+user); + return SessionManager.getInstance().getASLSession(sessionID, user); + } + + + protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException { + ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); + + Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); + return workspace; + } + + /** + * {@inheritDoc} + */ + @Override + public Item getRoot(List showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException { + _log.trace("getRoot showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+ filterCriteria); + + try { + + Workspace workspace = getWorkspace(); + + _log.trace("Start getRoot..."); + + WorkspaceFolder specials = workspace.getMySpecialFolders(); + + WorkspaceItem root = workspace.getRoot(); + + _log.trace("GetRoot - Replyiing root"); + + long startTime = System.currentTimeMillis(); + _log.trace("start time - " + startTime); + + Item rootItem = ItemBuilder.getItem(null, root, showableTypes, filterCriteria, 2); + + Item specialFolders = ItemBuilder.getItem(null, specials, showableTypes, filterCriteria, 2); + specialFolders.setShared(true); + rootItem.addChild(specialFolders); + + if(rootItem==null) + _log.trace("############ rootItem null"); + + _log.trace("Only showable types:"); + //printName("", rootItem); + + if (purgeEmpyFolders) rootItem = ItemBuilder.purgeEmptyFolders(rootItem); + + _log.trace("Returning:"); + + Long endTime = System.currentTimeMillis() - startTime; + String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); + _log.trace("end time - " + time); + + //printName("", rootItem); + + Collections.sort(rootItem.getChildren(), new ItemComparator()); + + return rootItem; + + } catch (Exception e) { + _log.error("Error during root retrieving", e); + throw new WorkspaceNavigatorServiceException(e.getMessage()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public Item getFolder(String folderId, List showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException { + _log.trace("getFolder folderId: "+folderId+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria); + + try { + + Workspace workspace = getWorkspace(); + WorkspaceItem folder = workspace.getItem(folderId); + + _log.trace("GetFolder - Replyiing folder"); + + long startTime = System.currentTimeMillis(); + _log.trace("start time - " + startTime); + + + Item folderItem = ItemBuilder.getItem(null, folder, showableTypes, filterCriteria, 2); + + _log.trace("Only showable types:"); + //printName("", folderItem); + + if (purgeEmpyFolders) folderItem = ItemBuilder.purgeEmptyFolders(folderItem); + + _log.trace("Returning:"); + + Long endTime = System.currentTimeMillis() - startTime; + String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); + _log.trace("end time - " + time); + + //printName("", folderItem); + + Collections.sort(folderItem.getChildren(), new ItemComparator()); + + return folderItem; + + } catch (Exception e) { + _log.error("Error during folder retrieving", e); + throw new WorkspaceNavigatorServiceException(e.getMessage()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean checkName(String name) throws WorkspaceNavigatorServiceException { + _log.trace("checkName name: "+name); + try { + ASLSession session = getASLSession(this.getThreadLocalRequest().getSession()); + Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername()); + return workspace.isValidName(name); + } catch (Exception e) { + _log.error("Error during folder retrieving", e); + throw new WorkspaceNavigatorServiceException(e.getMessage()); + } + } + + /*protected void printName(String indentation, Item item) + { + if(item!=null){ + _log.trace(indentation+item.getName()); + for (Item child:item.getChildren()) printName(indentation+"\t", child); + } + }*/ + + /** + * Gets the list parents by item identifier. + * + * @param itemIdentifier the item identifier + * @param includeItemAsParent - if parameter is true and item passed in input is a folder, the folder is included in path returned as last parent + * @return the list parents by item identifier + * @throws Exception the exception + */ + @Override + public List getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent) throws Exception { + /*List listParents = new ArrayList(); + _log.trace("get List Parents By Item Identifier "+ itemIdentifier); + try { + Workspace workspace = getWorkspace(); + + WorkspaceItem wsItem = workspace.getItem(itemIdentifier); + + _log.trace("workspace retrieve item name: "+wsItem.getName()); + + + String nameSpecialFolder = getNameForSpecialFolder(); + + if(includeItemAsParent==true && wsItem.getType().equals(WorkspaceItemType.FOLDER)){ + listParents.add(builder.buildGXTFolderModelItemHandleSpecialFolder((WorkspaceFolder) wsItem, null, nameSpecialFolder)); + } + + while(wsItem!=null && wsItem.getParent()!=null){ + + WorkspaceFolder wsFolder = wsItem.getParent(); + listParents.add(builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder, null, nameSpecialFolder)); + wsItem = wsFolder; + } + + Collections.reverse(listParents); + + //SET PARENTS + for(int i=0; i + * FieldVerifier validates that the name the user enters is valid. + *

+ *

+ * This class is in the shared packing because we use it in both + * the client code and on the server. On the client, we verify that the name is + * valid before sending an RPC request so the user doesn't have to wait for a + * network round trip to get feedback. On the server, we verify that the name is + * correct to ensure that the input is correct regardless of where the RPC + * originates. + *

+ *

+ * When creating a class that is used on both the client and the server, be sure + * that all code is translatable and does not use native JavaScript. Code that + * is note translatable (such as code that interacts with a database or the file + * system) cannot be compiled into client side JavaScript. Code that uses native + * JavaScript (such as Widgets) cannot be run on the server. + *

+ */ +public class FieldVerifier { + + /** + * Verifies that the specified name is valid for our service. + * + * In this example, we only require that the name is at least four + * characters. In your application, you can use more complex checks to ensure + * that usernames, passwords, email addresses, URLs, and other fields have the + * proper syntax. + * + * @param name the name to validate + * @return true if valid, false if invalid + */ + public static boolean isValidName(String name) { + if (name == null) { + return false; + } + return name.length() > 3; + } +} 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 new file mode 100644 index 0000000..af25a92 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/FilterCriteria.java @@ -0,0 +1,75 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.shared; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + + +/** + * The Class FilterCriteria. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 18, 2015 + */ +public class FilterCriteria implements Serializable { + + + /** + * + */ + private static final long serialVersionUID = 1912760277441333686L; + protected List allowedMimeTypes; + protected Map requiredProperties; + + /** + * Instantiates a new filter criteria. + */ + public FilterCriteria(){} + + /** + * Instantiates a new filter criteria. + * + * @param allowedMimeTypes the allowed mime types + * @param requiredProperties the required properties + */ + public FilterCriteria(List allowedMimeTypes, + Map requiredProperties) { + this.allowedMimeTypes = allowedMimeTypes; + this.requiredProperties = requiredProperties; + } + + /** + * Gets the allowed mime types. + * + * @return the allowedMimeTypes + */ + public List getAllowedMimeTypes() { + return allowedMimeTypes; + } + + /** + * Gets the required properties. + * + * @return the requiredProperties + */ + public Map getRequiredProperties() { + return requiredProperties; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("FilterCriteria [allowedMimeTypes="); + builder.append(allowedMimeTypes); + builder.append(", requiredProperties="); + builder.append(requiredProperties); + builder.append("]"); + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/Item.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/Item.java new file mode 100644 index 0000000..8bff4e2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/Item.java @@ -0,0 +1,212 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.shared; + +import java.util.ArrayList; + +import com.google.gwt.user.client.rpc.IsSerializable; + + +/** + * The Class Item. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 18, 2015 + */ +public class Item implements IsSerializable{ + + protected Item parent; + protected String id; + protected String name; + protected ItemType type; + + protected String path; + + protected boolean shared; + + protected ArrayList children; + + /** + * Instantiates a new item. + */ + public Item(){} + + /** + * Create a new item. + * @param parent the item parent. + * @param id the item id. + * @param name the item name. + * @param type the item type. + * @param path the item path. + */ + public Item(Item parent, String id, String name, ItemType type, String path) { + this.parent = parent; + this.id = id; + this.name = name; + this.type = type; + this.path = path; + this.children = new ArrayList(); + } + + + /** + * Checks if is shared. + * + * @return the shared + */ + public boolean isShared() { + return shared; + } + + /** + * Sets the shared. + * + * @param shared the shared to set + */ + public void setShared(boolean shared) { + this.shared = shared; + } + + /** + * The item parent. Null if is the root. + * @return the item parent. + */ + public Item getParent() { + return parent; + } + + /** + * The item id. + * @return the id. + */ + public String getId() { + return id; + } + + /** + * The item name. + * @return the name. + */ + public String getName() { + return name; + } + + /** + * The item type. + * @return the type. + */ + public ItemType getType() { + return type; + } + + + /** + * The item children. + * @return the children. + */ + public ArrayList getChildren() { + return children; + } + + + /** + * The item child. + * + * @param index the index + * @return the child at the specific position. + */ + public Item getChild(int index) { + return children.get(index); + } + + /** + * Add a child to this item. + * @param child the child to add. + */ + public void addChild(Item child) + { + children.add(child); + } + + /** + * Remove a child from this item. + * + * @param child the child + */ + public void removeChild(Item child) + { + children.remove(child); + } + + + + /** + * Return this item path. + * @return the item path. + */ +// Modified in date 26/06/2012 by Francesco Mangiacrapa + public String getPath() + { + System.out.println("getting path for "+name); + if (parent == null) return "/"; + + return parent.getPath() + name + "/"; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Item other = (Item) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Item [name="); + builder.append(name); + builder.append(", type="); + builder.append(type); + builder.append(", id="); + builder.append(id); + builder.append("]"); + return builder.toString(); + } + + /** + * Sets the parent. + * + * @param parent the new parent + */ + public void setParent(Item parent) { + this.parent = parent; + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/ItemType.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/ItemType.java new file mode 100644 index 0000000..94e50b6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/ItemType.java @@ -0,0 +1,31 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.shared; + + +/** + * The Enum ItemType. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 18, 2015 + */ +public enum ItemType { + + ROOT, + FOLDER, + EXTERNAL_IMAGE, + EXTERNAL_FILE, + EXTERNAL_PDF_FILE, + EXTERNAL_URL, + QUERY, + REPORT_TEMPLATE, + REPORT, + DOCUMENT, + METADATA, + PDF_DOCUMENT, + IMAGE_DOCUMENT, + URL_DOCUMENT, + GCUBE_ITEM, + UNKNOWN_TYPE; +} diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/WorkspaceNavigatorServiceException.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/WorkspaceNavigatorServiceException.java new file mode 100644 index 0000000..5404bab --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/shared/WorkspaceNavigatorServiceException.java @@ -0,0 +1,35 @@ +/** + * + */ +package org.gcube.portlets.widgets.wsexplorer.shared; + + +/** + * The Class WorkspaceNavigatorServiceException. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 18, 2015 + */ +public class WorkspaceNavigatorServiceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 6416932531764081333L; + + /** + * Instantiates a new workspace navigator service exception. + */ + public WorkspaceNavigatorServiceException() { + } + + /** + * Instantiates a new workspace navigator service exception. + * + * @param message the message + */ + public WorkspaceNavigatorServiceException(String message) { + super(message); + } + +} 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 new file mode 100644 index 0000000..e868b55 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorer.gwt.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..dcd8dfe --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,23 @@ + + + + + + workspaceExplorer + org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl + + + + workspaceExplorer + /WorkspaceExplorer/greet + + + + + WorkspaceExplorer.html + + + diff --git a/src/main/webapp/WorkspaceExplorer.css b/src/main/webapp/WorkspaceExplorer.css new file mode 100644 index 0000000..7aca7ac --- /dev/null +++ b/src/main/webapp/WorkspaceExplorer.css @@ -0,0 +1,34 @@ +/** Add css rules here for your application. */ + + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.sendButton { + display: block; + font-size: 16pt; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + +/** Set ids using widget.getElement().setId("idOfElement") */ +#closeButton { + margin: 15px 6px 6px; +} diff --git a/src/main/webapp/WorkspaceExplorer.html b/src/main/webapp/WorkspaceExplorer.html new file mode 100644 index 0000000..65ad2da --- /dev/null +++ b/src/main/webapp/WorkspaceExplorer.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +

Web Application Starter Project

+ + + + + + + + + + + + +
Please enter your name:
+ + diff --git a/src/test/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorerJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorerJUnit.gwt.xml new file mode 100644 index 0000000..7661802 --- /dev/null +++ b/src/test/resources/org/gcube/portlets/widgets/wsexplorer/WorkspaceExplorerJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +