SwingLabs-Demos: which version of appframework?

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

SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just noticed that restoring session state doesn't work, there's a log message "session restoration temporarily disabled" which seems to come from somewhere "down", that is not from SwingXSet and not from SingleXFrameApplication. I had use the appframework.jar from SwingXSet because StyledActions register a listener to context which seems to be somewhat newer (or older?) than the version used in the incubator.

May be related to the version: is the selectedProperty of a @Action supposed to work and if so, how-to? Can't figure it out ...

Thanks
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368020

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We're using the version that is in the SwingSet3 repo, which I believe was 1.03 (but could be slightly older).  I don't think it's newer than that.

The selectedProperty looks for a boolean property so: boldSelected -> public boolean isBoldSelected().  The selection state of the action is determined by this property.

The PCL determines if the current component is a viable target and then updates the action properties with updateTextActions.  Those setters all fire PC Events, which the Action listens for and respondes to.

Karl
[Message sent by forum member 'kschaefe' (kschaefe@...)]

http://forums.java.net/jive/thread.jspa?messageID=368041

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> We're using the version that is in the SwingSet3
> repo, which I believe was 1.03 (but could be slightly
> older).  I don't think it's newer than that.
>

hmm ... are you saying we have no option but to trial-and-error to re-compile without the restore session disabled?

> The selectedProperty looks for a boolean property so:
> boldSelected -> public boolean isBoldSelected().  The
> selection state of the action is determined by this
> property.
>
> The PCL determines if the current component is a
> viable target and then updates the action properties
> with updateTextActions.  Those setters all fire PC
> Events, which the Action listens for and respondes
> to.

another "hmmmm" :-) That's what I tried in SwingXSet, but getting funny behaviour if using such an action with a JCheckBoxMenuItem. Did something like

[code]
// the action and its selected property
    @Action (selectedProperty = "codeViewerVisible")
    public void toggleCodeViewerVisible() {
        setCodeViewerVisible(!isCodeViewerVisible());
    }
   
    public void setCodeViewerVisible(boolean selectorVisible) {
        boolean old = isCodeViewerVisible();
//        <snip> MultiSplit toggle visiility by constraint
        multiSplitLayout.displayNode("source", selectorVisible);
        ((JComponent) getMainFrame().getContentPane()).revalidate();
//        </snip>
        firePropertyChange("codeViewerVisible", old, isCodeViewerVisible());
        requestFocusOnDemo();
    }
 
   
    public boolean isCodeViewerVisible() {
        JComponent selector = getComponentByConstraint("source");
        return selector.isVisible();
    }

// using in a menu
       
        JMenuItem toggleCodeViewerVisible = new
             JCheckBoxMenuItem(getAction("toggleCodeViewerVisible"));

        // debug - toggles the visible property
        viewMenu.add(new JMenuItem(getAction("debugVisible")));

[/code]

problems:
- the initial selected state of the action is not taken, that is it's false
- the selected (and the visible) is not toggled when clicking the menu, only when clicking on the external (just for debugging) item

Probably missing something obvious ... any ideas what I'm doing wrong?

Thanks
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368051

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is the content of getAction(String)?  (Source code pointer is fine.)  Remember that there is a giant bug with the SAF that you need to maintain a copy of the ApplicationActionMap that generated the Action.  If you just grab the map and then the action from it, the map will die and the action will be useless.

Karl
[Message sent by forum member 'kschaefe' (kschaefe@...)]

http://forums.java.net/jive/thread.jspa?messageID=368062

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Below is some runnable code, pretty sure I'm doing something wrong, but can't work out what it is - too near to see ;-)

Thanks in advance for any pointers
 Jeanette

[code]
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;

import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.View;

public class ActionSelected extends SingleFrameApplication {


    JLabel label = new JLabel("something to hide");
    boolean selected = label.isVisible();

    @Action(selectedProperty = "selected")
    public void toggleSelected() {
        setSelected(!isSelected());
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        boolean old = isSelected();
        this.selected = selected;
        label.setVisible(selected);
        getMainView().getComponent().revalidate();
        getMainView().getComponent().repaint();
        firePropertyChange("selected", old, isSelected());
    }

    @Override
    protected void startup() {
        View view = getMainView();
        view.setComponent(createMainPanel());
        show(view);    
    }

    private JComponent createMainPanel() {
        JComponent panel = Box.createVerticalBox();
        JCheckBox box = new JCheckBox(getAction("toggleSelected"));
        panel.add(box);
        panel.add(label);
        return panel;
    }

    private javax.swing.Action getAction(String actionName) {
        return getContext().getActionMap().get(actionName);
    }

    public static void main(String[] args) {
        launch(ActionSelected.class, args);
    }

}

[/code]
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368064

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

overlapping posts :-)

> What is the content of getAction(String)?  (Source
> code pointer is fine.)  

grabs the action from the context ...

> Remember that there is a
> giant bug with the SAF that you need to maintain a
> copy of the ApplicationActionMap that generated the
> Action.  If you just grab the map and then the action
> from it, the map will die and the action will be
> useless.

hmm ... good to remember. But have a feeling that's not an issue here: the secondary action - the debugVisible which has no selected - works just fine. And all the others (we have a toggle font size) are okay as well.

Confused ...

Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368065

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> Edited the example to have an "external" action for
> toggling the selected property. Hmm ... maybe we
> can't have an action which acts on its
> selectedProperty? Round trip? But if so, it's rather
> meaningless ... head scratching ...

