List of usage examples for com.google.gwt.user.client.ui Hidden setName
public void setName(String name)
From source file:com.audata.client.widgets.UploadPanel.java
License:Open Source License
public UploadPanel() { VerticalPanel main = new VerticalPanel(); this.file = new FileUpload(); this.file.setName("document"); this.recid = new Hidden(); this.recid.setName("recid"); Hidden method = new Hidden(); method.setName("method"); method.setValue("put"); main.add(this.recid); main.add(method);//from ww w. j a v a 2 s .c om main.add(this.file); this.add(main); }
From source file:com.brainz.wokhei.client.home.OrderBrowserModulePart.java
private void setupPayPalForm() { boolean isSandbox = getModule().isSandBox(); //fill-up paypal form if (isSandbox) { _paypalForm.setAction(PayPalStrings.PAYPAL_SANDBOX_ACTION.getString()); } else {//from w w w . ja va 2s . c o m _paypalForm.setAction(PayPalStrings.PAYPAL_ACTION.getString()); } // _paypalForm.setEncoding(FormPanel.ENCODING_MULTIPART); _paypalForm.setMethod(FormPanel.METHOD_POST); VerticalPanel formPlaceHolder = new VerticalPanel(); //setup input element for seller Hidden sellerInfo = new Hidden(); sellerInfo.setName(PayPalStrings.PAYPAL_BUSINESS_NAME.getString()); if (isSandbox) { sellerInfo.setValue(PayPalStrings.PAYPAL_SANDBOX_BUSINESS_VALUE.getString()); } else { sellerInfo.setValue(PayPalStrings.PAYPAL_BUSINESS_VALUE.getString()); } formPlaceHolder.add(sellerInfo); //specify buy now button Hidden cmdInfo = new Hidden(); cmdInfo.setName(PayPalStrings.PAYPAL_CMD_NAME.getString()); cmdInfo.setValue(PayPalStrings.PAYPAL_CMD_VALUE.getString()); formPlaceHolder.add(cmdInfo); //specify purchase details Hidden itemNameInfo = new Hidden(); Hidden amountInfo = new Hidden(); Hidden taxInfo = new Hidden(); Hidden currencyInfo = new Hidden(); Hidden notifyInfo = new Hidden(); Hidden returnInfo = new Hidden(); Hidden custom = new Hidden(); Hidden locale = new Hidden(); //valuToPay sara il lordo(gross) da pagare Float valueToPay = TransactionType.BUYING_LOGO.getGrossToPay(_currentOrder.getTotalPaidTips()); itemNameInfo.setName(PayPalStrings.PAYPAL_ITEMNAME_NAME.getString()); itemNameInfo.setValue(TransactionType.BUYING_LOGO.getDescription()); formPlaceHolder.add(itemNameInfo); amountInfo.setName(PayPalStrings.PAYPAL_AMOUNT_NAME.getString()); amountInfo.setValue(TransactionType.BUYING_LOGO.getNet(valueToPay).toString()); formPlaceHolder.add(amountInfo); taxInfo.setName(PayPalStrings.PAYPAL_TAX_NAME.getString()); taxInfo.setValue(TransactionType.BUYING_LOGO.getTax(valueToPay).toString()); formPlaceHolder.add(taxInfo); currencyInfo.setName(PayPalStrings.PAYPAL_CURRENCY_NAME.getString()); currencyInfo.setValue(PayPalStrings.PAYPAL_CURRENCY_VALUE.getString()); formPlaceHolder.add(currencyInfo); notifyInfo.setName(PayPalStrings.PAYPAL_NOTIFY_URL_NAME.getString()); if (isSandbox) { notifyInfo.setValue(PayPalStrings.PAYPAL_NOTIFY_URL_SANDBOX_VALUE.getString()); } else { notifyInfo.setValue(PayPalStrings.PAYPAL_NOTIFY_URL_VALUE.getString()); } formPlaceHolder.add(notifyInfo); returnInfo.setName(PayPalStrings.PAYPAL_RETURN_NAME.getString()); returnInfo.setValue(PayPalStrings.PAYPAL_RETURN_VALUE.getString()); custom.setName(PayPalStrings.PAYPAL_CUSTOM_NAME.getString()); custom.setValue(_currentOrder.getId().toString() + ";" + TransactionType.BUYING_LOGO.toString()); formPlaceHolder.add(custom); locale.setName(PayPalStrings.PAYPAL_LOCALE_NAME.getString()); locale.setValue(PayPalStrings.PAYPAL_LOCALE_NAME.getString()); formPlaceHolder.add(locale); formPlaceHolder.add(_buyNowImage); _paypalForm.add(formPlaceHolder); _paypalForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { //nothing to handle? whoo-yeah! AVP sucks dick } }); }
From source file:com.ephesoft.gxt.batchinstance.client.presenter.TroubleshootPresenter.java
License:Open Source License
public void addSelectedCheckboxToContainer() { if (null != hiddenFieldsContainer) { List<TroubleshootDTO> selectedCheckboxList = view.getSelectedArtifacts(); if (!CollectionUtil.isEmpty(selectedCheckboxList)) { Hidden selectedCheckbox = null; for (TroubleshootDTO checkbox : selectedCheckboxList) { selectedCheckbox = new Hidden(checkbox.getName()); selectedCheckbox.setName(checkbox.getName()); selectedCheckbox.setValue("true"); hiddenFieldsContainer.add(selectedCheckbox); }//from ww w.j av a 2 s .c o m } } }
From source file:com.ephesoft.gxt.batchinstance.client.view.TroubleshootView.java
License:Open Source License
public void addSelectedCheckboxToForm() { if (null != hiddenFieldsContainer) { final List<TroubleshootDTO> selectedCheckboxList = tree.getCheckedSelection(); if (CollectionUtil.isEmpty(selectedCheckboxList)) { DialogUtil.showMessageDialog( LocaleDictionary.getConstantValue(BatchInstanceConstants.INFO_TITLE), LocaleDictionary .getMessageValue(BatchInstanceMessages.NO_ARTIFACTS_SELECTED_FOR_TROUBLESHOOTING), DialogIcon.ERROR);/*w w w . java 2 s .co m*/ } else { Hidden selectedCheckbox = null; for (final TroubleshootDTO checkbox : selectedCheckboxList) { selectedCheckbox = new Hidden(checkbox.getName()); selectedCheckbox.setName(checkbox.getName()); selectedCheckbox.setValue("true"); hiddenFieldsContainer.add(selectedCheckbox); } } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { HorizontalPanel uiObject = null;// ww w . j a v a 2s .c o m final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); final Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); final FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); fileUploadComponent.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String filename = fileUploadComponent.getFilename(); boolean enabled = (filename != null) && (filename.length() > 0); uploadButtonComponent.setEnabled(enabled); } }); Hidden appId = new Hidden(); final String appID = ClientApplicationContext.getInstance().getWindowSession(); appId.setName("APPUUID=" + appID); Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label clearLabel = new Label("Clear"); clearLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(clearLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(clearLabel.getElement(), "cursor", "hand"); clearLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); clearLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); init(fileUpload, uploadButton); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, clearLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); init(fileUploadComponent, uploadButtonComponent); } } return uiObject; }
From source file:com.qualogy.qafe.mgwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String owner, String uuid, String parent, String context, AbstractActivity activity) {//from w ww .j av a2 s . co m HorizontalPanel uiObject = null; final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); Hidden appId = new Hidden(); appId.setName("APPUUID=" + uuid); final String appID = uuid; Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label removeLabel = new Label("Remove"); removeLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(removeLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(removeLabel.getElement(), "cursor", "hand"); removeLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); removeLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, removeLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); } } return uiObject; }
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 va 2 s .com*/ */ 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.LabCommunication.java
License:Open Source License
/** * Sends a file asynchronously. Upon doing the async request to the server, it will be internally stored * in the async requests manager, and polling will be done until the response is available. Then, the * specified callback will be notified with the result. *//*from w w w . j ava 2 s .c o m*/ @Override public void sendAsyncFile(final 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()); final Hidden isAsyncElement = new Hidden(); isAsyncElement.setName(LabCommunication.FILE_IS_ASYNC_ATTR); isAsyncElement.setValue("true"); // 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(); // resultMessage will be a string such as SUCCESS@34KJ2341KJ if (GWT.isScript() && resultMessage == null) { this.reportFail(callback); } else { this.processResultMessage(callback, resultMessage); } } private void processResultMessage(IResponseCommandCallback commandCallback, String resultMessage) { final ResponseCommand parsedRequestIdCommand; try { // TODO: This should be improved. if (!resultMessage.toLowerCase().startsWith("success@")) throw new SerializationException("Async send file response does not start with success@"); final String reslt = resultMessage.substring("success@".length()); System.out.println("[DBG]: AsyncSendFile returned: " + reslt); parsedRequestIdCommand = new ResponseCommand(reslt); } catch (final SerializationException e) { commandCallback.onFailure(e); return; } // } catch (final SessionNotFoundException e) { // commandCallback.onFailure(e); // return; // } catch (final WlServerException e) { // commandCallback.onFailure(e); // return; // } // We now have the request id of our asynchronous send_file request. // We will need to register the request with the asynchronous manager // so that it automatically polls and notifies us when the request finishes. final String requestID = parsedRequestIdCommand.getCommandString(); AsyncRequestsManager asyncReqMngr = LabCommunication.this.asyncRequestsManagers.get(sessionId); // TODO: Consider some better way of handling the managers. if (asyncReqMngr == null) asyncReqMngr = new AsyncRequestsManager(LabCommunication.this, sessionId, (ILabSerializer) LabCommunication.this.serializer); asyncReqMngr.registerAsyncRequest(requestID, commandCallback); } private void reportFail(final IResponseCommandCallback callback) { GWT.log("reportFail could not async send the file", null); callback.onFailure(new CommException("Couldn't async send the file")); } }); // Submit uploadStructure.getFormPanel().submit(); }
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./* w w w . ja va2 s . c o 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: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 ww .j a va 2 s . co 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(); } }); }