Re: Updating text file in MultiView

2021-01-18 Thread Boris Heithecker
Hi,
use XMLDataObject.getDocument() to access the DOM. After modifying the DOM,
you can update the file like this:

final FileObject file = getPrimaryFile();
file.getFileSystem().runAtomicAction(() -> {
final FileLock l = file.lock();
try (final OutputStream os = file.getOutputStream(l)) {
XMLUtil.write(doc, os, "utf-8");
//Do something to unregister the Saveable
} finally {
l.releaseLock();
}
});

Hope it helps.
Boris

On Sun, 17 Jan 2021 at 23:13, Will Hartung  wrote:

> I have a XMLMultiView from the generic New File Type wizard.
>
> I'm creating the GUI form for the XML file.
>
> How do I keep the XML file up to date after I make changes in the GUI?
>
> Do I need to create a Saveable and put it in the lookup to mark it as
> "dirty", or will that happen automatically when the XML file is updated?
>
> Can I update the XML file only when the tabs are switched vs for every
> change? In that case, I would have to add a Saveable since the XML may not
> have changed yet.
>
> Anyway, how does that workflow all work out?
>
> Regards,
>
> Will Hartung
>
>

-- 
Boris Heithecker


Dr. Boris Heithecker
Lüneburger Str. 30
28870 Ottersberg
Festnetz: +49 4205 315834
Mobil: +49 170 6137015


Re: Updating text file in MultiView

2021-01-18 Thread Dragan Bjedov
I have created a similar plugin for CSV files.
Please take a look
https://bitbucket.org/draganbjedov/netbeans-csv-editor/src/master/
Hope it helps.

нед, 17. јан 2021. у 23:13 Will Hartung  је
написао/ла:

> I have a XMLMultiView from the generic New File Type wizard.
>
> I'm creating the GUI form for the XML file.
>
> How do I keep the XML file up to date after I make changes in the GUI?
>
> Do I need to create a Saveable and put it in the lookup to mark it as
> "dirty", or will that happen automatically when the XML file is updated?
>
> Can I update the XML file only when the tabs are switched vs for every
> change? In that case, I would have to add a Saveable since the XML may not
> have changed yet.
>
> Anyway, how does that workflow all work out?
>
> Regards,
>
> Will Hartung
>
>

-- 

MSc Dragan Bjedov


Updating text file in MultiView

2021-01-17 Thread Will Hartung
I have a XMLMultiView from the generic New File Type wizard.

I'm creating the GUI form for the XML file.

How do I keep the XML file up to date after I make changes in the GUI?

Do I need to create a Saveable and put it in the lookup to mark it as
"dirty", or will that happen automatically when the XML file is updated?

Can I update the XML file only when the tabs are switched vs for every
change? In that case, I would have to add a Saveable since the XML may not
have changed yet.

Anyway, how does that workflow all work out?

Regards,

Will Hartung