Пример #1
0
    @Override
    public void dockableRemoved(DockStation station, Dockable dockable) {
      if (dockable.getDockParent() != null && dockable.getDockParent() != station) {
        throw new IllegalStateException(
            "the parent of dockable is wrong: it is neither null nor '" + station + "'");
      }
      dockable.setDockParent(null);

      DockStation asStation = dockable.asDockStation();
      if (asStation != null) {
        asStation.removeDockStationListener(StationListener.this);
      }

      if (stalled == 0) {
        removeDockable(dockable);
      }
    }
 /**
  * Tells which children to show and which not. This method is called with all children (direct and
  * indirect) of the station. The default behavior is to return <code>true</code> for any direct
  * child or <code>true</code> if the monitored dockable is no station at all.
  *
  * @param dockable the child to check
  * @return <code>true</code> if there should be a button, <code>false</code> otherwise
  */
 protected boolean shouldShow(Dockable dockable) {
   if (dockable.getDockParent() == getDockable().asDockStation()) {
     return true;
   }
   if (dockable == getDockable() && dockable.asDockStation() == null) {
     return true;
   }
   return false;
 }
Пример #3
0
  /**
   * Gets a list of stations which have no parent and are therefore the roots of the dock-trees.
   *
   * @return the roots
   */
  public DockStation[] listRoots() {
    List<DockStation> list = new LinkedList<DockStation>();
    for (DockStation station : stations) {
      Dockable dockable = station.asDockable();
      if (dockable == null || dockable.getDockParent() == null) list.add(station);
    }

    return list.toArray(new DockStation[list.size()]);
  }
 public void hierarchyChanged(DockHierarchyEvent event) {
   if (bound > 0) {
     if (parent != null) {
       parent.removeDockStationListener(adapter);
     }
     parent = dockable.getDockParent();
     if (parent != null) {
       parent.addDockStationListener(adapter);
     }
     checkState();
   }
 }
    private void checkState() {
      if (!onChange) {
        try {
          onChange = true;

          DockStation parent = dockable.getDockParent();
          boolean select = false;

          if (parent != null) {
            select = parent.isChildShowing(dockable) && parent.getFrontDockable() == dockable;
          }

          setSelected(select);
        } finally {
          onChange = false;
        }
      }
    }
Пример #6
0
  /**
   * Removes a station which was managed by this register.
   *
   * @param station the station to remove
   */
  public void remove(DockStation station) {
    if (stations.contains(station)) {
      setProtected(station, false);
      Dockable dock = station.asDockable();
      if (dock != null) {
        DockStation parent = dock.getDockParent();
        if (parent != null) parent.drag(dock);
      }

      DockUtilities.visit(
          station,
          new DockUtilities.DockVisitor() {
            private Set<DockStation> ignored = new HashSet<DockStation>();

            @Override
            public void handleDockable(Dockable dockable) {
              DockStation station = dockable.asDockStation();
              if (station == null || !isProtected(station)) {
                for (DockStation parent : ignored) {
                  if (DockUtilities.isAncestor(parent, dockable)) {
                    return;
                  }
                }
                unregister(dockable);
              }
            }

            @Override
            public void handleDockStation(DockStation station) {
              if (isProtected(station)) {
                ignored.add(station);
              } else {
                unregister(station);
              }
            }
          });
    }
  }
    private void checkDockable() {
      if (!onChange) {
        try {
          onChange = true;

          if (isSelected()) {
            DockController controller = dockable.getController();
            if (controller != null) {
              controller.setFocusedDockable(dockable, null, true, true, true);
            }
          } else {
            DockStation parent = this.parent;
            Dockable dockable = this.dockable;

            DockStation finalParent = StationChildrenActionSource.this.dockable.getDockParent();

            while (parent != null) {
              if (parent.getFrontDockable() == dockable) {
                parent.setFrontDockable(null);
              }
              if (parent == finalParent) {
                parent = null;
              } else {
                dockable = parent.asDockable();
                if (dockable != null) {
                  parent = dockable.getDockParent();
                } else {
                  parent = null;
                }
              }
            }
          }
        } finally {
          onChange = false;
        }
      }
    }