Author: tchemit Date: 2008-04-03 17:15:19 +0000 (Thu, 03 Apr 2008) New Revision: 316 Removed: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/VCSFileStateTableModel.java Log: after remove some old ui classes Deleted: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/VCSFileStateTableModel.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/VCSFileStateTableModel.java 2008-04-03 17:13:23 UTC (rev 315) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/model/VCSFileStateTableModel.java 2008-04-03 17:15:19 UTC (rev 316) @@ -1,205 +0,0 @@ -/* -* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, -* Benjamin Poussin, Tony Chemit -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package org.codelutin.vcs.ui.model; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.vcs.VCSAction; -import org.codelutin.vcs.VCSFileState; -import org.codelutin.vcs.VCSState; -import org.codelutin.vcs.ui.VCSUIConstants; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -/** - * Simple Table model to display list of VCSFileState - * - * @author chemit - */ -public class VCSFileStateTableModel extends javax.swing.table.AbstractTableModel { - - protected List<VCSFileState> data; - - protected String[] columnNames; - - private static final long serialVersionUID = 4697917831388337369L; - - public VCSFileStateTableModel() { - super(); - columnNames = VCSUIConstants.SIMPLE_COLUMNS_NAMES; - } - - public VCSFileStateTableModel(String[] columnNames) { - super(); - this.columnNames = columnNames; - } - - public VCSFileStateTableModel(List<VCSFileState> data) throws RuntimeException { - super(); - setData(data); - } - - public List<VCSFileState> getData() { - return data; - } - - public int getColumnCount() { - return columnNames.length; - } - - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public Class<?> getColumnClass(int columnIndex) { - return String.class; - } - - @Override - public String getColumnName(int columnIndex) { - return _(columnNames[columnIndex]); - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } - - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - // read only data - } - - public Object getValueAt(int rowIndex, int columnIndex) { - if (isEmpty()) return null; - VCSFileState item = data.get(rowIndex); - Object result = null; - if (columnIndex == 0) { - // get module - result = item.getModuleName(); - } else if (columnIndex == 1) { - // get file - result = item.getFile().getName(); - } else if (columnIndex == 2) { - // get status - result = item.getState(); - } - return result; - } - - public void setData(List<VCSFileState> states) { - if (data != null) { - data.clear(); - data.addAll(states); - } else { - data = new ArrayList<VCSFileState>(states); - } - fireTableDataChanged(); - } - - public void addData(VCSFileState... states) { - if (data != null) { - data.addAll(Arrays.asList(states)); - } else { - data = new ArrayList<VCSFileState>(Arrays.asList(states)); - } - fireTableDataChanged(); - } - - public void removeData(VCSFileState... states) { - if (isEmpty()) { - return; - } - data.removeAll(Arrays.asList(states)); - fireTableDataChanged(); - } - - private boolean isEmpty() { - return data == null || data.isEmpty(); - } - - public void clear() { - if (isEmpty()) { - return; - } - data.clear(); - fireTableDataChanged(); - } - - public VCSFileState[] getData(VCSAction action) { - if (isEmpty()) { - return new VCSFileState[0]; - } - List<VCSFileState> list = new ArrayList<VCSFileState>(data); - for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) { - VCSFileState fileState = it.next(); - List<VCSAction> actions = fileState.getState().getActions(); - if (!actions.contains(action)) { - it.remove(); - } - } - return list.toArray(new VCSFileState[list.size()]); - } - - public VCSFileState[] getData(VCSState action) { - if (isEmpty()) { - return new VCSFileState[0]; - } - List<VCSFileState> list = new ArrayList<VCSFileState>(data); - for (Iterator<VCSFileState> it = list.iterator(); it.hasNext();) { - VCSFileState fileState = it.next(); - if (!action.equals(fileState.getState())) { - it.remove(); - } - } - return list.toArray(new VCSFileState[list.size()]); - } - - public VCSState[] getStates() { - if (isEmpty()) { - return new VCSState[0]; - } - List<VCSState> result = new ArrayList<VCSState>(); - for (VCSFileState vcsFileState : data) { - VCSState state = vcsFileState.getState(); - if (state != null && !result.contains(state)) { - result.add(state); - } - } - return result.toArray(new VCSState[result.size()]); - } - - public VCSAction[] getActions() { - if (isEmpty()) { - return new VCSAction[0]; - } - List<VCSAction> result = new ArrayList<VCSAction>(); - for (VCSFileState vcsFileState : data) { - VCSAction action = vcsFileState.getAction(); - if (action != null && !result.contains(action)) { - result.add(action); - } - } - return result.toArray(new VCSAction[result.size()]); - } -} \ No newline at end of file