<commit_before>package org.csstudio.channel.widgets;

import gov.bnl.channelfinder.api.Channel;
import gov.bnl.channelfinder.api.ChannelQuery;

import java.util.Collection;
import java.util.Collections;

import org.csstudio.csdata.ProcessVariable;
import org.csstudio.utility.pvmanager.widgets.VTableDisplayCell;

public class PVTableByPropertyCell implements ChannelQueryAdaptable {
	
	private String query;
	private Collection<Channel> channels;
	private boolean column;
	private boolean row;
	private boolean cell;
	
	PVTableByPropertyCell(VTableDisplayCell cell, PVTableByPropertyWidget table) {
		// Set data for cell
		if (cell.getColumn() >= 1 && cell.getRow() >= 0) {
			channels = table.getChannelsAt(cell.getRow(), cell.getColumn() - 1);
			this.cell = true;
		}
		
		// Set data for column
		if (cell.getColumn() >= 1 && cell.getRow() == -1) {
			channels = table.getChannelsInColumn(cell.getColumn() - 1);
			String propertyName = table.getColumnProperty();
			String propertyValue = null;
			if (table.getColumnPropertyValues() != null) {
				propertyValue = table.getColumnPropertyValues().get(cell.getColumn() - 1);
			}
			if (propertyName != null && propertyValue != null) {
				query = table.getChannelQuery().getQuery() + " " + propertyName
						+ "=" + propertyValue;
			}
			column = true;
		}
		
		// Set data for row
		if (cell.getColumn() == 0 && cell.getRow() >= 0) {
			channels = table.getChannelsInRow(cell.getRow());
			String propertyName = table.getRowProperty();
			String propertyValue = null;
			if (table.getRowPropertyValues() != null) {
				propertyValue = table.getRowPropertyValues().get(cell.getRow());
			}
			if (propertyName != null && propertyValue != null) {
				query = table.getChannelQuery().getQuery() + " " + propertyName
						+ "=" + propertyValue;
			}
			row = true;
		}
	}
	
	public Collection<Channel> getChannels() {
		return channels;
	}
	
	public String getQuery() {
		return query;
	}
	
	public boolean isColumn() {
		return column;
	}
	
	public boolean isRow() {
		return row;
	}
	
	public boolean isCell() {
		return cell;
	}

	@Override
	public Collection<Channel> toChannels() {
		return AdaptableUtilities.toChannels(toChannelQueries());
	}

	@Override
	public Collection<ProcessVariable> toProcesVariables() {
		return AdaptableUtilities.toProcessVariables(toChannels());
	}

	@Override
	public Collection<ChannelQuery> toChannelQueries() {
		return Collections.singletonList(ChannelQuery.query(getQuery()).result(getChannels(), null).build());
	}
}<commit_msg>..channel.widgets: pvtable selection could have no query but still have channels.<commit_after>package org.csstudio.channel.widgets;

import gov.bnl.channelfinder.api.Channel;
import gov.bnl.channelfinder.api.ChannelQuery;

import java.util.Collection;
import java.util.Collections;

import org.csstudio.csdata.ProcessVariable;
import org.csstudio.utility.pvmanager.widgets.VTableDisplayCell;

public class PVTableByPropertyCell implements ChannelQueryAdaptable {
	
	private String query;
	private Collection<Channel> channels;
	private boolean column;
	private boolean row;
	private boolean cell;
	
	PVTableByPropertyCell(VTableDisplayCell cell, PVTableByPropertyWidget table) {
		// Set data for cell
		if (cell.getColumn() >= 1 && cell.getRow() >= 0) {
			channels = table.getChannelsAt(cell.getRow(), cell.getColumn() - 1);
			this.cell = true;
		}
		
		// Set data for column
		if (cell.getColumn() >= 1 && cell.getRow() == -1) {
			channels = table.getChannelsInColumn(cell.getColumn() - 1);
			String propertyName = table.getColumnProperty();
			String propertyValue = null;
			if (table.getColumnPropertyValues() != null) {
				propertyValue = table.getColumnPropertyValues().get(cell.getColumn() - 1);
			}
			if (propertyName != null && propertyValue != null) {
				query = table.getChannelQuery().getQuery() + " " + propertyName
						+ "=" + propertyValue;
			}
			column = true;
		}
		
		// Set data for row
		if (cell.getColumn() == 0 && cell.getRow() >= 0) {
			channels = table.getChannelsInRow(cell.getRow());
			String propertyName = table.getRowProperty();
			String propertyValue = null;
			if (table.getRowPropertyValues() != null) {
				propertyValue = table.getRowPropertyValues().get(cell.getRow());
			}
			if (propertyName != null && propertyValue != null) {
				query = table.getChannelQuery().getQuery() + " " + propertyName
						+ "=" + propertyValue;
			}
			row = true;
		}
	}
	
	public Collection<Channel> getChannels() {
		return channels;
	}
	
	public String getQuery() {
		return query;
	}
	
	public boolean isColumn() {
		return column;
	}
	
	public boolean isRow() {
		return row;
	}
	
	public boolean isCell() {
		return cell;
	}

	@Override
	public Collection<Channel> toChannels() {
		return getChannels();
	}

	@Override
	public Collection<ProcessVariable> toProcesVariables() {
		return AdaptableUtilities.toProcessVariables(toChannels());
	}

	@Override
	public Collection<ChannelQuery> toChannelQueries() {
		if (query == null)
			return null;
		return Collections.singletonList(ChannelQuery.query(getQuery()).result(getChannels(), null).build());
	}
}
{'fraction_non_alphanumeric': 0.12858536585365854, 'fraction_numerical': 0.0035121951219512196, 'mean_word_length': 4.151758793969849, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6653492', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1564, 'n_words': 345}