was near ... solution is to not do anything (at least nothing related to the selectedProperty) in the toggleSelection

[code]
    @Action(selectedProperty = "selected")
    public void toggleSelected() {
        // empty method
    }

[/code]

looks weird, doesn't it? Hunger prevents to get me start ranting again (about mix'in binding state into the action) ... Still open: initial state, starts off with not-selected, first click changes visual state of checkbox to selected, next changes both visual state and label visibility.

Okay, 'nough for today, cu tomorrow
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368093

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You have the action contents in the selected property stuff.  Consider this:

[code]
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
 
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.View;
 
public class ActionSelected extends SingleFrameApplication {

    JLabel label = new JLabel("something to hide");
    boolean selected = label.isVisible();
 
    @Action(selectedProperty = "selected")
    public void toggleSelected() {
        label.setVisible(selected);
        getMainView().getComponent().revalidate();
        getMainView().getComponent().repaint();
    }
 
    public boolean isSelected() {
        return selected;
    }
 
    public void setSelected(boolean selected) {
        boolean old = isSelected();
        this.selected = selected;
        firePropertyChange("selected", old, isSelected());
    }
 
    @Override
    protected void startup() {
        View view = getMainView();
        view.setComponent(createMainPanel());
        show(view);    
    }
 
    private JComponent createMainPanel() {
        JComponent panel = Box.createVerticalBox();
        JCheckBox box = new JCheckBox(getAction("toggleSelected"));
        panel.add(box);
        panel.add(new JButton(getAction("toggleExternal")));
        panel.add(label);
        return panel;
    }
 
    private javax.swing.Action getAction(String actionName) {
        return getContext().getActionMap().get(actionName);
    }
 
    public static void main(String[] args) {
        launch(ActionSelected.class, args);
    }
 
}[/code]

And you must cache that map that you get from getContext.

Karl
[Message sent by forum member 'kschaefe' (kschaefe@...)]

http://forums.java.net/jive/thread.jspa?messageID=368097

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Karl,

thanks for your input. The drawback of your approach is that the setSelected method (it can be called from anywhere, that's what the toggleExternal simulates) doesn't toggle the label's visibility.

Still think that this stuff is a bit ... ehem .. unexpected.

Cheers
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368103

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well the property methods are publicly visible because the SAF needs them to be, but they should not be considered part of the external API.

If you look at StyledTextActions, nothing in that class should be considered part of the public API except the static method install.  Everything else should be grabbed from the ApplicationActionMap, using one of the action names.

Theorectially, if the SAF moves into core (someday), then the visibility of the property methods could be reduced, since core code could break the visibility barriers as it sees fit with priveliged actions.  I guess it could do so now, but then the SAF would need to be signed to be used from with web start and I think that was to be avoided.

Karl
[Message sent by forum member 'kschaefe' (kschaefe@...)]

http://forums.java.net/jive/thread.jspa?messageID=368127

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Well the property methods are publicly visible
> because the SAF needs them to be, but they should not
> be considered part of the external API.
>

ehh ... no. I tend to see it the other way round (don't get side-tracked by the name :-) The whole point in having a checkbox is to bind it to something which is on or off. So whatever that is, it's most probably a public property, can't think of anything else - after all, the @action binding is supposed to reduce boiler plate code. As I already mentioned (there's an oldish thread in swing/awt where I ranted about action.selected in Mustang), the base problem is mixing of binding model properties and action selected state. Here we see the unintuitiv consquence, IMO.

Good night (or day :-)
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368143

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> > Well the property methods are publicly visible
> > because the SAF needs them to be, but they should
> not
> > be considered part of the external API.
> >
>
> ehh ... no. I tend to see it the other way round
> (don't get side-tracked by the name :-) The whole
> point in having a checkbox is to bind it to something
> which is on or off. So whatever that is, it's most
> probably a public property, can't think of anything

to clarify: I do agree that the @action annotation using the selectedProperty introduces  "artefact" api, only disagree on which is the artefact :-) Actually, I regard it as a somewhat hidden binding to a property which is the real stuff. To get that binding, we need a public do-nothing method which is the artefact.

[code]
    /**
     * Toggles the codeViewerVisible property.
     * <p>
     * Note: this is public as an implementation side-effect. DON'T USE!
     */
    @Action (selectedProperty = "codeViewerVisible")
    public void toggleCodeViewerVisible() {
    }
[/code]

Probably should document that fact even stronger, just too lazy ..

CU
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368207

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: SwingLabs-Demos: which version of appframework?

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> We're using the version that is in the SwingSet3
> repo, which I believe was 1.03 (but could be slightly
> older).  I don't think it's newer than that.
>

FYI: changed to use bsaf, simply to have a fixed version of a appframework which hopefully will evolve. Details in

https://swinglabs-demos.dev.java.net/issues/show_bug.cgi?id=19

the ea2 (which is the most recent) seems to be very near to 1.0.3, with storage reverted (that is functioning <g>). Also reverted is that intermediate fix for Action/Map-loss, so Actions can again be lost, as of

https://appframework.dev.java.net/issues/show_bug.cgi?id=82

which I think is not a big spoiler (in the swingxset itself) because the actions have a permanent reference to them, once set as the action of a button. But most probably will be fixed in bsaf again soon.

CU
Jeanette
[Message sent by forum member 'kleopatra' (fastegal@...)]

http://forums.java.net/jive/thread.jspa?messageID=368210

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...