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
This commit is contained in:
Costantino Perciante 2018-02-14 15:25:23 +00:00
parent f6d583c8da
commit 21e18c26ef
8 changed files with 96 additions and 42 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="grsf-common-library-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/grsf-common-library/grsf-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="grsf-manage-widget"/>
<property name="java-output-path" value="/grsf-manage-widget/target/grsf-manage-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>

View File

@ -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();
}
}

View File

@ -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))

View File

@ -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();
}
}

View File

@ -0,0 +1,4 @@
.tooltip-inner {
max-width: 350px !important;
width: 350px !important;
}

View File

@ -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<CkanPair> 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<String, String> 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;
}
}

View File

@ -24,5 +24,8 @@
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- Specify the application specific style sheet. -->
<stylesheet src='GRSFManageWidget.css'/>
</module>

View File

@ -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;
}