You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Pete Whelpton <pe...@gmail.com> on 2018/01/13 13:16:29 UTC
[Module Development] Visual editor for binary file type
Hello - and apologies for what is probably a dumb question.
I am trying to create a Netbeans plugin that allows editing of a binary
file type (with is basically a two dimensional array) via a Visual Editor
containing a JTable.
I have a model class that extends AbstractTableModel, and I have followed
the New File tutorial but I am unsure of where to parse the binary file,
and of which class the model class be a property of?
Q. Should the model be a property of DataObject or of the VisualElement?
Q. When to parse the binary file? When DataObject is created, or in one of
the methods of VisualElement e.g. ComponentOpened ?
Can anybody recommend some similar plugin(s) I could look it to try and
help me fit these last pieces together?
Many thanks!
RE: [Module Development] Visual editor for binary file type
Posted by stephen cumminger <st...@sonideft.com>.
Hi Pete. If the binary file type has a unique file extension, you could certainly create a Data Object with the appropriate mime type to open the file and gain access to some of the typical functions for DataObjects that NetBeans enables (copy, rename, delete…)
However, if you don’t need all those things and you just present the user with a File Open Dialog to access the file, then you could make your efforts less complicated and go a simpler route. You should have a class dedicated to the storage and manipulation of your data. You could try to incorporate this directly into your table model. I think best practices would be to keep the table model as the go-between the table and data for reads/write operations. Probably depends on complexity though.
If you go the DataObject route, you would override the Open() method to parse your file (your class would extend DataObject). If you don’t, you would do it right after you open the file.
I haven’t done a plugin before, but hope this helps.
Regards
Steve
From: Pete Whelpton [mailto:peedeeboy@gmail.com]
Sent: Saturday, January 13, 2018 9:16 AM
To: users@netbeans.apache.org
Subject: [Module Development] Visual editor for binary file type
Hello - and apologies for what is probably a dumb question.
I am trying to create a Netbeans plugin that allows editing of a binary file type (with is basically a two dimensional array) via a Visual Editor containing a JTable.
I have a model class that extends AbstractTableModel, and I have followed the New File tutorial but I am unsure of where to parse the binary file, and of which class the model class be a property of?
Q. Should the model be a property of DataObject or of the VisualElement?
Q. When to parse the binary file? When DataObject is created, or in one of the methods of VisualElement e.g. ComponentOpened ?
Can anybody recommend some similar plugin(s) I could look it to try and help me fit these last pieces together?
Many thanks!
Re: [Module Development] Visual editor for binary file type
Posted by Oliver Rettig <Ol...@orat.de>.
Hi,
following
https://platform.netbeans.org/tutorials/nbm-filetype.html
maybe the missing peace is that you can extend DataObject and you add an object to its
lookup which provides support for your specific data.
public class ABCDataObject extends MultiDataObject {
public ABCObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException,
IOException {
super(pf, loader);
CookieSet cookieSet = getCookieSet();
ABCSpecificFunctionality impl = new ABCSpecificFunctionality();
cookieSet.assign(iABCSpecificFunctionality.class, impl);
registerEditor("yourmimetype", true);
}
...
}
Maybe this CookieSet stuff is the old style. Better use the new Lookup classes
Hope this helps a bit.
best regards
Oliver
> Hello - and apologies for what is probably a dumb question.
>
> I am trying to create a Netbeans plugin that allows editing of a binary
> file type (with is basically a two dimensional array) via a Visual Editor
> containing a JTable.
>
> I have a model class that extends AbstractTableModel, and I have followed
> the New File tutorial but I am unsure of where to parse the binary file,
> and of which class the model class be a property of?
>
> Q. Should the model be a property of DataObject or of the VisualElement?
>
> Q. When to parse the binary file? When DataObject is created, or in one of
> the methods of VisualElement e.g. ComponentOpened ?
>
>
> Can anybody recommend some similar plugin(s) I could look it to try and
> help me fit these last pieces together?
>
> Many thanks!