[WIP report, hope to add some more details but this is better than nothing. :) ]
Problem
When Voxelshop first runs (and before .voxelshop is created AFAICT), it creates a directory named .profile.
On a Mac this is located at:
~/.profile/default.layout a.k.a $HOME/.profile/default.layout a.k.a. /Users/<username>/.profile/default.layout
This issue was also mentioned in passing in #295 (comment).
(I encountered this issue nearly a year after I first tried out Voxelshop and was only able to match the creation of the ~/.profile directory to Voxelshop because I noticed that the creation time was around the same time as~/.voxelshop.)
Apparent cause
After a lot of searching, I think I've identified why this is happening.
AFAICT the code that is creating the directory is in the (closed) portions of the com.jidesoftapplication framework--specifically the code related to layout persistence (primarily docking related?).
In JIDE_Docking_Framework_Developer_Guide.pdf there is a section that talks about layout persisting which mentions:
JIDE Docking Framework offers the ability to save windows information and settings between sessions, using the java.util.prefs package. This means that under Windows, the information will be stored in the registry, while under UNIX, it will be stored in a file in your home directory.
All layout data are organized under one key called the ‘profile key’. This can be any string, but usually it’s your company name (we use “jidesoft” in our sample application). You should call setProfileKey(String key) to set this key when your application starts up.
[...] The default set of preferences lies under the key “default”, and is used whenever loadLayoutData() and saveLayoutData() are called to persist the window state.
And later on:
Another option you have is to let the JIDE Docking Framework use its default file location. By default it uses java.util.prefs to store layout information. However if you prefer disk storage, but want JIDE to manage the location, you can call setUsePref(false) to disable using java.util.prefs. Your layout data will be stored at {user.home}/.{profileName}, where profileName is either “default” or your profile name as specified above. If you want to specify where to store the layout data, you can call setLayoutDirectory(String dirName). Please note, the directory will be used only when setUsePref is false. You also need to make sure you call set those values (i.e. setProfileKey(), setUsePref(), setLayoutDirectory()) before you call any loadLayout() or saveLayout() methods.
Note: My supposition is that the documentation is incorrect when it says the default profileName value is "default"; or, when the order of calls is incorrect the profileName is different (e.g. "profile" leading to .profile as the filename).
It's not entirely clear to me if the correct order is used in the relevant code:
|
// try to load the saved layout |
|
layoutPersistence.beginLoadLayoutData(); |
|
byte[] layoutData = (byte[]) preferences.loadObject("custom_raw_layout_data"); |
|
layoutPersistence.setUsePref(false); |
|
if(layoutData != null) { |
|
layoutPersistence.setLayoutRawData(layoutData); |
|
} else { |
|
layoutPersistence.loadLayoutData(); |
|
} |
Update: See comment below for a de-compilation of the relevant code, that explains what is happening behind the scenes.
Potential fix
It seems that a call to setProfileKey() (on the manager, or all classes that use layout persistence) needs to occur before any call to a method that directly or indirectly calls getLayoutDirectory().
Example setProfileKey() use:
Additional details
If ~/.profile exists as a file an error appears in the console:
10:08:00 PM Failed to create directory: /Users/<username>/.profile
Related links
[WIP report, hope to add some more details but this is better than nothing. :) ]
Problem
When Voxelshop first runs (and before
.voxelshopis created AFAICT), it creates a directory named.profile.On a Mac this is located at:
~/.profile/default.layouta.k.a$HOME/.profile/default.layouta.k.a./Users/<username>/.profile/default.layoutThis issue was also mentioned in passing in #295 (comment).
(I encountered this issue nearly a year after I first tried out Voxelshop and was only able to match the creation of the
~/.profiledirectory to Voxelshop because I noticed that the creation time was around the same time as~/.voxelshop.)Apparent cause
After a lot of searching, I think I've identified why this is happening.
AFAICT the code that is creating the directory is in the (closed) portions of the
com.jidesoftapplication framework--specifically the code related to layout persistence (primarily docking related?).In
JIDE_Docking_Framework_Developer_Guide.pdfthere is a section that talks about layout persisting which mentions:And later on:
Note: My supposition is that the documentation is incorrect when it says the default
profileNamevalue is"default"; or, when the order of calls is incorrect theprofileNameis different (e.g."profile"leading to.profileas the filename).It's not entirely clear to me if the correct order is used in the relevant code:
voxelshop/src/main/java/com/vitco/app/layout/WindowManager.java
Lines 533 to 541 in 4094dd1
Update: See comment below for a de-compilation of the relevant code, that explains what is happening behind the scenes.
Potential fix
It seems that a call to
setProfileKey()(on the manager, or all classes that use layout persistence) needs to occur before any call to a method that directly or indirectly callsgetLayoutDirectory().Example
setProfileKey()use:jide/demo/SimplestActionFrameworkDemo.javaAdditional details
If
~/.profileexists as a file an error appears in the console:Related links
AbstractLayoutPersistence:getLayoutDirectory()&setProfileKey()LayoutPersistence:getLayoutDirectory()&setProfileKey()LayoutPersistenceManager:setProfileKey()http://www.jidesoft.com/javadoc/com/jidesoft/action/DockableBarManager.html#methods_inherited_from_class_com.jidesoft.swing.LayoutPersistence
App loader:
com/vitco/app/glue/config.xmlhttps://github.com/simlu/voxelshop/blob/master/src/main/java/com/vitco/app/layout/LayoutLoader.java
https://www.jidesoft.com/jdaf/JIDE_Desktop_Application_Framework_Developer_Guide.pdfhttp://www.jidesoft.com/jdaf/http://www.jidesoft.com/products/oss.htmhttp://www.jidesoft.com/products/dock.htm