javax.swing.table.TableColumn#getCellEditor ( )源码实例Demo

下面列出了javax.swing.table.TableColumn#getCellEditor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cuba   文件: DesktopAbstractTable.java
@Override
public void removeGeneratedColumn(String columnId) {
    checkArgument(columnId != null, "columnId is null");
    Column col = getColumn(columnId);
    if (col != null) {
        boolean oldContentRepaintEnabled = isContentRepaintEnabled();
        setContentRepaintEnabled(false);

        TableColumn targetTableColumn = getColumn(col);
        TableCellEditor cellEditor = targetTableColumn.getCellEditor();
        if (cellEditor instanceof DesktopTableCellEditor) {
            Column associatedRuntimeColumn = ((DesktopTableCellEditor) cellEditor).getAssociatedRuntimeColumn();

            removeColumn(associatedRuntimeColumn);
        }

        tableModel.removeGeneratedColumn(col);
        generatedColumnsCount--;

        packRows();
        repaintImplIfNeeded();
        setContentRepaintEnabled(oldContentRepaintEnabled);
    }
}
 
源代码2 项目: cuba   文件: DesktopAbstractTable.java
@Nullable
@Override
public Printable getPrintable(String columnId) {
    checkArgument(columnId != null, "columnId is null");

    Printable printable = printables.get(columnId);
    if (printable != null) {
        return printable;
    } else {
        Column column = getColumn(columnId);
        if (column != null) {
            TableColumn tableColumn = getColumn(column);
            TableCellEditor cellEditor = tableColumn.getCellEditor();
            if (cellEditor instanceof DesktopTableCellEditor) {
                ColumnGenerator columnGenerator = ((DesktopTableCellEditor) cellEditor).getColumnGenerator();
                if (columnGenerator instanceof Printable) {
                    return (Printable) columnGenerator;
                }
            }
        }
        return null;
    }
}
 
