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

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

import org.csstudio.csdata.ProcessVariable;
import org.csstudio.opibuilder.editparts.AbstractBaseEditPart;
import org.csstudio.opibuilder.widgets.figures.AbstractSWTWidgetFigure;
import org.csstudio.ui.util.AdapterUtil;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Composite;

/**
 * Base class for all figures that are based on SWTWidgets and channel finder.
 * 
 * @author carcassi
 *
 * @param <T> the widget type
 */
public abstract class AbstractChannelWidgetFigure<T extends Composite> extends AbstractSWTWidgetFigure {
	
	/**
	 * Creates a new figure based on the give swt widget and the selection provider.
	 * 
	 * @param composite pass through
	 * @param parentModel pass through
	 * @param swtWidget the SWT widget
	 * @param selectionProvider a corresponding selection provider
	 */
	public AbstractChannelWidgetFigure(AbstractBaseEditPart editPart) {
		super(editPart);
		widget = createWidget(composite);
		selectionProvider = retrieveSelectionProvider(widget);
	}

	/**
	 * Implement to create the widget to be wrapped.
	 * 
	 * @param parent the widget parent
	 * @return the new widget
	 */
	protected abstract T createWidget(Composite parent);
	
	/**
	 * Returns the selection provider to be used for pop-ups. By default, if the
	 * widget is itself an ISelectionProvider, the widget is returned.
	 * 
	 * @param widget the widget
	 * @return the selection provider or null
	 */
	protected ISelectionProvider retrieveSelectionProvider(T widget) {
		if (widget instanceof ISelectionProvider) {
			return (ISelectionProvider) widget;
		}
		return null;
	}
	
	private final T widget;
	private final ISelectionProvider selectionProvider;

	@Override
	public T getSWTWidget() {
		return widget;
	}
	
	/**
	 * The selection provider to be used for the pop-up.
	 * 
	 * @return the selection provider or null
	 */
	public ISelectionProvider getSelectionProvider() {
		return selectionProvider;
	}
	
	public boolean isRunMode() {
		return runmode;
	}
	
}
<commit_msg>channel.opiwidgets: fix a bug with putting native widget in container.<commit_after>package org.csstudio.channel.opiwidgets;

import org.csstudio.opibuilder.editparts.AbstractBaseEditPart;
import org.csstudio.opibuilder.widgets.figures.AbstractSWTWidgetFigure;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Composite;

/**
 * Base class for all figures that are based on SWTWidgets and channel finder.
 * 
 * @author carcassi
 *
 * @param <T> the widget type
 */
public abstract class AbstractChannelWidgetFigure<T extends Composite> extends AbstractSWTWidgetFigure {
	
	/**
	 * Creates a new figure based on the give swt widget and the selection provider.
	 * 
	 * @param composite pass through
	 * @param parentModel pass through
	 * @param swtWidget the SWT widget
	 * @param selectionProvider a corresponding selection provider
	 */
	public AbstractChannelWidgetFigure(AbstractBaseEditPart editPart) {
		super(editPart);
		widget = createWidget(getParentComposite());
		selectionProvider = retrieveSelectionProvider(widget);
	}

	/**
	 * Implement to create the widget to be wrapped.
	 * 
	 * @param parent the widget parent
	 * @return the new widget
	 */
	protected abstract T createWidget(Composite parent);
	
	/**
	 * Returns the selection provider to be used for pop-ups. By default, if the
	 * widget is itself an ISelectionProvider, the widget is returned.
	 * 
	 * @param widget the widget
	 * @return the selection provider or null
	 */
	protected ISelectionProvider retrieveSelectionProvider(T widget) {
		if (widget instanceof ISelectionProvider) {
			return (ISelectionProvider) widget;
		}
		return null;
	}
	
	private final T widget;
	private final ISelectionProvider selectionProvider;

	@Override
	public T getSWTWidget() {
		return widget;
	}
	
	/**
	 * The selection provider to be used for the pop-up.
	 * 
	 * @return the selection provider or null
	 */
	public ISelectionProvider getSelectionProvider() {
		return selectionProvider;
	}
	
	public boolean isRunMode() {
		return runmode;
	}
	
}

{'fraction_non_alphanumeric': 0.07456541628545288, 'fraction_numerical': 0.0, 'mean_word_length': 3.588667366211962, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5666046', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1175, 'n_words': 387}