|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
How to create "special" DataObjects (myself, not in layer)?Hello! I've got a special xml config file, whose name may even change from project to project. I've already created an ant project type (works :-) ), but now I want to create an XML multiview editor as described here: http://blogs.sun.com/geertjan/entry/visual_editor_part_1. My problem with this is, I'll not be able to declare my config file type in layer, as it is completely project dependent. Worse, there's not even any public or system id which could be used. So, how can I create an XmlMultiViewDataObject from my node's performAction method? BTW, I guess the object has to be created from my FileObject and has to be put into Lookup somehow - how? Kind regards Peter |
|
|
Re: How to create "special" DataObjects (myself, not in layer)?Hi Peter,
I think I don't understand the question. So let me explain what I understand: You have a XML file with ".xml" extension. (You say it's a "config" file, what does that mean? Are you using it inside the "nbproject" directory integrating it as a part of the "build.xml"?). The contents of the XML file do not have a common "root" element (so one file can start with "<invoices>" and another can start with "<facturas>"). What you want to do is to create a DataObject from that file, and then use a MultiView to be able to edit it visually. Am I right? Thanks, Antonio
|
|
|
Re: How to create "special" DataObjects (myself, not in layer)?AntonioV wrote:
> Hi Peter, > > I think I don't understand the question. So let me explain what I > understand: > > You have a XML file with ".xml" extension. (You say it's a "config" file, > what does that mean? Are you using it inside the "nbproject" directory > integrating it as a part of the "build.xml"?). The contents of the XML file > do not have a common "root" element (so one file can start with "<invoices>" > and another can start with "<facturas>"). No nbproject. Even worse, it's an XSLT file which *results* in something like a config, without anything making it possible to use a MimeResolver. > What you want to do is to create a DataObject from that file, and then use a > MultiView to be able to edit it visually. > > Am I right? Yes. I've already thought about using a java implemented mime resolver (like in "good old times" ;-) ), but AFAIK, declarative resolvers have higher precedence, so my file will be resolved as an xsl file anyway. Also, I don't know if NB will work well, if I had to ask for the project owning the file before mime resolution. Thanks Peter > > Thanks, > Antonio > > > > epdv wrote: >> >> Hello! >> >> I've got a special xml config file, whose name may even change from >> project to project. I've already created an ant project type (works :-) >> ), but now I want to create an XML multiview editor as described here: >> http://blogs.sun.com/geertjan/entry/visual_editor_part_1. >> >> My problem with this is, I'll not be able to declare my config file type >> in layer, as it is completely project dependent. Worse, there's not even >> any public or system id which could be used. So, how can I create an >> XmlMultiViewDataObject from my node's performAction method? BTW, I guess >> the object has to be created from my FileObject and has to be put into >> Lookup somehow - how? >> >> Kind regards >> >> Peter >> >> >> > |
|
|
Re: How to create "special" DataObjects (myself, not in layer)?Hi Peter,
I'm not very good at MimeResolvers, so I'm afraid you'll have to resort to a more expert answer. Anyway here goes my quick & dirty solution: what about creating a sibling file with a well known extension (so it's easily detected with current NBRCP infrastructure), and then build a MultiDataObject from that file as a primary file *and* your XSLT as a secondary file? I know that having a dummy file around is probably not the best solution but, hey, maybe it's a simpler way to have things done. Cheers, Antonio P.S.: If you're using your XSLT to build a "build.xml" file for Ant, then I think you can probably add a LookupProvider to your Project, and register that in a proper way see: http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-project-ant/org/netbeans/spi/project/support/ant/GeneratedFilesHelper.html#generateBuildScriptFromStylesheet%28java.lang.String,%20java.net.URL%29 and http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-project-ant/org/netbeans/api/project/ant/AntBuildExtender.html
|
|
|
Re: How to create "special" DataObjects (myself, not in layer)?Hi Antonio,
I'd guess this won't work, either. The name isn't fixed (it is project-dependent), it's not an Ant build file, what is produced (the config isn't even produced externally), and the XSL will most likely be interpreted by NB infrastructure - if I'm using a DataObject. OTOH, it should be possible to just edit the file in a "simple" editor, probably it might be possible to use some XML utilities, at least. There's also a non-XML multiview API, I'll use that. I've still got one problem with this: How do I load my data into an Editor/JEditorPane? Do I have instantiate an EditSupport? When creating WindowComponent in editor mode, I'm getting several bugs about singletons and restoring editors after restarting NetBeans, and my current approach is very "synthetic", i.e. windows system does not seem to be intended to be used this way ... Could You probably point me to some docs? Kind regards Peter Nabbefeld AntonioV wrote: > Hi Peter, > > I'm not very good at MimeResolvers, so I'm afraid you'll have to resort to a > more expert answer. > > Anyway here goes my quick& dirty solution: what about creating a sibling > file with a well known extension (so it's easily detected with current NBRCP > infrastructure), and then build a MultiDataObject from that file as a > primary file *and* your XSLT as a secondary file? > > I know that having a dummy file around is probably not the best solution > but, hey, maybe it's a simpler way to have things done. > > Cheers, > Antonio > > P.S.: If you're using your XSLT to build a "build.xml" file for Ant, then I > think you can probably add a LookupProvider to your Project, and register > that in a proper way see: > > http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-project-ant/org/netbeans/spi/project/support/ant/GeneratedFilesHelper.html#generateBuildScriptFromStylesheet%28java.lang.String,%20java.net.URL%29 > > and > > http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-project-ant/org/netbeans/api/project/ant/AntBuildExtender.html > > > > > epdv wrote: >> AntonioV wrote: >>> Hi Peter, >>> >>> I think I don't understand the question. So let me explain what I >>> understand: >>> >>> You have a XML file with ".xml" extension. (You say it's a "config" file, >>> what does that mean? Are you using it inside the "nbproject" directory >>> integrating it as a part of the "build.xml"?). The contents of the XML >>> file >>> do not have a common "root" element (so one file can start with >>> "<invoices>" >>> and another can start with "<facturas>"). >> No nbproject. Even worse, it's an XSLT file which *results* in something >> like a config, without anything making it possible to use a MimeResolver. >> >>> What you want to do is to create a DataObject from that file, and then >>> use a >>> MultiView to be able to edit it visually. >>> >>> Am I right? >> Yes. I've already thought about using a java implemented mime resolver >> (like in "good old times" ;-) ), but AFAIK, declarative resolvers have >> higher precedence, so my file will be resolved as an xsl file anyway. >> Also, I don't know if NB will work well, if I had to ask for the project >> owning the file before mime resolution. >> >> Thanks >> >> Peter >> >>> Thanks, >>> Antonio >>> >>> >>> >>> epdv wrote: >>>> Hello! >>>> >>>> I've got a special xml config file, whose name may even change from >>>> project to project. I've already created an ant project type (works :-) >>>> ), but now I want to create an XML multiview editor as described here: >>>> http://blogs.sun.com/geertjan/entry/visual_editor_part_1. >>>> >>>> My problem with this is, I'll not be able to declare my config file type >>>> in layer, as it is completely project dependent. Worse, there's not even >>>> any public or system id which could be used. So, how can I create an >>>> XmlMultiViewDataObject from my node's performAction method? BTW, I guess >>>> the object has to be created from my FileObject and has to be put into >>>> Lookup somehow - how? >>>> >>>> Kind regards >>>> >>>> Peter >>>> >>>> >>>> >> >> >> > |
|
|
Re: Re: How to create "special" DataObjects (myself, not in layer)?Hi Peter,
Comments below. P.N. escribió: > Hi Antonio, > > I'd guess this won't work, either. The name isn't fixed (it is > project-dependent), it's not an Ant build file, what is produced (the > config isn't even produced externally), and the XSL will most likely be > interpreted by NB infrastructure - if I'm using a DataObject. OTOH, it > should be possible to just edit the file in a "simple" editor, probably > it might be possible to use some XML utilities, at least. You're probably right here. > > There's also a non-XML multiview API, I'll use that. > > I've still got one problem with this: How do I load my data into an > Editor/JEditorPane? Do I have instantiate an EditSupport? As far as I know (I don't know much, by the way) you can either: - DataEditorSupport.create (default behaviour) [1] - Create your own EditorSupport. [2] - Create an object that implements OpenCookie and CloseCookie and use that to open/close your own TopComponent. [3] ... and then add that to the getCookieSet() in the constructor of your custom DataObject. > > When creating WindowComponent in editor mode, I'm getting several bugs > about singletons and restoring editors after restarting NetBeans, and my > current approach is very "synthetic", i.e. windows system does not seem > to be intended to be used this way ... There's another thread about singletons, but I don't think you really want a singleton TopComponent for editing your file. You may want different instances of your TopComponent (as different tabs of your editor). > > Could You probably point me to some doc [1] http://bits.netbeans.org/dev/javadoc/org-openide-loaders/org/openide/text/DataEditorSupport.html http://bits.netbeans.org/download/6_0/javadoc/org-openide-text/org/openide/text/CloneableEditorSupport.html [2] http://www.google.com/codesearch/p?hl=es&sa=N&cd=5&ct=rc#txuJ105FSvQ/trunk/projects/Db4oNBModuleSuite/Db4oNBModule/src/com/db4o/nb/db4ofiletype/Db4oEditorSupport.java&q=extends%20CloneableOpenSupport [3] package net.antonioshome.netbeans.b.cookies; import javax.swing.SwingUtilities; import net.antonioshome.netbeans.b.BDataObject; import net.antonioshome.netbeans.b.nodes.editor.tc.BTopComponent; import org.openide.cookies.CloseCookie; import org.openide.cookies.OpenCookie; public class BCookies implements OpenCookie, CloseCookie { public BDataObject bdo; private BTopComponent tc; public BCookies( BDataObject bdo ) { this.bdo = bdo; } public void open() { SwingUtilities.invokeLater( new Runnable() { public void run() { openInSwing(); } } ); } private void openInSwing() { if ( tc == null ) { tc = new BTopComponent(); } tc.show( this.bdo ); tc.open(); tc.requestActive(); } public boolean close() { if ( tc.canClose() ) { tc.close(); tc = null; return true; } return false; } } |
|
|
Re: How to create "special" DataObjects (myself, not in layer)?Thank You Antonio!
It works - at least partly :-) ! Kind regards Peter Antonio wrote: > Hi Peter, > > Comments below. > > P.N. escribió: >> Hi Antonio, >> >> I'd guess this won't work, either. The name isn't fixed (it is >> project-dependent), it's not an Ant build file, what is produced (the >> config isn't even produced externally), and the XSL will most likely >> be interpreted by NB infrastructure - if I'm using a DataObject. OTOH, >> it should be possible to just edit the file in a "simple" editor, >> probably it might be possible to use some XML utilities, at least. > > You're probably right here. > >> >> There's also a non-XML multiview API, I'll use that. >> >> I've still got one problem with this: How do I load my data into an >> Editor/JEditorPane? Do I have instantiate an EditSupport? > > As far as I know (I don't know much, by the way) you can either: > - DataEditorSupport.create (default behaviour) [1] > - Create your own EditorSupport. [2] > - Create an object that implements OpenCookie and CloseCookie and use > that to open/close your own TopComponent. [3] > > ... and then add that to the getCookieSet() in the constructor of your > custom DataObject. > >> >> When creating WindowComponent in editor mode, I'm getting several bugs >> about singletons and restoring editors after restarting NetBeans, and >> my current approach is very "synthetic", i.e. windows system does not >> seem to be intended to be used this way ... > > There's another thread about singletons, but I don't think you really > want a singleton TopComponent for editing your file. You may want > different instances of your TopComponent (as different tabs of your > editor). > >> >> Could You probably point me to some doc > > > > > [1] > http://bits.netbeans.org/dev/javadoc/org-openide-loaders/org/openide/text/DataEditorSupport.html > > http://bits.netbeans.org/download/6_0/javadoc/org-openide-text/org/openide/text/CloneableEditorSupport.html > > > [2] > http://www.google.com/codesearch/p?hl=es&sa=N&cd=5&ct=rc#txuJ105FSvQ/trunk/projects/Db4oNBModuleSuite/Db4oNBModule/src/com/db4o/nb/db4ofiletype/Db4oEditorSupport.java&q=extends%20CloneableOpenSupport > > > > [3] > > package net.antonioshome.netbeans.b.cookies; > > import javax.swing.SwingUtilities; > import net.antonioshome.netbeans.b.BDataObject; > import net.antonioshome.netbeans.b.nodes.editor.tc.BTopComponent; > import org.openide.cookies.CloseCookie; > import org.openide.cookies.OpenCookie; > > public class BCookies > implements OpenCookie, CloseCookie { > > public BDataObject bdo; > private BTopComponent tc; > > public BCookies( BDataObject bdo ) > { > this.bdo = bdo; > } > > public void open() { > SwingUtilities.invokeLater( new Runnable() { public void run() { > openInSwing(); } } ); > } > > private void openInSwing() > { > if ( tc == null ) > { > tc = new BTopComponent(); > } > tc.show( this.bdo ); > tc.open(); > tc.requestActive(); > } > > public boolean close() { > if ( tc.canClose() ) > { > tc.close(); > tc = null; > return true; > } > return false; > } > > } > |
|
|
Re: Re: How to create "special" DataObjects (myself, not in layer)?Which one of the three works for you? Is it 3)?
Cheers, Antonio epdv escribió: > Thank You Antonio! > > It works - at least partly :-) ! > > Kind regards > > Peter > > > > Antonio wrote: >> Hi Peter, >> >> Comments below. >> >> P.N. escribió: >>> Hi Antonio, >>> >>> I'd guess this won't work, either. The name isn't fixed (it is >>> project-dependent), it's not an Ant build file, what is produced (the >>> config isn't even produced externally), and the XSL will most likely >>> be interpreted by NB infrastructure - if I'm using a DataObject. OTOH, >>> it should be possible to just edit the file in a "simple" editor, >>> probably it might be possible to use some XML utilities, at least. >> >> You're probably right here. >> >>> >>> There's also a non-XML multiview API, I'll use that. >>> >>> I've still got one problem with this: How do I load my data into an >>> Editor/JEditorPane? Do I have instantiate an EditSupport? >> >> As far as I know (I don't know much, by the way) you can either: >> - DataEditorSupport.create (default behaviour) [1] >> - Create your own EditorSupport. [2] >> - Create an object that implements OpenCookie and CloseCookie and use >> that to open/close your own TopComponent. [3] >> >> ... and then add that to the getCookieSet() in the constructor of your >> custom DataObject. >> >>> >>> When creating WindowComponent in editor mode, I'm getting several bugs >>> about singletons and restoring editors after restarting NetBeans, and >>> my current approach is very "synthetic", i.e. windows system does not >>> seem to be intended to be used this way ... >> >> There's another thread about singletons, but I don't think you really >> want a singleton TopComponent for editing your file. You may want >> different instances of your TopComponent (as different tabs of your >> editor). >> >>> >>> Could You probably point me to some doc >> >> >> >> >> [1] >> http://bits.netbeans.org/dev/javadoc/org-openide-loaders/org/openide/text/DataEditorSupport.html >> >> >> http://bits.netbeans.org/download/6_0/javadoc/org-openide-text/org/openide/text/CloneableEditorSupport.html >> >> >> >> [2] >> http://www.google.com/codesearch/p?hl=es&sa=N&cd=5&ct=rc#txuJ105FSvQ/trunk/projects/Db4oNBModuleSuite/Db4oNBModule/src/com/db4o/nb/db4ofiletype/Db4oEditorSupport.java&q=extends%20CloneableOpenSupport >> >> >> >> >> [3] >> >> package net.antonioshome.netbeans.b.cookies; >> >> import javax.swing.SwingUtilities; >> import net.antonioshome.netbeans.b.BDataObject; >> import net.antonioshome.netbeans.b.nodes.editor.tc.BTopComponent; >> import org.openide.cookies.CloseCookie; >> import org.openide.cookies.OpenCookie; >> >> public class BCookies >> implements OpenCookie, CloseCookie { >> >> public BDataObject bdo; >> private BTopComponent tc; >> >> public BCookies( BDataObject bdo ) >> { >> this.bdo = bdo; >> } >> >> public void open() { >> SwingUtilities.invokeLater( new Runnable() { public void run() { >> openInSwing(); } } ); >> } >> >> private void openInSwing() >> { >> if ( tc == null ) >> { >> tc = new BTopComponent(); >> } >> tc.show( this.bdo ); >> tc.open(); >> tc.requestActive(); >> } >> >> public boolean close() { >> if ( tc.canClose() ) >> { >> tc.close(); >> tc = null; >> return true; >> } >> return false; >> } >> >> } >> > > > |
|
|
Re: How to create "special" DataObjects (myself, not in layer)?Antonio wrote:
> Which one of the three works for you? Is it 3)? > Didn't implement any of them, as all rely on DataObjects, but our discussion led me to have a clearer look at the facts, so helped anyway. Regards, Peter > Cheers, > Antonio > > epdv escribió: >> Thank You Antonio! >> >> It works - at least partly :-) ! >> >> Kind regards >> >> Peter >> >> >> >> Antonio wrote: >>> Hi Peter, >>> >>> Comments below. >>> >>> P.N. escribió: >>>> Hi Antonio, >>>> >>>> I'd guess this won't work, either. The name isn't fixed (it is >>>> project-dependent), it's not an Ant build file, what is produced (the >>>> config isn't even produced externally), and the XSL will most likely >>>> be interpreted by NB infrastructure - if I'm using a DataObject. OTOH, >>>> it should be possible to just edit the file in a "simple" editor, >>>> probably it might be possible to use some XML utilities, at least. >>> >>> You're probably right here. >>> >>>> >>>> There's also a non-XML multiview API, I'll use that. >>>> >>>> I've still got one problem with this: How do I load my data into an >>>> Editor/JEditorPane? Do I have instantiate an EditSupport? >>> >>> As far as I know (I don't know much, by the way) you can either: >>> - DataEditorSupport.create (default behaviour) [1] >>> - Create your own EditorSupport. [2] >>> - Create an object that implements OpenCookie and CloseCookie and use >>> that to open/close your own TopComponent. [3] >>> >>> ... and then add that to the getCookieSet() in the constructor of your >>> custom DataObject. >>> >>>> >>>> When creating WindowComponent in editor mode, I'm getting several bugs >>>> about singletons and restoring editors after restarting NetBeans, and >>>> my current approach is very "synthetic", i.e. windows system does not >>>> seem to be intended to be used this way ... >>> >>> There's another thread about singletons, but I don't think you really >>> want a singleton TopComponent for editing your file. You may want >>> different instances of your TopComponent (as different tabs of your >>> editor). >>> >>>> >>>> Could You probably point me to some doc >>> >>> >>> >>> >>> [1] >>> http://bits.netbeans.org/dev/javadoc/org-openide-loaders/org/openide/text/DataEditorSupport.html >>> >>> >>> http://bits.netbeans.org/download/6_0/javadoc/org-openide-text/org/openide/text/CloneableEditorSupport.html >>> >>> >>> >>> [2] >>> http://www.google.com/codesearch/p?hl=es&sa=N&cd=5&ct=rc#txuJ105FSvQ/trunk/projects/Db4oNBModuleSuite/Db4oNBModule/src/com/db4o/nb/db4ofiletype/Db4oEditorSupport.java&q=extends%20CloneableOpenSupport >>> >>> >>> >>> >>> [3] >>> >>> package net.antonioshome.netbeans.b.cookies; >>> >>> import javax.swing.SwingUtilities; >>> import net.antonioshome.netbeans.b.BDataObject; >>> import net.antonioshome.netbeans.b.nodes.editor.tc.BTopComponent; >>> import org.openide.cookies.CloseCookie; >>> import org.openide.cookies.OpenCookie; >>> >>> public class BCookies >>> implements OpenCookie, CloseCookie { >>> >>> public BDataObject bdo; >>> private BTopComponent tc; >>> >>> public BCookies( BDataObject bdo ) >>> { >>> this.bdo = bdo; >>> } >>> >>> public void open() { >>> SwingUtilities.invokeLater( new Runnable() { public void run() { >>> openInSwing(); } } ); >>> } >>> >>> private void openInSwing() >>> { >>> if ( tc == null ) >>> { >>> tc = new BTopComponent(); >>> } >>> tc.show( this.bdo ); >>> tc.open(); >>> tc.requestActive(); >>> } >>> >>> public boolean close() { >>> if ( tc.canClose() ) >>> { >>> tc.close(); >>> tc = null; >>> return true; >>> } >>> return false; >>> } >>> >>> } >>> >> >> >> > |
| Free embeddable forum powered by Nabble | Forum Help |