Search in sources :

Example 1 with CellSpanModel

use of spantable.CellSpanModel in project android by JetBrains.

the class ThemeEditorTable method updateRowHeights.

public void updateRowHeights() {
    TableModel rawModel = getModel();
    if (!(rawModel instanceof CellSpanModel)) {
        return;
    }
    CellSpanModel myModel = (CellSpanModel) rawModel;
    int defaultRowHeight = myClassHeights.get(Object.class);
    setRowHeight(defaultRowHeight);
    for (int row = 0; row < myModel.getRowCount(); row++) {
        // Find the maximum row height
        int maxRowHeight = -1;
        for (int col = 0; col < myModel.getColumnCount(); col += myModel.getColumnSpan(row, col)) {
            Class<?> cellClass = myModel.getCellClass(row, col);
            Integer rowHeight = myClassHeights.get(cellClass);
            if (rowHeight != null) {
                maxRowHeight = Math.max(maxRowHeight, rowHeight);
            }
        }
        if (maxRowHeight == -1) {
            // Leave the default size
            continue;
        }
        int viewRow = convertRowIndexToView(row);
        if (viewRow != -1) {
            setRowHeight(viewRow, maxRowHeight);
        }
    }
}
Also used : CellSpanModel(spantable.CellSpanModel) TableModel(javax.swing.table.TableModel) AttributesTableModel(com.android.tools.idea.editors.theme.attributes.AttributesTableModel)

Example 2 with CellSpanModel

use of spantable.CellSpanModel in project android by JetBrains.

the class DelegatingCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
    final Object stringValue;
    final CellSpanModel model = (CellSpanModel) table.getModel();
    boolean boldFont = false;
    if (value instanceof EditedStyleItem) {
        final EditedStyleItem item = (EditedStyleItem) value;
        stringValue = ThemeEditorUtils.extractRealValue(item, model.getCellClass(row, column));
        ConfiguredThemeEditorStyle selectedStyle = ((AttributesTableModel) table.getModel()).getSelectedStyle();
        // Displays in bold attributes that are overriding their inherited value
        boldFont = selectedStyle.hasItem(item);
    } else {
        // Not an EditedStyleItem for theme name and theme parent.
        stringValue = value;
    }
    final Component returnedComponent = myDelegate.getTableCellEditorComponent(table, myConvertValueToString ? stringValue : value, isSelected, row, column);
    returnedComponent.setFont(boldFont ? returnedComponent.getFont().deriveFont(Font.BOLD) : returnedComponent.getFont().deriveFont(Font.PLAIN));
    return returnedComponent;
}
Also used : AttributesTableModel(com.android.tools.idea.editors.theme.attributes.AttributesTableModel) CellSpanModel(spantable.CellSpanModel) EventObject(java.util.EventObject) EditedStyleItem(com.android.tools.idea.editors.theme.datamodels.EditedStyleItem) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)

Aggregations

AttributesTableModel (com.android.tools.idea.editors.theme.attributes.AttributesTableModel)2 CellSpanModel (spantable.CellSpanModel)2 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)1 EditedStyleItem (com.android.tools.idea.editors.theme.datamodels.EditedStyleItem)1 EventObject (java.util.EventObject)1 TableModel (javax.swing.table.TableModel)1