com.ibm.lab.soln.editor.core
Class MiniSpreadsheet

java.lang.Object
  |
  +--com.ibm.lab.soln.editor.core.MiniSpreadsheet

public class MiniSpreadsheet
extends java.lang.Object

Simple model for a "mini-spreadsheet" containing text/integer cell values.

See Also:
MiniSpreadsheetRow, IMiniSpreadsheetListener

Field Summary
static int DEFAULT_COLUMN_COUNT
           
static int DEFAULT_ROW_COUNT
           
static int MAX_COLUMN_COUNT
           
 
Constructor Summary
MiniSpreadsheet(java.io.InputStream is)
          Set the rows based on the content of the provided semi-colon delimited input stream.
MiniSpreadsheet(int rowCount, int columnCount)
          Return a mini-spreadsheet having dimensions [rows,columns].
 
Method Summary
 void addMiniSpreadsheetListener(IMiniSpreadsheetListener listener)
          Add the listener.
 void appendRow()
          Insert a new row at the end.
 void clearAll()
          Set all rows/columns to an empty string.
protected  void fireCellChanged(int row, int column, java.lang.String value)
           
 int getColumnCount()
          Returns the number of columns.
 int getInt(int row, int column)
          Get the value at [row,column] as an integer or zero if not a value integer format.
 int getRowCount()
          Return the number of rows.
 MiniSpreadsheetRow[] getRows()
          Return the rows.
 java.lang.String getString(int row, int column)
          Get the value at [row,column] as a string.
 int getTotal()
          Return the total of all integer cells.
 void load(java.io.InputStream is)
          Set the rows based on the content of the provided semi-colon delimited input stream.
 void removeMiniSpreadsheetListener(IMiniSpreadsheetListener listener)
          Remove the listener.
protected  void removeRow(MiniSpreadsheetRow msr)
           
 void save(org.eclipse.core.resources.IFile file)
          Save the current contents in a semi-colon delimited text file.
 void setData(int row, int column, java.lang.String newValue)
          Set the value at [row,column] to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLUMN_COUNT

public static final int DEFAULT_COLUMN_COUNT
See Also:
Constant Field Values

DEFAULT_ROW_COUNT

public static final int DEFAULT_ROW_COUNT
See Also:
Constant Field Values

MAX_COLUMN_COUNT

public static final int MAX_COLUMN_COUNT
See Also:
Constant Field Values
Constructor Detail

MiniSpreadsheet

public MiniSpreadsheet(java.io.InputStream is)
                throws org.eclipse.core.runtime.CoreException
Set the rows based on the content of the provided semi-colon delimited input stream.


MiniSpreadsheet

public MiniSpreadsheet(int rowCount,
                       int columnCount)
Return a mini-spreadsheet having dimensions [rows,columns].

Method Detail

addMiniSpreadsheetListener

public void addMiniSpreadsheetListener(IMiniSpreadsheetListener listener)
Add the listener.

See Also:
IMiniSpreadsheetListener

appendRow

public void appendRow()
Insert a new row at the end.


clearAll

public void clearAll()
Set all rows/columns to an empty string.


fireCellChanged

protected void fireCellChanged(int row,
                               int column,
                               java.lang.String value)

getColumnCount

public int getColumnCount()
Returns the number of columns.


getInt

public int getInt(int row,
                  int column)
Get the value at [row,column] as an integer or zero if not a value integer format.


getRowCount

public int getRowCount()
Return the number of rows.


getRows

public MiniSpreadsheetRow[] getRows()
Return the rows.


getString

public java.lang.String getString(int row,
                                  int column)
Get the value at [row,column] as a string.


getTotal

public int getTotal()
Return the total of all integer cells. Invalid cells are treated as zero.


load

public void load(java.io.InputStream is)
          throws org.eclipse.core.runtime.CoreException
Set the rows based on the content of the provided semi-colon delimited input stream.

org.eclipse.core.runtime.CoreException

removeMiniSpreadsheetListener

public void removeMiniSpreadsheetListener(IMiniSpreadsheetListener listener)
Remove the listener.

See Also:
IMiniSpreadsheetListener

removeRow

protected void removeRow(MiniSpreadsheetRow msr)

save

public void save(org.eclipse.core.resources.IFile file)
          throws org.eclipse.core.runtime.CoreException
Save the current contents in a semi-colon delimited text file.

org.eclipse.core.runtime.CoreException

setData

public void setData(int row,
                    int column,
                    java.lang.String newValue)
Set the value at [row,column] to a string.