<commit_before>/*************************************************************************\
* Copyright (c) 2010  UChicago Argonne, LLC
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
/*************************************************************************/

package org.csstudio.opibuilder.adl2boy.translator;

import org.csstudio.opibuilder.model.AbstractContainerModel;
import org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel;
import org.csstudio.opibuilder.widgets.model.XMeterModel;
import org.csstudio.utility.adlparser.fileParser.ADLWidget;
import org.csstudio.utility.adlparser.fileParser.widgets.Meter;
import org.eclipse.swt.graphics.RGB;

public class Meter2Model extends AbstractADL2Model {

	public Meter2Model(ADLWidget adlWidget, RGB[] colorMap, AbstractContainerModel parentModel) {
		super(adlWidget, colorMap, parentModel);
	}

	@Override
	public void processWidget(ADLWidget adlWidget) {
		Meter meterWidget = new Meter(adlWidget);
		if (meterWidget != null) {
			setADLObjectProps(meterWidget, widgetModel);
			setADLMonitorProps(meterWidget, widgetModel);
		}

		//set color mode
		String color_mode = meterWidget.getColor_mode();
		System.out.println("Meter Color mode " + color_mode);
		if ( color_mode.equals("static") ){
			widgetModel.setPropertyValue(XMeterModel.PROP_FORECOLOR_ALARMSENSITIVE, false);
		}
		else if (color_mode.equals("alarm") ){
			widgetModel.setPropertyValue(XMeterModel.PROP_FORECOLOR_ALARMSENSITIVE, true);
		}
		else if (color_mode.equals("discrete") ){
			widgetModel.setPropertyValue(XMeterModel.PROP_FORECOLOR_ALARMSENSITIVE, false);
			//TODO Meter2Model Figure out what to do if colorMode is discrete
		}
		
		//TODO Add PV Limits to Meter2Model
		// Decorate the meter Model
		//TODO Meter2Model cannot show value or channel at this time. can this be added to the widget or do we need to make a grouping container.
		String label = meterWidget.getLabel();
		if ( label.equals("none")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, false);
		}
		if ( label.equals("no decorations")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, false);
		}
		if ( label.equals("outline")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
		if ( label.equals("limits")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
		if ( label.equals("channel")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
	}

	@Override
	public void makeModel(ADLWidget adlWidget,
			AbstractContainerModel parentModel) {
		widgetModel = new XMeterModel();
		parentModel.addChild(widgetModel, true);
	}
}
<commit_msg>o.c.opibuilder.adl2boy Use proper base class for PROP_FORECOLOR_ALARMSENSITIVE.<commit_after>/*************************************************************************\
* Copyright (c) 2010  UChicago Argonne, LLC
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
/*************************************************************************/

package org.csstudio.opibuilder.adl2boy.translator;

import org.csstudio.opibuilder.model.AbstractContainerModel;
import org.csstudio.opibuilder.model.AbstractPVWidgetModel;
import org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel;
import org.csstudio.opibuilder.widgets.model.XMeterModel;
import org.csstudio.utility.adlparser.fileParser.ADLWidget;
import org.csstudio.utility.adlparser.fileParser.widgets.Meter;
import org.eclipse.swt.graphics.RGB;

public class Meter2Model extends AbstractADL2Model {

	public Meter2Model(ADLWidget adlWidget, RGB[] colorMap, AbstractContainerModel parentModel) {
		super(adlWidget, colorMap, parentModel);
	}

	@Override
	public void processWidget(ADLWidget adlWidget) {
		Meter meterWidget = new Meter(adlWidget);
		if (meterWidget != null) {
			setADLObjectProps(meterWidget, widgetModel);
			setADLMonitorProps(meterWidget, widgetModel);
		}

		//set color mode
		String color_mode = meterWidget.getColor_mode();
		if ( color_mode.equals("static") ){
			widgetModel.setPropertyValue(AbstractPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE, false);
		}
		else if (color_mode.equals("alarm") ){
			widgetModel.setPropertyValue(AbstractPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE, true);
		}
		else if (color_mode.equals("discrete") ){
			widgetModel.setPropertyValue(AbstractPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE, false);
			//TODO Meter2Model Figure out what to do if colorMode is discrete
		}
		
		//TODO Add PV Limits to Meter2Model
		// Decorate the meter Model
		//TODO Meter2Model cannot show value or channel at this time. can this be added to the widget or do we need to make a grouping container.
		String label = meterWidget.getLabel();
		if ( label.equals("none")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, false);
		}
		if ( label.equals("no decorations")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, false);
		}
		if ( label.equals("outline")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
		if ( label.equals("limits")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
		if ( label.equals("channel")){
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_MARKERS, false);
			widgetModel.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_SCALE, true);
		}
	}

	@Override
	public void makeModel(ADLWidget adlWidget,
			AbstractContainerModel parentModel) {
		widgetModel = new XMeterModel();
		parentModel.addChild(widgetModel, true);
	}
}

{'fraction_non_alphanumeric': 0.13192331101643334, 'fraction_numerical': 0.00349969567863664, 'mean_word_length': 6.3114571746384875, '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': '3147165', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1986, 'n_words': 386}