MD initial home page (open/create/import file page) hooks

florian.delizy's Avatar

florian.delizy

05 Feb, 2012 09:46 AM

Hi all,

I am trying to create a svn integration plugin for moneydance, and I would have a few questions regarding the initial home page hooks :

So far, I can register my module and detect when the initial home is displayed (that is, when I get the "md:file:opened" event, and that getContext().getRootAccount() or getContext().getRootAccount().getDataFile() returns null).

Now, the problem is, is there a way to add a button onto that page ? I would like to add a "SVN checkout" button, allowing the user to retreive the data file from the svn repository …

Regards,

  1. 1 Posted by florian.delizy on 05 Feb, 2012 09:53 AM

    florian.delizy's Avatar

    btw, I did posted that on the ML before I realised everything moved in here (might be a good thing to state this explicitely on moneydance developer page for noobs like me ;) )

  2. 2 Posted by Kevin Stembridg... on 05 Feb, 2012 10:00 AM

    Kevin Stembridge's Avatar

    Hi Florian,
    Sounds like a great idea for a plugin.

    I think what you want is a HomePageView. You can see an example of how to implement one in the following code:
    http://code.google.com/p/moneydance-forecaster/source/browse/tags/m...
    http://code.google.com/p/moneydance-forecaster/source/browse/tags/m...

    Cheers,
    Kevin

  3. 3 Posted by florian.delizy on 05 Feb, 2012 10:09 AM

    florian.delizy's Avatar

    Hum,

    correct me if I am wrong, but isn’t the HomePageView only integrating into the HomePage (that is, the frame displayed when there already is a dataFile loaded ?)

    I am looking to integrate into the startup page , that is, before any datafile is created.

    So far, I tried to get the underlying JFrame object of the startup page, but for some reasons :

    java.swing.Frame.getFrames() returns an empty array O_o ? (meaning that the frame displayed as the startup screen is actually … not a frame …).

    Any other idea ?

  4. 4 Posted by florian.delizy on 05 Feb, 2012 10:23 AM

    florian.delizy's Avatar

    hum, I meant

    java.awt.Frame.getFrames()

    (not swing).

    btw, java.awt.Window.getWindows() get me the same result :-/

  5. 5 Posted by Kevin Stembridg... on 05 Feb, 2012 10:53 AM

    Kevin Stembridge's Avatar

    Yes, you're correct. The HomePageView is just for the home page. Sorry, I thought that was the page you were referring to.

    So if I understand you correctly, you want to be notified before the data file is loaded and then display a button that allows the user to perform an svn checkout of some other data file and load that one instead.

    If that's the case then I don't think it would be a big deal to allow Moneydance to complete its normal startup with the default data file and then give the user the option to switch to a different data file, the one in svn.

    Maybe I don't understand your use case very well. I was thinking that the main benefit of using svn was for the version history aspect of it. i.e. this would allow the user to roll back to a previous version of the file. Can you describe the use cases you had in mind?

  6. 6 Posted by florian.delizy on 05 Feb, 2012 11:02 AM

    florian.delizy's Avatar

    Well, I guess I should explain my goal a little further then :

    Think of a workgroup in which all moneydance data files are stopred onto an svn server. That allows different operators to work on the same file (but not simultaneously off course). Then, the workflow must stick with svn, that is :

    • Before you work on a new file, first check it out of the svn tree (svn checkout)
    • If you already have a working copy of your file, then update it (svn update) or at least check that no new version is present on the server
    • Check that the file is not locked (otherwise conflicts may happen), if so open readonly
    • Lock your file on the depot (svn lock) to prevent other to modify it while you do
    • work on your file (modifications)
    • upon exiting, commit and ulock the file (svn commit)

    The point is then, that I need to integrate at different places :

    1. First on the startup screen to allow to user to choose to open a file from the svn server (that is, checking it out into a local directory then open it)
    2. Then before the file is loaded (to check that no new version is present on the server, and that the file itself is not locked by another user)
    3. And finally upon exiting (to send modifications to the server)

    I am currently trying to figure out a way to do 1 and 2

  7. 7 Posted by Kevin Stembridg... on 05 Feb, 2012 03:47 PM

    Kevin Stembridge's Avatar

    Sounds interesting. I'm afraid I don't know about any hooks though. Maybe one of the Moneydance developers will chip in with some advice.

  8. 8 Posted by florian.delizy on 05 Feb, 2012 03:51 PM

    florian.delizy's Avatar

    Anyway, for now, I can use the (very) ugly way to show a popup when the startup screen is displayed offering the choice to checkout a document from the server …

    But man I hate popups (especially like this).

  9. 9 Posted by florian.delizy on 05 Feb, 2012 10:40 PM

    florian.delizy's Avatar

    After some research, it seems that what I am looking like is tapping into the StartupWindow object created in the MoneydanceGUI object upon startup.

    Now the problem is that the code I saw is from the moneydance.jar shipped with MD, but is not present in the extension itself. Moreover, in that software the StartWindow is a local variable (local to a local block of the MoneydanceGUI.run() method), so there is nothing to access this particular object.

    Now, what really bother me is that the StartupWindow object inherits from JFrame, which should make it detectable using the java.awt.Frame.getFrames() way …

    OK, this is where I would be glad to have some info from the MD developers here.

  10. 10 Posted by florian.delizy on 06 Feb, 2012 11:15 AM

    florian.delizy's Avatar

    Well, I found a super uber ugly way out :

    1. first in my ant build.xml file, I add the mainstream moneydance.jar :

      <pathelement path="/opt/Moneydance/moneydance.jar"/>

    2. I create a class to override com.moneydance.apps.md.view.gui.StartupWindow

    3. I add everything I need to it
    4. when I detect (using events) that the startupwindow is being shown, I display mine too

    this way I do have a customized startupwindow, but for now it show first (under the default one). So to be sure that mine is gonna show up, I use

    JFrame.setAlwaysOnTop(true)
    

    Once the startup window does its job it will exit the two displayed window anyway, so that seems to work :)

    Ok, I warned you, this is super uber ugly !

  11. 11 Posted by robwilkens on 06 Feb, 2012 03:51 PM

    robwilkens's Avatar

    Wouldn't it be easier for what you're doing to just create a wrapper/launcher for instead of an add in? i.e. Click this OTHER icon to run money dance, before launching money dance, which would do the cvs/svn magic to pull the file, run money dance from within your program, on exit your launcher could push the cvs/svn file back onto the server. I say this because I don't know about you but for me, Moneydance doesn't usually pop up that startup window you mention, once you've told it where the file is, it seems smart enough to just open it next time without prompting you. As a result, i don't think an add in that runs when the startup screen pops up would be terribly useful.

  12. 12 Posted by florian.delizy on 06 Feb, 2012 04:08 PM

    florian.delizy's Avatar

    Indeed, but the startup process is only part of the integration.

    The rest will also happen magically (based on events), so that when you open a file already in a svn workcopy the plugin will be aware of it.

    Well, I’ll keep my hack as long as a dev don’t drop by here to give a better way (for now it works pretty well).

  13. System closed this discussion on 31 Mar, 2015 03:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac