List of usage examples for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART
String ENCODING_MULTIPART
To view the source code for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART.
Click Source Link
From source file:org.eclipse.che.ide.ext.git.ssh.client.upload.UploadSshKeyViewImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override public void submit() { uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.submit(); }
From source file:org.eclipse.che.ide.ext.ssh.client.upload.UploadSshKeyPresenter.java
License:Open Source License
@Override public void onUploadClicked() { String host = view.getHost(); if (host.isEmpty()) { view.setMessage(constant.hostValidationError()); return;/*from ww w .ja v a 2 s .com*/ } view.setEncoding(FormPanel.ENCODING_MULTIPART); view.setAction(restContext + "/ssh"); view.submit(); }
From source file:org.eclipse.che.ide.projectimport.local.LocalZipImporterPagePresenter.java
License:Open Source License
private void importProject() { final String projectName = view.getProjectName(); projectNotificationSubscriber.subscribe(projectName); view.setEncoding(FormPanel.ENCODING_MULTIPART); view.setAction(appContext.getDevMachine().getWsAgentBaseUrl() + "/project/" + workspaceId + "/upload/zipproject/" + projectName + "?force=false"); view.submit();/* w w w .ja va 2 s . co m*/ showProcessing(true); }
From source file:org.eclipse.che.ide.upload.file.UploadFilePresenter.java
License:Open Source License
/** {@inheritDoc} */ @Override/* w w w . j a v a 2 s . co m*/ public void onUploadClicked() { view.setEncoding(FormPanel.ENCODING_MULTIPART); view.setAction(appContext.getDevMachine().getWsAgentBaseUrl() + "/project/uploadfile" + ((HasStorablePath) getResourceBasedNode()).getStorablePath()); view.submit(); }
From source file:org.eclipse.che.ide.upload.folder.UploadFolderFromZipPresenter.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from ww w .j a v a 2 s . c o m*/ public void onUploadClicked() { view.setLoaderVisibility(true); view.setEncoding(FormPanel.ENCODING_MULTIPART); view.setAction(appContext.getDevMachine().getWsAgentBaseUrl() + "/project/upload/zipfolder/" + ((HasStorablePath) getResourceBasedNode()).getStorablePath()); view.submit(); }
From source file:org.eclipse.kura.web.client.ui.Device.CommandTabUi.java
License:Open Source License
public CommandTabUi() { initWidget(uiBinder.createAndBindUi(this)); this.formExecute.clear(); this.formExecute.setFocus(true); this.formExecute.setName("command"); this.formExecute.addKeyDownHandler(new KeyDownHandler() { @Override/*from ww w.j a v a 2s. co m*/ public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { CommandTabUi.this.formPassword.setFocus(true); } } }); this.xsrfTokenField.setID("xsrfToken"); this.xsrfTokenField.setName("xsrfToken"); this.xsrfTokenField.setValue(""); this.formPassword.setText(null); this.formPassword.setName("password"); this.formPassword.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { CommandTabUi.this.execute.setFocus(true); } } }); this.docPath.setName("file"); display(MSGS.deviceCommandNoOutput()); this.reset.setText(MSGS.reset()); this.reset.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CommandTabUi.this.commandForm.reset(); CommandTabUi.this.formExecute.setFocus(true); display(MSGS.deviceCommandNoOutput()); } }); this.execute.setText(MSGS.deviceCommandExecute()); this.execute.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CommandTabUi.this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { CommandTabUi.this.xsrfTokenField.setValue(token.getToken()); CommandTabUi.this.commandForm.submit(); CommandTabUi.this.formExecute.setFocus(true); } }); // http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/FileUpload.html } }); this.commandForm.setEncoding(FormPanel.ENCODING_MULTIPART); this.commandForm.setMethod(FormPanel.METHOD_POST); this.commandForm.setAction(SERVLET_URL); this.commandForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { String result = event.getResults(); if (result.contains("HTTP ERROR")) { display(MSGS.fileUploadFailure()); } else { EntryClassUi.showWaitModal(); CommandTabUi.this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() { @Override public void onFailure(Throwable ex) { EntryClassUi.hideWaitModal(); FailureHandler.handle(ex); } @Override public void onSuccess(GwtXSRFToken token) { CommandTabUi.this.gwtDeviceService.executeCommand(token, CommandTabUi.this.formExecute.getText(), CommandTabUi.this.formPassword.getText(), new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { if (caught.getLocalizedMessage() .equals(GwtKuraErrorCode.SERVICE_NOT_ENABLED.toString())) { display(MSGS.error() + "\n" + MSGS.commandServiceNotEnabled()); } else if (caught.getLocalizedMessage() .equals(GwtKuraErrorCode.ILLEGAL_ARGUMENT.toString())) { display(MSGS.error() + "\n" + MSGS.commandPasswordNotCorrect()); } else { display(MSGS.error() + "\n" + caught.getLocalizedMessage()); } EntryClassUi.hideWaitModal(); } @Override public void onSuccess(String result) { display(result); EntryClassUi.hideWaitModal(); } }); } }); } } }); }
From source file:org.eclipse.kura.web.client.ui.Packages.PackagesPanelUi.java
License:Open Source License
private void upload() { this.uploadModal.show(); // ******FILE TAB ****// this.fileLabel.setText(MSGS.fileLabel()); this.filePath.setName("uploadedFile"); this.xsrfTokenFieldFile.setID("xsrfToken"); this.xsrfTokenFieldFile.setName("xsrfToken"); this.xsrfTokenFieldFile.setValue(""); this.packagesFormFile.setAction(SERVLET_URL + "/upload"); this.packagesFormFile.setEncoding(FormPanel.ENCODING_MULTIPART); this.packagesFormFile.setMethod(FormPanel.METHOD_POST); this.packagesFormFile.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override/*from w w w . j a v a 2 s .c o m*/ public void onSubmitComplete(SubmitCompleteEvent event) { String result = event.getResults(); if (result == null || result.isEmpty()) { PackagesPanelUi.this.uploadModal.hide(); refresh(2500); } else { logger.log(Level.SEVERE, "Error uploading package!"); } } }); // ******URL TAB ****// this.formUrl.setName("packageUrl"); this.xsrfTokenFieldUrl.setID("xsrfToken"); this.xsrfTokenFieldUrl.setName("xsrfToken"); this.xsrfTokenFieldUrl.setValue(""); this.packagesFormUrl.setAction(SERVLET_URL + "/url"); this.packagesFormUrl.setMethod(FormPanel.METHOD_POST); this.packagesFormUrl.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { String result = event.getResults(); if (result == null || result.isEmpty()) { PackagesPanelUi.this.uploadModal.hide(); refresh(2500); } else { String errMsg = result; int startIdx = result.indexOf("<pre>"); int endIndex = result.indexOf("</pre>"); if (startIdx != -1 && endIndex != -1) { errMsg = result.substring(startIdx + 5, endIndex); } logger.log(Level.SEVERE, MSGS.error() + ": " + MSGS.fileDownloadFailure() + ": " + errMsg); } } }); }
From source file:org.eclipse.kura.web.client.ui.Settings.SnapshotsTabUi.java
License:Open Source License
private void uploadAndApply() { this.uploadModal.show(); this.uploadModal.setTitle(MSGS.upload()); this.snapshotsForm.setEncoding(FormPanel.ENCODING_MULTIPART); this.snapshotsForm.setMethod(FormPanel.METHOD_POST); this.snapshotsForm.setAction(SERVLET_URL); this.filePath.setName("uploadedFile"); this.xsrfTokenField.setID("xsrfToken"); this.xsrfTokenField.setName("xsrfToken"); this.xsrfTokenField.setValue(""); }
From source file:org.eurekastreams.web.client.ui.common.form.elements.avatar.AvatarUploadFormElement.java
License:Apache License
/** * Create an avatar upload form element. * /*from ww w . ja v a2 s . com*/ * @param label * the label of the element. * @param desc * the description. * @param servletPath * the path to hit to upload the image * @param inProcessor * the processor. * @param inStrategy * the strategy. */ public AvatarUploadFormElement(final String label, final String desc, final String servletPath, final ActionProcessor inProcessor, final ImageUploadStrategy inStrategy) { description = desc; strategy = inStrategy; Boolean resizeable = strategy.isResizable(); errorBox = new FlowPanel(); errorBox.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox()); errorBox.add(new Label("There was an error uploading your image. Please be sure " + "that your photo is under 4MB and is a PNG, JPG, or GIF.")); errorBox.setVisible(false); this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formAvatarUpload()); this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formElement()); processor = inProcessor; // AvatarEntity Entity = inEntity; uploadForm.setAction(servletPath); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); Label photoLabel = new Label(label); photoLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel()); panel.add(photoLabel); FlowPanel avatarModificationPanel = new FlowPanel(); avatarModificationPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarModificationPanel()); avatarContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarContainer()); avatarModificationPanel.add(avatarContainer); FlowPanel photoButtonPanel = new FlowPanel(); photoButtonPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formPhotoButtonPanel()); if (resizeable) { editButton = new Anchor("Resize"); editButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formResizeButton()); editButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton()); photoButtonPanel.add(editButton); } deleteButton = new Anchor("Delete"); deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formDeleteButton()); deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton()); photoButtonPanel.add(deleteButton); avatarModificationPanel.add(photoButtonPanel); panel.add(avatarModificationPanel); FlowPanel uploadPanel = new FlowPanel(); uploadPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formUploadPanel()); uploadPanel.add(errorBox); // Wrapping the FileUpload because otherwise IE7 shifts it way // to the right. I couldn't figure out why, // but for whatever reason, this works. FlowPanel fileUploadWrapper = new FlowPanel(); FileUpload upload = new FileUpload(); upload.setName("imageUploadFormElement"); upload.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formAvatarUpload()); fileUploadWrapper.add(upload); uploadPanel.add(fileUploadWrapper); uploadPanel.add(new Label(description)); Anchor submitButton = new Anchor(""); submitButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formUploadButton()); submitButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton()); uploadPanel.add(submitButton); hiddenImage = new Image(); hiddenImage.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarHiddenOriginal()); uploadPanel.add(hiddenImage); panel.add(uploadPanel); submitButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { uploadForm.submit(); } }); uploadForm.setWidget(panel); this.add(uploadForm); uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(final SubmitCompleteEvent ev) { String result = ev.getResults().replaceAll("\\<.*?\\>", ""); final boolean fail = "fail".equals(result); errorBox.setVisible(fail); if (!fail) { String[] results = result.split(","); if (results.length >= 4) { strategy.setX(Integer.parseInt(results[1])); strategy.setY(Integer.parseInt(results[2])); strategy.setCropSize(Integer.parseInt(results[3])); } onAvatarIdChanged(results[0], strategy.getEntityType() == EntityType.PERSON); } } }); if (editButton != null) { editButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent inArg0) { // Since the size of the image is required before we can correctly show the // resize dialog, this method determines the avatar url and sets image url. // The load event of that image being loaded will kick off the resize modal. AvatarUrlGenerator urlGenerator = new AvatarUrlGenerator(EntityType.PERSON); hiddenImage.setUrl(urlGenerator.getOriginalAvatarUrl(avatarId)); } }); hiddenImage.addLoadHandler(new LoadHandler() { public void onLoad(final LoadEvent inEvent) { imageCropDialog = new ImageCropContent(strategy, processor, avatarId, new Command() { public void execute() { onAvatarIdChanged(strategy.getImageId(), strategy.getEntityType() == EntityType.PERSON); } }, hiddenImage.getWidth() + "px", hiddenImage.getHeight() + "px"); Dialog dialog = new Dialog(imageCropDialog); dialog.showCentered(); } }); } if (strategy.getImageType().equals(ImageType.BANNER)) { onAvatarIdChanged(strategy.getImageId(), strategy.getId().equals(strategy.getImageEntityId()), true, strategy.getEntityType() == EntityType.PERSON); } else { onAvatarIdChanged(strategy.getImageId(), strategy.getEntityType() == EntityType.PERSON); } deleteButton.addClickHandler(new ClickHandler() { @SuppressWarnings("unchecked") public void onClick(final ClickEvent event) { if (new WidgetJSNIFacadeImpl().confirm("Are you sure you want to delete your current photo?")) { strategy.getDeleteAction().delete(strategy.getDeleteParam()); } } }); Session.getInstance().getEventBus().addObserver(ClearUploadedImageEvent.class, new Observer<ClearUploadedImageEvent>() { public void update(final ClearUploadedImageEvent event) { if (event.getImageType().equals(strategy.getImageType()) && event.getEntityType().equals(strategy.getEntityType())) { if (event.getImageType().equals(ImageType.BANNER)) { onAvatarIdChanged(event.getEntity().getBannerId(), strategy.getId().equals(event.getEntity().getBannerEntityId()), true, strategy.getEntityType() == EntityType.PERSON); } else { onAvatarIdChanged(null, strategy.getEntityType() == EntityType.PERSON); } } } }); }
From source file:org.footware.client.dialogs.UploadTrackBox.java
License:Apache License
public UploadTrackBox() { setText("Upload a Track"); Grid g = new Grid(7, 2); setAutoHideEnabled(true);/*ww w .j a v a 2s .com*/ setGlassEnabled(true); // trackName = new TextBox(); // trackName.setName(NAME); // g.setWidget(0, 0, new HTML("Name")); // g.setWidget(0, 1, trackName); privacy = new ListBox(); privacy.setName(PRIVACY); privacy.addItem("Public", PRIVACY_PUBLIC); privacy.addItem("Private", PRIVACY_PRIVATE); g.setWidget(1, 0, new HTML("Privacy")); g.setWidget(1, 1, privacy); enableComments = new CheckBox(); enableComments.setName(COMMENTS); g.setWidget(2, 0, new HTML("Enable comments")); g.setWidget(2, 1, enableComments); notes = new TextArea(); notes.setName(NOTES); notes.setSize("200px", "50px"); g.setWidget(3, 0, new HTML("Notes")); g.setWidget(3, 1, notes); email = new TextBox(); email.setVisible(false); g.setWidget(6, 0, email); file = new FileUpload(); file.setName(FILE); g.setWidget(4, 0, new HTML("Select File")); g.setWidget(4, 1, file); Button upload = new Button("Upload"); upload.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { doUpload(); hide(); } }); Button close = new Button("Cancel"); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); g.setWidget(5, 0, upload); g.setWidget(5, 1, close); form = new FormPanel(); // TODO implement httpservlet to accept file. form.setAction("/footware/trackUpload"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); form.add(g); add(form); }