<commit_before>package org.csstudio.display.waterfall.opi;

import org.csstudio.opibuilder.editparts.AbstractWidgetEditPart;
import org.csstudio.opibuilder.editparts.ExecutionMode;
import org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler;
import org.csstudio.opibuilder.widgets.figures.ComboFigure;
import org.csstudio.ui.util.CustomMediaFactory;
import org.csstudio.utility.pvmanager.widgets.WaterfallWidget;
import org.eclipse.draw2d.IFigure;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;

public class WaterfallEditPart extends AbstractWidgetEditPart {
	
	/**
	 * Create and initialize figure.
	 */
	@Override
	protected IFigure doCreateFigure() {
		WaterfallFigure figure = new WaterfallFigure((Composite) getViewer().getControl(), getWidgetModel().getParent());
		figure.setRunMode(getExecutionMode() == ExecutionMode.RUN_MODE);
		configure(figure.getSWTWidget(), getWidgetModel(), figure.isRunMode());
		return figure;
	}
	
	/**Get the widget model.
	 * It is recommended that all widget controller should override this method.
	 *@return the widget model.
	 */
	@Override
	public WaterfallModel getWidgetModel() {
		return (WaterfallModel) super.getWidgetModel();
	}
	
	private static WaterfallWidget widgetOf(IFigure figure) {
		return ((WaterfallFigure) figure).getSWTWidget();
	}
	
	private static boolean runMode(IFigure figure) {
		return ((WaterfallFigure) figure).isRunMode();
	}
	
	private static void configure(WaterfallWidget widget, WaterfallModel model, boolean runMode) {
		if (runMode)
			widget.setInputText(model.getInputText());
		widget.setShowRange(model.isShowRange());
		widget.setAdaptiveRange(model.isAdaptiveRange());
		widget.setPixelDuration(model.getPixelDuration());
		widget.setScrollDown(model.isScrollDown());
		widget.setSortProperty(model.getSortProperty());
		System.out.println("Update widget");
	}

	@Override
	protected void registerPropertyChangeHandlers() {
		// The handler when PV value changed.
		IWidgetPropertyChangeHandler reconfigure = new IWidgetPropertyChangeHandler() {
			public boolean handleChange(final Object oldValue,
					final Object newValue,
					final IFigure figure) {
				configure(widgetOf(figure), getWidgetModel(), runMode(figure));
				return false;
			}
		};
		setPropertyChangeHandler(WaterfallModel.INPUT_TEXT, reconfigure);
		setPropertyChangeHandler(WaterfallModel.ADAPTIVE_RANGE, reconfigure);
		setPropertyChangeHandler(WaterfallModel.PIXEL_DURATION, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SCROLL_DOWN, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SHOW_RANGE, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SORT_PROPERTY, reconfigure);
	}
	
}<commit_msg>...waterfall.opi: removing test message.<commit_after>package org.csstudio.display.waterfall.opi;

import org.csstudio.opibuilder.editparts.AbstractWidgetEditPart;
import org.csstudio.opibuilder.editparts.ExecutionMode;
import org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler;
import org.csstudio.opibuilder.widgets.figures.ComboFigure;
import org.csstudio.ui.util.CustomMediaFactory;
import org.csstudio.utility.pvmanager.widgets.WaterfallWidget;
import org.eclipse.draw2d.IFigure;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;

public class WaterfallEditPart extends AbstractWidgetEditPart {
	
	/**
	 * Create and initialize figure.
	 */
	@Override
	protected IFigure doCreateFigure() {
		WaterfallFigure figure = new WaterfallFigure((Composite) getViewer().getControl(), getWidgetModel().getParent());
		figure.setRunMode(getExecutionMode() == ExecutionMode.RUN_MODE);
		configure(figure.getSWTWidget(), getWidgetModel(), figure.isRunMode());
		return figure;
	}
	
	/**Get the widget model.
	 * It is recommended that all widget controller should override this method.
	 *@return the widget model.
	 */
	@Override
	public WaterfallModel getWidgetModel() {
		return (WaterfallModel) super.getWidgetModel();
	}
	
	private static WaterfallWidget widgetOf(IFigure figure) {
		return ((WaterfallFigure) figure).getSWTWidget();
	}
	
	private static boolean runMode(IFigure figure) {
		return ((WaterfallFigure) figure).isRunMode();
	}
	
	private static void configure(WaterfallWidget widget, WaterfallModel model, boolean runMode) {
		if (runMode)
			widget.setInputText(model.getInputText());
		widget.setShowRange(model.isShowRange());
		widget.setAdaptiveRange(model.isAdaptiveRange());
		widget.setPixelDuration(model.getPixelDuration());
		widget.setScrollDown(model.isScrollDown());
		widget.setSortProperty(model.getSortProperty());
	}

	@Override
	protected void registerPropertyChangeHandlers() {
		// The handler when PV value changed.
		IWidgetPropertyChangeHandler reconfigure = new IWidgetPropertyChangeHandler() {
			public boolean handleChange(final Object oldValue,
					final Object newValue,
					final IFigure figure) {
				configure(widgetOf(figure), getWidgetModel(), runMode(figure));
				return false;
			}
		};
		setPropertyChangeHandler(WaterfallModel.INPUT_TEXT, reconfigure);
		setPropertyChangeHandler(WaterfallModel.ADAPTIVE_RANGE, reconfigure);
		setPropertyChangeHandler(WaterfallModel.PIXEL_DURATION, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SCROLL_DOWN, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SHOW_RANGE, reconfigure);
		setPropertyChangeHandler(WaterfallModel.SORT_PROPERTY, reconfigure);
	}
	
}
{'fraction_non_alphanumeric': 0.10087241003271538, 'fraction_numerical': 0.0003635041802980734, 'mean_word_length': 6.2694848084544255, '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': '6993520', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1591, 'n_words': 303}