From 21e18c26efb36a04cbf09f8ad9c3e4116141fa52 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 14 Feb 2018 15:25:23 +0000 Subject: [PATCH] css and minor fixes git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@163286 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 ++ .../view/subwidgets/ConnectToWidget.java | 47 ++++++++++++++----- .../view/subwidgets/PasteAwareTextBox.java | 10 +++- .../client/view/subwidgets/SuggestMerges.java | 34 +++++++++++--- .../public/GRSFManageWidget.css | 4 ++ .../manage/GRSFNotificationService.java | 31 ++++++------ .../GRSFManageWidget.gwt.xml | 3 ++ src/main/webapp/GRSFManageWidget.css | 6 --- 8 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 src/main/java/org/gcube/datacatalogue/grsf_manage_widget/public/GRSFManageWidget.css delete mode 100644 src/main/webapp/GRSFManageWidget.css diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 38e18cb..d0ac04b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,9 @@ + + uses + diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/ConnectToWidget.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/ConnectToWidget.java index 0ccf035..6c4411c 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/ConnectToWidget.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/ConnectToWidget.java @@ -15,7 +15,10 @@ import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.Tooltip; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.Placement; +import com.github.gwtbootstrap.client.ui.constants.Trigger; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.FontWeight; @@ -196,7 +199,7 @@ public class ConnectToWidget extends Composite{ vpLeft.getElement().getStyle().setMarginLeft(15, Unit.PX); vpLeft.setWidth("80%"); Paragraph identifier = new Paragraph("Record UUID:"); - + // view link final Anchor view = new Anchor(); view.setText("View"); @@ -204,21 +207,23 @@ public class ConnectToWidget extends Composite{ view.setTarget("_blank"); view.getElement().getStyle().setFontWeight(FontWeight.BOLD); view.setVisible(false); - + // a textbox with a validate button on the right side AppendButton uuidAndValidateButton = new AppendButton(); final Button validateUUIDButton = new Button("Validate"); + final Tooltip tip = new Tooltip(); validateUUIDButton.setEnabled(false); - final PasteAwareTextBox box = new PasteAwareTextBox(validateUUIDButton); + final PasteAwareTextBox box = new PasteAwareTextBox(validateUUIDButton, tip); + setupTooltip(tip, box, "", false); box.setWidth("512px"); box.setPlaceholder("Copy and Paste the Identifier (UUID) of the record to connect here, then validate"); validateUUIDButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - - validateUUID(box, cb, view, validateUUIDButton, acceptedDomain); - + + validateUUID(box, cb, view, validateUUIDButton, acceptedDomain, tip); + } }); uuidAndValidateButton.add(box); @@ -262,13 +267,13 @@ public class ConnectToWidget extends Composite{ return new Tuple(cb, main, box); } - protected void validateUUID(final TextBox box, final ConnectedBean c, final Anchor view, final Button validateUUIDButton, final String acceptedDomain) { + protected void validateUUID(final TextBox box, final ConnectedBean c, final Anchor view, final Button validateUUIDButton, final String acceptedDomain, final Tooltip tip) { validateUUIDButton.setText("Validating..."); validateUUIDButton.setEnabled(false); box.setEnabled(false); view.setVisible(false); - + final String currentText = box.getText().trim(); c.setKnowledgeBaseId(null); c.setConnect(false); @@ -289,6 +294,7 @@ public class ConnectToWidget extends Composite{ validateUUIDButton.setType(ButtonType.SUCCESS); validateUUIDButton.setEnabled(false); eventBus.fireEvent(new EnableConfirmButtonEvent()); + setupTooltip(tip, box, "", false); } else{ view.setVisible(false); @@ -296,9 +302,10 @@ public class ConnectToWidget extends Composite{ validateUUIDButton.setText("Invalid"); validateUUIDButton.setType(ButtonType.DANGER); validateUUIDButton.setEnabled(true); + setupTooltip(tip, box, "Invalid", true); } - - + + } @Override @@ -306,10 +313,10 @@ public class ConnectToWidget extends Composite{ box.setEnabled(true); view.setVisible(false); validateUUIDButton.setText("Invalid"); - validateUUIDButton.setTitle("Error is " + caught); validateUUIDButton.setType(ButtonType.DANGER); view.setVisible(false); box.setEnabled(true); + setupTooltip(tip, box, caught.getMessage(), true); } }); @@ -342,4 +349,20 @@ public class ConnectToWidget extends Composite{ } + private void setupTooltip(Tooltip tooltip, Widget w, String message, boolean show) { + tooltip.setWidget(w); + tooltip.setText(message); + tooltip.setAnimation(true); + tooltip.setHideDelay(1000); + tooltip.setPlacement(Placement.TOP); + tooltip.setTrigger(Trigger.MANUAL); + tooltip.hide(); + tooltip.reconfigure(); + + if(show) + tooltip.show(); + else + tooltip.hide(); + } + } diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/PasteAwareTextBox.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/PasteAwareTextBox.java index dea45bd..1271113 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/PasteAwareTextBox.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/PasteAwareTextBox.java @@ -2,6 +2,8 @@ package org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.Tooltip; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.shared.GWT; import com.google.gwt.user.client.Event; @@ -12,11 +14,13 @@ import com.google.gwt.user.client.Event; public class PasteAwareTextBox extends TextBox { private Button toBeEnabled; + private Tooltip wrapperTip; private static final String REGEX_UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; - public PasteAwareTextBox(Button b) { + public PasteAwareTextBox(Button b, Tooltip tip) { super(); toBeEnabled = b; + wrapperTip = tip; sinkEvents(Event.ONPASTE); sinkEvents(Event.ONCHANGE); sinkEvents(Event.ONKEYPRESS); @@ -40,6 +44,10 @@ public class PasteAwareTextBox extends TextBox { private void onEvent(String clipboardData) { GWT.log("Current text is:" + clipboardData); toBeEnabled.setEnabled(false); + toBeEnabled.setText("Validate"); + toBeEnabled.setTitle(""); + toBeEnabled.setType(ButtonType.DEFAULT); + wrapperTip.hide(); if(clipboardData != null && !clipboardData.isEmpty()){ final String currentText = clipboardData.trim(); if(!currentText.matches(REGEX_UUID)) diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java index 638b85b..fc08a88 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/client/view/subwidgets/SuggestMerges.java @@ -12,7 +12,10 @@ import com.github.gwtbootstrap.client.ui.AppendButton; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.Tooltip; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.Placement; +import com.github.gwtbootstrap.client.ui.constants.Trigger; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.FontWeight; @@ -70,7 +73,7 @@ public class SuggestMerges extends Composite { Widget w = buildWidgetForExtraSimilarRecord(s, acceptedDomain, eventBus); extraSimilarRecordsList.add(new Tuple(s, w, null)); similarGrsfRecordsSuggestedPanel.add(w); - } + } }); } @@ -106,9 +109,10 @@ public class SuggestMerges extends Composite { // a textbox with a validate button on the right side AppendButton uuidAndValidateButton = new AppendButton(); + final Tooltip tip = new Tooltip(); final Button validateUUIDButton = new Button("Validate"); - validateUUIDButton.setEnabled(false); - final PasteAwareTextBox box = new PasteAwareTextBox(validateUUIDButton); + final PasteAwareTextBox box = new PasteAwareTextBox(validateUUIDButton, tip); + setupTooltip(tip, box, "", false); box.setWidth("512px"); box.setPlaceholder("Copy and Paste the Identifier (UUID) of the record to merge, then validate"); validateUUIDButton.addClickHandler(new ClickHandler() { @@ -116,7 +120,7 @@ public class SuggestMerges extends Composite { @Override public void onClick(ClickEvent event) { - validateUUID(box, s, view, validateUUIDButton, acceptedDomain, eventBus); + validateUUID(box, s, view, validateUUIDButton, acceptedDomain, eventBus, tip); } }); @@ -173,8 +177,9 @@ public class SuggestMerges extends Composite { * @param icon * @param view * @param eventBus2 + * @param tip */ - protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Anchor view, final Button validateUUIDButton, final String acceptedDomain, HandlerManager eventBus2) { + protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Anchor view, final Button validateUUIDButton, final String acceptedDomain, HandlerManager eventBus2, final Tooltip tip) { validateUUIDButton.setText("Validating..."); validateUUIDButton.setEnabled(false); @@ -201,6 +206,7 @@ public class SuggestMerges extends Composite { validateUUIDButton.setType(ButtonType.SUCCESS); validateUUIDButton.setEnabled(false); eventBus.fireEvent(new EnableConfirmButtonEvent()); + setupTooltip(tip, box, "", false); } else{ view.setVisible(false); @@ -208,6 +214,7 @@ public class SuggestMerges extends Composite { validateUUIDButton.setText("Invalid"); validateUUIDButton.setType(ButtonType.DANGER); validateUUIDButton.setEnabled(true); + setupTooltip(tip, box, "Invalid", true); } @@ -218,10 +225,10 @@ public class SuggestMerges extends Composite { box.setEnabled(true); view.setVisible(false); validateUUIDButton.setText("Invalid"); - validateUUIDButton.setTitle("Error is " + caught); validateUUIDButton.setType(ButtonType.DANGER); view.setVisible(false); box.setEnabled(true); + setupTooltip(tip, box, caught.getMessage(), true); } }); @@ -245,4 +252,19 @@ public class SuggestMerges extends Composite { return toReturn; } + private void setupTooltip(Tooltip tooltip, Widget w, String message, boolean show) { + tooltip.setWidget(w); + tooltip.setText(message); + tooltip.setAnimation(true); + tooltip.setHideDelay(1000); + tooltip.setPlacement(Placement.TOP); + tooltip.setTrigger(Trigger.MANUAL); + tooltip.hide(); + tooltip.reconfigure(); + + if(show) + tooltip.show(); + else + tooltip.hide(); + } } diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/public/GRSFManageWidget.css b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/public/GRSFManageWidget.css new file mode 100644 index 0000000..9f90bec --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/public/GRSFManageWidget.css @@ -0,0 +1,4 @@ +.tooltip-inner { + max-width: 350px !important; + width: 350px !important; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java index 7fba29f..5c83aa5 100644 --- a/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java +++ b/src/main/java/org/gcube/datacatalogue/grsf_manage_widget/server/manage/GRSFNotificationService.java @@ -555,10 +555,9 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS @Override public String checkIdentifierExistsInDomain(String id, - String domain) throws Exception { + String acceptedDomain) throws Exception { if(!Utils.isIntoPortal()){ - boolean throwException = Math.random() > 0.5; // simulate some delay... @@ -568,7 +567,6 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS throw new Exception("The suggested record is not a GRSF record"); return "http://data.d4science.org/catalogue/grsf_admin/" + id; - } String scopePerCurrentUrl = Utils.getScopeFromClientUrl(getThreadLocalRequest()); @@ -578,20 +576,19 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS if(dataset == null) throw new Exception("A record with id " + id + " doesn't exist"); - - if(!dataset.getOrganization().getName().equals(Constants.GRSF_ADMIN_ORGANIZATION_NAME)) - throw new Exception("The suggested record is not a GRSF record"); - - List extrasAsPairs = dataset.getExtras(); - - for (CkanPair ckanPair : extrasAsPairs) { - if(ckanPair.getKey().contains(Constants.DOMAIN_CUSTOM_KEY)){ - if(ckanPair.getValue().equalsIgnoreCase(domain)) - return dataset.getExtrasAsHashMap().get(Constants.ITEM_URL_FIELD); - } - } - - throw new Exception("A GRSF record with id " + id + " doesn't exist in domain " + domain); + + Map extras = dataset.getExtrasAsHashMap(); + String systemType = extras.get(Constants.SYSTEM_TYPE_CUSTOM_KEY); + String domain = extras.get(Constants.DOMAIN_CUSTOM_KEY); + String url = extras.get(Constants.ITEM_URL_FIELD); + + if(systemType.equals(Constants.SYSTEM_TYPE_FOR_SOURCES_VALUE)) + throw new Exception("This record is not a GRSF record!"); + + if(!acceptedDomain.equalsIgnoreCase(domain)) + throw new Exception("You are suggesting a " + domain + " record instead of a " + acceptedDomain + " record!"); + + return url; } } diff --git a/src/main/resources/org/gcube/datacatalogue/grsf_manage_widget/GRSFManageWidget.gwt.xml b/src/main/resources/org/gcube/datacatalogue/grsf_manage_widget/GRSFManageWidget.gwt.xml index a26e037..6388cdd 100644 --- a/src/main/resources/org/gcube/datacatalogue/grsf_manage_widget/GRSFManageWidget.gwt.xml +++ b/src/main/resources/org/gcube/datacatalogue/grsf_manage_widget/GRSFManageWidget.gwt.xml @@ -24,5 +24,8 @@ + + + diff --git a/src/main/webapp/GRSFManageWidget.css b/src/main/webapp/GRSFManageWidget.css deleted file mode 100644 index c257dd6..0000000 --- a/src/main/webapp/GRSFManageWidget.css +++ /dev/null @@ -1,6 +0,0 @@ -.error-text-box { - border: 1px solid red; - background: white url("../img/validation_error_icon.gif") - no-repeat left center; - padding-left: 15px !important; -} \ No newline at end of file