List of usage examples for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART
String ENCODING_MULTIPART
To view the source code for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART.
Click Source Link
From source file:com.tasktop.c2c.server.wiki.web.ui.client.view.EditWikiPageView.java
License:Open Source License
public EditWikiPageView() { initWidget(uiBinder.createAndBindUi(this)); content.setPath(path);/* w w w. j av a 2 s . com*/ attachmentForm.setEncoding(FormPanel.ENCODING_MULTIPART); attachmentForm.setMethod(FormPanel.METHOD_POST); attachmentSubmit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { attachmentForm.submit(); } }); new CompositeClickHandlers(cancelButton, cancelButton2).addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { isEditing = false; } }); driver.initialize(this); }
From source file:com.vaadin.client.ui.VUpload.java
License:Apache License
public VUpload() { super(com.google.gwt.dom.client.Document.get().createFormElement()); element = getElement().cast();/* www.java2s .c o m*/ setEncoding(getElement(), FormPanel.ENCODING_MULTIPART); element.setMethod(FormPanel.METHOD_POST); setWidget(panel); panel.add(maxfilesize); panel.add(fu); submitButton = new VButton(); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (immediate) { // fire click on upload (eg. focused button and hit space) fireNativeClick(fu.getElement()); } else { submit(); } } }); panel.add(submitButton); setStyleName(CLASSNAME); }
From source file:com.vaadin.terminal.gwt.client.ui.VUpload.java
License:Open Source License
public VUpload() { super(com.google.gwt.dom.client.Document.get().createFormElement()); element = getElement().cast();/*w w w. j a va2s. co m*/ setEncoding(getElement(), FormPanel.ENCODING_MULTIPART); element.setMethod(FormPanel.METHOD_POST); setWidget(panel); panel.add(maxfilesize); panel.add(fu); submitButton = new VButton(); submitButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (immediate) { // fire click on upload (eg. focused button and hit space) fireNativeClick(fu.getElement()); } else { submit(); } } }); panel.add(submitButton); setStyleName(CLASSNAME); sinkEvents(VTooltip.TOOLTIP_EVENTS); }
From source file:de.uni_koeln.spinfo.maalr.webapp.ui.admin.client.general.dbsettings.ImportDialog.java
License:Apache License
public void buildWidget(VerticalPanel parent) { parent.add(new Label("Select a database dump which will replace all currently stored entries. " + "Note that this operation cannot be undone.")); final FormPanel form = new FormPanel(); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); form.setAction("../admin/importDB"); final FileUpload fu = new FileUpload(); fu.setName("file"); fu.getElement().getStyle().setMarginTop(20, Unit.PX); fu.getElement().getStyle().setMarginBottom(20, Unit.PX); VerticalPanel panel = new VerticalPanel(); form.add(panel);// ww w .jav a 2 s.co m panel.setWidth("100%"); panel.add(fu); final ProgressBar progress = new ProgressBar(Style.ANIMATED); progress.setVisible(false); progress.setPercent(100); panel.add(progress); final Button submit = new Button("Submit"); final Button cancel = new Button("Cancel"); submit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { progress.setVisible(true); submit.setEnabled(false); cancel.setEnabled(false); form.submit(); } }); cancel.setType(ButtonType.PRIMARY); cancel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); form.addSubmitHandler(new SubmitHandler() { public void onSubmit(SubmitEvent event) { if (!"".equalsIgnoreCase(fu.getFilename())) { progress.setVisible(true); } else { event.cancel(); // cancel the event hide(); } } }); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { hide(); } }); parent.add(form); ModalFooter footer = new ModalFooter(submit, cancel); add(footer); }
From source file:edu.caltech.ipac.firefly.ui.input.FileUploadField.java
public FileUploadField(FileUploadFieldDef fieldDef) { this.fieldDef = fieldDef; field = new FileUpload(); field.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { GWT.log(event.toDebugString(), null); }// w ww .j a v a 2 s. co m }); int width = fieldDef.getPreferWidth() > 0 ? fieldDef.getPreferWidth() : 200; field.setName(fieldDef.getName()); field.setWidth(width + "px"); // use size to set field size String size = fieldDef.getSize(); if (!StringUtils.isEmpty(size)) { GwtUtil.setFileUploadSize(field, size); } uploadForm = new FormPanel(); // Because we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(FormPanel.SubmitEvent event) { uploadMask = GwtUtil.mask("uploading file...", field); } }); uploadForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { if (uploadMask != null) { uploadMask.hide(); } ServletReply reply = ServletReply.parse(event.getResults()); //if (reply == null || reply.getValue() == null) { if (reply != null && reply.getStatus() != 200) { if (callback != null) { callback.onFailure(new RuntimeException(reply.getMessage())); } } else { if (callback != null) { if (reply == null) { _fieldValue = uploadKey; callback.onSuccess(uploadKey); } else { _fieldValue = reply.getValue(); callback.onSuccess(reply.getValue()); } } } } }); uploadForm.add(field); initWidget(uploadForm); cnt++; }
From source file:edu.cudenver.bios.glimmpse.client.panels.ModeSelectionPanel.java
License:Open Source License
/** * Constructor/* w w w .j a v a2 s .c om*/ */ public ModeSelectionPanel() { VerticalPanel panel = new VerticalPanel(); // layout the widgets // add introductory text HTML header = new HTML(Glimmpse.constants.modeSelectionTitle()); HTML description = new HTML(Glimmpse.constants.modeSelectionDescription()); // create user input container Grid inputContainer = new Grid(1, 3); // guided study design mode VerticalPanel guidedModeContainer = new VerticalPanel(); HTML guidedTitle = new HTML(Glimmpse.constants.modeSelectionGuidedTitle()); HTML guidedDescription = new HTML(Glimmpse.constants.modeSelectionGuidedDescription()); Button guidedGoButton = new Button(Glimmpse.constants.modeSelectionGoButton(), new ClickHandler() { public void onClick(ClickEvent e) { for (ModeSelectionListener listener : startListeners) listener.onGuidedMode(); } }); guidedModeContainer.add(guidedTitle); guidedModeContainer.add(guidedDescription); guidedModeContainer.add(guidedGoButton); // matrix entry mode VerticalPanel matrixModeContainer = new VerticalPanel(); HTML matrixTitle = new HTML(Glimmpse.constants.modeSelectionMatrixTitle()); HTML matrixDescription = new HTML(Glimmpse.constants.modeSelectionMatrixDescription()); Button matrixGoButton = new Button(Glimmpse.constants.modeSelectionGoButton(), new ClickHandler() { public void onClick(ClickEvent e) { for (ModeSelectionListener listener : startListeners) listener.onMatrixMode(); } }); matrixModeContainer.add(matrixTitle); matrixModeContainer.add(matrixDescription); matrixModeContainer.add(matrixGoButton); // upload an existing study VerticalPanel uploadContainer = new VerticalPanel(); HTML uploadTitle = new HTML(Glimmpse.constants.modeSelectionUploadTitle()); HTML uploadDescription = new HTML(Glimmpse.constants.modeSelectionUploadDescription()); uploadContainer.add(uploadTitle); uploadContainer.add(uploadDescription); // build the upload form // for file upload, we need to use the POST method, and multipart MIME encoding. formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); formPanel.setAction(UPLOAD_URI); // panel to contain the contents of the submission form HorizontalPanel formContents = new HorizontalPanel(); // create an upload widget uploader.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent e) { String filename = uploader.getFilename(); if (filename == null || filename.isEmpty()) { Window.alert( "No filename specified. Please click the 'Browse' button and select a file for upload."); } else { formPanel.submit(); } } }); uploader.setName(FORM_TAG_FILE); formContents.add(uploader); formPanel.add(formContents); formPanel.addSubmitCompleteHandler(this); uploadContainer.add(formPanel); // build overall panel inputContainer.setWidget(0, 0, guidedModeContainer); inputContainer.setWidget(0, 1, matrixModeContainer); inputContainer.setWidget(0, 2, uploadContainer); panel.add(header); panel.add(description); panel.add(inputContainer); // add style header.setStyleName(STYLE_HEADER); description.setStyleName(STYLE_DESCRIPTION); panel.setStyleName(STYLE_PANEL); inputContainer.setStyleName(STYLE_INPUT_CONTAINER); // guided subpanel style guidedModeContainer.setStyleName(STYLE_CONTAINER); guidedTitle.setStyleName(STYLE_CONTAINER_TITLE); guidedDescription.setStyleName(STYLE_CONTAINER_DESC); guidedGoButton.setStyleName(STYLE_GO_BUTTON); // matrix subpanel style matrixModeContainer.setStyleName(STYLE_CONTAINER); matrixTitle.setStyleName(STYLE_CONTAINER_TITLE); matrixDescription.setStyleName(STYLE_CONTAINER_DESC); matrixGoButton.setStyleName(STYLE_GO_BUTTON); // upload subpanel style uploadContainer.setStyleName(STYLE_CONTAINER); uploadTitle.setStyleName(STYLE_CONTAINER_TITLE); uploadDescription.setStyleName(STYLE_CONTAINER_DESC); // initialize the panel initWidget(panel); }
From source file:edu.cudenver.bios.powercalculator.client.panels.StartPanel.java
License:Open Source License
public StartPanel(InputWizardStepListener wizard, int stepIndex) { VerticalPanel panel = new VerticalPanel(); // layout the widgets // add introductory text HTML header = new HTML(PowerCalculatorGUI.constants.textStartPanelHeader()); HTML description = new HTML(PowerCalculatorGUI.constants.textStartPanelDescription()); panel.add(header);/*from w w w. j a va2 s. c o m*/ panel.add(description); // create user input container VerticalPanel inputContainer = new VerticalPanel(); // template design mode Grid templateModeContainer = new Grid(1, 2); VerticalPanel templateTextContainer = new VerticalPanel(); templateTextContainer.add(new HTML("<b>Study Design Templates</b>")); templateTextContainer.add(new HTML( "Common study designs including ANOVA, ANCOVA, and MANOVA. For users less familiar with the general linear model")); templateModeContainer.setWidget(0, 0, templateTextContainer); Button templateGo = new Button("Go", new ClickHandler() { public void onClick(ClickEvent e) { for (StartListener listener : startListeners) listener.onTemplateMode(); } }); templateGo.setStyleName("startPanelGoButton"); templateModeContainer.setWidget(0, 1, templateGo); // matrix entry mode Grid matrixModeContainer = new Grid(1, 2); VerticalPanel matrixTextContainer = new VerticalPanel(); matrixTextContainer.add(new HTML("<b>Matrix Mode</b>")); matrixTextContainer.add(new HTML( "Directly enter matrix representation for the general linear model. For users who are more familiar with statistical methods.")); matrixModeContainer.setWidget(0, 0, matrixTextContainer); Button matrixGo = new Button("Go", new ClickHandler() { public void onClick(ClickEvent e) { for (StartListener listener : startListeners) listener.onMatrixMode(); } }); matrixGo.setStyleName("startPanelGoButton"); matrixModeContainer.setWidget(0, 1, matrixGo); // upload an existing study VerticalPanel uploadContainer = new VerticalPanel(); uploadContainer.add(new HTML("<b>Upload an Existing Study</b>")); uploadContainer.add(new HTML( "If you have previously saved a study design from Glimmpse, you may upload it here. Click browse to select your study design file.")); // build the upload form // for file upload, we need to use the POST method, and multipart MIME encoding. formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); formPanel.setAction(UPLOAD_URI); // panel to contain the contents of the submission form HorizontalPanel formContents = new HorizontalPanel(); // create an upload widget uploader.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent e) { String filename = uploader.getFilename(); if (filename == null || filename.isEmpty()) { Window.alert( "No filename specified. Please click the 'Browse' button and select a file for upload."); } else { formPanel.submit(); } } }); uploader.setName(FORM_TAG_FILE); formContents.add(uploader); formPanel.add(formContents); formPanel.addSubmitCompleteHandler(this); uploadContainer.add(formPanel); templateModeContainer.setStyleName("startPanelContainer"); matrixModeContainer.setStyleName("startPanelContainer"); uploadContainer.setStyleName("startPanelContainer"); inputContainer.add(templateModeContainer); inputContainer.add(matrixModeContainer); inputContainer.add(uploadContainer); panel.add(inputContainer); // add style header.setStyleName(PowerCalculatorConstants.STYLE_WIZARD_STEP_HEADER); description.setStyleName(PowerCalculatorConstants.STYLE_WIZARD_STEP_DESCRIPTION); panel.setStyleName(PowerCalculatorConstants.STYLE_WIZARD_STEP_PANEL); inputContainer.setStyleName(PowerCalculatorConstants.STYLE_WIZARD_STEP_INPUT_CONTAINER); initWidget(panel); }
From source file:edu.iastate.airl.semtus.client.SEMTUSWEBAPP.java
License:Open Source License
public FormPanel upload() { final FormPanel form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "upload"); // Because we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. HorizontalPanel panel = new HorizontalPanel(); form.setWidget(panel);/*www. j a va 2 s. co m*/ // Create a FileUpload widget. final FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); panel.add(new HTML(" ")); // Add a 'submit' button. panel.add(new Button("Upload", new ClickHandler() { public void onClick(ClickEvent event) { String filename = upload.getFilename(); if (filename.length() == 0) { Window.alert("No File Specified"); } else { form.submit(); } } })); panel.add(new HTML(" ")); // Add a 'Done' button. panel.add(new Button("Done", new ClickHandler() { public void onClick(ClickEvent event) { uploadBox.hide(); tabPanel.selectTab(0); } })); // Add an event handler to the form. form.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { } }); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // Check if there's been an error in upload if (event.getResults() == null) { Window.alert( "Ontology Upload Failed. Please give us feedback [sushain.pandit@gmail.com] explaining the parameters of upload (filesize, format, etc) and we'll try to get it resolved asap."); } else if (event.getResults().toLowerCase().contains("file already exists")) { // if it's already present on // server, then we're just // fine. Window.alert( "You just uploaded this ontology. Please proceed to the workspace for text input. Thanks !"); } else if (event.getResults().toLowerCase().contains("error") || event.getResults().toLowerCase().contains("not available")) { // o'wise flag an error Window.alert( "Ontology Upload Failed. Please give us feedback [sushain.pandit@gmail.com] explaining the parameters of upload (filesize, format, etc) and we'll try to get it resolved asap."); } else { Window.alert(event.getResults()); Window.alert("Ontology Upload Successful"); } } }); return form; }
From source file:edu.ucdenver.bios.glimmpseweb.client.shared.ModeSelectionPanel.java
License:Open Source License
/** * Constructor//from w w w . jav a 2 s .c om */ public ModeSelectionPanel() { VerticalPanel panel = new VerticalPanel(); HorizontalPanel selectPanel = new HorizontalPanel(); // build the working dialog buildWaitDialog(); // layout the widgets // add introductory text HTML header = new HTML(GlimmpseWeb.constants.modeSelectionTitle()); HTML description = new HTML(GlimmpseWeb.constants.modeSelectionDescription()); // create user input container Grid inputContainer = new Grid(1, 3); // guided study design mode VerticalPanel guidedModeContainer = new VerticalPanel(); HTML guidedTitle = new HTML(GlimmpseWeb.constants.modeSelectionGuidedTitle()); HTML guidedDescription = new HTML(GlimmpseWeb.constants.modeSelectionGuidedDescription()); Button guidedGoButton = new Button(GlimmpseWeb.constants.modeSelectionGoButton(), new ClickHandler() { public void onClick(ClickEvent e) { for (ModeSelectionHandler listener : modeSelectionHandlers) listener.onGuidedMode(); } }); guidedModeContainer.add(guidedTitle); guidedModeContainer.add(guidedDescription); guidedModeContainer.add(guidedGoButton); // matrix entry mode VerticalPanel matrixModeContainer = new VerticalPanel(); HTML matrixTitle = new HTML(GlimmpseWeb.constants.modeSelectionMatrixTitle()); HTML matrixDescription = new HTML(GlimmpseWeb.constants.modeSelectionMatrixDescription()); Button matrixGoButton = new Button(GlimmpseWeb.constants.modeSelectionGoButton(), new ClickHandler() { public void onClick(ClickEvent e) { for (ModeSelectionHandler listener : modeSelectionHandlers) listener.onMatrixMode(); } }); matrixModeContainer.add(matrixTitle); matrixModeContainer.add(matrixDescription); matrixModeContainer.add(matrixGoButton); // upload an existing study VerticalPanel uploadContainer = new VerticalPanel(); HTML uploadTitle = new HTML(GlimmpseWeb.constants.modeSelectionUploadTitle()); HTML uploadDescription = new HTML(GlimmpseWeb.constants.modeSelectionUploadDescription()); uploadContainer.add(uploadTitle); uploadContainer.add(uploadDescription); // build the upload form // for file upload, we need to use the POST method, and multipart MIME encoding. formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); formPanel.setAction(UPLOAD_URI); // panel to contain the contents of the submission form HorizontalPanel formContents = new HorizontalPanel(); // create an upload widget uploader.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent e) { String filename = uploader.getFilename(); if (filename == null || filename.isEmpty()) { Window.alert( "No filename specified. Please click the 'Browse' button and select a file for upload."); } else { showWorkingDialog(); formPanel.submit(); } } }); uploader.setName(FORM_TAG_FILE); formContents.add(uploader); formPanel.add(formContents); formPanel.addSubmitCompleteHandler(this); uploadContainer.add(formPanel); // build overall panel inputContainer.setWidget(0, 0, guidedModeContainer); inputContainer.setWidget(0, 1, matrixModeContainer); inputContainer.setWidget(0, 2, uploadContainer); panel.add(header); panel.add(description); panel.add(inputContainer); // add style header.setStyleName(STYLE_HEADER); description.setStyleName(STYLE_DESCRIPTION); panel.setStyleName(STYLE_PANEL); inputContainer.setStyleName(STYLE_INPUT_CONTAINER); // guided subpanel style guidedModeContainer.setStyleName(STYLE_CONTAINER); guidedTitle.setStyleName(STYLE_CONTAINER_TITLE); guidedDescription.setStyleName(STYLE_CONTAINER_DESC); guidedGoButton.setStyleName(STYLE_GO_BUTTON); // matrix subpanel style matrixModeContainer.setStyleName(STYLE_CONTAINER); matrixTitle.setStyleName(STYLE_CONTAINER_TITLE); matrixDescription.setStyleName(STYLE_CONTAINER_DESC); matrixGoButton.setStyleName(STYLE_GO_BUTTON); // upload subpanel style uploadContainer.setStyleName(STYLE_CONTAINER); uploadTitle.setStyleName(STYLE_CONTAINER_TITLE); uploadDescription.setStyleName(STYLE_CONTAINER_DESC); // initialize the panel initWidget(panel); }
From source file:edu.ucla.loni.client.ServerLibraryManager.java
License:Open Source License
/** * Sets workarea to an import form//from w w w .j a va2 s . co m */ private void importForm() { clearWorkarea(); // Title Label title = new Label("Import File(s)"); title.setHeight(30); title.setStyleName("workarea-title"); // Uses GWT form components so we can submit in the background Grid grid = new Grid(4, 3); final FormPanel uploadForm = new FormPanel(); uploadForm.setWidget(grid); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.setAction(GWT.getModuleBaseURL() + "upload"); // Package Name Label packageLabel = new Label("Package"); packageLabel.setHeight(30); final TextBox packageName = new TextBox(); packageName.setName("packageName"); packageName.setWidth("300px"); Label packageDescription = new Label("Set package to put all uploaded files into that package.<br/>" + "If empty all files will be placed in the package specified in the file"); packageDescription.setHeight(30); packageDescription.setWidth(500); packageDescription.setStyleName("workarea-description"); grid.setWidget(0, 0, packageLabel); grid.setWidget(0, 1, packageName); grid.setWidget(0, 2, packageDescription); // Upload local file Label uploadLabel = new Label("Upload Local Files"); uploadLabel.setHeight(40); FileUpload fileItem = new FileUpload(); fileItem.setName("theMostUniqueName"); Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { enableUpload(); //FROM :: http://forums.smartclient.com/showthread.php?t=16007 } }); Label uploadDescription = new Label( "Select local files to upload. Accepts \".pipe\" files only. All other files are discarded."); uploadDescription.setHeight(30); uploadDescription.setWidth(500); uploadDescription.setStyleName("workarea-description"); grid.setWidget(1, 0, uploadLabel); grid.setWidget(1, 1, fileItem); grid.setWidget(1, 2, uploadDescription); // Upload URLs Label urlLabel = new Label("Upload From URLs"); urlLabel.setHeight(40); final TextArea urls = new TextArea(); urls.setName("urls"); urls.setWidth("300px"); urls.setHeight("100px"); Label urlDescription = new Label("Enter a newline seperated list of urls."); urlDescription.setHeight(40); urlDescription.setWidth(400); urlDescription.setStyleName("workarea-description"); grid.setWidget(2, 0, urlLabel); grid.setWidget(2, 1, urls); grid.setWidget(2, 2, urlDescription); Button uploadButton = new Button("Send"); uploadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { uploadForm.submit(); } }); grid.setWidget(3, 0, uploadButton); uploadForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { if (event.getResults().length() == 0) { success("Successfully uploaded files"); } else { error("Failed to upload files: " + event.getResults()); } updateFullTree(null); basicInstructions(); } }); // Root Directory Hidden hRoot = new Hidden(); hRoot.setName("root"); hRoot.setValue(rootDirectory.absolutePath); grid.setWidget(3, 1, hRoot); workarea.addMember(title); workarea.addMember(uploadForm); }