List of usage examples for javax.swing.table TableColumn getCellEditor
public TableCellEditor getCellEditor()
TableCellEditor
used by the JTable
to edit values for this column. From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java
private void configVDTagsComboBox(JTable table, int columnIndex) { TableColumnModel columnModel = table.getColumnModel(); TableColumn comboColumn = columnModel.getColumn(columnIndex); JComboBox<String> comboBox = new JComboBox<>(); EnumSet<VideoDataTags> allVDTags = EnumSet.allOf(VideoDataTags.class); for (VideoDataTags videoDataTag : allVDTags) { comboBox.addItem(videoDataTag.toString()); }// w ww . j a va2 s. c o m comboColumn.setCellEditor(new DefaultCellEditor(comboBox)); /* * allows clearing a problem when cell editor is interrupted, very deep problem. * Only shows if: (A) combobox selection is interupted, (B) dialog is * closed , and (C) Wizard is entered from the menu in this exact order */ cellEditor = comboColumn.getCellEditor(); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText(ResourceBundleHelper.getMessageString("videoTab.tooltip")); comboColumn.setCellRenderer(renderer); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected void onDataChange() { for (TableColumn tableColumn : getAllColumns()) { TableCellEditor cellEditor = tableColumn.getCellEditor(); if (cellEditor instanceof DesktopTableCellEditor) { ((DesktopTableCellEditor) cellEditor).clearCache(); }/*from w w w . j a v a2s . co m*/ } repaintImplIfNeeded(); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Override public void removeGeneratedColumn(String columnId) { checkArgument(columnId != null, "columnId is null"); Column col = getColumn(columnId);//from w ww .j av a2 s .com 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); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Nullable @Override/* w w w. ja v a2 s . c om*/ 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; } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected Column addRuntimeGeneratedColumn(String columnId) { // store old cell editors / renderers TableCellEditor[] cellEditors = new TableCellEditor[tableModel.getColumnCount() + 1]; TableCellRenderer[] cellRenderers = new TableCellRenderer[tableModel.getColumnCount() + 1]; for (int i = 0; i < tableModel.getColumnCount(); i++) { Column tableModelColumn = tableModel.getColumn(i); if (tableModel.isGeneratedColumn(tableModelColumn)) { TableColumn tableColumn = getColumn(tableModelColumn); cellEditors[i] = tableColumn.getCellEditor(); cellRenderers[i] = tableColumn.getCellRenderer(); }/* w w w . ja v a 2 s . co m*/ } // if column with columnId does not exists then add new to model Column col = new Column(columnId, columnId); col.setEditable(false); columns.put(col.getId(), col); // do not touch columnsOrder, it will be synced from table model if (tableModel != null) { tableModel.addColumn(col); } // reassign column identifiers setColumnIdentifiers(); // reattach old generated columns for (int i = 0; i < tableModel.getColumnCount(); i++) { Column tableModelColumn = tableModel.getColumn(i); if (tableModel.isGeneratedColumn(tableModelColumn)) { TableColumn tableColumn = getColumn(tableModelColumn); if (cellEditors[i] != null) { tableColumn.setCellEditor(cellEditors[i]); } if (cellRenderers[i] != null) { tableColumn.setCellRenderer(cellRenderers[i]); } } } return col; }
From source file:com.haulmont.cuba.desktop.gui.components.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(); }/* w w w. ja v a 2 s . c o m*/ } } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected boolean allColumnsAreInline() { if (generatedColumnsCount <= 0) { return true; }/* ww w.j av a 2 s. c o m*/ 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; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Override public void removeColumn(Column column) { if (column == null) { return;//from www. j a v a2s . com } String name; if (column.getId() instanceof MetaPropertyPath) { MetaPropertyPath metaPropertyPath = (MetaPropertyPath) column.getId(); name = metaPropertyPath.getMetaProperty().getName(); editableColumns.remove(metaPropertyPath); } else { name = column.getId().toString(); } TableColumn tableColumn = null; Iterator<TableColumn> columnIterator = getAllColumns().iterator(); while (columnIterator.hasNext() && (tableColumn == null)) { TableColumn xColumn = columnIterator.next(); Object identifier = xColumn.getIdentifier(); if (identifier instanceof String && identifier.equals(name)) { tableColumn = xColumn; } else if (column.equals(identifier)) { tableColumn = xColumn; } } if (tableColumn != null) { // store old cell editors / renderers Map<Object, TableCellEditor> cellEditors = new HashMap<>(); Map<Object, TableCellRenderer> cellRenderers = new HashMap<>(); for (int i = 0; i < tableModel.getColumnCount(); i++) { Column tableModelColumn = tableModel.getColumn(i); if (tableModel.isGeneratedColumn(tableModelColumn)) { TableColumn oldColumn = getColumn(tableModelColumn); cellEditors.put(tableModelColumn.getId(), oldColumn.getCellEditor()); cellRenderers.put(tableModelColumn.getId(), oldColumn.getCellRenderer()); } } impl.getColumnModel().removeColumn(tableColumn); impl.removeColumn(tableColumn); columns.remove(column.getId()); columnsOrder.remove(column); if (tableModel != null) { tableModel.removeColumn(column); } // reassign column identifiers setColumnIdentifiers(); // reattach old generated columns for (int i = 0; i < tableModel.getColumnCount(); i++) { Column tableModelColumn = tableModel.getColumn(i); if (tableModel.isGeneratedColumn(tableModelColumn)) { TableColumn oldColumn = getColumn(tableModelColumn); if (cellEditors.containsKey(tableModelColumn.getId())) { oldColumn.setCellEditor(cellEditors.get(tableModelColumn.getId())); } if (cellRenderers.containsKey(tableModelColumn.getId())) { oldColumn.setCellRenderer(cellRenderers.get(tableModelColumn.getId())); } } } packRows(); repaintImplIfNeeded(); } column.setOwner(null); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
/** * {@inheritDoc}//from ww w . j a v a 2 s . c o m */ @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(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
@Override public void shutdown() { //Check to see if background tasks accessing the Workbench are active. if (shutdownLock.get() > 0) { return;//from ww w . j a va 2 s . c om } if (spreadSheet == null) { return; } //-------------------------------------------------------------------------------- // I really don't know how much of all this is necessary // but using the JProfiler it seems things got better when I did certain things. //-------------------------------------------------------------------------------- UIRegistry.getLaunchFindReplaceAction().setSearchReplacePanel(null); UIRegistry.enableFind(null, false); JFrame topFrame = (JFrame) UIRegistry.getTopWindow(); if (minMaxWindowListener != null) { topFrame.removeWindowListener(minMaxWindowListener); minMaxWindowListener = null; } shutdownValidators(); removeAll(); if (mainPanel != null) { mainPanel.removeAll(); } if (controllerPane != null) { controllerPane.removeAll(); } if (spreadSheet != null) { spreadSheet.setVisible(false); spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener); spreadSheet.cleanUp(); workbenchRowChangeListener = null; for (int i = 0; i < spreadSheet.getColumnCount(); i++) { TableColumn column = spreadSheet.getColumnModel().getColumn(i); TableCellEditor editor = column.getCellEditor(); if (editor instanceof GridCellEditor) { ((GridCellEditor) editor).cleanUp(); } } TableCellEditor editor = spreadSheet.getCellEditor(); if (editor instanceof GridCellEditor) { ((GridCellEditor) editor).cleanUp(); } } if (imageFrame != null) { imageFrame.cleanUp(); imageFrame.dispose(); } if (mapFrame != null) { mapFrame.dispose(); } if (model != null) { model.cleanUp(); } if (headers != null) { headers.clear(); } if (resultsetController != null) { resultsetController.removeListener(formPane); resultsetController = null; } if (formPane != null) { formPane.cleanup(); } formPane = null; findPanel = null; spreadSheet = null; workbench = null; model = null; imageColExt = null; columns = null; imageFrame = null; headers = null; recordSet = null; mainPanel = null; controllerPane = null; currentPanelType = null; cardLayout = null; cpCardLayout = null; uploadToolPanel = null; workBenchPlugins = null; super.shutdown(); }