/** * {@inheritDoc} */ @Override public List<TableColumn> getColumns(boolean includeHidden) { if (includeHidden) { return new ArrayList<TableColumn>(initialColumns); } return Collections.list(getColumns()); }
/** * * {@inheritDoc} * <p> * * Overridden to return a <code>DefaultTableColumnModelExt</code>. * * @see org.jdesktop.swingx.table.DefaultTableColumnModelExt */ @Override protected TableColumnModel createDefaultColumnModel() { return new DefaultTableColumnModelExt(); }
/** * {@inheritDoc} */ @Override public TableColumnExt getColumnExt(int columnIndex) { TableColumn column = getColumn(columnIndex); if (column instanceof TableColumnExt) { return (TableColumnExt) column; } return null; }
public void propertyChange(PropertyChangeEvent evt) { if ("visible".equals(evt.getPropertyName())) { TableColumnExt columnExt = (TableColumnExt)evt.getSource(); if (columnExt.isVisible()) { moveToVisible(columnExt); fireColumnPropertyChange(evt); } else { moveToInvisible(columnExt); } } else if (!((TableColumnExt) evt.getSource()).isVisible()) { fireColumnPropertyChange(evt); } } }
/** * Check if the add/remove event is triggered by a move to/from the * invisible columns. * * PRE: the event must be received in columnAdded/Removed. * * @param e the received event * @param added if true the event is assumed to be received via * columnAdded, otherwise via columnRemoved. * @return boolean indicating whether the removed/added is a side-effect * of hiding/showing the column. */ private boolean isVisibilityChange(TableColumnModelEvent e, boolean added) { // can't tell if (!(e.getSource() instanceof DefaultTableColumnModelExt)) return false; DefaultTableColumnModelExt model = (DefaultTableColumnModelExt) e .getSource(); if (added) { return model.isAddedFromInvisibleEvent(e.getToIndex()); } else { return model.isRemovedToInvisibleEvent(e.getFromIndex()); } }
/** * Update internal state after the visibility of the column * was changed to visible. The given column is assumed to * be contained in this model. * * @param col the column which was made visible. */ protected void moveToVisible(TableColumnExt col) { isVisibilityChange = true; // two step process: first add at end of columns // then move to "best" position relative to where it // was before hiding. super.addColumn(col); // this is analogous to the proposed fix in #253-swingx // but uses the currentColumns as reference. Integer addIndex = currentColumns.indexOf(col); for (int i = 0; i < (getColumnCount() - 1); i++) { TableColumn tableCol = getColumn(i); int actualPosition = currentColumns.indexOf(tableCol); if (actualPosition > addIndex) { super.moveColumn(getColumnCount() - 1, i); break; } } isVisibilityChange = false; }
@Override public void actionPerformed(ActionEvent e) { DefaultTableColumnModelExt columnModel = (DefaultTableColumnModelExt) table.getColumnModel(); TableColumn tableColumn = Collections.list(columnModel.getColumns()) .stream() .filter(f -> f.getHeaderValue().equals(category)) .findFirst() .orElseThrow(); columnModel.removeColumn(tableColumn); categoryService.removeCategory(category); LOG.debug("// WORKAROUND 28.12.2018/tornaia: resetting column model with a new but empty one. It is required to set the columnModel later otherwise tree will remain empty"); table.setColumnModel(new DefaultTableColumnModel()); dashboardEventPublisher.updateDashboard(); } }
/** * {@inheritDoc} */ @Override public int getColumnCount(boolean includeHidden) { if (includeHidden) { return initialColumns.size(); } return getColumnCount(); }
/** * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); fireColumnPropertyChange(evt); }
/** * {@inheritDoc} <p> * * Overridden to update internals related to column visibility. */ @Override public void moveColumn(int columnIndex, int newIndex) { if (columnIndex != newIndex) { updateCurrentColumns(columnIndex, newIndex); } super.moveColumn(columnIndex, newIndex); }
@Override public void propertyChange(PropertyChangeEvent evt) { if ("visible".equals(evt.getPropertyName())) { TableColumnExt columnExt = (TableColumnExt)evt.getSource(); if (columnExt.isVisible()) { moveToVisible(columnExt); fireColumnPropertyChange(evt); } else { moveToInvisible(columnExt); } } else if (!((TableColumnExt) evt.getSource()).isVisible()) { fireColumnPropertyChange(evt); } } }
/** * Check if the add/remove event is triggered by a move to/from the * invisible columns. * * PRE: the event must be received in columnAdded/Removed. * * @param e the received event * @param added if true the event is assumed to be received via * columnAdded, otherwise via columnRemoved. * @return boolean indicating whether the removed/added is a side-effect * of hiding/showing the column. */ private boolean isVisibilityChange(TableColumnModelEvent e, boolean added) { // can't tell if (!(e.getSource() instanceof DefaultTableColumnModelExt)) return false; DefaultTableColumnModelExt model = (DefaultTableColumnModelExt) e .getSource(); if (added) { return model.isAddedFromInvisibleEvent(e.getToIndex()); } else { return model.isRemovedToInvisibleEvent(e.getFromIndex()); } }
/** * Update internal state after the visibility of the column * was changed to visible. The given column is assumed to * be contained in this model. * * @param col the column which was made visible. */ protected void moveToVisible(TableColumnExt col) { isVisibilityChange = true; // two step process: first add at end of columns // then move to "best" position relative to where it // was before hiding. super.addColumn(col); // this is analogous to the proposed fix in #253-swingx // but uses the currentColumns as reference. Integer addIndex = currentColumns.indexOf(col); for (int i = 0; i < (getColumnCount() - 1); i++) { TableColumn tableCol = getColumn(i); int actualPosition = currentColumns.indexOf(tableCol); if (actualPosition > addIndex) { super.moveColumn(getColumnCount() - 1, i); break; } } isVisibilityChange = false; }
/** * {@inheritDoc} */ @Override public int getColumnCount(boolean includeHidden) { if (includeHidden) { return initialColumns.size(); } return getColumnCount(); }
/** * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); fireColumnPropertyChange(evt); }
/** * {@inheritDoc} <p> * * Overridden to update internals related to column visibility. */ @Override public void moveColumn(int columnIndex, int newIndex) { if (columnIndex != newIndex) { updateCurrentColumns(columnIndex, newIndex); } super.moveColumn(columnIndex, newIndex); }
@Override public void propertyChange(PropertyChangeEvent evt) { if ("visible".equals(evt.getPropertyName())) { TableColumnExt columnExt = (TableColumnExt)evt.getSource(); if (columnExt.isVisible()) { moveToVisible(columnExt); fireColumnPropertyChange(evt); } else { moveToInvisible(columnExt); } } else if (!((TableColumnExt) evt.getSource()).isVisible()) { fireColumnPropertyChange(evt); } } }
/** * {@inheritDoc} */ @Override public List<TableColumn> getColumns(boolean includeHidden) { if (includeHidden) { return new ArrayList<TableColumn>(initialColumns); } return Collections.list(getColumns()); }
/** * Check if the add/remove event is triggered by a move to/from the * invisible columns. * * PRE: the event must be received in columnAdded/Removed. * * @param e the received event * @param added if true the event is assumed to be received via * columnAdded, otherwise via columnRemoved. * @return boolean indicating whether the removed/added is a side-effect * of hiding/showing the column. */ private boolean isVisibilityChange(TableColumnModelEvent e, boolean added) { // can't tell if (!(e.getSource() instanceof DefaultTableColumnModelExt)) return false; DefaultTableColumnModelExt model = (DefaultTableColumnModelExt) e .getSource(); if (added) { return model.isAddedFromInvisibleEvent(e.getToIndex()); } else { return model.isRemovedToInvisibleEvent(e.getFromIndex()); } }
/** * Update internal state after the visibility of the column * was changed to visible. The given column is assumed to * be contained in this model. * * @param col the column which was made visible. */ protected void moveToVisible(TableColumnExt col) { isVisibilityChange = true; // two step process: first add at end of columns // then move to "best" position relative to where it // was before hiding. super.addColumn(col); // this is analogous to the proposed fix in #253-swingx // but uses the currentColumns as reference. Integer addIndex = currentColumns.indexOf(col); for (int i = 0; i < (getColumnCount() - 1); i++) { TableColumn tableCol = getColumn(i); int actualPosition = currentColumns.indexOf(tableCol); if (actualPosition > addIndex) { super.moveColumn(getColumnCount() - 1, i); break; } } isVisibilityChange = false; }