From 79e51db104ac7a28496820c770a4d266ecc765d5 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 8 Mar 2021 17:51:04 +0100 Subject: [PATCH] in progress --- .classpath | 8 +- .../client/CKanMetadataPublisher.java | 8 +- .../client/ui/form/CreateDatasetForm.java | 18 +-- .../client/ui/form/CreateDatasetForm.ui.xml | 7 +- .../SelectResourceByWEMainPanel.java | 129 +++++++++++------- .../SelectResourceByWEMainPanel.ui.xml | 38 ++++-- .../ui/workspace/SelectResourceWidget.java | 4 + .../ui/workspace/SelectResourceWidget.ui.xml | 12 +- 8 files changed, 144 insertions(+), 80 deletions(-) diff --git a/.classpath b/.classpath index 510cf3c..5fe0d51 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,13 @@ - + + + + + + + diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java index 0a064ce..2cbba2b 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java @@ -265,11 +265,15 @@ public class CKanMetadataPublisher implements EntryPoint { m.setWidth("1200px"); m.getElement().getStyle().setMarginLeft(-30, Unit.PCT); ResourceElementBean r = new ResourceElementBean(); - r.setFolder(true); + r.setFolder(false); r.setName("Root"); r.setParent(null); r.setChildrenSize(5); - r.setOriginalIdInWorkspace("4ab50488-67d7-4664-9a0f-88a1de043399"); + r.setOriginalIdInWorkspace("31d7ec0c-8d31-47d7-9139-c52b5e124349"); + + ResourceElementBean parent = new ResourceElementBean(); + parent.setOriginalIdInWorkspace("91409eba-0bf6-4aa5-8d73-3536bf181587"); + r.setParent(parent); List children = new ArrayList(); diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java index b93f95f..456fa0a 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java @@ -1247,15 +1247,15 @@ public class CreateDatasetForm extends Composite{ ); // resources field - InfoIconsLabels.preparePopupPanelAndPopover( - InfoIconsLabels.RESOURCES_INFO_ID_POPUP, - InfoIconsLabels.RESOURCES_INFO_TEXT, - InfoIconsLabels.RESOURCES_INFO_CAPTION, - infoIconResources, - popoverResources, - focusPanelResources, - popupOpenedIds - ); +// InfoIconsLabels.preparePopupPanelAndPopover( +// InfoIconsLabels.RESOURCES_INFO_ID_POPUP, +// InfoIconsLabels.RESOURCES_INFO_TEXT, +// InfoIconsLabels.RESOURCES_INFO_CAPTION, +// infoIconResources, +// popoverResources, +// focusPanelResources, +// popupOpenedIds +// ); // title InfoIconsLabels.preparePopupPanelAndPopover( diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml index cf4440a..d22c431 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml @@ -320,7 +320,6 @@ Manage Resources - @@ -329,13 +328,9 @@ - + - - - Continue diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java index 5aa1f89..8badec8 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java @@ -4,20 +4,25 @@ import java.util.HashMap; import java.util.Map; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; -import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesBExplorerPanel; import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel; -import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectBNotification.WorskpaceExplorerSelectBNotificationListener; +import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener; import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD; import org.gcube.portlets.widgets.wsexplorer.shared.Item; +import com.github.gwtbootstrap.client.ui.AccordionGroup; +import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.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.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; @@ -41,9 +46,18 @@ public class SelectResourceByWEMainPanel extends Composite { @UiField VerticalPanel selectResourcesContainer; + @UiField + Alert showAlert; + @UiField Button buttSelectResource; + @UiField + AccordionGroup buttPickResources; + + @UiField + HTMLPanel containerPickResources; + private Item selectedWEItem; Map mapSelectedResources = new HashMap(); @@ -67,57 +81,60 @@ public class SelectResourceByWEMainPanel extends Composite { this.frozen = false; this.initialBean = initialBean; + //this.buttPickResources.setType(ButtonType.LINK); WorkspaceResourcesExplorerPanel rp = null; DISPLAY_FIELD[] displayFields = new DISPLAY_FIELD[] { DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, - DISPLAY_FIELD.OWNER }; + DISPLAY_FIELD.OWNER, DISPLAY_FIELD.CREATION_DATE}; try { - String wsRootId = initialBean.isFolder() ? initialBean.getOriginalIdInWorkspace() - : initialBean.getParent().getOriginalIdInWorkspace(); - // WorkspaceResourcesBExplorerPanel(String folderId, boolean showOnlyFolders, - // List showProperties, FilterCriteria filter, boolean showGcubeInfo, - // DISPLAY_FIELD sortByColumn) throws Exception { - WorkspaceResourcesBExplorerPanel workspaceExplorerPanel = new WorkspaceResourcesBExplorerPanel(wsRootId, - false); - WorskpaceExplorerSelectBNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectBNotificationListener() { - + + String wsRootId = null; + if(initialBean.isFolder()) { + wsRootId = initialBean.getOriginalIdInWorkspace(); + }else { + //is file + wsRootId= initialBean.getParent()!=null? initialBean.getParent().getOriginalIdInWorkspace():null; + } + + //loads the WE only if the root is not null + if(wsRootId!=null) { + + WorkspaceResourcesExplorerPanel workspaceExplorerPanel = new WorkspaceResourcesExplorerPanel(wsRootId,false,null, null,false,null,displayFields); + WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() { - - @Override - public void onSelectedItem(Item item) { - GWT.log("Listener Selected Item " + item); - selectedWEItem = item; - } - - @Override - public void onFailed(Throwable throwable) { - // Log.error(throwable.getLocalizedMessage()); - throwable.printStackTrace(); - } + @Override + public void onSelectedItem(Item item) { + GWT.log("Listener Selected Item " + item); + selectedWEItem = item; + } + + @Override + public void onFailed(Throwable throwable) { + // Log.error(throwable.getLocalizedMessage()); + throwable.printStackTrace(); + } + + + @Override + public void onAborted() { + + } + + @Override + public void onNotValidSelection() { + selectedWEItem = null; + } + }; + + workspaceExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener); + wsContainer.add(workspaceExplorerPanel); + }else { + containerPickResources.setVisible(false); + } - @Override - public void onAborted() { - - } - - @Override - public void onNotValidSelection() { - selectedWEItem = null; - } - - @Override - public void onBreadcrumbChanged(Item item) { - GWT.log("Breadcrumb Changed: " + item); - - } - }; - - workspaceExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener); - wsContainer.add(workspaceExplorerPanel); - } catch (Exception e) { e.printStackTrace(); } @@ -131,7 +148,7 @@ public class SelectResourceByWEMainPanel extends Composite { @Override public void onClick(ClickEvent event) { - if(selectedWEItem!=null) { + if(selectedWEItem!=null && !selectedWEItem.isFolder()) { addSelectResource(selectedWEItem.getId(), selectedWEItem.getName(), selectedWEItem.getPath()); } @@ -144,7 +161,7 @@ public class SelectResourceByWEMainPanel extends Composite { SelectResourceWidget selWidg = mapSelectedResources.get(wsItemId); if (selWidg != null) { - Window.alert("Item '" + name + "' already selected"); + showAlertMsg(AlertType.WARNING,"Item '" + name + "' already selected",true); return; } @@ -156,10 +173,28 @@ public class SelectResourceByWEMainPanel extends Composite { selWidg = new SelectResourceWidget(rb); mapSelectedResources.put(wsItemId, selWidg); - selectResourcesContainer.add(selWidg); } + + private void showAlertMsg(AlertType type, String txt, boolean autoHide) { + showAlert.setType(type); + showAlert.setText(txt); + showAlert.setVisible(true); + showAlert.setClose(true); + if(autoHide) { + Timer timer = new Timer() { + + @Override + public void run() { + showAlert.setVisible(false); + + } + }; + + timer.schedule(5000); + } + } public ResourceElementBean getResourcesToPublish() { // TODO Auto-generated method stub diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml index e3cc515..3c0a414 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml @@ -6,21 +6,35 @@ .important { font-weight: bold; } + + .margin-bottom-40 { + margin-bottom: 40px; + } + + .max-height-250 { + max-height: 250px; + overflow-y: auto; + } - - - - - - - Select Resource - - - - + + Selected + + + + + + + + Select + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java index 526715e..7be131d 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java @@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -40,6 +41,9 @@ public class SelectResourceWidget extends Composite { this.fieldName.setText(rb.getEditableName()); + buttonEdit.setType(ButtonType.LINK); + buttonDelete.setType(ButtonType.LINK); + } } diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.ui.xml index 2c5e0e9..141a063 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.ui.xml @@ -6,11 +6,17 @@ .important { font-weight: bold; } + .selected-resources { + } + + .selected-resources td { + vertical-align: middle !important; + } - - - + + +