Package org.swingml.model

Examples of org.swingml.model.TableColumnModel


*/
public class TableHeaderCellRenderer extends DefaultTableCellRenderer {

    public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JTableModel model = (JTableModel) table.getModel();
        TableColumnModel columnModel = (TableColumnModel) model.getColumns().get(column);
        LabelDecorator.decorateLabel(this, columnModel, table.getFont());

        setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

        // Set alignment
        int alignment = JLabel.LEFT;
        if (columnModel.getAlignment().equalsIgnoreCase(Constants.RIGHT)) {
            alignment = JLabel.RIGHT;
        } else if (columnModel.getAlignment().equalsIgnoreCase(Constants.CENTER)) {
            alignment = JLabel.CENTER;
        }
        setHorizontalAlignment(alignment);

        setValue(value);
View Full Code Here


    public TableCellLabelDecorator (JTableComponent aTable) {
        super();
        JTableModel theTableModel = (JTableModel) aTable.getModel();
        Iterator theColumns = theTableModel.getColumns().iterator();
        TableColumnModel theColumn = null;
        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            TableCellRenderer originalRenderer = aTable.getDefaultRenderer(theColumn.getType().getClass());
            if (originalRenderer instanceof JLabel) {
                aTable.setDefaultRenderer(theColumn.getType().getClass(), new TableCellLabelRenderer(originalRenderer));
            }
        }
    }
View Full Code Here

    private String xmlColumnState () {
        StringBuffer result = new StringBuffer();
        JTableModel theModel = (JTableModel) super.getModel();
        List cols = theModel.getColumns();
        for (int columnIndex = 0; columnIndex < cols.size(); columnIndex++) {
            TableColumnModel colModel = (TableColumnModel) cols.get(columnIndex);
            result.append("<COLUMN ");
            result.append(Constants.TEXT);
            result.append("=\"");
            result.append(colModel.getText());
            result.append("\" ");
            result.append(Constants.COLUMN_ORDER);
            result.append("=\"");
            result.append(convertColumnIndexToView(columnIndex));
            result.append("\" ");
            result.append(Constants.WIDTH);
            result.append("=\"");
            result.append(getColumn(colModel.getText()).getWidth());
            result.append("\" ");
            result.append(Constants.SORT);
            result.append("=\"");
            result.append("ASC");
            result.append("\" ");
            result.append(Constants.SORTABLE);
            result.append("=\"");
            result.append(colModel.isSortable()?Constants.TRUE:Constants.FALSE);
            result.append("\" ");
            result.append(Constants.SORTORDER);
            result.append("=\"");
            result.append(-1);
            result.append("\" />");
View Full Code Here

    }

    public void applyColumnEditors () {
        JTableModel aModel = (JTableModel) getModel();
        for (int i = 0; i < aModel.getColumnCount(); i++) {
            TableColumnModel m = (TableColumnModel) aModel.getColumns().get(i);
            if (m.getCustomEditor() != null) {
                getColumnModel().getColumn(i).setCellEditor(m.getCustomEditor());
            }

        }
    }
View Full Code Here

    public TableBrowserCellIconDecorator (TableBrowserComponent aTable) {
        super();
        TableBrowserModel theTableModel = (TableBrowserModel) aTable.getModel();
        Iterator theColumns = theTableModel.getColumns().iterator();
        TableColumnModel theColumn = null;
        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            TableCellRenderer originalRenderer = aTable.getDefaultRenderer(theColumn.getType().getClass());
            if (!(originalRenderer instanceof TableBrowserCellIconRenderer)) {
                Class clazz = theColumn.getType().getClass();
                if (clazz == JButton.class) {
                    aTable.setDefaultRenderer(theColumn.getType().getClass(), new IconComponentCellEditor());
                } else {
                    aTable.setDefaultRenderer(theColumn.getType().getClass(), new TableBrowserCellIconRenderer(originalRenderer));                   
                }
            }
        }
    }
