Example usage for com.google.gwt.user.client.ui FormPanel reset

List of usage examples for com.google.gwt.user.client.ui FormPanel reset

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FormPanel reset.

Prototype

public void reset() 

Source Link

Document

Resets the form, clearing all fields.

Usage

From source file:org.freemedsoftware.gwt.client.screen.patient.ScannedDocumentsEntryScreen.java

License:Open Source License

protected void initClinicalAssesmentForm() {
    containerScannedDocumentsForm = new VerticalPanel();
    containerScannedDocumentsForm.setWidth("100%");
    if (canWrite)
        tabPanel.add(containerScannedDocumentsForm, scannedDocumentsEntryLabel.getText());
    containerScannedDocumentsForm.setWidth("100%");
    scannedDocumentsEntryLabel.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
    scannedDocumentsEntryLabel.setVisible(false);
    containerScannedDocumentsForm.add(scannedDocumentsEntryLabel);

    int row = 0;/*from  w  w  w  . ja  va  2s  .c o  m*/

    final FlexTable flexTable = new FlexTable();
    containerScannedDocumentsForm.add(flexTable);

    Label label = new Label(_("Date"));
    flexTable.setWidget(row, 0, label);
    final CustomDatePicker date = new CustomDatePicker();
    flexTable.setWidget(row, 1, date);
    containerScannedDocumentsFormFields.put("imagedt", date);
    row++;

    label = new Label(_("Type of Image"));
    flexTable.setWidget(row, 0, label);
    final CustomListBox typeOfImage = new CustomListBox();
    typeOfImage.addItem(_("Operative Report"), "op_report/misc");
    typeOfImage.addItem("- " + _("Colonoscopy"), "op_report/colonoscopy");
    typeOfImage.addItem("- " + _("Endoscopy"), "op_report/endoscopy");
    typeOfImage.addItem(_("Miscellaneous"), "misc/misc");
    typeOfImage.addItem("- " + _("Consult"), "misc/consult");
    typeOfImage.addItem("- " + _("Discharge Summary"), "misc/discharge_summary");
    typeOfImage.addItem("- " + _("History and Physical"), "misc/history_and_physical");
    typeOfImage.addItem(_("Lab Report"), "lab_report/misc");
    typeOfImage.addItem("- CBC", "lab_report/cbc");
    typeOfImage.addItem("- C8", "lab_report/c8");
    typeOfImage.addItem("- LFT", "lab_report/lft");
    typeOfImage.addItem("- " + _("Lipid Profile"), "lab_report/lipid_profile");
    typeOfImage.addItem("- UA", "lab_report/ua");
    typeOfImage.addItem("- " + _("Thyroid Profile"), "lab_report/thyroid_profile");
    typeOfImage.addItem(_("Letters"), "letters/misc");
    typeOfImage.addItem(_("Oncology"), "oncology/misc");
    typeOfImage.addItem(_("Hospital Records"), "hospital/misc");
    typeOfImage.addItem("- " + _("Discharge Summary"), "hospital/discharge");
    typeOfImage.addItem(_("Pathology"), "pathology/misc");
    typeOfImage.addItem(_("Patient"), "patient/misc");
    typeOfImage.addItem("- " + _("Consent"), "patient/consent");
    typeOfImage.addItem("- " + _("History"), "patient/history");
    typeOfImage.addItem("- " + _("Time Out"), "patient/time_out");
    typeOfImage.addItem(_("Questionnaire"), "questionnaire/misc");
    typeOfImage.addItem(_("Radiology"), "radiology/misc");
    typeOfImage.addItem("- " + _("Abdominal Radiograph"), "radiology/abdominal_radiograph");
    typeOfImage.addItem("- " + _("Chest Radiograph"), "radiology/chest_radiograph");
    typeOfImage.addItem("- " + _("Abdominal CT Reports"), "radiology/abdominal_ct_reports");
    typeOfImage.addItem("- " + _("Chest CT Reports"), "radiology/chest_ct_reports");
    typeOfImage.addItem("- " + _("Mammogram Reports"), "radiology/mammogram_reports");
    typeOfImage.addItem(_("Insurance Card"), "insurance_card");
    typeOfImage.addItem(_("Referral"), "referral/misc");
    typeOfImage.addItem("- " + _("Notes"), "referral/notes");
    typeOfImage.addItem("- " + _("Radiographs"), "referral/radiographs");
    typeOfImage.addItem("- " + _("Lab Reports"), "referral/lab_reports");
    typeOfImage.addItem("- " + _("Consult"), "referral/consult");
    typeOfImage.addItem(_("Financial Information"), "financial/misc");
    flexTable.setWidget(row, 1, typeOfImage);
    containerScannedDocumentsFormFields.put("imagetypecat", typeOfImage);
    row++;

    label = new Label(_("Physician"));
    flexTable.setWidget(row, 0, label);
    final ProviderWidget provider = new ProviderWidget();
    flexTable.setWidget(row, 1, provider);
    containerScannedDocumentsFormFields.put("imagephy", provider);
    row++;

    label = new Label(_("Description"));
    flexTable.setWidget(row, 0, label);
    final TextArea description = new TextArea();
    flexTable.setWidget(row, 1, description);
    containerScannedDocumentsFormFields.put("imagedesc", description);
    row++;

    label = new Label(_("Attach Image"));
    flexTable.setWidget(row, 0, label);
    final FileUpload fileUpload = new FileUpload();
    fileUpload.setName("imageupload");
    final FormPanel formPanel = new FormPanel();
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_POST);
    formPanel.add(fileUpload);
    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent arg0) {
            Integer id = (Integer) JsonUtil.shoehornJson(JSONParser.parseStrict(arg0.getResults()), "Integer");
            if (id != null) {
                Util.showInfoMsg(moduleName, _("Document added successfully."));
                formPanel.reset();
                resetForm();
                populateAvailableData();
            } else {
                Util.showErrorMsg(moduleName, _("Failed to add document."));
            }

        }

    });
    flexTable.setWidget(row, 1, formPanel);

    row++;

    HorizontalPanel buttonContainer = new HorizontalPanel();
    flexTable.setWidget(row, 1, buttonContainer);

    wSubmit = new CustomButton(_("Submit"), AppConstants.ICON_ADD);
    buttonContainer.add(wSubmit);

    wSubmit.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            String method = "Add";
            HashMap<String, String> data = Util.populateHashMap(containerScannedDocumentsFormFields);
            data.put("imagepat", patientId.toString());
            if (scannedDocumentId != null) {
                data.put("id", scannedDocumentId.toString());
                method = "Mod";
            }
            String[] params = { JsonUtil.jsonify(data) };
            String url = Util.getJsonRequest("org.freemedsoftware.module.ScannedDocuments." + method, params);
            formPanel.setAction(url);
            formPanel.submit();
        }

    });

    CustomButton resetButton = new CustomButton(_("Reset"), AppConstants.ICON_CLEAR);
    buttonContainer.add(resetButton);

    resetButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            formPanel.reset();
            resetForm();
        }

    });

    wDelete = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
    buttonContainer.add(wDelete);
    wDelete.setVisible(false);
    wDelete.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent evt) {
            deleteRecord(SCANNED_DOCUMENT, scannedDocumentId);
        }
    });

}

