<commit_before>/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.opibuilder.model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.csstudio.opibuilder.datadefinition.DisplayScaleData;
import org.csstudio.opibuilder.properties.ActionsProperty;
import org.csstudio.opibuilder.properties.BooleanProperty;
import org.csstudio.opibuilder.properties.ComplexDataProperty;
import org.csstudio.opibuilder.properties.DoubleProperty;
import org.csstudio.opibuilder.properties.IntegerProperty;
import org.csstudio.opibuilder.properties.VersionProperty;
import org.csstudio.opibuilder.properties.WidgetPropertyCategory;
import org.csstudio.opibuilder.runmode.IOPIRuntime;
import org.eclipse.core.runtime.IPath;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.GraphicalViewer;
import org.osgi.framework.Version;

/**
 * The root model for an OPI Display.
 *
 * @author <NAME>, <NAME>, <NAME> (class of same name in SDS)
 * @author <NAME>
 * @author <NAME> @ Cosylab (Property for frame rate)
 *
 */
public class DisplayModel extends AbstractContainerModel {

    /**
     * The type ID of this model.
     */
    public static final String ID = "org.csstudio.opibuilder.Display"; //$NON-NLS-1$

    /**
     * Space of grid in pixels.
     */
    public static final String PROP_GRID_SPACE = "grid_space"; //$NON-NLS-1$
    /**
     * If the grid should be visible.
     */
    public static final String PROP_SHOW_GRID = "show_grid"; //$NON-NLS-1$
    /**
     * If the ruler should be visible.
     */
    public static final String PROP_SHOW_RULER = "show_ruler"; //$NON-NLS-1$
    /**
     * If the moving widgets will be snapped to the geometry of other widgets.
     */
    public static final String PROP_SNAP_GEOMETRY = "snap_to_geometry"; //$NON-NLS-1$
    /**
     * If the dash boundary line of the display should be visible.
     */
    public static final String PROP_SHOW_EDIT_RANGE = "show_edit_range"; //$NON-NLS-1$

    /**
     * If the tab close button should be hidden.
     */
    public static final String PROP_SHOW_CLOSE_BUTTON = "show_close_button"; //$NON-NLS-1$

    public static final String PROP_BOY_VERSION = "boy_version"; //$NON-NLS-1$

    /**
     * Auto scale all the widgets as the window resizes. If this is set to true,
     * zoom operation will not work.
     */
    public static final String PROP_AUTO_ZOOM_TO_FIT_ALL = "auto_zoom_to_fit_all"; //$NON-NLS-1$

    /**
     * Automatically scale all widgets when window resizes.
     */
    public static final String PROP_AUTO_SCALE_WIDGETS = "auto_scale_widgets"; //$NON-NLS-1$

    /**
     * Frame rate in Hz.
     * This is the hidden property which can be referred only from scripts.
     * The value is valid only when running mode. In edit mode, it is always -1.
     */
    public static final String PROP_FRAME_RATE = "frame_rate"; //$NON-NLS-1$

    public static final Point NULL_LOCATION = new Point(-1, -1);

    private GraphicalViewer viewer;

    private IOPIRuntime opiRuntime;

    private IPath opiFilePath;

    private boolean FreshRateEnabled= false;

    private int displayID;

    /**
     * Create a Display Model which is the root model for an OPI.
     * Only use this constructor if this model doesn't relate to
     * any real opi file. Otherwise, please use {@link #DisplayModel(IPath)}.
     */
    public DisplayModel(){
        this(null);
    }

    /**Create a Display Model which is the root model for an OPI.
     * @param opiFilePath path of the OPI. It can only be null if this model doesn't relate to
     * any real opi file.
     */
    public DisplayModel(IPath opiFilePath) {
        super();
        setLocation(NULL_LOCATION);
        setSize(800, 600);
        setOpiFilePath(opiFilePath);
    }

