List of usage examples for com.google.gwt.user.client.ui FormPanel METHOD_POST
String METHOD_POST
To view the source code for com.google.gwt.user.client.ui FormPanel METHOD_POST.
Click Source Link
From source file:es.deusto.weblab.client.lab.comm.LabCommunication.java
License:Open Source License
/** * Sends the file specified through the upload structure to the server. This is done through an * HTTP post, which is received by a server-side web-script that actually does call the server-side * send_file method./*from w ww .j a va 2s .co m*/ */ @Override public void sendFile(SessionID sessionId, final UploadStructure uploadStructure, final IResponseCommandCallback callback) { // "Serialize" sessionId // We will now create the Hidden elements which we will use to pass // the required POST parameters to the web script that will actually handle // the file upload request. final Hidden sessionIdElement = new Hidden(); sessionIdElement.setName(LabCommunication.SESSION_ID_ATTR); sessionIdElement.setValue(sessionId.getRealId()); final Hidden fileInfoElement = new Hidden(); fileInfoElement.setName(LabCommunication.FILE_INFO_ATTR); fileInfoElement.setValue(uploadStructure.getFileInfo()); // TODO: This could be enabled. Left disabled for now just in case it has // side effects. It isn't really required because the is_async attribute is // optional and false by default. final Hidden isAsyncElement = new Hidden(); isAsyncElement.setName(LabCommunication.FILE_IS_ASYNC_ATTR); isAsyncElement.setValue("false"); // Set up uploadStructure uploadStructure.addInformation(sessionIdElement); uploadStructure.addInformation(fileInfoElement); uploadStructure.addInformation(isAsyncElement); uploadStructure.getFileUpload().setName(LabCommunication.FILE_SENT_ATTR); uploadStructure.getFormPanel().setAction(this.getFilePostUrl()); uploadStructure.getFormPanel().setEncoding(FormPanel.ENCODING_MULTIPART); uploadStructure.getFormPanel().setMethod(FormPanel.METHOD_POST); // Register handler uploadStructure.getFormPanel().addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { uploadStructure.removeInformation(sessionIdElement); final String resultMessage = event.getResults(); if (GWT.isScript() && resultMessage == null) { this.reportFail(callback); } else { this.processResultMessage(callback, resultMessage); } } private void processResultMessage(IResponseCommandCallback callback, String resultMessage) { final ResponseCommand parsedResponseCommand; try { parsedResponseCommand = ((ILabSerializer) LabCommunication.this.serializer) .parseSendFileResponse(resultMessage); } catch (final SerializationException e) { callback.onFailure(e); return; } catch (final SessionNotFoundException e) { callback.onFailure(e); return; } catch (final WebLabServerException e) { callback.onFailure(e); return; } callback.onSuccess(parsedResponseCommand); } private void reportFail(final IResponseCommandCallback callback) { GWT.log("reportFail could not send the file", null); callback.onFailure(new CommException("Couldn't send the file")); } }); // Submit uploadStructure.getFormPanel().submit(); }
From source file:es.deusto.weblab.client.lab.experiments.JSBoardBaseController.java
License:Open Source License
@Override public void sendFile(final UploadStructure uploadStructure, final IResponseCommandCallback callback) { final Hidden reservationIdElement = new Hidden("reservation_id", getReservationId()); // Set up uploadStructure uploadStructure.addInformation(reservationIdElement); uploadStructure.addInformation(new Hidden("file_info", uploadStructure.getFileInfo())); uploadStructure.addInformation(new Hidden("is_async", "false")); uploadStructure.getFileUpload().setName("file_sent"); uploadStructure.getFormPanel().setAction(getFileUploadUrl()); uploadStructure.getFormPanel().setEncoding(FormPanel.ENCODING_MULTIPART); uploadStructure.getFormPanel().setMethod(FormPanel.METHOD_POST); // Register handler uploadStructure.getFormPanel().addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override//w w w. ja v a2 s .c o m public void onSubmitComplete(SubmitCompleteEvent event) { uploadStructure.removeInformation(reservationIdElement); final String resultMessage = event.getResults(); if (GWT.isScript() && resultMessage == null) { this.reportFail(callback); } else { this.processResultMessage(callback, resultMessage); } } private void processResultMessage(IResponseCommandCallback callback, String resultMessage) { if (resultMessage == null) { if (GWT.isScript()) { callback.onSuccess(new EmptyResponseCommand()); } return; } final ResponseCommand parsedResponseCommand; try { parsedResponseCommand = parseSendFileResponse(resultMessage); } catch (final FileResponseException e) { callback.onFailure(e); return; } callback.onSuccess(parsedResponseCommand); } private void reportFail(final IResponseCommandCallback callback) { GWT.log("reportFail could not send the file", null); callback.onFailure(new CommException("Couldn't send the file")); } }); // Submit uploadStructure.getFormPanel().submit(); }
From source file:es.upm.fi.dia.oeg.map4rdf.client.view.ShapeFilesView.java
License:Open Source License
private Widget createFormUploadUi() { // Servlet action. formUpload.setAction("./upload"); // FileUpload widget needs to be a POST method. formUpload.setMethod(FormPanel.METHOD_POST); panel = new FlowPanel(); formUpload.setWidget(panel);/* w w w . j a v a 2 s . c o m*/ // Add the section to put the URL to download shapefiles. panel.add(new Label("URL to shapefiles:")); TextBox urlShapeFile = new TextBox(); urlShapeFile.setName("urlShapeFile"); panel.add(urlShapeFile); submitUrlButton = new Button("Submit URL and display"); panel.add(submitUrlButton); panel.add(new Label("\n--------------------\n")); panel.add(new Label("Select the zip file with the shapefiles you " + "want to display.")); fileUpload = new FileUpload(); fileUpload.setName("uploadFormElement"); panel.add(fileUpload); submitUploadButton = new Button("Upload and display"); panel.add(submitUploadButton); return formUpload; }
From source file:fi.jyu.student.jatahama.onlineinquirytool.client.OnlineInquiryTool.java
License:Open Source License
/** * UI Creator. Called after we have checked servlet existence *//*from ww w . ja v a 2s. c o m*/ public void createUI() { // Won't need this anymore because will build it right here! needUI = false; // Set window title Window.setTitle(constants.tcLblToolTitle()); // Create anchor createAnchor.addClickHandler(this); createAnchor.setStyleName("nav"); // Open anchor // NOTE: Because we use input (type=file), we wrap anchor inside a div which has invisible input over our anchor. openAnchor.setStyleName("nav"); // Open button openButton.addChangeHandler(this); openButton.getElement().setId("file-input"); openButton.setName("file-input"); openButton.setStyleName("file-open"); openButton.addMouseOutHandler(this); openButton.addMouseOverHandler(this); openButton.setTitle(""); // Wrapper for open stuff final FlowPanel openWrap = new FlowPanel(); openWrap.setStyleName("file-wrap"); openWrap.add(openAnchor); loadForm.setAction(loadsaveServletUrl); loadForm.setEncoding(FormPanel.ENCODING_MULTIPART); loadForm.setMethod(FormPanel.METHOD_POST); loadForm.add(openButton); loadForm.addSubmitCompleteHandler(this); openWrap.add(loadForm); // Save anchor saveAnchor.addClickHandler(this); saveAnchor.setStyleName("nav"); // Save as popup saveAsPopup.setStylePrimaryName("save-popup"); final VerticalPanel sv = new VerticalPanel(); sv.setStylePrimaryName("save-wrap"); final Label slbl = new Label(constants.tcLblSaveAs()); slbl.setStyleName("save-label"); sv.add(slbl); final HorizontalPanel sh1 = new HorizontalPanel(); sh1.setStylePrimaryName("save-name-wrap"); saveName.setStylePrimaryName("save-name"); sh1.add(saveName); saveName.setText(constants.tcTxtDefaultChartFilename()); saveName.addKeyDownHandler(this); final Label ssuf = new Label(".xhtml"); ssuf.setStylePrimaryName("save-suffix"); sh1.add(ssuf); sv.add(sh1); final HorizontalPanel sh2 = new HorizontalPanel(); sh2.setStylePrimaryName("save-button-wrap"); // btnSaveOk.setStylePrimaryName("save-button"); // btnSaveCancel.setStylePrimaryName("save-button"); sh2.add(btnSaveCancel); sh2.add(btnSaveOk); sv.add(sh2); btnSaveCancel.addClickHandler(this); btnSaveOk.addClickHandler(this); saveAsPopup.setWidget(sv); saveAsPopup.setGlassEnabled(true); saveAsPopup.setGlassStyleName("save-glass"); // (hidden) Form panel for save saveForm.setAction(loadsaveServletUrl); saveForm.setEncoding(FormPanel.ENCODING_MULTIPART); saveForm.setMethod(FormPanel.METHOD_POST); saveForm.setStylePrimaryName("no-display"); chartData.setStylePrimaryName("no-display"); chartData.setName("chartDataXML"); chartName.setStylePrimaryName("no-display"); chartName.setName("chartFilename"); final FlowPanel sp = new FlowPanel(); // Ordering is important because server expects name first! // Otherwise default filename would be used on server side. sp.add(chartName); sp.add(chartData); saveForm.add(sp); // loadingPopup final Label loadingLabel = new Label(OnlineInquiryTool.constants.tcLblLoading()); loadingLabel.setStyleName("loading-text", true); loadingPopup.setStyleName("popup-z", true); loadingPopup.setGlassEnabled(true); loadingPopup.setWidget(loadingLabel); // loadingFailed final VerticalPanel loadingFailContent = new VerticalPanel(); loadingFailContent.setStyleName("black-border"); loadingFailLabel.setStyleName("fail-label"); loadingFailedPopup.setStyleName("popup-z", true); loadingFailedPopup.setGlassEnabled(true); final ClickHandler failCloseHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { loadingFailedPopup.hide(); } }; final Button failPopClose = new Button(constants.tcBtnOk(), failCloseHandler); final SimplePanel failCloseHolder = new SimplePanel(); failCloseHolder.setStyleName("popup-button-holder"); failCloseHolder.add(failPopClose); loadingFailContent.add(loadingFailLabel); loadingFailContent.add(failCloseHolder); loadingFailedPopup.add(loadingFailContent); // Dirty popup dirtyPopup.setStylePrimaryName("dirty-popup"); final VerticalPanel sv2 = new VerticalPanel(); sv2.setStylePrimaryName("dirty-wrap"); final Label dlbl = new Label(constants.tcLblNotSaved()); dlbl.setStyleName("dirty-header"); sv2.add(dlbl); final Label dlbl2 = new Label(constants.tcLblPromptSave()); dlbl2.setStylePrimaryName("dirty-label"); sv2.add(dlbl2); final HorizontalPanel sh3 = new HorizontalPanel(); sh3.setStylePrimaryName("dirty-button-wrap"); sh3.add(btnDirtyCancel); sh3.add(btnDirtyNo); sh3.add(btnDirtyYes); sv2.add(sh3); btnDirtyCancel.addClickHandler(this); btnDirtyNo.addClickHandler(this); btnDirtyYes.addClickHandler(this); dirtyPopup.setWidget(sv2); dirtyPopup.setGlassEnabled(true); dirtyPopup.setGlassStyleName("dirty-glass"); // Navigation Hyperlink instructionsLink = new Hyperlink(constants.tcBtnInstructions(), "instructions"); instructionsLink.setStyleName("nav"); final Label spacer1 = new Label(); // Spacer for second column spacer1.setStyleName("nav-spacer"); final Label spacer2 = new Label(); // Spacer for second column spacer2.setStyleName("nav-spacer"); final FlowPanel navWrap1 = new FlowPanel(); navWrap1.setStyleName("clear-wrap nav-wrap rmargin10"); navWrap1.add(createAnchor); navWrap1.add(openWrap); navWrap1.add(saveAnchor); final FlowPanel navWrap2 = new FlowPanel(); navWrap2.setStyleName("clear-wrap nav-wrap"); navWrap2.add(spacer1); navWrap2.add(spacer2); navWrap2.add(instructionsLink); final FlowPanel navPanel = new FlowPanel(); navPanel.setStyleName("blue-border page-nav"); navPanel.add(navWrap1); navPanel.add(navWrap2); RootPanel.get("content").add(navPanel); // Site title Label siteTitle = new Label(constants.tcLblToolTitle()); siteTitle.setStyleName("site-title"); RootPanel.get("content").add(siteTitle); // Check load save states checkLoadSaveState(); // Build main deck final FlowPanel contentWrap = new FlowPanel(); contentWrap.setStyleName("blue-border page-main-content"); mainDeck.setStyleName("clear-wrap"); contentWrap.add(mainDeck); RootPanel.get("content").add(contentWrap); mainDeck.add(claimAnalysisPanel); mainDeck.showWidget(0); // Help popup final HTML helpText = new HTML(constants.tcTxtInstructionsText()); final ScrollPanel textWrapper = new ScrollPanel(); textWrapper.setStyleName("help-text-wrap", true); textWrapper.add(helpText); final VerticalPanel popContent = new VerticalPanel(); final ClickHandler closeHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { helpPanel.hide(); } }; final Button popClose = new Button(constants.tcBtnClose(), closeHandler); final SimplePanel holder = new SimplePanel(); holder.setStyleName("popup-button-holder"); holder.add(popClose); popContent.setStyleName("help-popup-wrap"); popContent.add(textWrapper); popContent.add(holder); helpPanel.setGlassEnabled(true); helpPanel.setWidget(popContent); helpPanel.setStyleName("popup-z", true); // helpPanel.setWidth("500px"); // Add history listener and set initial state History.addValueChangeHandler(this); String initToken = History.getToken(); if (initToken.length() == 0) { History.newItem("welcome"); } else { // Fire initial history state. History.fireCurrentHistoryState(); } claimAnalysisPanel.setClaim(null); claimAnalysisPanel.updateLayout(); claimAnalysisPanel.updateClaimTitleAndConclusionWidgets(); // App info (hidden) RootPanel.get("appinfo").add( new HTML("Version: " + AppInfo.getBuildVersion() + (AppInfo.isBuildClean() ? "-clean" : "-dirty") + "<br />" + "Date: " + AppInfo.getBuildDate() + "<br />" + "Branch: " + AppInfo.getBuildBranch() + "<br />" + "Commit: " + AppInfo.getBuildCommit())); // Copyright stuff + version VerticalPanel copyWrap = new VerticalPanel(); copyWrap.setStyleName("copyright-wrap"); copyAnchor.setStyleName("copyright-text"); copyAnchor.setText(constants.tcLblCopyright()); copyAnchor.addClickHandler(this); copyWrap.add(copyAnchor); versionAnchor.setStyleName("copyright-text"); versionAnchor.setText(constants.tcLblVersion() + " " + AppInfo.getBuildVersion()); versionAnchor.addClickHandler(this); copyWrap.add(versionAnchor); contentWrap.add(copyWrap); // Copyright and appinfo final SimplePanel infoWrapper = new SimplePanel(); infoWrapper.setStyleName("help-text-wrap", true); infoWrapper.add(infoText); final VerticalPanel infoPopContent = new VerticalPanel(); final ClickHandler infoCloseHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { infoPopup.hide(); } }; final Button infoPopClose = new Button(constants.tcBtnClose(), infoCloseHandler); final SimplePanel infoBtnHolder = new SimplePanel(); infoBtnHolder.setStyleName("popup-button-holder"); infoBtnHolder.add(infoPopClose); infoPopContent.setStyleName("info-popup-wrap"); infoPopContent.add(infoWrapper); infoPopContent.add(infoBtnHolder); infoPopup.setGlassEnabled(true); infoPopup.setWidget(infoPopContent); infoPopup.setStyleName("popup-z", true); // Confirm page leave if not saved Window.addWindowClosingHandler(new Window.ClosingHandler() { public void onWindowClosing(Window.ClosingEvent closingEvent) { ClaimAnalysis claim = claimAnalysisPanel.getClaim(); if (claim != null) { if (claim.isDirty()) { closingEvent.setMessage(constants.tcLblNotSaved()); } } } }); // Save form must be on doc or it will not work RootPanel.get().add(saveForm); }
From source file:fr.aliasource.webmail.client.composer.AttachmentUploadWidget.java
License:GNU General Public License
private void buildUpload(final DockPanel dp) { setEncoding(FormPanel.ENCODING_MULTIPART); setMethod(FormPanel.METHOD_POST); setAction(GWT.getModuleBaseURL() + "attachements"); Label l = new Label(); dp.add(l, DockPanel.WEST);//from w w w . j a v a 2 s . c o m dp.setCellVerticalAlignment(l, VerticalPanel.ALIGN_MIDDLE); upload = new FileUpload(); upload.setName(attachementId); dp.add(upload, DockPanel.CENTER); droppAttachmentLink = new Anchor(I18N.strings.delete()); droppAttachmentLink.addClickHandler(createDropAttachmentClickListener()); HorizontalPanel eastPanel = new HorizontalPanel(); upSpinner = new Image("minig/images/spinner_moz.gif"); upSpinner.setVisible(false); eastPanel.add(upSpinner); eastPanel.add(droppAttachmentLink); dp.add(eastPanel, DockPanel.EAST); addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { GWT.log("on submit " + attachementId, null); upSpinner.setVisible(true); droppAttachmentLink.setVisible(false); attachPanel.notifyUploadStarted(attachementId); } }); addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { GWT.log("on submit complete " + attachementId, null); upSpinner.setVisible(false); droppAttachmentLink.setVisible(true); attachPanel.notifyUploadComplete(attachementId); HorizontalPanel hp = new HorizontalPanel(); Label uploadInfo = new Label(); uploadInfo.setText("File '" + attachementId + "' attached."); hp.add(uploadInfo); dp.remove(upload); dp.add(hp, DockPanel.CENTER); updateMetadata(hp); } }); Timer t = new Timer() { public void run() { if (upload.getFilename() != null && upload.getFilename().length() > 0) { GWT.log("filename before upload: " + upload.getFilename(), null); cancel(); submit(); } } }; t.scheduleRepeating(300); }
From source file:fr.gael.dhus.gwt.client.page.UploadPage.java
License:Open Source License
private static void init() { showUpload();/*w w w. jav a2s. co m*/ uploadProductFile = FileUpload.wrap(RootPanel.get("upload_productFile").getElement()); final Hidden collectionsField = Hidden.wrap(RootPanel.get("upload_collections").getElement()); uploadButton = RootPanel.get("upload_uploadButton"); url = TextBox.wrap(RootPanel.get("upload_url").getElement()); username = TextBox.wrap(RootPanel.get("upload_username").getElement()); pattern = TextBox.wrap(RootPanel.get("upload_pattern").getElement()); patternResult = RootPanel.get("upload_patternResult"); password = PasswordTextBox.wrap(RootPanel.get("upload_password").getElement()); scanButton = RootPanel.get("upload_scanButton"); stopButton = RootPanel.get("upload_stopButton"); addButton = RootPanel.get("upload_addButton"); cancelButton = RootPanel.get("upload_cancelButton"); deleteButton = RootPanel.get("upload_deleteButton"); saveButton = RootPanel.get("upload_saveButton"); status = RootPanel.get("upload_status"); refreshButton = RootPanel.get("upload_refreshButton"); scannerInfos = RootPanel.get("upload_scannerInfos"); uploadForm = new FormPanel(); uploadForm.setAction(GWT.getHostPageBaseURL() + "/api/upload"); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.setWidget(RootPanel.get("upload_form")); RootPanel.get("upload_product").add(uploadForm); selectedCollections = new ArrayList<Long>(); uploadButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (uploadButton.getElement().getClassName().contains("disabled")) { return; } String filename = uploadProductFile.getFilename(); if (filename.length() == 0) { Window.alert("No file selected!"); } else { DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait"); String collections = ""; if (selectedCollections != null && !selectedCollections.isEmpty()) { for (Long cId : selectedCollections) { collections += cId + ","; } collections = collections.substring(0, collections.length() - 1); } collectionsField.setValue(collections); uploadForm.submit(); setState(State.UPLOADING); } } }, ClickEvent.getType()); uploadForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { RegExp regexp = RegExp.compile(".*HTTP Status ([0-9]+).*"); Integer errCode = null; try { errCode = new Integer(regexp.exec(event.getResults()).getGroup(1)); } catch (Exception e) { } if (errCode == null) { Window.alert("Your product has been successfully uploaded."); } else { switch (errCode) { case 400: Window.alert("Your request is missing a product file to upload."); break; case 403: Window.alert("You are not allowed to upload a file on Sentinel Data Hub."); break; case 406: Window.alert("Your product was not added. It can not be read by the system."); break; case 415: Window.alert("Request contents type is not supported by the servlet."); break; case 500: Window.alert("An error occurred while creating the file."); break; default: Window.alert("There was an untraceable error while uploading your product."); break; } } DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default"); setState(State.DEFAULT); } }); addButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (addButton.getElement().getClassName().contains("disabled")) { return; } uploadService.addFileScanner(url.getValue(), username.getValue(), password.getValue(), pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Long>() { @Override public void _onFailure(Throwable caught) { Window.alert("There was an error during adding '" + url.getValue() + "' to your file scanners.\n" + caught.getMessage()); } @Override public void onSuccess(Long result) { setState(State.ADDING_FILESCANNER); setState(State.DEFAULT); } }); } }, ClickEvent.getType()); scanButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (scanButton.getElement().getClassName().contains("disabled")) { return; } if (state == State.EDIT_FILESCANNER && editedScannerId != null) { uploadService.updateFileScanner(new Long(editedScannerId.longValue()), url.getValue(), username.getValue(), password.getValue(), pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { Window.alert("There was an error during adding '" + url.getValue() + "' to your file scanners.\n" + caught.getMessage()); } @Override public void onSuccess(Void scanId) { // final String sUrl = url.getValue(); setState(State.DEFAULT); uploadService.processScan(new Long(editedScannerId.longValue()), new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { } }); } }); } else { uploadService.addFileScanner(url.getValue(), username.getValue(), password.getValue(), pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Long>() { @Override public void _onFailure(Throwable caught) { Window.alert("There was an error during adding '" + url.getValue() + "' to your file scanners.\n" + caught.getMessage()); } @Override public void onSuccess(Long scanId) { // final String sUrl = url.getValue(); setState(State.ADDING_FILESCANNER); setState(State.DEFAULT); uploadService.processScan(scanId, new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { } }); } }); } } }, ClickEvent.getType()); stopButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (stopButton.getElement().getClassName().contains("disabled")) { return; } uploadService.stopScan(new Long(editedScannerId.longValue()), new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { setState(State.ADDING_FILESCANNER); setState(State.DEFAULT); } }); } }, ClickEvent.getType()); cancelButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (cancelButton.getElement().getClassName().contains("disabled")) { return; } setDefaultState(); } }, ClickEvent.getType()); refreshButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (refreshButton.getElement().getClassName().contains("disabled")) { return; } refreshScanners(); } }, ClickEvent.getType()); deleteButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (deleteButton.getElement().getClassName().contains("disabled") && editedScannerId != null) { return; } removeScanner(editedScannerId); } }, ClickEvent.getType()); saveButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (saveButton.getElement().getClassName().contains("disabled")) { return; } uploadService.updateFileScanner(new Long(editedScannerId), url.getValue(), username.getValue(), password.getValue(), pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { Window.alert("There was an error while updating your file scanner.\n" + caught.getMessage()); } @Override public void onSuccess(Void result) { setDefaultState(); } }); } }, ClickEvent.getType()); refresh(); }
From source file:gov.nist.appvet.gwt.client.gui.dialog.AppUploadDialogBox.java
License:Open Source License
public AppUploadDialogBox(String sessionId, String servletURL) { super(false, true); setSize("", ""); setAnimationEnabled(false);/*from w w w. ja v a 2 s .c o m*/ final VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); this.setWidget(dialogVPanel); dialogVPanel.setSize("", ""); final SimplePanel simplePanel = new SimplePanel(); simplePanel.setStyleName("appUploadPanel"); dialogVPanel.add(simplePanel); dialogVPanel.setCellVerticalAlignment(simplePanel, HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellHorizontalAlignment(simplePanel, HasHorizontalAlignment.ALIGN_CENTER); simplePanel.setSize("", ""); uploadAppForm = new FormPanel(); simplePanel.setWidget(uploadAppForm); uploadAppForm.setAction(servletURL); uploadAppForm.setMethod(FormPanel.METHOD_POST); uploadAppForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadAppForm.setSize("", ""); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); uploadAppForm.setWidget(verticalPanel); verticalPanel.setSize("", ""); final Hidden hiddenCommand = new Hidden(); hiddenCommand.setValue("SUBMIT_APP"); hiddenCommand.setName("command"); verticalPanel.add(hiddenCommand); hiddenCommand.setWidth(""); final Hidden hiddenSessionId = new Hidden(); hiddenSessionId.setName("sessionid"); hiddenSessionId.setValue(sessionId); verticalPanel.add(hiddenSessionId); hiddenSessionId.setWidth(""); final HorizontalPanel horizontalButtonPanel = new HorizontalPanel(); horizontalButtonPanel.setStyleName("buttonPanel"); dialogVPanel.add(horizontalButtonPanel); horizontalButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellVerticalAlignment(horizontalButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER); horizontalButtonPanel.setSpacing(10); horizontalButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); horizontalButtonPanel.setWidth("300px"); verticalPanel.setCellWidth(horizontalButtonPanel, "100%"); final Grid grid = new Grid(2, 2); grid.setStyleName("grid"); verticalPanel.add(grid); verticalPanel.setCellHorizontalAlignment(grid, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE); grid.setSize("", ""); final Label uploadLabel = new Label("App file: "); uploadLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(0, 0, uploadLabel); uploadLabel.setStyleName("uploadLabel"); uploadLabel.setSize("", ""); fileUpload = new FileUpload(); grid.setWidget(0, 1, fileUpload); grid.getCellFormatter().setWidth(0, 1, ""); grid.getCellFormatter().setHeight(0, 1, ""); fileUpload.setStyleName("appUpload"); fileUpload.setTitle("Select app file to upload"); fileUpload.setName("fileupload"); fileUpload.setSize("240px", ""); grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); submitAppStatusLabel = new Label(""); submitAppStatusLabel.setStyleName("submissionRequirementsLabel"); submitAppStatusLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.add(submitAppStatusLabel); verticalPanel.setCellHorizontalAlignment(submitAppStatusLabel, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setCellVerticalAlignment(submitAppStatusLabel, HasVerticalAlignment.ALIGN_MIDDLE); submitAppStatusLabel.setSize("", "18px"); cancelButton = new PushButton("Cancel"); cancelButton.setHTML("Cancel"); horizontalButtonPanel.add(cancelButton); horizontalButtonPanel.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_CENTER); cancelButton.setSize("70px", "18px"); submitButton = new PushButton("Submit"); horizontalButtonPanel.add(submitButton); horizontalButtonPanel.setCellHorizontalAlignment(submitButton, HasHorizontalAlignment.ALIGN_CENTER); submitButton.setSize("70px", "18px"); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { uploadAppForm.submit(); } }); }
From source file:gov.nist.appvet.gwt.client.gui.dialog.ReportUploadDialogBox.java
License:Open Source License
public ReportUploadDialogBox(String username, String sessionId, String appid, String servletURL, String[] availableToolNames, final String[] availableToolIDs) { super(false, true); setWidth("100%"); setAnimationEnabled(false);//from w w w .ja va2 s . c o m final VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); this.setWidget(dialogVPanel); dialogVPanel.setSize("", ""); this.servletURL = servletURL; final SimplePanel simplePanel = new SimplePanel(); simplePanel.setStyleName("reportUploadPanel"); dialogVPanel.add(simplePanel); dialogVPanel.setCellVerticalAlignment(simplePanel, HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellHorizontalAlignment(simplePanel, HasHorizontalAlignment.ALIGN_CENTER); simplePanel.setSize("", ""); uploadReportForm = new FormPanel(); simplePanel.setWidget(uploadReportForm); uploadReportForm.setSize("", ""); uploadReportForm.setAction(servletURL); uploadReportForm.setMethod(FormPanel.METHOD_POST); uploadReportForm.setEncoding(FormPanel.ENCODING_MULTIPART); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); uploadReportForm.setWidget(verticalPanel); verticalPanel.setSize("", ""); final Hidden hiddenAppid = new Hidden(); hiddenAppid.setName("appid"); hiddenAppid.setValue(appid); verticalPanel.add(hiddenAppid); final Hidden hiddenUsername = new Hidden(); hiddenUsername.setName("username"); hiddenUsername.setValue(username); verticalPanel.add(hiddenUsername); final Hidden hiddenSessionId = new Hidden(); hiddenSessionId.setName("sessionid"); hiddenSessionId.setValue(sessionId); verticalPanel.add(hiddenSessionId); // final Hidden hiddenAnalyst = new Hidden(); // hiddenAnalyst.setName("analyst"); // hiddenAnalyst.setValue(username); // verticalPanel.add(hiddenAnalyst); final Hidden hiddenCommand = new Hidden(); hiddenCommand.setValue("SUBMIT_REPORT"); hiddenCommand.setName("command"); verticalPanel.add(hiddenCommand); hiddenToolID = new Hidden(); hiddenToolID.setName("toolid"); verticalPanel.add(hiddenToolID); final Grid grid = new Grid(5, 2); grid.setCellPadding(5); grid.setStyleName("grid"); verticalPanel.add(grid); grid.setHeight("210px"); verticalPanel.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(grid, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setCellWidth(grid, "100%"); final Label labelAnalyst = new Label("Analyst: "); labelAnalyst.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); labelAnalyst.setStyleName("reportUploadLabel"); grid.setWidget(0, 0, labelAnalyst); labelAnalyst.setWidth(""); final TextBox analystTextBox = new TextBox(); analystTextBox.setAlignment(TextAlignment.LEFT); analystTextBox.setText(username); analystTextBox.setEnabled(true); analystTextBox.setReadOnly(true); grid.setWidget(0, 1, analystTextBox); grid.getCellFormatter().setHeight(0, 1, "18px"); grid.getCellFormatter().setWidth(0, 1, "300px"); grid.getCellFormatter().setStyleName(0, 1, "reportUploadWidget"); analystTextBox.setSize("220px", "18px"); final Label appIdLabel = new Label("App ID: "); appIdLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(1, 0, appIdLabel); grid.getCellFormatter().setWidth(1, 0, "300px"); grid.getCellFormatter().setHeight(1, 1, "18px"); grid.getCellFormatter().setWidth(1, 1, "300px"); final TextBox appIdTextBox = new TextBox(); appIdTextBox.setAlignment(TextAlignment.LEFT); appIdTextBox.setText(appid); appIdTextBox.setEnabled(true); appIdTextBox.setReadOnly(true); grid.setWidget(1, 1, appIdTextBox); grid.getCellFormatter().setStyleName(1, 1, "reportUploadWidget"); appIdTextBox.setSize("220px", "18px"); final Label toolNameLabel = new Label("Tool: "); toolNameLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(2, 0, toolNameLabel); toolNameLabel.setWidth("90px"); grid.getCellFormatter().setWidth(2, 1, "300px"); toolNamesComboBox = new ListBox(); grid.setWidget(2, 1, toolNamesComboBox); grid.getCellFormatter().setHeight(2, 1, "18px"); grid.getCellFormatter().setStyleName(2, 1, "reportUploadWidget"); toolNamesComboBox.setSize("231px", "22px"); final Label lblReport = new Label("Report: "); lblReport.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(3, 0, lblReport); grid.getCellFormatter().setWidth(3, 1, "300px"); fileUpload = new FileUpload(); fileUpload.setName("fileupload"); grid.setWidget(3, 1, fileUpload); grid.getCellFormatter().setHeight(3, 1, "18px"); grid.getCellFormatter().setStyleName(3, 1, "reportUploadWidget"); fileUpload.setSize("189px", "22px"); final Label riskLabel = new Label("Risk: "); riskLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(4, 0, riskLabel); grid.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setWidth(4, 1, "300px"); grid.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_MIDDLE); ListBox toolRiskComboBox = new ListBox(); toolRiskComboBox.setName("toolrisk"); toolRiskComboBox.addItem("PASS"); toolRiskComboBox.addItem("WARNING"); toolRiskComboBox.addItem("FAIL"); grid.setWidget(4, 1, toolRiskComboBox); grid.getCellFormatter().setHeight(4, 1, "18px"); grid.getCellFormatter().setStyleName(4, 1, "reportUploadWidget"); toolRiskComboBox.setSize("231px", "22px"); grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); statusLabel = new Label(""); statusLabel.setStyleName("submissionRequirementsLabel"); verticalPanel.add(statusLabel); verticalPanel.setCellWidth(statusLabel, "100%"); verticalPanel.setCellVerticalAlignment(statusLabel, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(statusLabel, HasHorizontalAlignment.ALIGN_CENTER); statusLabel.setHeight("20px"); final HorizontalPanel horizontalButtonPanel = new HorizontalPanel(); horizontalButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalButtonPanel.setStyleName("reportUploadButtonPanel"); dialogVPanel.add(horizontalButtonPanel); dialogVPanel.setCellVerticalAlignment(horizontalButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER); dialogVPanel.setCellWidth(horizontalButtonPanel, "100%"); horizontalButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); horizontalButtonPanel.setSize("210px", ""); cancelButton = new PushButton("Cancel"); cancelButton.setHTML("Cancel"); horizontalButtonPanel.add(cancelButton); cancelButton.setSize("70px", "18px"); horizontalButtonPanel.setCellVerticalAlignment(cancelButton, HasVerticalAlignment.ALIGN_MIDDLE); horizontalButtonPanel.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_CENTER); submitButton = new PushButton("Submit"); horizontalButtonPanel.add(submitButton); horizontalButtonPanel.setCellHorizontalAlignment(submitButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalButtonPanel.setCellVerticalAlignment(submitButton, HasVerticalAlignment.ALIGN_MIDDLE); submitButton.setSize("70px", "18px"); verticalPanel.setCellWidth(horizontalButtonPanel, "100%"); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Set toolid first int selectedToolNameIndex = toolNamesComboBox.getSelectedIndex(); String toolID = availableToolIDs[selectedToolNameIndex]; hiddenToolID.setValue(toolID); uploadReportForm.submit(); } }); for (final String availableTool : availableToolNames) { final String toolName = availableTool; if ((toolName != null) && !toolName.isEmpty()) { toolNamesComboBox.addItem(availableTool); } } }
From source file:gwtupload.client.Uploader.java
License:Apache License
/** * Initialize widget components and layout elements. * //from w ww . ja va 2 s. c om * @param type * file input to use * @param form * An existing form panel to use */ public Uploader(FileInputType type, FormPanel form) { thisInstance = this; this.fileInputType = type; if (form == null) { form = new FormFlowPanel(); } uploadForm = form; uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.addSubmitHandler(onSubmitFormHandler); uploadForm.addSubmitCompleteHandler(onSubmitCompleteHandler); uploaderPanel = getUploaderPanel(); uploaderPanel.add(uploadForm); uploaderPanel.setStyleName(STYLE_MAIN); setFileInput(fileInputType.getInstance()); setStatusWidget(statusWidget); super.initWidget(uploaderPanel); }
From source file:n3phele.client.widgets.S3UploadPanel.java
License:Open Source License
protected S3UploadPanel() { this.setWidth("500px"); flow = new FlowPanel(); this.add(flow); this.addStyleName(N3phele.n3pheleResource.css().workspacePanel()); Cell<MenuItem> cell = new IconTextCell<MenuItem>(32, 32); header = new HorizontalPanel(); header.setWidth("100%"); header.addStyleName(N3phele.n3pheleResource.css().workspacePanelHeader()); header.add(new CellWidget<MenuItem>(cell, new MenuItem(N3phele.n3pheleResource.uploadIcon(), "File Upload", null))); flow.add(header);//from w ww . j a v a 2 s . c o m quitWidget = new PushButton(new Image(N3phele.n3pheleResource.dialog_close()), new ClickHandler() { @Override public void onClick(ClickEvent event) { cancelled = true; S3UploadPanel.this.uploadPopup.hide(); } }); quitWidget.setWidth(N3phele.n3pheleResource.dialog_close().getWidth() + 4 + "px"); quitWidget.setHeight(N3phele.n3pheleResource.dialog_close().getHeight() + 4 + "px"); header.add(quitWidget); header.setCellHorizontalAlignment(quitWidget, HorizontalPanel.ALIGN_RIGHT); header.setCellVerticalAlignment(quitWidget, HorizontalPanel.ALIGN_TOP); this.setEncoding(FormPanel.ENCODING_MULTIPART); this.setMethod(FormPanel.METHOD_POST); key = new Hidden("key"); flow.add(key); awsAccessKeyId = new Hidden("AWSAccessKeyId"); flow.add(awsAccessKeyId); acl = new Hidden("acl", "private"); flow.add(acl); success_action = new Hidden("success_action_status", "201"); flow.add(success_action); policy = new Hidden("policy"); flow.add(policy); signature = new Hidden("signature"); flow.add(signature); contentType = new Hidden("Content-Type"); flow.add(contentType); table = new FlexTable(); flow.add(table); table.setWidth("490px"); fileUpload = new FileUpload(); fileUpload.setName("file"); fileUpload.setWidth("100%"); fileUpload.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { filename.setText(getFilename(fileUpload.getFilename())); upload.setEnabled(fileUpload.getFilename() != null && fileUpload.getFilename().length() > 0); } }); InlineHTML step1 = new InlineHTML("Step 1:"); step1.setStyleName(N3phele.n3pheleResource.css().repoContentElementName()); table.setWidget(0, 0, step1); InlineHTML step1Text = new InlineHTML("Choose file to upload"); step1Text.setStyleName(N3phele.n3pheleResource.css().repoContentElementName()); table.setWidget(0, 1, step1Text); table.setWidget(0, 2, fileUpload); InlineHTML step2 = new InlineHTML("Step 2:"); step2.setStyleName(N3phele.n3pheleResource.css().repoContentElementName()); table.setWidget(1, 0, step2); InlineHTML step2Text = new InlineHTML("Set Destination"); step2Text.setStyleName(N3phele.n3pheleResource.css().repoContentElementName()); table.setWidget(1, 1, step2Text); destination = new HTML("/"); table.setWidget(1, 2, destination); destination.setStyleName(N3phele.n3pheleResource.css().repoContentUploadPath()); filename = new TextBox(); table.setWidget(1, 3, filename); upload = new Button("upload"); upload.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { canonicalName = path; if (path == null || path.length() == 0) { canonicalName = filename.getText().trim(); } else { canonicalName = path + filename.getText().trim(); ; } if (activity != null) { upload.setEnabled(false); activity.getSignature(canonicalName); } } }); table.setWidget(2, 3, upload); this.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { GWT.log("submit ..." + event.toString()); } }); this.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { cancelled = false; S3UploadPanel.this.uploadPopup.hide(); activity.uploadComplete(canonicalName); } }); flow.add(upload); table.getFlexCellFormatter().setColSpan(0, 2, 2); table.getFlexCellFormatter().setWidth(0, 0, "10%"); table.getFlexCellFormatter().setWidth(0, 2, "70%"); // table.getFlexCellFormatter().setWidth(1, 2, "200px"); table.getFlexCellFormatter().setWidth(1, 3, "30%"); }