home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 14.5 KB | 417 lines |
- /*
- * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
- *
- * www.krumel.com - controls@krumel.com
- *
- * Permission is given to the buyer of this package for one software
- * developer to use this software on one CPU (one workstation) and to make
- * one backup copy. You may uitilize and/or modify this class for use in your
- * projects. You may distribute or sell any executable which results from
- * using this code in yur application, except a utility or class of similar
- * nature to this product. You may distribute this product in compiled
- * form only, but soley to be used with your cmpiled executable product
- * for the puposes of dynamic loading. You may NOT redistribute the source
- * code in any form or make it accessible through a network or other
- * distribution media to others. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * The source code is the confidential and proprietary information
- * of Krumel & Associates, Inc. ("Confidential Information"). You shall
- * not disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Krumel & Associates, Inc..
-
- * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
- * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
- * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
- * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- */
-
- package symantec.itools.db.awt;
-
- import java.awt.Image;
-
- /**
- * Interface defines the API required to support storing data for the TableView.<p>
- *
- * All row and column values are 0 relative.
- */
- public interface DataSource extends java.io.Serializable {
- /**
- * TableView level event that signifies that the current row has changed.
- */
- public static final String ROW_CHANGE_EVENT = "Row Change";
-
- /**
- * Sets the TableView displaying the data.
- */
- public void setTableView(TableView v);
-
- /**
- * Gets the TableView displaying the data for the DataSource
- */
- public TableView getView();
-
- /**
- * Informs the data source whether the TableView will be requesting successive data
- * for read only purposes.
- * @param manual true if the data source should expect read only data requests
- */
- public void fetchMode(boolean manual);
-
- /**
- * Sets the Data type for cell data when no data value has been set.
- */
- public void setDefaultData(Data defaultValue);
-
- /**
- * Requests the DataSource set an appropriate default data type .
- */
- public void setDefaultData();
-
- /**
- * Gets whether the DataSource has the ability to configure a TableView
- */
- public boolean supportsMeta();
-
- /**
- * Called by the TableView to configure the interface if the DataSource supports
- * meta information
- * @param v The TableView to configure
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested
- */
- public void setupTableView(TableView v) throws TypeNotSupported;
-
- /**
- * Requests the current data element be reset to the previously committed
- * state
- */
- public void rollbackCurrentData();
-
- /**
- * Gets the data for a cell that should only be used for reading. It does
- * not change the cell data being currently edited.
- * @param row the cells row
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public Data readData(int row, int col) throws DataNotAvailable;
-
- /**
- * Gets the data for a cell. If the requested data is not the data being
- * currently edited, the current data should be set to the data requested
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public Data getData(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Gets the data for a cell. If the requested data is not the data being
- * currently edited, the current data should be set to the data requested
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public Data getData(int r, int c) throws DataNotAvailable;
-
- /**
- * Commits the current data.
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void commitData() throws TypeNotSupported;
-
- /**
- * Sets the data value for a cell.
- * @param r the row of the cell
- * @param c the column of the cell
- * @param data the data value for the cell
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void setData(int r, int c, Data data) throws TypeNotSupported;
-
- /**
- * Sets the data value for a cell.
- * @param coord the cooridates of the cell
- * @param data the data value for the cell
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void setData(Coordinate coord, Data data) throws TypeNotSupported;
-
- /**
- * Gets the textual representation of a cell's data
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public String getText(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Gets an image representation of a cell's data
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public Image getImage(Coordinate coords) throws DataNotAvailable;
-
- /**
- * Deletes or marks a row for deletion from the data source
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void deleteRow(int row) throws TypeNotSupported;
-
- /**
- * Undeletes a row in the data source
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void undeleteRow(int row) throws TypeNotSupported;
-
- /**
- * Inserts a new row in the data source above the specified row
- * @exception TypeNotSupported If the data source does not support the type of
- * action requested or is not successful
- */
- public void insertRow(int row) throws TypeNotSupported;
-
- /**
- * Appends a new row at the end of the data source's data.
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public int appendRow() throws TypeNotSupported;
-
- /**
- * Gets whether the data source supports a specified type of data.
- */
- public boolean supports(Coordinate coords, int type);
-
- /**
- * Called in response to circulating an event caused by an invocation of
- * TableView.routeEvent(). The event IDs are specified in the CellEvent class
- */
- public void handleCellEvent(symantec.itools.db.awt.event.CellEvent e);
-
- /**
- * Gives a data source a chance to perform any actions in response to a table
- * level event.
- */
- public void handleTableEvent(symantec.itools.db.awt.event.TableEvent e);
-
- /**
- * Routes any exceptions generated to the TableView for proper handling which may
- * include putting a message on status bar or logging to a file.
- */
- public void handleException(int row, int col, Exception ex);
-
- /**
- * Requests the data source reread it data.
- */
- public void refresh();
-
- /**
- * Requests the data source remove all data.
- */
- public void clear();
-
- /**
- * Requests the data source save the current state as appopriate.
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public void save() throws TypeNotSupported;
-
- /**
- * Requests that any actions performed on a row be undone. The meaning
- * is left open and is to interpreted as appropriate for the type of
- * data source
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public void undoRow(int row) throws TypeNotSupported;
-
- /**
- * Gets whether a cells data is editable or non-editable
- * @return true if the data may be altered by the user.
- */
- public boolean isDataEditable(int row, int col);
-
- /**
- * Informs the data source of the current row of the TableView.
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public void setCurrentRow(int row) throws TypeNotSupported;
-
-
- //BS: added constants new, clean, deleted, modified row and non_exists
-
- /**
- * A constant indicating the row is new.
- * @see #rowState
- * @see #CLEAN_ROW
- * @see #DELETED_ROW
- * @see #MODIFIED_ROW
- * @see #NONEXISTS_ROW
- */
- public static final int NEW_ROW = 0;
- /**
- * A constant indicating the state of the row is clean (it has not been
- * been changed since loaded from its source).
- * @see #rowState
- * @see #NEW_ROW
- * @see #DELETED_ROW
- * @see #MODIFIED_ROW
- * @see #NONEXISTS_ROW
- */
- public static final int CLEAN_ROW = 1;
- /**
- * A constant indicating the row has been marked for deletion.
- * @see #rowState
- * @see #NEW_ROW
- * @see #CLEAN_ROW
- * @see #MODIFIED_ROW
- * @see #NONEXISTS_ROW
- */
- public static final int DELETED_ROW = 2;
- /**
- * A constant indicating the row has been modified since creation.
- * @see #rowState
- * @see #NEW_ROW
- * @see #CLEAN_ROW
- * @see #DELETED_ROW
- * @see #NONEXISTS_ROW
- */
- public static final int MODIFIED_ROW = 3;
- /**
- * A constant indicating the row does not exist.
- * @see #rowState
- * @see #NEW_ROW
- * @see #CLEAN_ROW
- * @see #DELETED_ROW
- * @see #MODIFIED_ROW
- */
- public static final int NONEXISTS_ROW = 4;
-
- /**
- * Gets the state of the row.
- * @return the state of the row's data. One of NEW_ROW, CLEAN_ROW, DELETED_ROW,
- * or MODIFIED_ROW
- */
-
- public int rowState(int row);
-
- /**
- * Gets the last row valid in requested range
- * @exception DataNotAvailable if the requested data is not set in the data source
- */
- public int validDataRowRange(int top, int bottom) throws DataNotAvailable;
-
- /**
- * Gets the number of rows of data stored in the data source
- */
- public int rows();
-
- /**
- * Requests the data source get all of the rows from its source of data.
- */
- public int fetchAllRows();
-
- //Here are some methods needed to support DefaultData
- /**
- * Method used to support Defaultdata class. Gets the type of data supported
- * by the cell.
- */
- public int type(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Commits the data for the
- * specified cell
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public void commit(int row, int col) throws TypeNotSupported;
-
- /**
- * Method used to support Defaultdata class. Gets whether the data for the
- * specified cell supports choice selection lists.
- */
- public boolean supportsChoice(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Gets the choices for the cell to
- * display.
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public Data[] getChoices(int row, int col) throws TypeNotSupported;
-
- /**
- * Method used to support Defaultdata class. Sets the textual value for a cell.
- */
- public void setText(int row, int col, String t);
- //pos is space where to be inserted (0 = first char)
-
- /**
- * Method used to support Defaultdata class. Inserts a character at the
- * specified location in the data value for a cell.
- * @param row The cell's row
- * @param col The cell's column
- * @param pos The position to insert character
- * @param c The character
- */
- public void insertChar(int row, int col, int pos, char c);
-
- /**
- * Method used to support Defaultdata class. Sets the text for a cell to a
- * character
- */
- public void setText(int row, int col, char c);
-
- /**
- * Method used to support Defaultdata class. Appends a character to the end
- * of the textual representation of the cell's data.
- */
- public void appendChar(int row, int col, char c);
-
- /**
- * Method used to support Defaultdata class. Clears the textual value of a cell.
- */
- public void clearText(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Deletes a character from a cell's
- * data.
- * @param row The cell's row
- * @param col The cell's column
- * @param pos The position to delete character
- */
- public void deleteChar(int row, int col, int pos);
-
- /**
- * Method used to support Defaultdata class. Gets a substring from a cell's
- * data.
- * @param row The cell's row
- * @param col The cell's column
- * @param spos The starting position of the substring, inclusive
- * @param epos The last position of the substring, exclusive
- */
- public String subString(int row, int col, int spos, int epos);
-
- /**
- * Method used to support Defaultdata class. Sets the image data for a cell
- */
- public void setImage(int row, int col, Image i);
-
- /**
- * Method used to support Defaultdata class. Gets a string representation of
- * a cell's data.
- */
- public String toString(int row, int col);
-
- /**
- * Method used to support Defaultdata class. Gets an image representationof
- * a cell's data.
- */
- public Image toImage(int row, int col);
- }
-
-