    @Override
    protected void configureProperties() {
        addProperty(new IntegerProperty(PROP_GRID_SPACE, "Grid Space",
                WidgetPropertyCategory.Display, 6, 1, 1000));
        addProperty(new BooleanProperty(PROP_SHOW_GRID, "Show Grid",
                WidgetPropertyCategory.Display, true));
        addProperty(new BooleanProperty(PROP_SHOW_RULER, "Show Ruler",
                WidgetPropertyCategory.Display, true));
        addProperty(new BooleanProperty(PROP_SNAP_GEOMETRY, "Snap to Geometry",<commit_msg>o.c.opibuilder: add back incrementing unique display ID.<commit_after>/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.opibuilder.model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

import org.csstudio.opibuilder.datadefinition.DisplayScaleData;
import org.csstudio.opibuilder.properties.ActionsProperty;
import org.csstudio.opibuilder.properties.BooleanProperty;
import org.csstudio.opibuilder.properties.ComplexDataProperty;
import org.csstudio.opibuilder.properties.DoubleProperty;
import org.csstudio.opibuilder.properties.IntegerProperty;
import org.csstudio.opibuilder.properties.VersionProperty;
import org.csstudio.opibuilder.properties.WidgetPropertyCategory;
import org.csstudio.opibuilder.runmode.IOPIRuntime;
import org.eclipse.core.runtime.IPath;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.GraphicalViewer;
import org.osgi.framework.Version;

/**
 * The root model for an OPI Display.
 *
 * @author <NAME>, <NAME>, <NAME> (class of same name in SDS)
 * @author <NAME>
 * @author <NAME> @ Cosylab (Property for frame rate)
 *
 */
public class DisplayModel extends AbstractContainerModel {

    /**
     * The type ID of this model.
     */
    public static final String ID = "org.csstudio.opibuilder.Display"; //$NON-NLS-1$

    /**
     * Space of grid in pixels.
     */
    public static final String PROP_GRID_SPACE = "grid_space"; //$NON-NLS-1$
    /**
     * If the grid should be visible.
     */
    public static final String PROP_SHOW_GRID = "show_grid"; //$NON-NLS-1$
    /**
     * If the ruler should be visible.
     */
    public static final String PROP_SHOW_RULER = "show_ruler"; //$NON-NLS-1$
    /**
     * If the moving widgets will be snapped to the geometry of other widgets.
     */
    public static final String PROP_SNAP_GEOMETRY = "snap_to_geometry"; //$NON-NLS-1$
    /**
     * If the dash boundary line of the display should be visible.
     */
    public static final String PROP_SHOW_EDIT_RANGE = "show_edit_range"; //$NON-NLS-1$

    /**
     * If the tab close button should be hidden.
     */
    public static final String PROP_SHOW_CLOSE_BUTTON = "show_close_button"; //$NON-NLS-1$

    public static final String PROP_BOY_VERSION = "boy_version"; //$NON-NLS-1$

    /**
     * Auto scale all the widgets as the window resizes. If this is set to true,
     * zoom operation will not work.
     */
    public static final String PROP_AUTO_ZOOM_TO_FIT_ALL = "auto_zoom_to_fit_all"; //$NON-NLS-1$

    /**
     * Automatically scale all widgets when window resizes.
     */
    public static final String PROP_AUTO_SCALE_WIDGETS = "auto_scale_widgets"; //$NON-NLS-1$

    /**
     * Frame rate in Hz.
     * This is the hidden property which can be referred only from scripts.
     * The value is valid only when running mode. In edit mode, it is always -1.
     */
    public static final String PROP_FRAME_RATE = "frame_rate"; //$NON-NLS-1$

    public static final Point NULL_LOCATION = new Point(-1, -1);

    private GraphicalViewer viewer;

    private IOPIRuntime opiRuntime;

    private IPath opiFilePath;

    private boolean FreshRateEnabled= false;

    private int displayID;
    private static AtomicInteger displayIDCounter = new AtomicInteger(0);

    /**
     * Create a Display Model which is the root model for an OPI.
     * Only use this constructor if this model doesn't relate to
     * any real opi file. Otherwise, please use {@link #DisplayModel(IPath)}.
     */
    public DisplayModel(){
        this(null);
    }

    /**Create a Display Model which is the root model for an OPI.
     * @param opiFilePath path of the OPI. It can only be null if this model doesn't relate to
     * any real opi file.
     */
    public DisplayModel(IPath opiFilePath) {
        super();
        setLocation(NULL_LOCATION);
        setSize(800, 600);
        setOpiFilePath(opiFilePath);
        displayID = displayIDCounter.incrementAndGet();
    }

    @Override
    protected void configureProperties() {
        addProperty(new IntegerProperty(PROP_GRID_SPACE, "Grid Space",
                WidgetPropertyCategory.Display, 6, 1, 1000));
        addProperty(new BooleanProperty(PROP_SHOW_GRID, "Show Grid",
                WidgetPropertyCategory.Display, true));
        addProperty(new BooleanProperty(PROP_SHOW_RULER, "Show Ruler",
                WidgetPropertyCategory.Display, true));
        addProperty(new BooleanProperty(PROP_SNAP_GEOMETRY, "Snap to Geometry",
{'fraction_non_alphanumeric': 0.12478229689580986, 'fraction_numerical': 0.007273844892941297, 'mean_word_length': 3.3175586023883237, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3962992', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2845, 'n_words': 861}