@Override public void columnAdded(TableColumnModelEvent e) { LinesTableColumn type = getColumnType(e.getToIndex()); TableColumn column = getColumnModel().getColumn(e.getToIndex()); switch (type) { case COLOR: column.setMaxWidth(25); break; case CLASS: column.setPreferredWidth(90); break; case STATION: column.setPreferredWidth(90); break; case ALGORITHM: column.setPreferredWidth(100); break; } super.columnAdded(e); }
public void columnMoved(TableColumnModelEvent event) { if(isEmpty() || getEventSource() != null) { return; } setEventSource(event.getSource()); int columnIndex = event.getFromIndex(); int newIndex = event.getToIndex(); Collection<TableColumnModel> models = values(); for (TableColumnModel model : models) { if(model == getEventSource()) continue; model.moveColumn(columnIndex, newIndex); } if(columnIndex != newIndex) { TableColumnSynchronizer column = columns.get(columnIndex); columns.remove(columnIndex); columns.add(newIndex, column); } setEventSource(null); }
public void columnAdded(TableColumnModelEvent event) { super.columnAdded(event); TableColumn column = getColumnModel().getColumn(event.getToIndex()); column.setCellRenderer(cellRenderer); AlignerTree aligner = getAlignerTree(); if(synchronizer != null && aligner != null) { synchronizer.add(aligner); synchronizer = null; } TableCellRenderer r = column.getHeaderRenderer(); if(r instanceof TreeHeaderRenderer) { JTree tree = ((TreeHeaderRenderer)r).getTree(); if(!(tree instanceof AlignerTree) && aligner != null) aligner.addTree((NameTree)tree); resizeAndRepaint(); } }
public void columnRemoved(TableColumnModelEvent event) { AlignerTree atree = getAlignerTree(); if(atree != null) { List<JTree> renderers = atree.getTrees(); Enumeration<TableColumn> e = getColumnModel().getColumns(); while(e.hasMoreElements()) { TableCellRenderer r = e.nextElement().getHeaderRenderer(); if(renderers.contains(r)) renderers.remove(r); } for(JTree tree: renderers) { atree.removeTree((NameTree)tree); } renderers.clear(); } super.columnRemoved(event); }
public void moveColumn(final int columnIndex, final int newIndex) { if (columnIndex < 0 || columnIndex >= getColumnCount() || newIndex < 0 || newIndex > getColumnCount()) { throw new IllegalArgumentException(Messages.getString("swing.79")); //$NON-NLS-1$ } if (columnIndex != newIndex) { TableColumn firstColumn = getColumn(columnIndex); tableColumns.remove(columnIndex); tableColumns.add(newIndex, firstColumn); boolean oldIsSelected = selectionModel.isSelectedIndex(columnIndex); selectionModel.removeIndexInterval(columnIndex, columnIndex); selectionModel.insertIndexInterval(newIndex, 1, true); if (oldIsSelected) { selectionModel.addSelectionInterval(newIndex, newIndex); } else { selectionModel.removeSelectionInterval(newIndex, newIndex); } } fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex)); }
@Override public void moveColumn(int viewFrom, int viewTo) { // viewToModelMap columnMap.get(viewToModelMap.get(viewFrom)).setOrder(viewTo); if(viewFrom < viewTo) { for (int i = viewFrom + 1; i <= viewTo; i++) { columnMap.get(viewToModelMap.get(i)).setOrder(i-1); } reorderViewColumns(true); }else if(viewFrom > viewTo){ for (int i = viewFrom-1; i >= viewTo; i--) { columnMap.get(viewToModelMap.get(i)).setOrder(i+1); } reorderViewColumns(true); }else{ //no change } this.fireColumnMoved(new TableColumnModelEvent(this, viewFrom, viewTo)); }
public void moveColumn(int fromIndex, int toIndex) { if (!MainFrame.getInstance().canNavigateAway()) return; MainFrame.getInstance().updateDesignationDisplay(); TableColumn from = columnList.get(fromIndex); TableColumn to = columnList.get(toIndex); columnList.set(fromIndex, to); to.setModelIndex(fromIndex); columnList.set(toIndex, from); from.setModelIndex(toIndex); orderUpdate(); for (TableColumnModelListener w : new ArrayList<TableColumnModelListener>(watchers)) { w.columnMoved(new TableColumnModelEvent(this, fromIndex, toIndex)); } }
@Override public void columnAdded(TableColumnModelEvent e) { int minWidth; final int index = e.getToIndex(); switch (index) { case 0: case 1: minWidth = 60; break; default: minWidth = 80; } TableColumnModel columnModel = (TableColumnModel) e.getSource(); columnModel.getColumn(index).setPreferredWidth(minWidth); columnModel.getColumn(index).setCellRenderer(new RightAlignmentTableCellRenderer()); }
/** Copy of addColumn(TableColumn) with an index specifying where to add the new column */ private void addColumn(TableColumn aColumn, int index) { if (aColumn == null) { throw new IllegalArgumentException("Object is null"); } tableColumns.insertElementAt(aColumn, index); aColumn.addPropertyChangeListener(this); //invalidateWidthCache(); totalColumnWidth = -1; // Post columnAdded event notification fireColumnAdded(new TableColumnModelEvent(this, 0, index)); }
@Override public void columnMoved(TableColumnModelEvent e) { int from = e.getFromIndex(); int to = e.getToIndex(); if(from == to) { return; } table.getTableHeader().getColumnModel().getColumn(from).setModelIndex(from); table.getTableHeader().getColumnModel().getColumn(to).setModelIndex(to); tableModel.moveColumn(from, to); }
@Override public void columnAdded(TableColumnModelEvent e) { super.columnAdded(e); // bigger default size TableColumn column = getColumnModel().getColumn(getColumnModel().getColumnCount() - 1); column.setPreferredWidth(COLUMN_WIDTH); }
/** Necessary to properly stopping the editing when a column is moved (dragged). */ @Override public void columnMoved(final TableColumnModelEvent e) { if (isEditing()) { cellEditor.stopCellEditing(); } super.columnMoved(e); }
/** * Overridden to fix * //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4330950: */ @Override public void columnMoved(TableColumnModelEvent e) { if (isEditing()) { cellEditor.stopCellEditing(); } super.columnMoved(e); }
/** * Maps {@code JTable.columnAdded(TableColumnModelEvent)} through queue */ public void columnAdded(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnAdded") { @Override public void map() { ((JTable) getSource()).columnAdded(tableColumnModelEvent); } }); }
/** * Maps {@code JTable.columnMoved(TableColumnModelEvent)} through queue */ public void columnMoved(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnMoved") { @Override public void map() { ((JTable) getSource()).columnMoved(tableColumnModelEvent); } }); }
/** * Maps {@code JTable.columnRemoved(TableColumnModelEvent)} through queue */ public void columnRemoved(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnRemoved") { @Override public void map() { ((JTable) getSource()).columnRemoved(tableColumnModelEvent); } }); }
/** * Maps {@code JTableHeader.columnAdded(TableColumnModelEvent)} through queue */ public void columnAdded(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnAdded") { @Override public void map() { ((JTableHeader) getSource()).columnAdded(tableColumnModelEvent); } }); }
/** * Maps {@code JTableHeader.columnRemoved(TableColumnModelEvent)} * through queue */ public void columnRemoved(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnRemoved") { @Override public void map() { ((JTableHeader) getSource()).columnRemoved(tableColumnModelEvent); } }); }
/** * Maps {@code JTableHeader.columnMoved(TableColumnModelEvent)} through queue */ public void columnMoved(final TableColumnModelEvent tableColumnModelEvent) { runMapping(new MapVoidAction("columnMoved") { @Override public void map() { ((JTableHeader) getSource()).columnMoved(tableColumnModelEvent); } }); }
@Override public void setColumnSizes(TableColumnModelEvent e) { TableColumnModel tcm = (TableColumnModel)e.getSource(); int cc = tcm.getColumnCount(); if (cc <= 1) return; setColumnWidths(tcm.getColumn(0), 40, 60, 75); setColumnWidths(tcm.getColumn(1), 80, 250, 400); doLayout(); }
public void setColumnSizes(TableColumnModelEvent e) { TableColumnModel tcm = (TableColumnModel)e.getSource(); for (int ii = 0; ii < tcm.getColumnCount(); ii++) { setColumnWidths(tcm.getColumn(ii), 70, 95, 200); } doLayout(); }
public void columnMoved(TableColumnModelEvent e) { if (isEditing() && !getCellEditor().stopCellEditing()) { getCellEditor().cancelCellEditing(); } isForceRefreshTable = true; repaint(); }
public void addColumn(TableColumn aColumn) { if (aColumn == null) { throw new IllegalArgumentException("Object is null"); } tableColumns.addElement(aColumn); invalidateWidthCache(); fireColumnAdded(new TableColumnModelEvent(this, 0, getColumnCount() - 1)); }
public void removeColumn(TableColumn column) { int columnIndex = tableColumns.indexOf(column); if (columnIndex != -1) { if (selectionModel != null) { selectionModel.removeIndexInterval(columnIndex, columnIndex); } column.removePropertyChangeListener(this); tableColumns.removeElementAt(columnIndex); invalidateWidthCache(); fireColumnRemoved(new TableColumnModelEvent(this, columnIndex, 0)); } }
public void moveColumn(int columnIndex, int newIndex) { if ((columnIndex < 0) || (columnIndex >= getColumnCount()) || (newIndex < 0) || (newIndex >= getColumnCount())) throw new IllegalArgumentException( "moveColumn() - Index out of range"); TableColumn aColumn; if (columnIndex == newIndex) { fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex)); return; } aColumn = tableColumns.elementAt(columnIndex); tableColumns.removeElementAt(columnIndex); boolean selected = selectionModel.isSelectedIndex(columnIndex); selectionModel.removeIndexInterval(columnIndex, columnIndex); tableColumns.insertElementAt(aColumn, newIndex); selectionModel.insertIndexInterval(newIndex, 1, true); if (selected) { selectionModel.addSelectionInterval(newIndex, newIndex); } else { selectionModel.removeSelectionInterval(newIndex, newIndex); } fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex)); }
protected void fireColumnAdded(TableColumnModelEvent e) { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TableColumnModelListener.class) { ((TableColumnModelListener) listeners[i + 1]).columnAdded(e); } } }
protected void fireColumnRemoved(TableColumnModelEvent e) { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TableColumnModelListener.class) { ((TableColumnModelListener) listeners[i + 1]).columnRemoved(e); } } }
protected void fireColumnMoved(TableColumnModelEvent e) { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TableColumnModelListener.class) { ((TableColumnModelListener) listeners[i + 1]).columnMoved(e); } } }
public void columnAdded(TableColumnModelEvent event) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); handleColumnChange(AccessibleTableModelChange.INSERT, event.getFromIndex(), event.getToIndex()); }
public void columnRemoved(TableColumnModelEvent event) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); handleColumnChange(AccessibleTableModelChange.DELETE, event.getFromIndex(), event.getToIndex()); }
public void columnMoved(TableColumnModelEvent event) { firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); handleColumnChange(AccessibleTableModelChange.DELETE, event.getFromIndex(), event.getFromIndex()); handleColumnChange(AccessibleTableModelChange.INSERT, event.getFromIndex(), event.getToIndex()); }
/** * Invoked when the column is moved. Revalidates and repains the table. */ public void columnMoved (TableColumnModelEvent event) { if (isEditing()) editingCanceled(null); revalidate(); repaint(); }