Class TangoSynopticHandler

All Implemented Interfaces:
fr.esrf.tangoatk.core.IAttributeStateListener, fr.esrf.tangoatk.core.IBooleanScalarListener, fr.esrf.tangoatk.core.IDevStateScalarListener, fr.esrf.tangoatk.core.IDevStateSpectrumListener, fr.esrf.tangoatk.core.IEnumScalarListener, fr.esrf.tangoatk.core.IErrorListener, fr.esrf.tangoatk.core.INumberScalarListener, fr.esrf.tangoatk.core.IStateListener, fr.esrf.tangoatk.core.IStatusListener, DropTargetListener, ActionListener, ComponentListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
SynopticFileViewer

public class TangoSynopticHandler extends JDrawEditor implements fr.esrf.tangoatk.core.IStateListener, fr.esrf.tangoatk.core.IStatusListener, fr.esrf.tangoatk.core.INumberScalarListener, fr.esrf.tangoatk.core.IEnumScalarListener, fr.esrf.tangoatk.core.IDevStateScalarListener, fr.esrf.tangoatk.core.IBooleanScalarListener, fr.esrf.tangoatk.core.IDevStateSpectrumListener, WindowListener
TangoSynopticHandler is the base class used to display and animate any tango synoptic drawing made with the JDraw drawing tool "JDraw". The drawing file is browsed and a behaviour is attached to each drawing component according to the tango object which is associated with. While brawsing the drawing file the name of the graphical component determines the associated tango object: For example if inside the synoptic drawing a simple rectangle is given the name "eas/test-api/1" it will be associated to the tango device eas/test-api/1. The animation on the graphical component depends on the type of the Tango object (device, attribute, command) and the type of JDraw graphical component (simple graphical component, multi-state JDraw object, interactive JDraw object) Here are the default (state) animations provided :
  • Tango device or Tango state attribute - simple graphical component : the colour of the graphical component represents the state of the tango device (on, off, alarm, fault...)
  • Tango device or Tango state attribute - Dynamic JDraw object (Dyno) : the Dyno is a group of JDobject where each of them represents the drawing which should be visible for one or more tango state. This way to each state (on, off, alarm, fault, ...) is associated a different form.
  • Tango device command - interactive JDraw object : no state animation
  • Tool Tip : A tooltip can be associated to any tango device. The tooltip can display either the name of the device or it's state according to the tooltip mode used.

In addition to the animation a default interaction behaviour is provided (reaction to mouse clicks). Here are the default interactions :

  • Tango device or Tango state attribute - simple graphical component : Click on the graphical component will launch a java class whose name has been specified during the drawing phase. If this class name is missing, the generic tool atkpanel is launched. If the class name is set to the predefined string "noPanel" the atkpanel is not launched.
  • Tango device - multi-state JDraw object : the same interaction model
  • Tango device command - interactive JDraw object : Click on the JDraw object will display an "input / output argument window" if the input is required or execute the associated command on the tango device if no input is required.
