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

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

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class PropertyListSelectionWidget extends Composite {
	
	private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
	
	private org.eclipse.swt.widgets.List unselected;
	private org.eclipse.swt.widgets.List selected;

	public PropertyListSelectionWidget(Composite parent, int style) {
		super(parent, style);
		setLayout(new GridLayout(3, false));
		
		unselected = new org.eclipse.swt.widgets.List(this, SWT.BORDER);
		unselected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite composite = new Composite(this, SWT.NONE);
		composite.setLayout(new GridLayout(1, false));
		
		Button selectButton = new Button(composite, SWT.NONE);
		selectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		selectButton.setSize(34, 30);
		selectButton.setText("-->");
		selectButton.addSelectionListener(new SelectionAdapter() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				List<String> newSelection = new ArrayList<String>(selectedProperties);
				newSelection.addAll(Arrays.asList(unselected.getSelection()));
				setSelectedProperties(newSelection);
				selected.setSelection(selectedProperties.size() - 1);
			}
		});
		
		Button upButton = new Button(composite, SWT.NONE);
		upButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		upButton.setText("Move Up");
		upButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				int oldIndex = selected.getSelectionIndex();
				if (oldIndex != 0) {
					List<String> newSelection = new ArrayList<String>(selectedProperties);
					newSelection.set(oldIndex - 1, selectedProperties.get(oldIndex));
					newSelection.set(oldIndex, selectedProperties.get(oldIndex - 1));
					setSelectedProperties(newSelection);
					selected.setSelection(oldIndex - 1);
				}
			}
		});
		
		Button downButton = new Button(composite, SWT.NONE);
		downButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		downButton.setText("Move Down");
		downButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				int oldIndex = selected.getSelectionIndex();
				if (oldIndex != selectedProperties.size() - 1) {
					List<String> newSelection = new ArrayList<String>(selectedProperties);
					newSelection.set(oldIndex + 1, selectedProperties.get(oldIndex));
					newSelection.set(oldIndex, selectedProperties.get(oldIndex + 1));
					setSelectedProperties(newSelection);
					selected.setSelection(oldIndex + 1);
				}
			}
		});
		
		Button unselectButton = new Button(composite, SWT.NONE);
		unselectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		unselectButton.setText("<--");
		unselectButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				List<String> newSelection = new ArrayList<String>(selectedProperties);
				newSelection.removeAll(Arrays.asList(selected.getSelection()));
				setSelectedProperties(newSelection);
			}
		});<commit_msg>..channel.widgets: property list editor button guard for empty selections.<commit_after>package org.csstudio.channel.widgets;

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

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class PropertyListSelectionWidget extends Composite {
	
	private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
	
	private org.eclipse.swt.widgets.List unselected;
	private org.eclipse.swt.widgets.List selected;

	public PropertyListSelectionWidget(Composite parent, int style) {
		super(parent, style);
		setLayout(new GridLayout(3, false));
		
		unselected = new org.eclipse.swt.widgets.List(this, SWT.BORDER);
		unselected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite composite = new Composite(this, SWT.NONE);
		composite.setLayout(new GridLayout(1, false));
		
		Button selectButton = new Button(composite, SWT.NONE);
		selectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		selectButton.setSize(34, 30);
		selectButton.setText("-->");
		selectButton.addSelectionListener(new SelectionAdapter() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (unselected.getSelectionCount() != 0) {
					List<String> newSelection = new ArrayList<String>(selectedProperties);
					newSelection.addAll(Arrays.asList(unselected.getSelection()));
					setSelectedProperties(newSelection);
					selected.setSelection(selectedProperties.size() - 1);
				}
			}
		});
		
		Button upButton = new Button(composite, SWT.NONE);
		upButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		upButton.setText("Move Up");
		upButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (selected.getSelectionCount() != 0) {
					int oldIndex = selected.getSelectionIndex();
					if (oldIndex != 0) {
						List<String> newSelection = new ArrayList<String>(selectedProperties);
						newSelection.set(oldIndex - 1, selectedProperties.get(oldIndex));
						newSelection.set(oldIndex, selectedProperties.get(oldIndex - 1));
						setSelectedProperties(newSelection);
						selected.setSelection(oldIndex - 1);
					}
				}
			}
		});
		
		Button downButton = new Button(composite, SWT.NONE);
		downButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		downButton.setText("Move Down");
		downButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (selected.getSelectionCount() != 0) {
					int oldIndex = selected.getSelectionIndex();
					if (oldIndex != selectedProperties.size() - 1) {
						List<String> newSelection = new ArrayList<String>(selectedProperties);
						newSelection.set(oldIndex + 1, selectedProperties.get(oldIndex));
						newSelection.set(oldIndex, selectedProperties.get(oldIndex + 1));
						setSelectedProperties(newSelection);
						selected.setSelection(oldIndex + 1);
					}
				}
			}
		});
		
		Button unselectButton = new Button(composite, SWT.NONE);
		unselectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		unselectButton.setText("<--");
		unselectButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (selected.getSelectionCount() != 0) {
					List<String> newSelection = new ArrayList<String>(selectedProperties);
					newSelection.removeAll(Arrays.asList(selected.getSelection()));
					setSelectedProperties(newSelection);
				}
			}
		});
{'fraction_non_alphanumeric': 0.11799447097260618, 'fraction_numerical': 0.006785624528776075, 'mean_word_length': 4.975225225225225, 'pattern_counts': {'":': 0, '<': 21, '<?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': '4675742', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2343, 'n_words': 456}