You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Andrei Pozolotin <an...@gmail.com> on 2011/06/05 05:16:14 UTC

pivot & ui state persistence patterns

     *Greg, *// *Christopher*//, *Martijn*//, *Noel*//, *Niclas*//,*
    Sandro*//, *Todd:
    *
    can you guys please share what are best
    pivot ui state persistence patterns?

    DesktopApplicationContext painstakingly goes through

                    Preferences preferences =
    Preferences.userNodeForPackage(DesktopApplicationContext.class);
                    preferences = preferences.node(applicationClassName);

                    boolean maximized =
    (windowedHostFrame.getExtendedState()
                        & java.awt.Frame.MAXIMIZED_BOTH) ==
    java.awt.Frame.MAXIMIZED_BOTH;
                    if (!maximized) {
                        preferences.putInt(X_ARGUMENT,
    windowedHostFrame.getX());
                        preferences.putInt(Y_ARGUMENT,
    windowedHostFrame.getY());
                        preferences.putInt(WIDTH_ARGUMENT,
    windowedHostFrame.getWidth());
                        preferences.putInt(HEIGHT_ARGUMENT,
    windowedHostFrame.getHeight());
                    }

    and BXMLSerializer just gives up:
        @Override
        public void writeObject(Object object, OutputStream
    outputStream) throws IOException,
            SerializationException {
            throw new UnsupportedOperationException();
        }

    Thank you,

    Andrei


Re: pivot & ui state persistence patterns

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
I'm sorry but all my samples are inside the zip in attach in this
thread, and published even here:
http://code.google.com/a/apache-extras.org/p/pivot-stuff/source/browse/#svn%2Ftrunk%2Fpivot-stuff-extensions

But if I understand good, you ask for a sample of persistence for
Pivot Containers/Components, right ?
I haven't on this, sorry.
Note that (by design) Pivot Components aren't Serializable so probably
it's not-so-simple (independently on the utility classes you chose)
... for sure Greg could give you some info (and maybe even Roger,
who's writing a big application, could have solved same problems as
you).

In any case I think we (all together) could start to think at a
common/generic approach (maybe even a Pivot API) to help solve this
type of problems ... for the 2.1 release.
If you want, a dedicated JIRA issue could be useful to keep track of things.

Bye,
Sandro

Re: pivot & ui state persistence patterns

Posted by Greg Brown <gk...@verizon.net>.
I would recommend using the standard Java preferences APIs (java.util.prefs) for this.

On Oct 6, 2011, at 12:51 AM, prophe wrote:

> Hi! Can you post an example or share code or give me an advice how to save
> the state of an application? I mean opened tabs, selected tabs, selected
> tree items and etc? Use preferences api or pivot can do it? or another
> variant?
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/pivot-ui-state-persistence-patterns-tp3025313p3398972.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: pivot & ui state persistence patterns

Posted by prophe <au...@cargosoft.ru>.
Hi! Can you post an example or share code or give me an advice how to save
the state of an application? I mean opened tabs, selected tabs, selected
tree items and etc? Use preferences api or pivot can do it? or another
variant?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/pivot-ui-state-persistence-patterns-tp3025313p3398972.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: pivot & ui state persistence patterns

Posted by Sandro Martini <sa...@gmail.com>.
Hi Andrei,
Ok, but I need only some day to recover from my disks and have related
classes in a status that compiles and works with Pivot 2.0 (I wrote
them for Pivot 1.2 ... and I never used them, so some parts could be
improved/simplified). One thing interesting was to have a factory to
create a Preferences for a FileSystem (useful for standard
applications and signed applets), and another for Web Start
applications. And the output format depending on the Pivot Serializer
tchosen (by default JSONSerializer).

Then I'll put here in attach, inside a zip, and maybe if you (and/or
others) say that could be useful, I could revise at pu for example
under pivot-stuff ... and comments, suggestions, etc will be welcome.

Bye

Re: pivot & ui state persistence patterns

Posted by Andrei Pozolotin <an...@gmail.com>.
     *Sandro:*

    please do, so at least we can take a look!

    Thank you,

    Andrei

-------- Original Message  --------
Subject: Re: pivot & ui state persistence patterns
From: Sandro Martini <sa...@gmail.com>
To: user@pivot.apache.org
Date: Mon 06 Jun 2011 04:41:37 AM CDT
> Hi all,
> some year ago I wrote some classes to implement a simple persistence (like
> the Preferences API), BUT using Pivot Serializers (if I remember well, by
> default the JSONSerializer) ... but has not been included in core Pivot, so
> I never used it ... if you are interested I could try to restore from disks
> (and maybe put inside one of our shiny-new apache-extras subprojects) ans
> see if working with Pivot-2.0.x, ok ?
>
> Bye,
> Sandro
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/pivot-ui-state-persistence-patterns-tp3025313p3029244.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
>   


Re: pivot & ui state persistence patterns

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
some year ago I wrote some classes to implement a simple persistence (like
the Preferences API), BUT using Pivot Serializers (if I remember well, by
default the JSONSerializer) ... but has not been included in core Pivot, so
I never used it ... if you are interested I could try to restore from disks
(and maybe put inside one of our shiny-new apache-extras subprojects) ans
see if working with Pivot-2.0.x, ok ?

Bye,
Sandro


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/pivot-ui-state-persistence-patterns-tp3025313p3029244.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: pivot & ui state persistence patterns

Posted by Greg Brown <gk...@verizon.net>.
DesktopApplicationContext simply saves the state of the native frame window. But I'm not sure what you are asking about. Can you elaborate?
G

On Jun 4, 2011, at 11:16 PM, Andrei Pozolotin wrote:

> Greg, Christopher, Martijn, Noel, Niclas, Sandro, Todd:
> 
> can you guys please share what are best
> pivot ui state persistence patterns?
> 
> DesktopApplicationContext painstakingly goes through 
> 
>                 Preferences preferences = Preferences.userNodeForPackage(DesktopApplicationContext.class);
>                 preferences = preferences.node(applicationClassName);
> 
>                 boolean maximized = (windowedHostFrame.getExtendedState()
>                     & java.awt.Frame.MAXIMIZED_BOTH) == java.awt.Frame.MAXIMIZED_BOTH;
>                 if (!maximized) {
>                     preferences.putInt(X_ARGUMENT, windowedHostFrame.getX());
>                     preferences.putInt(Y_ARGUMENT, windowedHostFrame.getY());
>                     preferences.putInt(WIDTH_ARGUMENT, windowedHostFrame.getWidth());
>                     preferences.putInt(HEIGHT_ARGUMENT, windowedHostFrame.getHeight());
>                 }
> 
> and BXMLSerializer just gives up:
>     @Override
>     public void writeObject(Object object, OutputStream outputStream) throws IOException,
>         SerializationException {
>         throw new UnsupportedOperationException();
>     }
> 
> Thank you, 
> 
> Andrei
> 

_____
Big Life: It's What You Make Itâ„¢