org.malai.instrument
Class Link<A extends Action,I extends Interaction,N extends Instrument>

java.lang.Object
  extended by org.malai.instrument.Link<A,I,N>
Type Parameters:
A - The type of the action that will produce this link.
I - The type of the interaction that will use this link.
N - The type of the instrument that will contain this link.
All Implemented Interfaces:
InteractionHandler
Direct Known Subclasses:
Border.DnD2MoveCtrlPoint, Border.DnD2MovePoint, Border.DnD2Rotate, Border.DnD2Scale, Button2Zoom, ButtonPress2RotateShape, ButtonPress2ShowExceptionFrame, ButtonPressed2ActivateIns, ButtonPressed2AddText, ButtonPressed2DefineStylePencil, ButtonPressed2Export, ButtonPressed2Redo, ButtonPressed2Undo, ButtonPressedForCustomiser, CheckBox2MagneticGrid, CheckBoxForCustomiser, CloseFrame2SavePreferences, ColourButtonForCustomiser, DeleteShapesLink, DnD2Select, DnD2Translate, DoubleClick2InitTextSetter, DrawingPropertiesCustomiser.CheckBox2CustDrawing, DrawingPropertiesCustomiser.ComboBox2CustDrawing, DrawingPropertiesCustomiser.TextField2CustDrawing, Enter2AddText, Enter2SetText, Interaction2AbstractCopy, Interaction2IOLink, Interaction2NewLink, Interaction2PasteShapes, KeyPress2Desactivate, KeysTyped2ChangePackages, List2ChangeStyle, ListForCustomiser, MenuItem2ActivateSetterLink, MenuItem2OpenWebPageLink, MenuItem2SetUnit, MenuItem2ShowComponentLink, MenuItem2ShowHideCodeScaleRuler, MenuPressed2Export, PencilLink, Press2AddText, Press2InitTextSetter, Press2InsertPicture, Press2Select, Scroll2Zoom, Scrolling2Scroll, ShapeCoordDimCustomiser.Spinner2TranslateShape, ShapeGrouper.Button2GroupShapes, ShapeGrouper.Button2SeparateShapes, Spinner2GridSpacing, Spinner2Zoom, SpinnerForCustomiser, TabSelector.TabSelected2ActivateInstruments

public abstract class Link<A extends Action,I extends Interaction,N extends Instrument>
extends java.lang.Object
implements InteractionHandler

In the Malai interaction model, an instrument links interactions to actions. Thus, an instrument is composed of Link definitions: each Link links an interaction to an action. A Link manages the life cycle of an action following the life cycle of the interaction (started, aborted, etc.).

This file is part of Malai.
Copyright (c) 2009-2012 Arnaud BLOUIN

Malai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Malai is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

05/10/2010

Since:
0.2
Version:
0.2
Author:
Arnaud BLOUIN

Field Summary
protected  A action
          The target action.
protected  java.lang.Class<A> clazzAction
           
protected  boolean execute
          Specifies if the action must be execute or update on each evolution of the interaction.
protected  N instrument
          The instrument that contains the link.
protected  I interaction
          The source interaction.
 
Constructor Summary
Link(N ins, boolean exec, java.lang.Class<A> clazzAction, java.lang.Class<I> clazzInteraction)
          Creates a link.
 
Method Summary
 void addEventable(Eventable eventable)
          Binds the interaction of the link to a Eventable object that produces events used by the interaction.
 void clearEvents()
          Stops the interaction and clears all its events waiting for a process.
protected  void createAction()
          Initialises the action of the link.
 A getAction()
           
 N getInstrument()
           
 I getInteraction()
           
abstract  void initAction()
          After being created by method createAction, the action must be initialised by this method.
 void interactionAborts(Interaction inter)
          Happens when the interaction goes to an aborting state.
 void interactionStarts(Interaction inter)
          Happens when the interaction quits its initial state.
 void interactionStops(Interaction inter)
          Happens when the interaction goes to a terminal state.
 void interactionUpdates(Interaction inter)
          Happens when the interaction goes to standard state.
 void interimFeedback()
          Defines the interim feedback of the link.
 boolean isActivated()
           
abstract  boolean isConditionRespected()
           
 boolean isExecute()
           
 boolean isInteractionMustBeAborted()
          Sometimes the interaction of two different links can overlap themselves.
 boolean isRunnable()
          Indicates if the link can be run.
 boolean isRunning()
           
 void setActivated(boolean activated)
          Activates the link.
 void updateAction()
          Updates the current action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interaction

