Skip to content

Commit

Permalink
Enhancements to preview window. Point to all problems.
Browse files Browse the repository at this point in the history
Add open file. Error count.
Fix display of columns when figure out how columns there really are.
  • Loading branch information
stant committed Mar 21, 2016
1 parent 81be477 commit e69d12d
Show file tree
Hide file tree
Showing 23 changed files with 970 additions and 275 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ Remove old version. Restart. Install via 'Add From File'.
The plug-in is still considered BETA, however, it works well for people who have tried it.

It is distributed under GNU LGPL. Among other things this means that it is free, but that the authors cannot take any responsibility for you using this code.

Quick Usage:<br/>
This is a top down window process. I might look at getting rid of 'Date Format', but when I have time.
You have to define a reader first of all and tell it how to match filenames. An improvement I plan to make is to tell people if they do not have one and that they need to create one first.

1.) So, what I do is download a new trans list csv file from my bank (XYZ)
2.) in MD do, "Import File" (my extension)
3.) I have say 6 defined so I pick the "File Reader" for my bank (XYZ).
4.) I hit button "Find Import File(s) for this Reader."
It populates "Select Import File:" dropdown with my list of files that match my reader "filename matcher". It also gives the number of files that match. Hopefully 1. If not I pick the file I want to import.
5.) Hit "Preview Import" so it validates the importing transactions.
6.) "Process" button becomes enabled. I hit it.
Done.
2 changes: 1 addition & 1 deletion build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu, 26 Mar 2015 00:12:42 -0400
#Sun, 20 Mar 2016 22:38:40 -0400


F\:\\github\\mdcsvimporter2015=
Binary file modified dist/mdcsvimporter.mxt
Binary file not shown.
Binary file modified dist/mdcsvimporter.zip
Binary file not shown.
14 changes: 10 additions & 4 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ is divided into following sections:
</not>
</and>
</condition>
<property name="javac.fork" value="${jdkBug6558476}"/>
<condition else="false" property="javac.fork">
<or>
<istrue value="${jdkBug6558476}"/>
<istrue value="${javac.external.vm}"/>
</or>
</condition>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
Expand All @@ -217,6 +222,7 @@ is divided into following sections:
<condition else="" property="testng.debug.mode" value="-mixed">
<istrue value="${junit+testng.available}"/>
</condition>
<property name="java.failonerror" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
Expand Down Expand Up @@ -693,7 +699,7 @@ is divided into following sections:
<sequential>
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
<java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
Expand Down Expand Up @@ -768,7 +774,7 @@ is divided into following sections:
<attribute default="${debug.classpath}" name="classpath"/>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" dir="${work.dir}" fork="true">
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
Expand All @@ -795,7 +801,7 @@ is divided into following sections:
<attribute default="jvm" name="jvm"/>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" dir="${work.dir}" fork="true">
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
Expand Down
4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=958a1d3e
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=277518bf
nbproject/build-impl.xml.script.CRC32=5d17cf3b
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
nbproject/build-impl.xml.script.CRC32=6c39e587
nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
2 changes: 1 addition & 1 deletion nbproject/private/private.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\stan\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
user.properties.file=C:\\Users\\stowians\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
8 changes: 7 additions & 1 deletion nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/Main.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderDialog.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/TransactionReader.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/PreviewImportWin.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/ImportDialog.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/CustomTableCellRenderer.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/formats/CustomReader.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/CustomReaderData.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java</file>
<file>file:/F:/github/mdcsvimporter2015/src/com/moneydance/modules/features/mdcsvimporter/CSVData.java</file>
</group>
</open-files>
</project-private>
119 changes: 109 additions & 10 deletions src/com/moneydance/modules/features/mdcsvimporter/CSVData.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

