public abstract class IlvConnectInteractor extends IlvManagerViewInteractor implements IlvPermanentInteractorInterface
IlvManagerViewInteractor
. It is used
to interconnect the values handled by different objects in an interactive
way. When the user clicks on a source object (for example, a prototype
instance) and drags the mouse to a destination object, the interactor prompts
for the names of the output and input properties and connects these values by
calling the subscribe
method for the source object.
When the connect interactor is attached to a manager view, existing connections are displayed with green arrows. The user can delete a connection by double-clicking on the connecting line.
This interactor also displays the value sources contained in the group bag associated with the manager to which the view is attached. The value sources are drawn as green outlined labels in the top-left corner of the view. Value sources can be connected like any other objects by clicking in and/or dragging to these labels.
This class is abstract. It must be subclassed and its
promptValues
method must be overridden to define a GUI in which
the user can select the output and input values.
Constructor and Description |
---|
IlvConnectInteractor()
Creates a new connection interactor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attach(IlvManagerView v)
Repaints the view to display existing connections.
|
protected void |
connectionCreated(IlvGroupElement from,
IlvGroupElement to,
String fromProperty,
String toProperty)
This method is called when a new connection is created.
|
protected void |
connectionDeleted(IlvGroupElement from,
IlvGroupElement to,
String fromProperty,
String toProperty)
This method is called when a connection is deleted.
|
protected void |
detach()
Repaints the view to erase displayed connections.
|
protected void |
drawGhost(Graphics g)
Draws a ghost line between the source and the destination objects when a
connection is being established.
|
IlvGroupElement |
getElementAt(int x,
int y)
Returns the group element (or the value source) located at the position
defined by (
x , y ) in the manager view to which
this interactor is attached. |
protected void |
handleExpose(Graphics g)
Draws the existing connections and the value sources.
|
boolean |
isPermanent()
Returns
false (the default value) if the interactor is removed
from the view once the object has been created. |
protected void |
processMouseEvent(MouseEvent event)
Processes the
MOUSE_PRESSED and MOUSE_RELEASED
events to define a connection. |
protected void |
processMouseMotionEvent(MouseEvent event)
Processes the
MOUSE_DRAGGED events to define a connection. |
protected abstract String[] |
promptValues(IlvGroupElement from,
IlvGroupElement to,
boolean create)
Prompts the user for the names of the source and destination values when a
connection is created or deleted.
|
void |
refresh()
Refreshes the display of connections and value sources.
|
void |
setPermanent(boolean permanent)
Specifies whether the interactor is removed from the view once the object
has been created.
|
protected void |
showDetails(MouseEvent event,
IlvGroupElement from,
IlvGroupElement to)
Called when the mouse is moved near a connecting line.
|
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, isXORGhost, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public IlvConnectInteractor()
public final boolean isPermanent()
false
(the default value) if the interactor is removed
from the view once the object has been created.isPermanent
in interface IlvPermanentInteractorInterface
public final void setPermanent(boolean permanent)
false
.setPermanent
in interface IlvPermanentInteractorInterface
permanent
- the new mode.protected void processMouseEvent(MouseEvent event)
MOUSE_PRESSED
and MOUSE_RELEASED
events to define a connection.processMouseEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)
protected void connectionCreated(IlvGroupElement from, IlvGroupElement to, String fromProperty, String toProperty)
from
- the source of the connection.to
- the target of the connection.fromProperty
- the source property name.toProperty
- the target property name.protected void connectionDeleted(IlvGroupElement from, IlvGroupElement to, String fromProperty, String toProperty)
from
- the source of the connection.to
- the target of the connection.fromProperty
- the source property name.toProperty
- the target property name.protected void processMouseMotionEvent(MouseEvent event)
MOUSE_DRAGGED
events to define a connection.processMouseMotionEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)
protected void drawGhost(Graphics g)
drawGhost
in class IlvManagerViewInteractor
g
- The graphics context.
Its current color is already set to the view's default ghost
color, see IlvManagerView.getDefaultGhostColor()
.
Also, in XOR ghost drawing mode, the graphics context is already
set to XOR mode, with the view's default XOR color, see
IlvManagerView.getDefaultXORColor()
.IlvManagerViewInteractor.handleExpose(java.awt.Graphics)
,
IlvManagerViewInteractor.setXORGhost(boolean)
protected void handleExpose(Graphics g)
handleExpose
in class IlvManagerViewInteractor
g
- The graphics.IlvManagerViewInteractor.drawGhost(java.awt.Graphics)
,
IlvManagerViewInteractor.isXORGhost()
,
IlvManagerView.getDefaultXORColor()
protected void attach(IlvManagerView v)
attach
in class IlvManagerViewInteractor
v
- The manager view.IlvManagerViewInteractor.detach()
protected void detach()
detach
in class IlvManagerViewInteractor
IlvManagerViewInteractor.attach(ilog.views.IlvManagerView)
public void refresh()
protected abstract String[] promptValues(IlvGroupElement from, IlvGroupElement to, boolean create)
from
- the source of the connection.to
- the destination of the connection.create
- true
if a connection is being established,
false
if a connection is being deleted.String
objects: the first element is
the source value and the second element is the destination value.
If the user canceled the dialog, the method returns
null
.protected void showDetails(MouseEvent event, IlvGroupElement from, IlvGroupElement to)
The default implementation does nothing.
event
- the event that can be used to get the mouse location.from
- the source of the connection.to
- the destination of the connection.public IlvGroupElement getElementAt(int x, int y)
x
, y
) in the manager view to which
this interactor is attached.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.