Class NewClassTree

All Implemented Interfaces:
DropTargetListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Scrollable

public class NewClassTree extends JTree implements DropTargetListener
Object of this class is created when user wishes to create a new Storable Class.

DropTargetListner is implemented by this class (i.e this class is the target for the drag and drop process). Fields can be dragged from Class Browser, Field Browser and dropped on this new class. Before accepting the dropped field, all kind of validations are made and the element is added only when the field gets cleared by all validations.

Some of the validations that are made in this class are

  1. Substructs cannot be added to base class.
  2. Sub-Classes can only have sub-structs and arrays.
  3. Fields can only be added to base class, array and sub-structs.
  4. Portal allows only up to 2 level deep of array or substruct.
  5. Existence of field in the current class.

See Also:
  • Field Details

  • Constructor Details

    • NewClassTree

      public NewClassTree(DDClass rootClass, DataDictionary dataDictionary) throws EBufException
      Constructor
      Parameters:
      rootClass - A DDClass object which is getting created by the user as a new storable class. FList for this DDClass is converted to JTree component and is displayed inside JInternal Frame.
      dataDictionary - Object of DataDictionary which know all about Portal.
      Throws:
      EBufException - JAVAPCM API's EBufException is thrown
  • Method Details

    • isUnKnownField

      protected boolean isUnKnownField(DDClassField classFieldObj) throws EBufException
      Verifies whether the passed in field is of type FIELD_NOT_FOUND_DB This situation shall arise when user is trying to open *.sce file in which some of the custom defined fields are missing in the current data-base. It will happen because the *.sce file was created using different data-base.
      Parameters:
      fieldObj - DDClassField object that is to checked for the "FIELD_NOT_FOUND_DB" type.
      Returns:
      Returns true if the passed in field is of type "FIELD_NOT_FOUND_DB" and false otherwise.
      Throws:
      EBufException
    • unKnownFieldsDetected

      public boolean unKnownFieldsDetected()
      Returns:
      Returns true if any unknown fields were detected and false otherwise.
    • isArrayOrSubstruct

      protected boolean isArrayOrSubstruct(DDClassField fieldObj)
      Varifies weather the passed in parameter is an Array or a Sub-Struct .
      Parameters:
      fieldObj - DDClassField object that is to checked weather it is an array or a substruct.
      Returns:
      Returns true if the passed in parameter is an array or substruct; false otherwise.
    • isAnArray

      protected boolean isAnArray(DDClassField fldObj)
      Verifies wheather the passed in parameter is an Array
      Parameters:
      fieldObj - DDClassField object that is to checked weather it is an array
      Returns:
      Returns true if the passed in parameter is an array; false otherwise.
    • isASubstruct

      protected boolean isASubstruct(DDClassField fldObj)
      Verifies wheather the passed in parameter is a Substruct
      Parameters:
      fieldObj - DDClassField object that is to checked weather it is a Substruct
      Returns:
      Returns true if the passed in parameter is a Substruct; false otherwise.
    • createNodes

      public void createNodes(DefaultMutableTreeNode top)
      Creates the DefaultMutableTreeNode
      Parameters:
      top - DefaultMutableTreeNode that is to be created.
    • expandAndSelect

      public TreePath expandAndSelect(String nameToFind)
      Attempts to locate the tree node representing the given field passed in. If found, that node will be expanded and selected. You can retrieve the actual DDClassField for the expanded node via the getUserObject() method on the last path component in the returned TreePath.
      Parameters:
      nameToFind - The field
      Returns:
      The TreePath to the node representing the storable class; null if not found.
    • dragEnter

      public void dragEnter(DropTargetDragEvent event)
      Is invoked when you are dragging over the DropSite
      Specified by:
      dragEnter in interface DropTargetListener
      Parameters:
      event - Event causing drag
    • dragOver

      public void dragOver(DropTargetDragEvent event)
      Is invoked when a drag operation is going on
      Specified by:
      dragOver in interface DropTargetListener
      Parameters:
      event - Event causing drag
    • drop

      public void drop(DropTargetDropEvent event)
      A drop has occurred. This the method which does all sorts of validations before the element is added to the JTree of DDClass .
      Specified by:
      drop in interface DropTargetListener
      Parameters:
      event - Event causing drag
    • drop

      public boolean drop(Transferable data)
      Add a dropped object to the tree.
      Parameters:
      data - dropped object.
      Returns:
      true if the object was dropped / pasted successfully.
    • dragExit

      public void dragExit(DropTargetEvent event)
      Is invoked when you are exit the DropSite without dropping
      Specified by:
      dragExit in interface DropTargetListener
      Parameters:
      event - Event causing Drag.
    • dropActionChanged

      public void dropActionChanged(DropTargetDragEvent event)
      Is invoked if the use modifies the current drop gesture
      Specified by:
      dropActionChanged in interface DropTargetListener
      Parameters:
      event - Event causing Drag.
    • changeSelection

      protected void changeSelection(DefaultMutableTreeNode child)
      Changes the selection of the JTree to the passed in parameter
      Parameters:
      child - Its a DefaultMutableTreeNode to which the selection is to be changed.
    • addArrayElementsToTree

      protected void addArrayElementsToTree(DDClassField obj) throws EBufException
      Adds the elements within the array of the passed in DDClassField to JTree
      Parameters:
      obj - Object of DDClassField whose elements are to be added as nodes to JTree
      Throws:
      EBufException - JAVAPCM's exception is thrown.
    • addArrayElementsToTree

      protected void addArrayElementsToTree(DefaultMutableTreeNode parent, DDClassField obj) throws EBufException
      Adds the elements within the array of the passed in DDClassField to JTree Called When FList is read from the file and Tree is built Or When an existing storable class is opened for modifications by double-clicking on the class in the class-browser.
      Parameters:
      parent - A DefaultMutableTreeNode to which the elements are to be added.
      obj - Object of DDClassField whose elements are to be added as nodes to JTree
      Throws:
      EBufException - JAVAPCM's exception is thrown.
    • removeElement

      public void removeElement(DefaultMutableTreeNode nodeToBeDeleted)
      Removes an element from storable class and update Flist of DDClass and DDClassField .
      Parameters:
      nodeToBeDeleted - A DefaultMutableTreeNode that is be removed from JTress
    • isNodeRemovable

      protected boolean isNodeRemovable(DefaultMutableTreeNode node)
      Varifies whether the node can be deleted from the current DDClass .
      Parameters:
      node - DefaultMutableTreeNode that is to be removed or deleted from the DDClass .
      Returns:
      Returns true if the node is removable; False otherwise.
    • isThisASubClass

      public boolean isThisASubClass()
      Varifies weather this DDClass is a subclass or not.
      Returns:
      Returns true if this DDClass is a subclass; False otherwise.
    • canDrop

      public boolean canDrop()
      Check if the currently selected item can be dropped into.
      Returns:
      true if a valid drop target is selected.