源代码3 项目: cuba   文件: DesktopAbstractTable.java
protected boolean allColumnsAreInline() {
    if (generatedColumnsCount <= 0) {
        return true;
    }

    for (Column column : columnsOrder) {
        if (!tableModel.isGeneratedColumn(column)) {
            continue;
        }

        TableColumn tableColumn = getColumn(column);
        if (tableColumn != null) {
            DesktopTableCellEditor cellEditor = (DesktopTableCellEditor) tableColumn.getCellEditor();
            if (cellEditor != null) {
                boolean inline = cellEditor.isInline();
                if (!inline) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
源代码4 项目: cuba   文件: DesktopAbstractTable.java
protected void onDataChange() {
    for (TableColumn tableColumn : getAllColumns()) {
        TableCellEditor cellEditor = tableColumn.getCellEditor();
        if (cellEditor instanceof DesktopTableCellEditor) {
            ((DesktopTableCellEditor) cellEditor).clearCache();
        }
    }
    repaintImplIfNeeded();
}
 
源代码5 项目: cuba   文件: DesktopAbstractTable.java
protected void clearGeneratedColumnsCache() {
    for (Column column : columnsOrder) {
        if (tableModel.isGeneratedColumn(column)) {
            TableColumn tableColumn = getColumn(column);
            if (tableColumn != null) {
                TableCellEditor tableCellEditor = tableColumn.getCellEditor();
                if (tableCellEditor instanceof DesktopTableCellEditor) {
                    ((DesktopTableCellEditor) tableCellEditor).clearCache();
                }
            }
        }
    }
}
 
源代码6 项目: cuba   文件: DesktopAbstractTable.java
/**
 * {@inheritDoc}
 */
@Override
public void repaint() {
    TableCellEditor cellEditor = impl.getCellEditor();
    if (cellEditor instanceof DesktopTableCellEditor) {
        ((DesktopTableCellEditor) cellEditor).clearCache();
    }

    List<TableColumn> implColumns = impl.getColumns();
    for (Column column : getColumns()) {
        TableColumn tableColumn = null;
        for (TableColumn implColumn : implColumns) {
            if (column.equals((implColumn.getIdentifier()))) {
                tableColumn = implColumn;
                break;
            }
        }
        // column may be hidden
        if (tableColumn != null) {
            TableCellEditor columnCellEditor = tableColumn.getCellEditor();
            if (columnCellEditor instanceof DesktopTableCellEditor) {
                ((DesktopTableCellEditor) columnCellEditor).clearCache();
            }
        }
    }
    packRows();
    repaintImplIfNeeded();
}
 
public void copyValues(TableColumn base) {
	modelIndex = base.getModelIndex();
	identifier = base.getIdentifier();
	width = base.getWidth();
	minWidth = base.getMinWidth();
	setPreferredWidth(base.getPreferredWidth());
	maxWidth = base.getMaxWidth();
	headerRenderer = base.getHeaderRenderer();
	headerValue = base.getHeaderValue();
	cellRenderer = base.getCellRenderer();
	cellEditor = base.getCellEditor();
	isResizable = base.getResizable();
}
 
源代码8 项目: gameserver   文件: MyTreeTable.java
@Override
public TableCellEditor getCellEditor(int row, int column) {
   TableColumn tableColumn = getColumnModel().getColumn(column);
   TableCellEditor editor = tableColumn.getCellEditor();
   if (editor == null) {
   	Object value = this.getValueAt(row, column);
   	if ( value != null ) {
   		editor = getDefaultEditor(value.getClass());
   	} else {
   		editor = getDefaultEditor(getColumnClass(column));
   	}
   }
   return editor;
}
 
源代码9 项目: snap-desktop   文件: ProductEntryTableModel.java
@Override
public boolean isCellEditable(final int rowIndex, final int columnIndex) {
    if (columnIndex >= columnList.size()) {
        return false;
    }
    final TableColumn column = columnList.get(columnIndex);
    return column.getCellEditor() != null;
}
 
源代码10 项目: snap-desktop   文件: AOITableModel.java
@Override
public boolean isCellEditable(final int rowIndex, final int columnIndex) {
    if (columnIndex >= columnList.size()) {
        return false;
    }
    final TableColumn column = columnList.get(columnIndex);
    return column.getCellEditor() != null;
}
 
源代码11 项目: pentaho-reporting   文件: ElementMetaDataTable.java
public TableCellEditor getCellEditor( final int row, final int viewColumn ) {
  final int column = convertColumnIndexToModel( viewColumn );
  final Object value = getModel().getValueAt( row, column );
  if ( value instanceof GroupingHeader ) {
    return getDefaultEditor( GroupingHeader.class );
  }

  final ElementMetaDataTableModel model = (ElementMetaDataTableModel) getModel();
  final PropertyEditor propertyEditor = model.getEditorForCell( row, column );
  final Class columnClass = model.getClassForCell( row, column );

  if ( propertyEditor != null ) {
    final String[] tags = propertyEditor.getTags();
    if ( columnClass.isArray() ) {
      arrayCellEditor.setPropertyEditorType( propertyEditor.getClass() );
    } else if ( tags == null || tags.length == 0 ) {
      propertyEditorCellEditor.setPropertyEditor( propertyEditor );
      return propertyEditorCellEditor;
    } else {
      taggedPropertyEditorCellEditor.setPropertyEditor( propertyEditor );
      return taggedPropertyEditorCellEditor;
    }
  }

  final TableColumn tableColumn = getColumnModel().getColumn( column );
  final TableCellEditor renderer = tableColumn.getCellEditor();
  if ( renderer != null ) {
    return renderer;
  }

  if ( columnClass.isArray() ) {
    return arrayCellEditor;
  }

  final TableCellEditor editor = getDefaultEditor( columnClass );
  if ( editor != null && logger.isTraceEnabled() ) {
    logger.trace( "Using preconfigured default editor for column class " + columnClass + ": " + editor ); // NON-NLS
  }
  return editor;
}
 
源代码12 项目: chipster   文件: EditableHeaderTableColumn.java
public void copyValues(TableColumn base) {    
	modelIndex     = base.getModelIndex();
	identifier     = base.getIdentifier();
	width          = base.getWidth();
	minWidth       = base.getMinWidth();
	setPreferredWidth(base.getPreferredWidth());
	maxWidth       = base.getMaxWidth();
	headerRenderer = base.getHeaderRenderer();
	headerValue    = base.getHeaderValue();
	cellRenderer   = base.getCellRenderer();
	cellEditor     = base.getCellEditor();
	isResizable    = base.getResizable();
}
 
源代码13 项目: netbeans   文件: Outline.java
@Override
public boolean editCellAt (int row, int column, EventObject e) {
    //If it was on column 0, it may be a request to expand a tree
    //node - check for that first.
    boolean isTreeColumn = isTreeColumnIndex(column);
    if (isTreeColumn && e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row));
        if (path != null && !getOutlineModel().isLeaf(path.getLastPathComponent())) {
            int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth();
            Insets ins = getInsets();
            int nd = path.getPathCount() - (isRootVisible() ? 1 : 2);
            if (nd < 0) {
                nd = 0;
            }
            int handleStart = ins.left + (nd * DefaultOutlineCellRenderer.getNestingWidth());
            int handleEnd = ins.left + handleStart + handleWidth;
            // Translate 'x' to position of column if non-0:
            int columnStart = getCellRect(row, column, false).x;
            handleStart += columnStart;
            handleEnd += columnStart;

            TableColumn tableColumn = getColumnModel().getColumn(column);
            TableCellEditor columnCellEditor = tableColumn.getCellEditor();
            if ((me.getX() > ins.left && me.getX() >= handleStart && me.getX() <= handleEnd) ||
                (me.getClickCount() > 1 && columnCellEditor == null)) {

                boolean expanded = getLayoutCache().isExpanded(path);
                //me.consume();  - has no effect!
                //System.err.println("  event consumed.");
                if (!expanded) {
                    getTreePathSupport().expandPath(path);
                    
                    Object ourObject = path.getLastPathComponent();
                    int cCount = getOutlineModel().getChildCount(ourObject);
                    if (cCount > 0) {
                        int lastRow = row;
                        for (int i = 0; i < cCount; i++) {
                            Object child = getOutlineModel().getChild(ourObject, i);
                            TreePath childPath = path.pathByAddingChild(child);
                            int childRow = getLayoutCache().getRowForPath(childPath);
                            childRow = convertRowIndexToView(childRow);
                            if (childRow > lastRow) {
                                lastRow = childRow;
                            }
                        }
                        int firstRow = row;
                        Rectangle rectLast = getCellRect(lastRow, 0, true);
                        Rectangle rectFirst = getCellRect(firstRow, 0, true);
                        Rectangle rectFull = new Rectangle(
                                rectFirst.x,
                                rectFirst.y,
                                rectLast.x + rectLast.width - rectFirst.x,
                                rectLast.y + rectLast.height - rectFirst.y);
                        scrollRectToVisible(rectFull);
                    }
                    
                } else {
                    getTreePathSupport().collapsePath(path);
                }
                selectionDisabled = true;
                return false;
            }
        }
        // It may be a request to check/uncheck a check-box
        if (checkAt(row, column, me)) {
            return false;
        }
    } else if (isTreeColumn && e instanceof ActionEvent) {
        if (((ActionEvent) e).getModifiers() == 0 &&
            lastProcessedKeyStroke != null) {
            
            if (lastProcessedKeyStroke.getKeyCode() == KeyEvent.VK_SPACE) {
                if (checkAt(row, column, null)) {
                    return false;
                }
            }
        }
    }
        
    boolean res = false;
    if (!isTreeColumn || e instanceof MouseEvent && row >= 0 && isEditEvent(row, column, (MouseEvent) e)) {
        res = super.editCellAt(row, column, e);
    }
    if( res && isTreeColumn && row >= 0 && null != getEditorComponent() ) {
        configureTreeCellEditor(getEditorComponent(), row, column);
    }
    if (e == null && !res && isTreeColumn) {
        // Handle SPACE
        checkAt(row, column, null);
    }
    return res;
}
 
源代码14 项目: opensim-gui   文件: ObjectPropertyViewerPanel.java
public TableCellEditor getCellEditor(int row, int column) {
   TableColumn tableColumn = getColumnModel().getColumn(column);
   TableCellEditor editor = tableColumn.getCellEditor();
   if (editor == null) editor = getDefaultEditor(model.getCellClass(adapter.nodeForRow(row), convertColumnIndexToModel(column)));
   return editor;
}
 
源代码15 项目: pentaho-reporting   文件: PropertyTable.java
public TableCellEditor getCellEditor( final int row, final int viewColumn ) {
  final TableModel tableModel = getModel();
  if ( tableModel instanceof PropertyTableModel ) {
    final PropertyTableModel model = (PropertyTableModel) getModel();
    final int column = convertColumnIndexToModel( viewColumn );

    final PropertyEditor propertyEditor = model.getEditorForCell( row, column );
    final Class columnClass = model.getClassForCell( row, column );

    if ( propertyEditor != null ) {
      final String[] tags = propertyEditor.getTags();

      if ( columnClass.isArray() ) {
        arrayCellEditor.setPropertyEditorType( propertyEditor.getClass() );
      } else if ( tags == null || tags.length == 0 ) {
        propertyEditorCellEditor.setPropertyEditor( propertyEditor );
        return propertyEditorCellEditor;
      } else {
        taggedPropertyEditorCellEditor.setPropertyEditor( propertyEditor );
        return taggedPropertyEditorCellEditor;
      }
    }

    final TableColumn tableColumn = getColumnModel().getColumn( column );
    final TableCellEditor renderer = tableColumn.getCellEditor();
    if ( renderer != null ) {
      return renderer;
    }

    if ( columnClass.isArray() ) {
      return arrayCellEditor;
    }

    final TableCellEditor editor = getDefaultEditor( columnClass );
    if ( editor != null && logger.isTraceEnabled() ) {
      logger.trace( "Using preconfigured default editor for column class " + columnClass + ": " + editor ); // NON-NLS
    }
    return editor;
  }
  return super.getCellEditor( row, viewColumn );
}