<commit_before>package de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.channels;

import org.eclipse.jface.viewers.ColumnLabelProvider;

import de.ptb.epics.eve.data.ComparisonTypes;
import de.ptb.epics.eve.data.measuringstation.event.MonitorEvent;
import de.ptb.epics.eve.data.scandescription.Channel;
import de.ptb.epics.eve.data.scandescription.ControlEvent;

/**
 * @author <NAME>
 * @since 1.34
 */
public class ParametersColumnLabelProvider extends ColumnLabelProvider {
	private static final String DASH = Character.toString('\u2014');
	private static final String STOPPED_BY = Character.toString('\u21E5');
	private static final String REDO = Character.toString('\u27F2');
	private static final String SIGMA = Character.toString('\u03C3');
	private static final String LESS_OR_EQUAL = Character.toString('\u2264');
	private static final String GREATER_OR_EQUAL = Character.toString('\u2267');
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getText(Object element) {
		Channel channel = (Channel)element;
		
		if (channel.getScanModule().isUsedAsNormalizeChannel(channel)) {
			return DASH;
		}
		
		switch (channel.getChannelMode()) {
		case INTERVAL:
			StringBuilder sbInterval = new StringBuilder();
			sbInterval.append(channel.getTriggerInterval() + "s");
			if (channel.getStoppedBy() != null) {
				sbInterval.append(" " + STOPPED_BY + " " + 
						channel.getStoppedBy().getName());
			}
			return sbInterval.toString();
		case STANDARD:
			StringBuilder sbStandard = new StringBuilder();
			sbStandard.append("n = " + channel.getAverageCount());
			if (channel.getMaxDeviation() != null) {
				sbStandard.append(", " + SIGMA + " " + LESS_OR_EQUAL + " " + 
						channel.getMaxDeviation() + " %");
			}
			if (channel.getMinimum() != null) {
				sbStandard.append(", x " + GREATER_OR_EQUAL + " " + 
						channel.getMinimum());
			}
			if (channel.getMaxAttempts() != null) {
				sbStandard.append(", a " + LESS_OR_EQUAL + " " + 
						channel.getMaxAttempts());
			}
			if (!channel.getRedoEvents().isEmpty()) {
				sbStandard.append(", " + REDO);
			}
			return sbStandard.toString();
		default:
			return DASH;
		}
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getToolTipText(Object element) {
		Channel channel = (Channel)element;
		
		StringBuilder sb = new StringBuilder();
		
		for (ControlEvent controlEvent : channel.getRedoEvents()) {<commit_msg>#4917: fixed a bug where a NullPointer occurred for an interval tooltip<commit_after>package de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.channels;

import org.eclipse.jface.viewers.ColumnLabelProvider;

import de.ptb.epics.eve.data.ComparisonTypes;
import de.ptb.epics.eve.data.measuringstation.event.MonitorEvent;
import de.ptb.epics.eve.data.scandescription.Channel;
import de.ptb.epics.eve.data.scandescription.ControlEvent;
import de.ptb.epics.eve.data.scandescription.channelmode.ChannelModes;

/**
 * @author <NAME>
 * @since 1.34
 */
public class ParametersColumnLabelProvider extends ColumnLabelProvider {
	private static final String DASH = Character.toString('\u2014');
	private static final String STOPPED_BY = Character.toString('\u21E5');
	private static final String REDO = Character.toString('\u27F2');
	private static final String SIGMA = Character.toString('\u03C3');
	private static final String LESS_OR_EQUAL = Character.toString('\u2264');
	private static final String GREATER_OR_EQUAL = Character.toString('\u2267');
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getText(Object element) {
		Channel channel = (Channel)element;
		
		if (channel.getScanModule().isUsedAsNormalizeChannel(channel)) {
			return DASH;
		}
		
		switch (channel.getChannelMode()) {
		case INTERVAL:
			StringBuilder sbInterval = new StringBuilder();
			sbInterval.append(channel.getTriggerInterval() + "s");
			if (channel.getStoppedBy() != null) {
				sbInterval.append(" " + STOPPED_BY + " " + 
						channel.getStoppedBy().getName());
			}
			return sbInterval.toString();
		case STANDARD:
			StringBuilder sbStandard = new StringBuilder();
			sbStandard.append("n = " + channel.getAverageCount());
			if (channel.getMaxDeviation() != null) {
				sbStandard.append(", " + SIGMA + " " + LESS_OR_EQUAL + " " + 
						channel.getMaxDeviation() + " %");
			}
			if (channel.getMinimum() != null) {
				sbStandard.append(", x " + GREATER_OR_EQUAL + " " + 
						channel.getMinimum());
			}
			if (channel.getMaxAttempts() != null) {
				sbStandard.append(", a " + LESS_OR_EQUAL + " " + 
						channel.getMaxAttempts());
			}
			if (!channel.getRedoEvents().isEmpty()) {
				sbStandard.append(", " + REDO);
			}
			return sbStandard.toString();
		default:
			return DASH;
		}
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getToolTipText(Object element) {
		Channel channel = (Channel)element;
		if (channel.getChannelMode().equals(ChannelModes.INTERVAL)) {
			return null;
		}
		
		StringBuilder sb = new StringBuilder();
		
		for (ControlEvent controlEvent : channel.getRedoEvents()) {
{'fraction_non_alphanumeric': 0.13788992648519768, 'fraction_numerical': 0.010331810053645937, 'mean_word_length': 4.131498470948012, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3409745', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1584, 'n_words': 303}