2016-06-13 09:48:29 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view;
|
|
|
|
|
2016-07-15 18:19:05 +02:00
|
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCatalog;
|
2016-06-23 12:49:45 +02:00
|
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.IFrameInstanciedEvent;
|
2016-09-14 16:42:46 +02:00
|
|
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
|
2016-06-23 12:49:45 +02:00
|
|
|
|
2016-06-22 18:40:38 +02:00
|
|
|
import com.google.gwt.core.shared.GWT;
|
2016-09-14 16:42:46 +02:00
|
|
|
import com.google.gwt.dom.client.Style.Display;
|
2016-06-13 09:48:29 +02:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
import com.google.gwt.event.dom.client.LoadEvent;
|
|
|
|
import com.google.gwt.event.dom.client.LoadHandler;
|
2016-06-23 12:49:45 +02:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2016-06-13 09:48:29 +02:00
|
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Frame;
|
2016-09-14 16:42:46 +02:00
|
|
|
import com.google.gwt.user.client.ui.Image;
|
2016-06-13 09:48:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class CkanFramePanel.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
|
|
* Jun 9, 2016
|
|
|
|
*/
|
|
|
|
public class CkanFramePanel extends FlowPanel{
|
|
|
|
|
|
|
|
private Frame frame;
|
2016-06-23 12:49:45 +02:00
|
|
|
private HandlerManager eventBus;
|
2016-09-14 16:42:46 +02:00
|
|
|
private Image loading = new Image(CkanPortletResources.ICONS.loading());
|
2016-06-23 12:49:45 +02:00
|
|
|
|
2016-06-13 09:48:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new ckan frame panel.
|
2016-06-23 12:49:45 +02:00
|
|
|
*
|
|
|
|
* @param eventBus the event bus
|
2016-06-13 09:48:29 +02:00
|
|
|
*/
|
2016-06-23 12:49:45 +02:00
|
|
|
public CkanFramePanel(HandlerManager eventBus) {
|
|
|
|
this.eventBus = eventBus;
|
2016-09-14 18:06:49 +02:00
|
|
|
addLoading();
|
2016-06-13 09:48:29 +02:00
|
|
|
}
|
|
|
|
|
2016-06-23 12:49:45 +02:00
|
|
|
/**
|
|
|
|
* Prints the.
|
|
|
|
*
|
|
|
|
* @param msg the msg
|
|
|
|
*/
|
2016-06-22 18:40:38 +02:00
|
|
|
private static native void print(String msg)/*-{
|
|
|
|
console.log(msg);
|
|
|
|
}-*/;
|
|
|
|
|
2016-06-13 09:48:29 +02:00
|
|
|
/**
|
|
|
|
* Instance frame.
|
|
|
|
*
|
|
|
|
* @param ckanUrlConnector the ckan url connector
|
|
|
|
* @return the frame
|
|
|
|
*/
|
|
|
|
public Frame instanceFrame(String ckanUrlConnector) {
|
2016-06-23 12:49:45 +02:00
|
|
|
GWT.log("Instancing new IFRAME with uri: "+ckanUrlConnector);
|
2016-06-22 18:40:38 +02:00
|
|
|
try{
|
|
|
|
if(frame != null)
|
|
|
|
remove(frame);
|
|
|
|
}catch(Exception e){
|
|
|
|
print("Error " + e);
|
|
|
|
}
|
2016-09-14 18:06:49 +02:00
|
|
|
|
|
|
|
addLoading();
|
2016-06-22 18:40:38 +02:00
|
|
|
|
2016-06-13 09:48:29 +02:00
|
|
|
frame = new Frame(ckanUrlConnector);
|
2016-07-15 18:19:05 +02:00
|
|
|
frame.getElement().setId(GCubeCkanDataCatalog.GCUBE_CKAN_IFRAME);
|
|
|
|
frame.setWidth("100%");
|
2016-09-14 16:42:46 +02:00
|
|
|
// frame.setHeight("100%");
|
|
|
|
// frame.getElement().getStyle().setOverflow(Overflow.HIDDEN);
|
|
|
|
// frame.getElement().setAttribute("scrolling", "no");
|
2016-06-13 09:48:29 +02:00
|
|
|
frame.getElement().getStyle().setBorderWidth(0, Unit.PX);
|
|
|
|
frame.addLoadHandler(new LoadHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLoad(LoadEvent arg0) {
|
2016-09-14 16:42:46 +02:00
|
|
|
|
|
|
|
CkanFramePanel.this.remove(loading);
|
|
|
|
|
2016-06-13 09:48:29 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
add(frame);
|
2016-06-29 16:50:18 +02:00
|
|
|
frame.setVisible(true);
|
2016-06-23 12:49:45 +02:00
|
|
|
eventBus.fireEvent(new IFrameInstanciedEvent());
|
2016-06-13 09:48:29 +02:00
|
|
|
return frame;
|
|
|
|
}
|
2016-06-23 12:49:45 +02:00
|
|
|
|
2016-06-13 09:48:29 +02:00
|
|
|
/**
|
2016-06-23 12:49:45 +02:00
|
|
|
* Gets the frame.
|
|
|
|
*
|
|
|
|
* @return the frame
|
2016-06-13 09:48:29 +02:00
|
|
|
*/
|
|
|
|
public Frame getFrame() {
|
|
|
|
return frame;
|
|
|
|
}
|
2016-09-14 18:06:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* add loading image
|
|
|
|
*/
|
|
|
|
private void addLoading(){
|
|
|
|
this.add(loading);
|
|
|
|
loading.getElement().getStyle().setProperty("margin", "auto");
|
|
|
|
loading.getElement().getStyle().setDisplay(Display.BLOCK);
|
|
|
|
}
|
2016-06-13 09:48:29 +02:00
|
|
|
}
|