Browse Source

FileSetting: On-first-use allocation of file selector

The FileSetting object stores a FileSelector, which is allocated
using defaultSelector() during construction. It can also be set via setFileSelector().

To avoid constructing a FileSelector (and thus call into the Swing/AWT Java package) in
headless / command-line mode, we allocate the default selector on first use, i.e.,
whenever the selector is null in a call to getFileSelector().
master
Joachim Klein 8 years ago
committed by Dave Parker
parent
commit
382aa51de3
  1. 7
      prism/src/settings/FileSetting.java

7
prism/src/settings/FileSetting.java

@ -72,8 +72,6 @@ public class FileSetting extends Setting
super(name, value, comment, owner, editableWhenMultiple);
if(value != null) validFile = value.isFile();
else validFile = false;
selector = defaultSelector();
}
public FileSetting(String name, File value, String comment, SettingOwner owner, boolean editableWhenMultiple, FontColorConstraint constraint)
@ -81,8 +79,6 @@ public class FileSetting extends Setting
super(name, value, comment, owner, editableWhenMultiple, constraint);
if(value != null) validFile = value.isFile();
else validFile = false;
selector = defaultSelector();
}
public void checkObjectWithConstraints(Object obj) throws SettingException
@ -153,6 +149,9 @@ public class FileSetting extends Setting
public FileSelector getFileSelector()
{
if (selector == null) {
selector = defaultSelector();
}
return selector;
}

Loading…
Cancel
Save