View Full Code Here

    public TableBrowserCellLabelDecorator (TableBrowserComponent aTable) {
        super();
        TableBrowserModel theTableModel = (TableBrowserModel) aTable.getModel();
        Iterator theColumns = theTableModel.getColumns().iterator();
        TableColumnModel theColumn = null;
        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            TableCellRenderer originalRenderer = aTable.getDefaultRenderer(theColumn.getType().getClass());
            TableCellEditor originalEditor = aTable.getDefaultEditor(theColumn.getType().getClass());
            if (originalRenderer instanceof JLabel) {
                Class clazz = theColumn.getType().getClass();
                if (clazz == JButton.class) {
                    aTable.setDefaultRenderer(theColumn.getType().getClass(), new IconComponentCellEditor());
                } else {
                    aTable.setDefaultRenderer(theColumn.getType().getClass(), new TableBrowserCellLabelRenderer(originalRenderer));
                    aTable.setDefaultEditor(theColumn.getType().getClass(), new TableBrowserCellLabelEditor(originalEditor));
                }
            }
        }
    }
View Full Code Here

    public TableCellIconDecorator (JTableComponent aTable) {
        super();
        JTableModel theTableModel = (JTableModel) aTable.getModel();
        Iterator theColumns = theTableModel.getColumns().iterator();
        TableColumnModel theColumn = null;
        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            TableCellRenderer originalRenderer = aTable.getDefaultRenderer(theColumn.getType().getClass());
            if (!(originalRenderer instanceof TableCellIconRenderer)) {
                aTable.setDefaultRenderer(theColumn.getType().getClass(), new TableCellIconRenderer(originalRenderer));
            }
        }
    }
View Full Code Here

        Iterator theColumns = theModel.getColumns().iterator();

        /*Sets the cell renderer for columns of type ColorComponent*/
        aTable.setDefaultRenderer(ColorComponent.class, new TableCellColorRenderer());

        TableColumnModel theColumn = null;
        List theColumnItems = null;
        ColorComponent[] theColors = null;
        String theColorName = null;
        ColorComponent theColor = null;
        JComboBox theCombo = null;

        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            if (theColumn.getType() instanceof ColorComponent) {

                /*Sets the cell editor for columns of type ColorComponent*/
                theColumnItems = theColumn.getItems();
                if (theColumnItems != null) {
                    theColors = new ColorComponent[theColumnItems.size()];
                    for (int i = 0; i < theColumnItems.size(); i++) {
                        theColorName = (String) theColumnItems.get(i);
                        theColor = ColorComponent.getColorByName(theColorName);
View Full Code Here

public class TableCellComboDecorator {
   
    public TableCellComboDecorator(JTableComponent aTable) {
        JTableModel theTableModel = (JTableModel) aTable.getModel();
        Iterator theColumns = theTableModel.getColumns().iterator();
        TableColumnModel theColumn = null;
        JComboBox theCombo = null;
        while (theColumns.hasNext()) {
            theColumn = (TableColumnModel) theColumns.next();
            if (theColumn.getType() instanceof JComboBox) {
                /*
                 Sets the cell editor to show up as a JComboBox for columns of type JComboBox.
                 It is not necesary to set a different cell renderer than the default for this case
                 */
                if (theColumn.getItems() != null) {
                    theCombo = new JComboBox(theColumn.getItems());
                    aTable.setDefaultEditor(JComboBox.class, new DefaultCellEditor(theCombo));
                }
            }
        }
    }
View Full Code Here

            }
        }

        // Look at column model and default this to the column model's ALIGN attribute instead of hard coding it.
        int columnInModel = table.convertColumnIndexToModel(column);
        TableColumnModel columnModel = (TableColumnModel) model.getColumns().get(columnInModel);
        String columnAlignment = columnModel.getAlignment();
        layout.setAlignment(FlowLayout.LEFT);
        if (columnAlignment != null) {
            if (columnAlignment.equals(Constants.CENTER)) {
                layout.setAlignment(FlowLayout.CENTER);
            } else if (columnAlignment.equals(Constants.RIGHT)) {
View Full Code Here

TOP

Related Classes of org.swingml.model.TableColumnModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.