fixed dom message about explore_vres_landing_page
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@146700 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5011dbc176
commit
6f9a110038
|
@ -7,15 +7,18 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCat
|
|||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.event.IFrameInstanciedEvent;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.LoadEvent;
|
||||
import com.google.gwt.event.dom.client.LoadHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Element;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Frame;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.NamedFrame;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -26,10 +29,11 @@ import com.google.gwt.user.client.ui.Image;
|
|||
*/
|
||||
public class CkanFramePanel extends FlowPanel{
|
||||
|
||||
private Frame frame;
|
||||
private NamedFrame frame;
|
||||
//private static final String FRAME_NAME = "ckan-content-frame";
|
||||
private HandlerManager eventBus;
|
||||
private Image loading = new Image(CkanPortletResources.ICONS.loading());
|
||||
|
||||
private String messageToSend;
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan frame panel.
|
||||
|
@ -41,6 +45,24 @@ public class CkanFramePanel extends FlowPanel{
|
|||
addLoading();
|
||||
}
|
||||
|
||||
/**
|
||||
* Post message.
|
||||
*
|
||||
* @param msg the msg (as json)
|
||||
* @param javaScriptObject
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
protected native void sendMessage(String msg, String frameName) /*-{
|
||||
console.log("Sending message " + msg);
|
||||
// $wnd.parent.postMessage(msg,'*');
|
||||
//var f = $wnd.frames[frameName];
|
||||
//console.log(f);
|
||||
//f.contentWindow.postMessage(msg, "*");
|
||||
$wnd.frames[frameName].postMessage(msg,"*")
|
||||
console.log("Message sent");
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Prints the.
|
||||
*
|
||||
|
@ -56,7 +78,7 @@ public class CkanFramePanel extends FlowPanel{
|
|||
* @param ckanUrlConnector the ckan url connector
|
||||
* @return the frame
|
||||
*/
|
||||
public Frame instanceFrame(String ckanUrlConnector) {
|
||||
public Frame instanceFrame(String ckanUrlConnector, final String messageToSend,final String ckanUrl) {
|
||||
GWT.log("Instancing new IFRAME with uri: "+ckanUrlConnector);
|
||||
try{
|
||||
if(frame != null)
|
||||
|
@ -64,10 +86,12 @@ public class CkanFramePanel extends FlowPanel{
|
|||
}catch(Exception e){
|
||||
print("Error " + e);
|
||||
}
|
||||
|
||||
|
||||
addLoading();
|
||||
|
||||
frame = new Frame(ckanUrlConnector);
|
||||
frame = new NamedFrame(GCubeCkanDataCatalog.GCUBE_CKAN_IFRAME);
|
||||
frame.setUrl(ckanUrlConnector);
|
||||
|
||||
frame.getElement().setId(GCubeCkanDataCatalog.GCUBE_CKAN_IFRAME);
|
||||
frame.setWidth("100%");
|
||||
// frame.setHeight("100%");
|
||||
|
@ -78,9 +102,10 @@ public class CkanFramePanel extends FlowPanel{
|
|||
|
||||
@Override
|
||||
public void onLoad(LoadEvent arg0) {
|
||||
|
||||
|
||||
CkanFramePanel.this.remove(loading);
|
||||
|
||||
sendMessage(messageToSend, GCubeCkanDataCatalog.GCUBE_CKAN_IFRAME);
|
||||
|
||||
}
|
||||
});
|
||||
add(frame);
|
||||
|
@ -97,7 +122,7 @@ public class CkanFramePanel extends FlowPanel{
|
|||
public Frame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add loading image
|
||||
*/
|
||||
|
|
|
@ -51,6 +51,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
private boolean isManageProductToShow = false;
|
||||
private static String latestSelectedProductIdentifier;
|
||||
public static final int IFRAME_FIX_HEIGHT = 1800;
|
||||
private JSONObject obj;
|
||||
|
||||
/**
|
||||
* Instantiates a new g cube ckan data catalog panel.
|
||||
|
@ -65,6 +66,14 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
|
||||
this.rootPanel = rootPanel;
|
||||
this.eventBus = eventManager;
|
||||
|
||||
//postMessage(obj.toString(), ckanFramePanel.getFrame());
|
||||
// send message about gateway url
|
||||
obj = new JSONObject();
|
||||
String landingPageVREs = Window.Location.getProtocol() + "//" + Window.Location.getHostName() + "/explore";
|
||||
JSONString value = new JSONString(landingPageVREs);
|
||||
obj.put("explore_vres_landing_page", value);
|
||||
|
||||
ckanFramePanel = new CkanFramePanel(eventBus);
|
||||
managementPanel = new CkanMetadataManagementPanel(eventBus);
|
||||
ckanOrganizationsPanel = new CkanOrganizationsPanel(this);
|
||||
|
@ -219,13 +228,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
|
||||
// listen for DOM messages
|
||||
listenForPostMessage();
|
||||
|
||||
// send message about gateway url
|
||||
JSONObject obj = new JSONObject();
|
||||
String landingPageVREs = Window.Location.getProtocol() + "//" + Window.Location.getHostName() + "/explore";
|
||||
JSONString value = new JSONString(landingPageVREs);
|
||||
obj.put("explore_vres_landing_page", value);
|
||||
postMessage(obj.toString());
|
||||
|
||||
}
|
||||
|
||||
public static String getLatestSelectedProductIdentifier(){
|
||||
|
@ -279,7 +282,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
ckanFramePanel.setVisible(true);
|
||||
ckanOrganizationsPanel.setVisible(false);
|
||||
ckanGroupsPanel.setVisible(false);
|
||||
return ckanFramePanel.instanceFrame(ckanUrlConnector);
|
||||
return ckanFramePanel.instanceFrame(ckanUrlConnector, obj.toString(), ckanAccessPoint.getBaseUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -326,16 +329,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
// workspace.setHeight(height+"px");
|
||||
}
|
||||
|
||||
/**
|
||||
* Post message.
|
||||
*
|
||||
* @param msg the msg (as json)
|
||||
*/
|
||||
protected native void postMessage(String msg) /*-{
|
||||
console.log("Sending message " + msg);
|
||||
$wnd.postMessage(msg, "*");
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Print a message
|
||||
* @param string
|
||||
|
@ -354,7 +347,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
that.@org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDataCatalogPanel::onPostMessage(Ljava/lang/String;Ljava/lang/String;)(msg.data, msg.origin);
|
||||
});
|
||||
}-*/;
|
||||
|
||||
|
||||
/**
|
||||
* On post message.
|
||||
*
|
||||
|
@ -362,11 +355,11 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
* @param origin the origin
|
||||
*/
|
||||
private void onPostMessage(String data, String origin) {
|
||||
GWT.log("Read data: "+data+", from origin: "+origin);
|
||||
GWT.log("Ckan base url: "+ckanAccessPoint.getBaseUrl());
|
||||
printString("Read data: "+data+", from origin: "+origin);
|
||||
printString("Ckan base url: "+ckanAccessPoint.getBaseUrl());
|
||||
|
||||
// parsing data.. it is a json bean of the type
|
||||
GWT.log("Incoming message is " + data + " from " + origin);
|
||||
printString("Incoming message is " + data + " from " + origin);
|
||||
|
||||
if (ckanAccessPoint.getBaseUrl().indexOf(origin)>=0) {
|
||||
// The data has been sent from your site
|
||||
|
|
Loading…
Reference in New Issue