protected I extends Interaction interaction
The source interaction.


action

protected A extends Action action
The target action.


instrument

protected N extends Instrument instrument
The instrument that contains the link.


execute

protected boolean execute
Specifies if the action must be execute or update on each evolution of the interaction.


clazzAction

protected java.lang.Class<A extends Action> clazzAction
Constructor Detail

Link

public Link(N ins,
            boolean exec,
            java.lang.Class<A> clazzAction,
            java.lang.Class<I> clazzInteraction)
     throws java.lang.InstantiationException,
            java.lang.IllegalAccessException
Creates a link. This constructor must initialise the interaction. The link is (de-)activated if the given instrument is (de-)activated.

Parameters:
ins - The instrument that contains the link.
exec - Specifies if the action must be execute or update on each evolution of the interaction.
clazzAction - The type of the action that will be created. Used to instantiate the action by reflexivity.
clazzInteraction - The type of the interaction that will be created. Used to instantiate the interaction by reflexivity.
Throws:
java.lang.IllegalAccessException - If no free-parameter constructor is available.
java.lang.InstantiationException - If an error occurs during instantiation of the interaction/action.
java.lang.IllegalArgumentException - If the given interaction or instrument is null.
Since:
0.2
Method Detail

addEventable

public void addEventable(Eventable eventable)
Binds the interaction of the link to a Eventable object that produces events used by the interaction.

Parameters:
eventable - The eventable object that gathers event used by the interaction.
Since:
0.2

clearEvents

public void clearEvents()
Stops the interaction and clears all its events waiting for a process.

Since:
0.2

createAction

protected void createAction()
Initialises the action of the link. If the attribute 'action' is not null, nothing will be done.

Since:
0.2

initAction

public abstract void initAction()
After being created by method createAction, the action must be initialised by this method.

Since:
0.2

updateAction

public void updateAction()
Updates the current action. To override.

Since:
0.2

isConditionRespected

public abstract boolean isConditionRespected()
Returns:
True if the condition of the link is respected.

getInteraction

public I getInteraction()
Returns:
The interaction.

getAction

public A getAction()
Returns:
The action in progress or null.

isActivated

public boolean isActivated()
Returns:
True if the link is activated.

isRunnable

public boolean isRunnable()
Indicates if the link can be run. To be run, no link, of the instrument, that produces the same type of action must be running.

Returns:
True: The link can be run.

isRunning

public boolean isRunning()
Returns:
True: if the link is currently used. since 0.2

isInteractionMustBeAborted

public boolean isInteractionMustBeAborted()
Sometimes the interaction of two different links can overlap themselves. It provokes that the first interaction can stops while the second is blocked in a intermediary state. Two solutions are possible to avoid such a problem:
- the use of this function that perform some tests. If the test fails, the starting interaction is aborted and the resulting action is never created;
- the modification of one of the interactions to avoid the overlapping.

Returns:
True: if the starting interaction must be aborted so that the action is never created.
Since:
0.2

interactionAborts

public void interactionAborts(Interaction inter)
Description copied from interface: InteractionHandler
Happens when the interaction goes to an aborting state.

Specified by:
interactionAborts in interface InteractionHandler
Parameters:
inter - The concerned interaction.

interactionStarts

public void interactionStarts(Interaction inter)
                       throws MustAbortStateMachineException
Description copied from interface: InteractionHandler
Happens when the interaction quits its initial state.

Specified by:
interactionStarts in interface InteractionHandler
Parameters:
inter - The concerned interaction.
Throws:
MustAbortStateMachineException - If the interaction must be aborted.

interactionStops

public void interactionStops(Interaction inter)
Description copied from interface: InteractionHandler
Happens when the interaction goes to a terminal state.

Specified by:
interactionStops in interface InteractionHandler
Parameters:
inter - The concerned interaction.

interactionUpdates

public void interactionUpdates(Interaction inter)
Description copied from interface: InteractionHandler
Happens when the interaction goes to standard state.

Specified by:
interactionUpdates in interface InteractionHandler
Parameters:
inter - The concerned interaction.

isExecute

public boolean isExecute()
Returns:
True if the action is executed on each evolution of the interaction.

interimFeedback

public void interimFeedback()
Defines the interim feedback of the link. If overridden, the interim feedback of its instrument should be define too.


setActivated

public void setActivated(boolean activated)
Activates the link.

Parameters:
activated - True: the link is activated. Otherwise, it is desactivated.
Since:
3.0

getInstrument

public N getInstrument()
Returns:
The instrument that contains the link.
Since:
0.1