psdi.webclient.applet.wfcanvas.diagram.editable

Class EditableDiagram

  • All Implemented Interfaces:
    java.awt.dnd.Autoscroll, java.awt.dnd.DropTargetListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, DnDContainer, WorkflowEditListener


    public class EditableDiagram
    extends Diagram
    implements WorkflowEditListener, java.awt.dnd.Autoscroll, java.awt.dnd.DropTargetListener, java.lang.Runnable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, DnDContainer

    This class displays allows editing of a workflow diagram via an associated workflow editor

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor and Description
      EditableDiagram(psdi.webclient.applet.wfcanvas.Workflow workflow, WorkflowEditor editor, WorkflowApplet applet, boolean canEdit)
      Constructs the ditable diagram for a workflow using the editor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void autoscroll(java.awt.Point p)
      Autoscroll the tree.
      void buildDiagram()
      Builds the diagram based on the current workflow and configuration.
      void clearCursor()
      Clears the container's cursor - this is necessary for the re-written DnD which doesn't use the system handler
      protected void connectNodes(psdi.webclient.applet.wfcanvas.WorkflowNode fromNode, psdi.webclient.applet.wfcanvas.WorkflowNode toNode, boolean negative)
      Connects two nodes in the diagram
      protected DiagramWorkflowNode createDiagramNode(psdi.webclient.applet.wfcanvas.WorkflowNode node, DiagramConfiguration configuration)
      Creates a workflow node
      void dragEnter(java.awt.dnd.DropTargetDragEvent event)
      Called when drag enters the drop target
      void dragExit(java.awt.dnd.DropTargetEvent event)
      Called when drag leaves the drop target
      void dragOver(java.awt.dnd.DropTargetDragEvent event)
      Called when drag occurs
      protected void drawConnectorLine(java.awt.Point dragPoint)
      Draws the line between the starting connector and the passed point
      void drop(java.awt.dnd.DropTargetDropEvent event)
      Called when a drop occurs
      void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
      Called when the drop action changes
      void dropComplete(psdi.webclient.applet.wfcanvas.WorkflowNode sourceNode, psdi.webclient.applet.wfcanvas.WorkflowNode dropNode)
      Called when one node is dropped over another
      java.awt.Insets getAutoscrollInsets()
      Returns the insets used by the drag/drop autoscrolling
      java.awt.Cursor getCursor(java.lang.String name)
      Gets a cursor for the diagram
      int getMode()
      Gets the diagram mode
      java.awt.Cursor getModeCursor()
      Gets the cursor for the current mode
      java.awt.Dimension getPreferredSize()
      Returns the preferred size - this is the diagram size + extra for adding/dragging nodes beyond the last nodes
      java.awt.datatransfer.Transferable getProxy(DiagramWorkflowNode node)
      Constructs the correct proxy for dragging
      protected psdi.webclient.applet.wfcanvas.WorkflowRelationship getRelationshipFromPoint(java.awt.Point p)
      Gets the relationship whose line crosses the point
      java.lang.String getToolTip(java.lang.String name)
      Gets a tooltip for the diagram
      boolean isDragOk(java.awt.dnd.DropTargetDragEvent event)
      Checks whether the row is a valid drop site.
      boolean isDropSupported()
      Returns whether a node can be dropped on another in the container
      void mouseClicked(java.awt.event.MouseEvent e)
      Called when the mouse has been pressed and released Locate the rectangle within which the mouse is clicked and fire the action.
      void mouseDragged(java.awt.event.MouseEvent e)
      Called when the mouse is being dragged
      void mouseEntered(java.awt.event.MouseEvent e)
      Called when the mouse has entered the component
      void mouseExited(java.awt.event.MouseEvent e)
      Called when the mouse leaves the component
      void mouseMoved(java.awt.event.MouseEvent e)
      Called when the mouse has moved
      void mousePressed(java.awt.event.MouseEvent e)
      Called when the mouse is pressed.
      void mouseReleased(java.awt.event.MouseEvent e)
      Called when the mouse is released.
      protected void paintComponent(java.awt.Graphics g)
      Paints the components
      void run()
      Run method - used to delay listener firing
      void setCursor(java.lang.String name, java.awt.Cursor cursor)
      Sets a cursor for the diagram
      void setMode(int mode)
      Sets the diagram mode
      void setScrollPane(javax.swing.JScrollPane scrollPane) 
      void setSelection(psdi.webclient.applet.wfcanvas.WorkflowEntity selection, javax.swing.JScrollPane scrollPane)
      Sets the current selection for the diagram.
      void setToolTip(java.lang.String name, java.lang.String text)
      Sets a tooltip for the diagram
      void setWorkflow(psdi.webclient.applet.wfcanvas.Workflow workflow)
      Sets a new workflow
      void setWorkflow(psdi.webclient.applet.wfcanvas.Workflow workflow, WorkflowEditor editor, boolean canEdit) 
      void workflowChanged(WorkflowEditEvent e)
      Called when the editor state changes
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • dropTarget

        protected java.awt.dnd.DropTarget dropTarget
      • dropAction

        protected int dropAction
      • dropLocation

        protected java.awt.Point dropLocation
      • dragStart

        protected java.awt.Point dragStart
      • scrollPane

        protected javax.swing.JScrollPane scrollPane
      • editable

        protected boolean editable
      • mode

        protected int mode
        The diagram mode which is normal, draw line or draw negative line
      • cursors

        protected java.util.Hashtable cursors
        The table of cursors for nodes , lines etc
      • tooltips

        protected java.util.Hashtable tooltips
        table of tooltips for nodes , lines etc
      • ITEM_DRAW_NEGATIVE_LINE

        public static final java.lang.String ITEM_DRAW_NEGATIVE_LINE
        See Also:
        Constant Field Values
      • MODE_DRAW_NEGATIVE_LINE

        public static final int MODE_DRAW_NEGATIVE_LINE
        See Also:
        Constant Field Values
    • Constructor Detail

      • EditableDiagram

        public EditableDiagram(psdi.webclient.applet.wfcanvas.Workflow workflow,
                               WorkflowEditor editor,
                               WorkflowApplet applet,
                               boolean canEdit)
        Constructs the ditable diagram for a workflow using the editor
        Parameters:
        workflow - The workflow to edit
        editor - The editor to handle the operations
    • Method Detail

      • setWorkflow

        public void setWorkflow(psdi.webclient.applet.wfcanvas.Workflow workflow)
        Sets a new workflow
        Overrides:
        setWorkflow in class Diagram
        Parameters:
        workflow - The workflow to display
        editor - The workflow editor
      • setWorkflow

        public void setWorkflow(psdi.webclient.applet.wfcanvas.Workflow workflow,
                                WorkflowEditor editor,
                                boolean canEdit)
      • buildDiagram

        public void buildDiagram()
        Builds the diagram based on the current workflow and configuration.
        Overrides:
        buildDiagram in class Diagram
      • setMode

        public void setMode(int mode)
        Sets the diagram mode
        Parameters:
        mode - The mode
      • getMode

        public int getMode()
        Gets the diagram mode
        Returns:
        The mode
      • getModeCursor

        public java.awt.Cursor getModeCursor()
        Gets the cursor for the current mode
        Returns:
        The cursor
      • setCursor

        public void setCursor(java.lang.String name,
                              java.awt.Cursor cursor)
                       throws java.lang.Exception
        Sets a cursor for the diagram
        Parameters:
        name - The item name
        cursor - The cursor
        Throws:
        java.lang.Exception
      • getCursor

        public java.awt.Cursor getCursor(java.lang.String name)
        Gets a cursor for the diagram
        Parameters:
        name - The item name
      • setToolTip

        public void setToolTip(java.lang.String name,
                               java.lang.String text)
                        throws java.lang.Exception
        Sets a tooltip for the diagram
        Parameters:
        name - The item name
        text - The tooltip
        Throws:
        java.lang.Exception
      • setScrollPane

        public void setScrollPane(javax.swing.JScrollPane scrollPane)
      • setSelection

        public void setSelection(psdi.webclient.applet.wfcanvas.WorkflowEntity selection,
                                 javax.swing.JScrollPane scrollPane)
        Sets the current selection for the diagram.
        Parameters:
        selection - The new selection
      • getToolTip

        public java.lang.String getToolTip(java.lang.String name)
        Gets a tooltip for the diagram
        Parameters:
        name - The item name
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Returns the preferred size - this is the diagram size + extra for adding/dragging nodes beyond the last nodes
        Overrides:
        getPreferredSize in class Diagram
        Returns:
        The preferred size
      • isDragOk

        public boolean isDragOk(java.awt.dnd.DropTargetDragEvent event)
        Checks whether the row is a valid drop site. The action must be copy/move and one of the acceptable data transfer flavors must be present
        Parameters:
        event - The drop target drag event
      • getRelationshipFromPoint

        protected psdi.webclient.applet.wfcanvas.WorkflowRelationship getRelationshipFromPoint(java.awt.Point p)
        Gets the relationship whose line crosses the point
        Parameters:
        p - The point
        Returns:
        The relationship or null if not one
      • connectNodes

        protected void connectNodes(psdi.webclient.applet.wfcanvas.WorkflowNode fromNode,
                                    psdi.webclient.applet.wfcanvas.WorkflowNode toNode,
                                    boolean negative)
        Connects two nodes in the diagram
        Parameters:
        fromNode - The node to connect from
        toNode - The node to connect to
        negative - The negative line flag
      • paintComponent

        protected void paintComponent(java.awt.Graphics g)
        Paints the components
        Overrides:
        paintComponent in class Diagram
        Parameters:
        g - The graphics context
      • dragEnter

        public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
        Called when drag enters the drop target
        Specified by:
        dragEnter in interface java.awt.dnd.DropTargetListener
        Parameters:
        event - The drop target drag event
      • dragExit

        public void dragExit(java.awt.dnd.DropTargetEvent event)
        Called when drag leaves the drop target
        Specified by:
        dragExit in interface java.awt.dnd.DropTargetListener
        Parameters:
        event - The drop target drag event
      • dragOver

        public void dragOver(java.awt.dnd.DropTargetDragEvent event)
        Called when drag occurs
        Specified by:
        dragOver in interface java.awt.dnd.DropTargetListener
        Parameters:
        event - The drop target drag event
      • drop

        public void drop(java.awt.dnd.DropTargetDropEvent event)
        Called when a drop occurs
        Specified by:
        drop in interface java.awt.dnd.DropTargetListener
        Parameters:
        event - The drop target drop event
      • dropActionChanged

        public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
        Called when the drop action changes
        Specified by:
        dropActionChanged in interface java.awt.dnd.DropTargetListener
        Parameters:
        event - The drop target drag event
      • getAutoscrollInsets

        public java.awt.Insets getAutoscrollInsets()
        Returns the insets used by the drag/drop autoscrolling
        Specified by:
        getAutoscrollInsets in interface java.awt.dnd.Autoscroll
        Returns:
        The insets for autoscroll region
      • autoscroll

        public void autoscroll(java.awt.Point p)
        Autoscroll the tree. The point is where the cursor is
        Specified by:
        autoscroll in interface java.awt.dnd.Autoscroll
        Parameters:
        p - The cursor point
      • run

        public void run()
        Run method - used to delay listener firing
        Specified by:
        run in interface java.lang.Runnable
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent e)
        Called when the mouse has been pressed and released Locate the rectangle within which the mouse is clicked and fire the action. Do not do this if the mouse has been dragged.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseEntered

        public void mouseEntered(java.awt.event.MouseEvent e)
        Called when the mouse has entered the component
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseExited

        public void mouseExited(java.awt.event.MouseEvent e)
        Called when the mouse leaves the component
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent e)
        Called when the mouse is pressed.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent e)
        Called when the mouse is released.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • drawConnectorLine

        protected void drawConnectorLine(java.awt.Point dragPoint)
        Draws the line between the starting connector and the passed point
        Parameters:
        dragPoint - The end of the connector line
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent e)
        Called when the mouse is being dragged
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        e - The mouse event
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent e)
        Called when the mouse has moved
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        e - The mouse event
      • getProxy

        public java.awt.datatransfer.Transferable getProxy(DiagramWorkflowNode node)
        Constructs the correct proxy for dragging
        Specified by:
        getProxy in interface DnDContainer
        Parameters:
        node - The node to be dragged
        Returns:
        The transferable
      • isDropSupported

        public boolean isDropSupported()
        Returns whether a node can be dropped on another in the container
        Specified by:
        isDropSupported in interface DnDContainer
        Returns:
        true If drop is supported
      • dropComplete

        public void dropComplete(psdi.webclient.applet.wfcanvas.WorkflowNode sourceNode,
                                 psdi.webclient.applet.wfcanvas.WorkflowNode dropNode)
        Called when one node is dropped over another
        Specified by:
        dropComplete in interface DnDContainer
        Parameters:
        sourceNode - The Node being dragged
        dropNode - The node dropped over
      • clearCursor

        public void clearCursor()
        Clears the container's cursor - this is necessary for the re-written DnD which doesn't use the system handler
        Specified by:
        clearCursor in interface DnDContainer