-
Notifications
You must be signed in to change notification settings - Fork 44
@DoPrivileged
peichhorn edited this page Jun 30, 2012
·
3 revisions
(Documentation pending)
import lombok.DoPrivileged;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;
public class DoPrivilegedExample extends JFrame {
@DoPrivileged
public File getFileUsingFileChooser() {
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileNameExtensionFilter("HTML Documents", "html"));
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile();
}
return null;
}
}
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;
public class DoPrivilegedExample extends JFrame {
public File getFileUsingFileChooser() {
return AccessController.doPrivileged(new PrivilegedAction<File>() {
public File run() {
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileNameExtensionFilter("HTML Documents", "html"));
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showSaveDialog(DoPrivilegedExample.this) == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile();
}
return null;
}
});
}
}
(Documentation pending)
Nothing to configure yet.
I am not able to run @Action. If I provide Action1 implementation it works.
implementation private static Action1 println() { return new Action1() { public void apply(final Object o) { System.out.println(o); } };
pom : com.github.peichhorn lombok-pg 0.11.3
<dependency>
<groupId>com.github.peichhorn</groupId>
<artifactId>lombok-pg</artifactId>
<version>0.11.3</version>
<classifier>runtime</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>