001 package net.sourceforge.mp3dings;
002
003 /* Mp3dings - manage mp3 meta-information
004 * Copyright (C) 2003 Moritz Ringler
005 * $Id: Mp3dingsTableModel.java 13 2007-07-27 09:52:39Z ringler $
006 *
007 * This program is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU General Public License
009 * as published by the Free Software Foundation; either version 2
010 * of the License, or (at your option) any later version.
011 *
012 * This program is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with this program; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020 */
021
022 import java.awt.Frame;
023 import java.io.File;
024 import java.util.prefs.Preferences;
025 import net.sourceforge.mp3dings.filter.FilterCollection;
026 import de.mospace.swing.event.MessageListener;
027 import de.mospace.swing.event.DataChangeListener;
028 import de.mospace.swing.table.HeaderPopupTableModel;
029 import de.mospace.swing.table.SortableTableModel;
030
031 /** The common interface of the mp3dings table models. **/
032 public interface Mp3dingsTableModel extends SortableTableModel,
033 FieldAssociatedTableModel, HeaderPopupTableModel{
034
035 public FilterCollection getFilters();
036 public boolean isFiltered(int column);
037 public Preferences getPrefs();
038 public String getPrefKey();
039
040 /* get file */
041 public File getFile(int row);
042
043 /**
044 * Gets the fields that are currently displayed.
045 *
046 * @return the fields that are currently displayed
047 */
048 public Field[] getFields();
049
050 /* change tracking */
051 public boolean discardChanges(Frame parent);
052 public void resetChangeCounter();
053
054 /* general table model methods */
055 /**
056 * Gets the value of the specified table cell, converting FullTextString
057 * values to strings on the fly.
058 *
059 * @param row the row of the cell
060 * @param col the column of the cell
061 * @return the value of the cell
062 */
063 public Object get(int row, int col);
064
065 /**
066 * Updates a range of cells and notifies
067 * tables displaying this model of the change in the data.
068 * This is faster than calling {@link #setValueAt(Object, int,
069 * int)} for each cell.<p>
070 * <em>This method must only be called from the AWT event dispatching
071 * thread, use {@link #set(Object, int[], int[])} if you want to update the
072 * table from another thread.</em>
073 *
074 * @param rows the rows of the cells
075 * @param cols the columns of the cells
076 * @param v the new value of the cells
077 */
078 public void setValueAt(Object v, int[] rows, int[] cols);
079
080 /**
081 * Updates a range of cells without firing any
082 * events. If you want a table displaying this model to reflect the change
083 * in the data you must explicitly ask it to do so.
084 *
085 * @param rows the rows of the cells
086 * @param cols the columns of the cells
087 * @param v the new value of the cells
088 *
089 * @see #setValueAt(Object, int[], int[])
090 */
091 public void set(Object v, int[] rows, int[] cols);
092
093 /** Updates the value of the specified table cell without firing any
094 * events. If you want a table displaying this model to reflect the change
095 * in the data you must explicitly ask it to do so.
096 *
097 * @param rows the row of the cell
098 * @param cols the column of the cell
099 * @param v the new val9ue of the cell
100 *
101 * @see #setValueAt(Object, int, int)
102 */
103 public void set(Object v, int rows, int cols);
104
105 /** Sets the columns by which this table is sorted. The entries will
106 * be sorted in ascending order.
107 *
108 * @param cols the columns to sort by in order of decreasing precedence
109 *
110 * @see SortableTableModel#setSortBy(int, boolean)
111 */
112 public void setSortBy(int[] cols);
113
114 /**
115 * Looks for consecutive duplicates in <code>rows</code>, starting at
116 * <code>startRowIndex</code>.
117 * The returned array contains the index of the first and the last rows
118 * that are identical in all columns specified by <code>cols</code>.
119 *
120 * @param rows an array of table model rows to search for duplicates
121 * @param startRowIndex the index where the search will begin
122 * @param cols the cols that will be taken into account for comparison, if
123 * <code>null</code> all columns are used.
124 * @return the bounds of the next set of consecutive duplicate rows
125 */
126 public int[] getNextDuplicates(int[] rows, int startRowIndex, int[] cols);
127
128 public void addMessageListener(MessageListener ml);
129 public void addDataChangeListener(DataChangeListener dl);
130 public void fireDataChanged(int n);
131
132 /** AbstractTableModel's fireTableDataChanged() method **/
133 public void fireTableDataChanged();
134 }