Permlink Replies: 8 - Pages: 1 - Last Post: 21-May-2018 09:47 Last Post By: davidekholm Threads: [ Previous | Next ]
ctwist

Posts: 544
Registered: 27-Sep-2003
Tool techniques
Posted: 17-May-2018 23:34
  Click to reply to this thread Reply
Today I published my first tool, SettingsConverter. I reviewed some existing tools to find out how to write it, but I could not find every technique that I needed, so most of it is new development.

This is a list of the techniques that I used. The source code is published, but I can provide additional details if necessary.
  • Written in compiled Java, using Eclipse. I avoid BeanShell abandonware whenever possible.
  • The behaviour is skin-dependent. For each skin, a simple plugin skinname.java must be written. The tool processes the plugin for the current skin via Java Reflection.
  • For each skin, the earliest supported version of the skin and jAlbum are specified. The tool refuses to run against earlier versions.
  • A cumulative log of changes is saved in the root image directory.
  • It can run in preview mode, which logs the changes without changing anything.
  • A converted setting is saved as a skin variable, AlbumObject variable or AlbumObject user variable.
  • It can run repeatedly for the same project; this ignores previously converted settings.
  • When complete, a message shows the status of the conversion. If changes were saved or previewed, a button is available to open the log file.

Edited by: RobM on 18-May-2018 14:58
Added link to the tool
davidekholm

Posts: 3,550
Registered: 18-Oct-2002
Re: Tool techniques
Posted: 18-May-2018 15:55   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
"Converted setting"? Can you explain what you mean? Thanks for contributing with new tools!. PS. I guess you forgot to include/attach the tool.
ctwist

Posts: 544
Registered: 27-Sep-2003
Re: Tool techniques
Posted: 18-May-2018 16:11   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
The tool is attached in the External Tools and Plugins forum. SettingsConverter.pdf explains everything.

I created a separate message here because I didn't want to "clutter" the other forum with development techniques; this could confuse end users.
ctwist

Posts: 544
Registered: 27-Sep-2003
Re: Tool techniques
Posted: 18-May-2018 16:34   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
There are two problems with SettingsConverter that I could not fix.

The tool changes some skin settings or AlbumObject settings for the current project. There is a possibility that jAlbum will overwrite these changes with its cached settings. To prevent this, in the instructions I specify that you must open the project immediately before running the tool and close it immediately afterwards.

1) When the tool starts, I want to verify that there are no unsaved project settings. If there are unsaved changes, the tool should terminate. I checked
engine.isDirty()
but this always returns true, even if the project has just been opened. Is there a way to detect if there are any unsaved changes?

2) When the tool finishes, I want to automatically close the project. Is there any way I can do this?
davidekholm

Posts: 3,550
Registered: 18-Oct-2002
Re: Tool techniques
Posted: 18-May-2018 21:40   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
The isDirty() method signals if the existing album needs to be refreshed with yet another "make album" operation. It doesn't signal if you have unsaved settings.

Before answering more, can I ask you: Are you manipulating jAlbum's .info files directly? You should never do that, instead use the APIs.
ctwist

Posts: 544
Registered: 27-Sep-2003
Re: Tool techniques
Posted: 19-May-2018 15:55   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
Are you manipulating jAlbum's .info files directly?
This is how I do it.

Get a user variable:
AlbumObject vAlbumObject;
.......
AlbumObjectProperties vProperties = vAlbumObject.getProperties();
if (vProperties != null)
{ HashMap vUserVariables = (HashMap) vProperties.get(AlbumObjectProperties.USER_VARIABLES);
  String vUserVariable = vUserVariables.get(pUserVarName)
}
Save a user variable:
if (vUserVariables == null)
{ vUserVariables = new HashMap();
}
vUserVariables.put(vUserVariableName, pSrcValue);
vProperties.put(AlbumObjectProperties.USER_VARIABLES, vUserVariables);
vProperties.save(false);


Edited by: ctwist on 19-May-2018 10:13
Added initialization of user variables.
davidekholm

Posts: 3,550
Registered: 18-Oct-2002
Re: Tool techniques
Posted: 20-May-2018 19:31   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
That's fine Chris, so why the need to close and reopen projects?
ctwist

Posts: 544
Registered: 27-Sep-2003
Re: Tool techniques
Posted: 20-May-2018 20:40   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
In one of my tests, after running SettingsConverter, I closed the project. jAlbum asked me if I wanted to save the project changes and I replied "Yes". After I re-opened the project I noticed that one of the converted settings had reverted to its previous value. My assumption was that jAlbum saved the original value.

So, to be safe, I want to avoid jAlbum and SettingsConverter from tripping over each other. Without knowing the internals of jAlbum, I am being extra cautious.
davidekholm

Posts: 3,550
Registered: 18-Oct-2002
Re: Tool techniques
Posted: 21-May-2018 09:47   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
I see. Thanks for providing this. I can't know what triggered the save changes warning. If you want to know, set debug level to FINE, then inspect jAlbum's system console after such a message has been triggered. It will then print what settings differ. Making changes via jAlbum's API's like you do should be fine.
Legend
Forum admins
Helpful Answer
Correct Answer

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