From source file:org.kie.guvnor.m2repo.client.editor.GAVEditor.java

License:Apache License

public GAVEditor(final FormPanel form) {
    super(ImageResources.INSTANCE.modelLarge(), "GAV Editor");

    TextBox groupIDTextBox = new TextBox();
    addAttribute("GroupID:", groupIDTextBox);
    TextBox artifactIDTextBox = new TextBox();
    addAttribute("ArtifactID:", artifactIDTextBox);
    TextBox versionID = new TextBox();
    addAttribute("VersionID:", versionID);
    Button ok = new Button("upload");
    ok.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            form.reset();
            HorizontalPanel fields = new HorizontalPanel();
            fields.add(getHiddenField(HTMLFileManagerFields.GROUP_ID, ""));
            fields.add(getHiddenField(HTMLFileManagerFields.ARTIFACT_ID, ""));
            fields.add(getHiddenField(HTMLFileManagerFields.VERSION_ID, ""));
            form.add(fields);//from   w  ww  .  ja  v  a2 s .  c  o m
            form.submit();
        }
    });
    addAttribute("", ok);
}

From source file:org.ow2.proactive_grid_cloud_portal.common.client.CredentialsWindow.java

License:Open Source License

private void build() {
    /* smartGWT forms don't allow simple multipart file upload,
     * so we use a smartGWT form for login/password/checkbox,
     * a pure GWT form for file upload, and upon submission,
     * put the fields from the first form as hidden fields of the
     * pure GWT form. It's a bit convoluted but like this we get
     * the pretty widgets and the nice features       */

    TextItem loginField = new TextItem("login", "Login");
    loginField.setRequired(true);/*from   w  w w.j  ava  2  s . co  m*/

    PasswordItem passwordField = new PasswordItem("password", "Password");
    passwordField.setRequired(true);

    final CheckboxItem moreField = new CheckboxItem("useSSH", "Use SSH private key");
    moreField.setValue(false);

    // smartGWT form: only used to input the data before filling the hidden fields
    // in the other form with it
    final DynamicForm form = new DynamicForm();
    form.setFields(loginField, passwordField, moreField);

    // pure GWT form for uploading, will be used to contact the servlet
    // even if no ssh key is used
    final FileUpload fileUpload = new FileUpload();
    fileUpload.setName("sshkey");
    final Hidden hiddenUser = new Hidden("username");
    final Hidden hiddenPass = new Hidden("password");
    final FormPanel formPanel = new FormPanel();
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_POST);
    formPanel.setAction(GWT.getModuleBaseURL() + "createcredential");
    final VerticalPanel vpan = new VerticalPanel();
    vpan.add(hiddenUser);
    vpan.add(hiddenPass);
    vpan.add(fileUpload);
    formPanel.setWidget(vpan);
    formPanel.setWidth("100%");
    formPanel.setHeight("30px");
    final HLayout formWrapper = new HLayout();
    formWrapper.setAlign(Alignment.CENTER);
    formWrapper.addChild(formPanel);
    formWrapper.setWidth100();
    formWrapper.addDrawHandler(new DrawHandler() {
        public void onDraw(DrawEvent event) {
            // took me half a day to find this hack:
            // if the form is added to the page in a hidden element,
            // it is never created and submission fails without callback.
            // it needs to be visible so that it is created once, then
            // we can safely hide it and still use it
            if (disableFormWrapper) {
                disableFormWrapper = false;
                formWrapper.setVisible(false);
            }
        }
    });

    // hide/show the ssh key upload input
    moreField.addChangedHandler(new ChangedHandler() {
        public void onChanged(ChangedEvent event) {
            if (moreField.getValueAsBoolean()) {
                formWrapper.setVisible(true);
            } else {
                formWrapper.setVisible(false);
                formPanel.reset();
            }
        }
    });
    // prevent form validation if no ssh key is selected
    Validator moreVal = new CustomValidator() {
        @Override
        protected boolean condition(Object value) {
            if (moreField.getValueAsBoolean()) {
                String file = fileUpload.getFilename();
                return (file != null && file.length() > 0);
            } else {
                return true;
            }
        }
    };
    moreVal.setErrorMessage("No file selected");
    moreField.setValidators(moreVal);

    final IButton clearButton = new IButton("Clear");
    clearButton.setIcon(Images.instance.clear_16().getSafeUri().asString());
    clearButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            form.clearValues();
            formPanel.reset();
            formWrapper.setVisible(false);
        }
    });

    final IButton closeButton = new IButton("Close");

    final Label label = new Label("A Credential is a file containing all information used"
            + " for authentication, in an encrypted form. It allows easier authentication and"
            + " automation.");
    label.setHeight(50);

    final HLayout buttonBar = new HLayout();

    final IButton okButton = new IButton();
    okButton.setShowDisabled(false);
    okButton.setIcon(Images.instance.ok_16().getSafeUri().asString());
    okButton.setTitle("Create");
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (!form.validate())
                return;

            String login = form.getValueAsString("login");
            String pw = form.getValueAsString("password");
            hiddenUser.setValue(login);
            hiddenPass.setValue(pw);

            formPanel.submit();
        }
    });

    closeButton.setIcon(Images.instance.cancel_16().getSafeUri().asString());
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CredentialsWindow.this.window.hide();
            CredentialsWindow.this.destroy();
        }
    });

    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            /* this happens only on error, if the call succeeds,
             * the response is relocated so that a 'save file' dialog appears */
            String str = event.getResults();
            label.setContents("<span style='color:red;'>" + str + "</span>");

        }
    });

    Layout formLayout = new VLayout();
    formLayout.setHeight100();
    formLayout.setWidth100();
    formLayout.setMembersMargin(10);
    formLayout.addMember(form);
    formLayout.addMember(formWrapper);

    buttonBar.setWidth100();
    buttonBar.setAlign(Alignment.RIGHT);
    buttonBar.setMembersMargin(5);
    buttonBar.setMembers(clearButton, okButton, closeButton);
    formLayout.addMember(buttonBar);

    VLayout layout = new VLayout();
    layout.setMembersMargin(10);
    layout.setMargin(5);
    layout.setMembers(label, formLayout, buttonBar);

    this.window = new Window();
    this.window.setTitle("Create Credentials");
    this.window.setShowMinimizeButton(false);
    this.window.setIsModal(true);
    this.window.setShowModalMask(true);
    this.window.addItem(layout);
    this.window.setWidth(370);
    this.window.setHeight(260);
    this.window.centerInPage();
}

