本文整理汇总了Java中com.google.gwt.user.client.ui.FileUpload类的典型用法代码示例。如果您正苦于以下问题:Java FileUpload类的具体用法?Java FileUpload怎么用?Java FileUpload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileUpload类属于com.google.gwt.user.client.ui包,在下文中一共展示了FileUpload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FileInputButton
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
public FileInputButton() {
wrapper = new Span();
wrapper.addStyleName(Styles.BTN);
upload = new FileUpload();
upload.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
fireChanged();
}
});
wrapper.add(upload);
wrapper.addStyleName("btn-file");
initWidget(wrapper);
}
示例2: showDialog
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void showDialog() {
errorMessage.setText("");
fileContent = null;
fileUpload = new FileUpload();
fileUpload.setHeight("22px");
fileUpload.setWidth("100%");
fileUpload.setName("file");
fileUpload.ensureDebugId("import-from-config-ChooseFile");
addHandler(fileUpload.getElement());
fileUpload.addChangeHandler(event -> buttonImport.setEnabled(fileUpload.getFilename() != null));
uploadForm.add(fileUpload);
this.show();
}
示例3: FormatterPreferencePageViewImpl
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
@Inject
public FormatterPreferencePageViewImpl(
FormatterPreferencePageViewImplUiBinder uiBinder,
JavaLocalizationConstant localizationConstant) {
widget = uiBinder.createAndBindUi(this);
fileUpload = new FileUpload();
radioButtonGroup = new RadioButtonGroup();
targetPanel.add(radioButtonGroup);
radioButtonGroup.addButton(
localizationConstant.formatterPreferencesProjectLabel(),
localizationConstant.formatterPreferencesProjectDescription(),
null,
event -> isWorkspace = false);
radioButtonGroup.addButton(
localizationConstant.formatterPreferencesWorkspaceLabel(),
localizationConstant.formatterPreferencesWorkspaceDescription(),
null,
event -> isWorkspace = true);
radioButtonGroup.selectButton(0);
uploadForm.add(fileUpload);
importButton.setEnabled(false);
}
示例4: selectFile
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
public static void selectFile(final Callback<JavaScriptObject, String> aCallback, String aFileTypes) {
final FileUpload fu = new FileUpload();
fu.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
fu.setWidth("10px");
fu.setHeight("10px");
fu.getElement().getStyle().setLeft(-100, Style.Unit.PX);
fu.getElement().getStyle().setTop(-100, Style.Unit.PX);
fu.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
Utils.JsObject jsFu = fu.getElement().cast();
JavaScriptObject oFiles = jsFu.getJs("files");
if (oFiles != null) {
JsArray<JavaScriptObject> jsFiles = oFiles.cast();
for (int i = 0; i < jsFiles.length(); i++) {
try {
aCallback.onSuccess(jsFiles.get(i));
} catch (Exception ex) {
Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
fu.removeFromParent();
}
});
RootPanel.get().add(fu, -100, -100);
fu.click();
Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
fu.removeFromParent();
return false;
}
}, 1000 * 60 * 1);// 1 min
}
示例5: getValue
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private static String getValue(FormPanel formPanel) {
String value = null;
if (formPanel instanceof HasWidgets) {
HasWidgets hasWidgets = formPanel;
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);
value = DOM.getElementAttribute(fileUpload.getElement(), "fu-uuid");
handleSimpleValue(formPanel, value);
}
}
}
return value;
}
示例6: showDialog
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
@Override
public void showDialog() {
uploadFormVPanel.clear();
certFile = new FileUpload();
certFile.setHeight("22px");
certFile.setWidth("100%");
certFile.setName("certFile");
certFile.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
delegate.onFileNameChanged();
}
});
uploadFormVPanel.add(certFile);
this.show();
}
示例7: execute
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
public void execute() {
if (toolBarOption.addDocumentOption) {
FileToUpload fileToUpload = new FileToUpload();
fileToUpload.setFileUpload(new FileUpload());
fileToUpload.setPath((String) Main.get().activeFolderTree.getActualPath());
fileToUpload.setAction(UIFileUploadConstants.ACTION_INSERT);
Main.get().fileUpload.addPendingFileToUpload(fileToUpload);
Main.get().activeFolderTree.hideMenuPopup();
}
}
示例8: createFileUpload
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private FileUpload createFileUpload() {
fileUpload = new FileUpload();
fileUpload.getElement().getStyle().setDisplay(Style.Display.NONE);
if (fileTypes != null) {
// Convert the format that the SWFUpload/Flash parameter expects to the W3C DOM standard
// See: http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#attr-input-accept
fileUpload.getElement()
.setAttribute("accept", this.fileTypes.replaceAll("\\;", ",").replaceAll("\\*\\.", "."));
// TODO(jake): Need to consider validation of this in the file queued handler as well,
// as the browsers don't appear to consistently support the "accept" attribute
}
final AbsolutePanel panel = this;
fileUpload.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
JsArray<?> selectedFiles = nativeGetSelectedFiles(fileUpload.getElement());
// Every time a file is selected replace the FileUpload component running in the DOM so that
// the user can continue to attempt uploading the same file multiple times (otherwise the
// "ChangeHandler" never fires)
panel.remove(fileUpload);
panel.add(createFileUpload());
addFilesToQueue(selectedFiles);
}
});
return fileUpload;
}
示例9: openFileDialog
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private void openFileDialog(FileUpload fileUpload, boolean multipleFiles) {
if (multipleFiles) {
fileUpload.getElement().setAttribute("multiple", "true");
} else {
fileUpload.getElement().removeAttribute("multiple");
}
if (fileDialogStartHandler != null) {
fileDialogStartHandler.onFileDialogStartEvent(new FileDialogStartEvent());
}
InputElement.as(fileUpload.getElement()).click();
}
示例10: createFileUpload
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private FileUpload createFileUpload() {
// Create a FileUpload widget.
FileUpload upload = new FileUpload();
upload.setName("uploadFormElement");
return upload;
}
示例11: initSelectWorkflowFromFilePanel
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private void initSelectWorkflowFromFilePanel() {
fromFilePanel = new VLayout();
fromFilePanel.setHeight("30px");
fileUpload = new FileUpload();
fileUpload.setName("job");
VerticalPanel formContent = new VerticalPanel();
formContent.setHeight("30px");
Hidden hiddenField = new Hidden();
hiddenField.setName(SESSION_ID_PARAMETER_NAME);
hiddenField.setValue(LoginModel.getInstance().getSessionId());
formContent.add(hiddenField);
formContent.add(fileUpload);
final FormPanel importFromFileformPanel = new FormPanel();
importFromFileformPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
importFromFileformPanel.setMethod(FormPanel.METHOD_POST);
importFromFileformPanel.setAction(URL_UPLOAD_FILE);
importFromFileformPanel.add(formContent);
importFromFileformPanel.addSubmitCompleteHandler(fileUploadCompleteHandler());
importFromFileformPanel.setHeight("30px");
fromFilePanel.addMember(importFromFileformPanel);
sendFromFileButton = new Button("Upload file");
sendFromFileButton.addClickHandler(clickHandlerForUploadFromFileButton(importFromFileformPanel));
}
示例12: addFileUploadForm
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private void addFileUploadForm() {
file = new FileUpload();
file.setHeight("22px");
file.setWidth("100%");
file.setName("file");
file.ensureDebugId("file-uploadFile-ChooseFile");
file.addChangeHandler(
new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
delegate.onFileNameChanged();
}
});
uploadPanel.insert(file, 0);
}
示例13: addFile
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
private void addFile() {
file = new FileUpload();
file.setHeight("22px");
file.setWidth("100%");
file.setName("file");
file.ensureDebugId("file-uploadFile-ChooseFile");
file.addChangeHandler(
new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
delegate.onFileNameChanged();
}
});
uploadPanel.insert(file, 0);
}
示例14: getFileNameShouldBeExecuted
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
@Test
public void getFileNameShouldBeExecuted() {
view.file = mock(FileUpload.class);
when(view.file.getFilename()).thenReturn("fileName");
view.getFileName();
verify(view.file).getFilename();
}
示例15: closeShouldBeExecuted
import com.google.gwt.user.client.ui.FileUpload; //导入依赖的package包/类
@Test
public void closeShouldBeExecuted() {
view.uploadPanel = mock(FlowPanel.class);
view.file = mock(FileUpload.class);
view.overwrite = mock(CheckBox.class);
view.btnUpload = mock(Button.class);
view.closeDialog();
verify(view.uploadPanel).remove((FileUpload) anyObject());
verify(view.btnUpload).setEnabled(eq(false));
verify(view.overwrite).setValue(eq(false));
}