/**
*
Expand All @@ -25,9 +24,10 @@
public class CSVData
{
private String[][] data;
private String[][] dataErr = { { "" } };
private int currentLineIndex = -1;
private int currentFieldIndex = -1;

public CSVReader reader;

public CSVData( CSVReader readerArg )
Expand All @@ -39,20 +39,27 @@ public void reset()
{
currentLineIndex = -1;
currentFieldIndex = -1;
//reader.reset(); NOT SUPPORTED
}

public String[][] getData()
{
return data;
}

public String[][] getDataErr()
{
return dataErr;
}

public void parseIntoLines( CustomReaderData customReaderData )
throws IOException
{
ArrayList<String> line = new ArrayList<String>();
ArrayList<String[]> file = new ArrayList<String[]>();
int fieldSeparator = customReaderData.getFieldSeparatorChar();

int maxFoundCols = 0;

if ( customReaderData != null )
{
reader.setFieldSeparator( fieldSeparator );
Expand All @@ -62,11 +69,15 @@ public void parseIntoLines( CustomReaderData customReaderData )
{
for ( String s = reader.nextField(); s != null; s = reader.nextField() )
{
System.err.println( " line.add string =" + s + "=" );
//System.err.println( " line.add string =" + s + "=" );
line.add( s );
}

System.err.println( " line.size() =" + line.size() + "=\n" );
if ( line.size() > maxFoundCols )
{
maxFoundCols = line.size();
}
String[] newLine = new String[ line.size() ];
line.toArray( newLine );
file.add( newLine );
Expand All @@ -75,9 +86,37 @@ public void parseIntoLines( CustomReaderData customReaderData )

data = new String[file.size()][];
file.toArray( data );
System.err.println( " parsed lines total =" + file.size() + "=" );
System.err.println( " 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 );
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 );
newLine[c] = "";
}
dataErr[r] = newLine;
}

// System.err.println( "PRINT OUT RESET dataErr" );
// maxr = dataErr.length;
// System.err.println( " reset maxr =" + maxr );
// for ( int r = 0; r < maxr; r++ )
// {
// int maxc = dataErr[r].length;
// System.err.println( " reset maxc =" + maxc );
// for ( int c = 0; c < maxc; c++ )
// {
// System.err.println( "dataErr blank [" + r + "][" + c +"] =" + dataErr[r][c] );
// }
// }
}

public void reverseListRangeOrder( long beg, long end )
Expand Down Expand Up @@ -117,7 +156,7 @@ public boolean nextLine()

public boolean hasEnoughFieldsPerCurrentLine( int neededFields )
{
//System.err.println( "fieldsPerCurrentLine() data[currentLineIndex].length + 1 =" + (data[currentLineIndex].length + 1) );
System.err.println( "fieldsPerCurrentLine() data[currentLineIndex].length + 1 =" + (data[currentLineIndex].length + 1) + " >= neededFields =" + neededFields );
return data[currentLineIndex].length + 1 >= neededFields;
}

Expand Down Expand Up @@ -156,16 +195,76 @@ public String getField()
{
if ( currentLineIndex < 0 || currentLineIndex >= data.length )
{
return null;
return "";
}
if ( currentFieldIndex < 0 || currentFieldIndex >= data[currentLineIndex].length )
{
return null;
return "";
}

return data[currentLineIndex][currentFieldIndex];
}

public String getFieldErr()
{
//System.err.println( "getFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" );
if ( currentLineIndex < 0 || currentLineIndex >= dataErr.length )
{
return "";
}
if ( currentFieldIndex < 0 || currentFieldIndex >= dataErr[currentLineIndex].length )
{
return "";
}

return dataErr[currentLineIndex][currentFieldIndex];
}

public void setFieldErr( String errStr )
{
//System.err.println( "setFieldErr current ptr [" + currentLineIndex + "][" + currentFieldIndex + "]" );
if ( currentLineIndex < 0 || currentLineIndex >= dataErr.length )
{
return;
}
if ( currentFieldIndex < 0 || currentFieldIndex >= dataErr[currentLineIndex].length )
{
return;
}

dataErr[currentLineIndex][currentFieldIndex] = errStr;
}

public String getFieldErr( int row, int col )
{
//System.err.println( "getFieldErr [" + row + "][" + col + "]" );
if ( row < 0 || row >= dataErr.length )
{
return "";
}
if ( col < 0 || col >= dataErr[row].length )
{
return "";
}

return dataErr[row][col];
}

public void setFieldErr( int row, int col, String errStr )
{
//System.err.println( "setFieldErr [" + row + "][" + col + "]" );
if ( row < 0 || row >= dataErr.length )
{
return;
}
if ( col < 0 || col >= dataErr[row].length )
{
return;
}

dataErr[row][col] = errStr;
}

public int getCurrentLineIndex()
{
return currentLineIndex;
Expand Down Expand Up @@ -207,7 +306,7 @@ public String printCurrentLine()
if ( currentLineIndex < 0 || currentLineIndex >= data.length )
{
System.err.append( "currentLineIndex out of range =" + currentLineIndex );
return null;
return "";
}

System.err.append( "\n curr line >" );
Expand All @@ -224,7 +323,7 @@ public String printCurrentLine()
System.err.append( "*** Error in printCurrentLine at currentLineIndex =" + currentLineIndex + " currentFieldIndex =" + currentFieldIndex );
}
System.err.append( "< curr line." );
return null;
return "";
}

public void printFile()
Expand Down
10 changes: 10 additions & 0 deletions src/com/moneydance/modules/features/mdcsvimporter/CSVReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ public void close()
lastChar = -1;
}

// THIS IS NOT SUPPORTED
// protected final void reset()
// {
// try {
// this.reader.reset();
// } catch (IOException ex) {
// Logger.getLogger(CSVReader.class.getName()).log(Level.SEVERE, null, ex);
// }
// }

/**
* Used to move to the next line in the CSV file. It must be called before the each
* line is processed, including before the very first line in the file. Any fields on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value=","/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
<Dimension value="[40, 25]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
Expand Down Expand Up @@ -849,7 +849,7 @@
<Property name="enabled" type="boolean" value="false"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
<Dimension value="[40, 25]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
Expand Down Expand Up @@ -879,7 +879,7 @@
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="."/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
<Dimension value="[40, 25]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 25]"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

fieldSeparatorChar.setHorizontalAlignment(javax.swing.JTextField.CENTER);
fieldSeparatorChar.setText(",");
fieldSeparatorChar.setMinimumSize(new java.awt.Dimension(20, 25));
fieldSeparatorChar.setMinimumSize(new java.awt.Dimension(40, 25));
fieldSeparatorChar.setPreferredSize(new java.awt.Dimension(20, 25));
fieldSeparatorChar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Expand Down Expand Up @@ -1367,7 +1367,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
amountGroupingSeparatorChar.setText(",");
amountGroupingSeparatorChar.setEnabled(false);
amountGroupingSeparatorChar.setFocusable(false);
amountGroupingSeparatorChar.setMinimumSize(new java.awt.Dimension(20, 25));
amountGroupingSeparatorChar.setMinimumSize(new java.awt.Dimension(40, 25));
amountGroupingSeparatorChar.setPreferredSize(new java.awt.Dimension(20, 25));
amountGroupingSeparatorChar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Expand All @@ -1390,7 +1390,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

amountDecimalSignChar.setHorizontalAlignment(javax.swing.JTextField.CENTER);
amountDecimalSignChar.setText(".");
amountDecimalSignChar.setMinimumSize(new java.awt.Dimension(20, 25));
amountDecimalSignChar.setMinimumSize(new java.awt.Dimension(40, 25));
amountDecimalSignChar.setPreferredSize(new java.awt.Dimension(20, 25));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
Expand Down
Loading

0 comments on commit e69d12d

Please sign in to comment.