added feature for editing VRE Text
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@128598 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
parent
75782b29d0
commit
abba2f43e5
@ -0,0 +1,108 @@
|
||||
package org.gcube.portlets.user.gcubeloggedin.client.ui;
|
||||
|
||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
|
||||
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Icon;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Window.Location;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class EditDescriptionModal extends Composite {
|
||||
private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class);
|
||||
private static EditDescriptionModalUiBinder uiBinder = GWT
|
||||
.create(EditDescriptionModalUiBinder.class);
|
||||
|
||||
interface EditDescriptionModalUiBinder extends
|
||||
UiBinder<Widget, EditDescriptionModal> {
|
||||
}
|
||||
|
||||
private String currDescription;
|
||||
|
||||
@UiField Modal modal;
|
||||
@UiField TextArea text2Edit;
|
||||
@UiField Button cancel;
|
||||
@UiField Button save;
|
||||
@UiField Icon loading;
|
||||
@UiField Paragraph loadingContainer;
|
||||
@UiField Paragraph loadingText;
|
||||
|
||||
|
||||
public EditDescriptionModal(String vreName, String currDescription) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
modal.setTitle(vreName + " description/abstract");
|
||||
text2Edit.setBlockLevel(true);
|
||||
text2Edit.setVisibleLines(10);
|
||||
this.currDescription = currDescription;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
text2Edit.setText(transformDescription(currDescription));
|
||||
text2Edit.setVisible(true);
|
||||
loadingContainer.setVisible(false);
|
||||
save.setVisible(true);
|
||||
modal.show();
|
||||
}
|
||||
|
||||
@UiHandler("cancel")
|
||||
void onCancelButton(ClickEvent e) {
|
||||
modal.hide();
|
||||
}
|
||||
|
||||
|
||||
@UiHandler("save")
|
||||
void onSaveButton(ClickEvent e) {
|
||||
final String vreDescription = text2Edit.getText();
|
||||
text2Edit.setText("");
|
||||
text2Edit.setVisible(false);
|
||||
loadingContainer.setVisible(true);
|
||||
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
doSave(vreDescription);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doSave(String toSave) {
|
||||
loggedinService.saveVREDescription(toSave, new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
loading.setIcon(IconType.CHECK_SIGN);
|
||||
loading.setSpin(false);
|
||||
loadingText.setText("Saving successful, please refresh the page to see your changes.");
|
||||
save.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private String transformDescription(String VREDescription) {
|
||||
String toReturn = VREDescription;
|
||||
// replace all the line breaks by <br/>
|
||||
toReturn = toReturn.replaceAll("<script","");
|
||||
toReturn = toReturn.replaceAll("</script","");
|
||||
return VREDescription;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<g:HTMLPanel>
|
||||
<b:Modal ui:field="modal" backdrop="STATIC"
|
||||
keyboard="true" animation="true">
|
||||
<b:TextArea ui:field="text2Edit">Modal Content!</b:TextArea>
|
||||
<b:Paragraph ui:field="loadingContainer" styleName="loading-text" visible="false">
|
||||
<b:Paragraph ui:field="loadingText">Saving VRE Description please wait ... </b:Paragraph>
|
||||
<b:Icon type="COG" size="FOUR_TIMES" spin="true" ui:field="loading"/>
|
||||
</b:Paragraph>
|
||||
<b:ModalFooter>
|
||||
<b:Button type="DEFAULT" ui:field="cancel">Close</b:Button>
|
||||
<b:Button icon="FILE" type="PRIMARY" ui:field="save">Save</b:Button>
|
||||
</b:ModalFooter>
|
||||
</b:Modal>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
@ -1,22 +1,16 @@
|
||||
package org.gcube.portlets.user.gcubeloggedin.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author massi
|
||||
*
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class VREClient extends VObject {
|
||||
|
||||
public VREClient() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public VREClient(String name, String groupName, String description, String imageURL, String friendlyURL,
|
||||
UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest) {
|
||||
super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest);
|
||||
// TODO Auto-generated constructor stub
|
||||
UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest, boolean isManager) {
|
||||
super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest, isManager);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue