-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/test/java/org/vaadin/easyuploads/demoandtestapp/DisabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.vaadin.easyuploads.demoandtestapp; | ||
|
||
import com.vaadin.data.Property; | ||
import com.vaadin.ui.CheckBox; | ||
import com.vaadin.ui.Component; | ||
import com.vaadin.ui.Notification; | ||
import com.vaadin.ui.VerticalLayout; | ||
import java.io.File; | ||
|
||
import org.vaadin.easyuploads.*; | ||
|
||
import org.vaadin.addonhelpers.AbstractTest; | ||
|
||
public class DisabledTest extends AbstractTest { | ||
|
||
public static class MyBean { | ||
|
||
private File file; | ||
|
||
public File getFile() { | ||
return file; | ||
} | ||
|
||
public void setFile(File file) { | ||
this.file = file; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MyBean{" + "file=" + (file == null ? "null" : file.getName()) + '}'; | ||
} | ||
|
||
} | ||
|
||
final UploadField file = new UploadField(); | ||
|
||
MyBean bean = new MyBean(); | ||
|
||
@Override | ||
public Component getTestComponent() { | ||
VerticalLayout layout = new VerticalLayout(); | ||
file.setEnabled(false); | ||
file.setButtonCaption("...Select File"); | ||
file.setDisplayUpload(false); | ||
|
||
file.addValueChangeListener(new Property.ValueChangeListener() { | ||
@Override | ||
public void valueChange(Property.ValueChangeEvent event) { | ||
Notification.show("File uploaded" + file.getLastFileName() + " IsEmpty:" + file.isEmpty()); | ||
} | ||
}); | ||
|
||
layout.addComponent(file); | ||
|
||
CheckBox cb = new CheckBox("Enabled"); | ||
cb.setValue(false); | ||
cb.addValueChangeListener(new Property.ValueChangeListener() { | ||
@Override | ||
public void valueChange(Property.ValueChangeEvent event) { | ||
final boolean name = !file.isEnabled(); | ||
file.setEnabled(name); | ||
} | ||
}); | ||
|
||
layout.addComponents(cb); | ||
|
||
return layout; | ||
} | ||
|
||
} |