PDA

View Full Version : Html Editor not selectable



harun
9 Feb 2010, 8:48 AM
Hi alls,
I searched the forum from beginning to end, but I can't find anything useful.

I tried to use Html editor in my Dialog.The first time html editor working good,but when I try to open new dialog I can't write anything in html editor.My codes are below,can anyone help me, please?



/**
*
*/
package ms.srstool.client.ui;

import ms.srstool.client.XRegistry;
import ms.srstool.client.model.RequirementNode;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.HtmlEditor;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class RequirementDialog extends Dialog
{
TextField<String> tfDefinition = new TextField<String>();
// TextArea taDesc = new TextArea();
HtmlEditor heDesc = new HtmlEditor();
TextField<String> tfParent = new TextField<String>();

RequirementNode currentRequirement = new RequirementNode();
RequirementNode parentRequirement;
RequirementTree requirementTree;
String indexPrefix = "";

public RequirementDialog(RequirementTree reqtree, RequirementNode parent)
{
this.requirementTree = reqtree;
// secili reqnode var onun altina eklenecek
if (parent.getId() > 0) {
this.parentRequirement = parent;
indexPrefix = parentRequirement.getIndex();
} else {// secili reqnode yok parent' null olacak
this.currentRequirement = parent;
// this.currentRequirement.setProjectID(parent.getProjectID());
// this.currentRequirement.setType(parent.getType());
this.parentRequirement = null;
}
setLayout(new FitLayout());
setSize(700, -1);
setHeading("New Requirement");
setModal(true);
setBlinkModal(true);

FormData formData = new FormData("-20");
final FormPanel fp = new FormPanel();
fp.setHeaderVisible(false);
fp.setFrame(true);
fp.setWidth(400);
fp.setLabelWidth(120);
tfDefinition.setFieldLabel("Definition");
tfDefinition.setAllowBlank(false);
fp.add(tfDefinition, formData);

// taDesc.setFieldLabel("Description");
// taDesc.setHeight(100);
// fp.add(taDesc, formData);

heDesc.setFieldLabel("Description");
heDesc.setHeight(200);
fp.add(heDesc, new FormData("-20"));

tfParent.setFieldLabel("Parent");
if (parent.getId() > 0) {
tfParent.setValue(parentRequirement.getIndex()
+ parentRequirement.getShortDesc());
} else {
tfParent.setValue("null");
}
fp.add(tfParent, new FormData("-20"));

setButtonAlign(HorizontalAlignment.CENTER);
setButtons("Empty");
Button btsave = new Button("Save");
getButtonBar().add(btsave);
btsave.addSelectionListener(new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce)
{
if (fp.isValid()) {
currentRequirement.setShortDesc(tfDefinition.getValue());
currentRequirement.setDescription(heDesc.getValue());
if (parentRequirement != null) {
currentRequirement.setParentId(parentRequirement
.getId());
}
XRegistry.getMainService().saveRequirement(
currentRequirement, indexPrefix,
new AsyncCallback<RequirementNode>() {

public void onSuccess(RequirementNode result)
{
if (currentRequirement.getId() > 0) {
requirementTree
.updateRequirement(currentRequirement);

} else if (currentRequirement.getParentId() > 0) {
requirementTree.createNewRequirement(
parentRequirement, result);
} else {
requirementTree
.createBaseRequirement(result);
}

}

public void onFailure(Throwable caught)
{
MessageBox.alert("Error", caught
.getLocalizedMessage(), null);
}
});
hide();
} else {
// ce.cancelBubble();
// ce.stopEvent();
}

}
});

Button btcancel = new Button("Cancel");
getButtonBar().add(btcancel);
btcancel.addSelectionListener(new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce)
{
hide();
}
});
// setFocusWidget(tfDefinition);
add(fp);

}

public void editDialog(RequirementNode rn)
{
setHeading("Edit Requirement");
setSize(700, -1);
tfDefinition.setValue(rn.getShortDesc());
heDesc.setValue(rn.getDescription());
tfParent.setVisible(false);
this.currentRequirement = rn;
this.parentRequirement = null;
show();
}

}
I show this dialog


RequirementDialog rd = new RequirementDialog(RequirementTree.this, rn);
rd.show();