git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7334 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Brian Remedios
2011-09-24 07:39:37 +00:00
parent 571dc30668
commit e13e441d96
2 changed files with 7 additions and 5 deletions

View File

@ -76,7 +76,7 @@ public class FileEditorFactory extends AbstractEditorFactory {
final FileProperty fp = filePropertyFrom(desc); // TODO - really necessary? final FileProperty fp = filePropertyFrom(desc); // TODO - really necessary?
picker.addListener(SWT.FocusOut, new Listener() { picker.addFocusOutListener(new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
File newValue = picker.getFile(); File newValue = picker.getFile();
File existingValue = (File)valueFor(source, fp); File existingValue = (File)valueFor(source, fp);

View File

@ -68,6 +68,10 @@ public class FilePicker extends Composite {
fileField.setLayoutData(data); fileField.setLayoutData(data);
} }
public void addFocusOutListener(Listener listener) {
fileField.addListener(SWT.FocusOut, listener);
}
private void openFileDialog(Shell shell) { private void openFileDialog(Shell shell) {
FileDialog fd = new FileDialog(shell, SWT.OPEN); FileDialog fd = new FileDialog(shell, SWT.OPEN);
@ -79,6 +83,7 @@ public class FilePicker extends Composite {
String selected = fd.open(); String selected = fd.open();
fileField.setText(selected == null ? "" : selected); fileField.setText(selected == null ? "" : selected);
fileField.setFocus();
} }
public void setBackground(Color clr) { public void setBackground(Color clr) {
@ -102,10 +107,7 @@ public class FilePicker extends Composite {
public File getFile() { public File getFile() {
String name = fileField.getText(); String name = fileField.getText();
if (StringUtil.isEmpty(name)) return null; return StringUtil.isEmpty(name) ? null : new File(name);
File file = new File(name);
return file.exists() ? file : null;
} }
} }