geoportal-data-viewer-app/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/ModalWindow.java

73 lines
1.5 KiB
Java
Raw Normal View History

2020-11-20 18:10:43 +01:00
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
2021-07-14 08:12:44 +02:00
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.Modal;
import org.gwtbootstrap3.client.ui.ModalFooter;
2020-11-20 18:10:43 +01:00
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class ModalWindow.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 20, 2020
*/
public class ModalWindow {
private Modal modal;
private Object caller;
/**
* Instantiates a new modal window.
*
* @param title the title
2021-01-15 15:12:03 +01:00
* @param width the width
* @param maxHeight the max height
2020-11-20 18:10:43 +01:00
*/
2021-01-15 15:12:03 +01:00
public ModalWindow(String title, int width, int maxHeight) {
2020-11-20 18:10:43 +01:00
2021-07-14 08:12:44 +02:00
modal = new Modal();
//modal.hide(false);
2020-11-20 18:10:43 +01:00
modal.setTitle(title);
2021-07-14 08:12:44 +02:00
modal.setClosable(true);
modal.setWidth(width+"px");
modal.getElement().getStyle().setProperty("maxHeight",maxHeight+"px");
2020-11-20 18:10:43 +01:00
ModalFooter modalFooter = new ModalFooter();
final Button buttClose = new Button("Close");
modalFooter.add(buttClose);
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modal.hide();
}
});
modal.add(modalFooter);
}
public void add(Widget toAdd) {
modal.add(toAdd);
}
public void setCaller(Object caller) {
this.caller = caller;
}
public void show() {
modal.show();
}
public void setWidth(int width) {
2021-07-14 08:12:44 +02:00
modal.setWidth(width+"px");
2020-11-20 18:10:43 +01:00
}
}