Skip to content

Commit

Permalink
break up form manager API
Browse files Browse the repository at this point in the history
  • Loading branch information
heiko-braun committed Aug 7, 2012
1 parent 3f15658 commit 3f690d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,18 @@ public void createFormProxy(String templateId, String modelId, final AsyncCallba
final FXTemplate fxTemplate = storage.loadTemplate(templateId);
final FXModel fxModel = fxTemplate.getModel(modelId);

loadDmrDescription(fxModel.getAddress(), new SimpleCallback<ModelNode>() {

@Override
public void onSuccess(ModelNode modelNode) {
callback.onSuccess(new FormProxy(fxModel, modelNode, BrowserPresenter.this));
}
});
}

public void loadDmrDescription(ModelNode address, final AsyncCallback<ModelNode> callback) {
ModelNode descriptionOp = new ModelNode();
descriptionOp.get(ADDRESS).set(fxModel.getAddress());
descriptionOp.get(ADDRESS).set(address);
descriptionOp.get(OP).set(READ_RESOURCE_DESCRIPTION_OPERATION);
descriptionOp.get(OPERATIONS).set(true);

Expand Down Expand Up @@ -280,7 +290,7 @@ public void onSuccess(DMRResponse dmrResponse) {
actualDescriptionNode = result;
}

callback.onSuccess(new FormProxy(fxModel, actualDescriptionNode, BrowserPresenter.this));
callback.onSuccess(actualDescriptionNode);
}
}}
);
Expand All @@ -291,9 +301,13 @@ public void getProxyData(String templateId, String modelId, final AsyncCallback<

final FXTemplate fxTemplate = storage.loadTemplate(templateId);
final FXModel fxModel = fxTemplate.getModel(modelId);
loadResourceData(fxModel.getAddress(), callback);
}

public void loadResourceData(ModelNode address, final AsyncCallback<ModelNode> callback)
{
ModelNode resourceOp = new ModelNode();
resourceOp.get(ADDRESS).set(fxModel.getAddress());
resourceOp.get(ADDRESS).set(address);
resourceOp.get(OP).set(READ_RESOURCE_OPERATION);

dispatcher.execute(new DMRAction(resourceOp), new SimpleCallback<DMRResponse>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public interface FXFormManager {

void createFormProxy(String templateId, String modelId, AsyncCallback<FormProxy> callback);
void getProxyData(String templateId, String modelId, final AsyncCallback<ModelNode> callback);

void loadDmrDescription(ModelNode address, final AsyncCallback<ModelNode> callback);
void loadResourceData(ModelNode address, final AsyncCallback<ModelNode> callback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ private void createForm(ModelNode description) {
public void onAttribute(String name, String description, String type, boolean required) {

// whitelist
if(!model.getFieldNames().contains(name))
if(model.getFieldNames().size()>0
&& !model.getFieldNames().contains(name))
return;

if("STRING".equals(type))
Expand Down

0 comments on commit 3f690d8

Please sign in to comment.