From source file:org.ow2.proactive_grid_cloud_portal.common.client.LoginPage.java

License:Open Source License

/**
 * @return the forms and widgets for plain login/password authentication
 *//*from   ww w . ja  v a2s.  c om*/
private Layout getPlainAuth() {

    /* smartGWT forms don't allow simple multipart file upload,
     * so we use a smartGWT form for login/password/checkbox,
     * a pure GWT form for file upload, and upon submission,
     * put the fields from the first form as hidden fields of the
     * pure GWT form. It's a bit convoluted but like this we get
     * the pretty widgets and the nice features       */

    TextItem loginField = new TextItem("login", "User");
    loginField.setRequired(true);

    PasswordItem passwordField = new PasswordItem("password", "Password");
    passwordField.setRequired(true);

    final CheckboxItem moreField = new CheckboxItem("useSSH", "Use SSH private key");
    moreField.setValue(false);

    // smartGWT form: only used to input the data before filling the hidden fields
    // in the other form with it
    final DynamicForm form = new DynamicForm();
    form.setFields(loginField, passwordField, moreField);
    form.hideItem("useSSH");

    // pure GWT form for uploading, will be used to contact the servlet
    // even if no ssh key is used
    final FileUpload fileUpload = new FileUpload();
    fileUpload.setName("sshkey");
    final Hidden hiddenUser = new Hidden("username");
    final Hidden hiddenPass = new Hidden("password");
    final FormPanel formPanel = new FormPanel();
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_POST);
    formPanel.setAction(GWT.getModuleBaseURL() + "login");
    final VerticalPanel vpan = new VerticalPanel();
    vpan.add(hiddenUser);
    vpan.add(hiddenPass);
    vpan.add(fileUpload);
    formPanel.setWidget(vpan);
    formPanel.setWidth("100%");
    formPanel.setHeight("30px");
    final HLayout formWrapper = new HLayout();
    formWrapper.setAlign(Alignment.CENTER);
    formWrapper.addChild(formPanel);
    formWrapper.setWidth100();
    formWrapper.addDrawHandler(new DrawHandler() {
        public void onDraw(DrawEvent event) {
            // took me half a day to find this hack:
            // if the form is added to the page in a hidden element,
            // it is never created and submission fails without callback.
            // it needs to be visible so that it is created once, then
            // we can safely hide it and still use it
            if (disableFormWrapper) {
                disableFormWrapper = false;
                formWrapper.setVisible(false);
            }
        }
    });

    // hide/show the ssh key upload input
    moreField.addChangedHandler(new ChangedHandler() {
        public void onChanged(ChangedEvent event) {
            if (moreField.getValueAsBoolean()) {
                //formWrapper.setVisible(true);
                formWrapper.animateShow(AnimationEffect.FLY);
            } else {
                //formWrapper.setVisible(false);
                formWrapper.animateHide(AnimationEffect.FLY);
                formPanel.reset();
            }
        }
    });
    // prevent form validation if no ssh key is selected
    Validator moreVal = new CustomValidator() {
        @Override
        protected boolean condition(Object value) {
            if (moreField.getValueAsBoolean()) {
                String file = fileUpload.getFilename();
                return (file != null && file.length() > 0);
            } else {
                return true;
            }
        }
    };
    moreVal.setErrorMessage("No file selected");
    moreField.setValidators(moreVal);

    final Runnable advancedVisibilityChanged = new Runnable() {
        @Override
        public void run() {
            if (!moreField.getVisible()) {
                authSelLayout.setVisible(true);
                form.showItem("useSSH");
                optsLabel.setIcon(Images.instance.close_16().getSafeUri().asString());
                optsLabel.setContents(
                        "<nobr style='color:#003168;font-size: 1.2em;" + "cursor:pointer'>less options</nobr>");
            } else {
                authTypeSelectForm.setValue("Mode", "Basic");
                switchPlainCredForm.run();
                authSelLayout.setVisible(false);
                form.hideItem("useSSH");
                formWrapper.animateHide(AnimationEffect.FLY);
                moreField.setValue(false);
                formPanel.reset();
                optsLabel.setIcon(Images.instance.expand_16().getSafeUri().asString());
                optsLabel.setContents(
                        "<nobr style='color:#003168;font-size: 1.2em;" + "cursor:pointer'>more options</nobr>");
            }
        }
    };
    optsLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            advancedVisibilityChanged.run();
        }
    });

    String cacheLogin = Settings.get().getSetting(controller.getLoginSettingKey());
    if (cacheLogin != null) {
        form.setValue("login", cacheLogin);
    }

    final IButton okButton = new IButton();
    okButton.setShowDisabled(false);
    okButton.setIcon(Images.instance.connect_16().getSafeUri().asString());
    okButton.setTitle("Connect");
    okButton.setWidth(120);
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (!form.validate())
                return;

            String login = form.getValueAsString("login");
            String pw = form.getValueAsString("password");
            hiddenUser.setValue(login);
            hiddenPass.setValue(pw);

            okButton.setIcon("loading.gif");
            okButton.setTitle("Connecting...");
            form.disable();
            formWrapper.disable();

            authTypeSelectForm.disable();
            okButton.disable();

            // only submit once the the error message is hidden so we don't try to show it (on form response)
            // while the effect is played resulting in the message hidden staying hidden
            if (errorLabel.isDrawn() && errorLabel.isVisible()) {
                errorLabel.animateHide(AnimationEffect.FLY, new AnimationCallback() {
                    @Override
                    public void execute(boolean earlyFinish) {
                        formPanel.submit();
                    }
                });
            } else {
                formPanel.submit();
            }
        }
    });

    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            String res = new HTML(event.getResults()).getText();
            boolean fail = false;
            try {
                JSONValue val = controller.parseJSON(res);
                JSONObject obj = val.isObject();
                if (obj != null && obj.containsKey("sessionId")) {
                    String sess = obj.isObject().get("sessionId").isString().stringValue();
                    controller.login(sess, form.getValueAsString("login"));
                } else {
                    fail = true;
                }
            } catch (Throwable t) {
                fail = true;
            }

            if (fail) {
                String err = JSONUtils.getJsonErrorMessage(res);
                int sta = JSONUtils.getJsonErrorCode(res);
                if (sta != -1)
                    err += " (" + sta + ")";
                errorLabel.setContents("<span style='color:red;'>Could not login: " + err + "</span>");
                errorLabel.animateShow(AnimationEffect.FLY);

                okButton.setIcon(Images.instance.connect_16().getSafeUri().asString());
                okButton.setTitle("Connect");
                formWrapper.enable();
                form.enable();
                authTypeSelectForm.enable();
                okButton.enable();
            }
        }
    });

    form.addItemKeyPressHandler(new ItemKeyPressHandler() {
        public void onItemKeyPress(ItemKeyPressEvent event) {
            if ("Enter".equals(event.getKeyName())) {
                okButton.fireEvent(new ClickEvent(null));
            }
        }
    });

    Layout formLayout = new VLayout();
    formLayout.setWidth100();
    formLayout.setMembersMargin(10);
    formLayout.addMember(form);
    formLayout.addMember(formWrapper);

    HLayout buttonBar = new HLayout();
    buttonBar.setWidth100();
    buttonBar.setAlign(Alignment.CENTER);
    buttonBar.addMember(okButton);
    formLayout.addMember(buttonBar);

    return formLayout;
}

