Class TreeEditor

All Implemented Interfaces:
Serializable, overit.geocall.clipboard.XClip, overit.geocall.marks.MethodExposer, overit.geocall.marks.NameExposer, AjaxableComponent, Badgeable, Hideable, Identified, Tool, overit.geocall.ux.configurability.UIConfigurable, overit.geocall.ux.edm.ModelConfigurable
Direct Known Subclasses:
TemplateJsonTreeEditor, TEProjectTreeView, TreeSelector

@Component public class TreeEditor extends Container implements Hideable, AjaxableComponent, overit.geocall.clipboard.XClip
The class implements the user interface element, that extends Container, and allows the hierarchical display of data through a tree structure, also allowing to compress / expand sub-branches or to modify the structure by adding new nodes, or, again, moving the nodes from one branch to another.
To use this container it is necessary to extend this class implementing the fillNode method, which will contains the logic for generating the html code necessary to render the contents of each node.
See Also:
GCApi:
component
  • Field Details

    • breakChars

      protected static String breakChars
    • _visible

      protected SetPredicate _visible
    • _mode

      protected char _mode
      Defines the editing policies on the individual tree node. e: editing mode, allows to make those operations that changes the tree's structure (cut, paste, delete, etc.) p: preview mode, allow to make operations that doesen't changes the tree's structure 8copy, edit, view, etc.)
    • _changedFrom

      protected Tree _changedFrom
    • _changedTo

      protected Tree _changedTo
    • _t

      protected Tree _t
    • _tInedit

      protected Tree _tInedit
    • _cutting

      protected Tree _cutting
    • _canpaste

      protected boolean _canpaste
    • _xclass

      protected String _xclass
      Filter attribute used in copy and paste and drag and drop actions. We can paste / drop the content only if the origin object has the same xclass of the destination object
    • _border

      protected boolean _border
    • _param

      protected String _param
    • _short

      protected boolean _short
    • _mousebutton

      protected String _mousebutton
    • _tmShort

      protected TaskMessage _tmShort
    • _msgNodeExpand

      protected String _msgNodeExpand
    • _msgNodeCollapse

      protected String _msgNodeCollapse
    • _msgEditTitle

      protected String _msgEditTitle
    • _msgDeleteTitle

      protected String _msgDeleteTitle
    • _msgDeleteMessage

      protected String _msgDeleteMessage
    • _msgCopyTitle

      protected String _msgCopyTitle
    • _msgCutTitle

      protected String _msgCutTitle
    • _msgPasteTitle

      protected String _msgPasteTitle
    • _msgPasteMessage

      protected String _msgPasteMessage
    • _msgInsertBeforeTitle

      protected String _msgInsertBeforeTitle
    • _msgInsertAfterTitle

      protected String _msgInsertAfterTitle
    • _msgInsertChildTitle

      protected String _msgInsertChildTitle
    • _msgInsertParentTitle

      protected String _msgInsertParentTitle
  • Constructor Details

    • TreeEditor

      public TreeEditor()
  • Method Details

    • setup

      protected void setup()
      Description copied from class: Component
      Setup the Component
      Overrides:
      setup in class Component
    • setXCLASS

      public void setXCLASS(String xclass)
      Sets a particular xclass to the TreeEditor; this string is used to limit the operations of copy / cut / paste / drag / drop that can be executed only between objects that have the same xclass attribute. If no value is specified, there aren't restriction imposed; otherwise a value can be pasted / dropped on the TreeEditor only if the source component has the same xclass value
      Parameters:
      xclass - The string that defines the xclass for the element
    • setMOUSEBUTTON

      public void setMOUSEBUTTON(String s)
      Sets wheter to bring up the contextual menu of individual nodes when the user presses the right or left mouse button.
      Parameters:
      s - Possible values are:
      "l": (default value) the contextual menu appears on left click
      "r": the contextual menu appears on right click
    • setMODE

      public void setMODE(String s)
      Sets the editing policies on the individual tree node.
      Parameters:
      s - Possible values are:
      "e": (default value) editing mode, allows to make those operations that changes the tree's structure (cut, paste, delete, etc.)
      "p": preview mode, allow to make operations that doesen't changes the tree's structure 8copy, edit, view, etc.)
    • setPARAM

      public void setPARAM(String s)
      Sets a parameter for the events associated to the TreeEditor (like Edit, Delete, Copy, etc)
      Parameters:
      s - A string that represents the param attribute of the events
    • onOpen

      public void onOpen(Object o)
      Description copied from class: Container
      Method called when is executed the WindowManager.push(overit.geocall.basic.ui.Window, java.lang.Object) of the Window that contains the Container. It calls the onOpen(o) method of all the Container's childrens.
      If a page is opened through the process of a route, it is possible that the route was called with params to pass to the page.
      The route params could be passed specifying them like query string's param on the url, using commas or the '=' character, to separate the keys and the values. Valid syntaxs are: "&params=KEY1,VAL1,KEY2,VAL2" or "&params=KEY1=VAL1,KEY2=VAL2"
      In that case it is possible to retrieve those params via the WindowManager.getRouteParams() method that returns an HashGetter with the params passed as parameters.
      For example it's possible to retrieve and use the params in this way: HashGetter hg = getWM().getRouteParams();
      String val1 = hg.getString("key1",null);
      String val2 = hg.getString("key2",null);
      Overrides:
      onOpen in class Container
      Parameters:
      o - Object received from the caller
    • configureShortMenu

      protected void configureShortMenu()
    • setTree

      public void setTree(Tree t)
      Sets a Tree to the TreeEditor
      Parameters:
      t - The Tree to set
    • getNewNode

      public Tree getNewNode()
      Returns a new node
      Returns:
      A new node, i.e. an empty Tree
    • getNewTree

      public Tree getNewTree()
      Returns a new tree
      Returns:
      An empty Tree
    • getArcDescription

      protected String getArcDescription(Tree tg)
    • getDropDownItem

      @Deprecated protected org.apache.ecs.html.TR getDropDownItem(String event, String param, String icon, String title, String msg, Tree t)
      Deprecated.
      Implements createMenu(tree)
      Parameters:
      event - Implements createMenu(tree)
      param - Implements createMenu(tree)
      icon - Implements createMenu(tree)
      title - Implements createMenu(tree)
      msg - Implements createMenu(tree)
      t - Implements createMenu(tree)
      Returns:
      Implements createMenu(tree)
    • getMenuItem

      @Deprecated protected org.apache.ecs.html.Div getMenuItem(String event, String param, String icon, String title, String msg, Tree t)
      Deprecated.
      The opening of the menu is managed in response to the Ajax OpenMenu event
      Implements createMenu(tree)
      Parameters:
      event - Implements createMenu(tree)
      param - Implements createMenu(tree)
      icon - Implements createMenu(tree)
      title - Implements createMenu(tree)
      msg - Implements createMenu(tree)
      t - Implements createMenu(tree)
      Returns:
      Implements createMenu(tree)
    • getMinusPlusButton

      protected org.apache.ecs.Element getMinusPlusButton(Tree t)
    • getUpDownButton

      protected org.apache.ecs.html.Div getUpDownButton(Tree t)
    • getDropDownT

      @Deprecated protected org.apache.ecs.Element getDropDownT(Tree t)
      Deprecated.
      Parameters:
      t - Use createMenu(tree)
      Returns:
      Use createMenu(tree)
    • getDropDownMenu

      @Deprecated protected org.apache.ecs.html.Table getDropDownMenu(Tree tt)
      Deprecated.
      Implements createMenu(tree)
      Parameters:
      tt - Implements createMenu(tree)
      Returns:
      Implements createMenu(tree)
    • getMenu

      @Deprecated protected org.apache.ecs.html.Div getMenu(Tree t)
      Deprecated.
      Implements createMenu(tree)
      Parameters:
      t - Implements createMenu(tree)
      Returns:
      Implements createMenu(tree)
    • onOpenMenu

      public boolean onOpenMenu(HashGetter hg)
      Opens the contextual menu for the node
      Parameters:
      hg - The HashGetter used to extract the correct node
      Returns:
      true
    • createMenu

      protected Menu createMenu(Tree t)
    • subTree

      protected org.apache.ecs.Element subTree(Tree tree, boolean editable, boolean isFirst, boolean isLast)
    • getCountInfo

      protected org.apache.ecs.Element getCountInfo(Tree t)
    • setOnClickAction

      protected void setOnClickAction(Tree t, org.apache.ecs.html.Div d)
    • fillNode

      protected void fillNode(Tree tg, org.apache.ecs.html.Div d)
    • getTDNodeType

      protected org.apache.ecs.html.TD getTDNodeType(Tree t)
    • getTDAlert

      protected org.apache.ecs.html.TD getTDAlert(Tree t)
    • fillArcDescription

      protected final void fillArcDescription(org.apache.ecs.html.Div dUp, org.apache.ecs.html.Div dDown, Tree t)
    • fillArcDescription

      protected void fillArcDescription(org.apache.ecs.ConcreteElement dUp, org.apache.ecs.ConcreteElement dDown, Tree tg)
    • getChunks

      protected String[] getChunks(String s)
    • spanOnTitle

      protected void spanOnTitle(org.apache.ecs.ConcreteElement e, String s, int maxsize)
    • span2OnTitle

      protected void span2OnTitle(org.apache.ecs.ConcreteElement e1, org.apache.ecs.ConcreteElement e2, String s1, String s2, int maxsize, boolean boldfirst)
    • calcTitle

      protected String calcTitle(String s0, String s1, boolean boldfirst)
    • evidence2

      protected void evidence2(String[] ss, boolean boldfirst)
    • evidence21

      protected void evidence21(String[] ss, String s0, String s1, String s2, boolean breakfirst, boolean boldfirst)
    • bold

      protected String bold(String s)
    • resolveTree

      protected Tree resolveTree(Object o, String field)
    • onDelete

      @Deprecated public boolean onDelete(Object o)
      Deprecated.
      Parameters:
      o - Use onDelete(UIMessage)
      Returns:
      Use onDelete(UIMessage)
    • onDelete

      public boolean onDelete(UIMessage uim)
      Deletes a node from the Tree
      Parameters:
      uim - The UIMessage used to extract the correct node to delete
      Returns:
      false if something is been deleted, true otherwise (if the Tree is null or we try to delete the root)
    • doDelete

      protected boolean doDelete(Tree tree, UIMessage uim)
    • onCopy

      @Deprecated public boolean onCopy(Object o)
      Deprecated.
      Parameters:
      o - Use onCopy(UIMessage)
      Returns:
      Use onCopy(UIMessage)
    • onCopy

      public boolean onCopy(UIMessage uim)
      Makes a copy of a node of the Tree
      Parameters:
      uim - The UIMessage used to extract the correct node to delete
      Returns:
      false if something is been copied, true otherwise (if the Tree is null)
    • doCopy

      protected boolean doCopy(Tree tree, UIMessage uim)
    • onCut

      @Deprecated public boolean onCut(Object o)
      Deprecated.
      Parameters:
      o - Use onCut(UIMessage)
      Returns:
      Use onCut(UIMessage)
    • onCut

      public boolean onCut(UIMessage uim)
      Cuts of a node of the Tree
      Parameters:
      uim - The UIMessage used to extract the correct node to cut
      Returns:
      false if something is been cutted, true otherwise (if the Tree is null or we try to cut the root)
    • doCut

      protected boolean doCut(Tree tree, UIMessage uim)
    • onPaste

      @Deprecated public boolean onPaste(Object o)
      Deprecated.
      Parameters:
      o - Use onPaste(UIMessage)
      Returns:
      Use onPaste(UIMessage)
    • onPaste

      public boolean onPaste(UIMessage uim)
      Pastes a node into the Tree
      Parameters:
      uim - The UIMessage used to extract the correct node to cut
      Returns:
      false if something is been pasted, true otherwise
    • doPaste

      protected boolean doPaste(Tree dest, UIMessage uim)
    • pasteContent

      protected Serializable pasteContent(Tree dest, Serializable s, boolean local)
    • getCutting

      public Tree getCutting()
      Gets the cutting node of the Tree
      Returns:
      The Tree
    • freeClip

      public void freeClip(boolean delete)
      Specified by:
      freeClip in interface overit.geocall.clipboard.XClip
    • onInsertBefore

      public boolean onInsertBefore(Object o)
      Adds a new node (see getNewNode()) before the target one
      Parameters:
      o - The HashGetter used to extract the correct Tree target
      Returns:
      true
    • onInsertAfter

      public boolean onInsertAfter(Object o)
      Adds a new node (see getNewNode()) after the target one
      Parameters:
      o - The HashGetter used to extract the correct Tree target
      Returns:
      true
    • onInsertChild

      public boolean onInsertChild(Object o)
      Adds a new node (see getNewNode()) as a child of the target one
      Parameters:
      o - The HashGetter used to extract the correct Tree target
      Returns:
      true
    • onInsertParent

      public boolean onInsertParent(Object o)
      Adds a new node (see getNewNode()) as parent of the target one
      Parameters:
      o - The HashGetter used to extract the correct Tree target
      Returns:
      true
    • onCancel

      public boolean onCancel(Object o)
    • onMinus

      public boolean onMinus(Object o)
      Compresses the childs of the node so that in visualization the node appears with no childs
      Parameters:
      o - The HashGetter used to extract the correct node
      Returns:
      true
    • onPlus

      public boolean onPlus(Object o)
      Expands the childs of the node prviously compressed
      Parameters:
      o - The HashGetter used to extract the correct node
      Returns:
      true
    • onUp

      public boolean onUp(Object o)
      Compresses the parents of the node so that in visualization the node is positioned as root
      Parameters:
      o - The HashGetter used to extract the correct node
      Returns:
      true
    • onDown

      public boolean onDown(Object o)
      Expands the parents of the node previously compressed
      Parameters:
      o - The HashGetter used to extract the correct node
      Returns:
      true
    • getAlert

      protected String getAlert(Tree tg)
    • onClose

      public boolean onClose(Object o)
      Pops the TreeEditor page and returns null to the restored page
      Parameters:
      o - Not used
      Returns:
      true
    • onAccept

      public boolean onAccept(Object o)
      Node acceptance event; if the node ad a not valid definition, it shows an Alert (see getTreeAlert())
      Parameters:
      o - Not used
      Returns:
      true
    • getTreeAlert

      public String getTreeAlert(Tree tg)
      Returns the string used in the Alert (see onAccept()) when the node has a not valid definition
      Parameters:
      tg - The Tree
      Returns:
      The string or null
    • getTree

      public Tree getTree()
      Returns the Tree of the TreeEditor
      Returns:
      The Tree managed by the TreeEditor
    • onBorder

      public boolean onBorder(Object o)
      Switches the value for the border attribute
      Parameters:
      o - Not used
      Returns:
      true
    • onShort

      public boolean onShort(Object o)
      Switches the value for showing the short versione of the contextual node's menu
      Parameters:
      o - Not used
      Returns:
      true
    • isVisible

      public boolean isVisible()
      Checks if the TreeEditor is rendered for the user currently logged in the application, or not (see getBoolean(visible,id,true))
      Specified by:
      isVisible in interface Hideable
      Returns:
      true if the editor is visible, false otherwise
    • setVISIBLE

      public void setVISIBLE(String s)
      Defines if the TreeEditor should be rendered or not
      Specified by:
      setVISIBLE in interface Hideable
      Parameters:
      s - A string that represents a boolean value ("true" or "1", "false" or "0") or a function.
      If the string is not recognized as a boolean value, it is considered as a user function with this meaning: if the user currently logged in the application has the function, the table will be rendered, otherwise it will not
    • changedSubTree

      protected void changedSubTree(Tree t)
    • changedSubTree

      protected void changedSubTree(Tree from, Tree to)
    • calcFrameId

      public String calcFrameId()
      Calculates the frame id.
      Returns:
      String containing the frame id
    • changed

      public void changed(overit.geocall.ux.servlet.processor.Change change)
      Defines the morphing of the TreeEditor element that occurs when there is an Ajax interaction
      Implements the AjaxableComponent interface.
      Specified by:
      changed in interface AjaxableComponent
      Parameters:
      change - The Change object that defines the specific morphing type for the TreeEditor
    • getDefaultChange

      public overit.geocall.ux.servlet.processor.Change getDefaultChange()
      Defines the default Change object for the TreeEditor.
      Implements the AjaxableComponent interface.
      Specified by:
      getDefaultChange in interface AjaxableComponent
      Returns:
      The default Change object that defines the default morphing type of the TreeEditor
    • getHtml

      public org.apache.ecs.Element getHtml(EntitySet es)
      Returns the html code of the TreeEditor
      Overrides:
      getHtml in class Container
      Parameters:
      es - Not used - The EntitySet to which the element belongs
      Returns:
      The html code of the TreeEditor
    • getFrameHtml

      public org.apache.ecs.Element getFrameHtml(overit.geocall.ux.servlet.processor.Change change, EntitySet es)
      Defines the html part of the TreeEditor that changes when an Ajax interaction occurs.
      Implements the AjaxableComponent interface.
      Specified by:
      getFrameHtml in interface AjaxableComponent
      Parameters:
      change - The Change object that defines the specific morphing type for the TreeEditor
      es - Not used - The EntitySet to which the element belongs
      Returns:
      The html part of the TreeEditor that changes when an Ajax interaction occurs
    • applyFilterToChildren

      protected boolean applyFilterToChildren()
      Extends the method, making it returns true, to enable the evaluation of the method Tree.isFiltered() during the html code generation of the sub-tree
      Returns:
      false