public Object getSourceData(short columnId, Object record) { if (log.isTraceEnabled()) log.trace("getColumnData(): columnId=" + columnId + ", record=" + record); LabelRecord labelRecord = (LabelRecord) record; // can insert model specific columns here if (columnId == COLUMN_DEGREE.getColumnId()) { return new Percentage(labelRecord.getActualTagDegree(relativeTag.getUniqueId())); } return super.getSourceData(columnId, record); }
public class TagLabelModelManager extends LabelModelManager { private static Logger log = Logger.getLogger(TagLabelModelManager.class); private static final long serialVersionUID = 0L; public static StaticTypeColumn[] ALL_COLUMNS = { COLUMN_LABEL_NAME.getInstance(true), COLUMN_THUMBNAIL_IMAGE.getInstance(true), COLUMN_DEGREE.getInstance(true), COLUMN_RATING_STARS.getInstance(true), COLUMN_RATING_VALUE.getInstance(false), COLUMN_NUM_SONGS.getInstance(true), COLUMN_COMMENTS.getInstance(true), COLUMN_STYLES.getInstance(false), COLUMN_TAGS.getInstance(false), COLUMN_LAST_MODIFIED.getInstance(false) }; //////////// // FIELDS // //////////// private transient FilterProfileLabelsModel profileLabelsModel; private transient TagProfile relativeTag; static { try { // in order for the XMLEncoder to skip transient variables, this is needed BeanInfo info = Introspector.getBeanInfo(TagLabelModelManager.class); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; ++i) { PropertyDescriptor pd = propertyDescriptors[i]; if (pd.getName().equals("profileLabelsModel") || pd.getName().equals("relativeTag")) { pd.setValue("transient", Boolean.TRUE); } } } catch (IntrospectionException e) { log.error("static(): error", e); } } ///////////////// // CONSTRUCTOR // ///////////////// public TagLabelModelManager() {} public TagLabelModelManager(LineReader lineReader) { super(lineReader); int version = Integer.parseInt(lineReader.getNextLine()); } public void initColumns() { sourceColumns.clear(); for (Column column : ALL_COLUMNS) sourceColumns.add(column); } protected void createSourceModel(QObject parent) { model = new FilterTabTableItemModel(getModelPopulator().getSize(), getNumColumns(), parent, this); loadTable(); } ///////////// // GETTERS // ///////////// public StaticTypeColumn[] getAllStaticColumns() { return ALL_COLUMNS; } public String getTypeDescription() { return "Tag Label"; } public Object getSourceData(short columnId, Object record) { if (log.isTraceEnabled()) log.trace("getColumnData(): columnId=" + columnId + ", record=" + record); LabelRecord labelRecord = (LabelRecord) record; // can insert model specific columns here if (columnId == COLUMN_DEGREE.getColumnId()) { return new Percentage(labelRecord.getActualTagDegree(relativeTag.getUniqueId())); } return super.getSourceData(columnId, record); } public ModelPopulatorInterface getModelPopulator() { return profileLabelsModel; } public boolean excludeExternalItems() { return false; } public boolean isLazySearchSupported() { return true; } ///////////// // SETTERS // ///////////// public void setRelativeTag(TagProfile relativeTag) { profileLabelsModel = new FilterProfileLabelsModel(relativeTag, this); this.relativeTag = relativeTag; } public void reset() { profileLabelsModel.update(); super.reset(); } public void refresh() { if (log.isDebugEnabled()) log.debug("refresh(): called"); try { loadData(profileLabelsModel.getResults(), getSearchProxyModel().getSearchParameters()); } catch (Exception e) { log.error("refresh(): error", e); } } ///////////// // METHODS // ///////////// public void write(LineWriter writer) { super.write(writer); writer.writeLine(1); // version } }
public static boolean isEditableFilterTabColumn(Column column) { if ((column.getColumnId() == COLUMN_DEGREE.getColumnId())) return true; return false; }