/** {@inheritDoc} */ @Override public void showDialog() { errorMessage.setText(""); fileContent = null; fileUpload = new FileUpload(); fileUpload.setHeight("22px"); fileUpload.setWidth("100%"); fileUpload.setName("file"); fileUpload.ensureDebugId("import-from-config-ChooseFile"); addHandler(fileUpload.getElement()); fileUpload.addChangeHandler(event -> buttonImport.setEnabled(fileUpload.getFilename() != null)); uploadForm.add(fileUpload); this.show(); }
@Inject public FormatterPreferencePageViewImpl( FormatterPreferencePageViewImplUiBinder uiBinder, JavaLocalizationConstant localizationConstant) { widget = uiBinder.createAndBindUi(this); fileUpload = new FileUpload(); radioButtonGroup = new RadioButtonGroup(); targetPanel.add(radioButtonGroup); radioButtonGroup.addButton( localizationConstant.formatterPreferencesProjectLabel(), localizationConstant.formatterPreferencesProjectDescription(), null, event -> isWorkspace = false); radioButtonGroup.addButton( localizationConstant.formatterPreferencesWorkspaceLabel(), localizationConstant.formatterPreferencesWorkspaceDescription(), null, event -> isWorkspace = true); radioButtonGroup.selectButton(0); uploadForm.add(fileUpload); importButton.setEnabled(false); }
public FileInputButton() { wrapper = new Span(); wrapper.addStyleName(Styles.BTN); upload = new FileUpload(); upload.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { fireChanged(); } }); wrapper.add(upload); wrapper.addStyleName("btn-file"); initWidget(wrapper); }
private static String getValue(FormPanel formPanel) { String value = null; if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); value = DOM.getElementAttribute(fileUpload.getElement(), "fu-uuid"); handleSimpleValue(formPanel, value); } } } return value; }
@Override public void showDialog() { uploadFormVPanel.clear(); certFile = new FileUpload(); certFile.setHeight("22px"); certFile.setWidth("100%"); certFile.setName("certFile"); certFile.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { delegate.onFileNameChanged(); } }); uploadFormVPanel.add(certFile); this.show(); }
public void execute() { if (toolBarOption.addDocumentOption) { FileToUpload fileToUpload = new FileToUpload(); fileToUpload.setFileUpload(new FileUpload()); fileToUpload.setPath((String) Main.get().activeFolderTree.getActualPath()); fileToUpload.setAction(UIFileUploadConstants.ACTION_INSERT); Main.get().fileUpload.addPendingFileToUpload(fileToUpload); Main.get().activeFolderTree.hideMenuPopup(); } }
private FileUpload createFileUpload() { fileUpload = new FileUpload(); fileUpload.getElement().getStyle().setDisplay(Style.Display.NONE); if (fileTypes != null) { // Convert the format that the SWFUpload/Flash parameter expects to the W3C DOM standard // See: http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#attr-input-accept fileUpload.getElement() .setAttribute("accept", this.fileTypes.replaceAll("\\;", ",").replaceAll("\\*\\.", ".")); // TODO(jake): Need to consider validation of this in the file queued handler as well, // as the browsers don't appear to consistently support the "accept" attribute } final AbsolutePanel panel = this; fileUpload.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { JsArray<?> selectedFiles = nativeGetSelectedFiles(fileUpload.getElement()); // Every time a file is selected replace the FileUpload component running in the DOM so that // the user can continue to attempt uploading the same file multiple times (otherwise the // "ChangeHandler" never fires) panel.remove(fileUpload); panel.add(createFileUpload()); addFilesToQueue(selectedFiles); } }); return fileUpload; }
private void openFileDialog(FileUpload fileUpload, boolean multipleFiles) { if (multipleFiles) { fileUpload.getElement().setAttribute("multiple", "true"); } else { fileUpload.getElement().removeAttribute("multiple"); } if (fileDialogStartHandler != null) { fileDialogStartHandler.onFileDialogStartEvent(new FileDialogStartEvent()); } InputElement.as(fileUpload.getElement()).click(); }
private FileUpload createFileUpload() { // Create a FileUpload widget. FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); return upload; }
private void initSelectWorkflowFromFilePanel() { fromFilePanel = new VLayout(); fromFilePanel.setHeight("30px"); fileUpload = new FileUpload(); fileUpload.setName("job"); VerticalPanel formContent = new VerticalPanel(); formContent.setHeight("30px"); Hidden hiddenField = new Hidden(); hiddenField.setName(SESSION_ID_PARAMETER_NAME); hiddenField.setValue(LoginModel.getInstance().getSessionId()); formContent.add(hiddenField); formContent.add(fileUpload); final FormPanel importFromFileformPanel = new FormPanel(); importFromFileformPanel.setEncoding(FormPanel.ENCODING_MULTIPART); importFromFileformPanel.setMethod(FormPanel.METHOD_POST); importFromFileformPanel.setAction(URL_UPLOAD_FILE); importFromFileformPanel.add(formContent); importFromFileformPanel.addSubmitCompleteHandler(fileUploadCompleteHandler()); importFromFileformPanel.setHeight("30px"); fromFilePanel.addMember(importFromFileformPanel); sendFromFileButton = new Button("Upload file"); sendFromFileButton.addClickHandler(clickHandlerForUploadFromFileButton(importFromFileformPanel)); }
private void addFileUploadForm() { file = new FileUpload(); file.setHeight("22px"); file.setWidth("100%"); file.setName("file"); file.ensureDebugId("file-uploadFile-ChooseFile"); file.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { delegate.onFileNameChanged(); } }); uploadPanel.insert(file, 0); }
private void addFile() { file = new FileUpload(); file.setHeight("22px"); file.setWidth("100%"); file.setName("file"); file.ensureDebugId("file-uploadFile-ChooseFile"); file.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { delegate.onFileNameChanged(); } }); uploadPanel.insert(file, 0); }
@Test public void getFileNameShouldBeExecuted() { view.file = mock(FileUpload.class); when(view.file.getFilename()).thenReturn("fileName"); view.getFileName(); verify(view.file).getFilename(); }
@Test public void closeShouldBeExecuted() { view.uploadPanel = mock(FlowPanel.class); view.file = mock(FileUpload.class); view.overwrite = mock(CheckBox.class); view.btnUpload = mock(Button.class); view.closeDialog(); verify(view.uploadPanel).remove((FileUpload) anyObject()); verify(view.btnUpload).setEnabled(eq(false)); verify(view.overwrite).setValue(eq(false)); }
public static void selectFile(final Callback<JavaScriptObject, String> aCallback, String aFileTypes) { final FileUpload fu = new FileUpload(); fu.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); fu.setWidth("10px"); fu.setHeight("10px"); fu.getElement().getStyle().setLeft(-100, Style.Unit.PX); fu.getElement().getStyle().setTop(-100, Style.Unit.PX); fu.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Utils.JsObject jsFu = fu.getElement().cast(); JavaScriptObject oFiles = jsFu.getJs("files"); if (oFiles != null) { JsArray<JavaScriptObject> jsFiles = oFiles.cast(); for (int i = 0; i < jsFiles.length(); i++) { try { aCallback.onSuccess(jsFiles.get(i)); } catch (Exception ex) { Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex); } } } fu.removeFromParent(); } }); RootPanel.get().add(fu, -100, -100); fu.click(); Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { @Override public boolean execute() { fu.removeFromParent(); return false; } }, 1000 * 60 * 1);// 1 min }
private void init(FileUpload fileUpload, Button uploadButton) { if (fileUpload != null) { ((InputElement)fileUpload.getElement().cast()).setValue(""); } if (uploadButton != null) { uploadButton.setEnabled(false); } }
public static SubmitCompleteHandler createSubmitCompleteHandler(final UIObject ui, final EventListenerGVO ev, final List<InputVariableGVO> inputVariables) { SubmitCompleteHandler submitCompleteHandler = new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if ((uuId != null) && (uuId.indexOf("=") > 0)) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } FormPanel fp = (FormPanel) ui; if (fp instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) fp; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); if (success) { DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(ui, QAMLConstants.EVENT_ONFINISH, ev, inputVariables); } else { Label fileNameLabel = new Label("Uploading unsuccessfull.");// (Hyperlink) // gridPanel.getWidget(1, // 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); gridPanel.add(fileNameLabel); } } } } } }; return submitCompleteHandler; }
/** {@inheritDoc} */ @Override public void add(final Widget w) { if (w instanceof ListBox || w instanceof FileUpload) { w.addStyleName(Styles.FORM_CONTROL); } add(w, (Element) getElement()); }
/** * Initialize this example. */ @ShowcaseSource @Override public Widget onInitialize() { // Create a vertical panel to align the content VerticalPanel vPanel = new VerticalPanel(); // Add a label vPanel.add(new HTML(constants.cwFileUploadSelectFile())); // Add a file upload widget final FileUpload fileUpload = new FileUpload(); fileUpload.ensureDebugId("cwFileUpload"); vPanel.add(fileUpload); // Add a button to upload the file Button uploadButton = new Button(constants.cwFileUploadButton()); uploadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String filename = fileUpload.getFilename(); if (filename.length() == 0) { Window.alert(constants.cwFileUploadNoFileError()); } else { Window.alert(constants.cwFileUploadSuccessful()); } } }); vPanel.add(new HTML("<br>")); vPanel.add(uploadButton); // Return the layout panel return vPanel; }
/** * Creates a new keystore upload wizard. */ public KeystoreUploadWizard(final Command callbackAfterUpload) { super(MESSAGES.keystoreUploadWizardCaption(), true, false); // Initialize UI final FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_USERFILE_FORM_ELEMENT); setStylePrimaryName("ode-DialogBox"); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(upload); addPage(panel); // Create finish command (upload a keystore) initFinishCommand(new Command() { @Override public void execute() { String filename = upload.getFilename(); if (filename.endsWith(KEYSTORE_EXTENSION)) { String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_USERFILE + "/" + StorageUtil.ANDROID_KEYSTORE_FILENAME; Uploader.getInstance().upload(upload, uploadUrl, new OdeAsyncCallback<UploadResponse>( // failure message MESSAGES.keystoreUploadError()) { @Override public void onSuccess(UploadResponse uploadResponse) { switch (uploadResponse.getStatus()) { case SUCCESS: if (callbackAfterUpload != null) { callbackAfterUpload.execute(); } break; default: ErrorReporter.reportError(MESSAGES.keystoreUploadError()); break; } } }); } else { Window.alert(MESSAGES.notKeystoreError()); center(); } } }); }
/** * Creates a new project upload wizard. */ public ProjectUploadWizard() { super(MESSAGES.projectUploadWizardCaption(), true, false); // Initialize UI final FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_PROJECT_ARCHIVE_FORM_ELEMENT); setStylePrimaryName("ode-DialogBox"); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(upload); addPage(panel); // Create finish command (upload a project archive) initFinishCommand(new Command() { @Override public void execute() { String filename = upload.getFilename(); if (filename.endsWith(PROJECT_ARCHIVE_EXTENSION)) { // Strip extension and leading path off filename. We need to support both Unix ('/') and // Windows ('\\') path separators. File.pathSeparator is not available in GWT. filename = filename.substring(0, filename.length() - PROJECT_ARCHIVE_EXTENSION.length()). substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); // Make sure the project name is legal and unique. if (!TextValidators.checkNewProjectName(filename)) { return; } String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_PROJECT + "/" + filename; Uploader.getInstance().upload(upload, uploadUrl, new OdeAsyncCallback<UploadResponse>( // failure message MESSAGES.projectUploadError()) { @Override public void onSuccess(UploadResponse uploadResponse) { switch (uploadResponse.getStatus()) { case SUCCESS: String info = uploadResponse.getInfo(); UserProject userProject = UserProject.valueOf(info); Ode ode = Ode.getInstance(); Project uploadedProject = ode.getProjectManager().addProject(userProject); ode.openYoungAndroidProjectInDesigner(uploadedProject); break; case NOT_PROJECT_ARCHIVE: // This may be a "severe" error; but in the // interest of reducing the number of red errors, the // line has been changed to report info not an error. // This error is triggered when the user attempts to // upload a zip file that is not a project. ErrorReporter.reportInfo(MESSAGES.notProjectArchiveError()); break; default: ErrorReporter.reportError(MESSAGES.projectUploadError()); break; } } }); } else { Window.alert(MESSAGES.notProjectArchiveError()); center(); } } }); }
private FileUpload createFileUpload() { FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_COMPONENT_ARCHIVE_FORM_ELEMENT); return upload; }
public ComponentUploadWizard() { super(MESSAGES.componentUploadWizardCaption(), true, false); final FileUpload uploadWiget = new FileUpload(); uploadWiget.setName(ServerLayout.UPLOAD_COMPONENT_ARCHIVE_FORM_ELEMENT); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(uploadWiget); addPage(panel); setStylePrimaryName("ode-DialogBox"); initFinishCommand(new Command() { @Override public void execute() { if (!uploadWiget.getFilename().endsWith(COMPONENT_ARCHIVE_EXTENSION)) { Window.alert(MESSAGES.notComponentArchiveError()); return; } String url = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_COMPONENT + "/" + trimLeadingPath(uploadWiget.getFilename()); Uploader.getInstance().upload(uploadWiget, url, new OdeAsyncCallback<UploadResponse>() { @Override public void onSuccess(UploadResponse uploadResponse) { Component component = Component.valueOf(uploadResponse.getInfo()); ErrorReporter.reportInfo("Uploaded successfully"); } }); } private String trimLeadingPath(String filename) { // Strip leading path off filename. // We need to support both Unix ('/') and Windows ('\\') separators. return filename.substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); } }); }
public NotEmptyFileUploadValidator(FileUpload fileUpload) { this.fileUpload = fileUpload; this.setCustomMsgKey(null); this.preventsPropagationOfValidationChain(); }
public void invokeActions(ValidationResult result) { if (fileUpload != null) { for (ValidationAction<FileUpload> action : getFailureActions()) action.invoke(result, fileUpload); } }
public FileUpload getFileUpload() { return fileUpload; }
public void setFileUpload(FileUpload fileUpload) { this.fileUpload = fileUpload; }
public void setImportFile(FileUpload importFile) { this.importFile = importFile; }
public FileUpload getImportFile() { return importFile; }
public static void setFileUploadSize(FileUpload widget, String size) { DOM.setElementAttribute(widget.getElement(), "size", size); }
private void processClearForInputComponents(UIObject uiObject, BuiltInFunctionGVO builtInFunction) { if (uiObject instanceof TextBoxBase) { TextBoxBase textBoxBase = (TextBoxBase) uiObject; textBoxBase.setText(""); } if (uiObject instanceof QDatePicker) { QDatePicker qDatePicker = (QDatePicker) uiObject; qDatePicker.getTextBox().setText(""); } if (uiObject instanceof HasDataGridMethods) { ((HasDataGridMethods) uiObject).insertData(null, false, builtInFunction.getSenderId(), builtInFunction.getListenerType()); ((HasDataGridMethods) uiObject).redraw(); } if (uiObject instanceof ListBox) { ListBox listBox = (ListBox) uiObject; boolean hasEmptyItem = DropDownRenderer.hasEmptyItem(listBox); int indexOfValue = hasEmptyItem ? 0 : -1; listBox.setSelectedIndex(indexOfValue); if (builtInFunction instanceof ClearGVO) { int offset = hasEmptyItem ? 1 : 0; while (listBox.getItemCount() > offset) { listBox.removeItem(listBox.getItemCount() - 1); } } } if (uiObject instanceof CheckBox) { CheckBox checkbox = (CheckBox) uiObject; checkbox.setValue(false); if (uiObject instanceof QRadioButton) { ((QRadioButton) uiObject).reset(); } } if (uiObject instanceof FileUpload) { FileUpload fileUpload = (FileUpload) uiObject; Widget fup = fileUpload.getParent(); // fup will be the layout component if (fup != null) { Widget fupp = fup.getParent(); if (fupp instanceof FormPanel) { ((FormPanel) fupp).reset(); } } } if(uiObject instanceof QSuggestBox){ QSuggestBox suggestTextField = (QSuggestBox)uiObject; suggestTextField.getTextBox().setText(""); } }
private static void processClearForInputComponents(UIObject uiObject, BuiltInFunctionGVO builtInFunction) { if (uiObject instanceof TextBoxBase) { TextBoxBase textBoxBase = (TextBoxBase) uiObject; textBoxBase.setText(""); } if (uiObject instanceof QDatePicker) { QDatePicker qDatePicker = (QDatePicker) uiObject; qDatePicker.getTextBox().setText(""); } if (uiObject instanceof HasDataGridMethods) { ((HasDataGridMethods) uiObject).insertData(null, false, builtInFunction.getSenderId(), builtInFunction.getListenerType()); ((HasDataGridMethods) uiObject).redraw(); } if (uiObject instanceof ListBox) { ListBox listBox = (ListBox) uiObject; boolean hasEmptyItem = DropDownRenderer.hasEmptyItem(listBox); int indexOfValue = hasEmptyItem ? 0 : -1; listBox.setSelectedIndex(indexOfValue); if (builtInFunction instanceof ClearGVO) { int offset = hasEmptyItem ? 1 : 0; while (listBox.getItemCount() > offset) { listBox.removeItem(listBox.getItemCount() - 1); } } } if (uiObject instanceof CheckBox) { CheckBox checkbox = (CheckBox) uiObject; checkbox.setValue(false); if (uiObject instanceof QRadioButton) { ((QRadioButton) uiObject).reset(); } } if (uiObject instanceof FileUpload) { FileUpload fileUpload = (FileUpload) uiObject; Widget fup = fileUpload.getParent(); // fup will be the layout component if (fup != null) { Widget fupp = fup.getParent(); if (fupp instanceof FormPanel) { ((FormPanel) fupp).reset(); } } } if(uiObject instanceof QSuggestBox){ QSuggestBox suggestTextField = (QSuggestBox)uiObject; suggestTextField.getTextBox().setText(""); } }
/** * Return the original FileUpload wrapped by this decorated widget. */ public FileUpload getFileUpload() { return input; }
/** * To set Import File. * * @param importFile FileUpload */ public void setImportFile(FileUpload importFile) { this.importFile = importFile; }
/** * To get Import File. * * @return FileUpload */ public FileUpload getImportFile() { return importFile; }