<commit_before>package example;
//-*- mode:java; encoding:utf8n; coding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

public class TestModel extends DefaultTableModel {
    private static final ColumnContext[] columnArray = {
        new ColumnContext("No.",      Integer.class, false),
        new ColumnContext("Name",     String.class, false),
        new ColumnContext("Progress", Integer.class, false)
    };
    private final Map<Integer, SwingWorker> swmap = new HashMap<Integer, SwingWorker>();
    private int number = 0;
    public void addTest(Test t, SwingWorker worker) {
        Object[] obj = {number, t.getName(), t.getProgress()};
        super.addRow(obj);
        swmap.put(number, worker);
        number++;
    }
    public synchronized SwingWorker getSwingWorker(int identifier) {
        Integer key = (Integer)getValueAt(identifier, 0);
        return swmap.get(key);
    }
    public Test getTest(int identifier) {
        return new Test((String)getValueAt(identifier,1), (Integer)getValueAt(identifier,2));
    }
    @Override public boolean isCellEditable(int row, int col) {
        return columnArray[col].isEditable;
    }
    @Override public Class<?> getColumnClass(int modelIndex) {
        return columnArray[modelIndex].columnClass;
    }
    @Override public int getColumnCount() {
        return columnArray.length;
    }
    @Override public String getColumnName(int modelIndex) {
        return columnArray[modelIndex].columnName;
    }
    private static class ColumnContext {
        public final String  columnName;
        public final Class   columnClass;
        public final boolean isEditable;
        public ColumnContext(String columnName, Class columnClass, boolean isEditable) {
            this.columnName = columnName;
            this.columnClass = columnClass;
            this.isEditable = isEditable;
        }
    }
}
class Test{
    private String name;
    private Integer progress;
    public Test(String name, Integer progress) {
        this.name = name;
        this.progress = progress;
    }
    public void setName(String str) {
        name = str;
    }
    public void setProgress(Integer str) {
        progress = str;
    }
    public String getName() {
        return name;
    }
    public Integer getProgress() {
        return progress;
    }
}
class ProgressRenderer extends DefaultTableCellRenderer {
    private final JProgressBar b = new JProgressBar(0, 100);
    private final JPanel p = new JPanel(new BorderLayout());
    public ProgressRenderer() {
        super();
        setOpaque(true);
        p.add(b);
//         //TEST:
//         UIManager.put("Table.cellNoFocusBorder", BorderFactory.createEmptyBorder(1,10,1,10));
//         UIManager.put("Table.focusSelectedCellHighlightBorder", BorderFactory.createEmptyBorder(1,10,1,10));
//         UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1,10,1,10));

        p.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
        //XXX: b.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
    }
    @Override public Component getTableCellRendererComponent(JTable table, Object value,
                                                   boolean isSelected, boolean hasFocus,
                                                   int row, int column) {
        Integer i = (Integer)value;
        String text = "Done";
        if(i<0) {
            text = "Canceled";
        }else if(i<100) {
            b.setValue(i);
            b.setBorder(BorderFactory.createEmptyBorder(0,10,0,0));
            b.revalidate();
            return b;
        }
        super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);<commit_msg>comment<commit_after>package example;
//-*- mode:java; encoding:utf8n; coding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

public class TestModel extends DefaultTableModel {
    private static final ColumnContext[] columnArray = {
        new ColumnContext("No.",      Integer.class, false),
        new ColumnContext("Name",     String.class, false),
        new ColumnContext("Progress", Integer.class, false)
    };
    private final Map<Integer, SwingWorker> swmap = new HashMap<Integer, SwingWorker>();
    private int number = 0;
    public void addTest(Test t, SwingWorker worker) {
        Object[] obj = {number, t.getName(), t.getProgress()};
        super.addRow(obj);
        swmap.put(number, worker);
        number++;
    }
    public synchronized SwingWorker getSwingWorker(int identifier) {
        Integer key = (Integer)getValueAt(identifier, 0);
        return swmap.get(key);
    }
    public Test getTest(int identifier) {
        return new Test((String)getValueAt(identifier,1), (Integer)getValueAt(identifier,2));
    }
    @Override public boolean isCellEditable(int row, int col) {
        return columnArray[col].isEditable;
    }
    @Override public Class<?> getColumnClass(int modelIndex) {
        return columnArray[modelIndex].columnClass;
    }
    @Override public int getColumnCount() {
        return columnArray.length;
    }
    @Override public String getColumnName(int modelIndex) {
        return columnArray[modelIndex].columnName;
    }
    private static class ColumnContext {
        public final String  columnName;
        public final Class   columnClass;
        public final boolean isEditable;
        public ColumnContext(String columnName, Class columnClass, boolean isEditable) {
            this.columnName = columnName;
            this.columnClass = columnClass;
            this.isEditable = isEditable;
        }
    }
}
class Test{
    private String name;
    private Integer progress;
    public Test(String name, Integer progress) {
        this.name = name;
        this.progress = progress;
    }
    public void setName(String str) {
        name = str;
    }
    public void setProgress(Integer str) {
        progress = str;
    }
    public String getName() {
        return name;
    }
    public Integer getProgress() {
        return progress;
    }
}
class ProgressRenderer extends DefaultTableCellRenderer {
    private final JProgressBar b = new JProgressBar(0, 100);
    private final JPanel p = new JPanel(new BorderLayout());
    public ProgressRenderer() {
        super();
        setOpaque(true);
//         //TEST:
//         UIManager.put("Table.cellNoFocusBorder", BorderFactory.createEmptyBorder(1,10,1,10));
//         UIManager.put("Table.focusSelectedCellHighlightBorder", BorderFactory.createEmptyBorder(1,10,1,10));
//         UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1,10,1,10));

        p.add(b);
        p.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
        //XXX: b.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
    }
    @Override public Component getTableCellRendererComponent(JTable table, Object value,
                                                   boolean isSelected, boolean hasFocus,
                                                   int row, int column) {
        Integer i = (Integer)value;
        String text = "Done";
        if(i<0) {
            text = "Canceled";
        }else if(i<100) {
            b.setValue(i);
            return p;
        }
        super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
{'fraction_non_alphanumeric': 0.10680127523910733, 'fraction_numerical': 0.011556854410201912, 'mean_word_length': 2.585238095238095, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3626863', 'n_tokens_mistral': 2065, 'n_tokens_neox': 2039, 'n_words': 499}