jbcl.view Package
java.lang.Object +----java.awt.Component +----java.awt.Container +----javax.swing.JComponent +----com.borland.jbcl.view.BeanPanel +----com.borland.jbcl.view.FieldView +----com.borland.jbcl.control.FieldControl
Variables Constructors Properties Methods Event Listeners
Implements ItemEditSite, ItemPaintSite, SingletonModelListener, SingletonModelView, SingletonView, FocusListener, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener
The FieldView
component is a field view element for
developing new composite components. It requires a
SingletonModel
data model and a
SingletonViewManager
view manager. It provides much of the behavior of the FieldControl
component.
The alignment
property aligns the data item within
the control. The itemMargins
property specifies the size
of the margins around the data item. If the flat
property is true, the control appears as a
two-dimensional control; otherwise, it appears as a
three-dimensional control.
If the readOnly
property is false,
the data item in the field view can be edited. If editInPlace
is true, the user can edit the data item; if it
is false, the data item can be edited
programmatically only. When editing
is true,
the item is being edited. If autoEdit
is true,
the user can begin an edit session by simply typing in the
control; if autoEdit
is false, the user
must press F2, Ctrl+Enter, or double-click the control to begin
editing. The startEdit()
method begins an edit session
while endEdit()
and safeEndEdit()
methods bring
an edit session to an end.
When the selectable
property is true,
the data item can be selected. When the data item is selected,
the selected
property is true.
protected boolean postOnFocusLost
public FieldView()
Constructs a FieldView
component with the background
color set to SystemColor.window.
public int getAlignment() public void setAlignment(int align)
Stores the alignment of the item in the FieldView
,
both horizontal and vertical. To set a new value for both
horizontal and vertical alignment, separate the values with a
vertical bar (|). Acceptable values for newAlignment
are
defined in com.borland.dx.text.Alignment.
public boolean isAutoEdit() public void setAutoEdit(boolean edit)
The autoEdit
property enables or disables automatic
item editing in the field. By default, this property is true,
meaning that a user can begin to edit the data item by typing a
character on the keyboard. If set to false, the
user must press F2, press Ctrl+Enter, or double-click, to start
an edit session.
public boolean isDataToolTip() public void setDataToolTip(boolean dataTip)The
dataToolTip
property enables/disables the automatic tooltip mechanism to display the contents of the model (as text) in a tooltip window when the mouse is floating over the field. By default, this property is false. If dataToolTip
is set to true, the text stored in the toolTipText
property is discarded.
public Point getEditClickPoint()
The editClickPoint
property stores the point where
the user clicked to initiate the edit session for this field.
This is used to determine where to place the text cursor in the
text field.
public boolean isEditing()
The editing
property (read-only) returns true
if an item is currently being edited in the field.
public boolean isEditInPlace() public void setEditInPlace(boolean editInPlace)
The editInPlace
property enables or disables item
editing in the field. By default, this property is true,
meaning that a user can edit the value. If set to false,
the field data cannot by modified by the user; the data can only
be changed through programmatic access to the field's model.
public ItemEditor getEditor()Returns the item editor being used or null if the field is not being edited.
public boolean isEnabled() public void setEnabled(boolean enabled)
The enabled
property specifies the enabled state of
this component. If enabled
is true, the
component can be navigated to and can have focus. If false,
the component cannot be navigated to, cannot have focus, and may
be dimmed.
public boolean isFlat() public void setFlat(boolean flat)Determines whether the field view is painted so that it is flat (true) or has a three-dimensional appearance (false).
public boolean isGrowEditor() public void setGrowEditor(boolean growEditor)The
growEditor
property enables/disables the automatic sizing of an item's item editor. In some look and feel settings, the item editors must grow vertically to properly edit the data. By default, this property is set to true.
public Rectangle getInnerRect()Returns the rectangle of the
FieldView
component.
public Insets getItemMargins() public void setItemMargins(Insets margins)
The itemMargins
property specifies the amount of
space between the text and the edge of the field.
public SingletonModel getModel() public void setModel(SingletonModel sm)
Specifies the data model object that provides the single item
for this component. FieldView
requires a SingletonModel
data model.
If an edit is in progress when the setModel()
method
is called, the edit is ended prior to setting the data model.
public boolean isPostOnEndEdit() public void setPostOnEndEdit(boolean post)
Specifies whether a pending edit on the data provided by the SingletonModel
should be saved or discarded when the edit is ended. This can
happen, for example, when calling setModel()
when an
edit is in progress. When postOnEndEdit
is true,
changes are saved. When false, changes are
discarded. The value of postOnEndEdit
defaults to true.
public boolean isPostOnFocusLost() public void setPostOnFocusLost(boolean post)
Specifies whether a pending edit on the data should be saved
or discarded when the component loses the focus. When postOnFocusLost
is true, changes are saved. When it is false,
changes are discarded. The default value is true.
public int getPreferredHeight() public void setPreferredHeight(int preferredHeight)
The preferredHeight
property specifies the vertical
size that you would prefer layout managers to use for this field.
public Dimension getPreferredSize()
The preferredSize
property specifies the size that
you would prefer layout managers to use for this field.
public int getPreferredWidth() public void setPreferredWidth(int preferredWidth)
The preferredWidth
property specifies the horizontal
size that you would prefer layout managers to use for this field.
public boolean isReadOnly() public void setReadOnly(boolean ro)
Specifies whether the FieldView
can be edited. The readOnly
property returns false only if the component
user sets it to false and a WritableSingletonModel
is being used. Otherwise, isReadOnly ()
returns true
regardless of how it has been set and the writable data model for
this component is set to null.
public boolean isSelectable() public void setSelectable(boolean select)
Specifies whether the FieldView
is selectable (true)
or not (false). If setSelectable()
is
successful, the FieldView
is repainted.
public boolean isSelected() public void setSelected(boolean selected)
Specifies the selected state of the FieldView
. The isSelected()
method returns true if selected, or false
if not. If setSelected()
is successful, it repaints the FieldView
.
public boolean isShowFocus() public void setShowFocus(boolean visible)
The showFocus
property enables or disables the
painting of the focus rectangle on the field. Specifically, the showFocus
property turns on or off the FOCUSED bit in the state information
that is passed to the ItemPainter
when the field is
painted. If an ItemPainter
ignores the FOCUSED bit, this
property will have no effect. By default, showFocus
is true.
public boolean isShowRollover() public void setShowRollover(boolean showRollover)
The showRollover
property enables/disables the
repainting of the rollover state. Rollover occurs when the mouse
is floating over the control. If an ItemPainter plugged into the
field ignores the ROLLOVER bit, this property has no effect. By
default, showRollover
is false.
public Component getSiteComponent()
Returns this FieldView
component.
public Graphics getSiteGraphics()
Returns a correctly assembled Graphics
object for coordinate comparisons with item painter coordinate calculations.
public boolean isTransparent()Determines whether the view is painted so that other objects behind it can be seen. If
transparent
is true, the the field view is painted as if it
is transparent; otherwise, it is opaque.
public SingletonViewManager getViewManager() public void setViewManager(SingletonViewManager viewManager)
Specifies the Singleton data model view manager object that handles viewer and editor selection for this component.
public WritableSingletonModel getWriteModel()
The writeModel
property returns the writable data
model for the FieldView
component. For the FieldView
,
the writable data model is the WritableSingletonModel
.
This method returns null if the readOnly
property is true.
This is a read-only property.
protected SingletonModel createDefaultModel()
protected SingletonViewManager createDefaultViewManager()
public JToolTip createToolTip()Creates a tool tip for the field.
Overrides: javax.swing.JComponent.createToolTip()
public void doLayout()Forces the field to update the layout of its contained data item.
Overrides: java.awt.Container.doLayout()
public void endEdit()
Ends the edit of the FieldView
component. If changes
have been made, endEdit()
informs the editor to post the
changes.
public void endEdit(boolean post)
Stops the edit session. If the post
parameter is true,
any changes that have been made during the edit session are
saved. If post
is false, the changes
are discarded.
protected void fireCustomizeItemEvent(Object data, int state, CustomPaintSite cps)A protected method that is called when the customized event is fired.
Parameters:
data
state
cps
CustomPaintSite
that allows the listener to set the background, foreground, font, alignment, and itemMargins for the particular item being painted (or edited).
protected ItemEditor getEditor(Object data)Returns an appropriate item editor for the data specified with the
data
parameter.protected Rectangle getEditorRect()Returns the rectangle that defines the location of the item editor.
protected ItemPainter getPainter(Object data)
Returns an appropriate item painter for the type of data in the field. See jbcl.model.SingletonViewManager.getPainter(java.lang.Object, int).
Parameters:
contents
protected Dimension getPreferredInnerSize(Object data)
public Point getToolTipLocation(MouseEvent e)Returns the location of the tool tip window.
Overrides: javax.swing.JComponent.getToolTipLocation(java.awt.event.MouseEvent)
public void paintComponent(Graphics g)Paints or repaints the
FieldView
component.
Parameters:
g
Graphics
object used for painting.
Overrides: com.borland.jbcl.view.BeanPanel.paintComponent(java.awt.Graphics)
protected String paramString()
A protected method that returns the parameter string of the FieldView
component. The parameter string represents comma-separated values
of this component's container properties such as selectable and
focus states.
Overrides: java.awt.Container.paramString()
protected void processFocusEvent(FocusEvent e)
A protected method that is called when a focus event occurs.
This method repaints the FieldView
with the appropriate
focus state when focus is gained or lost.
Parameters:
e
Overrides: com.borland.jbcl.view.BeanPanel.processFocusEvent(FocusEvent)
protected void processKeyPressed(KeyEvent e)
For Ctrl+Enter or F2, starts the edit session.
Parameters:
e
Overrides: com.borland.jbcl.view.BeanPanel.processKeyPressed(KeyEvent)
protected void processKeyTyped(KeyEvent e)
Parameters:
e
Overrides: com.borland.jbcl.view.BeanPanel.processKeyTyped(KeyEvent)
protected void processMouseEntered(MouseEvent e)
Overrides: com.borland.jbcl.view.BeanPanel.processMouseEntered(java.awt.event.MouseEvent)
protected void processMouseExited(MouseEvent e)
Overrides: com.borland.jbcl.view.BeanPanel.processMouseExited(java.awt.event.MouseEvent)
protected void processMousePressed(MouseEvent e)
Parameters:
e
Overrides: com.borland.jbcl.view.BeanPanel.processMousePressed(MouseEvent)
protected void resyncEditor()
public void safeEndEdit()
Calls endEdit()
to end an edit session. If the postOnEndEdit
property is true, changes are saved; otherwise,
changes are discarded. If the call to endEdit()
fails, endEdit()
throws an exception. safeEndEdit()
catches the
exception. If the editor is an instance of ExceptionHandler
,
the editor's handleException()
method is called.
Otherwise, if the model is an instance of ExceptionHandler
,
the model's handleException()
method is called.
public void startEdit()
Starts an edit session in the field, unless the editInPlace
property value is false.
public void update(Graphics g)
Calls the paint()
method.
Parameters:
g
Overrides: java.awt.Component.update(java.awt.Graphics)
public void updateUI()Repaints the
FieldView
.
Overrides: javax.swing.JComponent.updateUI()
public synchronized void addActionListener(ActionListener l) public synchronized void removeActionListener(ActionListener l)
public void addAncestorListener(javax.swing.event.AncestorListener ) public void removeAncestorListener(javax.swing.event.AncestorListener )
public synchronized void addComponentListener(java.awt.event.ComponentListener ) public synchronized void removeComponentListener(java.awt.event.ComponentListener )
public synchronized void addContainerListener(java.awt.event.ContainerListener ) public synchronized void removeContainerListener(java.awt.event.ContainerListener )
public synchronized void addCustomItemListener(CustomItemListener l) public synchronized void removeCustomItemListener(CustomItemListener l)
public synchronized void addFocusListener(java.awt.event.FocusListener ) public synchronized void removeFocusListener(java.awt.event.FocusListener )
public synchronized void addInputMethodListener(java.awt.event.InputMethodListener ) public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )
public void addKeyListener(KeyListener l) public void removeKeyListener(KeyListener l)
public void addModelListener(SingletonModelListener l) public void removeModelListener(SingletonModelListener l)
public synchronized void addMouseListener(java.awt.event.MouseListener ) public synchronized void removeMouseListener(java.awt.event.MouseListener )
public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener ) public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener ) public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )