Package org.csstudio.opibuilder.model
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringActions attached to the widget, which can be accessed on runtime via context menuActions.static final StringColor of border.static final StringStyle of border.static final StringWidth of border.static final StringBackground color.static final StringForeground color.static final StringEnable status.static final StringForeground color.static final StringHeight of the widget.static final StringThe Name of the widget.static final StringRules attached to the widget.static final StringThe options for its scale behavior.static final StringScripts attached to the widget.static final StringSource Connections.static final StringTarget Connections.static final StringTooltip of the widget, which will show up when mouse hover on the widget.static final StringVisibility of the widget.static final StringThe type of the widget.static final StringUnique ID of the widget, it should not be changed after generated.static final StringWidth of the widget.static final StringX position of the widget.static final StringY position of the widget.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnection(ConnectionModel conn) voidaddProperty(AbstractWidgetProperty property) Add a property to the widget.voidaddProperty(AbstractWidgetProperty property, boolean runtimeChangeable) Add a property to the widget with the option to set it running changeable.voidaddPVProperty(PVNameProperty pvNameProperty, PVValueProperty pvValueProperty) Add a PVNameProperty and its value property correspondingly.protected voidprotected abstract voidConfigure the properties of the widget.protected voiddoScale(double widthRatio, double heightRatio) The actual code that scaling the widget.voidFlip the widget figure horizontally.voidflipHorizontally(int centerX) Flip the widget figure horizontally.voidFlip the widget figure vertically.voidflipVertically(int centerY) Flip the widget figure horizontally.voidGenerate a new WUID for this widget.<T> TgetAdapter(Class<T> adapter) intorg.eclipse.draw2d.geometry.Rectangleprotected <TYPE> TYPEgetCastedPropertyValue(String propertyName) Return the casted value of a property of this widget model.getFont()intintgetIndex()org.eclipse.draw2d.geometry.PointgetName()intorg.eclipse.draw2d.geometry.Pointorg.eclipse.draw2d.geometry.DimensiongetProperty(String prop_id) getPVMap()getRGBFromColorProperty(String propID) getRootDisplayModel(boolean useLinkingContainersDisplayModel) protected org.eclipse.draw2d.geometry.DimensiongetScaledSize(double widthRatio, double heightRatio) Get the widget size after scaled.org.eclipse.draw2d.geometry.DimensiongetSize()getSWTColorFromColorProperty(String propID) getType()abstract Stringorg.osgi.framework.Versionorg.osgi.framework.VersionintgetWidth()getWUID()intgetX()intgetY()booleanisPropertySet(Object id) voidprocessVersionDifference(org.osgi.framework.Version boyVersionOnFile) Make necessary adjustment for widget compatibility between different versions.voidremoveProperty(String prop_id) Remove a property from the model.voidremovePVProperty(String pvNamePropId, String pvValuePropId) Remove a PV pvoidvoidrotate90(boolean clockwise) Rotate the widget figure 90 degree.voidrotate90(boolean clockwise, org.eclipse.draw2d.geometry.Point center) Rotate the widget figure 90 degree.voidscale(double widthRatio, double heightRatio) Scale location and size of the widget.protected voidscaleConnections(double widthRatio, double heightRatio) voidsetBackgroundColor(RGB color) voidsetBorderColor(RGB color) voidsetBorderStyle(BorderStyle borderStyle) voidsetBorderWidth(int width) voidsetBounds(int x, int y, int width, int height) voidsetBounds(org.eclipse.draw2d.geometry.Rectangle bounds) voidsetEnabled(boolean enable) voidsetExecutionMode(ExecutionMode executionMode) voidsetForegroundColor(RGB color) voidsetHeight(int height) voidsetLocation(int x, int y) voidsetLocation(org.eclipse.draw2d.geometry.Point point) voidvoidsetParent(AbstractContainerModel parent) voidsetPropertyDescription(String prop_id, String description) voidsetPropertyValue(Object id, Object value) voidsetPropertyValue(Object id, Object value, boolean forceFire) voidsetPropertyVisible(String prop_id, boolean visible) Set if property should be visible in property sheet.voidsetPropertyVisibleAndSavable(String prop_id, boolean visible, boolean isSavable) Set if property should be visible in property sheet and if savable to xml file.voidsetScaleOptions(boolean isWidthScalable, boolean isHeightScalable, boolean keepWHRatio) voidsetSize(int width, int height) voidsetSize(org.eclipse.draw2d.geometry.Dimension dimension) voidsetTooltip(String tooltip) voidsetVersionOnFile(org.osgi.framework.Version versionOnFile) Set the widget version read from opi file.voidsetWidth(int width) voidsetX(int x) voidsetY(int y)
-
Field Details
-
VERSION
- See Also:
-
PROP_NAME
The Name of the widget.- See Also:
-
PROP_SCRIPTS
Scripts attached to the widget.- See Also:
-
PROP_RULES
Rules attached to the widget.- See Also:
-
PROP_XPOS
X position of the widget.- See Also:
-
PROP_YPOS
Y position of the widget.- See Also:
-
PROP_WIDTH
Width of the widget.- See Also:
-
PROP_HEIGHT
Height of the widget.- See Also:
-
PROP_COLOR_BACKGROUND
Background color.- See Also:
-
PROP_COLOR_FOREGROUND
Foreground color.- See Also:
-
PROP_FONT
Foreground color.- See Also:
-
PROP_VISIBLE
Visibility of the widget.- See Also:
-
PROP_ENABLED
Enable status. Only effective for control widgets which will make control widget uncontrollable if this is false.- See Also:
-
PROP_ACTIONS
Actions attached to the widget, which can be accessed on runtime via context menuActions.- See Also:
-
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
Color of border.- See Also:
-
PROP_BORDER_WIDTH
Width of border.- See Also:
-
PROP_BORDER_STYLE
Style of border.- See Also:
-
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
Unique ID of the widget, it should not be changed after generated.- See Also:
-
PROP_SRC_CONNECTIONS
Source Connections.- See Also:
-
PROP_TGT_CONNECTIONS
Target Connections.- See Also:
-
PROP_SCALE_OPTIONS
The options for its scale behavior.- See Also:
-
-
Constructor Details
-
AbstractWidgetModel
public AbstractWidgetModel()
-
-
Method Details
-
addConnection
-
addProperty
Add a property to the widget.- Parameters:
property- the property to be added.
-
addProperty
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
-
addPVProperty
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
- Specified by:
getAdapterin interfaceIAdaptable
-
getAllPropertyIDs
-
getBackgroundColor
-
getBorderColor
-
getBorderStyle
-
getBorderWidth
public int getBorderWidth() -
getRGBFromColorProperty
-
getSWTColorFromColorProperty
-
getCastedPropertyValue
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
- Specified by:
getEditableValuein interfaceIPropertySource
-
getActionsInput
-
getBounds
public org.eclipse.draw2d.geometry.Rectangle getBounds() -
getFont
-
getForegroundColor
-
getLocation
public org.eclipse.draw2d.geometry.Point getLocation() -
getX
public int getX() -
getY
public int getY() -
getName
-
getProperty
-
getPropertyDescriptors
- Specified by:
getPropertyDescriptorsin interfaceIPropertySource
-
getPropertyValue
- Specified by:
getPropertyValuein interfaceIPropertySource
-
getRawPropertyValue
-
getPVMap
-
getRulesInput
-
getScriptsInput
-
getSize
public org.eclipse.draw2d.geometry.Dimension getSize() -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getTooltip
-
getRawTooltip
-
getType
-
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
-
isEnabled
-
isPropertySet
- Specified by:
isPropertySetin interfaceIPropertySource
-
isVisible
-
removeProperty
Remove a property from the model.- Parameters:
prop_id-
-
removePVProperty
Remove a PV p- Parameters:
pvNamePropId-pvValuePropId-
-
resetPropertyValue
- Specified by:
resetPropertyValuein interfaceIPropertySource
-
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 overridedoScale(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
-
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
-
setEnabled
public void setEnabled(boolean enable) -
setBorderColor
-
setBorderStyle
-
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
-
setLocation
public void setLocation(int x, int y) -
setLocation
public void setLocation(org.eclipse.draw2d.geometry.Point point) -
setName
-
setPropertyDescription
-
setPropertyValue
- Specified by:
setPropertyValuein interfaceIPropertySource
-
setPropertyValue
-
setPropertyVisible
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 usesetPropertyVisibleAndSavable(String, boolean, boolean).- Parameters:
prop_id- id of the property.visible- true if visible in
-
setPropertyVisibleAndSavable
Set if property should be visible in property sheet and if savable to xml file.- Parameters:
prop_id- id of the propertyvisible- 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
-
setParent
- 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
- Returns:
- the parent
-
getRootDisplayModel
- Returns:
- the root display model for this widget. null if its parent is not set yet.
-
getRootDisplayModel
- 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
- Parameters:
executionMode- the executionMode to set
-
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
- Returns:
- a copy list of source connections.
-
getTargetConnections
- Returns:
- a copy list of target connections.
-
getWUID
-
generateNewWUID
public void generateNewWUID()Generate a new WUID for this widget.
-