I'll fix the NPE. Thanks!
On Feb 1, 2010, at 5:08 PM, Scott Lanham wrote:
> Hi Greg,
>
> Thanks for the patch :-)
>
> It works unless I leave the root directory out of the File constructor:
>
> fileBrowserSheet.setSelectedFile(new File("New File"));
>
> Which causes a Null Pointer exception.
>
> On Tue, 2 Feb 2010 05:46:32 am Greg Brown wrote:
>> Hi Scott,
>> Were you able to apply this patch? Did it solve your problem?
>> Greg
>>
>> On Jan 29, 2010, at 6:16 PM, Greg Brown wrote:
>>> Hi Scott,
>>>
>>> That seems like a valid use case that FileBrowserSheet doesn't currently
>>> support. If you are building Pivot from source, can you try applying this
>>> patch:
>>>
>>> Index:
>>> wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.j
>>> ava ===================================================================
>>> ---
>>> wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.j
>>> ava (revision 902074) +++
>>> wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.j
>>> ava (working copy) @@ -326,7 +326,18 @@
>>> public void selectedFilesChanged(FileBrowserSheet fileBrowserSheet,
>>> Sequence<File> previousSelectedFiles) {
>>> if (!updatingSelection) {
>>> -
>>> fileBrowser.setSelectedFiles(fileBrowserSheet.getSelectedFiles()); +
>>> Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
>>> + fileBrowser.setSelectedFiles(selectedFiles);
>>> +
>>> + if (fileBrowser.getSelectedFiles().getLength() == 0
>>> + && selectedFiles.getLength() == 1) {
>>> + File selectedFile = selectedFiles.get(0);
>>> +
>>> + File rootDirectory = fileBrowser.getRootDirectory();
>>> + if (selectedFile.getParentFile().equals(rootDirectory))
>>> { + saveAsTextInput.setText(selectedFile.getName()); +
>>> }
>>> + }
>>> }
>>> }
>>>
>>> Then, do this in your app code:
>>>
>>> fileBrowserSheet.setSelectedFile(new
>>> File(fileBrowserSheet.getRootDirectory(), "New File"));
>>>
>>> Let me know if this works.
>>>
>>> Greg
>>>
>>> On Jan 29, 2010, at 5:21 PM, Scott Lanham wrote:
>>>> Hi Greg,
>>>>
>>>> The file is yet to be created so I just want the root directory to stay
>>>> at whatever default the system decides, /home in my case.
>>>>
>>>> On Fri, 29 Jan 2010 11:52:10 pm Greg Brown wrote:
>>>>> Haven't looked into this yet, but have you tried also setting the root
>>>>> directory to the folder that contains the file? (see
>>>>> setRootDirectory())
>>>>>
>>>>> G
>>>>>
>>>>> On Jan 28, 2010, at 7:55 PM, Scott Lanham wrote:
>>>>>> Howdy Hi,
>>>>>>
>>>>>> I am using a FileBrowserSheet in "save as" mode but can't seem to get
>>>>>> it to display a default file name. I have tried using
>>>>>> setSelectedFile(new File( "someDefaultFileName")) but it isn't
>>>>>> displayed.
>>>>>>
>>>>>> Any help very appreciated.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Scott.
>>