There are 4 extensions parsed by default :
  • className: If the Jdraw component is asscoiated to a Tango device or to a Tango state attribute this extension (className) represents the name of the java class to instantiate when the Jdraw object is clicked. This allows to give the name of the panel to be launched when the object is clicked. If the className is not specified the default panel (atkpanel read-only) is launched. If the className is set to "noPanel" nothing is launched.
  • classParam: first argument (always a string) to be passed to the java panel. If classParam is not specified the name associated to the JD component (device name or state attribute name is passed as the String argument to the constructor.
  • valueList: used by NumberScalarComboEditor and StringScalarComboEditor swing objects to acquire the values list
  • shellCommand(*):It allows to launch any shell command or application (dir, xterm, jive, firefox, etc ...) from the synoptic. If a JDObject is interactive and has the shellCommand extension its content will be executed at each valueExceedBounds event The command is always executed in background. Streams redirection is not allowed (should be done inside an script). Arguments can be passed to the shell command.
  • qualityFactor: If the Jdraw component is asscoiated to a NumberScalarAttribute and if this extension (qualityFactor) is set to "true" then the qualityFactor of the attribute will be used to change the background color.
Since:
ATKWidget-1.9.7
Author:
Faranguiss PONCET
See Also:
  • Field Details

    • TOOL_TIP_NONE

      public static final int TOOL_TIP_NONE
      Does not display tooltip
      See Also:
    • TOOL_TIP_STATE

      public static final int TOOL_TIP_STATE
      Displays device state within tooltip only for Device objects
      See Also:
    • TOOL_TIP_STATUS

      public static final int TOOL_TIP_STATUS
      Displays device status within tooltip only for Device objects
      See Also:
    • TOOL_TIP_NAME

      public static final int TOOL_TIP_NAME
      Displays the attribute name within tooltip
      See Also:
    • jdrawFileFullName

      protected String jdrawFileFullName
    • allAttributes

      protected fr.esrf.tangoatk.core.AttributeList allAttributes
    • jdHash

      protected Map<String,List<JDObject>> jdHash
    • stateCashHash

      protected Map<String,List<String>> stateCashHash
    • metaNames

      protected Vector<String> metaNames
  • Constructor Details

  • Method Details

    • setProgressListener

      public void setProgressListener(SynopticProgressListener p)
      Sets the loading progress listener
      Parameters:
      p - Handle to the progress listener
    • getToolTipMode

      public int getToolTipMode()
      Returns:
      the current Tooltip Mode
      See Also:
    • setToolTipMode

      public void setToolTipMode(int ttMode)
      Sets the current tooltip mode (device object only)
      Parameters:
      ttMode - Tooltip mode
      See Also:
    • getErrorHistoryWindow

      public ErrorHistory getErrorHistoryWindow()
      Returns:
      the current error history window
      See Also:
    • setErrorHistoryWindow

      public void setErrorHistoryWindow(ErrorHistory errh)
      Sets the current error history window. Note that the error history window should be set before the jdraw file is parsed (before the call to the setSynopticFileName)
      Parameters:
      errh - ErrorHistory window which will receive errors.
    • getSynopticFileName

      public String getSynopticFileName()
      Returns:
      the current synoptic filename.
      See Also:
    • addMetaName

      public void addMetaName(String metaName, String realName)
      Add a meta name. All JDObject name which contains the meta name will be replaced by real name before initialising Tango entities.
      Parameters:
      metaName - Original string
      realName - String which will appear after loading the synoptic
    • getAttributeList

      public fr.esrf.tangoatk.core.AttributeList getAttributeList()
      Returns:
      a Handle to the global attribute list which is used internaly to monitor attributes. This list is filled after setSynopticFileName() is called. To add an error listener to this list, you have to register it before loading a synoptic.
      See Also:
    • loadSynopticFromStream

      public void loadSynopticFromStream(InputStreamReader inp) throws IOException, MissingResourceException
      Load a jdraw grpahics input stream into the drawing area.The JLoox and Loox files formats are not supported. This method allows to load a synoptic which is not necessarily a file on disk. This method is particularly used when the synoptic jdraw file is pakaged into the application jarfile and cannot be accessed as a separate file on the disk.
      Parameters:
      inp - An InputStreamReader should be created by the application and passed to this method
      Throws:
      IOException - Exception when the inputStream cannot be accessed.
      MissingResourceException - when the "jdraw" inputStream cannot be parsed.
    • setSynopticFileName

      public void setSynopticFileName(String jdFileName) throws MissingResourceException, FileNotFoundException, IllegalArgumentException
      Reads the Jdraw file, browses and parses the synoptic components. The main purpose of this function is to attach Tango entity model to JDraw component.
      Parameters:
      jdFileName - Filename of the JDraw (jdw) synptic to load.
      Throws:
      FileNotFoundException - Exception when the input file cannot be accessed.
      MissingResourceException - when the "jdraw" inputStream cannot be parsed.
      IllegalArgumentException - Illegal argument
    • clearAllPanels

      public void clearAllPanels()
    • clearSynopticFileModel

      public void clearSynopticFileModel()
    • parseJdrawComponents

      protected void parseJdrawComponents()
      Parses JDraw components , detects tango entity name and attatch a model. This method does not recurse group and use isDevice() , isAttribute() and isDevice() to detect entity name.
      See Also:
    • isAttribute

      protected boolean isAttribute(String s)
      Parameters:
      s - Attribute name
      Returns:
      true only if the given name matches a Tango attribute name. Attribute name allowed syntax ( Can be preceded by tango: ):
         Full syntax: //hostName:portNumber/domain/family/member/attName
         Full syntax: //ipAddress:portNumber/domain/family/member/attName
         Short syntax: domain/family/member/attName
       
    • isSpectrumAttElement

      protected boolean isSpectrumAttElement(String s)
      Parameters:
      s - Spectrum Attribute element
      Returns:
      true only if the given name matches a Tango attribute name followed by [index]. Spectrum Attribute element allowed syntax ( Can be preceded by tango: ):
         Full syntax: //hostName:portNumber/domain/family/member/attName[xx]
         Full syntax: //ipAddress:portNumber/domain/family/member/attName[xx]
         Short syntax: domain/family/member/attName[xx]
       
    • isCommand

      protected boolean isCommand(String s)
      Parameters:
      s - Command name
      Returns:
      true only if the given name matches a Tango command name. Command name allowed syntax ( Can be preceded by tango: ):
         Full syntax: //hostName:portNumber/domain/family/member/cmdName
         Full syntax: //ipAddress:portNumber/domain/family/member/cmdName
         Short syntax: domain/family/member/cmdName
       
    • isDevice

      protected boolean isDevice(String devName)
      Parameters:
      devName - Device name
      Returns:
      true only if the given name matches a Tango device name. Device name allowed syntax ( Can be preceded by tango: ):
         Full syntax: //hostName:portNumber/domain/family/member
         Full syntax: //ipAddress:portNumber/domain/family/member
         Short syntax: domain/family/member
       
    • windowClosed

      public void windowClosed(WindowEvent e)
      Specified by:
      windowClosed in interface WindowListener
    • windowOpened

      public void windowOpened(WindowEvent e)
      Specified by:
      windowOpened in interface WindowListener
    • windowClosing

      public void windowClosing(WindowEvent e)
      Specified by:
      windowClosing in interface WindowListener
    • windowIconified

      public void windowIconified(WindowEvent e)
      Specified by:
      windowIconified in interface WindowListener
    • windowDeiconified

      public void windowDeiconified(WindowEvent e)
      Specified by:
      windowDeiconified in interface WindowListener
    • windowActivated

      public void windowActivated(WindowEvent e)
      Specified by:
      windowActivated in interface WindowListener
    • windowDeactivated

      public void windowDeactivated(WindowEvent e)
      Specified by:
      windowDeactivated in interface WindowListener
    • addAttribute

      protected void addAttribute(JDObject jddg, String s)
    • numberScalarChange

      public void numberScalarChange(fr.esrf.tangoatk.core.NumberScalarEvent evt)
      Specified by:
      numberScalarChange in interface fr.esrf.tangoatk.core.INumberScalarListener
    • enumScalarChange

      public void enumScalarChange(fr.esrf.tangoatk.core.EnumScalarEvent evt)
      Specified by:
      enumScalarChange in interface fr.esrf.tangoatk.core.IEnumScalarListener
    • booleanScalarChange

      public void booleanScalarChange(fr.esrf.tangoatk.core.BooleanScalarEvent evt)
      Specified by:
      booleanScalarChange in interface fr.esrf.tangoatk.core.IBooleanScalarListener
    • devStateSpectrumChange

      public void devStateSpectrumChange(fr.esrf.tangoatk.core.DevStateSpectrumEvent evt)
      Specified by:
      devStateSpectrumChange in interface fr.esrf.tangoatk.core.IDevStateSpectrumListener
    • stateChange

      public void stateChange(fr.esrf.tangoatk.core.AttributeStateEvent evt)
      change the color of the jdobj (bg or fg) according to the quality factor of the attribute If and Only If the JDobject is not a JDBar, or JDSlider and no color mapper is set for the JDobject and the "extension" QualityFactor is true
      Specified by:
      stateChange in interface fr.esrf.tangoatk.core.IAttributeStateListener
      Parameters:
      evt - AttributeState event
    • errorChange

      public void errorChange(fr.esrf.tangoatk.core.ErrorEvent event)
      Specified by:
      errorChange in interface fr.esrf.tangoatk.core.IErrorListener
    • refreshDisabled

      public void refreshDisabled(Color disabledColor)
      Update background color of disabled objects, it restore the state color if the JDObject is no longer disabled.
      Parameters:
      disabledColor - Disabled color
    • devStateScalarChange

      public void devStateScalarChange(fr.esrf.tangoatk.core.DevStateScalarEvent event)
      Specified by:
      devStateScalarChange in interface fr.esrf.tangoatk.core.IDevStateScalarListener
    • stateChange

      public void stateChange(fr.esrf.tangoatk.core.StateEvent event)
      Specified by:
      stateChange in interface fr.esrf.tangoatk.core.IStateListener
    • statusChange

      public void statusChange(fr.esrf.tangoatk.core.StatusEvent event)
      Specified by:
      statusChange in interface fr.esrf.tangoatk.core.IStatusListener
    • main

      public static void main(String[] args)