<commit_before>package de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.axes.positionlist.ui;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import de.ptb.epics.eve.data.scandescription.Axis;
import de.ptb.epics.eve.data.scandescription.axismode.PositionlistMode;
import de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.axes.positionlist.PositionlistValidator;
import de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.ui.DialogCellEditorDialog;

/**
 * @author <NAME>
 * @since 1.34
 */
public class PositionlistDialog extends DialogCellEditorDialog implements PropertyChangeListener {
	private final Axis axis;
	private final PositionlistMode positionlistMode;
	
	private Text positionlistText;
	private Label positionCountLabel;
	private Binding positionlistBinding;
	
	protected PositionlistDialog(Shell parentShell, Control control, Axis axis) {
		super(parentShell, control);
		this.axis = axis;
		this.positionlistMode = (PositionlistMode)axis.getMode();
		this.positionlistMode.addPropertyChangeListener(
				PositionlistMode.POSITIONLIST_PROP, this);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		// gridLayout.numColumns = 3;
		composite.setLayout(gridLayout);
		GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		gridData.minimumWidth = 400;
		composite.setLayoutData(gridData);

		// TODO clear button
		// TODO reset button (for discrete: clear and fill with default values)
		
		positionlistText = new Text(composite, 
				SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
		gridData = new GridData();
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.FILL;
		gridData.minimumHeight = 70;
		gridData.horizontalIndent = 7;
		positionlistText.setLayoutData(gridData);
		positionlistText.addFocusListener(new FocusAdapter() {
			@Override
			public void focusLost(FocusEvent e) {
				positionlistBinding.updateModelToTarget();
				positionlistBinding.validateTargetToModel();
				countPositions();
				super.focusLost(e);
			}
		});
		
		positionCountLabel = new Label(composite, SWT.NONE);
		positionCountLabel.setText("0 positions");
		
		this.createBinding();
		this.countPositions();
		
		return composite;
	}<commit_msg>#5420: limited width of Positionlist Dialog<commit_after>package de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.axes.positionlist.ui;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import de.ptb.epics.eve.data.scandescription.Axis;
import de.ptb.epics.eve.data.scandescription.axismode.PositionlistMode;
import de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.axes.positionlist.PositionlistValidator;
import de.ptb.epics.eve.editor.views.axeschannelsview.classiccomposite.ui.DialogCellEditorDialog;

/**
 * @author <NAME>
 * @since 1.34
 */
public class PositionlistDialog extends DialogCellEditorDialog implements PropertyChangeListener {
	private final Axis axis;
	private final PositionlistMode positionlistMode;
	
	private Text positionlistText;
	private Label positionCountLabel;
	private Binding positionlistBinding;
	
	protected PositionlistDialog(Shell parentShell, Control control, Axis axis) {
		super(parentShell, control);
		this.axis = axis;
		this.positionlistMode = (PositionlistMode)axis.getMode();
		this.positionlistMode.addPropertyChangeListener(
				PositionlistMode.POSITIONLIST_PROP, this);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		composite.setLayout(gridLayout);
		GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = true;
		gridData.minimumWidth = 400;
		composite.setLayoutData(gridData);

		positionlistText = new Text(composite, 
				SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
		gridData = new GridData();
		gridData.grabExcessHorizontalSpace = true;
		gridData.grabExcessVerticalSpace = true;
		gridData.horizontalAlignment = GridData.FILL;
		gridData.verticalAlignment = GridData.FILL;
		gridData.minimumHeight = 70;
		gridData.horizontalIndent = 7;
		positionlistText.setLayoutData(gridData);
		positionlistText.addFocusListener(new FocusAdapter() {
			@Override
			public void focusLost(FocusEvent e) {
				positionlistBinding.updateModelToTarget();
				positionlistBinding.validateTargetToModel();
				countPositions();
				super.focusLost(e);
			}
		});
		
		positionCountLabel = new Label(composite, SWT.NONE);
		positionCountLabel.setText("0 positions");
		
		this.createBinding();
		this.countPositions();
		
		return composite;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Point getInitialSize() {
		return new Point(450,250);
	}
{'fraction_non_alphanumeric': 0.10039170172638909, 'fraction_numerical': 0.004497316117800667, 'mean_word_length': 5.590822179732314, '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': '1925659', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2096, 'n_words': 359}