Merge branch 'upstream-sep2019-sfix' into subtree
authorNiki Roo <niki@nikiroo.be>
Mon, 30 Dec 2019 16:32:32 +0000 (17:32 +0100)
committerNiki Roo <niki@nikiroo.be>
Mon, 30 Dec 2019 16:32:32 +0000 (17:32 +0100)
1  2 
TWidget.java

diff --combined TWidget.java
index eb06175092d9a8dcd53c20a4d8e75b856d200967,e11a947687027b4da7de59b10d51f1542ea54342..f643f83c550c161dcf338a4a43935903fce6e444
@@@ -184,7 -184,14 +184,7 @@@ public abstract class TWidget implement
       * @param enabled if true assume enabled
       */
      protected TWidget(final TWidget parent, final boolean enabled) {
 -        this.enabled = enabled;
 -        this.parent = parent;
 -        children = new ArrayList<TWidget>();
 -
 -        if (parent != null) {
 -            this.window = parent.window;
 -            parent.addChild(this);
 -        }
 +        this(parent, enabled, 0, 0, 0, 0);
      }
  
      /**
       * @return difference between this.tabOrder and that.tabOrder, or
       * difference between this.z and that.z, or String.compareTo(text)
       */
 +    @Override
      public final int compareTo(final TWidget that) {
          if ((this instanceof TWindow)
              && (that instanceof TWindow)
       *
       * @param child TWidget to add
       */
-     private void addChild(final TWidget child) {
+     public void addChild(final TWidget child) {
          children.add(child);
  
          if ((child.enabled)
              children.get(i).tabOrder = i;
          }
      }
 +    
 +    /**
 +     * Remove and {@link TWidget#close()} the given child from this {@link TWidget}.
 +     * <p>
 +     * Will also reorder the tab values of the remaining children.
 +     * 
 +     * @param child the child to remove
 +     * 
 +     * @return TRUE if the child was removed, FALSE if it was not found
 +     */
 +    public boolean removeChild(final TWidget child) {
 +        if (children.remove(child)) {
 +                child.close();
 +                child.parent = null;
 +                child.window = null;
 +                
 +                resetTabOrder();
 +                
 +                return true;
 +        }
 +        
 +        return false;
 +    }
  
      /**
       * Switch the active child.