I built the FCKEditor in a GWT Composite and the image dialogs and other pops worked correctly. I changed Composite to a Canvas and none of the dialogs, form insertions etc. now work. I tried putting the composite version in a GWT PopupPanel to get around the problem but I can't get it to show. Is smartGWT interfering with the display?
I traced the code in the debugger and the process looked correct. Below is the code for the editor:
package edu.iastate.its.project.model.sharedwidgets.client.common;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
public class FCKEditor extends PopupPanel implements HasHTML {
private String elementID;
private HTML html;
private HTMLSaveListener listener;
private String cssWidth,cssHeight;
private String toolBar = "Default";
/**
* @wbp.parser.constructor
*/
public FCKEditor() {
this("600","400",null);
}
public FCKEditor(String cssWidth, String cssHeight, HTMLSaveListener listener) {
this.listener = listener;
this.cssWidth = cssWidth;
this.cssHeight = cssHeight;
this.elementID = "edu-iastate-its-project-model-sharedwidgets-htmleditor-"+System.identityHashCode(this);
html = new HTML();
HorizontalPanel hpanel = new HorizontalPanel();
Button save = new Button("Save");
save.addClickListener(new ClickListener() {
public void onClick(Widget w) {
save();
}
});
Button cancel = new Button("Cancel");
cancel.addClickListener(new ClickListener() {
public void onClick(Widget w) {
cancel();
}
});
hpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
hpanel.add(save);
hpanel.add(cancel);
VerticalPanel vpanel = new VerticalPanel();
vpanel.add(hpanel);
vpanel.add(html);
setWidget(vpanel);
}
/**
* Returns the HTML currently contained in the editor
*
* @return the HTML currently contained in the editor
*/
public String getHTML() {
return jsniGetText(elementID);
}
/**
* Returns <code>null</code> as this editor doesn't support straight text editing.
*
* @return <code>null</code> as this editor doesn't support straight text editing.
*/
public String getText() {
return null;
}
/**
* Sets the HTML currently contained in the editor
*
* @param html the HTML currently contained in the editor
*/
public void setHTML(String html) {
jsniSetText(elementID, html);
}
/**
* Does nothing as straight text editing is not supported by this editor
*
* @param text ignored
*/
public void setText(String text) {
//Do nothing
}
public void edit(String htmlText) {
show();
html.setHTML("<textarea wrap=\"virtual\" id=\""+elementID+"\">"+htmlText+"</textarea>");
initEditor(elementID,cssWidth,cssHeight,GWT.getModuleBaseURL(),"lib",toolBar);
}
private void save() {
String html = jsniGetText(elementID);
if (listener != null)
listener.onSave(html);
hide();
}
private void cancel() {
hide();
}
public String getToolBar() {
return toolBar;
}
public void setToolBar(String toolBar) {
this.toolBar = toolBar;
}
private static native String jsniGetText(String elementID) /*-{
if ($wnd.FCKeditorAPI) {
var instance = $wnd.FCKeditorAPI.GetInstance(elementID);
if (instance != null) {
return instance.GetXHTML(true);
} else {
//The instance isn't bound yet
return null;
}
} else {
//We're not bound yet in some way
return null;
}
}-*/;
private static native void jsniSetText(String elementID, String html) /*-{
if ($wnd.FCKeditorAPI) {
var instance = $wnd.FCKeditorAPI.GetInstance(elementID);
if (instance != null) {
return instance.SetHTML(html);
} else {
//The instance isn't bound yet
return;
}
} else {
//We're not bound yet in some way
return;
}
}-*/;
private native void initEditor(String name, String width, String height,String base, String root, String toolbar) /*-{
var editor = new $wnd.FCKeditor(name,parseInt(width),parseInt(height),toolbar,'');
editor.BasePath= base+'fckeditor/';
editor.Config['BaseHref'] = base + '/resources/' + root;
var link_url = '/resources/' + '&ServerPath=' + root;
var image_url = link_url + '&Type=Image';
var browserURL = editor.BasePath+'editor/filemanager/browser/default/browser.html?Connector=../../../../../';
editor.Config['ImageBrowserURL'] = browserURL + image_url;
editor.Config['LinkBrowserURL'] = browserURL + link_url;
editor.Config['EditorAreaCSS'] = editor.basePath + "skins/default/fck_editor.css";
editor.Config['StylesXmlPath'] = editor.BasePath + "fckstyles.xml";
editor.Config['TemplatesXmlPath'] = editor.BasePath + "fcktemplates.xml";
editor.ReplaceTextarea();
}-*/;
}
I traced the code in the debugger and the process looked correct. Below is the code for the editor:
package edu.iastate.its.project.model.sharedwidgets.client.common;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
public class FCKEditor extends PopupPanel implements HasHTML {
private String elementID;
private HTML html;
private HTMLSaveListener listener;
private String cssWidth,cssHeight;
private String toolBar = "Default";
/**
* @wbp.parser.constructor
*/
public FCKEditor() {
this("600","400",null);
}
public FCKEditor(String cssWidth, String cssHeight, HTMLSaveListener listener) {
this.listener = listener;
this.cssWidth = cssWidth;
this.cssHeight = cssHeight;
this.elementID = "edu-iastate-its-project-model-sharedwidgets-htmleditor-"+System.identityHashCode(this);
html = new HTML();
HorizontalPanel hpanel = new HorizontalPanel();
Button save = new Button("Save");
save.addClickListener(new ClickListener() {
public void onClick(Widget w) {
save();
}
});
Button cancel = new Button("Cancel");
cancel.addClickListener(new ClickListener() {
public void onClick(Widget w) {
cancel();
}
});
hpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
hpanel.add(save);
hpanel.add(cancel);
VerticalPanel vpanel = new VerticalPanel();
vpanel.add(hpanel);
vpanel.add(html);
setWidget(vpanel);
}
/**
* Returns the HTML currently contained in the editor
*
* @return the HTML currently contained in the editor
*/
public String getHTML() {
return jsniGetText(elementID);
}
/**
* Returns <code>null</code> as this editor doesn't support straight text editing.
*
* @return <code>null</code> as this editor doesn't support straight text editing.
*/
public String getText() {
return null;
}
/**
* Sets the HTML currently contained in the editor
*
* @param html the HTML currently contained in the editor
*/
public void setHTML(String html) {
jsniSetText(elementID, html);
}
/**
* Does nothing as straight text editing is not supported by this editor
*
* @param text ignored
*/
public void setText(String text) {
//Do nothing
}
public void edit(String htmlText) {
show();
html.setHTML("<textarea wrap=\"virtual\" id=\""+elementID+"\">"+htmlText+"</textarea>");
initEditor(elementID,cssWidth,cssHeight,GWT.getModuleBaseURL(),"lib",toolBar);
}
private void save() {
String html = jsniGetText(elementID);
if (listener != null)
listener.onSave(html);
hide();
}
private void cancel() {
hide();
}
public String getToolBar() {
return toolBar;
}
public void setToolBar(String toolBar) {
this.toolBar = toolBar;
}
private static native String jsniGetText(String elementID) /*-{
if ($wnd.FCKeditorAPI) {
var instance = $wnd.FCKeditorAPI.GetInstance(elementID);
if (instance != null) {
return instance.GetXHTML(true);
} else {
//The instance isn't bound yet
return null;
}
} else {
//We're not bound yet in some way
return null;
}
}-*/;
private static native void jsniSetText(String elementID, String html) /*-{
if ($wnd.FCKeditorAPI) {
var instance = $wnd.FCKeditorAPI.GetInstance(elementID);
if (instance != null) {
return instance.SetHTML(html);
} else {
//The instance isn't bound yet
return;
}
} else {
//We're not bound yet in some way
return;
}
}-*/;
private native void initEditor(String name, String width, String height,String base, String root, String toolbar) /*-{
var editor = new $wnd.FCKeditor(name,parseInt(width),parseInt(height),toolbar,'');
editor.BasePath= base+'fckeditor/';
editor.Config['BaseHref'] = base + '/resources/' + root;
var link_url = '/resources/' + '&ServerPath=' + root;
var image_url = link_url + '&Type=Image';
var browserURL = editor.BasePath+'editor/filemanager/browser/default/browser.html?Connector=../../../../../';
editor.Config['ImageBrowserURL'] = browserURL + image_url;
editor.Config['LinkBrowserURL'] = browserURL + link_url;
editor.Config['EditorAreaCSS'] = editor.basePath + "skins/default/fck_editor.css";
editor.Config['StylesXmlPath'] = editor.BasePath + "fckstyles.xml";
editor.Config['TemplatesXmlPath'] = editor.BasePath + "fcktemplates.xml";
editor.ReplaceTextarea();
}-*/;
}
Comment