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.htmlhttp://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;
}
}