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


Permlink Replies: 4 - Pages: 1 - Last Post: 6 Feb 21, 09:22 Last Post By: AndreWolff
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Howe to determine the current folder in a Custom panel?
Posted: 5 Feb 21, 10:01
 
  Click to reply to this thread Reply
I tried to add Browse buttons to my custom panel. These buttons should calculate a relative path, so I used the same function I used already for the root folder:
    void getRelativePath(JTextField linkField, FileFilter filter) {
        File myOutputdirectory = rootOutputDirectory;
        etc.
But as you see it calculates the relative path with respect to the root folder.

So I have to change this and add as argument the current folder.

But how do I get the current folder in a custom panel, it can be 1, 2 or more levels deep.

Is there an easy solution to get that folder?
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: Howe to determine the current folder in a Custom panel?
Posted: 5 Feb 21, 10:51   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
The parent class of your custom UI class maintains a "currentAO" variable. You can query it for the folder name: currentAO.getParent(), or if you want a pure File reference: currentAO.getParent().getFile(). You might also like currentAO.getPathFromRoot().

I see that you also maintain a cAO variable. You may use it as well, but you can also dump it in favor of "currentAO". Having two variables for the same purpose is just confusing.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: Howe to determine the current folder in a Custom panel?
Posted: 5 Feb 21, 15:44   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
The parent class of your custom UI class maintains a "currentAO" variable. You can query it for the folder name: currentAO.getParent(), or if you want a pure File reference: currentAO.getParent().getFile(). You might also like currentAO.getPathFromRoot().
I did ask the wrong question, the correct question is:

How do I get the output folder which corresponds with the current image folder in a custom panel, it can be 1, 2 or more levels deep.

With your solution above I get a relative path to the current image folder instead of to the current output folder.

So is there a function which converts an image folder to the corresponding output folder?
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: Howe to determine the current folder in a Custom panel?
Posted: 5 Feb 21, 18:49   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:

So is there a function which converts an image folder to the corresponding output folder?
There is the AlbumSynchronizer API that helps you getting to the output folder structure, but it turns out that the nifty methods that gets you the final step to the corresponding thumbnails and closeup images is private, so here's a code snippet, that given an album object gives you the corresponding thumbnails and closeup images. The album object is called "selected" here (the code can be run from the system console, and then acts on the selected album object):
rootOutputDirectory = engine.getInterpretedOutputDirectory();
origFile = new File(rootOutputDirectory, selected.getPathFromRoot());
thumbDir = new File(origFile.getParentFile(), engine.getThumbnailDirectory());
thumbFile = new File(thumbDir, engine.getTargetThumbName(origFile.getName()));
slidesDir = new File(origFile.getParentFile(), engine.getSlideDirectory());
closeupFile = new File(slidesDir, engine.getTargetName(origFile.getName()));
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: Howe to determine the current folder in a Custom panel?
Posted: 6 Feb 21, 09:22   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
AndreWolff wrote:

So is there a function which converts an image folder to the corresponding output folder?
There is the AlbumSynchronizer API that helps you getting to the output folder structure, but it turns out that the nifty methods that gets you the final step to the corresponding thumbnails and closeup images is private, so here's a code snippet, that given an album object gives you the corresponding thumbnails and closeup images. The album object is called "selected" here (the code can be run from the system console, and then acts on the selected album object):
rootOutputDirectory = engine.getInterpretedOutputDirectory();
origFile = new File(rootOutputDirectory, selected.getPathFromRoot());
thumbDir = new File(origFile.getParentFile(), engine.getThumbnailDirectory());
thumbFile = new File(thumbDir, engine.getTargetThumbName(origFile.getName()));
slidesDir = new File(origFile.getParentFile(), engine.getSlideDirectory());
closeupFile = new File(slidesDir, engine.getTargetName(origFile.getName()));
I am not sure how to use this code, your answer in the other thread looks more useful for me.
Legend
Forum admins
Helpful Answer
Correct Answer

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