This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 10 - Pages: 1 - Last Post: 11 Feb 21, 13:56 Last Post By: JeffTucker Threads: [ Previous | Next ]
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 00:51
 
  Click to reply to this thread Reply
Attachment JPtest.jaskin (22.5 KB)
A few years back, I struggled with including a JPlaylist in a custom popup. In short, the problem was that once you had used the "add" button in the JPlaylist component, it became unresponsive, for example, when trying to use it for the next object. It took a "close and reopen" of the project to shake it loose.

At the time, I was using some ancient frame code, and finally found a workaround. But David suggested using a JDialog instead of a frame. That old thread, from this post down:

https://jalbum.net/forum/thread.jspa?messageID=324573#324573

Fast forward to today, and that's what I'm doing with my custom popups - using a dialog box. Works beautifully, except with a JPlaylist, which exhibits the old bad behavior. No problem with saving or retrieving the entries, but after you've used it once, you can't use it again.

Attached is a very skeletal skin. Add a few images. Go into edit mode for the first image and add some music tracks (in the real world, this would be restricted to folders, but I wanted to keep this as stripped-down as possible). OK out of the popup, and move to the next image. Try to add music tracks. You can't. Close and reopen, and it's fine again.

Here's the entire code for the custom UI:
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import se.datadosen.component.*;
import se.datadosen.jalbum.JAlbumContext;
import se.datadosen.jalbum.JCustomPanel;
class JPtestCustom extends JCustomPanel {
    JButton popupButton = new JButton("Local Music Tracks");
    JPlaylist mtracks = new JPlaylist();
    String popupTitle;
    public JPtestCustom(JAlbumContext context) {
        super(context);
        setOpaque(false);
        add("center", popupButton);
        ControlPanel popup = new ControlPanel() {
            {
                add(mtracks);
            }  
        };
        popupButton.addActionListener((ActionEvent e) -> {
            popupTitle = "Music Tracks for: " + currentAO.getName();
            JOptionPane.showMessageDialog(context.getExplorer(), popup, popupTitle, JOptionPane.INFORMATION_MESSAGE);
        });
        init();
    }
}
Anyone have a clue about how to shake the JPlaylist loose following a close of the dialog box?

ETA: All source files bundled with the skin.
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 14:15   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
One more little tidbit.... If I plant the JPlaylist directly in the custom UI panel, rather than in a popup dialog box, there's no problem. Failing a solution to this problem, that's the route I'll probably follow. But it would be nice to keep the custom UI panel smaller and less cluttered.
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 19:07   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
I've been debugging this and it beats me :-(. I suppose the inner file chooser component (XFileChooser) becomes confused somehow, but I can't trigger any low level error messages. I've now swapped the XFileChooser component to a JNA (Java Native Access) based one, so no more reliance on the xfilechooser.jar and xfilechooser.dll files. Now it works. The only downside of this switch is that we can no longer set the default file chooser view mode to showing thumbnails. I think it's worth the switch in spite of that downside.

Just do a core update to try the new code. You should be able to remove the "xfiledialog*" files from "lib" now.
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 20:10   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
That does appear to cure the error. I'll have to do some more experimenting with it to be sure, but at the moment, I still have over a foot of fresh, heavy snow on part of my driveway. Tackled the bulk of it this morning, but I still have to spend some more quality time with my monster snow blower.

I noticed a little strangeness in the positioning of the chooser window - on the first hit, it was anchored to the lower right of the monitor. Once I manually moved it up to the center, things returned to normal. But after a relaunch, it was back to the lower right. It's as if it's confused about the location of its parent window. A chooser launched from the custom panel itself, rather than from a popup, behaves more normally. Not a show-stopper, certainly. Just odd.
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 21:17   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Attachment 20210202_144115.jpg (603.6 KB)
Other than the little window-positioning quirk, this looks solid.

Done with the driveway. Is it too early to start drinking?
RobM

Posts: 3,808
Registered: 4-Aug-2006
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 22:32   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
I just tried the test skin on my Mac, using jAlbum 23.1.4 - no core update for the new mod.
I select a folder and then enter edit mode, click load music tracks and add a file then click OK to close the dialogue. Click load music tracks again and I can select further tracks to add. Either I'm misunderstanding the issue or it might just be a Windows only issue.
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 2 Feb 21, 22:47   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I'll have to try it on my Mac. I suspect this is a Windows thing, however, since it's calling a file chooser from the OS.

ETA: Confirmed. It's purely a Windows issue. And after the core update, the window positioning quirk is, likewise, seen only in Windows.
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: Stuck JPlaylist in custom popup
Posted: 3 Feb 21, 11:03   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Yes, it's a Windows-only issue and now we have one less library to rely on (XFileChooser)
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 10 Feb 21, 21:05   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
One annoying little side effect of the change in file chooser. If you launch the skin editor - Tools > Skin developer > Edit skin files - the editor opens the top level of skin files. But if you then choose File > Open, the file chooser opens to the last location that was used, which might be almost anywhere in the file system, instead of opening to the skin directory.

This is a small annoyance, but I did notice it!
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: Stuck JPlaylist in custom popup
Posted: 11 Feb 21, 13:49   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Good that you noticed that one. In fact, the initial directory is ignored altogether. I've got a fix for it now in the upcoming release
JeffTucker

Posts: 8,037
Registered: 31-Jan-2006
Re: Stuck JPlaylist in custom popup
Posted: 11 Feb 21, 13:56   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Not a big deal. There are probably very few people editing skin files from within jAlbum. I usually stick to my own text editor, using the internal editor only for making quick changes to a copy of Minimal to check something out.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums