import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.table.AbstractTableModel;
+import yukihane.inqubus.manager.TaskKind;
+import yukihane.inqubus.manager.TaskStatus;
/**
*
*/
public class TargetsTableModel extends AbstractTableModel {
+ private static final long serialVersionUID = 1L;
+ private static final Logger logger = Logger.getLogger(TargetsTableModel.class.getName());
private final List<Target> targets = new ArrayList<Target>();
- private final String[] columnNames = new String[]{"動画", "コメント", "投コメ", "状態"};
- private final Class<?>[] columnClasses = new Class<?>[]{Location.class, Location.class, Location.class, Status.class};
+ private static final int STATUS_CLOMN = 4;
+ private final String[] columnNames = new String[]{"ID", "動画", "コメ", "変換", "状態"};
+ private final Class<?>[] columnClasses = new Class<?>[]{String.class, Boolean.class, Boolean.class, Boolean.class,
+ Progress.class};
@Override
public int getRowCount() {
Object res;
switch (columnIndex) {
case 0:
- res = t.getMovie();
+ res = t.getVideoId();
break;
case 1:
- res = t.getComment();
+ res = Boolean.valueOf(t.isVideoDownload());
break;
case 2:
- res = t.getOwnerComment();
+ res = Boolean.valueOf(t.isCommentDownload());
break;
case 3:
- res = t.getStatus();
+ res = Boolean.valueOf(t.isConvert());
+ break;
+ case 4:
+ res = t.getProgress();
break;
default:
throw new IllegalArgumentException();
return res;
}
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
public void addTarget(Collection<Target> t) {
int before = targets.size();
targets.addAll(t);
list.add(t);
addTarget(list);
}
+
+ public Target getTarget(int rowIndex) {
+ return targets.get(rowIndex);
+ }
+
+ public void setStatus(int id, TaskKind taskKind, TaskStatus taskStatus, double percent, String status) {
+ int pos = -1;
+ for (int i = 0; i < targets.size(); i++) {
+ final Target t = targets.get(i);
+ final int ri = t.getRowId();
+ if (id == ri) {
+ pos = i;
+ break;
+ }
+ }
+ if (pos < 0) {
+ logger.log(Level.SEVERE, "本来存在すべきレコードが存在しません id:{0}", id);
+ return;
+ }
+
+ final Target t = targets.get(pos);
+ t.setProgress(taskKind, taskStatus, percent, status);
+ fireTableCellUpdated(pos, STATUS_CLOMN);
+ }
}