View Javadoc

1   /**
2    * 
3    */
4   package org.appfuse.webapp.client.ui.upload.views;
5   
6   import org.appfuse.webapp.client.ui.upload.UploadedFileBean;
7   
8   import com.github.gwtbootstrap.client.ui.Button;
9   import com.google.gwt.core.client.GWT;
10  import com.google.gwt.dom.client.AnchorElement;
11  import com.google.gwt.editor.client.Editor;
12  import com.google.gwt.editor.client.EditorDriver;
13  import com.google.gwt.editor.client.SimpleBeanEditorDriver;
14  import com.google.gwt.event.dom.client.ClickEvent;
15  import com.google.gwt.safehtml.shared.SafeHtmlUtils;
16  import com.google.gwt.uibinder.client.UiBinder;
17  import com.google.gwt.uibinder.client.UiField;
18  import com.google.gwt.uibinder.client.UiHandler;
19  import com.google.gwt.user.client.ui.Composite;
20  import com.google.gwt.user.client.ui.Label;
21  import com.google.gwt.user.client.ui.Widget;
22  
23  /**
24   * @author ivangsa
25   *
26   */
27  public class UploadedFileViewImpl extends Composite implements UploadedFileView, Editor<UploadedFileBean> {
28  
29      interface Binder extends UiBinder<Widget, UploadedFileViewImpl> {
30      }
31  
32      private static final Binder BINDER = GWT.create(Binder.class);
33  
34      interface Driver extends SimpleBeanEditorDriver<UploadedFileBean, UploadedFileViewImpl> {
35      }
36  
37      private Driver driver = GWT.create(Driver.class);
38  
39      private UploadedFileView.Delegate delegate;
40  
41      @UiField
42      Label name;
43      @UiField
44      Label fileName;
45      @UiField
46      Label contentType;
47      @UiField
48      Label size;
49      @UiField
50      AnchorElement location;
51  
52      @UiField
53      Button doneButton;
54      @UiField
55      Button uploadAnotherFileButton;
56  
57      /**
58  	 * 
59  	 */
60      public UploadedFileViewImpl() {
61          super();
62          initWidget(BINDER.createAndBindUi(this));
63          driver.initialize(this);
64      }
65  
66      @Override
67      public void setDelegate(UploadedFileView.Delegate delegate) {
68          this.delegate = delegate;
69      }
70  
71      @Override
72      public void display(UploadedFileBean object) {
73          driver.edit(object);
74          location.setHref(object.getLink());
75          location.setInnerSafeHtml(SafeHtmlUtils.fromSafeConstant(object.getLocation()));
76      }
77  
78      @Override
79      public EditorDriver<UploadedFileBean> getEditorDriver() {
80          return driver;
81      }
82  
83      @UiHandler("doneButton")
84      public void onDoneClick(ClickEvent event) {
85          delegate.onDoneClick();
86      }
87  
88      @UiHandler("uploadAnotherFileButton")
89      public void onUploadAnotherFileClick(ClickEvent event) {
90          delegate.onUploadAnotherFileClick();
91      }
92  
93  }