@Override
 public TableCellEditor getCellEditor(int row, int column) {
   TableColumn tableColumn = getColumnModel().getColumn(column);
   TableCellEditor editor = tableColumn.getCellEditor();
   if (editor == null) {
     Class c = getColumnClass(column);
     if (c.equals(Object.class)) {
       Object o = getValueAt(row, column);
       if (o != null) c = getValueAt(row, column).getClass();
     }
     editor = getDefaultEditor(c);
   }
   return editor;
 }
Exemple #2
0
 private void initTableCellComponents() {
   for (int k = 0; k < getModel().getColumnCount(); k++) {
     OrderTableColumn column = OrderTableColumn.valuerOf(k);
     TableColumn tableColumn = getColumnModel().getColumn(k);
     ComplexCell cellComp;
     switch (column) {
       case boardDef:
         tableColumn.setCellEditor(new BoardDefCellEditor(this));
         tableColumn.setCellRenderer(new EntityTableRenderer<BoardDef>());
         break;
       case texture:
         tableColumn.setCellEditor(new TextureCellEditor(this));
         tableColumn.setCellRenderer(new EntityTableRenderer<TextureEntity>());
         break;
       case manufacturer:
         TableEditorsRenders.ItemsComboBox<Manufacturer> cb =
             new TableEditorsRenders.ItemsComboBox<Manufacturer>();
         cb.getItems().addAll(FacadeContext.getManufacturerFacade().loadAllSortedBy("name"));
         tableColumn.setCellEditor(new DefaultCellEditor(cb));
         tableColumn.setCellRenderer(new EntityTableRenderer<Manufacturer>());
         break;
       case length:
       case width:
       case count:
         final JTextField tf = new JTextField();
         tf.setDocument(new NumericDocument());
         tableColumn.setCellEditor(new DefaultCellEditor(tf));
         break;
       case glueing:
         cellComp = new ComplexCell();
         tableColumn.setCellEditor(cellComp);
         tableColumn.setCellRenderer(new ButtonCellRenderer(true));
         break;
       case milling:
         millingCellEditor = new MillingCellEditor();
         tableColumn.setCellEditor(millingCellEditor);
         tableColumn.setCellRenderer(new DefaultTableRenderer(new MillingCheckBoxProvider()));
         break;
       case drilling:
         DrillingCellEditor editor = new DrillingCellEditor();
         editor.setContext(context);
         tableColumn.setCellEditor(editor);
         tableColumn.setCellRenderer(new ButtonCellRenderer(false));
         break;
       case groove:
         cellComp = new CommonCellEditor();
         tableColumn.setCellEditor(cellComp);
         tableColumn.setCellRenderer(new ButtonCellRenderer(true));
         break;
       case a45:
         cellComp = new TextSideCellEditor();
         tableColumn.setCellEditor(cellComp);
         tableColumn.setCellRenderer(new ButtonCellRenderer(true));
         break;
       case cutoff:
         tableColumn.setCellEditor(new PopupEditor(new CutoffComponentProvider()));
         tableColumn.setCellRenderer(new DefaultTableRenderer(new CutoffCheckBoxProvider()));
         break;
     }
     if (tableColumn.getCellEditor() instanceof DefaultCellEditor) {
       ((DefaultCellEditor) tableColumn.getCellEditor()).setClickCountToStart(1);
     }
   }
 }