private boolean areAllVisible() { boolean retVal = true; final SessionEditor editor = getEditor(); final Session session = editor.getSession(); final List<TierViewItem> view = session.getTierView(); for (TierViewItem tvi : view) { retVal &= tvi.isVisible(); } return retVal; }
@Override public int getColumnCount() { int retVal = 0; final Session session = getSession(); if (session != null) { retVal = Columns.values().length - 1; retVal += session.getUserTierCount(); } return retVal; }
@Override public String getColumnName(int column) { String retVal = super.getColumnName(column); if (column < Columns.OTHER.ordinal()) { retVal = Columns.values()[column].getName(); } else { final Session session = getSession(); int tierIdx = column - Columns.OTHER.ordinal(); if (tierIdx < session.getUserTierCount()) { retVal = session.getUserTier(tierIdx).getName(); } } return retVal; }
@Override public Object getValueAt(int rowIndex, int columnIndex) { Object retVal = null; final Session session = getSession(); if (session != null && rowIndex < session.getRecordCount()) { final Record record = session.getRecord(rowIndex); if (columnIndex == Columns.RECORD_INDEX.ordinal()) { retVal = rowIndex + 1; } else if (columnIndex == Columns.SPEAKER.ordinal()) { retVal = record.getSpeaker(); } else { final String tierName = getColumnName(columnIndex); retVal = record.getTier(tierName); } } return retVal; }
@Override public void hookableActionPerformed(ActionEvent e) { final SessionEditor editor = getEditor(); final Session session = editor.getSession(); final List<TierViewItem> view = session.getTierView(); final List<TierViewItem> newView = new ArrayList<TierViewItem>(); final SessionFactory factory = SessionFactory.newFactory(); final boolean allVisible = areAllVisible(); for (TierViewItem oldItem : view) { final TierViewItem newItem = factory.createTierViewItem( oldItem.getTierName(), !allVisible, oldItem.getTierFont(), oldItem.isTierLocked()); newView.add(newItem); } final TierViewEdit edit = new TierViewEdit(getEditor(), view, newView); editor.getUndoSupport().postEdit(edit); putValue(NAME, (!allVisible ? "Hide " : "Show ") + "all tiers"); }
@Override public int getRowCount() { final Session session = getSession(); return (session != null ? session.getRecordCount() : 0); }