diff --git a/build.xml b/build.xml index 4a70cbd..9331943 100644 --- a/build.xml +++ b/build.xml @@ -77,6 +77,7 @@ + @@ -92,6 +93,7 @@ + @@ -111,6 +113,7 @@ diff --git a/build/built-jar.properties b/build/built-jar.properties index 4669d0c..16580a7 100644 --- a/build/built-jar.properties +++ b/build/built-jar.properties @@ -1,4 +1,4 @@ -#Sun, 20 Mar 2016 22:38:40 -0400 +#Tue, 04 Apr 2023 14:30:20 +0100 -F\:\\github\\mdcsvimporter2015= +/Users/stu/Documents/Moneydance/mdcsvimporter2015= diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE index b709611..c822439 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE @@ -19,7 +19,7 @@ import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.DateGuesser; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE index 4223077..16450a8 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; public class CitiBankCanadaReader diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE index 61dea62..ef73ac9 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; public class INGNetherlandsReader diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE index 9bef54d..b6bd436 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE @@ -19,7 +19,7 @@ import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.DateGuesser; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE index 1304899..66aa72e 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE index 8fccf92..3ae223a 100644 --- a/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE +++ b/build/classes/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /* @@ -237,7 +237,7 @@ public class YodleeReader } public void createSupportedDateFormats(String dateFormatArg) { - System.err.println("\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------"); + Util.logConsole("\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------"); String[] tmp = new String[1]; tmp[0] = dateFormatArg; SUPPORTED_DATE_FORMATS = tmp; @@ -261,7 +261,7 @@ public class YodleeReader return; } - System.err.println("setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "="); + Util.logConsole("setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "="); if (!format.equals(dateFormatStringSelected)) { dateFormat = new CustomDateFormat(format); dateFormatStringSelected = format; diff --git a/dist/lib/extadmin.jar b/dist/lib/extadmin.jar deleted file mode 100644 index 7040384..0000000 Binary files a/dist/lib/extadmin.jar and /dev/null differ diff --git a/dist/mdcsvimporter.mxt b/dist/mdcsvimporter.mxt index 0019f7a..c73cd31 100644 Binary files a/dist/mdcsvimporter.mxt and b/dist/mdcsvimporter.mxt differ diff --git a/dist/mdcsvimporter.zip b/dist/mdcsvimporter.zip index 5131fa2..5be2c3d 100644 Binary files a/dist/mdcsvimporter.zip and b/dist/mdcsvimporter.zip differ diff --git a/externals/moneydance/extadmin.jar b/externals/moneydance/extadmin.jar index 7040384..7c49dbb 100644 Binary files a/externals/moneydance/extadmin.jar and b/externals/moneydance/extadmin.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index 32e34e5..60962a7 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -53,6 +53,7 @@ javac.processorpath=\ ${javac.classpath} javac.source=11 javac.target=11 +javac.fork=true javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir}:\ diff --git a/private.key b/private.key deleted file mode 100644 index 4e86809..0000000 --- a/private.key +++ /dev/null @@ -1,13 +0,0 @@ -{ - "encrypted_x" = { - "ciphertext" = "BA1057A76803CB10CA2BF1F10F0036B2B94C9FD9D1FE999974347951CF4428046DB51B66BFE40AD1FB5D9D2FA1345F9C1D08B34AE46FEEB0" - "passwdhashalg" = "sha" - "alg" = "des" -} - - "g" = "174068207532402095185811980123523436538604490794561350978495831040599953488455823147851597408940950725307797094915759492368300574252438761037084473467180148876118103083043754985190983472601550494691329488083395492313850000361646482644608492304078721818959999056496097769368017749273708962006689187956744210730" - "q" = "864205495604807476120572616017955259175325408501" - "p" = "178011905478542266528237562450159990145232156369120674273274450314442865788737020770612695252123463079567156784778466449970650770920727857050009668388144034129745221171818506047231150039301079959358067395348717066319802262019714966524135060945913707594956514672855690606794135837542707371727429551343320695239" - "keytype" = "private" - "alg" = "dsa" -} diff --git a/public.key b/public.key deleted file mode 100644 index cb6985b..0000000 --- a/public.key +++ /dev/null @@ -1,8 +0,0 @@ -{ - "mod" = "2755173050474649447494762715300952622543787228348794738800212183908714374074668541779714579674890824819263657870431851600182063301553832202594678282989776171402530574761314666749834724929140568241911626065701736033036086088993297568377311942409032667137253795501617025465875689708904527747451078948984310271334003220787236794437376957980665618087915535237538811720312853548817104024200373198830518721590616891868547931274058630783357291249234525236148926574500227489112300886127743009018983969891957868546854994633323435251302694772169616622914406982530183084365978635852711683053560459451684264393859056911740466852205684520633588328000317446684209411176577113963961653427881389815501112473182559378000353257113311041278317845624979634876321444443939748531347999990370803789003385072765561741975824172998244025890617731887420422686401896736834925083291527559356551901693416749400716364937443326199202511547140224711347765294553861190125314150722478014682600619532654404694573607372250130577760996452936386767729926018151899543387466741067208306955822799007641760749520574286344462801917264456538266385310756654241600179653618009305056519767906469305040524783869345669835828425741896656985918760594241825812198003023442913923223626229" - "format" = "X.509" - "kalg" = "RSA" - "pubexp" = "65537" - "keytype" = "public" - "alg" = "rsa" -} diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CSVData.java b/src/com/moneydance/modules/features/mdcsvimporter/CSVData.java index 0851ab8..e75761c 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/CSVData.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CSVData.java @@ -69,11 +69,11 @@ public void parseIntoLines( CustomReaderData customReaderData ) { for ( String s = reader.nextField(); s != null; s = reader.nextField() ) { - //System.err.println( " line.add string =" + s + "=" ); + //Util.logConsole( " line.add string =" + s + "=" ); line.add( s ); } - System.err.println( " line.size() =" + line.size() + "=\n" ); + Util.logConsole( " line.size() =" + line.size() + "=\n" ); if ( line.size() > maxFoundCols ) { maxFoundCols = line.size(); @@ -86,44 +86,44 @@ public void parseIntoLines( CustomReaderData customReaderData ) data = new String[file.size()][]; file.toArray( data ); - System.err.println( " parsed lines total =" + file.size() + "= maxFoundCols =" + maxFoundCols ); + Util.logConsole( " parsed lines total =" + file.size() + "= maxFoundCols =" + maxFoundCols ); currentLineIndex = -1; currentFieldIndex = -1; int maxr = file.size(); dataErr = new String[maxr][]; - //System.err.println( " reset maxr =" + maxr ); + //Util.logConsole( " reset maxr =" + maxr ); for ( int r = 0; r < maxr; r++ ) { int maxc = maxFoundCols + 1; String[] newLine = new String[ maxFoundCols + 1 ]; for ( int c = 0; c < maxc; c++ ) { - //System.err.println( " reset r =" + r + " c =" + c ); + //Util.logConsole( " reset r =" + r + " c =" + c ); newLine[c] = ""; } dataErr[r] = newLine; } -// System.err.println( "PRINT OUT RESET dataErr" ); +// Util.logConsole( "PRINT OUT RESET dataErr" ); // maxr = dataErr.length; -// System.err.println( " reset maxr =" + maxr ); +// Util.logConsole( " reset maxr =" + maxr ); // for ( int r = 0; r < maxr; r++ ) // { // int maxc = dataErr[r].length; -// System.err.println( " reset maxc =" + maxc ); +// Util.logConsole( " reset maxc =" + maxc ); // for ( int c = 0; c < maxc; c++ ) // { -// System.err.println( "dataErr blank [" + r + "][" + c +"] =" + dataErr[r][c] ); +// Util.logConsole( "dataErr blank [" + r + "][" + c +"] =" + dataErr[r][c] ); // } // } } public void reverseListRangeOrder( long beg, long end ) { - //System.err.println( "hasZeroFields() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); - System.err.println( "revLine beg: " + beg ); - System.err.println( "revLine end: " + end ); + //Util.logConsole( "hasZeroFields() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); + Util.logConsole( "revLine beg: " + beg ); + Util.logConsole( "revLine end: " + end ); if ( end <= beg ) { return; @@ -150,22 +150,22 @@ public boolean nextLine() currentFieldIndex = -1; } - //System.err.println( "nextLine() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (currentLineIndex < data.length ? "true" : "false" ) ); + //Util.logConsole( "nextLine() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (currentLineIndex < data.length ? "true" : "false" ) ); return currentLineIndex < data.length; } public boolean hasEnoughFieldsPerCurrentLine( int neededFields ) { - System.err.println( "fieldsPerCurrentLine() data[currentLineIndex].length + 1 =" + (data[currentLineIndex].length + 1) + " >= neededFields =" + neededFields ); + Util.logConsole( "fieldsPerCurrentLine() data[currentLineIndex].length + 1 =" + (data[currentLineIndex].length + 1) + " >= neededFields =" + neededFields ); return data[currentLineIndex].length + 1 >= neededFields; } public boolean nextField() { - //System.err.println( "nextField() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); + //Util.logConsole( "nextField() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); if ( currentLineIndex < 0 || currentLineIndex >= data.length ) { - //System.err.println( "nextField() ---- return false" ); + //Util.logConsole( "nextField() ---- return false" ); return false; } @@ -174,20 +174,20 @@ public boolean nextField() ++currentFieldIndex; } - //System.err.println( "nextField()2 ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (currentFieldIndex < data[currentLineIndex].length ? "true" : "false" ) ); + //Util.logConsole( "nextField()2 ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (currentFieldIndex < data[currentLineIndex].length ? "true" : "false" ) ); return currentFieldIndex < data[currentLineIndex].length; } public boolean hasZeroFields() { - //System.err.println( "hasZeroFields() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); + //Util.logConsole( "hasZeroFields() ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length ); if ( currentLineIndex < 0 || currentLineIndex >= data.length ) { - //System.err.println( "hasZeroFields() ---- return false" ); + //Util.logConsole( "hasZeroFields() ---- return false" ); return false; } - //System.err.println( "hasZeroFields()2 ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (0 < data[currentLineIndex].length ? "true" : "false" ) ); + //Util.logConsole( "hasZeroFields()2 ---- currentLineIndex =" + currentLineIndex + "= data.length =" + data.length + " ans =" + (0 < data[currentLineIndex].length ? "true" : "false" ) ); return 0 < data[currentLineIndex].length; } @@ -207,7 +207,7 @@ public String getField() public String getFieldErr() { - //System.err.println( "getFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" ); + //Util.logConsole( "getFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" ); if ( currentLineIndex < 0 || currentLineIndex >= dataErr.length ) { return ""; @@ -222,7 +222,7 @@ public String getFieldErr() public void setFieldErr( String errStr ) { - //System.err.println( "setFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" ); + //Util.logConsole( "setFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" ); if ( currentLineIndex < 0 || currentLineIndex >= dataErr.length ) { return; @@ -237,7 +237,7 @@ public void setFieldErr( String errStr ) public String getFieldErr( int row, int col ) { - //System.err.println( "getFieldErr [" + row + "][" + col + "]" ); + //Util.logConsole( "getFieldErr [" + row + "][" + col + "]" ); if ( row < 0 || row >= dataErr.length ) { return ""; @@ -252,7 +252,7 @@ public String getFieldErr( int row, int col ) public void setFieldErr( int row, int col, String errStr ) { - //System.err.println( "setFieldErr [" + row + "][" + col + "]" ); + //Util.logConsole( "setFieldErr [" + row + "][" + col + "]" ); if ( row < 0 || row >= dataErr.length ) { return; @@ -305,43 +305,43 @@ public String printCurrentLine() { if ( currentLineIndex < 0 || currentLineIndex >= data.length ) { - System.err.append( "currentLineIndex out of range =" + currentLineIndex ); + Util.logConsoleAppend( "currentLineIndex out of range =" + currentLineIndex ); return ""; } - System.err.append( "\n curr line >" ); + Util.logConsoleAppend( "\n curr line >" ); try { for ( int i = 0; i < data[currentLineIndex].length; i ++ ) { if ( i > 0 ) - System.err.append( "|" ); - System.err.append( data[currentLineIndex][currentFieldIndex] ); + Util.logConsoleAppend( "|" ); + Util.logConsoleAppend( data[currentLineIndex][currentFieldIndex] ); } } catch( Exception ex ) { - System.err.append( "*** Error in printCurrentLine at currentLineIndex =" + currentLineIndex + " currentFieldIndex =" + currentFieldIndex ); + Util.logConsoleAppend( "*** Error in printCurrentLine at currentLineIndex =" + currentLineIndex + " currentFieldIndex =" + currentFieldIndex ); } - System.err.append( "< curr line." ); + Util.logConsoleAppend( "< curr line." ); return ""; } public void printFile() { - System.err.append( "\n ------------- PRINT FILE ---------------" ); + Util.logConsoleAppend( "\n ------------- PRINT FILE ---------------" ); int maxRows = data.length; for ( int row = 0; row < maxRows; row++ ) { - System.err.append( "\n line [" + row + "] >" ); + Util.logConsoleAppend( "\n line [" + row + "] >" ); for ( int fieldIndex = 0; fieldIndex < data[ row ].length; fieldIndex++ ) { if ( fieldIndex > 0 ) - System.err.append( "|" ); - System.err.append( data[ row ][ fieldIndex ] ); + Util.logConsoleAppend( "|" ); + Util.logConsoleAppend( data[ row ][ fieldIndex ] ); } - System.err.append( "<" ); + Util.logConsoleAppend( "<" ); } - System.err.append( "\n ------------- END PRINT FILE ---------------" ); + Util.logConsoleAppend( "\n ------------- END PRINT FILE ---------------" ); } public CSVReader getReader() { diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java b/src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java index 98e8dc7..01bc7ef 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java @@ -201,11 +201,11 @@ public boolean nextLine() public String nextField() throws IOException { - //System.err.println( "nextField() fieldSeparator =" + (char)fieldSeparator + "=" ); + //Util.logConsole( "nextField() fieldSeparator =" + (char)fieldSeparator + "=" ); if ( isEol( lastChar ) || isEof( lastChar ) ) { - //System.err.println( "nextField() return null for Eol or Eof" ); + //Util.logConsole( "nextField() return null for Eol or Eof" ); return null; } @@ -219,10 +219,10 @@ public String nextField() { builder.appendCodePoint( lastChar ); lastChar = reader.read(); - //System.err.println( "lastChar =" + lastChar + "=" ); + //Util.logConsole( "lastChar =" + lastChar + "=" ); } - //System.err.println( "end field" ); - //System.err.println( "read field =" + builder.toString() + "=" ); + //Util.logConsole( "end field" ); + //Util.logConsole( "read field =" + builder.toString() + "=" ); if ( !isQuote( lastChar ) ) { @@ -261,19 +261,19 @@ public String nextField() if ( trimFields ) { - //System.err.println( "CSVReader return nextField trim =" + builder.toString().trim() + "=" ); + //Util.logConsole( "CSVReader return nextField trim =" + builder.toString().trim() + "=" ); return builder.toString().trim(); } else { - //System.err.println( "CSVReader return nextField =" + builder.toString() + "=" ); + //Util.logConsole( "CSVReader return nextField =" + builder.toString() + "=" ); return builder.toString(); } } public void setFieldSeparator( int fieldSeparator ) { - //System.err.println( "CSVReader.setFieldSeparator =" + (char)fieldSeparator + "=" ); + //Util.logConsole( "CSVReader.setFieldSeparator =" + (char)fieldSeparator + "=" ); this.fieldSeparator = fieldSeparator; } diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderData.java b/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderData.java index dbe1b60..01e9a25 100755 --- a/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderData.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderData.java @@ -114,7 +114,7 @@ public int getNumberOfCustomReaderFieldsUsed() for ( ; c < max; c++ ) { - //System.err.println( "(String) dataTypesList.get(" + c + ") =" + (String) dataTypesList.get( c ) + "=" ); + //Util.logConsole( "(String) dataTypesList.get(" + c + ") =" + (String) dataTypesList.get( c ) + "=" ); if ( ((String) dataTypesList.get( c )).equalsIgnoreCase( "" ) ) return c; } diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderDialog.java b/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderDialog.java index 43e5c0e..1d62fa4 100755 --- a/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderDialog.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderDialog.java @@ -101,7 +101,7 @@ public static void addEscapeListener(final JDialog win) { @Override public void actionPerformed(ActionEvent e) { - //System.err.println( "CustomReaderDialog formWindow WINDOW_CLOSING()" ); + //Util.logConsole( "CustomReaderDialog formWindow WINDOW_CLOSING()" ); win.dispatchEvent( new WindowEvent( win, WindowEvent.WINDOW_CLOSING )); win.dispose(); } @@ -173,7 +173,7 @@ public boolean deleteReaderConfig() message.setText( "" ); DefaultListModel listModel = (DefaultListModel) customReadersList.getModel(); int index = customReadersList.getSelectedIndex(); - //System.err.println( " selected index =" + index + " item =" + listModel.getElementAt( index ) + "=" ); + //Util.logConsole( " selected index =" + index + " item =" + listModel.getElementAt( index ) + "=" ); Settings.removeCustomReaderConfig( ReaderConfigsHM.get( listModel.getElementAt( index ) ) ); @@ -229,10 +229,10 @@ public boolean getReaderConfig( String readerNameToGet ) DefaultListModel listModel = (DefaultListModel) customReadersList.getModel(); customReadersList.setSelectedValue( readerNameToGet, true ); - System.err.println( "get UseRegexFlag customReaderData.getUseRegexFlag()=" + customReaderData.getUseRegexFlag() + "= and gui getUseRegexFlag() =" + getUseRegexFlag() ); - System.err.println( "get regexsList arraylist =" + regexsList + "=" ); - System.err.println( "get dataTypesList arraylist =" + dataTypesList + "=" ); - System.err.println( "get emptyFlagsList arraylist =" + emptyFlagsList + "=" ); + Util.logConsole( "get UseRegexFlag customReaderData.getUseRegexFlag()=" + customReaderData.getUseRegexFlag() + "= and gui getUseRegexFlag() =" + getUseRegexFlag() ); + Util.logConsole( "get regexsList arraylist =" + regexsList + "=" ); + Util.logConsole( "get dataTypesList arraylist =" + dataTypesList + "=" ); + Util.logConsole( "get emptyFlagsList arraylist =" + emptyFlagsList + "=" ); int i = 0; /* @@ -245,7 +245,7 @@ public boolean getReaderConfig( String readerNameToGet ) } */ - System.err.println( "get regex ===================================" ); + Util.logConsole( "get regex ===================================" ); regex0.setText( regexsList.get( 0 ) ); regex1.setText( regexsList.get( 1 ) ); regex2.setText( regexsList.get( 2 ) ); @@ -257,7 +257,7 @@ public boolean getReaderConfig( String readerNameToGet ) regex8.setText( regexsList.get( 8 ) ); regex9.setText( regexsList.get( 9 ) ); - System.err.println( "get datatype ===================================" ); + Util.logConsole( "get datatype ===================================" ); dataType0.setSelectedItem( dataTypesList.get( 0 ) ); dataType1.setSelectedItem( dataTypesList.get( 1 ) ); dataType2.setSelectedItem( dataTypesList.get( 2 ) ); @@ -270,16 +270,16 @@ public boolean getReaderConfig( String readerNameToGet ) dataType9.setSelectedItem( dataTypesList.get( 9 ) ); i = 0; - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 0 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 1 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 2 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 3 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 4 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 5 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 6 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 7 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 8 ) + "=" ); - System.err.println( "get datatype " + (i++) + " =" + dataTypesList.get( 9 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 0 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 1 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 2 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 3 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 4 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 5 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 6 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 7 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 8 ) + "=" ); + Util.logConsole( "get datatype " + (i++) + " =" + dataTypesList.get( 9 ) + "=" ); if ( getUseRegexFlag() ) { @@ -309,17 +309,17 @@ public boolean getReaderConfig( String readerNameToGet ) } i = 0; - System.err.println( "get emptyFlagsList ===================================" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 0 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 1 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 2 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 3 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 4 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 5 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 6 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 7 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 8 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 9 ) + "=" ); + Util.logConsole( "get emptyFlagsList ===================================" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 0 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 1 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 2 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 3 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 4 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 5 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 6 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 7 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 8 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 9 ) + "=" ); isNullable0.setSelectedItem( emptyFlagsList.get( 0 ) ); @@ -334,17 +334,17 @@ public boolean getReaderConfig( String readerNameToGet ) isNullable9.setSelectedItem( emptyFlagsList.get( 9 ) ); i = 0; - System.err.println( "get isNullable ===================================" ); - System.err.println( "isNullable0.getSelectedItem() =" + isNullable0.getSelectedItem() + "=" ); - System.err.println( "isNullable1.getSelectedItem() =" + isNullable1.getSelectedItem() + "=" ); - System.err.println( "isNullable2.getSelectedItem() =" + isNullable2.getSelectedItem() + "=" ); - System.err.println( "isNullable3.getSelectedItem() =" + isNullable3.getSelectedItem() + "=" ); - System.err.println( "isNullable4.getSelectedItem() =" + isNullable4.getSelectedItem() + "=" ); - System.err.println( "isNullable5.getSelectedItem() =" + isNullable5.getSelectedItem() + "=" ); - System.err.println( "isNullable6.getSelectedItem() =" + isNullable6.getSelectedItem() + "=" ); - System.err.println( "isNullable7.getSelectedItem() =" + isNullable7.getSelectedItem() + "=" ); - System.err.println( "isNullable8.getSelectedItem() =" + isNullable8.getSelectedItem() + "=" ); - System.err.println( "isNullable8.getSelectedItem() =" + isNullable9.getSelectedItem() + "=" ); + Util.logConsole( "get isNullable ===================================" ); + Util.logConsole( "isNullable0.getSelectedItem() =" + isNullable0.getSelectedItem() + "=" ); + Util.logConsole( "isNullable1.getSelectedItem() =" + isNullable1.getSelectedItem() + "=" ); + Util.logConsole( "isNullable2.getSelectedItem() =" + isNullable2.getSelectedItem() + "=" ); + Util.logConsole( "isNullable3.getSelectedItem() =" + isNullable3.getSelectedItem() + "=" ); + Util.logConsole( "isNullable4.getSelectedItem() =" + isNullable4.getSelectedItem() + "=" ); + Util.logConsole( "isNullable5.getSelectedItem() =" + isNullable5.getSelectedItem() + "=" ); + Util.logConsole( "isNullable6.getSelectedItem() =" + isNullable6.getSelectedItem() + "=" ); + Util.logConsole( "isNullable7.getSelectedItem() =" + isNullable7.getSelectedItem() + "=" ); + Util.logConsole( "isNullable8.getSelectedItem() =" + isNullable8.getSelectedItem() + "=" ); + Util.logConsole( "isNullable8.getSelectedItem() =" + isNullable9.getSelectedItem() + "=" ); /* DefaultComboBoxModel dateFormatModel = new DefaultComboBoxModel(); @@ -371,7 +371,7 @@ public boolean getReaderConfig( String readerNameToGet ) customReader.createSupportedDateFormats( getDateFormatString() ); this.parent.createSupportedDateFormats( getDateFormatString() ); - System.err.println( "getNumberOfCustomReaderFieldsUsed() =" + getNumberOfCustomReaderFieldsUsed() ); + Util.logConsole( "getNumberOfCustomReaderFieldsUsed() =" + getNumberOfCustomReaderFieldsUsed() ); } catch( Exception exc ) { @@ -546,7 +546,7 @@ public int getNumberOfCustomReaderFieldsUsed() for ( ; c < max; c++ ) { - //System.err.println( "(String) dataTypesList.get(" + c + ") =" + (String) dataTypesList.get( c ) + "=" ); + //Util.logConsole( "(String) dataTypesList.get(" + c + ") =" + (String) dataTypesList.get( c ) + "=" ); if ( ((String) dataTypesList.get( c )).equalsIgnoreCase( "" ) ) return c; } @@ -556,12 +556,12 @@ public int getNumberOfCustomReaderFieldsUsed() public void setHeaderLines( int xxx ) { headerLines.setText( String.valueOf( xxx ) ); - //System.err.println( "CustomReaderDialog.setHeaderLines(" + xxx +") text =" + headerLines.getText().trim() + "=" ); + //Util.logConsole( "CustomReaderDialog.setHeaderLines(" + xxx +") text =" + headerLines.getText().trim() + "=" ); } public int getHeaderLines() { int x = 0; - //System.err.println( "CustomReaderDialog.getHeaderLines() text =" + headerLines.getText().trim() + "=" ); + //Util.logConsole( "CustomReaderDialog.getHeaderLines() text =" + headerLines.getText().trim() + "=" ); try { x = Integer.parseInt( headerLines.getText().trim() ); @@ -576,12 +576,12 @@ public int getHeaderLines() { public void setFooterLines( int xxx ) { footerLines.setText( String.valueOf( xxx ) ); - //System.err.println( "CustomReaderDialog.setFooterLines(" + xxx +") text =" + footerLines.getText().trim() + "=" ); + //Util.logConsole( "CustomReaderDialog.setFooterLines(" + xxx +") text =" + footerLines.getText().trim() + "=" ); } public int getFooterLines() { int x = 0; - //System.err.println( "CustomReaderDialog.getFooterLines() text =" + footerLines.getText().trim() + "=" ); + //Util.logConsole( "CustomReaderDialog.getFooterLines() text =" + footerLines.getText().trim() + "=" ); try { x = Integer.parseInt( footerLines.getText().trim() ); @@ -685,8 +685,8 @@ protected void init() WinProps winProps = Settings.getWinProps( false, "winprops.CustomReaderDialog" ); this.setLocation( winProps.getAtX(), winProps.getAtY() ); this.setSize( new Dimension( winProps.getWidth(), winProps.getHeight() ) ); - //System.err.println( "winProps.getWidth() =" + winProps.getWidth() + "=" ); - //System.err.println( "winProps.getHeight() =" + winProps.getHeight() + "=" ); + //Util.logConsole( "winProps.getWidth() =" + winProps.getWidth() + "=" ); + //Util.logConsole( "winProps.getHeight() =" + winProps.getHeight() + "=" ); /****** Quit using the built in readers ! Force people to make their own ReaderConfigsHM.put( "citiBankCanadaReader", null ); @@ -716,7 +716,7 @@ protected void init() for ( Iterator it=ReaderHM.keySet().iterator(); it.hasNext(); ) { String readerName = (String) it.next(); - System.err.println( "fill out readerName =" + readerName + "=" ); + Util.logConsole( "fill out readerName =" + readerName + "=" ); if ( ReaderHM.get( readerName ).isCustomReaderFlag() ) { listModel.addElement( readerName ); @@ -729,7 +729,7 @@ protected void init() } if ( this.parent != null ) { - System.err.println( "call add readerName to import dlg reader list =" + readerName + "=" ); + Util.logConsole( "call add readerName to import dlg reader list =" + readerName + "=" ); this.parent.comboFileFormat1AddItem( ReaderHM.get( readerName ) ); } } @@ -2020,17 +2020,17 @@ private void useRegexFlagActionPerformed(java.awt.event.ActionEvent evt) {//GEN- } int i = 0; - System.err.println( "get emptyFlagsList ===================================" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 0 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 1 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 2 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 3 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 4 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 5 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 6 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 7 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 8 ) + "=" ); - System.err.println( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 9 ) + "=" ); + Util.logConsole( "get emptyFlagsList ===================================" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 0 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 1 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 2 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 3 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 4 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 5 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 6 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 7 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 8 ) + "=" ); + Util.logConsole( "get emptyFlagsList " + (i++) + " =" + emptyFlagsList.get( 9 ) + "=" ); isNullable0.setSelectedItem( emptyFlagsList.get( 0 ) ); @@ -2048,7 +2048,7 @@ private void useRegexFlagActionPerformed(java.awt.event.ActionEvent evt) {//GEN- private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing WinProps winProps = new WinProps( this.getWidth(), this.getHeight(), this.getX(), this.getY() ); Settings.setWinProps( "winprops.CustomReaderDialog", winProps ); - //System.err.println( "doing event CustomReaderDialog formWindow WINDOW_CLOSING()" ); + //Util.logConsole( "doing event CustomReaderDialog formWindow WINDOW_CLOSING()" ); }//GEN-LAST:event_formWindowClosing private void customReadersListMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_customReadersListMouseClicked diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer.java b/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer.java index 8432c34..646d8ed 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer.java @@ -34,7 +34,7 @@ public void setForRowCol( int row, int col, String cellToolTip ) { rowSet = new HashSet(); errCells.put( row, rowSet ); - System.err.println( "ERROR RED Cell " + row + ", " + col ); + Util.logConsole( "ERROR RED Cell " + row + ", " + col ); } rowSet.add( col ); toolTip.put( row + "," + col, cellToolTip ); diff --git a/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer1.java b/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer1.java index ed299b1..6a493d8 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer1.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer1.java @@ -34,7 +34,7 @@ public void setForRowCol( int row, int col, String cellToolTip ) { rowSet = new HashSet(); errCells.put( row, rowSet ); - System.err.println( "ADD ERROR YELLOW Cell " + row + ", " + col ); + Util.logConsole( "ADD ERROR YELLOW Cell " + row + ", " + col ); } rowSet.add( col ); toolTip.put( row + "," + col, cellToolTip ); diff --git a/src/com/moneydance/modules/features/mdcsvimporter/DateGuesser.java b/src/com/moneydance/modules/features/mdcsvimporter/DateGuesser.java index 5686393..87a0dd8 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/DateGuesser.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/DateGuesser.java @@ -305,12 +305,12 @@ private void registerFormat() Integer count = results.get( key ); if ( count == null ) { - System.err.println( "saving format key =" + key + "= count =" + 1 ); + Util.logConsole( "saving format key =" + key + "= count =" + 1 ); results.put( key, 1 ); } else { - System.err.println( "saving format key =" + key + "= count =" + (count + 1) ); + Util.logConsole( "saving format key =" + key + "= count =" + (count + 1) ); results.put( key, count + 1 ); } } @@ -367,7 +367,7 @@ public int compare( Integer o1, Integer o2 ) for ( Map.Entry entry : results.entrySet() ) { - System.err.println( "results before sort entry.getValue() =" + entry.getValue() + "= entry.getKey() =" + entry.getKey() + "=" ); + Util.logConsole( "results before sort entry.getValue() =" + entry.getValue() + "= entry.getKey() =" + entry.getKey() + "=" ); sortedResults.put( entry.getValue(), entry.getKey() ); } @@ -376,7 +376,7 @@ public int compare( Integer o1, Integer o2 ) for ( String tmp : possibleFormats ) { - System.err.println( "possibleFormats =" + tmp + "=" ); + Util.logConsole( "possibleFormats =" + tmp + "=" ); } if ( datesDetected == 0 ) diff --git a/src/com/moneydance/modules/features/mdcsvimporter/ImportDialog.java b/src/com/moneydance/modules/features/mdcsvimporter/ImportDialog.java index 5f97785..1659c22 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/ImportDialog.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/ImportDialog.java @@ -12,11 +12,18 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ + + +// Fixed by Stuart Beesley - 4th April 2023 - null filename check + package com.moneydance.modules.features.mdcsvimporter; +import java.awt.FileDialog; import com.infinitekind.moneydance.model.*; import com.moneydance.apps.md.view.gui.MoneydanceGUI; import com.moneydance.apps.md.view.gui.OnlineManager; +import com.moneydance.util.Platform; + import static com.moneydance.modules.features.mdcsvimporter.TransactionReader.importDialog; import java.awt.Color; import java.awt.Desktop; @@ -41,10 +48,9 @@ /** * - * @author miki & Stan Towianski + * @author miki and Stan Towianski */ -public class ImportDialog - extends javax.swing.JDialog +public class ImportDialog extends javax.swing.JDialog { private OnlineManager onlineMgr = null; private File selectedFile; @@ -86,6 +92,9 @@ public ImportDialog() public ImportDialog( Main main, HashMap runArgsHM ) { super( main.getMoneydanceWindow(), true ); + + this.main = main; + initComponents(); this.runArgsHM = runArgsHM; @@ -114,8 +123,7 @@ public void changedUpdate( DocumentEvent e ) } ); **/ - this.main = main; - + if ( main.getMainContext() != null ) { com.moneydance.apps.md.controller.Main mainApp = @@ -139,7 +147,7 @@ public static void addEscapeListener(final JDialog win) { @Override public void actionPerformed(ActionEvent e) { - //System.err.println( "previewImportWin formWindow dispose()" ); + //Util.logConsole( "previewImportWin formWindow dispose()" ); win.dispatchEvent( new WindowEvent( win, WindowEvent.WINDOW_CLOSING )); win.dispose(); } @@ -174,8 +182,8 @@ protected ArrayList processRunArguments() { if ( ! runArgsHM.containsKey( RUN_ARGS_JUNIT ) && ! runArgsHM.containsKey( RUN_ARGS_NOPOPERRORSFLAG ) ) { - JOptionPane.showMessageDialog( this, "Cannot proceed with processing of csv file because \nfile \'" - + (String) runArgsHM.get( RUN_ARGS_FILE ) + "\' does not exist.", "Error", JOptionPane.ERROR_MESSAGE ); + JOptionPane.showMessageDialog( this, "Cannot proceed with processing of csv file because \nfile '" + + (String) runArgsHM.get( RUN_ARGS_FILE ) + "' does not exist.", "Error", JOptionPane.ERROR_MESSAGE ); } errCodeList.add( RUN_ARGS_ERRORCODE_INVALID_FILE ); errorInRunArgs = true; @@ -251,12 +259,12 @@ else if ( "REGULAR".equalsIgnoreCase( (String) runArgsHM.get( RUN_ARGS_IMPORTTYP { dcbm = (DefaultComboBoxModel) comboAccount.getModel(); int max = comboAccount.getItemCount(); - System.err.println( "runArgs at importaccount max =" + max ); + Util.logConsole( "runArgs at importaccount max =" + max ); Account foundAccount = null; for ( idx = max - 1; idx >= 0; idx-- ) { - System.err.println( "getAcountName() =" + ((Account) dcbm.getElementAt( idx )).getAccountName() + Util.logConsole( "getAcountName() =" + ((Account) dcbm.getElementAt( idx )).getAccountName() + "= importaccount =" + (String) runArgsHM.get( RUN_ARGS_IMPORTACCOUNT ) + "=" ); if ( ((Account) dcbm.getElementAt( idx )).getAccountName().equalsIgnoreCase( (String) runArgsHM.get( RUN_ARGS_IMPORTACCOUNT ) ) ) { @@ -358,7 +366,7 @@ private void fillAccountCombo( Main main ) if ( comboAccount.getItemCount() > 0 ) { - System.err.println( "Settings.getInteger( false, \"selected.account\", 0 ) =" + Settings.getInteger( false, "selected.account", 0 ) ); + Util.logConsole( "Settings.getInteger( false, \"selected.account\", 0 ) =" + Settings.getInteger( false, "selected.account", 0 ) ); try { comboAccount.setSelectedIndex( Settings.getInteger( false, "selected.account", 0 ) ); } @@ -397,7 +405,7 @@ public void setSkipDuringInit(boolean skipDuringInit) { } public boolean isSelectedOnlineImportTypeRB() { - System.err.println( "onlineImportTypeRB.isSelected() =" + onlineImportTypeRB.isSelected() + "=" ); + Util.logConsole( "onlineImportTypeRB.isSelected() =" + onlineImportTypeRB.isSelected() + "=" ); return onlineImportTypeRB.isSelected(); } @@ -415,17 +423,17 @@ public void setPropertiesFile() { private void processFileFormatChanged( TransactionReader transReader ) { - System.err.println( "processFileFormatChanged() --------------- " ); + Util.logConsole( "processFileFormatChanged() --------------- " ); if ( transReader != null ) { if ( transReader.isCustomReaderFlag() ) { - System.err.println( "Have a custom reader. Read config for =" + transReader.toString() + "=" ); + Util.logConsole( "Have a custom reader. Read config for =" + transReader.toString() + "=" ); customReaderDialog.getReaderConfig( transReader.toString() ); -// System.err.println( "importDialog() isSelectedOnlineImportTypeRB()) =" + isSelectedOnlineImportTypeRB()+ "=" ); -// System.err.println( "importDialog() reader.isUsingCategorynameFlag() =" + transReader.isUsingCategorynameFlag() + "=" ); +// Util.logConsole( "importDialog() isSelectedOnlineImportTypeRB()) =" + isSelectedOnlineImportTypeRB()+ "=" ); +// Util.logConsole( "importDialog() reader.isUsingCategorynameFlag() =" + transReader.isUsingCategorynameFlag() + "=" ); // if ( importDialog.isSelectedOnlineImportTypeRB() && transReader.isUsingCategorynameFlag() ) // { // JOptionPane.showMessageDialog( this, "Categories will not import using \'Online\' import type. Set to \'Regular\'" @@ -434,7 +442,7 @@ private void processFileFormatChanged( TransactionReader transReader ) } String[] formats = transReader.getSupportedDateFormats(); - System.err.println( "importDialog().processFileFormatChanged() formats =" + formats + "=" ); + Util.logConsole( "importDialog().processFileFormatChanged() formats =" + formats + "=" ); popComboDateFormatList( formats ); @@ -451,7 +459,7 @@ else if ( formats.length == 1 ) else { comboDateFormat.setEnabled( true ); - System.err.println( "importDialog() customReaderDialog set Date Format Selected =" + customReaderDialog.getDateFormatSelected() + "=" ); + Util.logConsole( "importDialog() customReaderDialog set Date Format Selected =" + customReaderDialog.getDateFormatSelected() + "=" ); comboDateFormat.setSelectedItem( customReaderDialog.getDateFormatSelected() ); } } @@ -459,7 +467,7 @@ else if ( formats.length == 1 ) protected void processActionPerformed(java.awt.event.ActionEvent evt) { - System.err.println( "Process button entered" ); + Util.logConsole( "Process button entered" ); Settings.setYesNo( "delete.file", checkDeleteFile.isSelected() ); Settings.setYesNo( "importtype.online.radiobutton", onlineImportTypeRB.isSelected() ); Settings.setInteger( "selected.account", comboAccount.getSelectedIndex() ); @@ -467,27 +475,27 @@ protected void processActionPerformed(java.awt.event.ActionEvent evt) try { TransactionReader transReader = (TransactionReader) comboFileFormat.getSelectedItem(); - System.err.println( "comboFileFormat is string =" + transReader.toString() + "=" ); + Util.logConsole( "comboFileFormat is string =" + transReader.toString() + "=" ); transReader.setDateFormat( (String) comboDateFormat.getSelectedItem() ); CSVReader csvReader = null; if ( transReader.getCustomReaderData().getUseRegexFlag() ) { - System.err.println( "\n================ Regex Reader" ); + Util.logConsole( "\n================ Regex Reader" ); csvReader = new RegexReader( new InputStreamReader( new FileInputStream( selectedFile ), Charset.forName( (String) transReader.getCustomReaderData().getFileEncoding() )), transReader.getCustomReaderData() ); } else { - System.err.println( "\n================ Csv Reader" ); + Util.logConsole( "\n================ Csv Reader" ); csvReader = new CSVReader( new InputStreamReader( new FileInputStream( selectedFile ), Charset.forName( (String) transReader.getCustomReaderData().getFileEncoding() )), transReader.getCustomReaderData() ); } CSVData csvData = new CSVData( csvReader ); - //System.err.println( "btnProcessActionPerformed customReaderDialog.getFieldSeparatorChar() =" + (char)customReaderDialog.getFieldSeparatorChar() + "=" ); + //Util.logConsole( "btnProcessActionPerformed customReaderDialog.getFieldSeparatorChar() =" + (char)customReaderDialog.getFieldSeparatorChar() + "=" ); //csvData.getReader().setFieldSeparator( customReaderDialog.getFieldSeparatorChar() ); Account account = (Account) comboAccount.getSelectedItem(); - System.err.println( "starting transReader.parse..." ); + Util.logConsole( "starting transReader.parse..." ); transReader.parse( main, csvData, account, main.getAccountBook() ); csvReader.close(); System.out.println( "finished transReader.parse" ); @@ -546,6 +554,7 @@ protected void deleteCsvFile() */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents + private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; @@ -581,7 +590,7 @@ private void initComponents() { jLabel3.setText("jLabel3"); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Import File: " + main.VERSION_STRING); + setTitle(Main.EXTN_NAME + "(build: " + main.getBuild() + ")"); setMinimumSize(new java.awt.Dimension(750, 470)); setName("importDialog"); // NOI18N setPreferredSize(new java.awt.Dimension(800, 470)); @@ -920,38 +929,75 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnBrowseActionPerformed {//GEN-HEADEREND:event_btnBrowseActionPerformed - JFileChooser dialog = new JFileChooser(); - dialog.setFileHidingEnabled( true ); - dialog.setDialogTitle( "Select text file" ); - dialog.setCurrentDirectory( - new File( Settings.get( false, "last.directory", - dialog.getCurrentDirectory().getAbsolutePath() ) ) ); - dialog.addChoosableFileFilter( new FileFilter() - { - @Override - public boolean accept( File f ) - { - return f.isDirectory() || f.getName().toUpperCase().endsWith( ".CSV" ); - } - @Override - public String getDescription() - { - return "Formatted Text File (*.csv)"; - } - } ); - if ( dialog.showDialog( this, "Select" ) == JFileChooser.APPROVE_OPTION ) - { - selectedFile = dialog.getSelectedFile(); - Settings.set( "last.directory", dialog.getCurrentDirectory().getAbsolutePath() ); - // textFilename.setSelectedItem( selectedFile.getPath() ); - String[] tt = { selectedFile.getPath() }; - popTextFilenameList( tt ); + if (Platform.isMac()) { + + FileDialog dialog = new FileDialog(this, "Select text file"); + dialog.setDirectory(Settings.get(false, "last.directory", dialog.getDirectory())); + dialog.setMultipleMode(false); + dialog.setMode(FileDialog.LOAD); + dialog.setFilenameFilter(new FilenameFilter() { + public boolean accept(File dir, String name) { + return dir.isDirectory() || name.toUpperCase().endsWith(".CSV"); + } + }); + dialog.setVisible(true); + + if (dialog.getFile() == null || dialog.getFile().equals("") || dialog.getFiles().length < 1){ + Util.logConsole("(Mac) No file selected?"); + } else { + selectedFile = dialog.getFiles()[0]; + Settings.set("last.directory", dialog.getDirectory()); + + String[] tt = new String[]{dialog.getFiles()[0].getAbsolutePath()}; + + Util.logConsole(true, "***HERE1a: " + selectedFile + " " + selectedFile.getPath() + " " + dialog.getFiles()[0] + " " + selectedFile.getName()); + popTextFilenameList(tt); + fileChanged2(); + btnProcess.setEnabled(false); + } + } else { + + JFileChooser dialog = new JFileChooser(); + dialog.setFileHidingEnabled(true); + dialog.setDialogTitle("Select text file"); + dialog.setCurrentDirectory( + new File(Settings.get(false, "last.directory", + dialog.getCurrentDirectory().getAbsolutePath()))); + dialog.addChoosableFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + + Util.logConsole(true, "inside FileFilter... File: " + f); + return f.isDirectory() || f.getName().toUpperCase().endsWith(".CSV"); + } + + @Override + public String getDescription() { + return "Formatted Text File (*.csv)"; + } + }); + if (dialog.showDialog(this, "Select") == JFileChooser.APPROVE_OPTION) { + selectedFile = dialog.getSelectedFile(); + Settings.set("last.directory", dialog.getCurrentDirectory().getAbsolutePath()); + // textFilename.setSelectedItem( selectedFile.getPath() ); + + String[] tt; + + if (Platform.isMac() && dialog.getSelectedFiles().length > 0) { + tt = new String[]{dialog.getSelectedFiles()[0].getAbsolutePath()}; + } else { + tt = new String[]{selectedFile.getPath()}; + } + Util.logConsole(true, "***HERE1b: " + selectedFile + " " + selectedFile.getPath() + " " + dialog.getSelectedFiles()[0] + " " + selectedFile.getName()); + popTextFilenameList(tt); // fileChanged(); - fileChanged2(); - btnProcess.setEnabled( false ); + fileChanged2(); + btnProcess.setEnabled(false); + } } -}//GEN-LAST:event_btnBrowseActionPerformed + + }//GEN-LAST:event_btnBrowseActionPerformed private void btnCloseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCloseActionPerformed {//GEN-HEADEREND:event_btnCloseActionPerformed @@ -965,19 +1011,19 @@ private void btnProcessActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRS private void fileFormatChanged(java.awt.event.ItemEvent evt)//GEN-FIRST:event_fileFormatChanged {//GEN-HEADEREND:event_fileFormatChanged - System.err.println( "fileFormatChanged() event --------------- " + evt ); + Util.logConsole( "fileFormatChanged() event --------------- " + evt ); if ( skipDuringInit ) { - System.err.println( "fileFormatChanged() skipDuringInit ---------------" ); + Util.logConsole( "fileFormatChanged() skipDuringInit ---------------" ); return; } if ( evt.getStateChange() == ItemEvent.SELECTED ) { - System.err.println( "fileFormatChanged() event == ItemEvent.SELECTED ---------------" ); + Util.logConsole( "fileFormatChanged() event == ItemEvent.SELECTED ---------------" ); if ( comboFileFormat.getSelectedItem() instanceof String ) { - System.err.println( "comboFileFormat is string =" + (String) comboFileFormat.getSelectedItem() + "=" ); + Util.logConsole( "comboFileFormat is string =" + (String) comboFileFormat.getSelectedItem() + "=" ); return; } @@ -1015,7 +1061,7 @@ private void comboFileFormatActionPerformed(java.awt.event.ActionEvent evt) {//G /* use actionPerformed - not both ! if ( comboFileFormat.getSelectedItem() instanceof String ) { - System.err.println( "comboFileFormat is string =" + (String) comboFileFormat.getSelectedItem() + "=" ); + Util.logConsole( "comboFileFormat is string =" + (String) comboFileFormat.getSelectedItem() + "=" ); return; } @@ -1024,7 +1070,7 @@ private void comboFileFormatActionPerformed(java.awt.event.ActionEvent evt) {//G { if ( transReader.isCustomReaderFlag() ) { - System.err.println( "Have a custom reader. Read config for =" + transReader.toString() + "=" ); + Util.logConsole( "Have a custom reader. Read config for =" + transReader.toString() + "=" ); customReaderDialog.getReaderConfig( transReader.toString() ); } @@ -1049,7 +1095,7 @@ else if ( formats.length == 1 ) else { comboDateFormat.setEnabled( true ); - System.err.println( "importDialog() customReaderDialog set Date Format Selected =" + customReaderDialog.getDateFormatSelected() + "=" ); + Util.logConsole( "importDialog() customReaderDialog set Date Format Selected =" + customReaderDialog.getDateFormatSelected() + "=" ); comboDateFormat.setSelectedItem( customReaderDialog.getDateFormatSelected() ); } } @@ -1104,16 +1150,16 @@ private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event }//GEN-LAST:event_formWindowOpened private void PreviewImportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PreviewImportBtnActionPerformed - System.err.println( "Preview Import button entered" ); + Util.logConsole( "Preview Import button entered" ); try { TransactionReader transReader = (TransactionReader) comboFileFormat.getSelectedItem(); - System.err.println( "comboFileFormat is string =" + transReader.toString() + "=" ); + Util.logConsole( "comboFileFormat is string =" + transReader.toString() + "=" ); transReader.setDateFormat( (String) comboDateFormat.getSelectedItem() ); Account account = (Account) comboAccount.getSelectedItem(); - //System.err.println( "starting transReader.parse..." ); + //Util.logConsole( "starting transReader.parse..." ); //transReader.parse( main, csvData, account, main.getRootAccount() ); transReader.setAccountBook(main.getAccountBook()); @@ -1136,28 +1182,33 @@ private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS }//GEN-LAST:event_jButton3ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed + Util.logConsole(true, "***HERE2"); popTextFilenameList( null ); btnProcess.setEnabled( false ); }//GEN-LAST:event_jButton4ActionPerformed private void textFilenameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_textFilenameItemStateChanged - System.err.println( "textFilenameItemStateChanged() event --------------- " + evt ); + Util.logConsole( "textFilenameItemStateChanged() event --------------- " + evt ); if ( skipDuringInit ) { - System.err.println( "textFilenameItemStateChanged() skipDuringInit ---------------" ); + Util.logConsole( "textFilenameItemStateChanged() skipDuringInit ---------------" ); return; } + Util.logConsole(true, "***HERE5: " + evt.getStateChange()); + if ( evt.getStateChange() == ItemEvent.SELECTED ) { - System.err.println( "textFilenameItemStateChanged() event == ItemEvent.SELECTED ---------------" ); + Util.logConsole(true, "***HERE6"); + Util.logConsole( "textFilenameItemStateChanged() event == ItemEvent.SELECTED ---------------" ); if ( textFilename.getSelectedItem() instanceof String ) { - System.err.println( "textFilename is string =" + (String) textFilename.getSelectedItem() + "=" ); + Util.logConsole( "textFilename is string =" + (String) textFilename.getSelectedItem() + "=" ); textFilenameChanged(); return; } } + Util.logConsole(true, "***HERE7 exit"); }//GEN-LAST:event_textFilenameItemStateChanged private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed @@ -1167,7 +1218,7 @@ private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing WinProps winProps = new WinProps( this.getWidth(), this.getHeight(), this.getX(), this.getY() ); Settings.setWinProps( "winprops.ImportDialog", winProps ); - //System.err.println( "setting winprops of importdlg wid =" + winProps.getWidth() ); + //Util.logConsole( "setting winprops of importdlg wid =" + winProps.getWidth() ); }//GEN-LAST:event_formWindowClosing @@ -1224,21 +1275,21 @@ public void windowClosing(java.awt.event.WindowEvent e) { public void comboFileFormat1AddItem( TransactionReader customReader ) { - System.err.println( "importDialog() add reader item =" + customReader.toString() + "=" ); + Util.logConsole( "importDialog() add reader item =" + customReader.toString() + "=" ); //customReaderCB.addItem( xxx ); comboFileFormat.addItem( customReader ); } public void comboFileFormat1SetItem( TransactionReader customReader ) { - System.err.println( "importDialog() comboFileFormat1SetItem() =" + customReader.toString() + "=" ); + Util.logConsole( "importDialog() comboFileFormat1SetItem() =" + customReader.toString() + "=" ); //customReaderCB.setSelectedItem( xxx ); comboFileFormat.setSelectedItem( customReader ); } public void comboDateFormatSetItem( String xxx ) { - System.err.println( "importDialog() comboDateFormat.setSelectedItem( xxx ) =" + xxx + "=" ); + Util.logConsole( "importDialog() comboDateFormat.setSelectedItem( xxx ) =" + xxx + "=" ); comboDateFormat.setSelectedItem( xxx ); } @@ -1255,20 +1306,20 @@ public void createSupportedDateFormats( String dateFormatArg ) public String comboDateFormatGetItem() { - System.err.println( "importDialog() comboDateFormat.comboDateFormat.getSelectedItem() =" + comboDateFormat.getSelectedItem() + "=" ); + Util.logConsole( "importDialog() comboDateFormat.comboDateFormat.getSelectedItem() =" + comboDateFormat.getSelectedItem() + "=" ); return (String) comboDateFormat.getSelectedItem(); } public void comboDateFormatAddItem( String format ) { - System.err.println( "importDialog() add date format item =" + comboDateFormat + "=" ); + Util.logConsole( "importDialog() add date format item =" + comboDateFormat + "=" ); //customReaderCB.addItem( xxx ); comboDateFormat.addItem( format ); } public void comboDateFormatSetModel( DefaultComboBoxModel model ) { - System.err.println( "importDialog() comboDateFormatSetModel()" ); + Util.logConsole( "importDialog() comboDateFormatSetModel()" ); comboDateFormat.setModel( model ); } @@ -1285,58 +1336,61 @@ private void textFilenameChanged() public void popTextFilenameList( String [] filenames ) { - System.err.println( "entered popTextFilenameList()" ); + Util.logConsole( "entered popTextFilenameList()" ); File dir = new File( Settings.get( false, "last.directory", "" ) ); - if ( filenames == null ) - { - if ( dir.equals( "" ) ) - { + if ( filenames == null ) { + Util.logConsole(true, "... filenames==null"); + if (dir.equals("")) { dir = (File.listRoots())[0]; - } + Util.logConsole(true, "...... " + dir); + } + Util.logConsole(true, "***HERE3"); TransactionReader transReader = (TransactionReader) comboFileFormat.getSelectedItem(); - if ( transReader.getCustomReaderData().getFilenameMatcher() == null || - transReader.getCustomReaderData().getFilenameMatcher().equals( "" ) ) - { - transReader.getCustomReaderData().setFilenameMatcher( ".*\\.[Cc][Ss][Vv]" ); - } + Util.logConsole(true, "***HERE4"); + if (transReader.getCustomReaderData().getFilenameMatcher() == null || + transReader.getCustomReaderData().getFilenameMatcher().equals("")) { + transReader.getCustomReaderData().setFilenameMatcher(".*\\.[Cc][Ss][Vv]"); + } // create new filename filter - FilenameFilter fileNameFilter = new FilenameFilter() - { + FilenameFilter fileNameFilter = new FilenameFilter() { TransactionReader transReader = (TransactionReader) comboFileFormat.getSelectedItem(); - { - System.err.println( "popTextFilenameList() transReader.getFormatName() >" + transReader.getFormatName() + "<" ); - } + + { + Util.logConsole("popTextFilenameList() transReader.getFormatName() >" + transReader.getFormatName() + "<"); + } + @Override public boolean accept(File dir, String name) { - System.err.println( "popTextFilenameList() match name? >" + name + "<" ); - //System.err.println( "popTextFilenameList() getFilenameMatcher() >" + transReader.getCustomReaderData().getFilenameMatcher() + "<" ); - if ( name.matches( transReader.getCustomReaderData().getFilenameMatcher() ) ) - { - return true; - } - return false; + Util.logConsole("popTextFilenameList() match name? >" + name + "<"); + //Util.logConsole( "popTextFilenameList() getFilenameMatcher() >" + transReader.getCustomReaderData().getFilenameMatcher() + "<" ); + if (name.matches(transReader.getCustomReaderData().getFilenameMatcher())) { + return true; + } + return false; } - }; - + }; + // returns pathnames for files and directory - filenames = dir.list( fileNameFilter ); + filenames = dir.list(fileNameFilter); textFilename.removeAllItems(); - for ( String s : filenames ) - { - System.err.println( "popTextFilenameList add format >" + s + "<" ); - textFilename.addItem( dir + System.getProperty( "file.separator" ) + s ); + if (filenames != null) { + for (String s : filenames) { + Util.logConsole("popTextFilenameList add format >" + s + "<"); + textFilename.addItem(dir + System.getProperty("file.separator") + s); } } + } else { + Util.logConsole(true, "... pop - else.... filenames: " + filenames); textFilename.removeAllItems(); for ( String s : filenames ) { - System.err.println( "popTextFilenameList add format >" + s + "<" ); + Util.logConsole( "popTextFilenameList add format >" + s + "<" ); textFilename.addItem( s ); } } @@ -1345,11 +1399,11 @@ public boolean accept(File dir, String name) { public void popComboDateFormatList( String [] formats ) { - System.err.println( "entered popComboDateFormatList()" ); + Util.logConsole( "entered popComboDateFormatList()" ); comboDateFormat.removeAllItems(); for ( String s : formats ) { - System.err.println( "popComboDateFormatList add format >" + s + "<" ); + Util.logConsole( "popComboDateFormatList add format >" + s + "<" ); comboDateFormat.addItem( s ); } } @@ -1436,7 +1490,7 @@ else if ( fileFormats.length == 1 ) { TransactionReader reader = (TransactionReader) comboFileFormat.getSelectedItem(); String[] formats = reader.getSupportedDateFormats(); - System.err.println( "importDialog().fileChanged() formats =" + formats + "=" ); + Util.logConsole( "importDialog().fileChanged() formats =" + formats + "=" ); popComboDateFormatList( formats ); @@ -1455,13 +1509,13 @@ else if ( formats.length == 1 ) else { comboDateFormat.setEnabled( true ); - System.err.println( "importDialog() customReaderDialog.getDateFormatSelected()) =" + customReaderDialog.getDateFormatSelected() + "=" ); + Util.logConsole( "importDialog() customReaderDialog.getDateFormatSelected()) =" + customReaderDialog.getDateFormatSelected() + "=" ); comboDateFormat.setSelectedItem( customReaderDialog.getDateFormatSelected() ); } - System.err.println( "importDialog() error =" + error + "=" ); - System.err.println( "importDialog() isSelectedOnlineImportTypeRB()) =" + isSelectedOnlineImportTypeRB()+ "=" ); - System.err.println( "importDialog() reader.isUsingCategorynameFlag() =" + reader.isUsingCategorynameFlag() + "=" ); + Util.logConsole( "importDialog() error =" + error + "=" ); + Util.logConsole( "importDialog() isSelectedOnlineImportTypeRB()) =" + isSelectedOnlineImportTypeRB()+ "=" ); + Util.logConsole( "importDialog() reader.isUsingCategorynameFlag() =" + reader.isUsingCategorynameFlag() + "=" ); if ( ! error && importDialog.isSelectedOnlineImportTypeRB() && isUsingCategorynameFlag ) { JOptionPane.showMessageDialog( this, "Categories will not import using \'Online\' import type. Set to \'Regular\' if you want that." @@ -1489,6 +1543,7 @@ protected void fileChanged2() boolean error = false; boolean isUsingCategorynameFlag = false; + Util.logConsole(true, "**** selectedFile: " + selectedFile);; // see if the file is selected if ( selectedFile == null || !selectedFile.exists() || !selectedFile.isFile() ) { diff --git a/src/com/moneydance/modules/features/mdcsvimporter/Main.java b/src/com/moneydance/modules/features/mdcsvimporter/Main.java index c2fe52e..591e972 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/Main.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/Main.java @@ -12,11 +12,21 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ + +// Fixed by Stuart Beesley - April 2023 +// Fixed filenames check when null in ImportDialog.java +// Tweaked with some more up-to-date MD API calls +// Fixed calls to StringUtils for MD2023... +// Fixed calls to JFileChooser for Mac; also so that FileDialog gets called instead... +// Fixed other NPEs found... + package com.moneydance.modules.features.mdcsvimporter; import com.infinitekind.moneydance.model.AccountBook; import com.moneydance.apps.md.controller.FeatureModule; import com.moneydance.apps.md.controller.FeatureModuleContext; +import com.moneydance.apps.md.view.gui.MoneydanceGUI; + import java.awt.Dimension; import java.awt.Image; import java.io.IOException; @@ -26,38 +36,43 @@ import javax.imageio.ImageIO; import javax.swing.JFrame; -/** - * - * @author miki - */ -public class Main - extends FeatureModule +public class Main extends FeatureModule { - private static final int VERSION = 23; - protected static final String VERSION_STRING = " " + VERSION + " for MD2022"; - private static final String NAME = "CSV Importer"; - private static final String VENDOR = "Stan Towianski"; - private static final String URL = "https://github.com/stant/mdcsvimporter2015"; - private static final String DESCRIPTION = - "Let's you create configs for say: Discover card, VISA, your private bank, etc... " + - "You denote columns like: -Payment-, -Deposit-, date, amount, memo, etc... " + - "It can test your file, giving you a list of all the readers that can handle your file. " + - "Importing does matching to skip duplicate entries." - ; - private static Image image; + + public static boolean DEBUG = false; + + public static final int MIN_MD_BUILD = 1372; // Runs on MD2015.8(1372) onwards... + public static final String EXTN_ID = "mdcsvimporter2015"; + public static final String EXTN_NAME = "CSV Importer"; + + public static com.moneydance.apps.md.controller.Main MD_REF; + +// private static final int VERSION = 23; +// protected static final String VERSION_STRING = " " + VERSION + " for MD2022"; +// private static final String NAME = "CSV Importer"; +// private static final String VENDOR = "Stan Towianski"; +// private static final String URL = "https://github.com/stant/mdcsvimporter2015"; +// private static final String DESCRIPTION = +// "Let's you create configs for say: Discover card, VISA, your private bank, etc... " + +// "You denote columns like: -Payment-, -Deposit-, date, amount, memo, etc... " + +// "It can test your file, giving you a list of all the readers that can handle your file. " + +// "Importing does matching to skip duplicate entries." +// ; + + // private static Image image; private ArrayList errCodeList = null; - { - try - { - image = ImageIO.read( Main.class.getResourceAsStream( "import.png" ) ); - } - catch ( IOException x ) - { - // ignore error; nothing we can do about it - } - } +// { +// try +// { +// image = ImageIO.read( Main.class.getResourceAsStream( "import.png" ) ); +// } +// catch ( IOException x ) +// { +// // ignore error; nothing we can do about it +// } +// } public Main() { @@ -73,20 +88,25 @@ public static void main(String args[]) System.out.println( "converted amount =" + amt.replaceAll( "\\((.*)\\)", "-$1" ) ); } */ - - @Override - public void init() - { - System.err.println( "name and version =" + NAME + " " + VERSION_STRING + "=" ); - FeatureModuleContext context = getContext(); - if ( context == null ) - { - System.err.println( "*** Error: got context == null" ); - return; - } - context.registerFeature( this, "import", image, "Import File" ); - } + @Override + public void init() { + FeatureModuleContext context = getContext(); + if (context == null) { + Util.logConsole("*** Error: got context == null"); + return; + } + + MD_REF = (com.moneydance.apps.md.controller.Main) context; + + if (context.getBuild() < MIN_MD_BUILD) { + Util.logConsole("ALERT: This extension/widget is only supported on MD2015.8(1372) onwards... Quitting....."); + return; + } + + context.registerFeature(this, "import", null, EXTN_NAME); + Util.logConsole(EXTN_NAME + " >> Initialised... Build:" + getBuild()); + } AccountBook getAccountBook() { @@ -94,32 +114,49 @@ AccountBook getAccountBook() return context.getCurrentAccountBook(); } - JFrame getMoneydanceWindow() - { - // Using undocumented feature. This way our windows and dialogs can have a parent, - // and behave more conformingly. Alternative is just returning null. Effects should - // be minor visual inconsistencies. + public static com.moneydance.apps.md.controller.Main getMDMain() { + return MD_REF; + } - FeatureModuleContext context = getContext(); - com.moneydance.apps.md.controller.Main main = - (com.moneydance.apps.md.controller.Main) context; - if ( main == null ) - { - return null; - } - com.moneydance.apps.md.view.gui.MoneydanceGUI gui = - (com.moneydance.apps.md.view.gui.MoneydanceGUI) main.getUI(); - if ( gui == null ) - { - return null; - } - return gui.getTopLevelFrame(); + public static MoneydanceGUI getMDGUI() { + return (MoneydanceGUI) getMDMain().getUI(); + } + + public FeatureModuleContext getMainContext() + { + return getContext(); } + JFrame getMoneydanceWindow() { return getMDGUI().getFirstMainFrame();} + +// JFrame getMoneydanceWindow() +// { +// return getMDGUI().getFirstMainFrame(); +// +// // Using undocumented feature. This way our windows and dialogs can have a parent, +// // and behave more conformingly. Alternative is just returning null. Effects should +// // be minor visual inconsistencies. +// +// FeatureModuleContext context = getContext(); +// com.moneydance.apps.md.controller.Main main = +// (com.moneydance.apps.md.controller.Main) context; +// if ( main == null ) +// { +// return null; +// } +// com.moneydance.apps.md.view.gui.MoneydanceGUI gui = +// (com.moneydance.apps.md.view.gui.MoneydanceGUI) main.getUI(); +// if ( gui == null ) +// { +// return null; +// } +// return gui.getTopLevelFrame(); +// } + @Override public String getName() { - return NAME; + return EXTN_NAME; } // @Override @@ -155,6 +192,7 @@ public void invoke( String uri ) argsHM.put( "deletecsvfileflag", null ); */ + Util.logConsole("Received .invoke() command: '" + uri + "'"); StringTokenizer tokenizer = new StringTokenizer( uri, "&" ); HashMap argsHM = new HashMap(); @@ -163,30 +201,30 @@ public void invoke( String uri ) //int count = tokenizer.countTokens(); //String url = count + " tokens("; - System.err.println( "uri string =" + uri + "=" ); +// Util.logConsole( "uri string =" + uri + "=" ); while ( tokenizer.hasMoreTokens() ) { //url = url.concat( tokenizer.nextToken() ); String [] pcs = tokenizer.nextToken().split( "=" ); - System.err.println( "arg token [0] =" + pcs[0] + "= token[1] =" + (pcs.length < 2 ? "" : pcs[1]) + "=" ); + Util.logConsole( "arg token [0] =" + pcs[0] + "= token[1] =" + (pcs.length < 2 ? "" : pcs[1]) + "=" ); if ( pcs.length > 1 ) { if ( pcs[1].startsWith( "\"" ) ) { argsHM.put( pcs[0].toLowerCase(), pcs[1].substring( 1, pcs[1].length() - 1 ) ); - System.err.println( "arg key =" + pcs[0].toLowerCase() + "= value =" + pcs[1].substring( 1, pcs[1].length() - 1 ) + "=" ); + Util.logConsole("arg key =" + pcs[0].toLowerCase() + "= value =" + pcs[1].substring( 1, pcs[1].length() - 1 ) + "=" ); } else { argsHM.put( pcs[0].toLowerCase(), pcs[1] ); - System.err.println( "arg key =" + pcs[0].toLowerCase() + "= value =" + pcs[1] + "=" ); + Util.logConsole("arg key =" + pcs[0].toLowerCase() + "= value =" + pcs[1] + "=" ); } } else { argsHM.put( pcs[0].toLowerCase(), null ); - System.err.println( "arg key =" + pcs[0].toLowerCase() + "= value =" + null + "=" ); + Util.logConsole("arg key =" + pcs[0].toLowerCase() + "= value =" + null + "=" ); } } argsHM.remove( "import" ); // This seems to be passed in and I do not know why. @@ -204,8 +242,8 @@ public void invoke( String uri ) WinProps winProps = Settings.getWinProps( true, "winprops.ImportDialog" ); dialog.setLocation( winProps.getAtX(), winProps.getAtY() ); dialog.setSize( new Dimension( winProps.getWidth(), winProps.getHeight() ) ); - //System.err.println( "winProps.getWidth() =" + winProps.getWidth() + "=" ); - //System.err.println( "winProps.getHeight() =" + winProps.getHeight() + "=" ); + //Util.logConsole( "winProps.getWidth() =" + winProps.getWidth() + "=" ); + //Util.logConsole( "winProps.getHeight() =" + winProps.getHeight() + "=" ); dialog.setVisible( true ); } @@ -227,14 +265,10 @@ public ArrayList getErrCodeList() { // return VENDOR; // } - @Override - public Image getIconImage() - { - return image; - } +// @Override +// public Image getIconImage() +// { +// return image; +// } - public FeatureModuleContext getMainContext() - { - return getContext(); - } } diff --git a/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportTblModel.java b/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportTblModel.java index 181a9d8..0670cd2 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportTblModel.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportTblModel.java @@ -22,19 +22,19 @@ public PreviewImportTblModel( ArrayList colNamesArg, String[][] dataArg, //headerCount = headerCountArg; colCount = colCountArg; - System.err.println( "row count =" + data.length ); - System.err.println( "col count =" + colCount ); + Util.logConsole( "row count =" + data.length ); + Util.logConsole( "col count =" + colCount ); } public int getColumnCount() { return colCount; } public int getRowCount() { return data.length;} public Object getValueAt(int row, int col) { - //System.err.println( "getValueAt row =" + row + " col =" + col ); + //Util.logConsole( "getValueAt row =" + row + " col =" + col ); try { if ( data[row][col] == "" ) { - //System.err.println( "NOT EXISTS getValueAt row =" + row + " col =" + col ); + //Util.logConsole( "NOT EXISTS getValueAt row =" + row + " col =" + col ); } } catch( Exception ex ) diff --git a/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportWin.java b/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportWin.java index 66e23bc..aab62b7 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportWin.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportWin.java @@ -54,7 +54,7 @@ public PreviewImportWin() { public void myInit( ImportDialog importDialog, TransactionReader transReaderArg ) //, CSVData csvDataArg, CSVReader csvReader ) { - System.err.println( "entered PreviewImportWin.myInit()" + "< ==============================" ); + Util.logConsole( "entered PreviewImportWin.myInit()" + "< ==============================" ); this.importDialog = importDialog; transReader = transReaderArg; selectedFile.setText( importDialog.getSelectedFile().getPath() ); @@ -71,18 +71,18 @@ public void parseFile() if ( transReader.getCustomReaderData().getUseRegexFlag() ) { - System.err.println( "\n================ Regex Reader" ); + Util.logConsole( "\n================ Regex Reader" ); csvReader = new RegexReader( new InputStreamReader( new FileInputStream( importDialog.getSelectedFile() ), Charset.forName( (String) transReader.getCustomReaderData().getFileEncoding() )), transReader.getCustomReaderData() ); } else { - System.err.println( "\n================ Csv Reader" ); + Util.logConsole( "\n================ Csv Reader" ); csvReader = new CSVReader( new InputStreamReader( new FileInputStream( importDialog.getSelectedFile() ), Charset.forName( (String) transReader.getCustomReaderData().getFileEncoding() )), transReader.getCustomReaderData() ); } CSVData csvData = new CSVData( csvReader ); - //System.err.println( "btnProcessActionPerformed customReaderDialog.getFieldSeparatorChar() =" + (char)customReaderDialog.getFieldSeparatorChar() + "=" ); + //Util.logConsole( "btnProcessActionPerformed customReaderDialog.getFieldSeparatorChar() =" + (char)customReaderDialog.getFieldSeparatorChar() + "=" ); //csvData.getReader().setFieldSeparator( customReaderDialog.getFieldSeparatorChar() ); csvData.reset(); @@ -92,7 +92,7 @@ public void parseFile() importDialog.btnProcess.setEnabled( true ); processBtn.setEnabled( true ); processBtn.requestFocusInWindow(); - System.err.println( "=============== at canparse WORKS for >" + transReader.getFormatName() + "< ===============" ); + Util.logConsole( "=============== at canparse WORKS for >" + transReader.getFormatName() + "< ===============" ); } else { @@ -100,27 +100,27 @@ public void parseFile() importDialog.btnProcess.setEnabled( false ); processBtn.setEnabled( false ); parseFileBtn.requestFocusInWindow(); - System.err.println( "=============== at canparse NOT WORK for >" + transReader.getFormatName() + " at row,col " + Util.logConsole( "=============== at canparse NOT WORK for >" + transReader.getFormatName() + " at row,col " + csvData.getCurrentLineIndex() + "," + csvData.getCurrentFieldIndex() + "< ===============" ); gotError = true; } //csvData.parseIntoLines( transReader.getCustomReaderData().getFieldSeparatorChar() ); - System.err.println( "after parse row count =" + csvData.getData().length ); - System.err.println( "after parse col count =" + (csvData.getData())[ transReader.getHeaderCount() ].length ); + Util.logConsole( "after parse row count =" + csvData.getData().length ); + Util.logConsole( "after parse col count =" + (csvData.getData())[ transReader.getHeaderCount() ].length ); // Find and Insert User DataTypes as a Header row to show if they line up: int fieldIndex = 0; int colCount = 0; int maxFieldIndex = transReader.getCustomReaderData().getNumberOfCustomReaderFieldsUsed(); - System.err.println( "maxFieldIndex =" + maxFieldIndex ); + Util.logConsole( "maxFieldIndex =" + maxFieldIndex ); ArrayList headerDataTypesList = new ArrayList(); for ( ; fieldIndex < maxFieldIndex; fieldIndex ++ ) { String dataTypeExpecting = transReader.getCustomReaderData().getDataTypesList().get( fieldIndex ); - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= fieldIndex = " + fieldIndex ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= fieldIndex = " + fieldIndex ); if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE_REST ) ) { @@ -134,11 +134,11 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE ) ) try { x = Integer.parseInt( transReader.getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() ); - System.err.println( "ignore " + x + " lines" ); + Util.logConsole( "ignore " + x + " lines" ); } catch ( Exception ex ) { - System.err.println( "assume ignore 1 column on field =" + transReader.getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); + Util.logConsole( "assume ignore 1 column on field =" + transReader.getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); } int cnt = x; headerDataTypesList.add( dataTypeExpecting + "-" + cnt ); @@ -156,7 +156,7 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE ) ) colCount++; } } - System.err.println( "after parse col count =" + colCount ); + Util.logConsole( "after parse col count =" + colCount ); previewImportTbl.setModel( new PreviewImportTblModel( headerDataTypesList, csvData.getData(), colCount ) ); CustomTableCellRenderer customTableCellRenderer = new CustomTableCellRenderer(); @@ -168,14 +168,14 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE ) ) int maxr = csvData.getDataErr().length; for ( int r = 0; r < maxr; r++ ) { - //System.err.println( "Check Data Err row =" + r ); + //Util.logConsole( "Check Data Err row =" + r ); int maxc = (csvData.getDataErr())[r].length; for ( int c = 0; c < maxc; c++ ) { - //System.err.println( "Check Data Err col =" + c ); + //Util.logConsole( "Check Data Err col =" + c ); if ( ! csvData.getFieldErr(r, c).equals( "" ) ) { - System.err.println( "dataErr [" + r + "][" + c + "] =" + csvData.getFieldErr(r, c) ); + Util.logConsole( "dataErr [" + r + "][" + c + "] =" + csvData.getFieldErr(r, c) ); customTableCellRenderer.setForRowCol( r, c, csvData.getFieldErr(r, c) ); totalErrs++; //previewImportTbl.getColumnModel().getColumn( csvData.getCurrentFieldIndexWithinBounds() ).setCellRenderer( customTableCellRenderer ); @@ -206,8 +206,10 @@ public void addEscapeListener(final JFrame win) { @Override public void actionPerformed(ActionEvent e) { try { - //System.err.println( "previewImportWin formWindow dispose()" ); - csvReader.close(); + //Util.logConsole( "previewImportWin formWindow dispose()" ); + if (csvReader != null) { + csvReader.close(); + } csvData = null; transReader = null; } catch (IOException ex) { @@ -445,7 +447,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing try { - System.err.println( "previewImportWin formWindowClosing()" ); + Util.logConsole( "previewImportWin formWindowClosing()" ); } catch (Exception ex) { Logger.getLogger(PreviewImportWin.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/src/com/moneydance/modules/features/mdcsvimporter/RegexReader.java b/src/com/moneydance/modules/features/mdcsvimporter/RegexReader.java index 74c022f..87fa006 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/RegexReader.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/RegexReader.java @@ -227,36 +227,36 @@ public String nextField() for ( String patString : customReaderData.getRegexsList() ) { matcherAl.add( Pattern.compile( patString ).matcher("") ); - //System.err.println( "patString =" + patString + "=" ); + //Util.logConsole( "patString =" + patString + "=" ); } Matcher matcher = matcherAl.get( 0 ); String item = null; - //System.err.println( "\nnextField() fieldSeparator =" + (char)fieldSeparator + "=" ); + //Util.logConsole( "\nnextField() fieldSeparator =" + (char)fieldSeparator + "=" ); // if ( isEol( lastChar ) || isEof( lastChar ) ) // { -// //System.err.println( "nextField() return null for Eol or Eof" ); +// //Util.logConsole( "nextField() return null for Eol or Eof" ); // return null; // } if ( ! rgLine.isEmpty() ) { try { - System.err.println( "\n----- left =" + rgLine + "= use regex [" + rgFieldCnt + "] =" + matcherAl.get( rgFieldCnt ).pattern() + "=" ); + Util.logConsole( "\n----- left =" + rgLine + "= use regex [" + rgFieldCnt + "] =" + matcherAl.get( rgFieldCnt ).pattern() + "=" ); matcher = (matcherAl.get( rgFieldCnt )); matcher.reset( rgLine ); //reset the input if ( matcher.matches() ) { - //System.err.println("Num groups: " + matcher.groupCount()); + //Util.logConsole("Num groups: " + matcher.groupCount()); try { item = matcher.group("value") == null ? "" : matcher.group("value"); } catch( Exception exc ) { exc.printStackTrace(); - System.err.println("regex probably does not exist."); + Util.logConsole("regex probably does not exist."); item = ""; } // rgLine = rgLine.substring( item.length() ); @@ -266,18 +266,18 @@ public String nextField() catch( Exception exc ) { exc.printStackTrace(); - System.err.println("regex probably does not exist."); + Util.logConsole("regex probably does not exist."); rgLine = ""; } // if ( item.endsWith( "," ) ) // item = item.substring( 0, item.length() - 1 ); - System.err.println( "rgFieldCnt =" + rgFieldCnt + " item >" + item + "< item2 to become leftover line >" + rgLine + "<" ); + Util.logConsole( "rgFieldCnt =" + rgFieldCnt + " item >" + item + "< item2 to become leftover line >" + rgLine + "<" ); } } catch( Exception exc ) { exc.printStackTrace(); - System.err.println("Input does not match pattern."); + Util.logConsole("Input does not match pattern."); rgLine = ""; return null; } @@ -285,7 +285,7 @@ public String nextField() } else { - System.err.println( "No more fields left." ); + Util.logConsole( "No more fields left." ); rgLine = ""; return null; } @@ -294,12 +294,12 @@ public String nextField() if ( trimFields ) { - System.err.println( "RegexReader return nextField trim =" + item.trim() + "=" ); + Util.logConsole( "RegexReader return nextField trim =" + item.trim() + "=" ); return item.trim(); } else { - System.err.println( "RegexReader return nextField =" + item + "=" ); + Util.logConsole( "RegexReader return nextField =" + item + "=" ); return item; } } @@ -315,10 +315,10 @@ public boolean nextLine() //LineNumberReader lineReader = new LineNumberReader( reader ); //) { - System.err.println( "entered RegexReader.nextLine()" ); + Util.logConsole( "entered RegexReader.nextLine()" ); if ((rgLine = lineReader.readLine()) != null) { - System.err.println( "\n---------- line =" + rgLine + "=" ); + Util.logConsole( "\n---------- line =" + rgLine + "=" ); rgFieldCnt = 0; return true; } @@ -331,7 +331,7 @@ public boolean nextLine() public void setFieldSeparator( int fieldSeparator ) { - //System.err.println( "CSVReader.setFieldSeparator =" + (char)fieldSeparator + "=" ); + //Util.logConsole( "CSVReader.setFieldSeparator =" + (char)fieldSeparator + "=" ); this.fieldSeparator = fieldSeparator; } diff --git a/src/com/moneydance/modules/features/mdcsvimporter/Settings.java b/src/com/moneydance/modules/features/mdcsvimporter/Settings.java index f332281..843df90 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/Settings.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/Settings.java @@ -45,7 +45,7 @@ public final class Settings //static String emptyRegexsArrayProperty = "[ a a a a a a a a a ]"; public static File getFilename() { - System.err.println( "os.name =" + System.getProperty( "os.name" ) + "=" ); + Util.logConsole( "os.name =" + System.getProperty( "os.name" ) + "=" ); File moneydanceHome = null; File moneydanceHome1 = null; File moneydanceHome2 = null; @@ -56,7 +56,7 @@ public static File getFilename() if ( System.getProperty( "os.name" ).toLowerCase().startsWith( "mac" ) ) { moneydanceHome1 = new File( System.getProperty( "user.home" ) + "/Library/Application Support", "Moneydance" ); - System.err.println( "try moneydanceHome folder =" + moneydanceHome1 + "=" ); + Util.logConsole( "try moneydanceHome folder =" + moneydanceHome1 + "=" ); if ( moneydanceHome1.exists() ) { moneydanceHome = moneydanceHome1; @@ -64,7 +64,7 @@ public static File getFilename() else { moneydanceHome2 = new File( System.getProperty( "user.home" ) + "/Library/Preferences", "Moneydance" ); - System.err.println( "try moneydanceHome folder =" + moneydanceHome2 + "=" ); + Util.logConsole( "try moneydanceHome folder =" + moneydanceHome2 + "=" ); if ( moneydanceHome2.exists() ) { moneydanceHome = moneydanceHome2; @@ -72,7 +72,7 @@ public static File getFilename() else { moneydanceHome3 = new File( "/Library/Preferences", "Moneydance" ); - System.err.println( "try moneydanceHome folder =" + moneydanceHome3 + "=" ); + Util.logConsole( "try moneydanceHome folder =" + moneydanceHome3 + "=" ); if ( moneydanceHome3.exists() ) { moneydanceHome = moneydanceHome3; @@ -80,7 +80,7 @@ public static File getFilename() else { moneydanceHome4 = new File( System.getProperty( "user.home" ) + "/Library", "Moneydance" ); - System.err.println( "try moneydanceHome folder =" + moneydanceHome4 + "=" ); + Util.logConsole( "try moneydanceHome folder =" + moneydanceHome4 + "=" ); if ( moneydanceHome4.exists() ) moneydanceHome = moneydanceHome4; } // 3 @@ -91,7 +91,7 @@ public static File getFilename() if ( moneydanceHome == null ) { - System.err.println( "Could not find so assuming moneydanceHome folder =" + moneydanceHome1 + "=" ); + Util.logConsole( "Could not find so assuming moneydanceHome folder =" + moneydanceHome1 + "=" ); moneydanceHome = moneydanceHome1; missingHomeErrMsg = "\n\nI looked in these 4 places in this order: \n\n" + moneydanceHome1 + "\n" @@ -103,13 +103,13 @@ public static File getFilename() else // windows + Linux : test for moneydance folder { moneydanceHome1 = new File( System.getProperty( "user.home" ), ".moneydance" ); - System.err.println( "try moneydanceHome folder =" + moneydanceHome1 + "=" ); + Util.logConsole( "try moneydanceHome folder =" + moneydanceHome1 + "=" ); if ( moneydanceHome1.exists() ) moneydanceHome = moneydanceHome1; if ( moneydanceHome == null ) { - System.err.println( "Could not find so assuming moneydanceHome folder =" + moneydanceHome1 + "=" ); + Util.logConsole( "Could not find so assuming moneydanceHome folder =" + moneydanceHome1 + "=" ); moneydanceHome = moneydanceHome1; missingHomeErrMsg = ""; //\n\nI looked in this place: \n\n" //+ moneydanceHome + "\n"; @@ -178,7 +178,7 @@ private static void save( Properties props ) OutputStream os = new FileOutputStream( getFilename() ); //, Charset.forName( "UTF-8" ) ); //(String) transReader.getCustomReaderData().getFileEncoding() ) ); try { - //System.err.println( "DOING SAVE TO PROPS FILE" ); + //Util.logConsole( "DOING SAVE TO PROPS FILE" ); props.store( os, "MDCSVImporter - Moneydance CSV Importer" ); } finally @@ -303,10 +303,10 @@ public static void setInteger( String name, int value ) public static WinProps getWinProps( boolean loadProps, String name ) { String value = get( loadProps, name ); - //System.err.println( "getWinProps(" + name + ") value =" + value + "=" ); + //Util.logConsole( "getWinProps(" + name + ") value =" + value + "=" ); if ( value == null ) { - //System.err.println( "getWinProps() string value is null" ); + //Util.logConsole( "getWinProps() string value is null" ); return new WinProps(); } @@ -315,9 +315,9 @@ public static WinProps getWinProps( boolean loadProps, String name ) ArrayList numList = new ArrayList(); for ( String one : tmpList ) { - //System.err.println( "one =" + one + "=" ); + //Util.logConsole( "one =" + one + "=" ); numList.add( Integer.parseInt( one.trim() ) ); - //System.err.println( "getWinProps set name =" + name + "= list value =" + one.getWinPropsAsList().toString() + "=" ); + //Util.logConsole( "getWinProps set name =" + name + "= list value =" + one.getWinPropsAsList().toString() + "=" ); } return new WinProps( numList ); } @@ -325,7 +325,7 @@ public static WinProps getWinProps( boolean loadProps, String name ) public static void setWinProps( String name, WinProps value ) { set( name, value.getWinPropsAsList().toString() ); - //System.err.println( "set name =" + name + "= list value =" + value.getWinPropsAsList().toString() + "=" ); + //Util.logConsole( "set name =" + name + "= list value =" + value.getWinPropsAsList().toString() + "=" ); } public static HashMap createReaderConfigsHM() @@ -344,7 +344,7 @@ public static HashMap createReaderConfigsHM() if ( key.startsWith( "reader:" ) && key.endsWith( ".Name" ) ) { String readerName = key.replaceAll( "reader\\:(.*)\\..*", "reader:$1" ); - System.err.println( "readerName >" + readerName + "<" ); + Util.logConsole( "readerName >" + readerName + "<" ); CustomReaderData customReaderData = new CustomReaderData(); customReaderData.setReaderName( props.getProperty( readerName + ".Name" ) ); @@ -370,7 +370,7 @@ public static HashMap createReaderConfigsHM() customReaderData.setEmptyFlagsList( new ArrayList(Arrays.asList( props.getProperty( readerName + ".EmptyFlagsList", emptyArrayProperty ).split( "[\\[\\],]" ) ) ) ); int max = customReaderData.getDataTypesList().size(); - System.err.println( "props customReaderData.getRegexsList().size() =" + customReaderData.getRegexsList().size() + "= max =" + max ); + Util.logConsole( "props customReaderData.getRegexsList().size() =" + customReaderData.getRegexsList().size() + "= max =" + max ); for ( int c = 1; c < max; c++ ) { customReaderData.getRegexsList().set( c - 1, props.getProperty( readerName + ".RegexsList." + (c-1), "" ) ); @@ -394,14 +394,14 @@ public static HashMap createReaderConfigsHM() customReaderData.getDateFormatList().set( c - 1,customReaderData.getDateFormatList().get( c ).trim() ); } */ - System.err.println( "props readerName =" + customReaderData.getReaderName() + "=" ); - System.err.println( "props getFieldSeparatorChar() =" + customReaderData.getFieldSeparatorChar() + "=" ); - System.err.println( "props getFileEncoding() =" + customReaderData.getFileEncoding() + "=" ); - System.err.println( "props getDateFormatString() =" + customReaderData.getDateFormatString()+ "=" ); - System.err.println( "props getHeaderLines() =" + customReaderData.getHeaderLines() + "=" ); - System.err.println( "props getRegexsList() =" + customReaderData.getRegexsList() + "=" ); - System.err.println( "props getDataTypesList() =" + customReaderData.getDataTypesList() + "=" ); - System.err.println( "props getEmptyFlagsList() =" + customReaderData.getEmptyFlagsList() + "=" ); + Util.logConsole( "props readerName =" + customReaderData.getReaderName() + "=" ); + Util.logConsole( "props getFieldSeparatorChar() =" + customReaderData.getFieldSeparatorChar() + "=" ); + Util.logConsole( "props getFileEncoding() =" + customReaderData.getFileEncoding() + "=" ); + Util.logConsole( "props getDateFormatString() =" + customReaderData.getDateFormatString()+ "=" ); + Util.logConsole( "props getHeaderLines() =" + customReaderData.getHeaderLines() + "=" ); + Util.logConsole( "props getRegexsList() =" + customReaderData.getRegexsList() + "=" ); + Util.logConsole( "props getDataTypesList() =" + customReaderData.getDataTypesList() + "=" ); + Util.logConsole( "props getEmptyFlagsList() =" + customReaderData.getEmptyFlagsList() + "=" ); ReaderConfigsHM.put( props.getProperty( readerName + ".Name" ), customReaderData ); diff --git a/src/com/moneydance/modules/features/mdcsvimporter/StringUtils.java b/src/com/moneydance/modules/features/mdcsvimporter/StringUtils.java index 5d00064..164eac8 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/StringUtils.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/StringUtils.java @@ -17,9 +17,6 @@ *
  • \ uXXXX : Hexadecimal based Unicode character.
  • * * - * @param st - * A string optionally containing standard java escape sequences. - * @return The translated string. */ public class StringUtils diff --git a/src/com/moneydance/modules/features/mdcsvimporter/TransactionReader.java b/src/com/moneydance/modules/features/mdcsvimporter/TransactionReader.java index efe65ab..3b4c862 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/TransactionReader.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/TransactionReader.java @@ -105,9 +105,9 @@ protected final void setAccountBook(AccountBook book) public final String calcFITxnIdAbstract( AbstractTxn atxn ) throws IOException { - //System.err.println( "\n--------- entered TransactionReader().calcFITxnId( AbstractTxn ) -------------" ); - //System.err.println( "key.getDescription() =" + atxn.getDescription() + "= atxn.getFiTxnId( 1 ) =" + atxn.getFiTxnId( 1 ) + "=" ); - //System.err.println( "atxn.getFiTxnId( 1 ) [" + k + "] =" + atxn.getFiTxnId( 1 ) + "= atxn.getFiTxnId( 0 ) [" + k + "] =" + atxn.getFiTxnId( 0 ) + "=" ); + //Util.logConsole( "\n--------- entered TransactionReader().calcFITxnId( AbstractTxn ) -------------" ); + //Util.logConsole( "key.getDescription() =" + atxn.getDescription() + "= atxn.getFiTxnId( 1 ) =" + atxn.getFiTxnId( 1 ) + "=" ); + //Util.logConsole( "atxn.getFiTxnId( 1 ) [" + k + "] =" + atxn.getFiTxnId( 1 ) + "= atxn.getFiTxnId( 0 ) [" + k + "] =" + atxn.getFiTxnId( 0 ) + "=" ); //tsetMatcherKey.add( atxn.getFiTxnId( 1 ) ); // Here I am manually recreating the FiTxnId that I set on imported txn's because I could not figure @@ -189,7 +189,7 @@ public final String calcFITxnIdAbstract( AbstractTxn atxn ) + ":" + (origCheckNumber == null ? "" : origCheckNumber.replaceAll( "^0*(.*)", "$1" ) ) // strip leading 0's + ":" + (atxn.getParameter("ol.orig-memo") == null ? "" : atxn.getParameter("ol.orig-memo")); - //System.err.println( "calc abstract FITxnld >" + tmp + "<" ); + //Util.logConsole( "calc abstract FITxnld >" + tmp + "<" ); return tmp; } @@ -197,7 +197,7 @@ public final String calcFITxnIdAbstract( AbstractTxn atxn ) public final String calcFITxnId( OnlineTxn onlinetxn ) throws IOException { - //System.err.println( "\n--------- entered TransactionReader().calcFITxnId( onlinetxn ) -------------" ); + //Util.logConsole( "\n--------- entered TransactionReader().calcFITxnId( onlinetxn ) -------------" ); // txn.setFITxnId( date + ":" + currency.format( amount, '.' ) + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() ); String tmp = onlinetxn.getDateInitiatedInt() + ":" + currency.format( onlinetxn.getAmount(), '.' ) @@ -206,7 +206,7 @@ public final String calcFITxnId( OnlineTxn onlinetxn ) + ":" + (onlinetxn.getMemo() == null ? "" : onlinetxn.getMemo() ) ; - //System.err.println( "calc online FITxnld >" + tmp + "<" ); + //Util.logConsole( "calc online FITxnld >" + tmp + "<" ); return tmp; } @@ -218,7 +218,7 @@ private final void makeSetOfExistingTxns( TxnSet tset ) { String tmp = calcFITxnIdAbstract( atxn ); - //System.err.println( "tmp string [" + k + "] =" + tmp + "=" ); + //Util.logConsole( "tmp string [" + k + "] =" + tmp + "=" ); tsetMatcherKey.add( tmp ); tsetFITxnIdMatcherKey.add( atxn.getFiTxnId( OnlineTxn.PROTO_TYPE_OFX ) ); tsetFITxnIdMatcherKey.add( atxn.getFiTxnId( defProtocolId ) ); @@ -227,7 +227,7 @@ private final void makeSetOfExistingTxns( TxnSet tset ) //if ( k > 9 ) // break; } - //System.err.println( "\n--------- end: make set of existing account transactions -------------" ); + //Util.logConsole( "\n--------- end: make set of existing account transactions -------------" ); } /* @@ -236,7 +236,7 @@ private final void makeSetOfExistingTxns( TxnSet tset ) public final void parse( Main main, CSVData csvDataArg, Account accountIn, AccountBook book) throws IOException { - System.err.println("\n--------- entered TransactionReader().parse() -------------"); + Util.logConsole("\n--------- entered TransactionReader().parse() -------------"); this.csvData = csvDataArg; this.book = book; @@ -256,9 +256,9 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou // //getAllAccountNames - is only path from root to present acct // //end testing - System.err.println("\n--------- beg: make set of existing account transactions -------------"); - //System.err.println( "number of trans list =" +this.txnSet.getTransactionsForAccount( account ).getSize() ); - System.err.println("size of txnSet.getAllTxns = " + this.txnSet.getAllTxns().getSize()); + Util.logConsole("\n--------- beg: make set of existing account transactions -------------"); + //Util.logConsole( "number of trans list =" +this.txnSet.getTransactionsForAccount( account ).getSize() ); + Util.logConsole("size of txnSet.getAllTxns = " + this.txnSet.getAllTxns().getSize()); // cannot get just for account because I am putting them into a temp/empty account ! //Enumeration tenums = this.txnSet.getTransactionsForAccount( account ).getAllTxns(); TxnSet tset = this.txnSet.getAllTxns(); @@ -283,7 +283,7 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou while ( tenums.hasMoreElements() ) { AbstractTxn key = tenums.nextElement(); - System.err.println( "key.getDescription() =" + key.getDescription() + "= key.getFiTxnId( 0 )" + key.getFiTxnId( 0 ) + "=" ); + Util.logConsole( "key.getDescription() =" + key.getDescription() + "= key.getFiTxnId( 0 )" + key.getFiTxnId( 0 ) + "=" ); tsetMatcherKey.add( key.getFiTxnId( 0 ) ); } * @@ -296,14 +296,14 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou OnlineTxn onlinetxn = transactionList.getTxn( k ); String tmp = calcFITxnId( onlinetxn ); - //System.err.println( "tmp string [" + k + "] =" + tmp + "=" ); + //Util.logConsole( "tmp string [" + k + "] =" + tmp + "=" ); onlineMatcherKey.add( tmp ); //if ( k > 9 ) // break; } */ - System.err.println( "\n--------- end: make set of existing account online transactions -------------" ); + Util.logConsole( "\n--------- end: make set of existing account online transactions -------------" ); //csvData.reset(); if ( this instanceof CustomReader ) @@ -315,9 +315,9 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou csvData.parseIntoLines( null ); } - //System.err.println( "at parse getFieldSeparator() =" + (char)csvData.getReader().getFieldSeparator() + "=" ); + //Util.logConsole( "at parse getFieldSeparator() =" + (char)csvData.getReader().getFieldSeparator() + "=" ); //csvData.getReader().setFieldSeparator( customReaderDialog.getFieldSeparatorChar() ); - //System.err.println( "at parse getFieldSeparator() after set =" + (char)csvData.getReader().getFieldSeparator() + "=" ); + //Util.logConsole( "at parse getFieldSeparator() after set =" + (char)csvData.getReader().getFieldSeparator() + "=" ); csvData.reset(); long fileLineCount = 0; @@ -329,23 +329,23 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou if ( ! csvData.hasZeroFields() ) { endingBlankLines ++; - System.err.println( "endingBlankLines =" + endingBlankLines ); + Util.logConsole( "endingBlankLines =" + endingBlankLines ); } else { endingBlankLines = 0; } } - System.err.println( "fileLineCount =" + fileLineCount ); + Util.logConsole( "fileLineCount =" + fileLineCount ); csvData.reset(); //----- Skip Header Lines ----- - System.err.println( "getHeaderCount() =" + getHeaderCount() ); + Util.logConsole( "getHeaderCount() =" + getHeaderCount() ); for ( int hdrCnt = getHeaderCount(); hdrCnt > 0; --hdrCnt ) { csvData.nextLine(); // skip the header - System.err.println( "skip header" ); + Util.logConsole( "skip header" ); } long begAtLine = csvData.getCurrentLineIndex() + 1; @@ -366,7 +366,7 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou boolean accountMissingError = false; // csvData.printFile(); - System.err.println( "ImportReverseOrderFlg(): " + getCustomReaderData().getImportReverseOrderFlg() ); + Util.logConsole( "ImportReverseOrderFlg(): " + getCustomReaderData().getImportReverseOrderFlg() ); if ( getCustomReaderData().getImportReverseOrderFlg() ) { csvData.reverseListRangeOrder( begAtLine, stopAtLine - 1 ); @@ -392,7 +392,7 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou System.out.println( "accountNameFromCSV: " + accountNameFromCSV ); if ( this.account == null ) { - System.err.println( "ERROR: account is null" ); + Util.logConsole( "ERROR: account is null" ); //TODO: make new account? if ( ! accountMissingError ) { @@ -413,7 +413,7 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou // ! accountNameFromCSV.contentEquals(priorAccountNameFromCSV)) { // priorAccountNameFromCSV = accountNameFromCSV; this.transactionList = account.getDownloadedTxns();//TODO: move this out of loop - System.err.println( "tset.getSize() = " + tset.getSize() + " online txns.getSize() = " + transactionList.getTxnCount() ); + Util.logConsole( "tset.getSize() = " + tset.getSize() + " online txns.getSize() = " + transactionList.getTxnCount() ); // } System.out.println("OnlineTxn txn = transactionList.newTxn();"); @@ -429,14 +429,14 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou txn.setTotalAmount( -txn.getAmount() ); } */ - System.err.println( "if (account.balanceIsNegated())" ); + Util.logConsole( "if (account.balanceIsNegated())" ); if ( account.balanceIsNegated() ) { txn.setAmount( -txn.getAmount() ); txn.setTotalAmount( -txn.getAmount() ); } - //System.err.println( "call to calc fitxnid - should be online type" ); + //Util.logConsole( "call to calc fitxnid - should be online type" ); String onlineMatchKey = calcFITxnId( txn ); txn.setFITxnId( onlineMatchKey ); @@ -445,9 +445,9 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou ! tsetFITxnIdMatcherKey.contains( onlineMatchKey ) ) { - System.err.println( "will add transaction with txn.getFITxnId( ) =" + txn.getFITxnId( ) + "= txn.getFIID() =" + txn.getFIID() + "=" ); + Util.logConsole( "will add transaction with txn.getFITxnId( ) =" + txn.getFITxnId( ) + "= txn.getFIID() =" + txn.getFIID() + "=" ); // + "\n or onlineMatchKey =" + onlineMatchKey + "=" ); - //System.err.println( "importDialog =" + importDialog + "=" ); + //Util.logConsole( "importDialog =" + importDialog + "=" ); /* NOTE: This is to convert the online txn to an regular txn. This would let me set categories and tags * on incoming txn's, but it automatically sets the category to the default account one and I like it @@ -455,12 +455,12 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou */ if ( importDialog.isSelectedOnlineImportTypeRB() ) { - System.err.println( "add new onlineTxn" ); + Util.logConsole( "add new onlineTxn" ); transactionList.addNewTxn( txn ); } else { - System.err.println( "add new parentTxn/splitTxn" ); + Util.logConsole( "add new parentTxn/splitTxn" ); ParentTxn pTxn = onlineToParentTxn( account, book, txn ); if ( pTxn != null ) { @@ -469,12 +469,12 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou } totalAccepted ++; // I don't know why, but for now this works here, but not below, after the main loop - Stan. Maybe because of using multiple account names? - System.err.println( "onlineMgr.processDownloadedTxns for account :" + account.getAccountName() ); + Util.logConsole( "onlineMgr.processDownloadedTxns for account :" + account.getAccountName() ); onlineMgr.processDownloadedTxns( account ); } else { - System.err.println( "will NOT add Duplicate transaction with txn.getFITxnId( ) =" + txn.getFITxnId( ) + "=" ); + Util.logConsole( "will NOT add Duplicate transaction with txn.getFITxnId( ) =" + txn.getFITxnId( ) + "=" ); totalDuplicates ++; } } // parseNext() @@ -504,17 +504,17 @@ public final void parse( Main main, CSVData csvDataArg, Account accountIn, Accou + "\nRejected Records: " + totalRejected + "\n\nDo you want to import the New records ?" , "Results", JOptionPane.YES_NO_OPTION ); - System.err.println( "ans =" + ans + "= JOptionPane.YES_OPTION =" + JOptionPane.YES_OPTION + "= JOptionPane.NO_OPTION =" + JOptionPane.NO_OPTION + "=" ); + Util.logConsole( "ans =" + ans + "= JOptionPane.YES_OPTION =" + JOptionPane.YES_OPTION + "= JOptionPane.NO_OPTION =" + JOptionPane.NO_OPTION + "=" ); if ( ans == JOptionPane.YES_OPTION ) { OnlineTxnList transactionListCurrent = account.getDownloadedTxns(); int max = transactionList.getTxnCount(); - System.err.println( "getTxnCount()/max =" + max + "=" ); + Util.logConsole( "getTxnCount()/max =" + max + "=" ); for ( int j = 0; j < max; j ++ ) { - System.err.println( "transactionList.getTxn( " + j + " ) =" + transactionList.getTxn( j ) + "=" ); + Util.logConsole( "transactionList.getTxn( " + j + " ) =" + transactionList.getTxn( j ) + "=" ); transactionListCurrent.addNewTxn( transactionList.getTxn( j ) ); } @@ -561,10 +561,10 @@ protected ParentTxn onlineToParentTxn( Account account, AccountBook book, Online , ckNum, account, oTxn.getName(), oTxn.getMemo() , -1, AbstractTxn.STATUS_UNRECONCILED ); try { - System.err.println( "find category for oTxn.getSubAccountTo() =" + oTxn.getSubAccountTo() + "=" ); + Util.logConsole( "find category for oTxn.getSubAccountTo() =" + oTxn.getSubAccountTo() + "=" ); category = getAccount( account, oTxn.getSubAccountTo(), AccountUtil.getDefaultCategoryForAcct( account ).getAccountName() //rr.getString("default_category"), , oTxn.getAmount() <= 0 ? Account.AccountType.EXPENSE : Account.AccountType.INCOME ); - System.err.println( "found category =" + category + "=" ); + Util.logConsole( "found category =" + category + "=" ); } catch (Exception ex) { Logger.getLogger(TransactionReader.class.getName()).log(Level.SEVERE, null, ex); @@ -588,7 +588,7 @@ protected ParentTxn onlineToParentTxn( Account account, AccountBook book, Online public void setCustomReaderDialog( CustomReaderDialog customReaderDialog ) { - System.err.println( "custreader set custreaderdialog" ); + Util.logConsole( "custreader set custreaderdialog" ); this.customReaderDialog = customReaderDialog; } @@ -605,25 +605,25 @@ public static TransactionReader[] getCompatibleReaders( boolean getAllReadersLis ArrayList formats = new ArrayList(); // moving importDialog = importDialogArg; - System.err.println( "getCompatibleReaders() call cust read canParse()" ); + Util.logConsole( "getCompatibleReaders() call cust read canParse()" ); CSVReader csvReader = null; for ( String key : Settings.getReaderHM().keySet() ) { TransactionReader transactionReader = Settings.getReaderHM().get( key ); - System.err.println( "\n================ at canparse for transReader >" + key + "< ===============" ); + Util.logConsole( "\n================ at canparse for transReader >" + key + "< ===============" ); try { - System.err.println( "using fileEncoding >" + transactionReader.getCustomReaderData().getFileEncoding() + "< ===============" ); + Util.logConsole( "using fileEncoding >" + transactionReader.getCustomReaderData().getFileEncoding() + "< ===============" ); if ( transactionReader.getCustomReaderData().getUseRegexFlag() ) { - System.err.println( "\n================ Regex Reader" ); + Util.logConsole( "\n================ Regex Reader" ); csvReader = new RegexReader( new InputStreamReader( new FileInputStream( selectedFile ), Charset.forName( transactionReader.getCustomReaderData().getFileEncoding() ) ), transactionReader.getCustomReaderData() ); } else { - System.err.println( "\n================ Csv Reader" ); + Util.logConsole( "\n================ Csv Reader" ); csvReader = new CSVReader( new InputStreamReader( new FileInputStream( selectedFile ), Charset.forName( transactionReader.getCustomReaderData().getFileEncoding() ) ), transactionReader.getCustomReaderData() ); } CSVData csvData = new CSVData( csvReader ); @@ -631,24 +631,24 @@ public static TransactionReader[] getCompatibleReaders( boolean getAllReadersLis transactionReader.setAccountBook(TransactionReader.book); if ( getAllReadersList ) { - System.err.println( "=============== add all readers for >" + key + "< ===============" ); + Util.logConsole( "=============== add all readers for >" + key + "< ===============" ); formats.add( transactionReader ); } else if ( transactionReader.canParse( csvData, PARSE_THRU_ERRORS_STOP_AT_FIRST ) ) { - System.err.println( "=============== at canparse WORKS for >" + key + "< ===============" ); + Util.logConsole( "=============== at canparse WORKS for >" + key + "< ===============" ); formats.add( transactionReader ); } else { - System.err.println( "=============== at canparse NOT WORK for >" + key + "< ===============" ); + Util.logConsole( "=============== at canparse NOT WORK for >" + key + "< ===============" ); } } catch ( Throwable x ) { - System.err.println( "at canparse error reading file !" ); - System.err.println( "=============== at canparse NOT WORK for >" + key + "< ===============" ); - System.err.println( "File Error: " ); + Util.logConsole( "at canparse error reading file !" ); + Util.logConsole( "=============== at canparse NOT WORK for >" + key + "< ===============" ); + Util.logConsole( "File Error: " ); x.printStackTrace(); } finally @@ -668,15 +668,15 @@ else if ( transactionReader.canParse( csvData, PARSE_THRU_ERRORS_STOP_AT_FIRST ) if ( customerReaderName != null && ! customerReaderName.equals( "" ) ) s { - System.err.println( "at canparse getFieldSeparator() =" + (char)data.getReader().getFieldSeparator() + "=" ); + Util.logConsole( "at canparse getFieldSeparator() =" + (char)data.getReader().getFieldSeparator() + "=" ); //data.getReader().setFieldSeparator( customReaderDialog.getFieldSeparatorChar() ); - //System.err.println( "at canparse getFieldSeparator() after set =" + (char)data.getReader().getFieldSeparator() + "=" ); + //Util.logConsole( "at canparse getFieldSeparator() after set =" + (char)data.getReader().getFieldSeparator() + "=" ); -//s System.err.println( "at canparse getFieldSeparator() after set =" + (char)data.getReader().getFieldSeparator() + "=" ); +//s Util.logConsole( "at canparse getFieldSeparator() after set =" + (char)data.getReader().getFieldSeparator() + "=" ); customReader.setDateFormat( importDialog.comboDateFormatGetItem() ); - System.err.println( "at canparse importDialog.comboDateFormatGetItem() after set =" + importDialog.comboDateFormatGetItem() + "=" ); + Util.logConsole( "at canparse importDialog.comboDateFormatGetItem() after set =" + importDialog.comboDateFormatGetItem() + "=" ); if ( customReader.canParse( data ) ) { @@ -748,7 +748,7 @@ public boolean isUsingCategorynameFlag() { public void setUsingCategorynameFlag(boolean xx) { this.isUsingCategorynameFlag = xx; - //System.err.println( "set isUsingCategorynameFlag to =" + isUsingCategorynameFlag + "=" ); + //Util.logConsole( "set isUsingCategorynameFlag to =" + isUsingCategorynameFlag + "=" ); } /**************************************************************************************/ diff --git a/src/com/moneydance/modules/features/mdcsvimporter/Util.java b/src/com/moneydance/modules/features/mdcsvimporter/Util.java new file mode 100644 index 0000000..f66cfb4 --- /dev/null +++ b/src/com/moneydance/modules/features/mdcsvimporter/Util.java @@ -0,0 +1,28 @@ +package com.moneydance.modules.features.mdcsvimporter; + +import java.awt.*; + +public class Util { + + public static void logConsole(String message) { + logConsole(false, message); + } + + public static void logConsole(Object objMessage) { + logConsole(false, objMessage.toString()); + } + + public static void logConsole(Boolean onlyWhenDebug, String message) { + if (onlyWhenDebug && !Main.DEBUG) return; + System.err.println(Main.EXTN_ID + ": " + message); + } + + public static void logConsoleAppend(String appendSequence) { + System.err.append(appendSequence); + } + + public static Color getPositiveGreen() { + return Main.getMDGUI().getColors().budgetHealthyColor; + } + +} diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE index b709611..c822439 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/BbvaCompassBankReader.java-HIDE @@ -19,7 +19,7 @@ import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.DateGuesser; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE index 4223077..16450a8 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/CitiBankCanadaReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; public class CitiBankCanadaReader diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/CustomReader.java b/src/com/moneydance/modules/features/mdcsvimporter/formats/CustomReader.java index b7e23d1..79802e0 100755 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/CustomReader.java +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/CustomReader.java @@ -18,8 +18,9 @@ import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.CustomReaderData; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; +import com.moneydance.modules.features.mdcsvimporter.Util; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -98,7 +99,7 @@ public void setSupportedDateFormats( String[] supportedDateFormats ) public void createSupportedDateFormats( String dateFormatArg ) { - System.err.println( "\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------" ); + Util.logConsole( "\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------" ); String[] tmp = new String[1]; tmp[0] = dateFormatArg; SUPPORTED_DATE_FORMATS = tmp; @@ -108,7 +109,7 @@ public void createSupportedDateFormats( String dateFormatArg ) @Override public boolean canParse( CSVData data, int parseThruErrors ) { - System.err.println( "--------- entered customerReader().canParse() as type =" + getFormatName() + "= -------------" ); + Util.logConsole( "--------- entered customerReader().canParse() as type =" + getFormatName() + "= -------------" ); try { data.parseIntoLines( getCustomReaderData() ); } @@ -119,11 +120,11 @@ public boolean canParse( CSVData data, int parseThruErrors ) } //if ( data.getReader() == null ) - // System.err.println( "data.getReader() == null" ); + // Util.logConsole( "data.getReader() == null" ); - //System.err.println( "at parse getFieldSeparator() =" + (char)csvData.getReader().getFieldSeparator() + "=" ); + //Util.logConsole( "at parse getFieldSeparator() =" + (char)csvData.getReader().getFieldSeparator() + "=" ); //csvData.getReader().setFieldSeparator( getCustomReaderData().getFieldSeparatorChar() ); - //System.err.println( "at parse getFieldSeparator() after set =" + (char)csvData.getReader().getFieldSeparator() + "=" ); + //Util.logConsole( "at parse getFieldSeparator() after set =" + (char)csvData.getReader().getFieldSeparator() + "=" ); data.reset(); long fileLineCount = 0; @@ -135,21 +136,21 @@ public boolean canParse( CSVData data, int parseThruErrors ) if ( ! data.hasZeroFields() ) { endingBlankLines ++; - System.err.println( "endingBlankLines =" + endingBlankLines ); + Util.logConsole( "endingBlankLines =" + endingBlankLines ); } else { endingBlankLines = 0; } } - System.err.println( "fileLineCount =" + fileLineCount ); + Util.logConsole( "fileLineCount =" + fileLineCount ); data.reset(); int skipHeaderLines = getHeaderCount(); - System.err.println( "skip any Header Lines =" + skipHeaderLines ); + Util.logConsole( "skip any Header Lines =" + skipHeaderLines ); for ( int i = 0; i < skipHeaderLines; i++ ) { - System.err.println( "skip header line" ); + Util.logConsole( "skip header line" ); data.nextLine(); } long begAtLine = data.getCurrentLineIndex() + 1; @@ -165,7 +166,7 @@ public boolean canParse( CSVData data, int parseThruErrors ) SimpleDateFormat sdf = new SimpleDateFormat( jDateFormat, Locale.ENGLISH ); sdf.setLenient( false ); - System.err.println( "using dateFormat string =" + getCustomReaderData().getDateFormatString() + "->" + jDateFormat + "<-" ); + Util.logConsole( "using dateFormat string =" + getCustomReaderData().getDateFormatString() + "->" + jDateFormat + "<-" ); long totalProcessed = 0; long stopAtLine = fileLineCount - getHeaderCount() - getCustomReaderData().getFooterLines() - endingBlankLines; @@ -181,7 +182,7 @@ public boolean canParse( CSVData data, int parseThruErrors ) && data.nextLine() && totalProcessed < stopAtLine ) { totalProcessed++; - System.err.println( "------- next line ---------------" ); + Util.logConsole( "------- next line ---------------" ); if ( ! data.hasZeroFields() ) { continue; // skip empty lines @@ -189,7 +190,7 @@ public boolean canParse( CSVData data, int parseThruErrors ) if ( ! data.hasEnoughFieldsPerCurrentLine( maxFieldIndex - 1 ) ) { - System.err.println( "Have too few fields. Needed >= " + ( maxFieldIndex - 1 ) ); + Util.logConsole( "Have too few fields. Needed >= " + ( maxFieldIndex - 1 ) ); data.printCurrentLine(); retVal = false; data.nextField(); // read to first field since we did not start yet. @@ -198,18 +199,18 @@ public boolean canParse( CSVData data, int parseThruErrors ) } int fieldIndex = 0; - System.err.println( "maxFieldIndex =" + maxFieldIndex ); + Util.logConsole( "maxFieldIndex =" + maxFieldIndex ); for ( ; ( retVal || (parseThruErrors == TransactionReader.PARSE_THRU_ERRORS_CONTINUE) ) && fieldIndex < maxFieldIndex; fieldIndex ++ ) { String dataTypeExpecting = getCustomReaderData().getDataTypesList().get( fieldIndex ); - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= fieldIndex = " + fieldIndex ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= fieldIndex = " + fieldIndex ); data.nextField(); // if ( ! data.nextField() ) // { -// //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but have no data left." ); +// //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but have no data left." ); // retVal = false; // break; // } @@ -231,17 +232,17 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE ) ) try { x = Integer.parseInt( getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() ); - System.err.println( "ignore " + x + " lines" ); + Util.logConsole( "ignore " + x + " lines" ); } catch ( Exception ex ) { - System.err.println( "assume ignore 1 line by erro on field =" + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); + Util.logConsole( "assume ignore 1 line by erro on field =" + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); } while ( x > 1 ) { data.nextField(); fieldString = data.getField(); - System.err.println( "ignore fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); + Util.logConsole( "ignore fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); //fieldIndex ++; NO - just skip data not field data type index x--; } @@ -251,14 +252,14 @@ else if ( ( fieldString == null || fieldString.equals( DATA_TYPE_BLANK ) ) ) { if ( ! getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).equals( "Can Be Blank" ) ) { - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but got no value =" + fieldString + "= and STOP ON ERROR" ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but got no value =" + fieldString + "= and STOP ON ERROR" ); retVal = false; data.setFieldErr( "Field Cannot Be Blank" ); //break; } else { - System.err.println( "ok to skip this blank field" ); + Util.logConsole( "ok to skip this blank field" ); continue; } } @@ -270,7 +271,7 @@ else if ( ( fieldString == null || fieldString.equals( DATA_TYPE_BLANK ) ) ) || dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE_PURCHASED ) ) { - System.err.println( "date >" + fieldString + "<" ); + Util.logConsole( "date >" + fieldString + "<" ); /* // find guessable date formats @@ -295,7 +296,7 @@ else if ( ( fieldString == null || fieldString.equals( DATA_TYPE_BLANK ) ) ) // retVal = false; // break; // } - System.err.println( "fieldString =" + fieldString + "= date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "fieldString =" + fieldString + "= date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); try { sdf.parse( fieldString ); // This seems to catch jan 32 -> feb 01 which I do not want to allow. @@ -308,13 +309,13 @@ else if ( ( fieldString == null || fieldString.equals( DATA_TYPE_BLANK ) ) ) // } } catch (ParseException e) { - System.err.println( "canParse() parseException: " + sdf.toString() + "<" ); + Util.logConsole( "canParse() parseException: " + sdf.toString() + "<" ); retVal = false; data.setFieldErr( "Invalid Date" ); //break; } catch (IllegalArgumentException e) { - System.err.println( "canParse() IllegalArgumentException: " + sdf.toString() + "<" ); + Util.logConsole( "canParse() IllegalArgumentException: " + sdf.toString() + "<" ); retVal = false; data.setFieldErr( "Invalid Date" ); //break; @@ -325,31 +326,31 @@ else if ( ( fieldString == null || fieldString.equals( DATA_TYPE_BLANK ) ) ) else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_PAYMENT ) || dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DEPOSIT ) ) // was only amount before { - System.err.println( "amountString >" + fieldString + "<" ); + Util.logConsole( "amountString >" + fieldString + "<" ); fieldString = fieldString.replaceAll( "\\((.*)\\)", "-$1" ); - System.err.println( "amountString >" + fieldString + "<" ); + Util.logConsole( "amountString >" + fieldString + "<" ); fieldString = fieldString.replaceAll( "[^0-9]*(.*)", "$1" ); // strip leading non-digits - System.err.println( "amountString >" + fieldString + "<" ); + Util.logConsole( "amountString >" + fieldString + "<" ); try { //StringUtils.parseDoubleWithException( fieldString, '.' ); String tmp = fieldString.replace( '$', '0' ); - //System.err.println( "check modified amountString 1 >" + tmp + "<" ); + //Util.logConsole( "check modified amountString 1 >" + tmp + "<" ); tmp = tmp.replace( '-', '0' ); - //System.err.println( "check modified amountString 2 >" + tmp + "<" ); + //Util.logConsole( "check modified amountString 2 >" + tmp + "<" ); tmp = tmp.replaceAll( " ", "" ); - //System.err.println( "check modified amountString 3 >" + tmp + "<" ); + //Util.logConsole( "check modified amountString 3 >" + tmp + "<" ); tmp = tmp.replaceAll( ",", "" ); - //System.err.println( "check modified amountString 4 >" + tmp + "<" ); + //Util.logConsole( "check modified amountString 4 >" + tmp + "<" ); tmp = tmp.replaceAll( "\\.", "" ); - //System.err.println( "check modified amountString 5 >" + tmp + "<" ); + //Util.logConsole( "check modified amountString 5 >" + tmp + "<" ); tmp = tmp.replaceAll( "\\d", "" ); - System.err.println( "check modified amountString 6 >" + tmp + "<" ); + Util.logConsole( "check modified amountString 6 >" + tmp + "<" ); //Number number = NumberFormat.getNumberInstance().parse( tmp ); if ( tmp.equals( "" ) ) //number instanceof Double || number instanceof Long ) { - System.err.println( "ok number" ); + Util.logConsole( "ok number" ); ; } else @@ -369,25 +370,25 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_PAYMENT ) } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DESCRIPTION ) ) { - System.err.println( "description >" + fieldString + "<" ); + Util.logConsole( "description >" + fieldString + "<" ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_MEMO) ) { - System.err.println( "memo >" + fieldString + "<" ); + Util.logConsole( "memo >" + fieldString + "<" ); } else if ( dataTypeExpecting.equalsIgnoreCase( "tag" ) ) { - System.err.println( "tag >" + fieldString + "<" ); + Util.logConsole( "tag >" + fieldString + "<" ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_ACCOUNT_NAME ) ) { - System.err.println( "accountName >" + fieldString + "<" ); + Util.logConsole( "accountName >" + fieldString + "<" ); accountName = fieldString; if ( book.getRootAccount().getAccountByName( accountName ) == null ) { - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); -// //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); +// //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); // retVal = false; // break; } @@ -395,14 +396,14 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_ACCOUNT_NAME ) ) } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_CATEGORY_NAME ) ) { - System.err.println( "categoryName >" + fieldString + "<" ); + Util.logConsole( "categoryName >" + fieldString + "<" ); categoryName = fieldString; setUsingCategorynameFlag( true ); // if ( rootAccount.getAccountByName( categoryName ) == null ) // { -// System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); -//// System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); +// Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); +//// Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); //// retVal = false; //// break; // } @@ -411,7 +412,7 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_CATEGORY_NAME ) ) } // end for } - System.err.println( "canParse will return =" + retVal ); + Util.logConsole( "canParse will return =" + retVal ); return retVal; } @@ -442,26 +443,26 @@ protected boolean parseNext() throws IOException int fieldIndex = 0; int amountDecimalSignChar = getCustomReaderData().getAmountDecimalSignChar(); int maxFieldIndex = getCustomReaderData().getNumberOfCustomReaderFieldsUsed(); - System.err.println( "maxFieldIndex =" + maxFieldIndex ); + Util.logConsole( "maxFieldIndex =" + maxFieldIndex ); setDateFormat( getCustomReaderData().getDateFormatString() ); - System.err.println( "using dateFormat string =" + getCustomReaderData().getDateFormatString() + "=" ); + Util.logConsole( "using dateFormat string =" + getCustomReaderData().getDateFormatString() + "=" ); - System.err.println( "----------------------" ); + Util.logConsole( "----------------------" ); if ( ! csvData.hasZeroFields() ) { - System.err.println( "skip empty line" ); + Util.logConsole( "skip empty line" ); return false; // skip empty lines } for ( ; fieldIndex < maxFieldIndex; fieldIndex ++ ) { String dataTypeExpecting = getCustomReaderData().getDataTypesList().get( fieldIndex ); - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= EmptyFlagsList = " + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ) + "=" ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= EmptyFlagsList = " + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ) + "=" ); csvData.nextField(); String fieldString = csvData.getField(); - System.err.println( "fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); + Util.logConsole( "fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE_REST ) ) { @@ -473,17 +474,17 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_IGNORE ) ) try { x = Integer.parseInt( getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() ); - System.err.println( "ignore " + x + " lines" ); + Util.logConsole( "ignore " + x + " lines" ); } catch ( Exception ex ) { - System.err.println( "ignore 1 line by erro on field =" + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); + Util.logConsole( "ignore 1 line by erro on field =" + getCustomReaderData().getEmptyFlagsList().get( fieldIndex ).trim() + "=" ); } while ( x > 1 ) { csvData.nextField(); fieldString = csvData.getField(); - System.err.println( "ignore fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); + Util.logConsole( "ignore fieldString =" + fieldString + "= fieldIndex = " + fieldIndex ); //fieldIndex ++; NO - just skip data not field data type index x--; } @@ -493,23 +494,23 @@ else if ( ( fieldString == null || fieldString.equals( "" ) ) && ! getCustomReaderData().getEmptyFlagsList().get( fieldIndex ) .equals( "Can Be Blank" ) ) { - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but got no value =" + fieldString + "= and STOP ON ERROR" ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but got no value =" + fieldString + "= and STOP ON ERROR" ); throwException( "dataTypeExpecting =" + dataTypeExpecting + "= but got no value =" + fieldString + "= and STOP ON ERROR" ); } if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE ) ) { - System.err.println( "date >" + fieldString + "<" ); + Util.logConsole( "date >" + fieldString + "<" ); fieldString = convertMmmFormattedDate( fieldString, getCustomReaderData().getDateFormatString() ); - System.err.println( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); date = dateFormat.parseInt( fieldString ); // I thought the format was giving incorrect dates for 2/5/2011 so I started doing my own thing. I later // found out the method I am calling uses an MD method which is working, and my new stuff was not so I left it out. Stan // Date gotDate = parseDateToInt( fieldString, getCustomReaderData().getDateFormatString() ); // part of my new stuff not being used. // date = getIntDate( gotDate ); -// System.err.println( "new date int =" + getIntDate( gotDate ) + "= new date formatted >" + giveFormattedDate( gotDate, getCustomReaderData().getDateFormatString() ) + "<" ); +// Util.logConsole( "new date int =" + getIntDate( gotDate ) + "= new date formatted >" + giveFormattedDate( gotDate, getCustomReaderData().getDateFormatString() ) + "<" ); // txn.setDatePostedInt( date ); // txn.setDateInitiatedInt( date ); @@ -524,33 +525,33 @@ else if ( ( fieldString == null || fieldString.equals( "" ) ) } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE_AVAILABLE ) ) { - System.err.println( "dateAvailable >" + fieldString + "<" ); + Util.logConsole( "dateAvailable >" + fieldString + "<" ); fieldString = convertMmmFormattedDate( fieldString, getCustomReaderData().getDateFormatString() ); - System.err.println( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); dateAvailable = dateFormat.parseInt( fieldString ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE_INITIATED) ) { - System.err.println( "dateInitiated >" + fieldString + "<" ); + Util.logConsole( "dateInitiated >" + fieldString + "<" ); fieldString = convertMmmFormattedDate( fieldString, getCustomReaderData().getDateFormatString() ); - System.err.println( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); dateInitiated = dateFormat.parseInt( fieldString ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE_POSTED ) ) { - System.err.println( "datePosted >" + fieldString + "<" ); + Util.logConsole( "datePosted >" + fieldString + "<" ); fieldString = convertMmmFormattedDate( fieldString, getCustomReaderData().getDateFormatString() ); - System.err.println( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); datePosted = dateFormat.parseInt( fieldString ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DATE_PURCHASED ) ) { - System.err.println( "datePurchased >" + fieldString + "<" ); + Util.logConsole( "datePurchased >" + fieldString + "<" ); fieldString = convertMmmFormattedDate( fieldString, getCustomReaderData().getDateFormatString() ); - System.err.println( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); + Util.logConsole( "MMM date str =" + fieldString + "= date int =" + dateFormat.parseInt( fieldString ) + "= old date formatted >" + dateFormat.format( dateFormat.parseInt( fieldString ) ) + "<" ); datePurchased = dateFormat.parseInt( fieldString ); } @@ -559,10 +560,10 @@ else if ( ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_PAYMENT ) && ! ( fieldString == null || fieldString.equals( "" ) ) ) { - System.err.println( "amountString >" + fieldString + "<" ); + Util.logConsole( "amountString >" + fieldString + "<" ); fieldString = fieldString.replaceAll( "\\((.*)\\)", "-$1" ); fieldString = StringUtils.stripNonNumbers( fieldString, (char)amountDecimalSignChar ); - System.err.println( "amountString >" + fieldString + "<" ); + Util.logConsole( "amountString >" + fieldString + "<" ); try { @@ -573,7 +574,7 @@ else if ( ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_PAYMENT ) } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DEPOSIT ) ) { - System.err.println( "flip sign for deposit" ); + Util.logConsole( "flip sign for deposit" ); amount -= currency.getLongValue( amountDouble ); } } @@ -594,38 +595,38 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_CHECK_NUMBER ) ) fieldString = fieldString.replaceAll( "^0*(.*)", "$1" ); } */ - System.err.println( "check number >" + fieldString + "<" ); + Util.logConsole( "check number >" + fieldString + "<" ); checkNumber = fieldString; // txn.setCheckNum( fieldString ); } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_DESCRIPTION ) ) { - System.err.println( "description >" + fieldString + "<" ); + Util.logConsole( "description >" + fieldString + "<" ); // txn.setName( fieldString ); description = fieldString; } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_MEMO ) ) { - System.err.println( "memo >" + fieldString + "<" ); + Util.logConsole( "memo >" + fieldString + "<" ); memo = fieldString; // txn.setMemo( fieldString ); } else if ( dataTypeExpecting.equalsIgnoreCase( "tag" ) ) { - System.err.println( "tag in phone field >" + fieldString + "<" ); + Util.logConsole( "tag in phone field >" + fieldString + "<" ); // storing it into phone field for now since onlinetxn cannot handle tags. A kludge for now. Stan // txn.setPhone( fieldString ); phoneString = fieldString; } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_ACCOUNT_NAME ) ) { - System.err.println( "accountName >" + fieldString + "<" ); + Util.logConsole( "accountName >" + fieldString + "<" ); accountName = fieldString; if ( book.getRootAccount().getAccountByName( accountName ) == null ) { - //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); -// //System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); + //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); +// //Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); // throwException( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); return false; // skip this line } @@ -633,13 +634,13 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_ACCOUNT_NAME ) ) } else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_CATEGORY_NAME ) ) { - System.err.println( "categoryName >" + fieldString + "<" ); + Util.logConsole( "categoryName >" + fieldString + "<" ); categoryName = fieldString; // if ( rootAccount.getAccountByName( accountName ) == null ) // { -// System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); -//// System.err.println( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); +// Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= will not import it." ); +//// Util.logConsole( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); //// throwException( "dataTypeExpecting =" + dataTypeExpecting + "= but that account does not exist =" + fieldString + "= and STOP ON ERROR" ); // return false; // skip this line // } @@ -649,7 +650,7 @@ else if ( dataTypeExpecting.equalsIgnoreCase( DATA_TYPE_CATEGORY_NAME ) ) // MOVED to TransactionReader so everyone creates it the same way. // txn.setFITxnId( date + ":" + currency.format( amount, '.' ) + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() ); -// System.err.println( "FITxnld >" + date + ":" + currency.format( amount, '.' ) + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() + "<" ); +// Util.logConsole( "FITxnld >" + date + ":" + currency.format( amount, '.' ) + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() + "<" ); return true; } @@ -667,14 +668,14 @@ public Date parseDateToInt( String dateStr, String format ) sdf.setLenient( false ); ddd = sdf.parse(dateStr); - System.err.println( "parseDateToInt() from format =" + format + "= and date in string =" + dateStr + "= got Date =" + ddd.toString() + "=" ); + Util.logConsole( "parseDateToInt() from format =" + format + "= and date in string =" + dateStr + "= got Date =" + ddd.toString() + "=" ); } catch (ParseException e) { - System.err.println( "parseDateToInt() parseException =" + sdf.toString() + "=" ); + Util.logConsole( "parseDateToInt() parseException =" + sdf.toString() + "=" ); return ddd; } catch (IllegalArgumentException e) { - System.err.println( "parseDateToInt() IllegalArgumentException =" + sdf.toString() + "=" ); + Util.logConsole( "parseDateToInt() IllegalArgumentException =" + sdf.toString() + "=" ); return ddd; } return ddd; @@ -693,18 +694,18 @@ public String convertMmmFormattedDate( String dateStr, String format ) sdf.setLenient( false ); ddd = sdf.parse( dateStr ); - System.err.println( "convertMmmFormattedDate() from format =" + format + "= and date in string =" + dateStr + "= got Date =" + ddd.toString() + "=" ); + Util.logConsole( "convertMmmFormattedDate() from format =" + format + "= and date in string =" + dateStr + "= got Date =" + ddd.toString() + "=" ); jDateFormat = jDateFormat.replace( "MMM", "MM" ); // convert MMM Jan to MM number 1 sdf = new SimpleDateFormat( jDateFormat ); sdf.setLenient( false ); } catch (ParseException e) { - System.err.println( "parseDateToInt() parseException =" + sdf.toString() + "=" ); + Util.logConsole( "parseDateToInt() parseException =" + sdf.toString() + "=" ); return dateStr; } catch (IllegalArgumentException e) { - System.err.println( "parseDateToInt() IllegalArgumentException =" + sdf.toString() + "=" ); + Util.logConsole( "parseDateToInt() IllegalArgumentException =" + sdf.toString() + "=" ); return dateStr; } return sdf.format( ddd ); @@ -759,7 +760,7 @@ else if ( dateAvailable != 0 ) } else { - System.err.println( "*** Error: No Date field is set !" ); + Util.logConsole( "*** Error: No Date field is set !" ); throwException( "*** Error: No Date field is set !" ); } } @@ -800,11 +801,11 @@ else if ( dateAvailable != 0 ) txn.setDatePurchasedInt( date ); } -// System.err.println( "date >" + date + "<" ); -// System.err.println( "date >" + txn.getDateAvailableInt() + "<" ); -// System.err.println( "date >" + txn.getDateInitiatedInt() + "<" ); -// System.err.println( "date >" + txn.getDatePostedInt() + "<" ); -// System.err.println( "date >" + txn.getDatePurchasedInt() + "<" ); +// Util.logConsole( "date >" + date + "<" ); +// Util.logConsole( "date >" + txn.getDateAvailableInt() + "<" ); +// Util.logConsole( "date >" + txn.getDateInitiatedInt() + "<" ); +// Util.logConsole( "date >" + txn.getDatePostedInt() + "<" ); +// Util.logConsole( "date >" + txn.getDatePurchasedInt() + "<" ); txn.setCheckNum( checkNumber ); txn.setName( description ); @@ -815,7 +816,7 @@ else if ( dateAvailable != 0 ) // MOVED to TransactionReader so everyone creates it the same way. // txn.setFITxnId( date + ":" + currency.format( amount, '.' ) // + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() ); - //System.err.println( "FITxnld >" + date + ":" + currency.format( amount, '.' ) + //Util.logConsole( "FITxnld >" + date + ":" + currency.format( amount, '.' ) // + ":" + description + ":" + txn.getCheckNum() + ":" + txn.getMemo() + "<" ); //(date == 0 ? datePurchased : date) return true; @@ -830,7 +831,7 @@ public String[] getSupportedDateFormats() @Override public String getDateFormat() { - System.err.println( "customReader getDateFormat() >" + dateFormatStringSelected + "<" ); + Util.logConsole( "customReader getDateFormat() >" + dateFormatStringSelected + "<" ); return dateFormatStringSelected; } @@ -842,7 +843,7 @@ public void setDateFormat( String format ) return; } - System.err.println( "setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "=" ); + Util.logConsole( "setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "=" ); if ( ! format.equals( dateFormatStringSelected ) ) { dateFormat = new CustomDateFormat( format ); @@ -851,8 +852,8 @@ public void setDateFormat( String format ) /* dateFormatStringSelected = getCustomReaderData().getDateFormatString(); - System.err.println( "customReader setDateFormat() =" + dateFormatStringSelected + "<" ); - System.err.println( "customReader customReaderDialog.getDateFormatSelected() >" + getCustomReaderData().getDateFormatString() + "<" ); + Util.logConsole( "customReader setDateFormat() =" + dateFormatStringSelected + "<" ); + Util.logConsole( "customReader customReaderDialog.getDateFormatSelected() >" + getCustomReaderData().getDateFormatString() + "<" ); dateFormat = new CustomDateFormat( getCustomReaderData().getDateFormatString() ); */ diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE index 61dea62..ef73ac9 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/INGNetherlandsReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; public class INGNetherlandsReader diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE index 9bef54d..b6bd436 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/SimpleCreditDebitReader.java-HIDE @@ -19,7 +19,7 @@ import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.DateGuesser; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE index 1304899..66aa72e 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/WellsFargoReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /** diff --git a/src/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE b/src/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE index 8fccf92..3ae223a 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE +++ b/src/com/moneydance/modules/features/mdcsvimporter/formats/YodleeReader.java-HIDE @@ -18,7 +18,7 @@ import com.moneydance.apps.md.model.OnlineTxn; import com.moneydance.modules.features.mdcsvimporter.CSVData; import com.moneydance.modules.features.mdcsvimporter.TransactionReader; import com.moneydance.util.CustomDateFormat; -import com.moneydance.util.StringUtils; +import com.infinitekind.util.StringUtils; import java.io.IOException; /* @@ -237,7 +237,7 @@ public class YodleeReader } public void createSupportedDateFormats(String dateFormatArg) { - System.err.println("\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------"); + Util.logConsole("\n--------- entered createSupportedDateFormats() dateFormatArg =" + dateFormatArg + "= -------------"); String[] tmp = new String[1]; tmp[0] = dateFormatArg; SUPPORTED_DATE_FORMATS = tmp; @@ -261,7 +261,7 @@ public class YodleeReader return; } - System.err.println("setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "="); + Util.logConsole("setDateFormat() format =" + format + "= dateFormatString =" + dateFormatString + "="); if (!format.equals(dateFormatStringSelected)) { dateFormat = new CustomDateFormat(format); dateFormatStringSelected = format; diff --git a/src/com/moneydance/modules/features/mdcsvimporter/meta_info.dict b/src/com/moneydance/modules/features/mdcsvimporter/meta_info.dict index 252ebea..398884c 100644 --- a/src/com/moneydance/modules/features/mdcsvimporter/meta_info.dict +++ b/src/com/moneydance/modules/features/mdcsvimporter/meta_info.dict @@ -1,6 +1,6 @@ { - "vendor" = "Stan Towianski" - "module_build" = "23" + "vendor" = "Stan Towianski - Updated by Stuart Beesley StuWareSoftSystems" + "module_build" = "1000" "minbuild" = "1000" "vendor.url" = "https://github.com/stant/mdcsvimporter2015/releases" "module_name" = "mdcsvimporter2015"