T
- the "Modify" Link control used to upload a new image picture.public abstract class AbstractPictureControl<T extends org.eclipse.swt.widgets.Control>
extends org.eclipse.swt.widgets.Composite
implements java.beans.PropertyChangeListener
Label
, SWT
Composite
and Link according if you use only SWT (see
PictureControl
) or SWT Form Toolkit (see FormPictureControl
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BUNDLE_NAME
Bundle name constant
|
static java.lang.String |
IMAGE_BYTEARRAY_PROPERTY |
protected java.util.ResourceBundle |
resources
Resources bundle
|
Modifier | Constructor and Description |
---|---|
|
AbstractPictureControl(org.eclipse.swt.widgets.Composite parent)
Constructor for
AbstractPictureControl with default SWT styles. |
|
AbstractPictureControl(org.eclipse.swt.widgets.Composite parent,
int compositeStyle,
int labelStyle,
int linkStyle)
Constructor for
AbstractPictureControl with given SWT style . |
protected |
AbstractPictureControl(org.eclipse.swt.widgets.Composite parent,
int compositeStyle,
int labelStyle,
int linkStyle,
boolean createUI)
Constructor for
AbstractPictureControl with given SWT styles. |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addDeleteImageHandler(T deleteImageLink)
Add the handler to delete the image to the Link control.
|
protected abstract void |
addModifyImageHandler(T modifyImageLink)
Add the handler to open Explorer files to the Link control.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
protected void |
configure(org.eclipse.swt.widgets.FileDialog fd)
Configure the
FileDialog to set the file extension, the text,
etc. |
protected abstract org.eclipse.swt.widgets.Composite |
createComposite(org.eclipse.swt.widgets.Composite parent,
int style)
Create a SWT
Composite . |
protected abstract org.eclipse.swt.widgets.Label |
createLabel(org.eclipse.swt.widgets.Composite parent,
int style)
Create a SWT
Label . |
protected org.eclipse.swt.widgets.Label |
createLabelImage(org.eclipse.swt.widgets.Composite parent,
int style)
Create the SWT
Label to host the image picture. |
protected abstract T |
createLink(org.eclipse.swt.widgets.Composite parent,
int style)
Create a SWT control for the "Modify" Link.
|
protected org.eclipse.swt.widgets.Menu |
createMenu(org.eclipse.swt.widgets.Control parent)
Create the menu with "Delete", "Modify" Item.
|
protected org.eclipse.swt.widgets.Composite |
createUI(int labelStyle,
int linkStyle)
Create the UI picture control composed with Label (for host the image
picture)
|
void |
dispose() |
T |
getDeleteImageLink()
Returns the "Delete" Link control used to open Explorer files to change
image.
|
protected int |
getFileDialogStyle()
Returns the
FileDialog SWT style. |
byte[] |
getImageByteArray()
Returns the byte array of the image picture and null if none picture was
setted.
|
java.io.InputStream |
getImageStream()
Returns the
InputStream of the image picture and null if none
picture was setted. |
java.lang.Integer |
getMaxImageHeight()
Returns the maximum height of the image.
|
java.lang.Integer |
getMaxImageWidth()
Returns the maximum width of the image.
|
T |
getModifyImageLink()
Returns the "Modify" Link control used to open Explorer files to change
image.
|
org.eclipse.swt.widgets.Label |
getPictureLabel()
Returns the picture label which hosts the picture image.
|
protected org.eclipse.swt.graphics.ImageData |
getResizedImageData(org.eclipse.swt.graphics.ImageData imageData)
Returns the resized
ImageData . |
protected void |
handleDeleteImage()
Delete the current image picture.
|
protected void |
handleError(java.lang.Throwable e)
Handle error when file selected cannot be loaded as Image.
|
protected void |
handleModifyImage()
Open the Explorer File to select a new image.
|
void |
propertyChange(java.beans.PropertyChangeEvent arg0) |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
setDefaultImage(org.eclipse.swt.graphics.Image defaultImage)
Set the default image for the picture.
|
void |
setDeleteImageLinkText(java.lang.String text)
Set the text of the "Modify" Link.
|
void |
setFilterExtensions(java.lang.String[] extensions)
Set the file extensions which the dialog will use to filter the files it
shows to the argument, which may be null.
|
void |
setImageByteArray(byte[] imageByteArray)
Set the current byte array of the image picture.
|
void |
setImageStream(java.io.InputStream stream)
Set the current
InputStream of the image picture. |
protected abstract void |
setLinkText(T link,
java.lang.String text)
Set the text of a Link control.
|
void |
setLocale(java.util.Locale locale)
Sets a new locale to use for picture controle.
|
void |
setMaxImageHeight(java.lang.Integer maxImageHeight)
Set the maximum height of the image.
|
void |
setMaxImageWidth(java.lang.Integer maxImageWidth)
Set the maximum width of the image.
|
void |
setModifyImageLinkText(java.lang.String text)
Set the text of the "Modify" Link.
|
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
public static final java.lang.String BUNDLE_NAME
public static final java.lang.String IMAGE_BYTEARRAY_PROPERTY
protected java.util.ResourceBundle resources
public AbstractPictureControl(org.eclipse.swt.widgets.Composite parent)
AbstractPictureControl
with default SWT styles.parent
- a composite control which will be the parent of the new
instance (cannot be null)public AbstractPictureControl(org.eclipse.swt.widgets.Composite parent, int compositeStyle, int labelStyle, int linkStyle)
AbstractPictureControl
with given SWT style .parent
- a composite control which will be the parent of the new
instance (cannot be null)compositeStyle
- SWT style of the SWT Composite which host Label+Link controls.labelStyle
- SWT style of the Label control.linkStyle
- SWT style of the Link control.protected AbstractPictureControl(org.eclipse.swt.widgets.Composite parent, int compositeStyle, int labelStyle, int linkStyle, boolean createUI)
AbstractPictureControl
with given SWT styles.parent
- a composite control which will be the parent of the new
instance (cannot be null)compositeStyle
- SWT style of the SWT Composite which host Label+Link controls.labelStyle
- SWT style of the Label control.linkStyle
- SWT style of the Link control.createUI
- true if UI must be created and false otherwise.protected org.eclipse.swt.widgets.Composite createUI(int labelStyle, int linkStyle)
labelStyle
- the SWT label style.linkStyle
- the link style.protected org.eclipse.swt.widgets.Label createLabelImage(org.eclipse.swt.widgets.Composite parent, int style)
Label
to host the image picture.parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructprotected org.eclipse.swt.widgets.Menu createMenu(org.eclipse.swt.widgets.Control parent)
parent
- public void setModifyImageLinkText(java.lang.String text)
text
- public void setDeleteImageLinkText(java.lang.String text)
text
- protected void handleDeleteImage()
public void setFilterExtensions(java.lang.String[] extensions)
The strings are platform specific. For example, on some platforms, an extension filter string is typically of the form "*.extension", where "*.*" matches all files. For filters with multiple extensions, use semicolon as a separator, e.g. "*.jpg;*.png".
extensions
- the file extension filterto specify the user-friendly names corresponding to
the extensions
protected void handleModifyImage()
protected void configure(org.eclipse.swt.widgets.FileDialog fd)
FileDialog
to set the file extension, the text,
etc. This method can be override to custome the configuration.fd
- protected int getFileDialogStyle()
FileDialog
SWT style. This method can be override if
the SWT style should be customized.protected void handleError(java.lang.Throwable e)
e
- public org.eclipse.swt.widgets.Label getPictureLabel()
public T getModifyImageLink()
public T getDeleteImageLink()
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void propertyChange(java.beans.PropertyChangeEvent arg0)
propertyChange
in interface java.beans.PropertyChangeListener
public void setImageStream(java.io.InputStream stream) throws java.io.IOException
InputStream
of the image picture. null is
accepted to delete the image.stream
- java.io.IOException
public java.io.InputStream getImageStream()
InputStream
of the image picture and null if none
picture was setted.public void setImageByteArray(byte[] imageByteArray)
imageByteArray
- protected org.eclipse.swt.graphics.ImageData getResizedImageData(org.eclipse.swt.graphics.ImageData imageData)
ImageData
. This method can be override if
scale logic doen't please you.imageData
- public byte[] getImageByteArray()
public void setLocale(java.util.Locale locale)
locale
- new locale (must not be null)public void setMaxImageHeight(java.lang.Integer maxImageHeight)
maxImageHeight
- public java.lang.Integer getMaxImageHeight()
maxImageHeight
- public void setMaxImageWidth(java.lang.Integer maxImageWidth)
maxImageWidth
- public java.lang.Integer getMaxImageWidth()
maxImageWidth
- public void setDefaultImage(org.eclipse.swt.graphics.Image defaultImage)
defaultImage
- public void dispose()
dispose
in class org.eclipse.swt.widgets.Widget
protected abstract org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent, int style)
Label
.parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructprotected abstract T createLink(org.eclipse.swt.widgets.Composite parent, int style)
parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructprotected abstract org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent, int style)
Composite
.parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructprotected abstract void setLinkText(T link, java.lang.String text)
modifyImageLink
- text
- protected abstract void addModifyImageHandler(T modifyImageLink)
modifyImageLink
- protected abstract void addDeleteImageHandler(T deleteImageLink)
modifyImageLink
-