xmlAreaItem.setTitleOrientation(TitleOrientation.TOP);
textForm.setFields(textAreaItem);
editorLayout.addChild(textForm);
VStack moveControls = new VStack(10);
moveControls.setWidth(handleHorizontal(32));
moveControls.setHeight(handleVertical(74));
moveControls.setLayoutAlign(Alignment.CENTER);
TransferImgButton rightArrow = new TransferImgButton(
TransferImgButton.RIGHT, new ClickHandler() {
public void onClick(ClickEvent event) {
unmarshelService.unmarshel(
textAreaItem.getValue() + "", TreeToStruct
.getStruct(treeGrid, rootNode, null),
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof UnmarshalException) {
String val = (String) textAreaItem
.getValue();
String after = val
.replace("\n", "\r\n")
.substring(
0,
((UnmarshalException) caught).lastPossition);
int count = after.length()
- after.replace("\r\n",
"\n").length();
textAreaItem
.setSelectionRange(
0,
((UnmarshalException) caught).lastPossition
- count);
xmlAreaItem.setValue("");
com.google.gwt.user.client.Window
.alert("Parsing failed. Managed to parse only the selected text. Last position:"
+ ((UnmarshalException) caught).lastPossition);
} else {
com.google.gwt.user.client.Window
.alert("Operation failed.");
}
GWT.log("", caught);
}
@Override
public void onSuccess(String result) {
xmlAreaItem.setValue(result);
}
});
}
});
moveControls.addMember(rightArrow);
TransferImgButton leftArrow = new TransferImgButton(
TransferImgButton.LEFT, new ClickHandler() {
public void onClick(ClickEvent event) {
unmarshelService.marshel(xmlAreaItem.getValue() + "",
TreeToStruct
.getStruct(treeGrid, rootNode, null),
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
com.google.gwt.user.client.Window
.alert("Can't perform operation: "
+ caught);
GWT.log("", caught);
}
@Override
public void onSuccess(String result) {
textAreaItem.setValue(result);
}
});
}
});
moveControls.addMember(leftArrow);
moveControls.setTop(handleVertical(80));
moveControls.setLeft(handleHorizontal(585));
editorLayout.addChild(moveControls);
xmlForm.setFields(xmlAreaItem);
editorLayout.addChild(xmlForm);