From 68970848a540722ca06a04fec877dd3cc8c2bb2a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 20 Dec 2019 12:11:14 +0100 Subject: [PATCH] Enhancements on the GUI-side --- .../client/ui/BasicTabPanel.java | 102 ++++++++++-------- .../ui/publishfile/PublishFileView.ui.xml | 12 ++- .../client/view/Ckan2ZenodoViewManager.java | 11 +- .../public/CkanToZenodoPublisher.css | 14 ++- 4 files changed, 79 insertions(+), 60 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/BasicTabPanel.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/BasicTabPanel.java index 300e990..70f48b5 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/BasicTabPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/BasicTabPanel.java @@ -6,7 +6,13 @@ import java.util.List; import com.github.gwtbootstrap.client.ui.Pager; import com.github.gwtbootstrap.client.ui.Tab; import com.github.gwtbootstrap.client.ui.TabPanel; +import com.github.gwtbootstrap.client.ui.TabPanel.ShownEvent.Handler; +import com.github.gwtbootstrap.client.ui.event.ShowEvent; +import com.github.gwtbootstrap.client.ui.event.ShowHandler; +import com.github.gwtbootstrap.client.ui.event.ShownEvent; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; @@ -14,14 +20,14 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; -public abstract class BasicTabPanel extends Composite { +public class BasicTabPanel extends Composite { private static BasicTabPanelUiBinder uiBinder = GWT.create(BasicTabPanelUiBinder.class); interface BasicTabPanelUiBinder extends UiBinder { } - public abstract void checkTabVisited(); + //public abstract void checkTabVisited(); @UiField Tab acc_basic_info; @@ -45,24 +51,6 @@ public abstract class BasicTabPanel extends Composite { listActivatedTab = new ArrayList<>(); listActivatedTab.add(acc_basic_info.isActive()); listActivatedTab.add(acc_files.isActive()); - - acc_basic_info.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - listActivatedTab.set(0, true); - checkTabVisited(); - } - }); - - acc_files.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - listActivatedTab.set(1, true); - checkTabVisited(); - } - }); pager.getRight().addClickHandler(new ClickHandler() { @@ -81,7 +69,36 @@ public abstract class BasicTabPanel extends Composite { } }); - managePager(null); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + managePager(null); + } + }); + + + class ShownEventHandler implements com.github.gwtbootstrap.client.ui.TabPanel.ShownEvent.Handler{ + + @Override + public void onShow(com.github.gwtbootstrap.client.ui.TabPanel.ShownEvent shownEvent) { + GWT.log("tab shownEvent fired"); + managePager(null); + } + } + + ShownEventHandler handler = new ShownEventHandler(); + +// com.github.gwtbootstrap.client.ui.TabPanel.ShowEvent.Handler myHadler = new com.github.gwtbootstrap.client.ui.TabPanel.ShowEvent.Handler() { +// +// @Override +// public void onShow(com.github.gwtbootstrap.client.ui.TabPanel.ShowEvent showEvent) { +// +// GWT.log("showEvent fired"); +// } +// }; + + tabPanel.addShownHandler(handler); } public Tab getAcc_basic_info() { @@ -92,42 +109,37 @@ public abstract class BasicTabPanel extends Composite { return acc_files; } -// public Tab getAcc_license() { -// return acc_license; -// } - - public boolean allTabVisited() { - for (Boolean value : listActivatedTab) { - if (!value) - return false; - } - - return true; - } public TabPanel getTabPanel() { return tabPanel; } - private void managePager(PAGER direction){ + public void managePager(PAGER direction){ int selectTab = tabPanel.getSelectedTab(); - pager.getLeft().setVisible(true); - pager.getRight().setVisible(true); + GWT.log("selectTab tab: "+selectTab); + GWT.log("tabPanel.getWidgetCount(): "+tabPanel.getWidgetCount()); - if(selectTab==0) { - pager.getLeft().setVisible(false); - } - - if(selectTab==tabPanel.getWidgetCount()) { - pager.getRight().setVisible(false); - } + checkPagerVisibility(selectTab); if(direction!=null) { int newSelectTabIndex = direction.equals(PAGER.BACK)?selectTab-1:selectTab+1; - GWT.log("selecting index: "+newSelectTabIndex); - + GWT.log("newSelectTabIndex: "+newSelectTabIndex); tabPanel.selectTab(newSelectTabIndex); + checkPagerVisibility(newSelectTabIndex); } + } + + private void checkPagerVisibility(int index) { + pager.getLeft().setVisible(true); + pager.getRight().setVisible(true); + //first tab + if(index<=0) { + pager.getLeft().setVisible(false); + } + //last tab + if(index>=tabPanel.getWidgetCount()-1) { + pager.getRight().setVisible(false); + } } } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFileView.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFileView.ui.xml index 7e89097..3f9d6ad 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFileView.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFileView.ui.xml @@ -8,6 +8,13 @@ .padding-left-10 { padding-left: 10px; } + + .to-publish-hr { + margin-top: 1px; + } + .to-padding{ + padding: 3px; + } @@ -16,8 +23,9 @@ - - publish + + Publish diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java index 4fbf289..04afcf5 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java @@ -42,14 +42,7 @@ public class Ckan2ZenodoViewManager { Modal modal = new Modal(true); - basicTabPanel = new BasicTabPanel() { - - @Override - public void checkTabVisited() { - buttonPublish.setEnabled(basicTabPanel.allTabVisited()); - } - - }; + basicTabPanel = new BasicTabPanel(); boolean isUpdate = false; if(zenodoItem.getMetadata()!=null) { @@ -89,7 +82,7 @@ public class Ckan2ZenodoViewManager { modal.add(basicTabPanel); - buttonPublish.setEnabled(false); + //buttonPublish.setEnabled(false); buttonPublish.addClickHandler(new ClickHandler() { diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css index c7fa493..c7c815a 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css @@ -24,16 +24,22 @@ height: 645px; } +.ckan2zenodo-modal-style .nav-tabs { + height: 645px; +} + .ckan2zenodo-modal-style .pager { - margin-right: 10px; - margin-left: 10px; + margin-right: 20px; + margin-left: 140px; + margin-top: 0px; + margin-bottom: 0px; } .legend-style { width: auto; padding: 10px; margin-bottom: 0px; - font-size: 16px; + font-size: 18px; color: gray; text-align: right; } @@ -47,7 +53,7 @@ } .form-font-size label { - font-size: 15px; + font-size: 16px; } .authors-table-spacing td {