Class AbstractWidgetModel

java.lang.Object
org.csstudio.opibuilder.model.AbstractWidgetModel
All Implemented Interfaces:
IAdaptable, IPropertySource
Direct Known Subclasses:
AbstractContainerModel, AbstractLayoutModel, AbstractPVWidgetModel, ConnectionModel, ImageModel, TableModel, WebBrowserModel

public abstract class AbstractWidgetModel extends Object implements IAdaptable, IPropertySource
  • Field Details

    • VERSION

      public static final String VERSION
      See Also:
    • PROP_NAME

      public static final String PROP_NAME
      The Name of the widget.
      See Also:
    • PROP_SCRIPTS

      public static final String PROP_SCRIPTS
      Scripts attached to the widget.
      See Also:
    • PROP_RULES

      public static final String PROP_RULES
      Rules attached to the widget.
      See Also:
    • PROP_XPOS

      public static final String PROP_XPOS
      X position of the widget.
      See Also:
    • PROP_YPOS

      public static final String PROP_YPOS
      Y position of the widget.
      See Also:
    • PROP_WIDTH

      public static final String PROP_WIDTH
      Width of the widget.
      See Also:
    • PROP_HEIGHT

      public static final String PROP_HEIGHT
      Height of the widget.
      See Also:
    • PROP_COLOR_BACKGROUND

      public static final String PROP_COLOR_BACKGROUND
      Background color.
      See Also:
    • PROP_COLOR_FOREGROUND

      public static final String PROP_COLOR_FOREGROUND
      Foreground color.
      See Also:
    • PROP_FONT

      public static final String PROP_FONT
      Foreground color.
      See Also:
    • PROP_VISIBLE

      public static final String PROP_VISIBLE
      Visibility of the widget.
      See Also:
    • PROP_ENABLED

      public static final String PROP_ENABLED
      Enable status. Only effective for control widgets which will make control widget uncontrollable if this is false.
      See Also:
    • PROP_ACTIONS

      public static final String PROP_ACTIONS
      Actions attached to the widget, which can be accessed on runtime via context menu Actions.
      See Also:
    • PROP_TOOLTIP

      public static final String PROP_TOOLTIP
      Tooltip of the widget, which will show up when mouse hover on the widget. Macros are allowed and can be updated. The property macro $(pv_value) could be used to show the PV value which has timestamp, value, severity and status.
      See Also:
    • PROP_BORDER_COLOR

      public static final String PROP_BORDER_COLOR
      Color of border.
      See Also:
    • PROP_BORDER_WIDTH

      public static final String PROP_BORDER_WIDTH
      Width of border.
      See Also:
    • PROP_BORDER_STYLE

      public static final String PROP_BORDER_STYLE
      Style of border.
      See Also:
    • PROP_WIDGET_TYPE

      public static final String PROP_WIDGET_TYPE
      The type of the widget. This is the only property that cannot be edited. The name and type of the selected widget will also be displayed on the status bar.
      See Also:
    • PROP_WIDGET_UID

      public static final String PROP_WIDGET_UID
      Unique ID of the widget, it should not be changed after generated.
      See Also:
    • PROP_SRC_CONNECTIONS

      public static final String PROP_SRC_CONNECTIONS
      Source Connections.
      See Also:
    • PROP_TGT_CONNECTIONS

      public static final String PROP_TGT_CONNECTIONS
      Target Connections.
      See Also:
    • PROP_SCALE_OPTIONS

      public static final String PROP_SCALE_OPTIONS
      The options for its scale behavior.
      See Also:
  • Constructor Details

    • AbstractWidgetModel

      public AbstractWidgetModel()
  • Method Details

    • addConnection

      public void addConnection(ConnectionModel conn)
    • addProperty

      public void addProperty(AbstractWidgetProperty property)
      Add a property to the widget.
      Parameters:
      property - the property to be added.
    • addProperty

      public void addProperty(AbstractWidgetProperty property, boolean runtimeChangeable)
      Add a property to the widget with the option to set it running changeable.
      Parameters:
      property - the property to be added.
      runtimeChangeable - true if this property is changeable during running. false otherwise.
    • getRuntimePropertyList

      public List<AbstractWidgetProperty> getRuntimePropertyList()
    • addPVProperty

      public void addPVProperty(PVNameProperty pvNameProperty, PVValueProperty pvValueProperty)
      Add a PVNameProperty and its value property correspondingly.
      Parameters:
      pvNameProperty -
      pvValueProperty -
    • configureBaseProperties

      protected void configureBaseProperties()
    • configureProperties

      protected abstract void configureProperties()
      Configure the properties of the widget. Subclass should add new properties in this method.
    • getAdapter

      public <T> T getAdapter(Class<T> adapter)
      Specified by:
      getAdapter in interface IAdaptable
    • getAllPropertyIDs

      public Set<String> getAllPropertyIDs()
    • getBackgroundColor

      public RGB getBackgroundColor()
    • getBorderColor

      public RGB getBorderColor()
    • getBorderStyle

      public BorderStyle getBorderStyle()
    • getBorderWidth

      public int getBorderWidth()
    • getRGBFromColorProperty

      public RGB getRGBFromColorProperty(String propID)
    • getSWTColorFromColorProperty

      public Color getSWTColorFromColorProperty(String propID)
    • getCastedPropertyValue

      protected <TYPE> TYPE getCastedPropertyValue(String propertyName)
      Return the casted value of a property of this widget model.
      Type Parameters:
      TYPE - The return type of the property value.
      Parameters:
      propertyName - The ID of the property.
      Returns:
      The casted value of a property of this widget model.
    • getEditableValue

      public Object getEditableValue()
      Specified by:
      getEditableValue in interface IPropertySource
    • getActionsInput

      public ActionsInput getActionsInput()
    • getBounds

      public org.eclipse.draw2d.geometry.Rectangle getBounds()
    • getFont

      public OPIFont getFont()
    • getForegroundColor

      public RGB getForegroundColor()
    • getLocation

      public org.eclipse.draw2d.geometry.Point getLocation()
    • getX

      public int getX()
    • getY

      public int getY()
    • getName

      public String getName()
    • getProperty

      public AbstractWidgetProperty getProperty(String prop_id)
    • getPropertyDescriptors

      public IPropertyDescriptor[] getPropertyDescriptors()
      Specified by:
      getPropertyDescriptors in interface IPropertySource
    • getPropertyValue

      public Object getPropertyValue(Object id)
      Specified by:
      getPropertyValue in interface IPropertySource
    • getRawPropertyValue

      public Object getRawPropertyValue(Object id)
    • getPVMap

    • getRulesInput

      public RulesInput getRulesInput()
    • getScriptsInput

      public ScriptsInput getScriptsInput()
    • getSize

      public org.eclipse.draw2d.geometry.Dimension getSize()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getTooltip

      public String getTooltip()
    • getRawTooltip

      public String getRawTooltip()
    • getType

      public String getType()
    • getTypeID

      public abstract String getTypeID()
      Returns:
      the unique typeID of the model.
    • getVersion

      public org.osgi.framework.Version getVersion()
      Returns:
      version of this widget model.
    • getVersionOnFile

      public org.osgi.framework.Version getVersionOnFile()
      Returns:
      version read from opi file.
    • getWidgetType

      public String getWidgetType()
    • isEnabled

      public Boolean isEnabled()
    • isPropertySet

      public boolean isPropertySet(Object id)
      Specified by:
      isPropertySet in interface IPropertySource
    • isVisible

      public Boolean isVisible()
    • removeProperty

      public void removeProperty(String prop_id)
      Remove a property from the model.
      Parameters:
      prop_id -
    • removePVProperty

      public void removePVProperty(String pvNamePropId, String pvValuePropId)
      Remove a PV p
      Parameters:
      pvNamePropId -
      pvValuePropId -
    • resetPropertyValue

      public void resetPropertyValue(Object id)
      Specified by:
      resetPropertyValue in interface IPropertySource
    • scale

      public void scale(double widthRatio, double heightRatio)
      Scale location and size of the widget. If the widget needs to change its scale behavior, it should override doScale(double, double) instead of this method.
      Parameters:
      widthRatio - Ratio of width change.
      heightRatio - Ratio of height change.
    • doScale

      protected void doScale(double widthRatio, double heightRatio)
      The actual code that scaling the widget.
      Parameters:
      widthRatio -
      heightRatio -
    • scaleConnections

      protected void scaleConnections(double widthRatio, double heightRatio)
      Parameters:
      widthRatio -
      heightRatio -
    • getOriginSize

      public org.eclipse.draw2d.geometry.Dimension getOriginSize()
      Returns:
      the original size before scaling
    • getOriginLocation

      public org.eclipse.draw2d.geometry.Point getOriginLocation()
      Returns:
      the original location before scaling
    • processVersionDifference

      public void processVersionDifference(org.osgi.framework.Version boyVersionOnFile)
      Make necessary adjustment for widget compatibility between different versions.
    • getScaleOptions

      public WidgetScaleData getScaleOptions()
    • setScaleOptions

      public void setScaleOptions(boolean isWidthScalable, boolean isHeightScalable, boolean keepWHRatio)
    • getScaledSize

      protected org.eclipse.draw2d.geometry.Dimension getScaledSize(double widthRatio, double heightRatio)
      Get the widget size after scaled.
      Parameters:
      widthRatio - Ratio of width change.
      heightRatio - Ratio of height change.
      Returns:
      the new size.
    • setBackgroundColor

      public void setBackgroundColor(RGB color)
    • setEnabled

      public void setEnabled(boolean enable)
    • setBorderColor

      public void setBorderColor(RGB color)
    • setBorderStyle

      public void setBorderStyle(BorderStyle borderStyle)
    • setBorderWidth

      public void setBorderWidth(int width)
    • setBounds

      public void setBounds(org.eclipse.draw2d.geometry.Rectangle bounds)
    • setBounds

      public void setBounds(int x, int y, int width, int height)
    • setForegroundColor

      public void setForegroundColor(RGB color)
    • setLocation

      public void setLocation(int x, int y)
    • setLocation

      public void setLocation(org.eclipse.draw2d.geometry.Point point)
    • setName

      public void setName(String name)
    • setPropertyDescription

      public void setPropertyDescription(String prop_id, String description)
    • setPropertyValue

      public void setPropertyValue(Object id, Object value)
      Specified by:
      setPropertyValue in interface IPropertySource
    • setPropertyValue

      public void setPropertyValue(Object id, Object value, boolean forceFire)
    • setPropertyVisible

      public void setPropertyVisible(String prop_id, boolean visible)
      Set if property should be visible in property sheet. Note: this method will also make the invisible property not savable to xml file. If the invisible property still needs to be saved, please use setPropertyVisibleAndSavable(String, boolean, boolean).
      Parameters:
      prop_id - id of the property.
      visible - true if visible in
    • setPropertyVisibleAndSavable

      public void setPropertyVisibleAndSavable(String prop_id, boolean visible, boolean isSavable)
      Set if property should be visible in property sheet and if savable to xml file.
      Parameters:
      prop_id - id of the property
      visible - true if visible in property sheet.
      isSavable - true if this property should be saved to xml file.
    • setSize

      public void setSize(org.eclipse.draw2d.geometry.Dimension dimension)
    • setSize

      public void setSize(int width, int height)
    • setWidth

      public void setWidth(int width)
    • setHeight

      public void setHeight(int height)
    • setX

      public void setX(int x)
    • setY

      public void setY(int y)
    • setTooltip

      public void setTooltip(String tooltip)
    • setParent

      public void setParent(AbstractContainerModel parent)
      Parameters:
      parent - the parent to set
    • setVersionOnFile

      public void setVersionOnFile(org.osgi.framework.Version versionOnFile)
      Set the widget version read from opi file.
      Parameters:
      versionOnFile -
    • getParent

      public AbstractContainerModel getParent()
      Returns:
      the parent
    • getRootDisplayModel

      public DisplayModel getRootDisplayModel()
      Returns:
      the root display model for this widget. null if its parent is not set yet.
    • getRootDisplayModel

      public DisplayModel getRootDisplayModel(boolean useLinkingContainersDisplayModel)
      Parameters:
      useLinkingContainersDisplayModel - if one of the parents of this widget is a linking container use its display model
      Returns:
      the root display model for this widget. null if its parent is not set yet.
    • getNestedDepth

      public int getNestedDepth()
      Returns:
      the nested depth of the widget in the model tree.
    • getIndex

      public int getIndex()
      Returns:
      the index of the widget in its parent's children list
    • setExecutionMode

      public void setExecutionMode(ExecutionMode executionMode)
      Parameters:
      executionMode - the executionMode to set
    • getExecutionMode

      public ExecutionMode getExecutionMode()
      Returns:
      the executionMode
    • flipHorizontally

      public void flipHorizontally()
      Flip the widget figure horizontally.
    • flipHorizontally

      public void flipHorizontally(int centerX)
      Flip the widget figure horizontally.
      Parameters:
      centerX - the center X coordinate
    • flipVertically

      public void flipVertically()
      Flip the widget figure vertically.
    • flipVertically

      public void flipVertically(int centerY)
      Flip the widget figure horizontally.
      Parameters:
      centerY - the center Y coordinate
    • rotate90

      public void rotate90(boolean clockwise)
      Rotate the widget figure 90 degree.
      Parameters:
      clockwise - true if rotate clockwise. false if counterclockwise.
    • rotate90

      public void rotate90(boolean clockwise, org.eclipse.draw2d.geometry.Point center)
      Rotate the widget figure 90 degree.
      Parameters:
      clockwise - true if rotate clockwise. false if counterclockwise.
    • getSourceConnections

      public List<ConnectionModel> getSourceConnections()
      Returns:
      a copy list of source connections.
    • getTargetConnections

      public List<ConnectionModel> getTargetConnections()
      Returns:
      a copy list of target connections.
    • getWUID

      public String getWUID()
    • generateNewWUID

      public void generateNewWUID()
      Generate a new WUID for this widget.