List of usage examples for com.google.gwt.user.client.ui FormPanel FormPanel
public FormPanel()
From source file:edu.ucla.loni.client.ServerLibraryManager.java
License:Open Source License
/** * Sets workarea to an import form/*from www . j a v a 2 s . c o 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); }
From source file:es.deusto.weblab.client.lab.comm.UploadStructure.java
License:Open Source License
public UploadStructure() { this.formPanel = new FormPanel(); this.fileUploader = new FileUpload(); this.configurePanel(); this.setWidth("100%"); this.setElement(this.panel.getElement()); }
From source file:fr.gael.dhus.gwt.client.page.UploadPage.java
License:Open Source License
private static void init() { showUpload();/*from ww w.ja va 2 s . c o 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);// www . java 2 s.c om 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);//w ww . j a v a2s .c om 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.sendmailsample.client.SendMailSample.java
License:Apache License
public void onModuleLoad() { final FlexTable grid = new FlexTable(); grid.setText(1, 0, "From:"); grid.setWidget(1, 1, new TextBox() { {//from ww w. ja v a 2s . com setName("from"); } }); grid.setText(2, 0, "To:"); grid.setWidget(2, 1, new TextBox() { { setName("to"); } }); grid.setText(3, 0, "Subject:"); grid.setWidget(3, 1, new TextBox() { { setName("subject"); } }); grid.setText(4, 0, "Body:"); grid.setWidget(4, 1, new TextArea() { { setName("body"); } }); Button send = new Button("Send it"); FormPanel form = new FormPanel() { public void add(Widget w) { grid.setWidget(grid.getRowCount(), 1, w); } { super.add(grid); } }; SingleUploader uploader = new SingleUploader(FileInputType.LABEL, new ModalUploadStatus(), send, form); uploader.setServletPath("send.mail"); RootPanel.get().add(uploader); grid.setText(5, 0, "Attachment:"); uploader.addOnFinishUploadHandler(new OnFinishUploaderHandler() { public void onFinish(IUploader uploader) { if (uploader.getStatus() == Status.SUCCESS) { Window.alert("Server response: \n" + uploader.getServerResponse()); uploader.reset(); } } }); }
From source file:ilarkesto.gwt.client.Gwt.java
License:Open Source License
public static final FormPanel createForm(Widget content) { FormPanel form = new FormPanel(); form.add(content); return form; }
From source file:net.scran24.admin.client.UserManager.java
public UserManager() { FlowPanel contents = new FlowPanel(); final FormPanel form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "uploadUserInfo"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); VerticalPanel panel = new VerticalPanel(); form.setWidget(panel);//www . j a v a 2 s .c o m final FileUpload upload = new FileUpload(); upload.setName("file"); panel.add(upload); RadioButton append = new RadioButton("mode", "Append to existing user list"); append.setFormValue("append"); final RadioButton replace = new RadioButton("mode", "Replace existing user list"); replace.setFormValue("replace"); replace.setValue(true); panel.add(append); panel.add(replace); panel.add(WidgetFactory.createButton("Upload", new ClickHandler() { @Override public void onClick(ClickEvent event) { form.submit(); } })); form.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { if (upload.getFilename().isEmpty()) { Window.alert("Please choose a .csv file containing user information to upload"); event.cancel(); } else if (replace.getValue()) if (!Window.confirm( "Doing this will delete all user information from the database and replace it with the list you are submitting. Proceed?")) event.cancel(); } }); form.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { // This is not a very robust way of detecting the status code, // but unfortunately there does not seem to be a better way of doing // this // that supports IE8 -- Ivan. // https://code.google.com/p/google-web-toolkit/issues/detail?id=7365 String result = event.getResults(); if (result.equals("OK")) Window.alert("User information uploaded."); else if (result.startsWith("ERR:")) { Window.alert("There was a problem uploading the user information: " + result.substring(4)); } else if (result.contains("401")) { LoginForm.showPopup(new Callback1<UserInfo>() { @Override public void call(UserInfo info) { form.submit(); } }); } else if (result.contains("403")) { // User is not authorised, e.g. someone has logged on as admin, // opened the user upload tab and timed out, then someone else // logged on as someone who does not have the right to // upload users. In this case, let them know and refresh the page // to either show the UI that corresponds to their set of permissions // or redirect them to another page. Window.alert("You are not authorised to upload user information."); Location.reload(); } } }); contents.add(new HTMLPanel("<h2>Staff user accounts</h2>")); contents.add(new Button("Add")); contents.add(new HTMLPanel("<h2>Respondent user accounts</h2>")); contents.add(form); initWidget(contents); }
From source file:net.scran24.common.client.UserInfoUpload.java
public UserInfoUpload(final String surveyId, final String role, final List<String> permissions, final Callback1<Option<String>> onUploadComplete) { final FormPanel form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "../staff/uploadUserInfo?surveyId=" + surveyId); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); VerticalPanel panel = new VerticalPanel(); form.setWidget(panel);/*from w w w . j a v a 2 s . c om*/ final Hidden roleField = new Hidden("role", role); panel.add(roleField); for (String perm : permissions) { final Hidden permField = new Hidden("permission", perm); panel.add(permField); } final FileUpload upload = new FileUpload(); upload.setName("file"); panel.add(upload); Button uploadButton = WidgetFactory.createButton("Upload", new ClickHandler() { @Override public void onClick(ClickEvent event) { form.submit(); } }); uploadButton.getElement().addClassName("scran24-admin-button"); panel.add(uploadButton); form.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { if (upload.getFilename().isEmpty()) { Window.alert("Please choose a .csv file containing user information to upload"); event.cancel(); } } }); form.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { // This is not a very robust way of detecting the status code, // but unfortunately there does not seem to be a better way of // doing this that supports IE8 // https://code.google.com/p/google-web-toolkit/issues/detail?id=7365 String result = event.getResults(); if (result.equals("OK")) { onUploadComplete.call(Option.<String>none()); } else if (result.startsWith("ERR:")) { onUploadComplete.call( Option.some("There was a problem uploading user information: " + result.substring(4))); } else if (result.contains("401")) { LoginForm.showPopup(new Callback1<UserInfo>() { @Override public void call(UserInfo info) { form.submit(); } }); } else if (result.contains("403")) { // User is not authorised, e.g. someone has logged on as // admin, opened the user upload tab and timed out, then someone // else logged on as someone who does not have the right to // upload users. In this case, let them know and refresh the // page to either show the UI that corresponds to their set of // permissions or redirect them to another page. onUploadComplete.call(Option.some("You are not authorised to upload user information.")); } else { onUploadComplete .call(Option.some("There was an problem uploading user information: " + result)); } } }); initWidget(form); }
From source file:nz.org.winters.appspot.acrareporter.client.ui.MappingUpload.java
License:Apache License
public MappingUpload(final LoginInfo loginInfo, String packageName, final DialogCallback callback) { this.callback = callback; form = new FormPanel(); textPackage = new TextBox(); textVersion = new TextBox(); fileUpload = new FileUpload(); vertPanel = new VerticalPanel(); initWidget(uiBinder.createAndBindUi(this)); textPackage.setText(packageName);/*from ww w . j av a2s. c om*/ form.setAction("/mappingupload"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); textId = new TextBox(); textId.setVisible(false); textId.setName("id"); vertPanel.add(textId); // Add an event handler to the form. form.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { // This event is fired just before the form is submitted. We can take // this opportunity to perform validation. String fileName = fileUpload.getFilename(); if (Utils.isEmpty(fileName)) { Window.alert(constants.mappingUploadAlertNofile()); event.cancel(); return; } if (textVersion.getText().length() == 0) { Window.alert(constants.mappingUploadAlertNoVersion()); event.cancel(); } textId.setValue(Long.toString(loginInfo.getAppUserShared().id)); AppLoadingView.getInstance().start(); } }); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { AppLoadingView.getInstance().stop(); String result = event.getResults(); int pos = result.indexOf(";\">"); if (pos >= 0) { result = result.substring(pos + 3, result.indexOf("</pre") - 1).trim(); } if (Utils.isEmpty(result) || !result.equalsIgnoreCase("OK")) { Window.alert(constants.mappingUploadAlertResponse(result)); } else callback.result(true); } }); }