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.event.dom.client.ClickEvent;
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.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
@ -175,6 +177,33 @@ public class DialogShareableLink extends Composite {
final Button buttClose = new Button("Close");
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
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() {
@Override
@ -204,7 +225,6 @@ public class DialogShareableLink extends Composite {
}
});
showPrivateLongLinkButton.addClickHandler(new ClickHandler() {
@Override
@ -225,8 +245,11 @@ public class DialogShareableLink extends Composite {
cgPublicLongLink.setVisible(true);
textPublicLongLink.setText(loadedPublicLink.getCompleteURL());
}else {
textPublicLongLink.setText("Not available");
showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled");
// showPublicLongLinkButton.setVisible(false);
disableTextBox(textPublicLongLink);
}
}
});
@ -237,6 +260,7 @@ public class DialogShareableLink extends Composite {
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copied to clipboard");
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@ -247,11 +271,19 @@ public class DialogShareableLink extends Composite {
};
timer.schedule(1000);
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() {
@ -268,11 +300,19 @@ public class DialogShareableLink extends Composite {
};
timer.schedule(1000);
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() {
@Override
@ -288,11 +328,19 @@ public class DialogShareableLink extends Composite {
};
timer.schedule(1000);
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() {
@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) {
textBox.setEnabled(false);
textBox.getElement().getStyle().setOpacity(0.3);
@ -632,8 +674,10 @@ public class DialogShareableLink extends Composite {
allowAccessToFolderLink(item.getIdentifier(), setAsPublic);
} else {
showError("Permission Denied!" + " "+result.getAccessAllowDenyMotivation());
showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled");
// showPublicLongLinkButton.setText("Not available");
// showPublicLongLinkButton.addStyleName("href-disabled");
showPublicLongLinkButton.setVisible(false);
textPublicLink.setText("You are not authorized");
disableTextBox(textPublicLink);
}

View File

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

View File

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