if (ParallelSerialData.SOURCE_PATH.equals(param)) {
final Value sourceFile =
getParamSaved(ParallelSerialData.SOURCE_PATH);
final String regexp = ".*[^/]$";
final MyButton fileChooserBtn = widgetFactory.createButton("Browse...");
final Widget paramWi = widgetFactory.createInstance(
Widget.Type.TEXTFIELD,
sourceFile,
Widget.NO_ITEMS,
regexp,
width,
Widget.NO_ABBRV,
new AccessMode(getAccessType(param),
AccessMode.NORMAL),
fileChooserBtn);
if (Tools.isWindows()) {
/* does not work on windows and I tries, ultimatly because
FilePane.usesShellFolder(fc) in BasicFileChooserUI returns
true and it is not possible to descent into a directory.
TODO: It may work in the future.
*/
paramWi.setTFButtonEnabled(false);
}
fileChooserBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
final String oldDir = paramWi.getStringValue();
final String directory;
if (oldDir == null || oldDir.isEmpty()) {
final String type = getComboBoxValue(
ParallelSerialData.TYPE).getValueForConfig();
if ("dev".equals(type)) {
directory = "/dev";
} else {
directory = "/";
}
} else {
directory = oldDir;
}
startFileChooser(paramWi,
directory,
FILECHOOSER_FILE_ONLY);
}
});
t.start();
}
});
widgetAdd(param, prefix, paramWi);
return paramWi;
} else {
final Widget paramWi = super.createWidget(param, prefix, width);
if (ParallelSerialData.TYPE.equals(param)
|| ParallelSerialData.SOURCE_MODE.equals(param)) {
paramWi.setAlwaysEditable(false);
}
return paramWi;
}
}