@Override public void onSubmitComplete(SubmitCompleteEvent event) { sending = false; String result = event.getResults(); htmlMessage.setHTML(""); if (Strings.isNullOrEmpty(result)) { htmlMessage.setHTML("アップロード中にエラーが発生しました。頻繁に発生する場合は管理人にお知らせ下さい。"); } else if (result.contains(Constant.ICON_UPLOAD_RESPONSE_OK)) { htmlMessage.setHTML("アイコンのアップロードに成功しました。反映まで若干時間がかかります。"); UserData.get().load(); } else if (result.contains(Constant.ICON_UPLOAD_RESPONSE_FAILED_TO_DETECT_IMAGE_FILE_TYPE)) { htmlMessage.setHTML("画像ファイルを認識できませんでした。正しい画像ファイルであることを確認して再度アップロードしてください。"); } else if (result.contains(Constant.ICON_UPLOAD_RESPONSE_FAILED_TO_PARSE_REQUEST)) { htmlMessage.setHTML("送信されたデータが不正です。ファイルサイズ等を確認して再度アップロードしてください。"); } else if (result.contains(Constant.ICON_UPLOAD_RESPONSE_IMAGE_FILE_NAME_FORMAT_ERROR)) { htmlMessage.setHTML("画像ファイルのファイル名に'.'が含まれていません。正しいファイルを再度アップロードしてください。"); } else if (result.contains(Constant.ICON_UPLOAD_RESPONSE_REQUEST_FORMAT_ERROR)) { htmlMessage.setHTML("不正なパラメータが送信されました。正規のインタフェースから再度操作をしてください"); } else { htmlMessage.setHTML("原因不明のエラーが発生しました。管理者にご連絡ください。"); logger.warning("アイコンのアップロードに失敗しました。\n" + result); } buttonSubmit.setEnabled(true); }
private void initIFrame() { final Frame iframe = new Frame("javascript:\"\""); iframe.getElement().setAttribute("name", id); iframe.getElement().setAttribute("style", "position:absolute;width:0;height:0;border:0"); iframe.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { String content = IFrameElement.as(iframe.getElement()).getContentDocument().getBody().getInnerHTML(); if (content != null && !"".equals(content)) formPanel.fireEvent(new SubmitCompleteEvent(content) { }); } }); flowPanel.add(iframe); }
private void onFileUploaded(SubmitCompleteEvent event) { templateUploadDisplay.stopLoadingAnimation(); FileUploadResponse response = parseResponse(event.getResults()); if (response.getDone()) { fireSuccessfulFileUpload(response.getMessage()); } else { fireFailedFileUpload(response.getMessage()); } }
public static SubmitCompleteHandler createSubmitCompleteHandler(final UIObject ui, final EventListenerGVO ev, final List<InputVariableGVO> inputVariables) { SubmitCompleteHandler submitCompleteHandler = new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if ((uuId != null) && (uuId.indexOf("=") > 0)) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } FormPanel fp = (FormPanel) ui; if (fp instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) fp; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); if (success) { DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(ui, QAMLConstants.EVENT_ONFINISH, ev, inputVariables); } else { Label fileNameLabel = new Label("Uploading unsuccessfull.");// (Hyperlink) // gridPanel.getWidget(1, // 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); gridPanel.add(fileNameLabel); } } } } } }; return submitCompleteHandler; }
/** * @see com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler#onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) */ @Override public void onSubmitComplete(SubmitCompleteEvent event) { dialog.destroy(); AddResult results = AddResult.fromResult(event.getResults()); if (results.isError()) { if (results.getError() != null) { notificationService.completeProgressNotification( notification.getUuid(), i18n.format("add-deployment-submit.error-adding-deployment"), //$NON-NLS-1$ results.getError()); } else { notificationService.completeProgressNotification( notification.getUuid(), i18n.format("add-deployment-submit.error-adding-deployment"), //$NON-NLS-1$ i18n.format("add-deployment-submit.error-adding-deployment-msg")); //$NON-NLS-1$ } } else if (results.isBatch()) { String message = i18n.format("add-deployment-submit.upload-complete-msg", results.getBatchNumSuccess(), results.getBatchNumFailed()); //$NON-NLS-1$ notificationService.completeProgressNotification( notification.getUuid(), i18n.format("add-deployment-submit.upload-complete"), //$NON-NLS-1$ message); } else { Widget ty = new InlineLabel(i18n.format("add-deployment-submit.thanks")); //$NON-NLS-1$ TransitionAnchor<DeploymentDetailsPage> clickHere = toDetailsFactory.get("uuid", results.getUuid()); //$NON-NLS-1$ clickHere.setText(i18n.format("add-deployment-submit.click-here-1")); //$NON-NLS-1$ Widget postAmble = new InlineLabel(i18n.format("add-deployment-submit.click-here-2")); //$NON-NLS-1$ FlowPanel body = new FlowPanel(); body.add(ty); body.add(clickHere); body.add(postAmble); notificationService.completeProgressNotification( notification.getUuid(), i18n.format("add-deployment-submit.successfully-added"), //$NON-NLS-1$ body); } }
public void onSubmitComplete(SubmitCompleteEvent event) { updateStatusTimer.cancel(); onSubmitComplete = true; serverResponse = event.getResults(); if (serverResponse != null) { serverResponse = serverResponse.replaceFirst(".*" + TAG_MSG_START + "([\\s\\S]*?)" + TAG_MSG_END + ".*", "$1"); serverResponse = serverResponse.replace(TAG_MSG_LT, "<").replace(TAG_MSG_GT, ">").replace("<", "<").replaceAll(">", ">"); } log("onSubmitComplete: " + serverResponse, null); try { // Parse the xml and extract serverInfo Document doc = XMLParser.parse(serverResponse); serverInfo.setMessage(Utils.getXmlNodeValue(doc, TAG_MESSAGE)); serverInfo.setField(Utils.getXmlNodeValue(doc, TAG_FIELD)); NodeList list = doc.getElementsByTagName(TAG_FILE); for (int i = 0; i < list.getLength(); i++) { UploadedInfo info = new UploadedInfo(); info.setName(doc.getElementsByTagName(TAG_NAME).item(i).getFirstChild().getNodeValue()); info.setCtype(doc.getElementsByTagName(TAG_CTYPE).item(i).getFirstChild().getNodeValue()); String size = doc.getElementsByTagName(TAG_SIZE).item(i).getFirstChild().getNodeValue(); if (size != null) { info.setSize(Integer.parseInt(size)); } serverInfo.add(info); } // If the server response is a valid xml parseAjaxResponse(serverResponse); } catch (Exception e) { log("onSubmitComplete exception parsing response: ", e); // Otherwise force an ajax request so as we have not to wait to the timer schedule updateStatusTimer.run(); } }
private SubmitCompleteHandler fileUploadCompleteHandler() { return new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { String fn = fileUpload.getFilename(); // chrome workaround final String fileName = fn.replace("C:\\fakepath\\", ""); String res = event.getResults(); try { JSONValue js = JSONParser.parseStrict(res); JSONObject obj = js.isObject(); if (obj.get("jobEdit") != null && obj.get("jobEdit").isString() != null) { String val = obj.get("jobEdit").isString().stringValue(); job = new String(org.ow2.proactive_grid_cloud_portal.common.shared.Base64Utils.fromBase64(val)); // if the job has an EXECUTION_CALENDAR Generic Information defined, the startAccordingToPlanningRadioButton becomes visible, and invisible otherwise setStartAccordingPlanningRadioButtonState(job); variables = readVars(job); } else { GWT.log("JSON parse ERROR"); displayErrorMessage(res); //Force disable check&submit buttons to prevent confusion if a valid job was uploaded first but not submitted setEnabledStartAtPart(false); startAccordingPlanningRadioButton.setVisible(false); return; } } catch (JSONException t) { GWT.log("JSON parse ERROR"); displayErrorMessage(res); //Force disable check&submit buttons to prevent confusion if a valid job was uploaded first but not submitted setEnabledStartAtPart(false); startAccordingPlanningRadioButton.setVisible(false); return; } redrawVariables(); } }; }
/** * Instantiates a new RecordPanel. */ public RecordPanel(AvroWidgetsConfig config, boolean showCaption, String title, HasErrorMessage hasErrorMessage, boolean optional, boolean readOnly) { this.showCaption = showCaption; this.optional = optional; this.readOnly = readOnly; this.hasErrorMessage = hasErrorMessage; FlexTable table = new FlexTable(); table.setWidth("100%"); if (config == null) { config = new AvroWidgetsConfig.Builder().createConfig(); } recordFieldWidget = new RecordFieldWidget(config, readOnly); if (showCaption) { recordCaption = new CaptionPanel(); setTitle(title); recordCaption.setContentWidget(recordFieldWidget); table.setWidget(0, 0, recordCaption); } else { table.setWidget(0, 0, recordFieldWidget); } recordFileUpload = new FileUploadForm(); recordFileUpload.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { loadRecordFromFile(); } }); recordFileUpload.addChangeHandler(this); recordFileItemName = recordFileUpload.getFileItemName(); uploadButton = new Button(Utils.constants.upload(), new ClickHandler() { @Override public void onClick(ClickEvent event) { recordFileUpload.submit(); } }); uploadButton.addStyleName(Utils.kaaAdminStyle.bAppButtonSmall()); uploadButton.setEnabled(false); uploadTable = new FlexTable(); Label uploadLabel = new Label(Utils.constants.uploadFromFile()); uploadTable.setWidget(0, 0, uploadLabel); uploadTable.setWidget(0, 1, recordFileUpload); uploadTable.setWidget(0, 2, uploadButton); uploadTable.getFlexCellFormatter() .setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); uploadTable.getFlexCellFormatter() .setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_MIDDLE); table.setWidget(1, 0, uploadTable); setWidget(table); setUploadVisible(!readOnly); formDataLoader = new DefaultFormDataLoader(); }
@UiHandler("answerForm") public void onFileFormSubmitComplete(SubmitCompleteEvent event) { this.fireEvent(new FormSubmitCompleteEvent(this, event.getResults())); }