private boolean isValidForm() { for (IPCFileUploadField f : fufList) { if (!Strings.isNullOrEmpty(f.getValue()) && !f.getValue().equalsIgnoreCase(uploadDest.getId()) && f.isValid()) { return true; } } return false; }
@UiHandler({"fuf0", "fuf1", "fuf2", "fuf3", "fuf4"}) void onFormKeyUp(KeyUpEvent event) { if ((event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) || (event.getNativeKeyCode() == KeyCodes.KEY_DELETE)) { TextField tf = (TextField) event.getSource(); for (IPCFileUploadField fuf : fufList) { String value = fuf.getValue(); String currentValue = tf.getCurrentValue(); if (value.equalsIgnoreCase(currentValue)) { fuf.clear(); fuf.validate(true); break; } } } }
private void doUpload() { FastMap<IPCFileUploadField> destResourceMap = new FastMap<IPCFileUploadField>(); for (IPCFileUploadField field : fufList) { String fileName = field.getValue().replaceAll(".*[\\\\/]", ""); field.setEnabled(!Strings.isNullOrEmpty(fileName) && !fileName.equalsIgnoreCase("null")); if (field.isEnabled()) { destResourceMap.put(uploadDest.getPath() + "/" + fileName, field); } else { field.setEnabled(false); } } if (!destResourceMap.isEmpty()) { final ArrayList<String> ids = Lists.newArrayList(destResourceMap.keySet()); final HasPaths dto = FS_FACTORY.pathsList().as(); dto.setPaths(ids); final CheckDuplicatesCallback cb = new CheckDuplicatesCallback( ids, destResourceMap, statList, fufList, submittedForms, formList); drService.diskResourcesExist(dto, cb); } }
@UiHandler({"form0", "form1", "form2", "form3", "form4"}) void onSubmitComplete(SubmitCompleteEvent event) { if (submittedForms.contains(event.getSource())) { submittedForms.remove(event.getSource()); statList.get(formList.indexOf(event.getSource())).clearStatus(""); } String results2 = event.getResults(); String results = Format.stripTags(results2); Splittable split = StringQuoter.split(results); IPCFileUploadField field = fufList.get(formList.indexOf(event.getSource())); if (split.isUndefined("file") || (split.get("file") == null)) { field.markInvalid(I18N.ERROR.fileUploadFailed(field.getValue())); IplantAnnouncer.getInstance() .schedule(new ErrorAnnouncementConfig(I18N.ERROR.fileUploadFailed(field.getValue()))); } else { eventBus.fireEvent(new FileUploadedEvent(uploadDest, field.getValue(), results)); } if (submittedForms.size() == 0) { hide(); } }
@UiHandler({"btn0", "btn1", "btn2", "btn3", "btn4"}) void onResetClicked(SelectEvent event) { IPCFileUploadField uField = fufList.get(tbList.indexOf(event.getSource())); uField.reset(); uField.validate(true); }
private void addValidators() { for (IPCFileUploadField f : fufList) { f.addValidator(new DiskResourceNameValidator()); } }