Hello giancarlo,

[top-posting is IMHO very annoying, so I cut your answer and paste at the 
bottom, see http://en.wikipedia.org/wiki/Posting_style#Top-posting]

On Wednesday 11 March 2009, 09:12, giancarlo wrote:
> Sorry, I previously misunderstood you before...
> In the call to dispatch() I call another method which does some checks
> and then creates an instance of a class which extends JFrame.
>
> "I meant: you want only once instance of your JFrame in the whole
> office?" (I've misunderstood this before) : the answer is not, I need to
> open a JFrame for each opened document  on OOo.
> The only problem is that toolbar button and menu item seem to be two
> different extensions...

well, then you need a sort of Frame manager, which can be a singleton. Just 
the first idea that comes to my mind: 
* your Frame Manager can keep track if your JFrame is actually instantiated 
for an OOo XFrame
* then from your ProtocolHandler's dispatch you can call your FrameManager to 
create a new instance of your JFrame or return the existing one: 
       MyJFrame FrameManager.getOrCreateMyJFrame(css.frame.XFrame xOOoFrame)

you can do this by holding a collection of XFrame-MyJframe pairs (when the 
JFrame is closed, you remove it from the collection... but you should also 
listen to OOo XFrame's actions [don't know what you do with your JFrame if the 
user chooses, for example, the print preview, etc.]). If the css.frame.XFrame 
reference is found in your XFrame-MyJframe pair collection, return that 
JFrame, if not instantiate a new one... etc. etc.

Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to