improved the behaviour

This commit is contained in:
Francesco Mangiacrapa 2020-02-10 11:47:28 +01:00
parent 82277c67c4
commit 5d6756d7bc
3 changed files with 76 additions and 33 deletions

View File

@ -28,6 +28,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
@ -175,6 +177,33 @@ public class DialogShareableLink extends Composite {
final Button buttClose = new Button("Close"); final Button buttClose = new Button("Close");
modalFooter.add(buttClose); modalFooter.add(buttClose);
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modalBox.hide();
}
});
addEvents();
textPrivateLink.setId(Random.nextInt()+Random.nextInt()+"");
textPrivateLongLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLongLink.setId(Random.nextInt()+Random.nextInt()+"");
modalBox.add(this);
modalBox.add(modalFooter);
modalBox.show();
}
/**
* Adds the events.
*/
private void addEvents() {
//THIS IS TO PUBLIC FOLDER //THIS IS TO PUBLIC FOLDER
switchButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() { switchButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@ -187,14 +216,6 @@ public class DialogShareableLink extends Composite {
}); });
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modalBox.hide();
}
});
buttonShareSettings.addClickHandler(new ClickHandler() { buttonShareSettings.addClickHandler(new ClickHandler() {
@Override @Override
@ -204,7 +225,6 @@ public class DialogShareableLink extends Composite {
} }
}); });
showPrivateLongLinkButton.addClickHandler(new ClickHandler() { showPrivateLongLinkButton.addClickHandler(new ClickHandler() {
@Override @Override
@ -225,8 +245,11 @@ public class DialogShareableLink extends Composite {
cgPublicLongLink.setVisible(true); cgPublicLongLink.setVisible(true);
textPublicLongLink.setText(loadedPublicLink.getCompleteURL()); textPublicLongLink.setText(loadedPublicLink.getCompleteURL());
}else { }else {
textPublicLongLink.setText("Not available");
showPublicLongLinkButton.setText("Not available"); showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled"); showPublicLongLinkButton.addStyleName("href-disabled");
// showPublicLongLinkButton.setVisible(false);
disableTextBox(textPublicLongLink);
} }
} }
}); });
@ -237,6 +260,7 @@ public class DialogShareableLink extends Composite {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement(); final Element elem = event.getRelativeElement();
elem.setTitle("Copied to clipboard");
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get()); Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() { Timer timer = new Timer() {
@ -247,11 +271,19 @@ public class DialogShareableLink extends Composite {
}; };
timer.schedule(1000); timer.schedule(1000);
copyToClipboard(textPrivateLink.getId()); copyToClipboard(textPrivateLink.getId());
} }
}); });
privateLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
privateLongLinkCopyButton.addClickHandler(new ClickHandler() { privateLongLinkCopyButton.addClickHandler(new ClickHandler() {
@ -268,11 +300,19 @@ public class DialogShareableLink extends Composite {
}; };
timer.schedule(1000); timer.schedule(1000);
copyToClipboard(textPrivateLongLink.getId()); copyToClipboard(textPrivateLongLink.getId());
} }
}); });
privateLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
publicLongLinkCopyButton.addClickHandler(new ClickHandler() { publicLongLinkCopyButton.addClickHandler(new ClickHandler() {
@Override @Override
@ -288,11 +328,19 @@ public class DialogShareableLink extends Composite {
}; };
timer.schedule(1000); timer.schedule(1000);
copyToClipboard(textPublicLongLink.getId()); copyToClipboard(textPublicLongLink.getId());
} }
}); });
publicLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
textPrivateLink.addClickHandler(new ClickHandler() { textPrivateLink.addClickHandler(new ClickHandler() {
@Override @Override
@ -317,17 +365,6 @@ public class DialogShareableLink extends Composite {
} }
}); });
textPrivateLink.setId(Random.nextInt()+Random.nextInt()+"");
textPrivateLongLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLongLink.setId(Random.nextInt()+Random.nextInt()+"");
modalBox.add(this);
modalBox.add(modalFooter);
modalBox.show();
} }
@ -533,6 +570,11 @@ public class DialogShareableLink extends Composite {
}); });
} }
/**
* Disable text box.
*
* @param textBox the text box
*/
private void disableTextBox(TextBox textBox) { private void disableTextBox(TextBox textBox) {
textBox.setEnabled(false); textBox.setEnabled(false);
textBox.getElement().getStyle().setOpacity(0.3); textBox.getElement().getStyle().setOpacity(0.3);
@ -632,8 +674,10 @@ public class DialogShareableLink extends Composite {
allowAccessToFolderLink(item.getIdentifier(), setAsPublic); allowAccessToFolderLink(item.getIdentifier(), setAsPublic);
} else { } else {
showError("Permission Denied!" + " "+result.getAccessAllowDenyMotivation()); showError("Permission Denied!" + " "+result.getAccessAllowDenyMotivation());
showPublicLongLinkButton.setText("Not available"); // showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled"); // showPublicLongLinkButton.addStyleName("href-disabled");
showPublicLongLinkButton.setVisible(false);
textPublicLink.setText("You are not authorized");
disableTextBox(textPublicLink); disableTextBox(textPublicLink);
} }

View File

@ -93,7 +93,7 @@
</b:TextBox> </b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL"> <b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" ui:field="privateLinkCopyButton" <b:Button icon="COPY" ui:field="privateLinkCopyButton"
type="INFO"></b:Button> type="PRIMARY"></b:Button>
</b:Tooltip> </b:Tooltip>
</b:InputAddOn> </b:InputAddOn>
<b:Button ui:field="showPrivateLongLinkButton" <b:Button ui:field="showPrivateLongLinkButton"
@ -104,7 +104,7 @@
<b:ControlGroup addStyleNames="my-control-group" <b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPrivateLongLink" visible="false"> ui:field="cgPrivateLongLink" visible="false">
<b:ControlLabel>Private Long Link</b:ControlLabel> <b:ControlLabel></b:ControlLabel>
<b:Controls> <b:Controls>
<b:InputAddOn prependIcon="LINK" <b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width"> addStyleNames="my-prepend-width">
@ -113,7 +113,7 @@
</b:TextBox> </b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL"> <b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" <b:Button icon="COPY"
ui:field="privateLongLinkCopyButton" type="INFO"></b:Button> ui:field="privateLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip> </b:Tooltip>
</b:InputAddOn> </b:InputAddOn>
</b:Controls> </b:Controls>
@ -164,14 +164,13 @@
<b:TextBox ui:field="textPublicLink" readOnly="true"> <b:TextBox ui:field="textPublicLink" readOnly="true">
</b:TextBox> </b:TextBox>
</b:InputAddOn> </b:InputAddOn>
<b:Button ui:field="showPublicLongLinkButton" type="LINK" addStyleNames="margin-left-5">Show <b:Button ui:field="showPublicLongLinkButton" type="LINK" addStyleNames="margin-left-5">Show as Long URL</b:Button>
as Long URL</b:Button>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup addStyleNames="my-control-group" <b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPublicLongLink" visible="false"> ui:field="cgPublicLongLink" visible="false">
<b:ControlLabel>Private Long Link</b:ControlLabel> <b:ControlLabel></b:ControlLabel>
<b:Controls> <b:Controls>
<b:InputAddOn prependIcon="LINK" <b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width"> addStyleNames="my-prepend-width">
@ -180,7 +179,7 @@
</b:TextBox> </b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL"> <b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" <b:Button icon="COPY"
ui:field="publicLongLinkCopyButton" type="INFO"></b:Button> ui:field="publicLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip> </b:Tooltip>
</b:InputAddOn> </b:InputAddOn>
</b:Controls> </b:Controls>

View File

@ -298,6 +298,6 @@ table.userssuggest th {
.href-disabled { .href-disabled {
pointer-events: none; pointer-events: none;
cursor: default; cursor: default;
color: gray; color: gray !important;
text-decoration: none; text-decoration: none;
} }