⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decoratedtablemodel.java

📁 ULCeclipse的插件集成的swing的框架
💻 JAVA
字号:
package com.canoo.ulc.onlineshop.model;

import com.ulcjava.base.application.event.ITableModelListener;
import com.ulcjava.base.application.table.AbstractTableModel;
import com.ulcjava.base.application.table.ITableModel;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * This class serves as a decorator for a table model. Subclasses may implement a sorted table model, or a filtered
 * table model, etc.
 *
 * @author Etienne.Studer@canoo.com
 */
abstract public class DecoratedTableModel extends AbstractTableModel implements ITableModelListener {
    private ITableModel fModel;
    private List fIndices;


    public DecoratedTableModel(ITableModel sourceModel) {
        fModel = sourceModel;
        fModel.addTableModelListener(this);
        fIndices = new ArrayList();
    }


    public ITableModel getModel() {
        return fModel;
    }


    public int getRowCount() {
        return getIndices().size();
    }


    public Object getValueAt(int rowIndex, int columnIndex) {
        return getModel().getValueAt(getRealRow(rowIndex), columnIndex);
    }


    public void setValueAt(Object value, int rowIndex, int columnIndex) {
        getModel().setValueAt(value, getRealRow(rowIndex), columnIndex);
    }


    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return getModel().isCellEditable(getRealRow(rowIndex), columnIndex);
    }


    public int getRealRow(int mappedRow) {
        return ((Integer)getIndices().get(mappedRow)).intValue();
    }


    public int getMappedRow(int realRow) {
        return getIndices().indexOf(new Integer(realRow));
    }


    protected List getIndices() {
        return fIndices;
    }


    protected void moveIndices(int fromRow, int offset) {
        for (ListIterator iterator = getIndices().listIterator(); iterator.hasNext();) {
            int realRow = ((Integer)iterator.next()).intValue();
            if (realRow >= fromRow) {
                iterator.set(new Integer(realRow + offset));
            }
        }
    }


    public int getColumnCount() {
        return fModel.getColumnCount();
    }


    public String getColumnName(int columnIndex) {
        return fModel.getColumnName(columnIndex);
    }


    public Class getColumnClass(int columnIndex) {
        return fModel.getColumnClass(columnIndex);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -