Platform Hook into TopComponent close

View: New views
3 Messages — Rating Filter:   Alert me  

Platform Hook into TopComponent close

by Steve Mosley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everybody,

Our App built in NB Platform is going to have many, TopComponents that act as data entry forms. Key thing here being that when a Form is saved it is done via a Web Service. So there is no file backing the form.



What we want to do is hook into the user attempting to close the form so we can display a dialog warning them they might lose changes, all of the information I can find about this relates to working with real files. Is there a simple way to catch the closing of a Top Component?





Re: Platform Hook into TopComponent close

by Mario Burdman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, you have to implement canClose in your TCs and override closing method in a module installer to handle when someone close the app with opened TCs.

Something like this:

    @Override
    public boolean closing() {
        boolean allTcsCanClose = true;
        for(TopComponent tc :WindowManager.getDefault().getRegistry().getOpened()) {
            if(!tc.canClose()) {
                allTcsCanClose = false;
                break;
            }
        }
        return allTcsCanClose;
    }


Hope that helps.

--
Mario


On Wed, Oct 21, 2009 at 9:59 PM, smozely <steven.mosley1@...> wrote:
Hi everybody,

Our App built in NB Platform is going to have many, TopComponents that act as data entry forms. Key thing here being that when a Form is saved it is done via a Web Service. So there is no file backing the form.



What we want to do is hook into the user attempting to close the form so we can display a dialog warning them they might lose changes, all of the information I can find about this relates to working with real files. Is there a simple way to catch the closing of a Top Component?






Platform Hook into TopComponent close

by Steve Mosley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks,



We knew it had to be simple but somehow missed that one