Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. @UiField
  2. TextBox name;
  3.  
  4. @UiField
  5. TextArea comment;
  6.  
  7. @UiField
  8. ListBox type;
  9.  
  10. ...
  11.  
  12. private void editCustomer(CustomerProxy entity) {
  13.  
  14. MyRequestFactory requestFactory = MyRequest.getRequestFactory();
  15.  
  16. CustomerRequestContext requestContext = requestFactory.customerRequest();
  17.  
  18. entity = requestContext.edit(entity);
  19.  
  20. editorDriver.edit(entity, requestContext);
  21. }
  22.  
  23. @UiHandler("saveButton")
  24. void onSaveButtonClick(ClickEvent event){
  25. ????
  26. }
  27.  
  28. public abstract class AbstractTaskBuilderActivity extends <E extends AnalyticsTaskProxy, R extends DaoRequest<E>> implements TaskBuilderView {
  29.  
  30.  
  31. /**
  32. * Create a new task. This will initialize any new lists.
  33. * @param context The RequestContext to use to create the task.
  34. * @param clazz The class type to be created.
  35. * @return
  36. */
  37. protected E create(R context, Class<E> clazz) {
  38. // This is implemented in my inherited classes.
  39. E editableAnalyticsTask = context.create(clazz);
  40. // More initialization code expecially initializing arrays to empty so that
  41. // any ListEditor sub editors will work.
  42.  
  43.  
  44. return editableAnalyticsTask;
  45. }
  46.  
  47. /**
  48. * Call to edit the task and update the dashboards.
  49. * @param context
  50. * @param task
  51. */
  52. protected void doEdit(R context, E task) {
  53. RequestFactoryEditorDriver<? super AnalyticsTaskProxy, ?> driver = display.getEditorDriver();
  54. E editable = context.edit(task);
  55. context.save(editable).with(driver.getPaths()).to(new Receiver<Long>() {
  56.  
  57. @Override
  58. public void onFailure(ServerFailure error) {
  59. display.showError(error.getMessage());
  60. super.onFailure(error);
  61. }
  62.  
  63. public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
  64. display.getEditorDriver().setConstraintViolations(violations);
  65. }
  66.  
  67. @Override
  68. public void onSuccess(Long response) {
  69. clientFactory.getPlaceController().goTo(getSavePlace());
  70. }
  71.  
  72. });
  73. driver.edit(editable, context);
  74. }
  75.  
  76.  
  77. /**
  78. * Save the task.
  79. */
  80. @Override
  81. public void onSaveTask() {
  82.  
  83. RequestFactoryEditorDriver<? super AnalyticsTaskProxy, ?> driver = display.getEditorDriver();
  84.  
  85. RequestContext request = driver.flush();
  86. request.fire();
  87. }
  88.  
  89. }
  90.  
  91. public interface TaskBuilderView extends View {
  92.  
  93. public interface Presenter {
  94. void onSaveTask();
  95. }
  96.  
  97. public RequestFactoryEditorDriver<AnalyticsTaskProxy, ?> getFactoryEditorDriver();
  98.  
  99. public void setPresenter(Presenter presenter);
  100. }
  101.  
  102. public class AnalyticsTaskBuilderViewImpl extends ViewImpl implements AnalyticsTaskBuilderView, Editor<AnalyticsTaskProxy> {
  103.  
  104. interface AnalyticsTaskBuilderDriver extends RequestFactoryEditorDriver<AnalyticsTaskProxy, AnalyticsTaskBuilderViewImpl> {
  105. }
  106.  
  107. /**
  108. * UiBinder implementation.
  109. *
  110. * @author chinshaw
  111. *
  112. */
  113. @UiTemplate("AnalyticsTaskBuilderView.ui.xml")
  114. interface Binder extends UiBinder<Widget, AnalyticsTaskBuilderViewImpl> {
  115. }
  116.  
  117. /**
  118. * Name component for the name of the analytics operation.
  119. * This also implements {@link HasEditorErrors so it can show
  120. * constraint violations when an error occurs.
  121. */
  122. @UiField
  123. ValueBoxEditorDecorator<String> name;
  124.  
  125. /**
  126. * Description component that edits analytics operation description.
  127. * This also implements {@link HasEditorErrors} so it can show
  128. * constraint violations when an error occurs
  129. */
  130. @UiField
  131. ValueBoxEditorDecorator<String> description;
  132.  
  133. public AnalyticsTaskBuilderViewImpl(Resources resources) {
  134. super(resources);
  135. // Must initialize the view before calling driver initialize
  136. initWidget(GWT.<Binder> create(Binder.class).createAndBindUi(this));
  137. driver.initialize(this);
  138. }
  139.  
  140. @Override
  141. public void setPresenter(Presenter presenter) {
  142. this.presenter = presenter;
  143. bindToPresenter();
  144. }
  145.  
  146. // Save the task
  147. @UiHandler("saveTask")
  148. void handleClick(ClickEvent clickEvent) {
  149. presenter.onSaveTask();
  150. }
  151.  
  152. @Override
  153. public RequestFactoryEditorDriver<AnalyticsTaskProxy, ?> getEditorDriver() {
  154. return driver;
  155. }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement