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


Permlink Replies: 8 - Pages: 1 - Last Post: 7 Dec 20, 05:03 Last Post By: AndreWolff Threads: [ Previous | Next ]
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
How to show a custom panel only for a folder?
Posted: 4 Dec 20, 13:29
 
  Click to reply to this thread Reply
I coded two custom panels, one for images and another for folder thumbs.

I like to show the folder custom panel only if a folder is selected.
I tried to do that with the next code at the end of the FancyBox.java file:
        JAlbumContext context = JAlbumContext.getInstance();
        PluginContext pc = context.getPluginContext();
        EditPanel editPanel = pc.getEditPanel();
 
  if (currentAO.getCategory() == Category.image) {
        PanoCustomUI CustomUI = new PanoCustomUI(context);
// Install panorama custom panel in Jalbum's edit panel
        editPanel.addCustomTab("Panoramic image", CustomUI);
}
        
    if (currentAO.getCategory() == Category.folder) {
        FancyBoxFolderCustomUI CustomUI2 = new FancyBoxFolderCustomUI(context);
// Install folder custom panel in Jalbum's edit panel
        editPanel.addCustomTab("FancyBox folder", CustomUI2);
    };
  }
However currentAO is not accepted here.
What should I add/change to get this done?
ctwist

Posts: 471
Registered: 27-Sep-2003
Re: How to show a custom panel only for a folder?
Posted: 4 Dec 20, 15:34   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
PanoCustomUI CustomUI = new PanoCustomUI(context);

This should be "customUI". You should only capitalize class names.
This does not answer your question.
ctwist

Posts: 471
Registered: 27-Sep-2003
Re: How to show a custom panel only for a folder?
Posted: 4 Dec 20, 16:06   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
You have two custom UI classes. I suggest that you should combine these into a single class. Within this class, choose which type of panel should be built.

Use David's example http://jalbum.net/help/en/Creating_a_custom_user_interface; make sure that you replicate his structure. The reference to currentAO will be processed later, when an album object has been established.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to show a custom panel only for a folder?
Posted: 4 Dec 20, 16:59   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
You have two custom UI classes. I suggest that you should combine these into a single class.
Well I did that in my first try, see the code here
Within this class, choose which type of panel should be built.
I have no idea how to do that so that you see different panel titles.

For a user it is more conveniant if he sees two panels, one which can be selected if an image is displayed and another for a folder thumbnail. He should see only one panel title at the time.
Use David's example http://jalbum.net/help/en/Creating_a_custom_user_interface; make sure that you replicate his structure. The reference to currentAO will be processed later, when an album object has been established.
That is an example of a non-compiled UI and people convinced me that I should use a compiled GUI.
My folder panel is very simple:
class FancyBoxFolderCustomUI extends JCustomPanel {
 
    JSmartTextField moreInfoURL = new JSmartTextField();
 
    public FancyBoxFolderCustomUI(JAlbumContext context) {
        super(context);
        new StateMonitor() {
            public void onChange() {
                saveUI();
            }
        }.add(moreInfoURL);
        setBackground(SystemColor.text);
        setOpaque(true);
        init();
    }
 
    public void setAlbumObject(AlbumObject ao) {
        removeAll();
        if (ao != null) {
            super.setAlbumObject(ao);
            boolean isFolder = currentAO.getCategory() == Category.folder;
            add(new JLabelFor("URL for 'More info' button:", moreInfoURL));
            add("br hfill", moreInfoURL);
            moreInfoURL.setEnabled(isFolder);
        }
    }
}
I came to this solution after looking into the Pluto skin code and it seems to work well.
But I like to see this panel only if the current edited item is a folder and the Panorama panel should disappear in the same way as the Location, Camera and Description panels do disappear for a folder.
ctwist

Posts: 471
Registered: 27-Sep-2003
Re: How to show a custom panel only for a folder?
Posted: 4 Dec 20, 18:54   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
ctwist wrote:
You have two custom UI classes. I suggest that you should combine these into a single class.
Well I did that in my first try, see the code here
This didn't work because it adds the fields to the custom panel in setAlbumObject(). Further details are later in this message.
Use David's example http://jalbum.net/help/en/Creating_a_custom_user_interface; make sure that you replicate his structure.
That is an example of a non-compiled UI and people convinced me that I should use a compiled GUI.
It is Java code. It can be run as a script or within a class.
BTW Ignore the "set up the ui" section because you can't do this until you know the album object type.
I came to this solution after looking into the Pluto skin code and it seems to work well.
But I like to see this panel only if the current edited item is a folder.
So in your circumstances it doesn't work well.

Edited by: ctwist on 06-Dec-2020 23:03

Suggestion at the end removed; it wasn't entirely accurate.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to show a custom panel only for a folder?
Posted: 4 Dec 20, 23:16   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Well Chris I appreciate that you tried to help me, but the two panels in two files do work although I hardly understand the code (I am not a JAVA programmer). The Panorama panel code is mainly coded by Heinz-Peter Bader (Dschuwi), see here, I am glad it works and I don't like to change the code. I could change the folder panel code, but that will not help to get what I like to accomplish.

I did hope that I could select the correct panel with the type of code I showed above but apparently is currentAO not a global variable I could use there. If such a selection is not possible, I will use two panels I think.

Thanks for your help!
ctwist

Posts: 471
Registered: 27-Sep-2003
Re: How to show a custom panel only for a folder?
Posted: 5 Dec 20, 00:38   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
When you have a working version of CustomUI, send the skin to me. I can probably provide alternative contents in a single panel in 15 minutes.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to show a custom panel only for a folder?
Posted: 5 Dec 20, 09:09   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Attachment FancyBox.jaskin (1.3 MB)
ctwist wrote:
When you have a working version of CustomUI, send the skin to me. I can probably provide alternative contents in a single panel in 15 minutes.
The sources are send by mail, the jaskin file is attached.

Thanks in advance!

André
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to show a custom panel only for a folder?
Posted: 5 Dec 20, 10:33   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Well with your suggestion and the info in this thread I could tune the this custom GUI code:
class FancyBoxCustomUI extends JCustomPanel {
 
    AlbumObject cAO;
    AlbumObjectProperties cProps;
    JCheckBox panoramicSphericalImage = new JCheckBox("Spherical panoramic image", false);
    JCheckBox panoramicImage = new JCheckBox("Cylindrical panoramic image", false);
    JCheckBox pan360 = new JCheckBox("<html>360° panorama</html>", false);
    JSmartTextField moreInfoURL = new JSmartTextField();
 
    public void setAlbumObject(AlbumObject ao) {
        super.setAlbumObject(ao);
        removeAll();
        if (ao != null) {
            cAO = ao;
            cProps = cAO.getProperties();
            File currentContextFile = ao.getFile();
            boolean isFolder = cAO.getCategory() == Category.folder;
            boolean isImage = cAO.getCategory() == Category.image;
            if (isFolder) {
                add(new JLabelFor("URL for 'More info' button:", moreInfoURL));
                add("br hfill", moreInfoURL);
                moreInfoURL.setEnabled(isFolder);
            } else {
                add("br", panoramicSphericalImage);
                add("br", panoramicImage);
                add("br", pan360);
                panoramicSphericalImage.setEnabled(isImage);
                panoramicImage.setEnabled(isImage);
                pan360.setEnabled(isImage);
                pan360.setEnabled(panoramicImage.isSelected());
            }
            loadUI();
      
Now at least the contains for a folder and for an image are completely different.

It is still not what I had in mind: I like to see this panel only if the current edited item is a folder and the Panorama panel should disappear in the same way as the Location, Camera and Description panels do disappear for a folder.
The panel should have different titles for a folder and an image
But this comes close!
Legend
Forum admins
Helpful Answer
Correct Answer

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