From source file:org.rebioma.client.UploadView.java

License:Apache License

private UploadView(View parent, UploadListener uListener) {
    super(parent, false);
    this.uploadListener = uListener;
    modelingBox.setName("modeling");
    final VerticalPanel uploadPanel = new VerticalPanel();
    uploadPanel.setStyleName("pupload");
    HorizontalPanel privateModelField = new HorizontalPanel();
    privateModelField.add(privateRadioButton);
    privateModelField.add(new HTML("&nbsp;("));
    privateModelField.add(modelingBox);//  w w  w .  ja  v  a2s .c  o m
    privateModelField.add(new HTML(")"));
    HorizontalPanel delimiterPanel = new HorizontalPanel();
    delimiterBox.addItem(constants.Comma(), ",");
    delimiterBox.addItem(constants.Semicolon(), ";");
    delimiterBox.setName("delimiter");
    delimiterPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    delimiterPanel.add(delimiterBox);
    delimiterPanel.add(new HTML("&nbsp;&nbsp;" + constants.CSVDelimiter()));

    fileUpload.setName("file_upload");
    //uploadForm.setAction(GWT.getModuleBaseURL() + "upload");
    //uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    //uploadForm.setMethod(FormPanel.METHOD_POST);
    //uploadPanel.add(fileUpload);
    uploadPanel.add(delimiterPanel);
    showEmailBox.setName("show_email");
    clearReviewCheckBox.setName("clear_review");
    clearReviewCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue()) {
                MessageBox boxWarning = new MessageBox("Reset review state?", "");
                boxWarning.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.CANCEL);
                boxWarning.setIcon(MessageBox.ICONS.warning());
                boxWarning.setWidth("415px");
                boxWarning.setMessage(
                        "You are resetting all the TRB's review on all occurrences. Would you like to continue?");
                boxWarning.addHideHandler(new HideHandler() {

                    @Override
                    public void onHide(HideEvent eventW) {
                        Dialog btnW = (Dialog) eventW.getSource();
                        if (!btnW.getHideButton().getText().equalsIgnoreCase("yes")) {
                            clearReviewCheckBox.setChecked(false);
                        }
                    }
                });

                boxWarning.show();
            }
        }
    });
    uploadPanel.add(clearReviewCheckBox);
    uploadPanel.add(showEmailBox);
    uploadPanel.add(privateModelField);
    uploadPanel.add(publicRadioButton);
    setClearReview(ApplicationView.getCurrentState() == ViewState.SUPERADMIN);
    UserQuery query = friendsTable.getQuery();
    query.setUsersCollaboratorsOnly(true);
    friendsTable.addCheckedListener(this);
    // TODO: fix resize
    // friendsTable.setSize("500px", "300px");
    friendsTable.resetTable();
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);
    uploadPanel.add(hp);
    //HorizontalPanel buttonPanel = new HorizontalPanel();
    // buttonPanel.add(uploadButton);
    // buttonPanel.add(cancelButton);
    // buttonPanel.setSpacing(2);
    //uploadPanel.add(dataSharingAgreementLink);
    // uploadPanel.add(buttonPanel);
    hiddenSessionId.setValue(Cookies.getCookie(ApplicationView.SESSION_ID_NAME));
    uploadPanel.add(hiddenSessionId);
    uploadPanel.add(collaboratorsSharing);
    final VerticalPanel friendsPanel = new VerticalPanel();
    Label collaborator = new Label(constants.CollaboratorsOnUpload());
    collaborator.setStyleName("title1");
    friendsPanel.add(collaborator);
    friendsPanel.add(friendsTable);
    //HorizontalPanel friendUplodaHp = new HorizontalPanel();
    //friendUplodaHp.add(uploadPanel);
    //friendUplodaHp.add(friendsPanel);
    //friendUplodaHp.setSpacing(5);

    //uploadForm.setWidget(friendUplodaHp);
    /*mainSp.setWidget(uploadForm);
    initWidget(mainSp);*/

    final FlexTable grid = new FlexTable();
    grid.setStyleName("GWTUpld");
    final FormPanel form = new FormPanel() {
        public void add(Widget w) {
            grid.setWidget(grid.getRowCount(), 1, uploadPanel);
            grid.getFlexCellFormatter().setRowSpan(0, 2, 20);
            grid.setWidget(0, 2, new Label("   "));
            grid.getFlexCellFormatter().setStyleName(0, 2, "sep");
            grid.getFlexCellFormatter().setRowSpan(0, 3, 20);
            grid.setWidget(0, 3, friendsPanel);
            grid.setWidget(grid.getRowCount(), 1, dataSharingAgreementLink);
            grid.setWidget(grid.getRowCount(), 1, w);
            //grid.getFlexCellFormatter().setColSpan(grid.getRowCount()+1, 1, 2);
        }

        {
            super.add(grid);
        }
    };
    class MyFancyLookingSubmitButton extends Composite implements HasClickHandlers {
        DecoratorPanel widget = new DecoratorPanel();

        public MyFancyLookingSubmitButton() {
            Button widget = new Button(constants.AcceptDsaUpload());
            initWidget(widget);
        }

        public HandlerRegistration addClickHandler(ClickHandler handler) {
            return addDomHandler(handler, ClickEvent.getType());
        }

    }

    SingleUploader uploader = new SingleUploader(FileInputType.LABEL, new ModalUploadStatus(),
            new MyFancyLookingSubmitButton(), form);
    uploader.setServletPath("send.file");
    //mainSp.add(uploader);
    //grid.setText(5, 0, "Attachment:");
    mainSp.setWidget(uploader);
    uploader.getFileInput().setText(constants.chooseFileLabel());
    initWidget(mainSp);

    uploader.addOnFinishUploadHandler(new OnFinishUploaderHandler() {
        public void onFinish(IUploader uploader) {
            if (uploader.getStatus() == Status.SUCCESS) {
                Document doc = null;
                String displayMsg = null;
                try {
                    doc = XMLParser.parse(uploader.getServerResponse());
                    displayMsg = Utils.getXmlNodeValue(doc, "message");
                } catch (Exception e) {
                }

                //Window.alert("Server response: \n" + displayMsg);

                setUploadEnable(true);
                if (displayMsg != null) {
                    if (displayMsg.matches("<.+>.+<.+>")) {
                        displayMsg = displayMsg.substring(displayMsg.indexOf('>') + 1,
                                displayMsg.lastIndexOf('<'));
                    }
                    JSONObject serverMsg = JSONParser.parse(displayMsg).isObject();
                    if (serverMsg.get("onSuccess") != null) {
                        JSONValue successValue = serverMsg.get("onSuccess");
                        popupStatusMessage.showMessage(successValue);
                        popupStatusMessage.setWidth("300px");
                        //uploadForm.reset();
                    } else {
                        JSONObject error = serverMsg.get("onFailure").isObject();
                        String errorKey = error.keySet().iterator().next();
                        JSONValue jValue = error.get(errorKey);
                        if (errorKey.equals("No File")) {
                            Window.alert(constants.UploadFailedNoFile());
                        } else if (errorKey.equals("Invalid File")) {
                            Window.alert(constants.UploadFailedInvalidFile());
                        } else if (errorKey.equals("Missing Required Headers")) {
                            Window.alert(constants.MissingRequiredHeader() + jValue.isArray());
                        } else {
                            Window.alert(constants.UploadFailedException() + jValue.isString());
                        }
                    }
                }
                DataSwitch.get().clearCache(DataSwitch.OCCURRENCE_KEY);
                uploadListener.onUploadComplete();
                popupStatusMessage.checkAndResize();
                uploader.getFileInput().setText(constants.chooseFileLabel());
                uploader.getFileInput().setSize("200px", "auto");
                uploader.reset();
                form.reset();
            }
        }
    });

    initListeners();
    cancelButton.setEnabled(false);
    publicRadioButton.setValue(true);
    showEmailBox.setValue(true);

    // Adds upload form handlers
    //uploadForm.addSubmitHandler(new SubmitHandler() {

    /**
     * If the uploading file is empty display an error message and cancels the
     * submit event.
     * 
     * @see com.google.gwt.user.client.ui.FormPanel.SubmitHandler#onSubmit(com.google.gwt.user.client.ui.FormPanel.SubmitEvent)
     */
    /*public void onSubmit(SubmitEvent event) {
      if (fileUpload.getFilename().equals("")) {
     Window.alert(constants.FileCantBeEmpty());
     event.cancel();
      } else {
     uploadListener.onUploadStart();
     setUploadEnable(false);
      }
    }
            
    });*/

    //uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
    /**
     * Notifies the user whether the upload was successful. Also clears the
     * DataSwitch cache since new records were uploaded.
     * 
     * @see com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler#onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent)
     */
    /*public void onSubmitComplete(SubmitCompleteEvent event) {
        setUploadEnable(true);
        String displayMsg = event.getResults();
        // displayMsg =
        // "<something>{\"onFailure\": \"No file uploaded\"}</something>";
        if (displayMsg.matches("<.+>.+<.+>")) {
     displayMsg = displayMsg.substring(displayMsg.indexOf('>') + 1,
         displayMsg.lastIndexOf('<'));
        }
        JSONObject serverMsg = JSONParser.parse(displayMsg).isObject();
        if (serverMsg.get("onSuccess") != null) {
     JSONValue successValue = serverMsg.get("onSuccess");
     popupStatusMessage.showMessage(successValue);
     uploadForm.reset();
        } else {
     JSONObject error = serverMsg.get("onFailure").isObject();
     String errorKey = error.keySet().iterator().next();
     JSONValue jValue = error.get(errorKey);
     if (errorKey.equals("No File")) {
       Window.alert(constants.UploadFailedNoFile());
     } else if (errorKey.equals("Invalid File")) {
       Window.alert(constants.UploadFailedInvalidFile());
     } else if (errorKey.equals("Missing Required Headers")) {
       Window.alert(constants.MissingRequiredHeader() + jValue.isArray());
     } else {
       Window.alert(constants.UploadFailedException() + jValue.isString());
     }
        }
        DataSwitch.get().clearCache(DataSwitch.OCCURRENCE_KEY);
        uploadListener.onUploadComplete();
        popupStatusMessage.checkAndResize();
      }
    });*/

}