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
Modifier and TypeFieldDescriptionstatic final String
Actions attached to the widget, which can be accessed on runtime via context menuActions
.static final String
Color of border.static final String
Style of border.static final String
Width of border.static final String
Background color.static final String
Foreground color.static final String
Enable status.static final String
Foreground color.static final String
Height of the widget.static final String
The Name of the widget.static final String
Rules attached to the widget.static final String
The options for its scale behavior.static final String
Scripts attached to the widget.static final String
Source Connections.static final String
Target Connections.static final String
Tooltip of the widget, which will show up when mouse hover on the widget.static final String
Visibility of the widget.static final String
The type of the widget.static final String
Unique ID of the widget, it should not be changed after generated.static final String
Width of the widget.static final String
X position of the widget.static final String
Y position of the widget.static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnection
(ConnectionModel conn) void
addProperty
(AbstractWidgetProperty property) Add a property to the widget.void
addProperty
(AbstractWidgetProperty property, boolean runtimeChangeable) Add a property to the widget with the option to set it running changeable.void
addPVProperty
(PVNameProperty pvNameProperty, PVValueProperty pvValueProperty) Add a PVNameProperty and its value property correspondingly.protected void
protected abstract void
Configure the properties of the widget.protected void
doScale
(double widthRatio, double heightRatio) The actual code that scaling the widget.void
Flip the widget figure horizontally.void
flipHorizontally
(int centerX) Flip the widget figure horizontally.void
Flip the widget figure vertically.void
flipVertically
(int centerY) Flip the widget figure horizontally.void
Generate a new WUID for this widget.<T> T
getAdapter
(Class<T> adapter) int
org.eclipse.draw2d.geometry.Rectangle
protected <TYPE> TYPE
getCastedPropertyValue
(String propertyName) Return the casted value of a property of this widget model.getFont()
int
int
getIndex()
org.eclipse.draw2d.geometry.Point
getName()
int
org.eclipse.draw2d.geometry.Point
org.eclipse.draw2d.geometry.Dimension
getProperty
(String prop_id) getPVMap()
getRGBFromColorProperty
(String propID) getRootDisplayModel
(boolean useLinkingContainersDisplayModel) protected org.eclipse.draw2d.geometry.Dimension
getScaledSize
(double widthRatio, double heightRatio) Get the widget size after scaled.org.eclipse.draw2d.geometry.Dimension
getSize()
getSWTColorFromColorProperty
(String propID) getType()
abstract String
org.osgi.framework.Version
org.osgi.framework.Version
int
getWidth()
getWUID()
int
getX()
int
getY()
boolean
isPropertySet
(Object id) void
processVersionDifference
(org.osgi.framework.Version boyVersionOnFile) Make necessary adjustment for widget compatibility between different versions.void
removeProperty
(String prop_id) Remove a property from the model.void
removePVProperty
(String pvNamePropId, String pvValuePropId) Remove a PV pvoid
void
rotate90
(boolean clockwise) Rotate the widget figure 90 degree.void
rotate90
(boolean clockwise, org.eclipse.draw2d.geometry.Point center) Rotate the widget figure 90 degree.void
scale
(double widthRatio, double heightRatio) Scale location and size of the widget.protected void
scaleConnections
(double widthRatio, double heightRatio) void
setBackgroundColor
(RGB color) void
setBorderColor
(RGB color) void
setBorderStyle
(BorderStyle borderStyle) void
setBorderWidth
(int width) void
setBounds
(int x, int y, int width, int height) void
setBounds
(org.eclipse.draw2d.geometry.Rectangle bounds) void
setEnabled
(boolean enable) void
setExecutionMode
(ExecutionMode executionMode) void
setForegroundColor
(RGB color) void
setHeight
(int height) void
setLocation
(int x, int y) void
setLocation
(org.eclipse.draw2d.geometry.Point point) void
void
setParent
(AbstractContainerModel parent) void
setPropertyDescription
(String prop_id, String description) void
setPropertyValue
(Object id, Object value) void
setPropertyValue
(Object id, Object value, boolean forceFire) void
setPropertyVisible
(String prop_id, boolean visible) Set if property should be visible in property sheet.void
setPropertyVisibleAndSavable
(String prop_id, boolean visible, boolean isSavable) Set if property should be visible in property sheet and if savable to xml file.void
setScaleOptions
(boolean isWidthScalable, boolean isHeightScalable, boolean keepWHRatio) void
setSize
(int width, int height) void
setSize
(org.eclipse.draw2d.geometry.Dimension dimension) void
setTooltip
(String tooltip) void
setVersionOnFile
(org.osgi.framework.Version versionOnFile) Set the widget version read from opi file.void
setWidth
(int width) void
setX
(int x) void
setY
(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:
getAdapter
in 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:
getEditableValue
in 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:
getPropertyDescriptors
in interfaceIPropertySource
-
getPropertyValue
- Specified by:
getPropertyValue
in 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:
isPropertySet
in interfaceIPropertySource
-
isVisible
-
removeProperty
Remove a property from the model.- Parameters:
prop_id
-
-
removePVProperty
Remove a PV p- Parameters:
pvNamePropId
-pvValuePropId
-
-
resetPropertyValue
- Specified by:
resetPropertyValue
in 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:
setPropertyValue
in 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.
-