<commit_before>package cerberus.view.gui.swt.slider;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import cerberus.data.collection.ISelection;
import cerberus.manager.IGeneralManager;
import cerberus.manager.ILoggerManager.LoggerType;

public class SelectionSliderViewRep 
extends ASliderViewRep {

	protected int iSelectionId;
	
	protected String sSelectionFieldName;
	
	public SelectionSliderViewRep(IGeneralManager refGeneralManager, 
			int iViewId, 
			int iParentContainerId, 
			String sLabel) {
		
		super(refGeneralManager, iViewId, iParentContainerId, sLabel);
	}
	
	public void initView() {
		
		super.initView();
		
		ISelection tmpSelection =
			refGeneralManager.getSingelton().getSelectionManager()
				.getItemSelection(iSelectionId);
		
		if (sSelectionFieldName.equals("length"))
		{
			iCurrentSliderValue = tmpSelection.length();
		}
		else if (sSelectionFieldName.equals("offset"))
		{
			iCurrentSliderValue = tmpSelection.getOffset();
		}
		else if (sSelectionFieldName.equals("multioffset"))
		{
			iCurrentSliderValue = tmpSelection.getMultiOffset();
		}
		else if (sSelectionFieldName.equals("multirepeat"))
		{
			iCurrentSliderValue = tmpSelection.getMultiRepeat();
		}
		
	    refSlider.addListener (SWT.Selection, new Listener () {
			public void handleEvent (Event event) {
				ISelection tmpSelection =
					refGeneralManager.getSingelton().getSelectionManager()
						.getItemSelection(iSelectionId);
				
				if (sSelectionFieldName.equals("length"))
				{
					tmpSelection.setLength(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("offset"))
				{
					tmpSelection.setOffset(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("multioffset"))
				{
					tmpSelection.setMultiOffset(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("multirepeat"))
				{
					tmpSelection.setMultiRepeat(refSlider.getSelection());
				}	
			}
		});
	}
	
	/**
	 * Retrieves the slider selection ID 
	 * from the parameter handler
	 * and sets the local variable.
	 */
	public void extractAttributes() {
		
		//TODO: optimize this workflow!
		
		iSelectionId = refParameterHandler.getValueInt( "iSelectionId" );
		
		sSelectionFieldName = refParameterHandler.getValueString( "sSelectionFieldName" );
	}
	
	// TODO: retrieve locking token!
	public void update(Object eventTrigger) {
		
		int triggerId = ((ISelection)eventTrigger).getId();	
		refGeneralManager.getSingelton().getLoggerManager().logMsg( 
				"Slider update called by " +triggerId,
				LoggerType.VERBOSE );
		
		if (eventTrigger instanceof ISelection)
		{
			if (sSelectionFieldName.equals("length"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).length();
			}
			else if (sSelectionFieldName.equals("offset"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getOffset();
			}
			else if (sSelectionFieldName.equals("multioffset"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getMultiOffset();
			}
			else if (sSelectionFieldName.equals("multirepeat"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getMultiRepeat();
			}
			
			drawView();
		}
	}
}
<commit_msg>Selection slider uses the writeToken.<commit_after>package cerberus.view.gui.swt.slider;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import cerberus.data.collection.ISelection;
import cerberus.manager.IGeneralManager;
import cerberus.manager.ILoggerManager.LoggerType;

public class SelectionSliderViewRep 
extends ASliderViewRep {

	protected int iSelectionId;
	
	protected String sSelectionFieldName;
	
	public SelectionSliderViewRep(IGeneralManager refGeneralManager, 
			int iViewId, 
			int iParentContainerId, 
			String sLabel) {
		
		super(refGeneralManager, iViewId, iParentContainerId, sLabel);
	}
	
	public void initView() {
		
		super.initView();
		
		ISelection tmpSelection =
			refGeneralManager.getSingelton().getSelectionManager()
				.getItemSelection(iSelectionId);
		
		if (sSelectionFieldName.equals("length"))
		{
			iCurrentSliderValue = tmpSelection.length();
		}
		else if (sSelectionFieldName.equals("offset"))
		{
			iCurrentSliderValue = tmpSelection.getOffset();
		}
		else if (sSelectionFieldName.equals("multioffset"))
		{
			iCurrentSliderValue = tmpSelection.getMultiOffset();
		}
		else if (sSelectionFieldName.equals("multirepeat"))
		{
			iCurrentSliderValue = tmpSelection.getMultiRepeat();
		}
		
	    refSlider.addListener (SWT.Selection, new Listener () {
			public void handleEvent (Event event) {
				ISelection tmpSelection =
					refGeneralManager.getSingelton().getSelectionManager()
						.getItemSelection(iSelectionId);
				
				tmpSelection.getWriteToken();
				
				if (sSelectionFieldName.equals("length"))
				{
					tmpSelection.setLength(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("offset"))
				{
					tmpSelection.setOffset(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("multioffset"))
				{
					tmpSelection.setMultiOffset(refSlider.getSelection());
				}
				else if (sSelectionFieldName.equals("multirepeat"))
				{
					tmpSelection.setMultiRepeat(refSlider.getSelection());
				}	
				
				tmpSelection.returnWriteToken();
			}
		});
	}
	
	/**
	 * Retrieves the slider selection ID 
	 * from the parameter handler
	 * and sets the local variable.
	 */
	public void extractAttributes() {
		
		//TODO: optimize this workflow!
		
		iSelectionId = refParameterHandler.getValueInt( "iSelectionId" );
		
		sSelectionFieldName = refParameterHandler.getValueString( "sSelectionFieldName" );
	}
	
	// TODO: retrieve locking token!
	public void update(Object eventTrigger) {
		
		int triggerId = ((ISelection)eventTrigger).getId();	
		refGeneralManager.getSingelton().getLoggerManager().logMsg( 
				"Slider update called by " +triggerId,
				LoggerType.VERBOSE );
		
		if (eventTrigger instanceof ISelection)
		{
			if (sSelectionFieldName.equals("length"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).length();
			}
			else if (sSelectionFieldName.equals("offset"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getOffset();
			}
			else if (sSelectionFieldName.equals("multioffset"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getMultiOffset();
			}
			else if (sSelectionFieldName.equals("multirepeat"))
			{
				iCurrentSliderValue = ((ISelection)eventTrigger).getMultiRepeat();
			}
			
			drawView();
		}
	}
}

{'fraction_non_alphanumeric': 0.10992529348986126, 'fraction_numerical': 0.0, 'mean_word_length': 4.222929936305732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '415634', 'n_tokens_mistral': 2369, 'n_tokens_neox': 1963, 'n_words': 330}