Package com.iizigo
Class ApplicationUI
java.lang.Object
com.iizigo.ApplicationUI
The ApplicationUI instance holds the various images loaded from Image Descriptors and can be used as SWT Images directly, as well as other SWT allocated object such as colors.
- Author:
- Christopher Mindus
Nested Class Summary
Field Summary
Modifier and TypeFieldDescriptionfinal Color
final Display
The Display.static final StyledString.Styler
The error style color for StyledText.final Color
final Image
final Image
final Image
final Image
final StyledString.Styler
Styler used for Package Names for StyledString's.final StyledString.Styler
Styler used for Project Names for StyledString's.final Color
final Color
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addThemeListener
(IThemeListener listener) Call this method to register for theme changes.static boolean
addThemeListener
(IThemeListener listener, Control widget) Call this method to register for theme changes and automatic removal of its listener when the widget is disposed of.void
Applies a gradient on a composite in light mode, and in dark mode, just use the default widget background.static int
autoScaleDown
(int size) Auto-scales down for high DPI displays.static int
autoScaleUp
(int size) Auto-scales up for high DPI displays.void
Centers the window on screen over its parent and sets the size.void
Centers the window on screen over its parent and sets the size.void
Centers the window on screen over its parent and sets the size and image.void
Centers the window on screen over its parent and sets the size and image.void
Centers the window on screen over its parent and sets the size and image.int
cx
(int w) Calculates the width of an element with the dialog font.int
cy
(int h) Calculates the height of an element with the dialog font.int
Gets the height of each item for properties.Gets a bold font for a standard component.getColor
(int rgb) Gets a color and adds it to be disposed of when the plug-in exits.getColor
(int r, int g, int b) Gets a color and adds it to be disposed of when the plug-in exits.getDecoratedImage
(Image image, int errorLevel) Creates or gets a (perhaps) decorated image for warning/errors.getErrorImage
(int level) Gets the image for the property error level 0=INFO, 1=WARNING, 2=ERROR.getErrorImage
(IPropErrorItem errorItem) Gets the image for the property error severity level.getErrorImageDecoration
(int level) Gets the small decoration images for the property error levels 1=WARNING, 2=ERROR.Gets the standard fixed font.Gets a font and adds it to be disposed of when the plug-in exits.Gets a heading font.getImage
(DesignerProp dp) Gets the Image for a DesignerProp instance.Gets an Image for a property.Gets an Image for a property class.Gets an Image from a file name.getImage
(ImageDescriptor descriptor) Loads the image for an Image Descriptor and caches it.static ApplicationUI
Gets the instance of the ApplicationUI.Gets an italic font for a standard component.getNewImage
(Image image) Creates a "New item" image from an existing image.getNewImageDescriptor
(Image image) Creates a "New item" image descriptor from an existing image.Gets the default dialog normal font.getTheme()
Gets the current theme.getWizardImage
(Image image) Creates a "wizard" image from an existing image.getWorkBenchImage
(String name) Gets a Workbench Shared image by a name.boolean
Gets the flag not to use scaling because it's automatic.boolean
Checks if a "dark" mode is used, e.g.static boolean
Checks if the ApplicationUI instance is created.void
loadWorkBenchImages
(ToolItem item, String name) Loads a set of workbench Image's from its symbolic names defined in org.eclipse.ui.ISharedImages and assigns it to the ToolItem.void
loadWorkBenchImages
(ToolItem item, String nameEnabled, String nameDisabled) Loads a set of workbench Image's from its symbolic names defined in org.eclipse.ui.ISharedImages and assigns it to the ToolItem.boolean
removeImage
(Image image) Removes an image and its image descriptor once loaded.static boolean
removeThemeListener
(IThemeListener listener) Call this method to register for theme changes.int
s10()
Gets the spacing of 5 "pixels" depending on font scaling.int
s15()
Gets the spacing of 5 "pixels" depending on font scaling.int
s2()
Gets the spacing of 2 "pixels" depending on font scaling.int
s20()
Gets the spacing of 5 "pixels" depending on font scaling.int
s4()
Gets the spacing of 4 "pixels" depending on font scaling.int
s5()
Gets the spacing of 5 "pixels" depending on font scaling.int
s8()
Gets the spacing of 8 "pixels" depending on font scaling.
Field Details
ERROR_STYLER
The error style color for StyledText.display
The Display.white
black
transparent
gray
border
foreground
background
widgetBackground
headerBackground
listSelectionForeground
listSelectionBackground
disabledForeground
lightShadow
darkShadow
tooltipBackground
entryFieldFocusBackground
entryFieldBackground
entryFieldForeground
errorBackground
errorBackgroundCursor
errorForeground
warningBackground
warningBackgroundCursor
warningForeground
infoBackground
infoBackgroundCursor
infoForeground
greenForeground
greenBackground
selectedPropBackground
propertyValueWarning
propertyValueError
propertyValueUndefined
propertyValueDefined
propertyValueInherited
propertyValueOverridden
paleLine
propTreeLine
propEditorBackground
propEditorIconBackground
packageNameStyler
Styler used for Package Names for StyledString's.projectNameStyler
Styler used for Project Names for StyledString's.imageFile
imageError
imageWarning
imageInformation
imageFolder
imageFolderSelector
imageInformationCircle
imageEditPen
imageEditProperties
imageGotoInput
imageIizi
imageModule
imagePanel
imageVirtualSpace
imageInfo
imageWizard
imageExtends
imageAdd
imageShow
imageMore
imageMore16
imageProperties
imageExpandAll
imageCollapseAll
imageSortA2Z
imageSortZ2A
imageSortByType
imageShowTree
imageShowInherited
imageLinkProps
imageHideValues
imageShowInEditor
imageErrorDecoration
imageWarningDecoration
imageConvert
imageRichText
imageRawText
imageTagProcessing
imageTextTable
imageTranslate
imageImport
imageOpen
imageMoveProps
imageTextOK
imageTextError
imageFormatPlain
imageFormatPlainTag
imageFormatHTML
imageFormatHTMLTag
imageInsertTextID
imageInsertTextIDDisabled
imageInsertTextVS
imageInsertTextVSDisabled
imageInsertHyperlink
imageInsertHyperlinkDisabled
imageRemoveHyperlink
imageRemoveHyperlinkDisabled
imageInsertImage
imageInsertImageDisabled
imageMoveUp
imageMoveDown
imageMoveTop
imageMoveBottom
imageUIPanelPart
imageUIDialog
imageUIAccordion
imageUIContainer
imageUIContextMenu
imageUITitlePane
imageUIMenuBar
imageUIMenu
imageUITabContainer
imageUISwapContainer
imageUILayouts
imageUIAbsoluteLayout
imageUIAccordionLayout
imageUIBorderLayout
imageUIFlexLayout
imageUIGridLayout
imageUITabLayout
imageUISwapLayout
imageSelector
imageSelectors
imageStyles
imageStateStyles
imageAsset
imageDevicePortrait
imageDeviceLandscape
imageUIComponent
imageUIComponents
imageThemes
imageThemesError
imageUIButton
imageUICalendar
imageUICheckBox
imageUIComboBox
imageUIDateTime
imageUIEmpty
imageUILabel
imageUIOutput
imageUIMenuItem
imageUICheckedMenuItem
imageUIRadioMenuItem
imageUIMenuSeparator
imageUIProgress
imageUIRadioButton
imageUIGauge
imageUISlider
imageUISpinner
imageUIText
imageUITextArea
imageUIPicker
imageUIPickerSlot
imageUITable
imageUITableColumn
imageUIChart
imageUIImage
imageUIImage2
imageUICalendarList
imageUICalendarEvent
imageUIMap
imageUIMapMarkers
imageUIMapMarker
imageMUIButton
imageMUICheckBox
imageMUIRadioButton
imageMUIList
imageMUIHeading
imageMUITabBar
imageMUIProgress
imageMUIProgressInd
imageMUISlider
imageMUISwitch
imageMUIListHeader
imageMUISimpleListItem
imageVSComponent
imageVSTable
imageVSColumn
imageVSRow
imageVSField
imageVSGroup
imageVSCell
imageVSAction
imageVSActionReference
imageAction
imageActions
imageActionReference
imageVSType
imageVSMessage
imageVSName
imageVSValue
imageVSParticipant
imageVSParticipants
imageVSState
imageVSReference
imageDescription
imageCNProperty
imageActors
imageConnectionsIn
imageConnectionsOut
imageConnectionsOneToMany
imageConnectionsManyToOne
imageClear
imageClearHover
imageExpanded
imageExpandedHover
imageExpandedWarning
imageExpandedWarningHover
imageExpandedError
imageExpandedErrorHover
imageCollapsed
imageCollapsedHover
imageCollapsedWarning
imageCollapsedWarningHover
imageCollapsedError
imageCollapsedErrorHover
imageUndefined
imageUndefinedHover
imageMissing
imageDefined
imageDefinedHover
imageDefinedWarning
imageDefinedWarningHover
imageDefinedError
imageDefinedErrorHover
imagePlus
imagePlusHover
imageMinus
imageMinusHover
imageChecked
imageUnchecked
imageText
imageTextHover
imageTextTag
imageTextTagHover
imageHTML
imageHTMLHover
imageHTMLTag
imageHTMLTagHover
imageHoverButton
imageDownButton
imageModulePackage
imageModulePackageEmpty
imageModulePackageNameError
imageImageDefinition
imageFontFaces
imageFontIconsDefinition
imageFontIconDefinition
imageFontFiles
imageFontFile
imageSingleImage
imageMultipleImages
imageStyledImage
imageImageLocation
imageImageResolution
imageImageStyle
imageSVGDefinition
imageClass
imageJavaMethodInstance
imageJavaMethodStatic
imageJavaMethodInstanceLarge
imageJavaMethodStaticLarge
imageJavaActionActor
imageNewFieldActor
imageNewActionActor
checkBoxChecked
checkBoxUnchecked
checkBoxCheckedDisabled
checkBoxUncheckedDisabled
radioButtonSelected
radioButtonUnselected
radioButtonSelectedDisabled
radioButtonUnselectedDisabled
deviceCast
deviceCastDisabled
Method Details
autoScaleDown
public static int autoScaleDown(int size) Auto-scales down for high DPI displays.- Parameters:
size
- Value to scale down.- Returns:
- The scaled value if supported, otherwise the same value.
autoScaleUp
public static int autoScaleUp(int size) Auto-scales up for high DPI displays.- Parameters:
size
- Value to scale up.- Returns:
- The scaled value if supported, otherwise the same value.
addThemeListener
Call this method to register for theme changes.- Parameters:
listener
- The listener.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
addThemeListener
Call this method to register for theme changes and automatic removal of its listener when the widget is disposed of.- Parameters:
listener
- The listener.widget
- The widget or container to listen to for dispose.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeThemeListener
Call this method to register for theme changes.- Parameters:
listener
- The listener.- Returns:
- true if the listener was removed, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
getInstance
Gets the instance of the ApplicationUI. The first time this is done, it must be from the SWT thread, otherwise an InternalError is thrown.- Returns:
- The singleton instance of the
ApplicationUI
.
isInstanceCreated
public static boolean isInstanceCreated()Checks if the ApplicationUI instance is created.- Returns:
- true if ApplicationUI is created or not.
isAutoScaled
public boolean isAutoScaled()Gets the flag not to use scaling because it's automatic.- Returns:
- true if Eclipse and SWT automatically adjust values to scale, false otherwise.
getTheme
Gets the current theme.- Returns:
- The current theme.
isDarkMode
public boolean isDarkMode()Checks if a "dark" mode is used, e.g. usingApplicationUI.Theme.DARK
. In the future, it could be other dark themes, but right now, "there can be only one"!- Returns:
- The flag, generally affecting images and/or colors.
getColor
Gets a color and adds it to be disposed of when the plug-in exits. If the color has been created previously, that one is returned. This call must be done from the SWT thread.- Parameters:
rgb
- The RGB color value between 0x000000 and 0xFFFFFF.- Returns:
- The new Color instance, or a cached one.
getColor
Gets a color and adds it to be disposed of when the plug-in exits. If the color has been created previously, that one is returned. This call must be done from the SWT thread.- Parameters:
r
- The red color 0-255.g
- The green color 0-255.b
- The blue color 0-255.- Returns:
- The new Color instance, or a cached one.
getFont
Gets a font and adds it to be disposed of when the plug-in exits. If the font has been created previously, the same font is returned. This call must be done from the SWT thread.- Parameters:
name
- The name of the font.height
- The height of the font in pixels.style
- The style of the font.- Returns:
- A new of cached font instance.
getImage
Gets an Image from a file name.- Parameters:
fileName
- The file name loads a descriptor from the "icons" folder.- Returns:
- A new or cached image of the file name.
getImage
Loads the image for an Image Descriptor and caches it. It will be disposed of when the plug-in exits.- Parameters:
descriptor
- The Image Descriptor or null if none.- Returns:
- The image created, null for none or when Image Descriptor is null.
removeImage
Removes an image and its image descriptor once loaded.- Parameters:
image
- The image to remove.- Returns:
- true if the image was removed, false otherwise.
getDecoratedImage
Creates or gets a (perhaps) decorated image for warning/errors. Error level is the same as IMarker.SEVERITY_*.- Parameters:
image
- The image to decorate.errorLevel
- 0=no decoration, 1=warning, 2=error.- Returns:
- The (perhaps) decorated image. The image is cached in order to reuse the decoration for that image.
getImage
Gets an Image for a property.- Parameters:
property
- The property instance or null for none.- Returns:
- The Image or null for none or property instance is null.
getImage
Gets an Image for a property class.- Type Parameters:
GPROP
- The GProperty from the property class.- Parameters:
propertyClass
- The property class.- Returns:
- The Image Descriptor or null for none.
getImage
Gets the Image for a DesignerProp instance.- Parameters:
dp
- The Designer property instance.- Returns:
- The Image, or null if
dp
is null.
getErrorImage
Gets the image for the property error severity level.- Parameters:
errorItem
- An instance of an error item.- Returns:
- The cached image for the severity in question, null for no image.
getErrorImage
Gets the image for the property error level 0=INFO, 1=WARNING, 2=ERROR.- Parameters:
level
- The error level (0-2).- Returns:
- The cached image for the severity, or null if the level is not 0-2.
getErrorImageDecoration
Gets the small decoration images for the property error levels 1=WARNING, 2=ERROR.- Parameters:
level
- The error level (1-2).- Returns:
- The cached image for the severity, or null if the level is not 1-2.
getWorkBenchImage
Gets a Workbench Shared image by a name.- Parameters:
name
- The name defined in org.eclipse.ui.ISharedImages.- Returns:
- The cached image, or null if not found.
loadWorkBenchImages
Loads a set of workbench Image's from its symbolic names defined in org.eclipse.ui.ISharedImages and assigns it to the ToolItem. The "_DISABLED" image will be loaded and used if defined.- Parameters:
item
- The tool bar item.name
- The name of the image.
applyHeaderGradient
Applies a gradient on a composite in light mode, and in dark mode, just use the default widget background.- Parameters:
c
- The composite.
center
Centers the window on screen over its parent and sets the size.- Parameters:
shell
- The window shell.w
- Width of window, zero for none, negative not to scale.h
- Height of window, zero for none, negative not to scale.
center
Centers the window on screen over its parent and sets the size and image.- Parameters:
shell
- The window shell.image
- The image for the dialog relative the icon directory.w
- Width of window, zero for none, negative not to scale.h
- Height of window, zero for none, negative not to scale.
center
Centers the window on screen over its parent and sets the size. The dialog size is kept to restore next time it's opened.- Parameters:
shell
- The window shell.clazz
- The class to remember the size of the dialog for, null for none.w
- Width of window, zero for none, negative not to scale.h
- Height of window, zero for none, negative not to scale.
center
Centers the window on screen over its parent and sets the size and image. The dialog size is kept to restore next time it's opened.- Parameters:
shell
- The window shell.clazz
- The class to remember the size of the dialog for, null for none.image
- The image for the dialog relative the icon directory, null for none.w
- Width of window, zero for none, negative not to scale.h
- Height of window, zero for none, negative not to scale.
center
Centers the window on screen over its parent and sets the size and image. The dialog size is kept to restore next time it's opened.- Parameters:
shell
- The window shell.className
- The class to remember the size of the dialog for, null for none.image
- The image for the dialog relative the icon directory, null for none.w
- Width of window, zero for none, negative not to scale.h
- Height of window, zero for none, negative not to scale.
cx
public int cx(int w) Calculates the width of an element with the dialog font.- Parameters:
w
- The width in pixel for the 100% font.- Returns:
- The width to use.
cy
public int cy(int h) Calculates the height of an element with the dialog font.- Parameters:
h
- The width in pixel for the 100% font.- Returns:
- The height to use.
s2
public int s2()Gets the spacing of 2 "pixels" depending on font scaling.- Returns:
- The pixel value.
s4
public int s4()Gets the spacing of 4 "pixels" depending on font scaling.- Returns:
- The pixel value.
s5
public int s5()Gets the spacing of 5 "pixels" depending on font scaling.- Returns:
- The pixel value.
s8
public int s8()Gets the spacing of 8 "pixels" depending on font scaling.- Returns:
- The pixel value.
s10
public int s10()Gets the spacing of 5 "pixels" depending on font scaling.- Returns:
- The pixel value.
s15
public int s15()Gets the spacing of 5 "pixels" depending on font scaling.- Returns:
- The pixel value.
s20
public int s20()Gets the spacing of 5 "pixels" depending on font scaling.- Returns:
- The pixel value.
cyProperty
public int cyProperty()Gets the height of each item for properties.- Returns:
- The default height is 16.
getNormalFont
Gets the default dialog normal font.- Returns:
- The normal font.
getHeadingFont
Gets a heading font.- Returns:
- The font.
getBoldFont
Gets a bold font for a standard component.- Returns:
- The font.
getItalicFont
Gets an italic font for a standard component.- Returns:
- The font.
getFixedFont
Gets the standard fixed font.- Returns:
- The font.
loadWorkBenchImages
Loads a set of workbench Image's from its symbolic names defined in org.eclipse.ui.ISharedImages and assigns it to the ToolItem.- Parameters:
item
- The tool bar item.nameEnabled
- The name of the enabled image.nameDisabled
- The name of the disabled image.
getNewImageDescriptor
Creates a "New item" image descriptor from an existing image.- Parameters:
image
- The image.- Returns:
- The cached image descriptor with a "new item decorator" on the top-right corner.
getNewImage
Creates a "New item" image from an existing image.- Parameters:
image
- The image.- Returns:
- A cached image with a "new item decorator" on the top-right corner.
getWizardImage
Creates a "wizard" image from an existing image.- Parameters:
image
- The image.- Returns:
- A cached image with the overlay of a new-wizard.