From: Johann G. <jo...@gy...> - 2008-11-30 19:30:07
|
Hi all, I'm about to start to do another release of the JMoney project. Please tell me what the appropriate time frame would be to do so. My next steps will be to review and clean up code and then switch to Eclipse 3.4. Currently, however, the plugins do not even build because of a missing class: net.sf.jmoney.views.SectionlessPage. Was this class removed by accident? Thanks, Johann On Wed, Sep 3, 2008 at 00:14, <jav...@mi...> wrote: > Yes, another release is certainly due. > > I will be very happy if you switch to Eclipse 3.4. I have done some work on an Equinox p2 deployment of JMoney from WebStart. It is no quite working, but that would require 3.4. I have a few other partially completed bits of work that I really need to get checked-in. This includes replacing the navigation view with the Common Navigator Framework. This will allow developers to add to the navigation view using the more standard and flexible extensions in the CNF instead of our custom extension point developed way back in 2004. The tables are usable, but have quite a few problems that really need to be fixed - I have just learnt to bypass the problems when I am doing mine own accounts. The stock plug-in is not usable at this point of time, but is very close to being so. Those are the things I will be working on. > > Just wondering what areas you were thinking of in your cleanup? I am certainly keen on any ways we can make the programming model simpler, both for maintenance reasons and to make it as easy as possible for others to develop plug-ins. > > Nigel > > >> -------Original Message------- >> From: Johann Gyger <jo...@gy...> >> Subject: Re: [jmoney-devel] Submitting GnucashXML plugin changes to the JMoney project. >> Sent: 02 Sep '08 20:06 >> >> Hi Mark, >> >> The patches are absolutely OK. I had a glance at your code and it is >> definitively better than the existing Gnucash importer code. So I >> propose to add you as a commiter. Please subscribe to jmoney-devel and >> jmoney-cvs (Subversion commit mails, was CVS before). >> >> Generally, I'd like to do some clean up, switch to Eclipse 3.4 and >> make another release out of it. >> >> @Nigel: What do you think? >> >> Regards, >> Johann >> >> >> On Tue, Sep 2, 2008 at 12:50 AM, Mark Kendall <ma...@ma...> wrote: >> > Hi Johann, >> > >> > I have attached the patch files to this email. I believe I have included all >> > the files I have changed, but let me know if you find that I might have left >> > any files out. >> > >> > Thanks for your help, >> > Mark >> > >> > Johann Gyger wrote: >> >> >> >> Hi Mark, >> >> >> >> Creating a patch file with Eclipse is actually pretty easy. Select the >> >> project(s) in Package Explorer and select Team > Create Patch... The >> >> wizard is self explaining. Send the patch file to this list and I will >> >> have a look at it. >> >> >> >> Regards, >> >> Johann >> >> >> >> >> >> On Mon, Sep 1, 2008 at 7:16 PM, Mark Kendall <ma...@ma...> wrote: >> >> >> >>> >> >>> Hi Johann, >> >>> >> >>> Thanks for the reply. I think the best way for me to submit changes is >> >>> to post a patch file instead of having commit rights. I am new to Java >> >>> programming (my native language is C++), so out of my ignorance I may >> >>> not always follow good Java programming practices. I would prefer to >> >>> have my changes reviewed before they are committed permanently to the >> >>> JMoney project. I'll submit my changes as soon as I can figure out how >> >>> to create a patch file. Can you give me any advice on how to create the >> >>> patch files? FYI, in order to get the Gnucash plugin to work I modified >> >>> the net.sf.jmoney.views.NavigationView.java and the >> >>> net.sf.jmoney.gnucashXML.GnucashXML.java files. Also, I would welcome >> >>> any advice or criticism you might have on my Java programming. >> >>> >> >>> My commercial project that I have in mind is actually a series of >> >>> personal information manager programs that all have a common theme. >> >>> Something like a suite of personal programs. I own a sole-proprietorship >> >>> company, called MKware Systems, and right now I am the only employee of >> >>> the company and the only developer on this project. Since I am the only >> >>> developer on this project, I thought I would use open source software to >> >>> help save development time. I think JMoney would be a great addition to >> >>> the suite of PIM programs I 'm developing. >> >>> >> >>> In order to satisfy the GPL license, it's my intention to submit for >> >>> review, and possible inclusion in the original JMoney project, any >> >>> changes or modifications I do to the JMoney source code. In addition, I >> >>> will make sure that the entire source code is available for the final >> >>> release of the project according to the terms of the GPL license. I >> >>> believe that making the source available will satisfy the GPL license. >> >>> In any case, I would like to work with you in a collaborative effort to >> >>> make JMoney and my project both a success. >> >>> >> >>> Sincerely, >> >>> Mark >> >>> >> >>> Johann Gyger wrote: >> >>> >> >>>> >> >>>> Hi Mark, >> >>>> >> >>>> Thanks for your interest in JMoney and as an open source project we >> >>>> are always interested in contributions. There are two possibilities: >> >>>> either you provide/post a patch file for review or we will give you >> >>>> commit rights. In order to do so wie need you SF login-id >> >>>> >> >>>> What sort of commercial project are you planning to start? Be aware >> >>>> that JMoney itself is licensed under GPL. >> >>>> >> >>>> Regards, >> >>>> Johann >> >>>> >> >>>> >> >>>> On Sat, Aug 23, 2008 at 10:46 PM, Mark Kendall <ma...@ma...> >> >>>> wrote: >> >>>> >> >>>> >> >>>>> >> >>>>> Hi All, >> >>>>> >> >>>>> My name is Mark Kendall and I have an interest in using JMoney as a >> >>>>> base >> >>>>> for a commercial project. I have started development work on this >> >>>>> project and since I currently use Gnucash for tracking my personal >> >>>>> finances, I thought I would start my project by getting the GnucashXML >> >>>>> plugin to work. I have made modifications to the net.sf.jmoney and >> >>>>> net.sf.jmoney.gnucashXML plugins and I have now been successful in >> >>>>> getting the GnuCashXML plugin to import Gnucash files. In the spirit of >> >>>>> Open Source Software I would like to contribute my changes to the >> >>>>> JMoney >> >>>>> project. I have never worked on an open source project before so I >> >>>>> don't >> >>>>> know how to submit changes. Would you be interested in the changes I >> >>>>> made to JMoney? If so, please let me know how I can submit the changes. >> >>>>> In any case, thanks for all your good work on the JMoney project. >> >>>>> >> >>>>> Sincerely, >> >>>>> Mark >> >>>>> >> >>>>> >> >>>>> >> >>>>> ------------------------------------------------------------------------- >> >>>>> This SF.Net email is sponsored by the Moblin Your Move Developer's >> >>>>> challenge >> >>>>> Build the coolest Linux based applications with Moblin SDK & win great >> >>>>> prizes >> >>>>> Grand prize is a trip for two to an Open Source event anywhere in the >> >>>>> world >> >>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> >>>>> _______________________________________________ >> >>>>> jmoney-devel mailing list >> >>>>> jmo...@li... >> >>>>> https://lists.sourceforge.net/lists/listinfo/jmoney-devel >> >>>>> >> >>>>> >> >>>> >> >>>> >> >>>> ------------------------------------------------------------------------- >> >>>> This SF.Net email is sponsored by the Moblin Your Move Developer's >> >>>> challenge >> >>>> Build the coolest Linux based applications with Moblin SDK & win great >> >>>> prizes >> >>>> Grand prize is a trip for two to an Open Source event anywhere in the >> >>>> world >> >>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> >>>> _______________________________________________ >> >>>> jmoney-devel mailing list >> >>>> jmo...@li... >> >>>> https://lists.sourceforge.net/lists/listinfo/jmoney-devel >> >>>> >> >>>> >> >>>> >> >>> >> >>> ------------------------------------------------------------------------- >> >>> This SF.Net email is sponsored by the Moblin Your Move Developer's >> >>> challenge >> >>> Build the coolest Linux based applications with Moblin SDK & win great >> >>> prizes >> >>> Grand prize is a trip for two to an Open Source event anywhere in the >> >>> world >> >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> >>> _______________________________________________ >> >>> jmoney-devel mailing list >> >>> jmo...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/jmoney-devel >> >>> >> >>> >> >> >> >> >> > >> > Index: src/net/sf/jmoney/views/NavigationView.java >> > =================================================================== >> > --- src/net/sf/jmoney/views/NavigationView.java (revision 710) >> > +++ src/net/sf/jmoney/views/NavigationView.java (working copy) >> > @@ -275,10 +275,19 @@ >> > } >> > >> > @Override >> > - public void objectInserted(ExtendableObject newObject) { >> > + public void objectInserted(final ExtendableObject newObject) >> > { >> > if (newObject instanceof Account) { >> > - Object parentElement = >> > contentProvider.getParent(newObject); >> > - viewer.insert(parentElement, newObject, 0); >> > + >> > getSite().getShell().getDisplay().asyncExec(new Runnable() { >> > + public void run() { >> > + Object parentElement = >> > contentProvider >> > + >> > .getParent(newObject); >> > + viewer.insert(parentElement, >> > newObject, 0); >> > + >> > viewer.refresh(TreeNode.getTreeNode(AccountsNode.ID), >> > + false); >> > + >> > viewer.refresh(TreeNode.getTreeNode(CategoriesNode.ID), >> > + false); >> > + } >> > + }); >> > } >> > } >> > >> > @@ -301,7 +310,7 @@ >> > } >> > >> > @Override >> > - public void objectChanged(ExtendableObject changedObject, >> > + public void objectChanged(final ExtendableObject >> > changedObject, >> > ScalarPropertyAccessor propertyAccessor, >> > Object oldValue, >> > Object newValue) { >> > if (changedObject instanceof Account >> > @@ -306,7 +315,15 @@ >> > Object newValue) { >> > if (changedObject instanceof Account >> > && propertyAccessor == >> > AccountInfo.getNameAccessor()) { >> > - viewer.update(changedObject, null); >> > + >> > getSite().getShell().getDisplay().asyncExec(new Runnable() { >> > + public void run() { >> > + viewer.update(changedObject, >> > null); >> > + >> > viewer.refresh(TreeNode.getTreeNode(AccountsNode.ID), >> > + false); >> > + >> > viewer.refresh(TreeNode.getTreeNode(CategoriesNode.ID), >> > + false); >> > + } >> > + }); >> > } >> > } >> > >> > @@ -347,8 +364,7 @@ >> > if (memento != null) { >> > // Restore any session that was open when the >> > workbench >> > // was last closed. >> > - session = JMoneyPlugin.openSession(memento >> > - .getChild("session")); //$NON-NLS-1$ >> > + session = >> > JMoneyPlugin.openSession(memento.getChild("session")); //$NON-NLS-1$ >> > } else { >> > session = null; >> > } >> > @@ -1149,4 +1165,4 @@ >> > public void setFocus() { >> > viewer.getControl().setFocus(); >> > } >> > -} >> > \ No newline at end of file >> > +} >> > >> > ### Eclipse Workspace Patch 1.0 >> > #P net.sf.jmoney.gnucashXML >> > Index: META-INF/MANIFEST.MF >> > =================================================================== >> > --- META-INF/MANIFEST.MF (revision 675) >> > +++ META-INF/MANIFEST.MF (working copy) >> > @@ -12,5 +12,7 @@ >> > net.sf.jmoney.gnucashXML.actions >> > Require-Bundle: org.eclipse.ui, >> > org.eclipse.core.runtime, >> > - net.sf.jmoney >> > + net.sf.jmoney, >> > + org.eclipse.ui.ide, >> > + org.eclipse.core.resources >> > Eclipse-LazyStart: true >> > Index: plugin.xml >> > =================================================================== >> > --- plugin.xml (revision 675) >> > +++ plugin.xml (working copy) >> > @@ -22,5 +22,16 @@ >> > id="net.sf.jmoney.gnucashXML.actions.gnucashXMLExport"/> >> > </actionSet> >> > </extension> >> > + <extension >> > + point="org.eclipse.ui.importWizards"> >> > + <wizard >> > + class="net.sf.jmoney.gnucashXML.wizards.GnucashImportWizard" >> > + id="net.sf.jmoney.gnucashXML.ImportWizard" >> > + name="Gnucash Import"> >> > + <description> >> > + Import data from a Gnucash file. >> > + </description> >> > + </wizard> >> > + </extension> >> > >> > </plugin> >> > Index: src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizard.java >> > =================================================================== >> > --- src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizard.java >> > (revision 0) >> > +++ src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizard.java >> > (revision 0) >> > @@ -0,0 +1,113 @@ >> > +/* >> > + * >> > + * JMoney - A Personal Finance Manager >> > + * Copyright (c) 2004 Nigel Westbury <wes...@us...> >> > + * >> > + * >> > + * This program is free software; you can redistribute it and/or modify >> > + * it under the terms of the GNU General Public License as published by >> > + * the Free Software Foundation; either version 2 of the License, or >> > + * (at your option) any later version. >> > + * >> > + * This program is distributed in the hope that it will be useful, >> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> > + * GNU General Public License for more details. >> > + * >> > + * You should have received a copy of the GNU General Public License >> > + * along with this program; if not, write to the Free Software >> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >> > + * >> > + */ >> > +package net.sf.jmoney.gnucashXML.wizards; >> > + >> > +import java.io.File; >> > + >> > +import net.sf.jmoney.JMoneyPlugin; >> > +import net.sf.jmoney.model2.Session; >> > +import net.sf.jmoney.gnucashXML.GnucashXMLPlugin; >> > +import net.sf.jmoney.gnucashXML.GnucashXML; >> > + >> > +import org.eclipse.jface.dialogs.IDialogConstants; >> > +import org.eclipse.jface.dialogs.IDialogSettings; >> > +import org.eclipse.jface.dialogs.MessageDialog; >> > +import org.eclipse.jface.viewers.IStructuredSelection; >> > +import org.eclipse.jface.wizard.Wizard; >> > +import org.eclipse.ui.IImportWizard; >> > +import org.eclipse.ui.IWorkbench; >> > +import org.eclipse.ui.IWorkbenchWindow; >> > + >> > +/** >> > + * A wizard to import data from a QIF file. >> > + * >> > + * Currently this wizard if a single page wizard that asks only for the >> > file. >> > + * This feature is implemented as a wizard because the Eclipse workbench >> > import >> > + * action requires all import implementations to be wizards. >> > + */ >> > +public class GnucashImportWizard extends Wizard implements IImportWizard >> > +{ >> > + private IWorkbenchWindow window; >> > + >> > + private GnucashImportWizardPage mainPage; >> > + >> > + private Session session; >> > + >> > + public GnucashImportWizard() >> > + { >> > + IDialogSettings workbenchSettings = >> > GnucashXMLPlugin.getDefault() >> > + .getDialogSettings(); >> > + IDialogSettings section = workbenchSettings >> > + >> > .getSection("GnucashImportWizard");//$NON-NLS-1$ >> > + if(section == null) >> > + { >> > + section = >> > workbenchSettings.addNewSection("GnucashImportWizard");//$NON-NLS-1$ >> > + } >> > + setDialogSettings(section); >> > + } >> > + >> > + /* (non-Javadoc) >> > + * @see >> > org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, >> > org.eclipse.jface.viewers.IStructuredSelection) >> > + */ >> > + public void init(IWorkbench workbench, IStructuredSelection >> > selection) >> > + { >> > + this.window = workbench.getActiveWorkbenchWindow(); >> > + >> > + this.session = JMoneyPlugin.getDefault().getSession(); >> > + >> > + // Original JMoney disabled the import menu items when no >> > + // session was open. I don't know how to do that in Eclipse, >> > + // so we display a message instead. >> > + if(session == null) >> > + { >> > + MessageDialog waitDialog = new MessageDialog( >> > + window.getShell(), >> > + "Disabled Action Selected", >> > + null, // accept the default window >> > icon >> > + "You cannot import data into an >> > accounting session unless you have a session open. You must first open a >> > session or create a new session.", >> > + MessageDialog.INFORMATION, >> > + new String[] { >> > IDialogConstants.OK_LABEL }, 0); >> > + waitDialog.open(); >> > + return; >> > + } >> > + >> > + mainPage = new GnucashImportWizardPage(window); >> > + addPage(mainPage); >> > + } >> > + >> > + /* (non-Javadoc) >> > + * @see org.eclipse.jface.wizard.Wizard#performFinish() >> > + */ >> > + @Override >> > + public boolean performFinish() >> > + { >> > + String fileName = mainPage.getFileName(); >> > + if(fileName != null) >> > + { >> > + File gnucashFile = new File(fileName); >> > + GnucashXML importer = >> > GnucashXML.getSingleton(window); >> > + importer.importFile(session, gnucashFile); >> > + } >> > + >> > + return true; >> > + } >> > +} >> > Index: src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizardPage.java >> > =================================================================== >> > --- src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizardPage.java >> > (revision 0) >> > +++ src/net/sf/jmoney/gnucashXML/wizards/GnucashImportWizardPage.java >> > (revision 0) >> > @@ -0,0 +1,150 @@ >> > +/** >> > + * >> > + */ >> > +package net.sf.jmoney.gnucashXML.wizards; >> > + >> > +import net.sf.jmoney.gnucashXML.GnucashXMLPlugin; >> > + >> > +import org.eclipse.jface.dialogs.Dialog; >> > +import org.eclipse.jface.dialogs.IDialogSettings; >> > +import org.eclipse.jface.wizard.WizardPage; >> > +import org.eclipse.swt.SWT; >> > +import org.eclipse.swt.events.ModifyEvent; >> > +import org.eclipse.swt.events.ModifyListener; >> > +import org.eclipse.swt.events.SelectionAdapter; >> > +import org.eclipse.swt.events.SelectionEvent; >> > +import org.eclipse.swt.layout.GridData; >> > +import org.eclipse.swt.layout.GridLayout; >> > +import org.eclipse.swt.widgets.Button; >> > +import org.eclipse.swt.widgets.Composite; >> > +import org.eclipse.swt.widgets.FileDialog; >> > +import org.eclipse.swt.widgets.Label; >> > +import org.eclipse.swt.widgets.Text; >> > +import org.eclipse.ui.IWorkbenchWindow; >> > + >> > +/** >> > + * Page 1 of the Gnucash import Wizard >> > + */ >> > +public class GnucashImportWizardPage extends WizardPage >> > +{ >> > + private static final String GNUCASH_IMPORT_WIZARD_PAGE = >> > "gnucashImportWizardPage"; // //$NON-NLS-1$ >> > + >> > + private IWorkbenchWindow window; >> > + >> > + private Text filePathText; >> > + >> > + /** >> > + * Create an instance of this class >> > + */ >> > + public GnucashImportWizardPage(IWorkbenchWindow window) >> > + { >> > + super(GNUCASH_IMPORT_WIZARD_PAGE); >> > + this.window = window; >> > + setTitle("Choose File"); >> > + setDescription("Choose the Gnucash file to import"); >> > + } >> > + >> > + /* >> > + * (non-Javadoc) >> > + * >> > + * @see >> > org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >> > + */ >> > + public void createControl(Composite parent) >> > + { >> > + initializeDialogUnits(parent); >> > + Composite composite = new Composite(parent, SWT.NULL); >> > + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, >> > true, true)); >> > + >> > + GridLayout gdContainer = new GridLayout(2, false); >> > + gdContainer.horizontalSpacing = 10; >> > + gdContainer.verticalSpacing = 25; >> > + gdContainer.marginWidth = 20; >> > + gdContainer.marginHeight = 20; >> > + composite.setLayout(gdContainer); >> > + >> > + filePathText = new Text(composite, SWT.BORDER | >> > SWT.READ_ONLY); >> > + filePathText >> > + .setLayoutData(new GridData(SWT.FILL, >> > SWT.FILL, true, false)); >> > + >> > + Button fileBrowseButton = new Button(composite, SWT.NONE); >> > + fileBrowseButton.setText("Browse"); >> > + fileBrowseButton.addSelectionListener(new SelectionAdapter() >> > + { >> > + @Override >> > + public void widgetSelected(SelectionEvent evt) >> > + { >> > + browsePressed(); >> > + } >> > + }); >> > + >> > + Label label = new Label(composite, SWT.WRAP); >> > + label >> > + .setText("The selected Gnucash file will be >> > imported."); >> > + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >> > + gd.horizontalSpan = 2; >> > + gd.widthHint = 600; >> > + label.setLayoutData(gd); >> > + >> > + setDescription("Import data from a Gnucash file on your >> > local file system."); >> > + setPageComplete(false); >> > + filePathText.addModifyListener(new ModifyListener() >> > + { >> > + public void modifyText(ModifyEvent e) >> > + { >> > + // TODO Validate text >> > + >> > + setPageComplete(true); >> > + } >> > + }); >> > + >> > + restoreWidgetValues(); >> > + >> > + // can not finish initially, but don't want to start with an >> > error >> > + // message either >> > + setPageComplete(false); >> > + >> > + setControl(composite); >> > + >> > + filePathText.setFocus(); >> > + >> > + Dialog.applyDialogFont(composite); >> > + } >> > + >> > + protected void browsePressed() >> > + { >> > + FileDialog fileChooser = new FileDialog(window.getShell(), >> > SWT.OPEN); >> > + fileChooser.setText(GnucashXMLPlugin >> > + .getResourceString("MainFrame.import")); >> > + fileChooser.setFilterExtensions(new String[] { "*.*" }); >> > + fileChooser >> > + .setFilterNames(new String[] { "All Files >> > (*.*)" }); >> > + String filename = fileChooser.open(); >> > + if(filename != null) >> > + { >> > + filePathText.setText(filename); >> > + setPageComplete(true); >> > + } >> > + } >> > + >> > + /** >> > + * Hook method for restoring widget values to the values that they >> > held last >> > + * time this wizard was used to completion. >> > + */ >> > + protected void restoreWidgetValues() >> > + { >> > + IDialogSettings settings = getDialogSettings(); >> > + if(settings != null) >> > + { >> > + String directory = settings.get("directory"); >> > + if(directory != null) >> > + { >> > + filePathText.setText(directory); >> > + } >> > + } >> > + } >> > + >> > + public String getFileName() >> > + { >> > + return filePathText.getText(); >> > + } >> > +} >> > Index: src/net/sf/jmoney/gnucashXML/GnucashXML.java >> > =================================================================== >> > --- src/net/sf/jmoney/gnucashXML/GnucashXML.java (revision 675) >> > +++ src/net/sf/jmoney/gnucashXML/GnucashXML.java (working copy) >> > @@ -8,6 +8,7 @@ >> > import java.io.IOException; >> > import java.lang.reflect.InvocationTargetException; >> > import java.net.MalformedURLException; >> > +import java.net.URI; >> > import java.net.URL; >> > import java.text.DateFormat; >> > import java.text.NumberFormat; >> > @@ -37,9 +38,14 @@ >> > >> > import net.sf.jmoney.JMoneyPlugin; >> > import net.sf.jmoney.model2.Account; >> > +import net.sf.jmoney.model2.BankAccount; >> > import net.sf.jmoney.model2.BankAccountInfo; >> > +import net.sf.jmoney.model2.IncomeExpenseAccount; >> > +import net.sf.jmoney.model2.IncomeExpenseAccountInfo; >> > import net.sf.jmoney.model2.CapitalAccount; >> > +import net.sf.jmoney.model2.CapitalAccountInfo; >> > import net.sf.jmoney.model2.Entry; >> > +import net.sf.jmoney.model2.ExtendablePropertySet; >> > import net.sf.jmoney.model2.Session; >> > import net.sf.jmoney.model2.Transaction; >> > import oracle.xml.parser.v2.DOMParser; >> > @@ -59,753 +65,815 @@ >> > >> > /** >> > * Singleton-Class to implement the import/export of GnuCash files. >> > + * >> > * @author Faucheux >> > */ >> > public final class GnucashXML implements FileFormat, IRunnableWithProgress >> > { >> > - private NumberFormat number = NumberFormat.getInstance(Locale.US); >> > - >> > - private IWorkbenchWindow window; >> > + private NumberFormat number = NumberFormat.getInstance(Locale.US); >> > >> > - private DateFormat gnucashDateFormat = new SimpleDateFormat( >> > - "yyyy-MM-dd HH:mm:ss Z"); >> > + private IWorkbenchWindow window; >> > >> > - private Hashtable<String, CapitalAccount> accountsGUIDTable; >> > + private DateFormat gnucashDateFormat = new SimpleDateFormat( >> > + "yyyy-MM-dd HH:mm:ss Z"); >> > >> > - private Session session; >> > + private Hashtable<String, Account> accountsGUIDTable; >> > >> > - private File file; >> > + private Hashtable<String, Integer> accountsTypeTable; >> > >> > - private Document doc; >> > + private Session session; >> > >> > - private Element bookElement; >> > - >> > - static private GnucashXML myInstance = null; >> > + private File file; >> > >> > - /** >> > - * Create a new GnucashXML Class >> > - */ >> > - private GnucashXML(IWorkbenchWindow window) { >> > - this.window = window; >> > - number.setMinimumFractionDigits(2); >> > - number.setMaximumFractionDigits(2); >> > - } >> > - >> > - static public GnucashXML getSingleton (IWorkbenchWindow window) { >> > - if (myInstance == null) myInstance = new GnucashXML (window); >> > - return myInstance; >> > - } >> > + private Document doc; >> > >> > - /** >> > - * FileFiter which the OpenBox offers to fiter the Gnucash Files >> > - */ >> > - public FileFilter fileFilter() { >> > - return null; >> > - } >> > + private Element bookElement; >> > >> > - public void importFile(Session session, File file) { >> > - ProgressMonitorDialog progressDialog = new ProgressMonitorDialog( >> > - window.getShell()); >> > - this.session = session; >> > - this.file = file; >> > - try { >> > - progressDialog.run(true, false, this); >> > - } catch (InvocationTargetException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (InterruptedException e) { >> > - JMoneyPlugin.log(e); >> > - } >> > - // run(monitor); >> > - } >> > + static private GnucashXML myInstance = null; >> > >> > - /** >> > - * import of the GnuCash File The XML File has following structur: >> > <?xml >> > - * version="1.0"?> <gnc-v2> <count-data type="account">63</count-data> >> > - * <count-data type="transaction">1660</count-data> <account >> > - * version="2.0.0"> <!-- Cf accounts --> </account> <account >> > - * version="2.0.0"> </account> <transaction version="2.0.0"> <!-- Cf >> > - * transaction --> </transaction> <transaction version="2.0.0"> <!-- Cf >> > - * transaction --> </transaction> </gnc-v2> >> > - */ >> > - public void run(IProgressMonitor monitor) { >> > - DOMParser parser = new DOMParser(); >> > - accountsGUIDTable = new Hashtable<String, CapitalAccount>(); // >> > hash beetween GUID of the >> > - // accounts (hash) and >> > their >> > - // names (value). >> > + /** >> > + * Create a new GnucashXML Class >> > + */ >> > + private GnucashXML(IWorkbenchWindow window) { >> > + this.window = window; >> > + number.setMinimumFractionDigits(2); >> > + number.setMaximumFractionDigits(2); >> > + } >> > >> > - try { >> > + static public GnucashXML getSingleton(IWorkbenchWindow window) { >> > + if (myInstance == null) >> > + myInstance = new GnucashXML(window); >> > + return myInstance; >> > + } >> > >> > - // Set various parser options; validation off, >> > - // warnings shown, error stream set to stderr. >> > - parser.setErrorStream(System.err); >> > - parser.setValidationMode(DOMParser.NONVALIDATING); >> > - parser.showWarnings(true); >> > + /** >> > + * FileFiter which the OpenBox offers to fiter the Gnucash Files >> > + */ >> > + public FileFilter fileFilter() { >> > + return null; >> > + } >> > >> > - // set the DTD >> > - monitor.beginTask("Reading the file...", 0); >> > - URL urlDTD = >> > this.getClass().getResource("resources/gnucash.dtd"); >> > - parser.parseDTD(urlDTD, "gnc-v2"); >> > - parser.setDoctype(parser.getDoctype()); >> > + public void importFile(Session session, File file) { >> > + ProgressMonitorDialog progressDialog = new >> > ProgressMonitorDialog(window >> > + .getShell()); >> > + this.session = session; >> > + this.file = file; >> > + try { >> > + progressDialog.run(true, false, this); >> > + } catch (InvocationTargetException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (InterruptedException e) { >> > + JMoneyPlugin.log(e); >> > + } >> > + } >> > >> > - // parse the document >> > - monitor.beginTask("Parsing the document...", 1); >> > - URL url = file.toURL(); >> > - parser.parse(url); >> > + /** >> > + * import of the GnuCash File The XML File has following structure: >> > <?xml >> > + * version="1.0"?> <gnc-v2> <count-data >> > type="account">63</count-data> >> > + * <count-data type="transaction">1660</count-data> <account >> > + * version="2.0.0"> <!-- Cf accounts --> </account> <account >> > + * version="2.0.0"> </account> <transaction version="2.0.0"> <!-- Cf >> > + * transaction --> </transaction> <transaction version="2.0.0"> <!-- >> > Cf >> > + * transaction --> </transaction> </gnc-v2> >> > + */ >> > + public void run(IProgressMonitor monitor) { >> > + DOMParser parser = new DOMParser(); >> > + accountsGUIDTable = new Hashtable<String, Account>(); // >> > hash >> > + accountsTypeTable = new Hashtable<String, Integer>(); // >> > hash >> > + // between >> > + // GUID >> > + // of >> > + // the >> > + // accounts (hash) and their >> > + // names (value). >> > >> > - // Obtain the document >> > - XMLDocument doc = parser.getDocument(); >> > + try { >> > >> > - // Create the accounts >> > - monitor.beginTask("Creating the accounts...", 2); >> > - createAccounts(doc); >> > + // Set various parser options; validation off, >> > + // warnings shown, error stream set to stderr. >> > + parser.setErrorStream(System.err); >> > + parser.setValidationMode(DOMParser.NONVALIDATING); >> > + parser.showWarnings(true); >> > >> > - // Create the transactions >> > - monitor.beginTask("Importing the transactions...", 3); >> > - createTransactions(doc); >> > + // set the DTD >> > + monitor.beginTask("Reading the file...", 0); >> > + URL urlDTD = >> > this.getClass().getResource("resources/gnucash.dtd"); >> > + parser.parseDTD(urlDTD, "gnc-v2"); >> > + parser.setDoctype(parser.getDoctype()); >> > >> > - // Commit the changes to the datastore >> > -/* TODO: decide if we are going to support import as an undoable operation. >> > - * This old mechanism is no longer supported, and building a full >> > - * undo history could be expensive in this case. >> > - session.registerUndoableChange(GnucashXMLPlugin >> > - .getResourceString("importDescription")); >> > -*/ >> > - } catch (MalformedURLException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (IOException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (SAXException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (LessThanTwoSplitsException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (MoreThanTwoSplitsException e) { >> > - JMoneyPlugin.log(e); >> > - } catch (ParseException e) { >> > - JMoneyPlugin.log(e); >> > - } finally { >> > - monitor.done(); >> > - } >> > - } >> > + // parse the document >> > + monitor.beginTask("Parsing the document...", 1); >> > + URI uri = file.toURI(); >> > + URL url = uri.toURL(); >> > >> > - /** >> > - * Create the accounts. Each XML-Account has following structure: >> > <account >> > - * version="2.0.0"> <name>Sorties culturelles</name> <id >> > - * type="guid">3ce87b30bc7b5fc69b7ccba0ddab4d72</id> >> > <type>EXPENSE</type> >> > - * <currency> <space>ISO4217</space> <id>EUR</id> </currency> >> > - * <currency-scu>100</currency-scu> <parent >> > - * type="guid">210104bdd4a8a79fd297ea233e1966c9</parent> </account> >> > - * >> > - * @param doc = >> > - * handle to the file to read it has to have the form: <?xml >> > - * version="1.0"?> <gnc-v2> <something></something> <account >> > - * version="2.0.0"> <!-- Cf accounts --> </account> <account >> > - * version="2.0.0"> <!-- Cf accounts --> </account> >> > <something></something> >> > - * </gnc-v2> >> > - * @author Olivier Faucheux >> > - * TODO: Faucheux - treats the type (EXPENSE, BANK, >> > - * CASH, CURRENCY, ...) - treats the currency (for the time, >> > the >> > - * standard currency is always used) - when (or if ever) jmoney >> > - * accepts it, treats the parent. >> > - */ >> > - private void createAccounts(XMLDocument doc) { >> > - Node node; // First child of <gnc-v2> >> > - final Hashtable<String, String> childParent = new Hashtable<String, >> > String>(); >> > - List<String> accountToRecreate = new LinkedList<String>(); >> > + parser.parse(url); >> > >> > - // For each account of the file >> > - for (node = doc.getFirstChild().getNextSibling().getFirstChild() >> > - .getNextSibling().getFirstChild(); node != null; node = >> > (Element) node >> > - .getNextSibling()) { >> > + // Obtain the document >> > + XMLDocument doc = parser.getDocument(); >> > >> > - if (GnucashXMLPlugin.DEBUG) >> > - System.out.println("Node: " + node.getNodeName()); >> > - if (node.getNodeName().compareToIgnoreCase("gnc:Account") == 0) >> > { >> > - String accountName = null; >> > - String accountGUID = null; >> > - String parentGUID = null; >> > + // Create the accounts >> > + monitor.beginTask("Creating the accounts...", 2); >> > + createAccounts(doc); >> > >> > - NodeList childNodes = node.getChildNodes(); >> > - for (int j = 0; j < childNodes.getLength(); j++) { >> > - // if (GnucashXMLPlugin.DEBUG) System.out.println(" >> > Subnode >> > - // : " + childNodes.item(j).getNodeName() + ": " + >> > - // childNodes.item(j).getFirstChild().getNodeValue()); >> > - if (childNodes.item(j).getNodeName().equalsIgnoreCase( >> > - "act:name")) { >> > - accountName = childNodes.item(j).getFirstChild() >> > - .getNodeValue(); >> > - } else if (childNodes.item(j).getNodeName() >> > - .equalsIgnoreCase("act:id")) { >> > - accountGUID = childNodes.item(j).getFirstChild() >> > - .getNodeValue(); >> > - } else if (childNodes.item(j).getNodeName() >> > - .equalsIgnoreCase("act:parent")) { >> > - parentGUID = childNodes.item(j).getFirstChild() >> > - .getNodeValue(); >> > - } >> > - } >> > + // Create the transactions >> > + monitor.beginTask("Importing the transactions...", >> > 3); >> > + createTransactions(doc); >> > >> > - // Create the account >> > - if (accountName != null) { >> > - if (GnucashXMLPlugin.DEBUG) { >> > - System.out.println("I'm creating the account >" >> > - + accountName + "< with guid >" + >> > accountGUID >> > - + "<"); >> > - } >> > - CapitalAccount account = >> > session.createAccount(BankAccountInfo.getPropertySet()); >> > - account.setName(accountName); >> > - accountsGUIDTable.put(accountGUID, account); >> > - if (parentGUID != null) { >> > - childParent.put(accountGUID, parentGUID); >> > - accountToRecreate.add(accountGUID); >> > - } >> > + // Commit the changes to the datastore >> > + /* >> > + * TODO: decide if we are going to support import as >> > an undoable >> > + * operation. This old mechanism is no longer >> > supported, and >> > + * building a full undo history could be expensive >> > in this case. >> > + * session.registerUndoableChange(GnucashXMLPlugin >> > + * .getResourceString("importDescription")); >> > + */ >> > + } catch (MalformedURLException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (IOException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (SAXException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (LessThanTwoSplitsException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (MoreThanTwoSplitsException e) { >> > + JMoneyPlugin.log(e); >> > + } catch (ParseException e) { >> > + JMoneyPlugin.log(e); >> > + } finally { >> > + monitor.done(); >> > + } >> > + } >> > >> > - } else { >> > - JMoneyPlugin >> > - .log(new RuntimeException( >> > - "Error while importing: Account without >> > any name found!")); >> > - } >> > - } >> > + /** >> > + * Create the accounts. Each XML-Account has following structure: >> > <account >> > + * version="2.0.0"> <name>Sorties culturelles</name> <id >> > + * type="guid">3ce87b30bc7b5fc69b7ccba0ddab4d72</id> >> > <type>EXPENSE</type> >> > + * <currency> <space>ISO4217</space> <id>EUR</id> </currency> >> > + * <currency-scu>100</currency-scu> <parent >> > + * type="guid">210104bdd4a8a79fd297ea233e1966c9</parent> </account> >> > + * >> > + * @param doc = >> > + * handle to the file to read it has to have the form: >> > <?xml >> > + * version="1.0"?> <gnc-v2> <something></something> >> > <account >> > + * version="2.0.0"> <!-- Cf accounts --> </account> >> > <account >> > + * version="2.0.0"> <!-- Cf accounts --> </account> >> > <something></something> >> > + * </gnc-v2> >> > + * @author Olivier Faucheux TODO: Faucheux - treats the type >> > (EXPENSE, BANK, >> > + * CASH, CURRENCY, ...) - treats the currency (for the time, >> > the >> > + * standard currency is always used) - when (or if ever) >> > jmoney >> > + * accepts it, treats the parent. >> > + */ >> > + private void createAccounts(XMLDocument doc) { >> > + Node node; // First child of <gnc-v2> >> > + final Hashtable<String, String> childParent = new >> > Hashtable<String, String>(); >> > + List<String> accountToRecreate = new LinkedList<String>(); >> > + String rootGUID = null; >> > + final int BANKACCTTYPE = 0; >> > + final int CATEGORYTYPE = 1; >> > >> > - } >> > + // For each account of the file >> > + for (node = >> > doc.getFirstChild().getNextSibling().getFirstChild() >> > + .getNextSibling().getFirstChild(); node != >> > null; node = (Element) node >> > + .getNextSibling()) { >> > + if (GnucashXMLPlugin.DEBUG) >> > + System.out.println("Node: " + >> > node.getNodeName()); >> > + if >> > (node.getNodeName().compareToIgnoreCase("gnc:Account") == 0) { >> > + String accountName = null; >> > + String accountGUID = null; >> > + String parentGUID = null; >> > + String gnucashType = null; >> > + int accountType = BANKACCTTYPE; // 0 = >> > Account type; 1 = >> > + >> > // Category type >> > >> > - // Now link childs and parents. We have to recreate the parents >> > before >> > - // the children. >> > - // Therefore, first sort the list >> > - Collections.sort(accountToRecreate, new Comparator<String>() { >> > - public int compare(String GUIDA, String GUIDB) { >> > - String GUIDParentOfA = childParent.get(GUIDA); >> > - String GUIDParentOfB = childParent.get(GUIDB); >> > + NodeList childNodes = node.getChildNodes(); >> > + int thecount = childNodes.getLength(); >> > + for (int j = 0; j < thecount; j++) { >> > + // if (GnucashXMLPlugin.DEBUG) >> > System.out.println(" Subnode >> > + // : " + >> > childNodes.item(j).getNodeName() + ": " + >> > + // >> > childNodes.item(j).getFirstChild().getNodeValue()); >> > + if >> > (childNodes.item(j).getNodeName().equalsIgnoreCase( >> > + "act:name")) { >> > + accountName = >> > childNodes.item(j).getFirstChild() >> > + >> > .getNodeValue(); >> > + } else if >> > (childNodes.item(j).getNodeName() >> > + >> > .equalsIgnoreCase("act:id")) { >> > + accountGUID = >> > childNodes.item(j).getFirstChild() >> > + >> > .getNodeValue(); >> > >> > - // case we compare two root-accounts >> > - if (GUIDParentOfA == null & GUIDParentOfB == null) >> > - return 0; >> > + } else if >> > (childNodes.item(j).getNodeName() >> > + >> > .equalsIgnoreCase("act:parent")) { >> > + parentGUID = >> > childNodes.item(j).getFirstChild() >> > + >> > .getNodeValue(); >> > + } else if >> > (childNodes.item(j).getNodeName() >> > + >> > .equalsIgnoreCase("act:type")) { >> > + gnucashType = >> > childNodes.item(j).getFirstChild() >> > + >> > .getNodeValue(); >> > + if >> > (gnucashType.equalsIgnoreCase("INCOME") >> > + || >> > gnucashType.equalsIgnoreCase("EXPENSE")) >> > + accountType = >> > CATEGORYTYPE; >> > + else >> > + accountType = >> > BANKACCTTYPE; >> > + } >> > + if (accountName.equals("Root >> > Account") && rootGUID == null) { >> > + rootGUID = accountGUID; >> > + } >> > + } >> > >> > - // case A is root account >> > - if (GUIDParentOfA == null) >> > - return compare(GUIDA, GUIDParentOfB); >> > + // Create the account >> > + if (accountName != null) { >> > + if >> > (!accountName.equalsIgnoreCase("Root Account")) { >> > + if (GnucashXMLPlugin.DEBUG) >> > { >> > + >> > System.out.println("I'm creating the account >" >> > + + >> > accountName + "< with guid >" >> > + + >> > accountGUID + "<"); >> > + } >> > + if (accountType == >> > BANKACCTTYPE) { >> > + >> > ExtendablePropertySet<BankAccount> propset = BankAccountInfo >> > + >> > .getPropertySet(); >> > + CapitalAccount >> > account = session >> > + >> > .createAccount(propset); >> > + >> > account.setName(accountName); >> > + >> > accountsGUIDTable.put(accountGUID, account); >> > + >> > accountsTypeTable.put(accountGUID, BANKACCTTYPE); >> > + } else { >> > + >> > ExtendablePropertySet<IncomeExpenseAccount> propset = >> > IncomeExpenseAccountInfo >> > + >> > .getPropertySet(); >> > + IncomeExpenseAccount >> > account = session >> > + >> > .createAccount(propset); >> > + >> > account.setName(accountName); >> > + >> > account.setCurrency(session.getDefaultCurrency()); >> > + >> > accountsGUIDTable.put(accountGUID, account); >> > + >> > accountsTypeTable.put(accountGUID, CATEGORYTYPE); >> > + } >> > + if (parentGUID != null >> > + && >> > !parentGUID.equalsIgnoreCase(rootGUID)) { >> > + >> > childParent.put(accountGUID, parentGUID); >> > + >> > accountToRecreate.add(accountGUID); >> > + } >> > + } >> > + } else { >> > + JMoneyPlugin >> > + .log(new >> > RuntimeException( >> > + >> > "Error while importing: Account without any name found!")); >> > + } >> > + } >> > >> > - // case B is root account >> > - if (GUIDParentOfB == null) >> > - return compare(GUIDParentOfA, GUIDB); >> > + } >> > >> > - // case neither A nor B are root accounts >> > - if (GUIDA.equals(GUIDParentOfB)) >> > - return -1; >> > - if (GUIDB.equals(GUIDParentOfA)) >> > - return 1; >> > + // Now link childs and parents. We have to recreate the >> > parents before >> > + // the children. >> > + // Therefore, first sort the list >> > + Collections.sort(accountToRecreate, new Comparator<String>() >> > { >> > + public int compare(String GUIDA, String GUIDB) { >> > + String GUIDParentOfA = >> > childParent.get(GUIDA); >> > + String GUIDParentOfB = >> > childParent.get(GUIDB); >> > >> > - return compare(GUIDParentOfA, GUIDB); >> > - } >> > - }); >> > + // case we compare two root-accounts >> > + if (GUIDParentOfA == null & GUIDParentOfB == >> > null) >> > + return 0; >> > >> > - // Now recreate some accounts. >> > - for (String childGUID: accountToRecreate) { >> > - String parentGUID = childParent.get(childGUID); >> > - // if (GnucashXMLPlugin.DEBUG) System.out.println("childGUID:" >> > + >> > - // childGUID); >> > - // if (GnucashXMLPlugin.DEBUG) System.out.println("parentGUID:" >> > + >> > - // parentGUID); >> > - CapitalAccount child = getAccountFromGUID(childGUID); >> > - CapitalAccount parent = getAccountFromGUID(parentGUID); >> > + // case A is root account >> > + if (GUIDParentOfA == null) >> > + return compare(GUIDA, >> > GUIDParentOfB); >> > >> > - session.deleteAccount(child); >> > - CapitalAccount newChild = >> > parent.createSubAccount(BankAccountInfo.getPropertySet()); >> > - accountsGUIDTable.remove(childGUID); >> > - accountsGUIDTable.put(childGUID, newChild); >> > + // case B is root account >> > + if (GUIDParentOfB == null) >> > + return compare(GUIDParentOfA, >> > GUIDB); >> > >> > - newChild.setName(child.getName()); >> > - if (GnucashXMLPlugin.DEBUG) >> > - System.out >> > - .println("Child: " + newChild + ", Parent: " + >> > parent); >> > - } >> > + // case neither A nor B are root accounts >> > + if (GUIDA.equals(GUIDParentOfB)) >> > + return -1; >> > + if (GUIDB.equals(GUIDParentOfA)) >> > + return 1; >> > >> > - } >> > + return compare(GUIDParentOfA, GUIDB); >> > + } >> > + }); >> > >> > - /** >> > - * Add all the transactions of the XML-File. A transaction looks as >> > - * following: <transaction version="2.0.0"> <id >> > - * type="guid">66e591ba1b00dab33628d58390973e33</id> <date-posted> >> > - * <date>2003-10-31 000000 +0000</date> </date-posted> <date-entered> >> > - * <date>2003-11-03 070741 +0000</date> </date-entered> >> > - * <description>Geldkarte</description> <splits> <split> <id >> > - * type="guid">73fd69691319ea2872565aad65e26cde</id> >> > <reconciled-state>n</reconciled-state> >> > - * <value>-2600/100</value> <quantity>-2600/100</quantity> <account >> > - * type="guid">c192cbb8d5980c690c0d44c188fede4b</account> </split> >> > <split> >> > - * <id type="guid">396f463aaea2482a4c80da8b1eb2bcfa</id> >> > - * <reconciled-state>n</reconciled-state> <value>2600/100</value> >> > - * <quantity>2600/100</quantity> <account >> > - * type="guid">00a629b2ed01633286b2c9782a17757c</account> </split> >> > - * </splits> </transaction> TODO Faucheux: - can we store the >> > "date-entered" >> > - * in jmoney too? - when we have two "splits", it's a simple double >> > Entry. >> > - * When more, it's a splitted one. For the time, only "simple double" >> > - * Entries works. >> > - * >> > - * @param doc >> > - * @throws MoreThanTwoSplitsException >> > - * @throws LessThanTwoSplitsException >> > - * @throws ParseException >> > - */ >> > - private void createTransactions(XMLDocument doc) >> > - throws MoreThanTwoSplitsException, LessThanTwoSplitsException, >> > - ParseException { >> > + // Now recreate some accounts. >> > + for (String childGUID : accountToRecreate) { >> > + String parentGUID = childParent.get(childGUID); >> > + Account child = getAccountFromGUID(childGUID); >> > + Integer accountType = >> > getAccountTypeFromGUID(childGUID); >> > + if (accountType == BANKACCTTYPE) { >> > + CapitalAccount parent = (CapitalAccount) >> > getAccountFromGUID(parentGUID); >> > >> > - Node transactionElement; /* Currently treated Transaction node */ >> > + session.deleteAccount(child); >> > + CapitalAccount newChild = parent >> > + >> > .createSubAccount(BankAccountInfo.getPropertySet()); >> > + accountsGUIDTable.remove(childGUID); >> > + accountsGUIDTable.put(childGUID, newChild); >> > + accountsTypeTable.remove(childGUID); >> > + accountsTypeTable.put(childGUID, >> > BANKACCTTYPE); >> > >> > - // For each Transaction of the XML file >> > + newChild.setName(child.getName()); >> > + } else { >> > + IncomeExpenseAccount parent = >> > (IncomeExpenseAccount) getAccountFromGUID(parentGUID); >> > >> > - for (transactionElement = doc.getFirstChild().getNextSibling() >> > - .getFirstChild().getNextSibling().getFirstChild(); >> > transactionElement != null; transactionElement = (Element) >> > transactionElement >> > - .getNextSibling()) { >> > + session.deleteAccount(child); >> > + IncomeExpenseAccount newChild = >> > parent.createSubAccount(); >> > + >> > newChild.setCurrency(session.getDefaultCurrency()); >> > + accountsGUIDTable.remove(childGUID); >> > + accountsGUIDTable.put(childGUID, newChild); >> > + accountsTypeTable.remove(childGUID); >> > + accountsTypeTable.put(childGUID, >> > CATEGORYTYPE); >> > >> > - if (GnucashXMLPlugin.DEBUG) >> > - System.out.println("Node: " + >> > transactionElement.getNodeName()); >> > + newChild.setName(child.getName()); >> > + } >> > + } >> > + } >> > >> > - if (transactionElement.getNodeName().equalsIgnoreCase( >> > - "gnc:transaction")) { >> > + /** >> > + * Add all the transactions of the XML-File. A transaction looks as >> > + * following: <transaction version="2.0.0"> <id >> > + * type="guid">66e591ba1b00dab33628d58390973e33</id> <date-posted> >> > + * <date>2003-10-31 000000 +0000</date> </date-posted> >> > <date-entered> >> > + * <date>2003-11-03 070741 +... [truncated message content] |